1 | var Vue = (function (exports) {
|
2 | 'use strict';
|
3 |
|
4 | |
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function makeMap(str, expectsLowerCase) {
|
12 | const map = Object.create(null);
|
13 | const list = str.split(',');
|
14 | for (let i = 0; i < list.length; i++) {
|
15 | map[list[i]] = true;
|
16 | }
|
17 | return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
|
18 | }
|
19 |
|
20 | |
21 |
|
22 |
|
23 | const PatchFlagNames = {
|
24 | [1 ]: `TEXT`,
|
25 | [2 ]: `CLASS`,
|
26 | [4 ]: `STYLE`,
|
27 | [8 ]: `PROPS`,
|
28 | [16 ]: `FULL_PROPS`,
|
29 | [32 ]: `HYDRATE_EVENTS`,
|
30 | [64 ]: `STABLE_FRAGMENT`,
|
31 | [128 ]: `KEYED_FRAGMENT`,
|
32 | [256 ]: `UNKEYED_FRAGMENT`,
|
33 | [512 ]: `NEED_PATCH`,
|
34 | [1024 ]: `DYNAMIC_SLOTS`,
|
35 | [2048 ]: `DEV_ROOT_FRAGMENT`,
|
36 | [-1 ]: `HOISTED`,
|
37 | [-2 ]: `BAIL`
|
38 | };
|
39 |
|
40 | |
41 |
|
42 |
|
43 | const slotFlagsText = {
|
44 | [1 ]: 'STABLE',
|
45 | [2 ]: 'DYNAMIC',
|
46 | [3 ]: 'FORWARDED'
|
47 | };
|
48 |
|
49 | const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
|
50 | 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
|
51 | 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
|
52 | const isGloballyWhitelisted = makeMap(GLOBALS_WHITE_LISTED);
|
53 |
|
54 | const range = 2;
|
55 | function generateCodeFrame(source, start = 0, end = source.length) {
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | let lines = source.split(/(\r?\n)/);
|
61 |
|
62 | const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
63 | lines = lines.filter((_, idx) => idx % 2 === 0);
|
64 | let count = 0;
|
65 | const res = [];
|
66 | for (let i = 0; i < lines.length; i++) {
|
67 | count +=
|
68 | lines[i].length +
|
69 | ((newlineSequences[i] && newlineSequences[i].length) || 0);
|
70 | if (count >= start) {
|
71 | for (let j = i - range; j <= i + range || end > count; j++) {
|
72 | if (j < 0 || j >= lines.length)
|
73 | continue;
|
74 | const line = j + 1;
|
75 | res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
76 | const lineLength = lines[j].length;
|
77 | const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
|
78 | if (j === i) {
|
79 |
|
80 | const pad = start - (count - (lineLength + newLineSeqLength));
|
81 | const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
82 | res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
83 | }
|
84 | else if (j > i) {
|
85 | if (end > count) {
|
86 | const length = Math.max(Math.min(end - count, lineLength), 1);
|
87 | res.push(` | ` + '^'.repeat(length));
|
88 | }
|
89 | count += lineLength + newLineSeqLength;
|
90 | }
|
91 | }
|
92 | break;
|
93 | }
|
94 | }
|
95 | return res.join('\n');
|
96 | }
|
97 |
|
98 | |
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
110 | const isSpecialBooleanAttr = makeMap(specialBooleanAttrs);
|
111 | |
112 |
|
113 |
|
114 |
|
115 | function includeBooleanAttr(value) {
|
116 | return !!value || value === '';
|
117 | }
|
118 |
|
119 | function normalizeStyle(value) {
|
120 | if (isArray(value)) {
|
121 | const res = {};
|
122 | for (let i = 0; i < value.length; i++) {
|
123 | const item = value[i];
|
124 | const normalized = isString(item)
|
125 | ? parseStringStyle(item)
|
126 | : normalizeStyle(item);
|
127 | if (normalized) {
|
128 | for (const key in normalized) {
|
129 | res[key] = normalized[key];
|
130 | }
|
131 | }
|
132 | }
|
133 | return res;
|
134 | }
|
135 | else if (isString(value)) {
|
136 | return value;
|
137 | }
|
138 | else if (isObject(value)) {
|
139 | return value;
|
140 | }
|
141 | }
|
142 | const listDelimiterRE = /;(?![^(]*\))/g;
|
143 | const propertyDelimiterRE = /:(.+)/;
|
144 | function parseStringStyle(cssText) {
|
145 | const ret = {};
|
146 | cssText.split(listDelimiterRE).forEach(item => {
|
147 | if (item) {
|
148 | const tmp = item.split(propertyDelimiterRE);
|
149 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
150 | }
|
151 | });
|
152 | return ret;
|
153 | }
|
154 | function normalizeClass(value) {
|
155 | let res = '';
|
156 | if (isString(value)) {
|
157 | res = value;
|
158 | }
|
159 | else if (isArray(value)) {
|
160 | for (let i = 0; i < value.length; i++) {
|
161 | const normalized = normalizeClass(value[i]);
|
162 | if (normalized) {
|
163 | res += normalized + ' ';
|
164 | }
|
165 | }
|
166 | }
|
167 | else if (isObject(value)) {
|
168 | for (const name in value) {
|
169 | if (value[name]) {
|
170 | res += name + ' ';
|
171 | }
|
172 | }
|
173 | }
|
174 | return res.trim();
|
175 | }
|
176 | function normalizeProps(props) {
|
177 | if (!props)
|
178 | return null;
|
179 | let { class: klass, style } = props;
|
180 | if (klass && !isString(klass)) {
|
181 | props.class = normalizeClass(klass);
|
182 | }
|
183 | if (style) {
|
184 | props.style = normalizeStyle(style);
|
185 | }
|
186 | return props;
|
187 | }
|
188 |
|
189 |
|
190 |
|
191 | const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
|
192 | 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
|
193 | 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
|
194 | 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
|
195 | 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
|
196 | 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
|
197 | 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
|
198 | 'option,output,progress,select,textarea,details,dialog,menu,' +
|
199 | 'summary,template,blockquote,iframe,tfoot';
|
200 |
|
201 | const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
|
202 | 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
|
203 | 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
|
204 | 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
|
205 | 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
|
206 | 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
|
207 | 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
|
208 | 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
|
209 | 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
|
210 | 'text,textPath,title,tspan,unknown,use,view';
|
211 | const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
|
212 | const isHTMLTag = makeMap(HTML_TAGS);
|
213 | const isSVGTag = makeMap(SVG_TAGS);
|
214 | const isVoidTag = makeMap(VOID_TAGS);
|
215 |
|
216 | function looseCompareArrays(a, b) {
|
217 | if (a.length !== b.length)
|
218 | return false;
|
219 | let equal = true;
|
220 | for (let i = 0; equal && i < a.length; i++) {
|
221 | equal = looseEqual(a[i], b[i]);
|
222 | }
|
223 | return equal;
|
224 | }
|
225 | function looseEqual(a, b) {
|
226 | if (a === b)
|
227 | return true;
|
228 | let aValidType = isDate(a);
|
229 | let bValidType = isDate(b);
|
230 | if (aValidType || bValidType) {
|
231 | return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
232 | }
|
233 | aValidType = isArray(a);
|
234 | bValidType = isArray(b);
|
235 | if (aValidType || bValidType) {
|
236 | return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
237 | }
|
238 | aValidType = isObject(a);
|
239 | bValidType = isObject(b);
|
240 | if (aValidType || bValidType) {
|
241 |
|
242 | if (!aValidType || !bValidType) {
|
243 | return false;
|
244 | }
|
245 | const aKeysCount = Object.keys(a).length;
|
246 | const bKeysCount = Object.keys(b).length;
|
247 | if (aKeysCount !== bKeysCount) {
|
248 | return false;
|
249 | }
|
250 | for (const key in a) {
|
251 | const aHasKey = a.hasOwnProperty(key);
|
252 | const bHasKey = b.hasOwnProperty(key);
|
253 | if ((aHasKey && !bHasKey) ||
|
254 | (!aHasKey && bHasKey) ||
|
255 | !looseEqual(a[key], b[key])) {
|
256 | return false;
|
257 | }
|
258 | }
|
259 | }
|
260 | return String(a) === String(b);
|
261 | }
|
262 | function looseIndexOf(arr, val) {
|
263 | return arr.findIndex(item => looseEqual(item, val));
|
264 | }
|
265 |
|
266 | |
267 |
|
268 |
|
269 |
|
270 | const toDisplayString = (val) => {
|
271 | return val == null
|
272 | ? ''
|
273 | : isArray(val) ||
|
274 | (isObject(val) &&
|
275 | (val.toString === objectToString || !isFunction(val.toString)))
|
276 | ? JSON.stringify(val, replacer, 2)
|
277 | : String(val);
|
278 | };
|
279 | const replacer = (_key, val) => {
|
280 |
|
281 | if (val && val.__v_isRef) {
|
282 | return replacer(_key, val.value);
|
283 | }
|
284 | else if (isMap(val)) {
|
285 | return {
|
286 | [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
|
287 | entries[`${key} =>`] = val;
|
288 | return entries;
|
289 | }, {})
|
290 | };
|
291 | }
|
292 | else if (isSet(val)) {
|
293 | return {
|
294 | [`Set(${val.size})`]: [...val.values()]
|
295 | };
|
296 | }
|
297 | else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
|
298 | return String(val);
|
299 | }
|
300 | return val;
|
301 | };
|
302 |
|
303 | const EMPTY_OBJ = Object.freeze({})
|
304 | ;
|
305 | const EMPTY_ARR = Object.freeze([]) ;
|
306 | const NOOP = () => { };
|
307 | |
308 |
|
309 |
|
310 | const NO = () => false;
|
311 | const onRE = /^on[^a-z]/;
|
312 | const isOn = (key) => onRE.test(key);
|
313 | const isModelListener = (key) => key.startsWith('onUpdate:');
|
314 | const extend = Object.assign;
|
315 | const remove = (arr, el) => {
|
316 | const i = arr.indexOf(el);
|
317 | if (i > -1) {
|
318 | arr.splice(i, 1);
|
319 | }
|
320 | };
|
321 | const hasOwnProperty = Object.prototype.hasOwnProperty;
|
322 | const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
323 | const isArray = Array.isArray;
|
324 | const isMap = (val) => toTypeString(val) === '[object Map]';
|
325 | const isSet = (val) => toTypeString(val) === '[object Set]';
|
326 | const isDate = (val) => val instanceof Date;
|
327 | const isFunction = (val) => typeof val === 'function';
|
328 | const isString = (val) => typeof val === 'string';
|
329 | const isSymbol = (val) => typeof val === 'symbol';
|
330 | const isObject = (val) => val !== null && typeof val === 'object';
|
331 | const isPromise = (val) => {
|
332 | return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
333 | };
|
334 | const objectToString = Object.prototype.toString;
|
335 | const toTypeString = (value) => objectToString.call(value);
|
336 | const toRawType = (value) => {
|
337 |
|
338 | return toTypeString(value).slice(8, -1);
|
339 | };
|
340 | const isPlainObject = (val) => toTypeString(val) === '[object Object]';
|
341 | const isIntegerKey = (key) => isString(key) &&
|
342 | key !== 'NaN' &&
|
343 | key[0] !== '-' &&
|
344 | '' + parseInt(key, 10) === key;
|
345 | const isReservedProp = makeMap(
|
346 |
|
347 | ',key,ref,' +
|
348 | 'onVnodeBeforeMount,onVnodeMounted,' +
|
349 | 'onVnodeBeforeUpdate,onVnodeUpdated,' +
|
350 | 'onVnodeBeforeUnmount,onVnodeUnmounted');
|
351 | const cacheStringFunction = (fn) => {
|
352 | const cache = Object.create(null);
|
353 | return ((str) => {
|
354 | const hit = cache[str];
|
355 | return hit || (cache[str] = fn(str));
|
356 | });
|
357 | };
|
358 | const camelizeRE = /-(\w)/g;
|
359 | |
360 |
|
361 |
|
362 | const camelize = cacheStringFunction((str) => {
|
363 | return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
|
364 | });
|
365 | const hyphenateRE = /\B([A-Z])/g;
|
366 | |
367 |
|
368 |
|
369 | const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
|
370 | |
371 |
|
372 |
|
373 | const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
374 | |
375 |
|
376 |
|
377 | const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
|
378 |
|
379 | const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
380 | const invokeArrayFns = (fns, arg) => {
|
381 | for (let i = 0; i < fns.length; i++) {
|
382 | fns[i](arg);
|
383 | }
|
384 | };
|
385 | const def = (obj, key, value) => {
|
386 | Object.defineProperty(obj, key, {
|
387 | configurable: true,
|
388 | enumerable: false,
|
389 | value
|
390 | });
|
391 | };
|
392 | const toNumber = (val) => {
|
393 | const n = parseFloat(val);
|
394 | return isNaN(n) ? val : n;
|
395 | };
|
396 | let _globalThis;
|
397 | const getGlobalThis = () => {
|
398 | return (_globalThis ||
|
399 | (_globalThis =
|
400 | typeof globalThis !== 'undefined'
|
401 | ? globalThis
|
402 | : typeof self !== 'undefined'
|
403 | ? self
|
404 | : typeof window !== 'undefined'
|
405 | ? window
|
406 | : typeof global !== 'undefined'
|
407 | ? global
|
408 | : {}));
|
409 | };
|
410 |
|
411 | function warn(msg, ...args) {
|
412 | console.warn(`[Vue warn] ${msg}`, ...args);
|
413 | }
|
414 |
|
415 | let activeEffectScope;
|
416 | const effectScopeStack = [];
|
417 | class EffectScope {
|
418 | constructor(detached = false) {
|
419 | this.active = true;
|
420 | this.effects = [];
|
421 | this.cleanups = [];
|
422 | if (!detached && activeEffectScope) {
|
423 | this.parent = activeEffectScope;
|
424 | this.index =
|
425 | (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
426 | }
|
427 | }
|
428 | run(fn) {
|
429 | if (this.active) {
|
430 | try {
|
431 | this.on();
|
432 | return fn();
|
433 | }
|
434 | finally {
|
435 | this.off();
|
436 | }
|
437 | }
|
438 | else {
|
439 | warn(`cannot run an inactive effect scope.`);
|
440 | }
|
441 | }
|
442 | on() {
|
443 | if (this.active) {
|
444 | effectScopeStack.push(this);
|
445 | activeEffectScope = this;
|
446 | }
|
447 | }
|
448 | off() {
|
449 | if (this.active) {
|
450 | effectScopeStack.pop();
|
451 | activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
|
452 | }
|
453 | }
|
454 | stop(fromParent) {
|
455 | if (this.active) {
|
456 | this.effects.forEach(e => e.stop());
|
457 | this.cleanups.forEach(cleanup => cleanup());
|
458 | if (this.scopes) {
|
459 | this.scopes.forEach(e => e.stop(true));
|
460 | }
|
461 |
|
462 | if (this.parent && !fromParent) {
|
463 |
|
464 | const last = this.parent.scopes.pop();
|
465 | if (last && last !== this) {
|
466 | this.parent.scopes[this.index] = last;
|
467 | last.index = this.index;
|
468 | }
|
469 | }
|
470 | this.active = false;
|
471 | }
|
472 | }
|
473 | }
|
474 | function effectScope(detached) {
|
475 | return new EffectScope(detached);
|
476 | }
|
477 | function recordEffectScope(effect, scope) {
|
478 | scope = scope || activeEffectScope;
|
479 | if (scope && scope.active) {
|
480 | scope.effects.push(effect);
|
481 | }
|
482 | }
|
483 | function getCurrentScope() {
|
484 | return activeEffectScope;
|
485 | }
|
486 | function onScopeDispose(fn) {
|
487 | if (activeEffectScope) {
|
488 | activeEffectScope.cleanups.push(fn);
|
489 | }
|
490 | else {
|
491 | warn(`onScopeDispose() is called when there is no active effect scope` +
|
492 | ` to be associated with.`);
|
493 | }
|
494 | }
|
495 |
|
496 | const createDep = (effects) => {
|
497 | const dep = new Set(effects);
|
498 | dep.w = 0;
|
499 | dep.n = 0;
|
500 | return dep;
|
501 | };
|
502 | const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
|
503 | const newTracked = (dep) => (dep.n & trackOpBit) > 0;
|
504 | const initDepMarkers = ({ deps }) => {
|
505 | if (deps.length) {
|
506 | for (let i = 0; i < deps.length; i++) {
|
507 | deps[i].w |= trackOpBit;
|
508 | }
|
509 | }
|
510 | };
|
511 | const finalizeDepMarkers = (effect) => {
|
512 | const { deps } = effect;
|
513 | if (deps.length) {
|
514 | let ptr = 0;
|
515 | for (let i = 0; i < deps.length; i++) {
|
516 | const dep = deps[i];
|
517 | if (wasTracked(dep) && !newTracked(dep)) {
|
518 | dep.delete(effect);
|
519 | }
|
520 | else {
|
521 | deps[ptr++] = dep;
|
522 | }
|
523 |
|
524 | dep.w &= ~trackOpBit;
|
525 | dep.n &= ~trackOpBit;
|
526 | }
|
527 | deps.length = ptr;
|
528 | }
|
529 | };
|
530 |
|
531 | const targetMap = new WeakMap();
|
532 |
|
533 | let effectTrackDepth = 0;
|
534 | let trackOpBit = 1;
|
535 | |
536 |
|
537 |
|
538 |
|
539 |
|
540 | const maxMarkerBits = 30;
|
541 | const effectStack = [];
|
542 | let activeEffect;
|
543 | const ITERATE_KEY = Symbol('iterate' );
|
544 | const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
|
545 | class ReactiveEffect {
|
546 | constructor(fn, scheduler = null, scope) {
|
547 | this.fn = fn;
|
548 | this.scheduler = scheduler;
|
549 | this.active = true;
|
550 | this.deps = [];
|
551 | recordEffectScope(this, scope);
|
552 | }
|
553 | run() {
|
554 | if (!this.active) {
|
555 | return this.fn();
|
556 | }
|
557 | if (!effectStack.includes(this)) {
|
558 | try {
|
559 | effectStack.push((activeEffect = this));
|
560 | enableTracking();
|
561 | trackOpBit = 1 << ++effectTrackDepth;
|
562 | if (effectTrackDepth <= maxMarkerBits) {
|
563 | initDepMarkers(this);
|
564 | }
|
565 | else {
|
566 | cleanupEffect(this);
|
567 | }
|
568 | return this.fn();
|
569 | }
|
570 | finally {
|
571 | if (effectTrackDepth <= maxMarkerBits) {
|
572 | finalizeDepMarkers(this);
|
573 | }
|
574 | trackOpBit = 1 << --effectTrackDepth;
|
575 | resetTracking();
|
576 | effectStack.pop();
|
577 | const n = effectStack.length;
|
578 | activeEffect = n > 0 ? effectStack[n - 1] : undefined;
|
579 | }
|
580 | }
|
581 | }
|
582 | stop() {
|
583 | if (this.active) {
|
584 | cleanupEffect(this);
|
585 | if (this.onStop) {
|
586 | this.onStop();
|
587 | }
|
588 | this.active = false;
|
589 | }
|
590 | }
|
591 | }
|
592 | function cleanupEffect(effect) {
|
593 | const { deps } = effect;
|
594 | if (deps.length) {
|
595 | for (let i = 0; i < deps.length; i++) {
|
596 | deps[i].delete(effect);
|
597 | }
|
598 | deps.length = 0;
|
599 | }
|
600 | }
|
601 | function effect(fn, options) {
|
602 | if (fn.effect) {
|
603 | fn = fn.effect.fn;
|
604 | }
|
605 | const _effect = new ReactiveEffect(fn);
|
606 | if (options) {
|
607 | extend(_effect, options);
|
608 | if (options.scope)
|
609 | recordEffectScope(_effect, options.scope);
|
610 | }
|
611 | if (!options || !options.lazy) {
|
612 | _effect.run();
|
613 | }
|
614 | const runner = _effect.run.bind(_effect);
|
615 | runner.effect = _effect;
|
616 | return runner;
|
617 | }
|
618 | function stop(runner) {
|
619 | runner.effect.stop();
|
620 | }
|
621 | let shouldTrack = true;
|
622 | const trackStack = [];
|
623 | function pauseTracking() {
|
624 | trackStack.push(shouldTrack);
|
625 | shouldTrack = false;
|
626 | }
|
627 | function enableTracking() {
|
628 | trackStack.push(shouldTrack);
|
629 | shouldTrack = true;
|
630 | }
|
631 | function resetTracking() {
|
632 | const last = trackStack.pop();
|
633 | shouldTrack = last === undefined ? true : last;
|
634 | }
|
635 | function track(target, type, key) {
|
636 | if (!isTracking()) {
|
637 | return;
|
638 | }
|
639 | let depsMap = targetMap.get(target);
|
640 | if (!depsMap) {
|
641 | targetMap.set(target, (depsMap = new Map()));
|
642 | }
|
643 | let dep = depsMap.get(key);
|
644 | if (!dep) {
|
645 | depsMap.set(key, (dep = createDep()));
|
646 | }
|
647 | const eventInfo = { effect: activeEffect, target, type, key }
|
648 | ;
|
649 | trackEffects(dep, eventInfo);
|
650 | }
|
651 | function isTracking() {
|
652 | return shouldTrack && activeEffect !== undefined;
|
653 | }
|
654 | function trackEffects(dep, debuggerEventExtraInfo) {
|
655 | let shouldTrack = false;
|
656 | if (effectTrackDepth <= maxMarkerBits) {
|
657 | if (!newTracked(dep)) {
|
658 | dep.n |= trackOpBit;
|
659 | shouldTrack = !wasTracked(dep);
|
660 | }
|
661 | }
|
662 | else {
|
663 |
|
664 | shouldTrack = !dep.has(activeEffect);
|
665 | }
|
666 | if (shouldTrack) {
|
667 | dep.add(activeEffect);
|
668 | activeEffect.deps.push(dep);
|
669 | if (activeEffect.onTrack) {
|
670 | activeEffect.onTrack(Object.assign({
|
671 | effect: activeEffect
|
672 | }, debuggerEventExtraInfo));
|
673 | }
|
674 | }
|
675 | }
|
676 | function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
677 | const depsMap = targetMap.get(target);
|
678 | if (!depsMap) {
|
679 |
|
680 | return;
|
681 | }
|
682 | let deps = [];
|
683 | if (type === "clear" ) {
|
684 |
|
685 |
|
686 | deps = [...depsMap.values()];
|
687 | }
|
688 | else if (key === 'length' && isArray(target)) {
|
689 | depsMap.forEach((dep, key) => {
|
690 | if (key === 'length' || key >= newValue) {
|
691 | deps.push(dep);
|
692 | }
|
693 | });
|
694 | }
|
695 | else {
|
696 |
|
697 | if (key !== void 0) {
|
698 | deps.push(depsMap.get(key));
|
699 | }
|
700 |
|
701 | switch (type) {
|
702 | case "add" :
|
703 | if (!isArray(target)) {
|
704 | deps.push(depsMap.get(ITERATE_KEY));
|
705 | if (isMap(target)) {
|
706 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
707 | }
|
708 | }
|
709 | else if (isIntegerKey(key)) {
|
710 |
|
711 | deps.push(depsMap.get('length'));
|
712 | }
|
713 | break;
|
714 | case "delete" :
|
715 | if (!isArray(target)) {
|
716 | deps.push(depsMap.get(ITERATE_KEY));
|
717 | if (isMap(target)) {
|
718 | deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
719 | }
|
720 | }
|
721 | break;
|
722 | case "set" :
|
723 | if (isMap(target)) {
|
724 | deps.push(depsMap.get(ITERATE_KEY));
|
725 | }
|
726 | break;
|
727 | }
|
728 | }
|
729 | const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
|
730 | ;
|
731 | if (deps.length === 1) {
|
732 | if (deps[0]) {
|
733 | {
|
734 | triggerEffects(deps[0], eventInfo);
|
735 | }
|
736 | }
|
737 | }
|
738 | else {
|
739 | const effects = [];
|
740 | for (const dep of deps) {
|
741 | if (dep) {
|
742 | effects.push(...dep);
|
743 | }
|
744 | }
|
745 | {
|
746 | triggerEffects(createDep(effects), eventInfo);
|
747 | }
|
748 | }
|
749 | }
|
750 | function triggerEffects(dep, debuggerEventExtraInfo) {
|
751 |
|
752 | for (const effect of isArray(dep) ? dep : [...dep]) {
|
753 | if (effect !== activeEffect || effect.allowRecurse) {
|
754 | if (effect.onTrigger) {
|
755 | effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
|
756 | }
|
757 | if (effect.scheduler) {
|
758 | effect.scheduler();
|
759 | }
|
760 | else {
|
761 | effect.run();
|
762 | }
|
763 | }
|
764 | }
|
765 | }
|
766 |
|
767 | const isNonTrackableKeys = makeMap(`__proto__,__v_isRef,__isVue`);
|
768 | const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
|
769 | .map(key => Symbol[key])
|
770 | .filter(isSymbol));
|
771 | const get = /*#__PURE__*/ createGetter();
|
772 | const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
773 | const readonlyGet = /*#__PURE__*/ createGetter(true);
|
774 | const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
775 | const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
776 | function createArrayInstrumentations() {
|
777 | const instrumentations = {};
|
778 | ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
|
779 | instrumentations[key] = function (...args) {
|
780 | const arr = toRaw(this);
|
781 | for (let i = 0, l = this.length; i < l; i++) {
|
782 | track(arr, "get" , i + '');
|
783 | }
|
784 |
|
785 | const res = arr[key](...args);
|
786 | if (res === -1 || res === false) {
|
787 |
|
788 | return arr[key](...args.map(toRaw));
|
789 | }
|
790 | else {
|
791 | return res;
|
792 | }
|
793 | };
|
794 | });
|
795 | ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
796 | instrumentations[key] = function (...args) {
|
797 | pauseTracking();
|
798 | const res = toRaw(this)[key].apply(this, args);
|
799 | resetTracking();
|
800 | return res;
|
801 | };
|
802 | });
|
803 | return instrumentations;
|
804 | }
|
805 | function createGetter(isReadonly = false, shallow = false) {
|
806 | return function get(target, key, receiver) {
|
807 | if (key === "__v_isReactive" ) {
|
808 | return !isReadonly;
|
809 | }
|
810 | else if (key === "__v_isReadonly" ) {
|
811 | return isReadonly;
|
812 | }
|
813 | else if (key === "__v_raw" &&
|
814 | receiver ===
|
815 | (isReadonly
|
816 | ? shallow
|
817 | ? shallowReadonlyMap
|
818 | : readonlyMap
|
819 | : shallow
|
820 | ? shallowReactiveMap
|
821 | : reactiveMap).get(target)) {
|
822 | return target;
|
823 | }
|
824 | const targetIsArray = isArray(target);
|
825 | if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
826 | return Reflect.get(arrayInstrumentations, key, receiver);
|
827 | }
|
828 | const res = Reflect.get(target, key, receiver);
|
829 | if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
830 | return res;
|
831 | }
|
832 | if (!isReadonly) {
|
833 | track(target, "get" , key);
|
834 | }
|
835 | if (shallow) {
|
836 | return res;
|
837 | }
|
838 | if (isRef(res)) {
|
839 |
|
840 | const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
|
841 | return shouldUnwrap ? res.value : res;
|
842 | }
|
843 | if (isObject(res)) {
|
844 |
|
845 |
|
846 |
|
847 | return isReadonly ? readonly(res) : reactive(res);
|
848 | }
|
849 | return res;
|
850 | };
|
851 | }
|
852 | const set = /*#__PURE__*/ createSetter();
|
853 | const shallowSet = /*#__PURE__*/ createSetter(true);
|
854 | function createSetter(shallow = false) {
|
855 | return function set(target, key, value, receiver) {
|
856 | let oldValue = target[key];
|
857 | if (!shallow) {
|
858 | value = toRaw(value);
|
859 | oldValue = toRaw(oldValue);
|
860 | if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
861 | oldValue.value = value;
|
862 | return true;
|
863 | }
|
864 | }
|
865 | const hadKey = isArray(target) && isIntegerKey(key)
|
866 | ? Number(key) < target.length
|
867 | : hasOwn(target, key);
|
868 | const result = Reflect.set(target, key, value, receiver);
|
869 |
|
870 | if (target === toRaw(receiver)) {
|
871 | if (!hadKey) {
|
872 | trigger(target, "add" , key, value);
|
873 | }
|
874 | else if (hasChanged(value, oldValue)) {
|
875 | trigger(target, "set" , key, value, oldValue);
|
876 | }
|
877 | }
|
878 | return result;
|
879 | };
|
880 | }
|
881 | function deleteProperty(target, key) {
|
882 | const hadKey = hasOwn(target, key);
|
883 | const oldValue = target[key];
|
884 | const result = Reflect.deleteProperty(target, key);
|
885 | if (result && hadKey) {
|
886 | trigger(target, "delete" , key, undefined, oldValue);
|
887 | }
|
888 | return result;
|
889 | }
|
890 | function has(target, key) {
|
891 | const result = Reflect.has(target, key);
|
892 | if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
893 | track(target, "has" , key);
|
894 | }
|
895 | return result;
|
896 | }
|
897 | function ownKeys(target) {
|
898 | track(target, "iterate" , isArray(target) ? 'length' : ITERATE_KEY);
|
899 | return Reflect.ownKeys(target);
|
900 | }
|
901 | const mutableHandlers = {
|
902 | get,
|
903 | set,
|
904 | deleteProperty,
|
905 | has,
|
906 | ownKeys
|
907 | };
|
908 | const readonlyHandlers = {
|
909 | get: readonlyGet,
|
910 | set(target, key) {
|
911 | {
|
912 | console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
913 | }
|
914 | return true;
|
915 | },
|
916 | deleteProperty(target, key) {
|
917 | {
|
918 | console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
919 | }
|
920 | return true;
|
921 | }
|
922 | };
|
923 | const shallowReactiveHandlers = extend({}, mutableHandlers, {
|
924 | get: shallowGet,
|
925 | set: shallowSet
|
926 | });
|
927 | // Props handlers are special in the sense that it should not unwrap top-level
|
928 | // refs (in order to allow refs to be explicitly passed down), but should
|
929 | // retain the reactivity of the normal readonly object.
|
930 | const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
|
931 | get: shallowReadonlyGet
|
932 | });
|
933 |
|
934 | const toShallow = (value) => value;
|
935 | const getProto = (v) => Reflect.getPrototypeOf(v);
|
936 | function get$1(target, key, isReadonly = false, isShallow = false) {
|
937 |
|
938 |
|
939 | target = target["__v_raw" ];
|
940 | const rawTarget = toRaw(target);
|
941 | const rawKey = toRaw(key);
|
942 | if (key !== rawKey) {
|
943 | !isReadonly && track(rawTarget, "get" , key);
|
944 | }
|
945 | !isReadonly && track(rawTarget, "get" , rawKey);
|
946 | const { has } = getProto(rawTarget);
|
947 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
948 | if (has.call(rawTarget, key)) {
|
949 | return wrap(target.get(key));
|
950 | }
|
951 | else if (has.call(rawTarget, rawKey)) {
|
952 | return wrap(target.get(rawKey));
|
953 | }
|
954 | else if (target !== rawTarget) {
|
955 |
|
956 |
|
957 | target.get(key);
|
958 | }
|
959 | }
|
960 | function has$1(key, isReadonly = false) {
|
961 | const target = this["__v_raw" ];
|
962 | const rawTarget = toRaw(target);
|
963 | const rawKey = toRaw(key);
|
964 | if (key !== rawKey) {
|
965 | !isReadonly && track(rawTarget, "has" , key);
|
966 | }
|
967 | !isReadonly && track(rawTarget, "has" , rawKey);
|
968 | return key === rawKey
|
969 | ? target.has(key)
|
970 | : target.has(key) || target.has(rawKey);
|
971 | }
|
972 | function size(target, isReadonly = false) {
|
973 | target = target["__v_raw" ];
|
974 | !isReadonly && track(toRaw(target), "iterate" , ITERATE_KEY);
|
975 | return Reflect.get(target, 'size', target);
|
976 | }
|
977 | function add(value) {
|
978 | value = toRaw(value);
|
979 | const target = toRaw(this);
|
980 | const proto = getProto(target);
|
981 | const hadKey = proto.has.call(target, value);
|
982 | if (!hadKey) {
|
983 | target.add(value);
|
984 | trigger(target, "add" , value, value);
|
985 | }
|
986 | return this;
|
987 | }
|
988 | function set$1(key, value) {
|
989 | value = toRaw(value);
|
990 | const target = toRaw(this);
|
991 | const { has, get } = getProto(target);
|
992 | let hadKey = has.call(target, key);
|
993 | if (!hadKey) {
|
994 | key = toRaw(key);
|
995 | hadKey = has.call(target, key);
|
996 | }
|
997 | else {
|
998 | checkIdentityKeys(target, has, key);
|
999 | }
|
1000 | const oldValue = get.call(target, key);
|
1001 | target.set(key, value);
|
1002 | if (!hadKey) {
|
1003 | trigger(target, "add" , key, value);
|
1004 | }
|
1005 | else if (hasChanged(value, oldValue)) {
|
1006 | trigger(target, "set" , key, value, oldValue);
|
1007 | }
|
1008 | return this;
|
1009 | }
|
1010 | function deleteEntry(key) {
|
1011 | const target = toRaw(this);
|
1012 | const { has, get } = getProto(target);
|
1013 | let hadKey = has.call(target, key);
|
1014 | if (!hadKey) {
|
1015 | key = toRaw(key);
|
1016 | hadKey = has.call(target, key);
|
1017 | }
|
1018 | else {
|
1019 | checkIdentityKeys(target, has, key);
|
1020 | }
|
1021 | const oldValue = get ? get.call(target, key) : undefined;
|
1022 | // forward the operation before queueing reactions
|
1023 | const result = target.delete(key);
|
1024 | if (hadKey) {
|
1025 | trigger(target, "delete" , key, undefined, oldValue);
|
1026 | }
|
1027 | return result;
|
1028 | }
|
1029 | function clear() {
|
1030 | const target = toRaw(this);
|
1031 | const hadItems = target.size !== 0;
|
1032 | const oldTarget = isMap(target)
|
1033 | ? new Map(target)
|
1034 | : new Set(target)
|
1035 | ;
|
1036 |
|
1037 | const result = target.clear();
|
1038 | if (hadItems) {
|
1039 | trigger(target, "clear" , undefined, undefined, oldTarget);
|
1040 | }
|
1041 | return result;
|
1042 | }
|
1043 | function createForEach(isReadonly, isShallow) {
|
1044 | return function forEach(callback, thisArg) {
|
1045 | const observed = this;
|
1046 | const target = observed["__v_raw" ];
|
1047 | const rawTarget = toRaw(target);
|
1048 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1049 | !isReadonly && track(rawTarget, "iterate" , ITERATE_KEY);
|
1050 | return target.forEach((value, key) => {
|
1051 |
|
1052 |
|
1053 |
|
1054 | return callback.call(thisArg, wrap(value), wrap(key), observed);
|
1055 | });
|
1056 | };
|
1057 | }
|
1058 | function createIterableMethod(method, isReadonly, isShallow) {
|
1059 | return function (...args) {
|
1060 | const target = this["__v_raw" ];
|
1061 | const rawTarget = toRaw(target);
|
1062 | const targetIsMap = isMap(rawTarget);
|
1063 | const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
|
1064 | const isKeyOnly = method === 'keys' && targetIsMap;
|
1065 | const innerIterator = target[method](...args);
|
1066 | const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
|
1067 | !isReadonly &&
|
1068 | track(rawTarget, "iterate" , isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
1069 |
|
1070 |
|
1071 | return {
|
1072 |
|
1073 | next() {
|
1074 | const { value, done } = innerIterator.next();
|
1075 | return done
|
1076 | ? { value, done }
|
1077 | : {
|
1078 | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
1079 | done
|
1080 | };
|
1081 | },
|
1082 |
|
1083 | [Symbol.iterator]() {
|
1084 | return this;
|
1085 | }
|
1086 | };
|
1087 | };
|
1088 | }
|
1089 | function createReadonlyMethod(type) {
|
1090 | return function (...args) {
|
1091 | {
|
1092 | const key = args[0] ? `on key "${args[0]}" ` : ``;
|
1093 | console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
|
1094 | }
|
1095 | return type === "delete" ? false : this;
|
1096 | };
|
1097 | }
|
1098 | function createInstrumentations() {
|
1099 | const mutableInstrumentations = {
|
1100 | get(key) {
|
1101 | return get$1(this, key);
|
1102 | },
|
1103 | get size() {
|
1104 | return size(this);
|
1105 | },
|
1106 | has: has$1,
|
1107 | add,
|
1108 | set: set$1,
|
1109 | delete: deleteEntry,
|
1110 | clear,
|
1111 | forEach: createForEach(false, false)
|
1112 | };
|
1113 | const shallowInstrumentations = {
|
1114 | get(key) {
|
1115 | return get$1(this, key, false, true);
|
1116 | },
|
1117 | get size() {
|
1118 | return size(this);
|
1119 | },
|
1120 | has: has$1,
|
1121 | add,
|
1122 | set: set$1,
|
1123 | delete: deleteEntry,
|
1124 | clear,
|
1125 | forEach: createForEach(false, true)
|
1126 | };
|
1127 | const readonlyInstrumentations = {
|
1128 | get(key) {
|
1129 | return get$1(this, key, true);
|
1130 | },
|
1131 | get size() {
|
1132 | return size(this, true);
|
1133 | },
|
1134 | has(key) {
|
1135 | return has$1.call(this, key, true);
|
1136 | },
|
1137 | add: createReadonlyMethod("add" ),
|
1138 | set: createReadonlyMethod("set" /* SET */),
|
1139 | delete: createReadonlyMethod("delete" /* DELETE */),
|
1140 | clear: createReadonlyMethod("clear" /* CLEAR */),
|
1141 | forEach: createForEach(true, false)
|
1142 | };
|
1143 | const shallowReadonlyInstrumentations = {
|
1144 | get(key) {
|
1145 | return get$1(this, key, true, true);
|
1146 | },
|
1147 | get size() {
|
1148 | return size(this, true);
|
1149 | },
|
1150 | has(key) {
|
1151 | return has$1.call(this, key, true);
|
1152 | },
|
1153 | add: createReadonlyMethod("add" ),
|
1154 | set: createReadonlyMethod("set" /* SET */),
|
1155 | delete: createReadonlyMethod("delete" /* DELETE */),
|
1156 | clear: createReadonlyMethod("clear" /* CLEAR */),
|
1157 | forEach: createForEach(true, true)
|
1158 | };
|
1159 | const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
|
1160 | iteratorMethods.forEach(method => {
|
1161 | mutableInstrumentations[method] = createIterableMethod(method, false, false);
|
1162 | readonlyInstrumentations[method] = createIterableMethod(method, true, false);
|
1163 | shallowInstrumentations[method] = createIterableMethod(method, false, true);
|
1164 | shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
|
1165 | });
|
1166 | return [
|
1167 | mutableInstrumentations,
|
1168 | readonlyInstrumentations,
|
1169 | shallowInstrumentations,
|
1170 | shallowReadonlyInstrumentations
|
1171 | ];
|
1172 | }
|
1173 | const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = createInstrumentations();
|
1174 | function createInstrumentationGetter(isReadonly, shallow) {
|
1175 | const instrumentations = shallow
|
1176 | ? isReadonly
|
1177 | ? shallowReadonlyInstrumentations
|
1178 | : shallowInstrumentations
|
1179 | : isReadonly
|
1180 | ? readonlyInstrumentations
|
1181 | : mutableInstrumentations;
|
1182 | return (target, key, receiver) => {
|
1183 | if (key === "__v_isReactive" ) {
|
1184 | return !isReadonly;
|
1185 | }
|
1186 | else if (key === "__v_isReadonly" ) {
|
1187 | return isReadonly;
|
1188 | }
|
1189 | else if (key === "__v_raw" ) {
|
1190 | return target;
|
1191 | }
|
1192 | return Reflect.get(hasOwn(instrumentations, key) && key in target
|
1193 | ? instrumentations
|
1194 | : target, key, receiver);
|
1195 | };
|
1196 | }
|
1197 | const mutableCollectionHandlers = {
|
1198 | get: /*#__PURE__*/ createInstrumentationGetter(false, false)
|
1199 | };
|
1200 | const shallowCollectionHandlers = {
|
1201 | get: /*#__PURE__*/ createInstrumentationGetter(false, true)
|
1202 | };
|
1203 | const readonlyCollectionHandlers = {
|
1204 | get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
1205 | };
|
1206 | const shallowReadonlyCollectionHandlers = {
|
1207 | get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
1208 | };
|
1209 | function checkIdentityKeys(target, has, key) {
|
1210 | const rawKey = toRaw(key);
|
1211 | if (rawKey !== key && has.call(target, rawKey)) {
|
1212 | const type = toRawType(target);
|
1213 | console.warn(`Reactive ${type} contains both the raw and reactive ` +
|
1214 | `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
|
1215 | `which can lead to inconsistencies. ` +
|
1216 | `Avoid differentiating between the raw and reactive versions ` +
|
1217 | `of an object and only use the reactive version if possible.`);
|
1218 | }
|
1219 | }
|
1220 |
|
1221 | const reactiveMap = new WeakMap();
|
1222 | const shallowReactiveMap = new WeakMap();
|
1223 | const readonlyMap = new WeakMap();
|
1224 | const shallowReadonlyMap = new WeakMap();
|
1225 | function targetTypeMap(rawType) {
|
1226 | switch (rawType) {
|
1227 | case 'Object':
|
1228 | case 'Array':
|
1229 | return 1 ;
|
1230 | case 'Map':
|
1231 | case 'Set':
|
1232 | case 'WeakMap':
|
1233 | case 'WeakSet':
|
1234 | return 2 ;
|
1235 | default:
|
1236 | return 0 ;
|
1237 | }
|
1238 | }
|
1239 | function getTargetType(value) {
|
1240 | return value["__v_skip" ] || !Object.isExtensible(value)
|
1241 | ? 0
|
1242 | : targetTypeMap(toRawType(value));
|
1243 | }
|
1244 | function reactive(target) {
|
1245 |
|
1246 | if (target && target["__v_isReadonly" ]) {
|
1247 | return target;
|
1248 | }
|
1249 | return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
1250 | }
|
1251 | |
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 | function shallowReactive(target) {
|
1257 | return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
|
1258 | }
|
1259 | |
1260 |
|
1261 |
|
1262 |
|
1263 | function readonly(target) {
|
1264 | return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
1265 | }
|
1266 | |
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 | function shallowReadonly(target) {
|
1273 | return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
|
1274 | }
|
1275 | function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
|
1276 | if (!isObject(target)) {
|
1277 | {
|
1278 | console.warn(`value cannot be made reactive: ${String(target)}`);
|
1279 | }
|
1280 | return target;
|
1281 | }
|
1282 |
|
1283 |
|
1284 | if (target["__v_raw" ] &&
|
1285 | !(isReadonly && target["__v_isReactive" ])) {
|
1286 | return target;
|
1287 | }
|
1288 |
|
1289 | const existingProxy = proxyMap.get(target);
|
1290 | if (existingProxy) {
|
1291 | return existingProxy;
|
1292 | }
|
1293 |
|
1294 | const targetType = getTargetType(target);
|
1295 | if (targetType === 0 ) {
|
1296 | return target;
|
1297 | }
|
1298 | const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
1299 | proxyMap.set(target, proxy);
|
1300 | return proxy;
|
1301 | }
|
1302 | function isReactive(value) {
|
1303 | if (isReadonly(value)) {
|
1304 | return isReactive(value["__v_raw" ]);
|
1305 | }
|
1306 | return !!(value && value["__v_isReactive" ]);
|
1307 | }
|
1308 | function isReadonly(value) {
|
1309 | return !!(value && value["__v_isReadonly" ]);
|
1310 | }
|
1311 | function isProxy(value) {
|
1312 | return isReactive(value) || isReadonly(value);
|
1313 | }
|
1314 | function toRaw(observed) {
|
1315 | const raw = observed && observed["__v_raw" ];
|
1316 | return raw ? toRaw(raw) : observed;
|
1317 | }
|
1318 | function markRaw(value) {
|
1319 | def(value, "__v_skip" , true);
|
1320 | return value;
|
1321 | }
|
1322 | const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
1323 | const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
1324 |
|
1325 | function trackRefValue(ref) {
|
1326 | if (isTracking()) {
|
1327 | ref = toRaw(ref);
|
1328 | if (!ref.dep) {
|
1329 | ref.dep = createDep();
|
1330 | }
|
1331 | {
|
1332 | trackEffects(ref.dep, {
|
1333 | target: ref,
|
1334 | type: "get" ,
|
1335 | key: 'value'
|
1336 | });
|
1337 | }
|
1338 | }
|
1339 | }
|
1340 | function triggerRefValue(ref, newVal) {
|
1341 | ref = toRaw(ref);
|
1342 | if (ref.dep) {
|
1343 | {
|
1344 | triggerEffects(ref.dep, {
|
1345 | target: ref,
|
1346 | type: "set" ,
|
1347 | key: 'value',
|
1348 | newValue: newVal
|
1349 | });
|
1350 | }
|
1351 | }
|
1352 | }
|
1353 | function isRef(r) {
|
1354 | return Boolean(r && r.__v_isRef === true);
|
1355 | }
|
1356 | function ref(value) {
|
1357 | return createRef(value, false);
|
1358 | }
|
1359 | function shallowRef(value) {
|
1360 | return createRef(value, true);
|
1361 | }
|
1362 | function createRef(rawValue, shallow) {
|
1363 | if (isRef(rawValue)) {
|
1364 | return rawValue;
|
1365 | }
|
1366 | return new RefImpl(rawValue, shallow);
|
1367 | }
|
1368 | class RefImpl {
|
1369 | constructor(value, _shallow) {
|
1370 | this._shallow = _shallow;
|
1371 | this.dep = undefined;
|
1372 | this.__v_isRef = true;
|
1373 | this._rawValue = _shallow ? value : toRaw(value);
|
1374 | this._value = _shallow ? value : toReactive(value);
|
1375 | }
|
1376 | get value() {
|
1377 | trackRefValue(this);
|
1378 | return this._value;
|
1379 | }
|
1380 | set value(newVal) {
|
1381 | newVal = this._shallow ? newVal : toRaw(newVal);
|
1382 | if (hasChanged(newVal, this._rawValue)) {
|
1383 | this._rawValue = newVal;
|
1384 | this._value = this._shallow ? newVal : toReactive(newVal);
|
1385 | triggerRefValue(this, newVal);
|
1386 | }
|
1387 | }
|
1388 | }
|
1389 | function triggerRef(ref) {
|
1390 | triggerRefValue(ref, ref.value );
|
1391 | }
|
1392 | function unref(ref) {
|
1393 | return isRef(ref) ? ref.value : ref;
|
1394 | }
|
1395 | const shallowUnwrapHandlers = {
|
1396 | get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
|
1397 | set: (target, key, value, receiver) => {
|
1398 | const oldValue = target[key];
|
1399 | if (isRef(oldValue) && !isRef(value)) {
|
1400 | oldValue.value = value;
|
1401 | return true;
|
1402 | }
|
1403 | else {
|
1404 | return Reflect.set(target, key, value, receiver);
|
1405 | }
|
1406 | }
|
1407 | };
|
1408 | function proxyRefs(objectWithRefs) {
|
1409 | return isReactive(objectWithRefs)
|
1410 | ? objectWithRefs
|
1411 | : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
1412 | }
|
1413 | class CustomRefImpl {
|
1414 | constructor(factory) {
|
1415 | this.dep = undefined;
|
1416 | this.__v_isRef = true;
|
1417 | const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
|
1418 | this._get = get;
|
1419 | this._set = set;
|
1420 | }
|
1421 | get value() {
|
1422 | return this._get();
|
1423 | }
|
1424 | set value(newVal) {
|
1425 | this._set(newVal);
|
1426 | }
|
1427 | }
|
1428 | function customRef(factory) {
|
1429 | return new CustomRefImpl(factory);
|
1430 | }
|
1431 | function toRefs(object) {
|
1432 | if (!isProxy(object)) {
|
1433 | console.warn(`toRefs() expects a reactive object but received a plain one.`);
|
1434 | }
|
1435 | const ret = isArray(object) ? new Array(object.length) : {};
|
1436 | for (const key in object) {
|
1437 | ret[key] = toRef(object, key);
|
1438 | }
|
1439 | return ret;
|
1440 | }
|
1441 | class ObjectRefImpl {
|
1442 | constructor(_object, _key) {
|
1443 | this._object = _object;
|
1444 | this._key = _key;
|
1445 | this.__v_isRef = true;
|
1446 | }
|
1447 | get value() {
|
1448 | return this._object[this._key];
|
1449 | }
|
1450 | set value(newVal) {
|
1451 | this._object[this._key] = newVal;
|
1452 | }
|
1453 | }
|
1454 | function toRef(object, key) {
|
1455 | const val = object[key];
|
1456 | return isRef(val) ? val : new ObjectRefImpl(object, key);
|
1457 | }
|
1458 |
|
1459 | class ComputedRefImpl {
|
1460 | constructor(getter, _setter, isReadonly) {
|
1461 | this._setter = _setter;
|
1462 | this.dep = undefined;
|
1463 | this._dirty = true;
|
1464 | this.__v_isRef = true;
|
1465 | this.effect = new ReactiveEffect(getter, () => {
|
1466 | if (!this._dirty) {
|
1467 | this._dirty = true;
|
1468 | triggerRefValue(this);
|
1469 | }
|
1470 | });
|
1471 | this["__v_isReadonly" ] = isReadonly;
|
1472 | }
|
1473 | get value() {
|
1474 |
|
1475 | const self = toRaw(this);
|
1476 | trackRefValue(self);
|
1477 | if (self._dirty) {
|
1478 | self._dirty = false;
|
1479 | self._value = self.effect.run();
|
1480 | }
|
1481 | return self._value;
|
1482 | }
|
1483 | set value(newValue) {
|
1484 | this._setter(newValue);
|
1485 | }
|
1486 | }
|
1487 | function computed(getterOrOptions, debugOptions) {
|
1488 | let getter;
|
1489 | let setter;
|
1490 | const onlyGetter = isFunction(getterOrOptions);
|
1491 | if (onlyGetter) {
|
1492 | getter = getterOrOptions;
|
1493 | setter = () => {
|
1494 | console.warn('Write operation failed: computed value is readonly');
|
1495 | }
|
1496 | ;
|
1497 | }
|
1498 | else {
|
1499 | getter = getterOrOptions.get;
|
1500 | setter = getterOrOptions.set;
|
1501 | }
|
1502 | const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
|
1503 | if (debugOptions) {
|
1504 | cRef.effect.onTrack = debugOptions.onTrack;
|
1505 | cRef.effect.onTrigger = debugOptions.onTrigger;
|
1506 | }
|
1507 | return cRef;
|
1508 | }
|
1509 |
|
1510 |
|
1511 | let isHmrUpdating = false;
|
1512 | const hmrDirtyComponents = new Set();
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 | {
|
1519 | getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
1520 | createRecord: tryWrap(createRecord),
|
1521 | rerender: tryWrap(rerender),
|
1522 | reload: tryWrap(reload)
|
1523 | };
|
1524 | }
|
1525 | const map = new Map();
|
1526 | function registerHMR(instance) {
|
1527 | const id = instance.type.__hmrId;
|
1528 | let record = map.get(id);
|
1529 | if (!record) {
|
1530 | createRecord(id);
|
1531 | record = map.get(id);
|
1532 | }
|
1533 | record.add(instance);
|
1534 | }
|
1535 | function unregisterHMR(instance) {
|
1536 | map.get(instance.type.__hmrId).delete(instance);
|
1537 | }
|
1538 | function createRecord(id) {
|
1539 | if (map.has(id)) {
|
1540 | return false;
|
1541 | }
|
1542 | map.set(id, new Set());
|
1543 | return true;
|
1544 | }
|
1545 | function normalizeClassComponent(component) {
|
1546 | return isClassComponent(component) ? component.__vccOpts : component;
|
1547 | }
|
1548 | function rerender(id, newRender) {
|
1549 | const record = map.get(id);
|
1550 | if (!record) {
|
1551 | return;
|
1552 | }
|
1553 | [...record].forEach(instance => {
|
1554 | if (newRender) {
|
1555 | instance.render = newRender;
|
1556 | normalizeClassComponent(instance.type).render = newRender;
|
1557 | }
|
1558 | instance.renderCache = [];
|
1559 |
|
1560 | isHmrUpdating = true;
|
1561 | instance.update();
|
1562 | isHmrUpdating = false;
|
1563 | });
|
1564 | }
|
1565 | function reload(id, newComp) {
|
1566 | const record = map.get(id);
|
1567 | if (!record)
|
1568 | return;
|
1569 | newComp = normalizeClassComponent(newComp);
|
1570 |
|
1571 | const instances = [...record];
|
1572 | for (const instance of instances) {
|
1573 | const oldComp = normalizeClassComponent(instance.type);
|
1574 | if (!hmrDirtyComponents.has(oldComp)) {
|
1575 |
|
1576 | extend(oldComp, newComp);
|
1577 | for (const key in oldComp) {
|
1578 | if (key !== '__file' && !(key in newComp)) {
|
1579 | delete oldComp[key];
|
1580 | }
|
1581 | }
|
1582 |
|
1583 |
|
1584 | hmrDirtyComponents.add(oldComp);
|
1585 | }
|
1586 |
|
1587 | instance.appContext.optionsCache.delete(instance.type);
|
1588 |
|
1589 | if (instance.ceReload) {
|
1590 |
|
1591 | hmrDirtyComponents.add(oldComp);
|
1592 | instance.ceReload(newComp.styles);
|
1593 | hmrDirtyComponents.delete(oldComp);
|
1594 | }
|
1595 | else if (instance.parent) {
|
1596 |
|
1597 |
|
1598 |
|
1599 | queueJob(instance.parent.update);
|
1600 |
|
1601 |
|
1602 | if (instance.parent.type.__asyncLoader &&
|
1603 | instance.parent.ceReload) {
|
1604 | instance.parent.ceReload(newComp.styles);
|
1605 | }
|
1606 | }
|
1607 | else if (instance.appContext.reload) {
|
1608 |
|
1609 | instance.appContext.reload();
|
1610 | }
|
1611 | else if (typeof window !== 'undefined') {
|
1612 |
|
1613 | window.location.reload();
|
1614 | }
|
1615 | else {
|
1616 | console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
|
1617 | }
|
1618 | }
|
1619 |
|
1620 | queuePostFlushCb(() => {
|
1621 | for (const instance of instances) {
|
1622 | hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
|
1623 | }
|
1624 | });
|
1625 | }
|
1626 | function tryWrap(fn) {
|
1627 | return (id, arg) => {
|
1628 | try {
|
1629 | return fn(id, arg);
|
1630 | }
|
1631 | catch (e) {
|
1632 | console.error(e);
|
1633 | console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
|
1634 | `Full reload required.`);
|
1635 | }
|
1636 | };
|
1637 | }
|
1638 |
|
1639 | let buffer = [];
|
1640 | function emit(event, ...args) {
|
1641 | if (exports.devtools) {
|
1642 | exports.devtools.emit(event, ...args);
|
1643 | }
|
1644 | else {
|
1645 | buffer.push({ event, args });
|
1646 | }
|
1647 | }
|
1648 | function setDevtoolsHook(hook, target) {
|
1649 | exports.devtools = hook;
|
1650 | if (exports.devtools) {
|
1651 | exports.devtools.enabled = true;
|
1652 | buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
|
1653 | buffer = [];
|
1654 | }
|
1655 | else {
|
1656 | const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
|
1657 | target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
|
1658 | replay.push((newHook) => {
|
1659 | setDevtoolsHook(newHook, target);
|
1660 | });
|
1661 | }
|
1662 | }
|
1663 | function devtoolsInitApp(app, version) {
|
1664 | emit("app:init" , app, version, {
|
1665 | Fragment,
|
1666 | Text,
|
1667 | Comment,
|
1668 | Static
|
1669 | });
|
1670 | }
|
1671 | function devtoolsUnmountApp(app) {
|
1672 | emit("app:unmount" , app);
|
1673 | }
|
1674 | const devtoolsComponentAdded = createDevtoolsComponentHook("component:added" );
|
1675 | const devtoolsComponentUpdated =
|
1676 | createDevtoolsComponentHook("component:updated" );
|
1677 | const devtoolsComponentRemoved =
|
1678 | createDevtoolsComponentHook("component:removed" );
|
1679 | function createDevtoolsComponentHook(hook) {
|
1680 | return (component) => {
|
1681 | emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
|
1682 | };
|
1683 | }
|
1684 | const devtoolsPerfStart = createDevtoolsPerformanceHook("perf:start" );
|
1685 | const devtoolsPerfEnd = createDevtoolsPerformanceHook("perf:end" );
|
1686 | function createDevtoolsPerformanceHook(hook) {
|
1687 | return (component, type, time) => {
|
1688 | emit(hook, component.appContext.app, component.uid, component, type, time);
|
1689 | };
|
1690 | }
|
1691 | function devtoolsComponentEmit(component, event, params) {
|
1692 | emit("component:emit" , component.appContext.app, component, event, params);
|
1693 | }
|
1694 |
|
1695 | function emit$1(instance, event, ...rawArgs) {
|
1696 | const props = instance.vnode.props || EMPTY_OBJ;
|
1697 | {
|
1698 | const { emitsOptions, propsOptions: [propsOptions] } = instance;
|
1699 | if (emitsOptions) {
|
1700 | if (!(event in emitsOptions) &&
|
1701 | !(false )) {
|
1702 | if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
|
1703 | warn$1(`Component emitted event "${event}" but it is neither declared in ` +
|
1704 | `the emits option nor as an "${toHandlerKey(event)}" prop.`);
|
1705 | }
|
1706 | }
|
1707 | else {
|
1708 | const validator = emitsOptions[event];
|
1709 | if (isFunction(validator)) {
|
1710 | const isValid = validator(...rawArgs);
|
1711 | if (!isValid) {
|
1712 | warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
|
1713 | }
|
1714 | }
|
1715 | }
|
1716 | }
|
1717 | }
|
1718 | let args = rawArgs;
|
1719 | const isModelListener = event.startsWith('update:');
|
1720 |
|
1721 | const modelArg = isModelListener && event.slice(7);
|
1722 | if (modelArg && modelArg in props) {
|
1723 | const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
|
1724 | const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
|
1725 | if (trim) {
|
1726 | args = rawArgs.map(a => a.trim());
|
1727 | }
|
1728 | else if (number) {
|
1729 | args = rawArgs.map(toNumber);
|
1730 | }
|
1731 | }
|
1732 | {
|
1733 | devtoolsComponentEmit(instance, event, args);
|
1734 | }
|
1735 | {
|
1736 | const lowerCaseEvent = event.toLowerCase();
|
1737 | if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
|
1738 | warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
|
1739 | `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
|
1740 | `Note that HTML attributes are case-insensitive and you cannot use ` +
|
1741 | `v-on to listen to camelCase events when using in-DOM templates. ` +
|
1742 | `You should probably use "${hyphenate(event)}" instead of "${event}".`);
|
1743 | }
|
1744 | }
|
1745 | let handlerName;
|
1746 | let handler = props[(handlerName = toHandlerKey(event))] ||
|
1747 |
|
1748 | props[(handlerName = toHandlerKey(camelize(event)))];
|
1749 |
|
1750 |
|
1751 | if (!handler && isModelListener) {
|
1752 | handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
|
1753 | }
|
1754 | if (handler) {
|
1755 | callWithAsyncErrorHandling(handler, instance, 6 , args);
|
1756 | }
|
1757 | const onceHandler = props[handlerName + `Once`];
|
1758 | if (onceHandler) {
|
1759 | if (!instance.emitted) {
|
1760 | instance.emitted = {};
|
1761 | }
|
1762 | else if (instance.emitted[handlerName]) {
|
1763 | return;
|
1764 | }
|
1765 | instance.emitted[handlerName] = true;
|
1766 | callWithAsyncErrorHandling(onceHandler, instance, 6 , args);
|
1767 | }
|
1768 | }
|
1769 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
1770 | const cache = appContext.emitsCache;
|
1771 | const cached = cache.get(comp);
|
1772 | if (cached !== undefined) {
|
1773 | return cached;
|
1774 | }
|
1775 | const raw = comp.emits;
|
1776 | let normalized = {};
|
1777 |
|
1778 | let hasExtends = false;
|
1779 | if (!isFunction(comp)) {
|
1780 | const extendEmits = (raw) => {
|
1781 | const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
|
1782 | if (normalizedFromExtend) {
|
1783 | hasExtends = true;
|
1784 | extend(normalized, normalizedFromExtend);
|
1785 | }
|
1786 | };
|
1787 | if (!asMixin && appContext.mixins.length) {
|
1788 | appContext.mixins.forEach(extendEmits);
|
1789 | }
|
1790 | if (comp.extends) {
|
1791 | extendEmits(comp.extends);
|
1792 | }
|
1793 | if (comp.mixins) {
|
1794 | comp.mixins.forEach(extendEmits);
|
1795 | }
|
1796 | }
|
1797 | if (!raw && !hasExtends) {
|
1798 | cache.set(comp, null);
|
1799 | return null;
|
1800 | }
|
1801 | if (isArray(raw)) {
|
1802 | raw.forEach(key => (normalized[key] = null));
|
1803 | }
|
1804 | else {
|
1805 | extend(normalized, raw);
|
1806 | }
|
1807 | cache.set(comp, normalized);
|
1808 | return normalized;
|
1809 | }
|
1810 |
|
1811 |
|
1812 |
|
1813 | function isEmitListener(options, key) {
|
1814 | if (!options || !isOn(key)) {
|
1815 | return false;
|
1816 | }
|
1817 | key = key.slice(2).replace(/Once$/, '');
|
1818 | return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
|
1819 | hasOwn(options, hyphenate(key)) ||
|
1820 | hasOwn(options, key));
|
1821 | }
|
1822 |
|
1823 | |
1824 |
|
1825 |
|
1826 |
|
1827 | let currentRenderingInstance = null;
|
1828 | let currentScopeId = null;
|
1829 | |
1830 |
|
1831 |
|
1832 |
|
1833 |
|
1834 |
|
1835 |
|
1836 |
|
1837 |
|
1838 |
|
1839 | function setCurrentRenderingInstance(instance) {
|
1840 | const prev = currentRenderingInstance;
|
1841 | currentRenderingInstance = instance;
|
1842 | currentScopeId = (instance && instance.type.__scopeId) || null;
|
1843 | return prev;
|
1844 | }
|
1845 | |
1846 |
|
1847 |
|
1848 |
|
1849 | function pushScopeId(id) {
|
1850 | currentScopeId = id;
|
1851 | }
|
1852 | |
1853 |
|
1854 |
|
1855 |
|
1856 |
|
1857 | function popScopeId() {
|
1858 | currentScopeId = null;
|
1859 | }
|
1860 | |
1861 |
|
1862 |
|
1863 |
|
1864 | const withScopeId = (_id) => withCtx;
|
1865 | |
1866 |
|
1867 |
|
1868 |
|
1869 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
|
1870 | ) {
|
1871 | if (!ctx)
|
1872 | return fn;
|
1873 |
|
1874 | if (fn._n) {
|
1875 | return fn;
|
1876 | }
|
1877 | const renderFnWithContext = (...args) => {
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 | if (renderFnWithContext._d) {
|
1884 | setBlockTracking(-1);
|
1885 | }
|
1886 | const prevInstance = setCurrentRenderingInstance(ctx);
|
1887 | const res = fn(...args);
|
1888 | setCurrentRenderingInstance(prevInstance);
|
1889 | if (renderFnWithContext._d) {
|
1890 | setBlockTracking(1);
|
1891 | }
|
1892 | {
|
1893 | devtoolsComponentUpdated(ctx);
|
1894 | }
|
1895 | return res;
|
1896 | };
|
1897 |
|
1898 | renderFnWithContext._n = true;
|
1899 |
|
1900 |
|
1901 |
|
1902 | renderFnWithContext._c = true;
|
1903 |
|
1904 | renderFnWithContext._d = true;
|
1905 | return renderFnWithContext;
|
1906 | }
|
1907 |
|
1908 | |
1909 |
|
1910 |
|
1911 |
|
1912 |
|
1913 | let accessedAttrs = false;
|
1914 | function markAttrsAccessed() {
|
1915 | accessedAttrs = true;
|
1916 | }
|
1917 | function renderComponentRoot(instance) {
|
1918 | const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
|
1919 | let result;
|
1920 | let fallthroughAttrs;
|
1921 | const prev = setCurrentRenderingInstance(instance);
|
1922 | {
|
1923 | accessedAttrs = false;
|
1924 | }
|
1925 | try {
|
1926 | if (vnode.shapeFlag & 4 ) {
|
1927 |
|
1928 |
|
1929 | const proxyToUse = withProxy || proxy;
|
1930 | result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
|
1931 | fallthroughAttrs = attrs;
|
1932 | }
|
1933 | else {
|
1934 |
|
1935 | const render = Component;
|
1936 |
|
1937 | if (true && attrs === props) {
|
1938 | markAttrsAccessed();
|
1939 | }
|
1940 | result = normalizeVNode(render.length > 1
|
1941 | ? render(props, true
|
1942 | ? {
|
1943 | get attrs() {
|
1944 | markAttrsAccessed();
|
1945 | return attrs;
|
1946 | },
|
1947 | slots,
|
1948 | emit
|
1949 | }
|
1950 | : { attrs, slots, emit })
|
1951 | : render(props, null ));
|
1952 | fallthroughAttrs = Component.props
|
1953 | ? attrs
|
1954 | : getFunctionalFallthrough(attrs);
|
1955 | }
|
1956 | }
|
1957 | catch (err) {
|
1958 | blockStack.length = 0;
|
1959 | handleError(err, instance, 1 );
|
1960 | result = createVNode(Comment);
|
1961 | }
|
1962 |
|
1963 |
|
1964 |
|
1965 | let root = result;
|
1966 | let setRoot = undefined;
|
1967 | if (result.patchFlag > 0 &&
|
1968 | result.patchFlag & 2048 ) {
|
1969 | [root, setRoot] = getChildRoot(result);
|
1970 | }
|
1971 | if (fallthroughAttrs && inheritAttrs !== false) {
|
1972 | const keys = Object.keys(fallthroughAttrs);
|
1973 | const { shapeFlag } = root;
|
1974 | if (keys.length) {
|
1975 | if (shapeFlag & (1 | 6 )) {
|
1976 | if (propsOptions && keys.some(isModelListener)) {
|
1977 |
|
1978 |
|
1979 |
|
1980 |
|
1981 | fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
|
1982 | }
|
1983 | root = cloneVNode(root, fallthroughAttrs);
|
1984 | }
|
1985 | else if (!accessedAttrs && root.type !== Comment) {
|
1986 | const allAttrs = Object.keys(attrs);
|
1987 | const eventAttrs = [];
|
1988 | const extraAttrs = [];
|
1989 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
1990 | const key = allAttrs[i];
|
1991 | if (isOn(key)) {
|
1992 |
|
1993 | if (!isModelListener(key)) {
|
1994 |
|
1995 |
|
1996 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
1997 | }
|
1998 | }
|
1999 | else {
|
2000 | extraAttrs.push(key);
|
2001 | }
|
2002 | }
|
2003 | if (extraAttrs.length) {
|
2004 | warn$1(`Extraneous non-props attributes (` +
|
2005 | `${extraAttrs.join(', ')}) ` +
|
2006 | `were passed to component but could not be automatically inherited ` +
|
2007 | `because component renders fragment or text root nodes.`);
|
2008 | }
|
2009 | if (eventAttrs.length) {
|
2010 | warn$1(`Extraneous non-emits event listeners (` +
|
2011 | `${eventAttrs.join(', ')}) ` +
|
2012 | `were passed to component but could not be automatically inherited ` +
|
2013 | `because component renders fragment or text root nodes. ` +
|
2014 | `If the listener is intended to be a component custom event listener only, ` +
|
2015 | `declare it using the "emits" option.`);
|
2016 | }
|
2017 | }
|
2018 | }
|
2019 | }
|
2020 |
|
2021 | if (vnode.dirs) {
|
2022 | if (!isElementRoot(root)) {
|
2023 | warn$1(`Runtime directive used on component with non-element root node. ` +
|
2024 | `The directives will not function as intended.`);
|
2025 | }
|
2026 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
2027 | }
|
2028 |
|
2029 | if (vnode.transition) {
|
2030 | if (!isElementRoot(root)) {
|
2031 | warn$1(`Component inside <Transition> renders non-element root node ` +
|
2032 | `that cannot be animated.`);
|
2033 | }
|
2034 | root.transition = vnode.transition;
|
2035 | }
|
2036 | if (setRoot) {
|
2037 | setRoot(root);
|
2038 | }
|
2039 | else {
|
2040 | result = root;
|
2041 | }
|
2042 | setCurrentRenderingInstance(prev);
|
2043 | return result;
|
2044 | }
|
2045 | |
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 | const getChildRoot = (vnode) => {
|
2052 | const rawChildren = vnode.children;
|
2053 | const dynamicChildren = vnode.dynamicChildren;
|
2054 | const childRoot = filterSingleRoot(rawChildren);
|
2055 | if (!childRoot) {
|
2056 | return [vnode, undefined];
|
2057 | }
|
2058 | const index = rawChildren.indexOf(childRoot);
|
2059 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
2060 | const setRoot = (updatedRoot) => {
|
2061 | rawChildren[index] = updatedRoot;
|
2062 | if (dynamicChildren) {
|
2063 | if (dynamicIndex > -1) {
|
2064 | dynamicChildren[dynamicIndex] = updatedRoot;
|
2065 | }
|
2066 | else if (updatedRoot.patchFlag > 0) {
|
2067 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
2068 | }
|
2069 | }
|
2070 | };
|
2071 | return [normalizeVNode(childRoot), setRoot];
|
2072 | };
|
2073 | function filterSingleRoot(children) {
|
2074 | let singleRoot;
|
2075 | for (let i = 0; i < children.length; i++) {
|
2076 | const child = children[i];
|
2077 | if (isVNode(child)) {
|
2078 |
|
2079 | if (child.type !== Comment || child.children === 'v-if') {
|
2080 | if (singleRoot) {
|
2081 |
|
2082 | return;
|
2083 | }
|
2084 | else {
|
2085 | singleRoot = child;
|
2086 | }
|
2087 | }
|
2088 | }
|
2089 | else {
|
2090 | return;
|
2091 | }
|
2092 | }
|
2093 | return singleRoot;
|
2094 | }
|
2095 | const getFunctionalFallthrough = (attrs) => {
|
2096 | let res;
|
2097 | for (const key in attrs) {
|
2098 | if (key === 'class' || key === 'style' || isOn(key)) {
|
2099 | (res || (res = {}))[key] = attrs[key];
|
2100 | }
|
2101 | }
|
2102 | return res;
|
2103 | };
|
2104 | const filterModelListeners = (attrs, props) => {
|
2105 | const res = {};
|
2106 | for (const key in attrs) {
|
2107 | if (!isModelListener(key) || !(key.slice(9) in props)) {
|
2108 | res[key] = attrs[key];
|
2109 | }
|
2110 | }
|
2111 | return res;
|
2112 | };
|
2113 | const isElementRoot = (vnode) => {
|
2114 | return (vnode.shapeFlag & (6 | 1 ) ||
|
2115 | vnode.type === Comment
|
2116 | );
|
2117 | };
|
2118 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
2119 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
2120 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
2121 | const emits = component.emitsOptions;
|
2122 |
|
2123 |
|
2124 |
|
2125 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
2126 | return true;
|
2127 | }
|
2128 |
|
2129 | if (nextVNode.dirs || nextVNode.transition) {
|
2130 | return true;
|
2131 | }
|
2132 | if (optimized && patchFlag >= 0) {
|
2133 | if (patchFlag & 1024 ) {
|
2134 |
|
2135 |
|
2136 | return true;
|
2137 | }
|
2138 | if (patchFlag & 16 ) {
|
2139 | if (!prevProps) {
|
2140 | return !!nextProps;
|
2141 | }
|
2142 |
|
2143 | return hasPropsChanged(prevProps, nextProps, emits);
|
2144 | }
|
2145 | else if (patchFlag & 8 ) {
|
2146 | const dynamicProps = nextVNode.dynamicProps;
|
2147 | for (let i = 0; i < dynamicProps.length; i++) {
|
2148 | const key = dynamicProps[i];
|
2149 | if (nextProps[key] !== prevProps[key] &&
|
2150 | !isEmitListener(emits, key)) {
|
2151 | return true;
|
2152 | }
|
2153 | }
|
2154 | }
|
2155 | }
|
2156 | else {
|
2157 |
|
2158 |
|
2159 | if (prevChildren || nextChildren) {
|
2160 | if (!nextChildren || !nextChildren.$stable) {
|
2161 | return true;
|
2162 | }
|
2163 | }
|
2164 | if (prevProps === nextProps) {
|
2165 | return false;
|
2166 | }
|
2167 | if (!prevProps) {
|
2168 | return !!nextProps;
|
2169 | }
|
2170 | if (!nextProps) {
|
2171 | return true;
|
2172 | }
|
2173 | return hasPropsChanged(prevProps, nextProps, emits);
|
2174 | }
|
2175 | return false;
|
2176 | }
|
2177 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
2178 | const nextKeys = Object.keys(nextProps);
|
2179 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
2180 | return true;
|
2181 | }
|
2182 | for (let i = 0; i < nextKeys.length; i++) {
|
2183 | const key = nextKeys[i];
|
2184 | if (nextProps[key] !== prevProps[key] &&
|
2185 | !isEmitListener(emitsOptions, key)) {
|
2186 | return true;
|
2187 | }
|
2188 | }
|
2189 | return false;
|
2190 | }
|
2191 | function updateHOCHostEl({ vnode, parent }, el // HostNode
|
2192 | ) {
|
2193 | while (parent && parent.subTree === vnode) {
|
2194 | (vnode = parent.vnode).el = el;
|
2195 | parent = parent.parent;
|
2196 | }
|
2197 | }
|
2198 |
|
2199 | const isSuspense = (type) => type.__isSuspense;
|
2200 |
|
2201 |
|
2202 |
|
2203 | const SuspenseImpl = {
|
2204 | name: 'Suspense',
|
2205 |
|
2206 |
|
2207 |
|
2208 |
|
2209 | __isSuspense: true,
|
2210 | process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
|
2211 |
|
2212 | rendererInternals) {
|
2213 | if (n1 == null) {
|
2214 | mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
|
2215 | }
|
2216 | else {
|
2217 | patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
|
2218 | }
|
2219 | },
|
2220 | hydrate: hydrateSuspense,
|
2221 | create: createSuspenseBoundary,
|
2222 | normalize: normalizeSuspenseChildren
|
2223 | };
|
2224 |
|
2225 | const Suspense = (SuspenseImpl );
|
2226 | function triggerEvent(vnode, name) {
|
2227 | const eventListener = vnode.props && vnode.props[name];
|
2228 | if (isFunction(eventListener)) {
|
2229 | eventListener();
|
2230 | }
|
2231 | }
|
2232 | function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
|
2233 | const { p: patch, o: { createElement } } = rendererInternals;
|
2234 | const hiddenContainer = createElement('div');
|
2235 | const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
|
2236 |
|
2237 | patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
|
2238 |
|
2239 | if (suspense.deps > 0) {
|
2240 |
|
2241 |
|
2242 | triggerEvent(vnode, 'onPending');
|
2243 | triggerEvent(vnode, 'onFallback');
|
2244 |
|
2245 | patch(null, vnode.ssFallback, container, anchor, parentComponent, null,
|
2246 | isSVG, slotScopeIds);
|
2247 | setActiveBranch(suspense, vnode.ssFallback);
|
2248 | }
|
2249 | else {
|
2250 |
|
2251 | suspense.resolve();
|
2252 | }
|
2253 | }
|
2254 | function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
|
2255 | const suspense = (n2.suspense = n1.suspense);
|
2256 | suspense.vnode = n2;
|
2257 | n2.el = n1.el;
|
2258 | const newBranch = n2.ssContent;
|
2259 | const newFallback = n2.ssFallback;
|
2260 | const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
2261 | if (pendingBranch) {
|
2262 | suspense.pendingBranch = newBranch;
|
2263 | if (isSameVNodeType(newBranch, pendingBranch)) {
|
2264 |
|
2265 | patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2266 | if (suspense.deps <= 0) {
|
2267 | suspense.resolve();
|
2268 | }
|
2269 | else if (isInFallback) {
|
2270 | patch(activeBranch, newFallback, container, anchor, parentComponent, null,
|
2271 | isSVG, slotScopeIds, optimized);
|
2272 | setActiveBranch(suspense, newFallback);
|
2273 | }
|
2274 | }
|
2275 | else {
|
2276 |
|
2277 | suspense.pendingId++;
|
2278 | if (isHydrating) {
|
2279 |
|
2280 |
|
2281 |
|
2282 | suspense.isHydrating = false;
|
2283 | suspense.activeBranch = pendingBranch;
|
2284 | }
|
2285 | else {
|
2286 | unmount(pendingBranch, parentComponent, suspense);
|
2287 | }
|
2288 |
|
2289 |
|
2290 | suspense.deps = 0;
|
2291 |
|
2292 | suspense.effects.length = 0;
|
2293 |
|
2294 | suspense.hiddenContainer = createElement('div');
|
2295 | if (isInFallback) {
|
2296 |
|
2297 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2298 | if (suspense.deps <= 0) {
|
2299 | suspense.resolve();
|
2300 | }
|
2301 | else {
|
2302 | patch(activeBranch, newFallback, container, anchor, parentComponent, null,
|
2303 | isSVG, slotScopeIds, optimized);
|
2304 | setActiveBranch(suspense, newFallback);
|
2305 | }
|
2306 | }
|
2307 | else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2308 |
|
2309 | patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2310 |
|
2311 | suspense.resolve(true);
|
2312 | }
|
2313 | else {
|
2314 |
|
2315 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2316 | if (suspense.deps <= 0) {
|
2317 | suspense.resolve();
|
2318 | }
|
2319 | }
|
2320 | }
|
2321 | }
|
2322 | else {
|
2323 | if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
2324 |
|
2325 | patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2326 | setActiveBranch(suspense, newBranch);
|
2327 | }
|
2328 | else {
|
2329 |
|
2330 |
|
2331 | triggerEvent(n2, 'onPending');
|
2332 |
|
2333 | suspense.pendingBranch = newBranch;
|
2334 | suspense.pendingId++;
|
2335 | patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
|
2336 | if (suspense.deps <= 0) {
|
2337 |
|
2338 | suspense.resolve();
|
2339 | }
|
2340 | else {
|
2341 | const { timeout, pendingId } = suspense;
|
2342 | if (timeout > 0) {
|
2343 | setTimeout(() => {
|
2344 | if (suspense.pendingId === pendingId) {
|
2345 | suspense.fallback(newFallback);
|
2346 | }
|
2347 | }, timeout);
|
2348 | }
|
2349 | else if (timeout === 0) {
|
2350 | suspense.fallback(newFallback);
|
2351 | }
|
2352 | }
|
2353 | }
|
2354 | }
|
2355 | }
|
2356 | let hasWarned = false;
|
2357 | function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
2358 |
|
2359 | if (!hasWarned) {
|
2360 | hasWarned = true;
|
2361 |
|
2362 | console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
|
2363 | }
|
2364 | const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
|
2365 | const timeout = toNumber(vnode.props && vnode.props.timeout);
|
2366 | const suspense = {
|
2367 | vnode,
|
2368 | parent,
|
2369 | parentComponent,
|
2370 | isSVG,
|
2371 | container,
|
2372 | hiddenContainer,
|
2373 | anchor,
|
2374 | deps: 0,
|
2375 | pendingId: 0,
|
2376 | timeout: typeof timeout === 'number' ? timeout : -1,
|
2377 | activeBranch: null,
|
2378 | pendingBranch: null,
|
2379 | isInFallback: true,
|
2380 | isHydrating,
|
2381 | isUnmounted: false,
|
2382 | effects: [],
|
2383 | resolve(resume = false) {
|
2384 | {
|
2385 | if (!resume && !suspense.pendingBranch) {
|
2386 | throw new Error(`suspense.resolve() is called without a pending branch.`);
|
2387 | }
|
2388 | if (suspense.isUnmounted) {
|
2389 | throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
|
2390 | }
|
2391 | }
|
2392 | const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
|
2393 | if (suspense.isHydrating) {
|
2394 | suspense.isHydrating = false;
|
2395 | }
|
2396 | else if (!resume) {
|
2397 | const delayEnter = activeBranch &&
|
2398 | pendingBranch.transition &&
|
2399 | pendingBranch.transition.mode === 'out-in';
|
2400 | if (delayEnter) {
|
2401 | activeBranch.transition.afterLeave = () => {
|
2402 | if (pendingId === suspense.pendingId) {
|
2403 | move(pendingBranch, container, anchor, 0 );
|
2404 | }
|
2405 | };
|
2406 | }
|
2407 |
|
2408 | let { anchor } = suspense;
|
2409 |
|
2410 | if (activeBranch) {
|
2411 |
|
2412 |
|
2413 | anchor = next(activeBranch);
|
2414 | unmount(activeBranch, parentComponent, suspense, true);
|
2415 | }
|
2416 | if (!delayEnter) {
|
2417 |
|
2418 | move(pendingBranch, container, anchor, 0 );
|
2419 | }
|
2420 | }
|
2421 | setActiveBranch(suspense, pendingBranch);
|
2422 | suspense.pendingBranch = null;
|
2423 | suspense.isInFallback = false;
|
2424 |
|
2425 |
|
2426 | let parent = suspense.parent;
|
2427 | let hasUnresolvedAncestor = false;
|
2428 | while (parent) {
|
2429 | if (parent.pendingBranch) {
|
2430 |
|
2431 |
|
2432 | parent.effects.push(...effects);
|
2433 | hasUnresolvedAncestor = true;
|
2434 | break;
|
2435 | }
|
2436 | parent = parent.parent;
|
2437 | }
|
2438 |
|
2439 | if (!hasUnresolvedAncestor) {
|
2440 | queuePostFlushCb(effects);
|
2441 | }
|
2442 | suspense.effects = [];
|
2443 |
|
2444 | triggerEvent(vnode, 'onResolve');
|
2445 | },
|
2446 | fallback(fallbackVNode) {
|
2447 | if (!suspense.pendingBranch) {
|
2448 | return;
|
2449 | }
|
2450 | const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
|
2451 |
|
2452 | triggerEvent(vnode, 'onFallback');
|
2453 | const anchor = next(activeBranch);
|
2454 | const mountFallback = () => {
|
2455 | if (!suspense.isInFallback) {
|
2456 | return;
|
2457 | }
|
2458 |
|
2459 | patch(null, fallbackVNode, container, anchor, parentComponent, null,
|
2460 | isSVG, slotScopeIds, optimized);
|
2461 | setActiveBranch(suspense, fallbackVNode);
|
2462 | };
|
2463 | const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
|
2464 | if (delayEnter) {
|
2465 | activeBranch.transition.afterLeave = mountFallback;
|
2466 | }
|
2467 | suspense.isInFallback = true;
|
2468 |
|
2469 | unmount(activeBranch, parentComponent, null,
|
2470 | true
|
2471 | );
|
2472 | if (!delayEnter) {
|
2473 | mountFallback();
|
2474 | }
|
2475 | },
|
2476 | move(container, anchor, type) {
|
2477 | suspense.activeBranch &&
|
2478 | move(suspense.activeBranch, container, anchor, type);
|
2479 | suspense.container = container;
|
2480 | },
|
2481 | next() {
|
2482 | return suspense.activeBranch && next(suspense.activeBranch);
|
2483 | },
|
2484 | registerDep(instance, setupRenderEffect) {
|
2485 | const isInPendingSuspense = !!suspense.pendingBranch;
|
2486 | if (isInPendingSuspense) {
|
2487 | suspense.deps++;
|
2488 | }
|
2489 | const hydratedEl = instance.vnode.el;
|
2490 | instance
|
2491 | .asyncDep.catch(err => {
|
2492 | handleError(err, instance, 0 );
|
2493 | })
|
2494 | .then(asyncSetupResult => {
|
2495 |
|
2496 |
|
2497 | if (instance.isUnmounted ||
|
2498 | suspense.isUnmounted ||
|
2499 | suspense.pendingId !== instance.suspenseId) {
|
2500 | return;
|
2501 | }
|
2502 |
|
2503 | instance.asyncResolved = true;
|
2504 | const { vnode } = instance;
|
2505 | {
|
2506 | pushWarningContext(vnode);
|
2507 | }
|
2508 | handleSetupResult(instance, asyncSetupResult, false);
|
2509 | if (hydratedEl) {
|
2510 |
|
2511 |
|
2512 | vnode.el = hydratedEl;
|
2513 | }
|
2514 | const placeholder = !hydratedEl && instance.subTree.el;
|
2515 | setupRenderEffect(instance, vnode,
|
2516 |
|
2517 |
|
2518 |
|
2519 | parentNode(hydratedEl || instance.subTree.el),
|
2520 |
|
2521 |
|
2522 | hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
|
2523 | if (placeholder) {
|
2524 | remove(placeholder);
|
2525 | }
|
2526 | updateHOCHostEl(instance, vnode.el);
|
2527 | {
|
2528 | popWarningContext();
|
2529 | }
|
2530 |
|
2531 | if (isInPendingSuspense && --suspense.deps === 0) {
|
2532 | suspense.resolve();
|
2533 | }
|
2534 | });
|
2535 | },
|
2536 | unmount(parentSuspense, doRemove) {
|
2537 | suspense.isUnmounted = true;
|
2538 | if (suspense.activeBranch) {
|
2539 | unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
|
2540 | }
|
2541 | if (suspense.pendingBranch) {
|
2542 | unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
|
2543 | }
|
2544 | }
|
2545 | };
|
2546 | return suspense;
|
2547 | }
|
2548 | function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
2549 |
|
2550 | const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true ));
|
2551 |
|
2552 |
|
2553 |
|
2554 |
|
2555 |
|
2556 |
|
2557 | const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
|
2558 | if (suspense.deps === 0) {
|
2559 | suspense.resolve();
|
2560 | }
|
2561 | return result;
|
2562 |
|
2563 | }
|
2564 | function normalizeSuspenseChildren(vnode) {
|
2565 | const { shapeFlag, children } = vnode;
|
2566 | const isSlotChildren = shapeFlag & 32 ;
|
2567 | vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
|
2568 | vnode.ssFallback = isSlotChildren
|
2569 | ? normalizeSuspenseSlot(children.fallback)
|
2570 | : createVNode(Comment);
|
2571 | }
|
2572 | function normalizeSuspenseSlot(s) {
|
2573 | let block;
|
2574 | if (isFunction(s)) {
|
2575 | const trackBlock = isBlockTreeEnabled && s._c;
|
2576 | if (trackBlock) {
|
2577 |
|
2578 |
|
2579 |
|
2580 | s._d = false;
|
2581 | openBlock();
|
2582 | }
|
2583 | s = s();
|
2584 | if (trackBlock) {
|
2585 | s._d = true;
|
2586 | block = currentBlock;
|
2587 | closeBlock();
|
2588 | }
|
2589 | }
|
2590 | if (isArray(s)) {
|
2591 | const singleChild = filterSingleRoot(s);
|
2592 | if (!singleChild) {
|
2593 | warn$1(`<Suspense> slots expect a single root node.`);
|
2594 | }
|
2595 | s = singleChild;
|
2596 | }
|
2597 | s = normalizeVNode(s);
|
2598 | if (block && !s.dynamicChildren) {
|
2599 | s.dynamicChildren = block.filter(c => c !== s);
|
2600 | }
|
2601 | return s;
|
2602 | }
|
2603 | function queueEffectWithSuspense(fn, suspense) {
|
2604 | if (suspense && suspense.pendingBranch) {
|
2605 | if (isArray(fn)) {
|
2606 | suspense.effects.push(...fn);
|
2607 | }
|
2608 | else {
|
2609 | suspense.effects.push(fn);
|
2610 | }
|
2611 | }
|
2612 | else {
|
2613 | queuePostFlushCb(fn);
|
2614 | }
|
2615 | }
|
2616 | function setActiveBranch(suspense, branch) {
|
2617 | suspense.activeBranch = branch;
|
2618 | const { vnode, parentComponent } = suspense;
|
2619 | const el = (vnode.el = branch.el);
|
2620 |
|
2621 |
|
2622 | if (parentComponent && parentComponent.subTree === vnode) {
|
2623 | parentComponent.vnode.el = el;
|
2624 | updateHOCHostEl(parentComponent, el);
|
2625 | }
|
2626 | }
|
2627 |
|
2628 | function provide(key, value) {
|
2629 | if (!currentInstance) {
|
2630 | {
|
2631 | warn$1(`provide() can only be used inside setup().`);
|
2632 | }
|
2633 | }
|
2634 | else {
|
2635 | let provides = currentInstance.provides;
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
2642 | if (parentProvides === provides) {
|
2643 | provides = currentInstance.provides = Object.create(parentProvides);
|
2644 | }
|
2645 |
|
2646 | provides[key] = value;
|
2647 | }
|
2648 | }
|
2649 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
2650 |
|
2651 |
|
2652 | const instance = currentInstance || currentRenderingInstance;
|
2653 | if (instance) {
|
2654 |
|
2655 |
|
2656 |
|
2657 | const provides = instance.parent == null
|
2658 | ? instance.vnode.appContext && instance.vnode.appContext.provides
|
2659 | : instance.parent.provides;
|
2660 | if (provides && key in provides) {
|
2661 |
|
2662 | return provides[key];
|
2663 | }
|
2664 | else if (arguments.length > 1) {
|
2665 | return treatDefaultAsFactory && isFunction(defaultValue)
|
2666 | ? defaultValue.call(instance.proxy)
|
2667 | : defaultValue;
|
2668 | }
|
2669 | else {
|
2670 | warn$1(`injection "${String(key)}" not found.`);
|
2671 | }
|
2672 | }
|
2673 | else {
|
2674 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
2675 | }
|
2676 | }
|
2677 |
|
2678 | function useTransitionState() {
|
2679 | const state = {
|
2680 | isMounted: false,
|
2681 | isLeaving: false,
|
2682 | isUnmounting: false,
|
2683 | leavingVNodes: new Map()
|
2684 | };
|
2685 | onMounted(() => {
|
2686 | state.isMounted = true;
|
2687 | });
|
2688 | onBeforeUnmount(() => {
|
2689 | state.isUnmounting = true;
|
2690 | });
|
2691 | return state;
|
2692 | }
|
2693 | const TransitionHookValidator = [Function, Array];
|
2694 | const BaseTransitionImpl = {
|
2695 | name: `BaseTransition`,
|
2696 | props: {
|
2697 | mode: String,
|
2698 | appear: Boolean,
|
2699 | persisted: Boolean,
|
2700 |
|
2701 | onBeforeEnter: TransitionHookValidator,
|
2702 | onEnter: TransitionHookValidator,
|
2703 | onAfterEnter: TransitionHookValidator,
|
2704 | onEnterCancelled: TransitionHookValidator,
|
2705 |
|
2706 | onBeforeLeave: TransitionHookValidator,
|
2707 | onLeave: TransitionHookValidator,
|
2708 | onAfterLeave: TransitionHookValidator,
|
2709 | onLeaveCancelled: TransitionHookValidator,
|
2710 |
|
2711 | onBeforeAppear: TransitionHookValidator,
|
2712 | onAppear: TransitionHookValidator,
|
2713 | onAfterAppear: TransitionHookValidator,
|
2714 | onAppearCancelled: TransitionHookValidator
|
2715 | },
|
2716 | setup(props, { slots }) {
|
2717 | const instance = getCurrentInstance();
|
2718 | const state = useTransitionState();
|
2719 | let prevTransitionKey;
|
2720 | return () => {
|
2721 | const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
2722 | if (!children || !children.length) {
|
2723 | return;
|
2724 | }
|
2725 |
|
2726 | if (children.length > 1) {
|
2727 | warn$1('<transition> can only be used on a single element or component. Use ' +
|
2728 | '<transition-group> for lists.');
|
2729 | }
|
2730 |
|
2731 |
|
2732 | const rawProps = toRaw(props);
|
2733 | const { mode } = rawProps;
|
2734 |
|
2735 | if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
|
2736 | warn$1(`invalid <transition> mode: ${mode}`);
|
2737 | }
|
2738 |
|
2739 | const child = children[0];
|
2740 | if (state.isLeaving) {
|
2741 | return emptyPlaceholder(child);
|
2742 | }
|
2743 |
|
2744 |
|
2745 | const innerChild = getKeepAliveChild(child);
|
2746 | if (!innerChild) {
|
2747 | return emptyPlaceholder(child);
|
2748 | }
|
2749 | const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
|
2750 | setTransitionHooks(innerChild, enterHooks);
|
2751 | const oldChild = instance.subTree;
|
2752 | const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
|
2753 | let transitionKeyChanged = false;
|
2754 | const { getTransitionKey } = innerChild.type;
|
2755 | if (getTransitionKey) {
|
2756 | const key = getTransitionKey();
|
2757 | if (prevTransitionKey === undefined) {
|
2758 | prevTransitionKey = key;
|
2759 | }
|
2760 | else if (key !== prevTransitionKey) {
|
2761 | prevTransitionKey = key;
|
2762 | transitionKeyChanged = true;
|
2763 | }
|
2764 | }
|
2765 |
|
2766 | if (oldInnerChild &&
|
2767 | oldInnerChild.type !== Comment &&
|
2768 | (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
|
2769 | const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
|
2770 |
|
2771 | setTransitionHooks(oldInnerChild, leavingHooks);
|
2772 |
|
2773 | if (mode === 'out-in') {
|
2774 | state.isLeaving = true;
|
2775 |
|
2776 | leavingHooks.afterLeave = () => {
|
2777 | state.isLeaving = false;
|
2778 | instance.update();
|
2779 | };
|
2780 | return emptyPlaceholder(child);
|
2781 | }
|
2782 | else if (mode === 'in-out' && innerChild.type !== Comment) {
|
2783 | leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
2784 | const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
|
2785 | leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
2786 |
|
2787 | el._leaveCb = () => {
|
2788 | earlyRemove();
|
2789 | el._leaveCb = undefined;
|
2790 | delete enterHooks.delayedLeave;
|
2791 | };
|
2792 | enterHooks.delayedLeave = delayedLeave;
|
2793 | };
|
2794 | }
|
2795 | }
|
2796 | return child;
|
2797 | };
|
2798 | }
|
2799 | };
|
2800 |
|
2801 |
|
2802 | const BaseTransition = BaseTransitionImpl;
|
2803 | function getLeavingNodesForType(state, vnode) {
|
2804 | const { leavingVNodes } = state;
|
2805 | let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
2806 | if (!leavingVNodesCache) {
|
2807 | leavingVNodesCache = Object.create(null);
|
2808 | leavingVNodes.set(vnode.type, leavingVNodesCache);
|
2809 | }
|
2810 | return leavingVNodesCache;
|
2811 | }
|
2812 |
|
2813 |
|
2814 | function resolveTransitionHooks(vnode, props, state, instance) {
|
2815 | const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
|
2816 | const key = String(vnode.key);
|
2817 | const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
2818 | const callHook = (hook, args) => {
|
2819 | hook &&
|
2820 | callWithAsyncErrorHandling(hook, instance, 9 , args);
|
2821 | };
|
2822 | const hooks = {
|
2823 | mode,
|
2824 | persisted,
|
2825 | beforeEnter(el) {
|
2826 | let hook = onBeforeEnter;
|
2827 | if (!state.isMounted) {
|
2828 | if (appear) {
|
2829 | hook = onBeforeAppear || onBeforeEnter;
|
2830 | }
|
2831 | else {
|
2832 | return;
|
2833 | }
|
2834 | }
|
2835 |
|
2836 | if (el._leaveCb) {
|
2837 | el._leaveCb(true );
|
2838 | }
|
2839 |
|
2840 | const leavingVNode = leavingVNodesCache[key];
|
2841 | if (leavingVNode &&
|
2842 | isSameVNodeType(vnode, leavingVNode) &&
|
2843 | leavingVNode.el._leaveCb) {
|
2844 |
|
2845 | leavingVNode.el._leaveCb();
|
2846 | }
|
2847 | callHook(hook, [el]);
|
2848 | },
|
2849 | enter(el) {
|
2850 | let hook = onEnter;
|
2851 | let afterHook = onAfterEnter;
|
2852 | let cancelHook = onEnterCancelled;
|
2853 | if (!state.isMounted) {
|
2854 | if (appear) {
|
2855 | hook = onAppear || onEnter;
|
2856 | afterHook = onAfterAppear || onAfterEnter;
|
2857 | cancelHook = onAppearCancelled || onEnterCancelled;
|
2858 | }
|
2859 | else {
|
2860 | return;
|
2861 | }
|
2862 | }
|
2863 | let called = false;
|
2864 | const done = (el._enterCb = (cancelled) => {
|
2865 | if (called)
|
2866 | return;
|
2867 | called = true;
|
2868 | if (cancelled) {
|
2869 | callHook(cancelHook, [el]);
|
2870 | }
|
2871 | else {
|
2872 | callHook(afterHook, [el]);
|
2873 | }
|
2874 | if (hooks.delayedLeave) {
|
2875 | hooks.delayedLeave();
|
2876 | }
|
2877 | el._enterCb = undefined;
|
2878 | });
|
2879 | if (hook) {
|
2880 | hook(el, done);
|
2881 | if (hook.length <= 1) {
|
2882 | done();
|
2883 | }
|
2884 | }
|
2885 | else {
|
2886 | done();
|
2887 | }
|
2888 | },
|
2889 | leave(el, remove) {
|
2890 | const key = String(vnode.key);
|
2891 | if (el._enterCb) {
|
2892 | el._enterCb(true );
|
2893 | }
|
2894 | if (state.isUnmounting) {
|
2895 | return remove();
|
2896 | }
|
2897 | callHook(onBeforeLeave, [el]);
|
2898 | let called = false;
|
2899 | const done = (el._leaveCb = (cancelled) => {
|
2900 | if (called)
|
2901 | return;
|
2902 | called = true;
|
2903 | remove();
|
2904 | if (cancelled) {
|
2905 | callHook(onLeaveCancelled, [el]);
|
2906 | }
|
2907 | else {
|
2908 | callHook(onAfterLeave, [el]);
|
2909 | }
|
2910 | el._leaveCb = undefined;
|
2911 | if (leavingVNodesCache[key] === vnode) {
|
2912 | delete leavingVNodesCache[key];
|
2913 | }
|
2914 | });
|
2915 | leavingVNodesCache[key] = vnode;
|
2916 | if (onLeave) {
|
2917 | onLeave(el, done);
|
2918 | if (onLeave.length <= 1) {
|
2919 | done();
|
2920 | }
|
2921 | }
|
2922 | else {
|
2923 | done();
|
2924 | }
|
2925 | },
|
2926 | clone(vnode) {
|
2927 | return resolveTransitionHooks(vnode, props, state, instance);
|
2928 | }
|
2929 | };
|
2930 | return hooks;
|
2931 | }
|
2932 |
|
2933 |
|
2934 |
|
2935 |
|
2936 | function emptyPlaceholder(vnode) {
|
2937 | if (isKeepAlive(vnode)) {
|
2938 | vnode = cloneVNode(vnode);
|
2939 | vnode.children = null;
|
2940 | return vnode;
|
2941 | }
|
2942 | }
|
2943 | function getKeepAliveChild(vnode) {
|
2944 | return isKeepAlive(vnode)
|
2945 | ? vnode.children
|
2946 | ? vnode.children[0]
|
2947 | : undefined
|
2948 | : vnode;
|
2949 | }
|
2950 | function setTransitionHooks(vnode, hooks) {
|
2951 | if (vnode.shapeFlag & 6 && vnode.component) {
|
2952 | setTransitionHooks(vnode.component.subTree, hooks);
|
2953 | }
|
2954 | else if (vnode.shapeFlag & 128 ) {
|
2955 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
2956 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
2957 | }
|
2958 | else {
|
2959 | vnode.transition = hooks;
|
2960 | }
|
2961 | }
|
2962 | function getTransitionRawChildren(children, keepComment = false) {
|
2963 | let ret = [];
|
2964 | let keyedFragmentCount = 0;
|
2965 | for (let i = 0; i < children.length; i++) {
|
2966 | const child = children[i];
|
2967 |
|
2968 | if (child.type === Fragment) {
|
2969 | if (child.patchFlag & 128 )
|
2970 | keyedFragmentCount++;
|
2971 | ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
|
2972 | }
|
2973 |
|
2974 | else if (keepComment || child.type !== Comment) {
|
2975 | ret.push(child);
|
2976 | }
|
2977 | }
|
2978 |
|
2979 |
|
2980 |
|
2981 |
|
2982 | if (keyedFragmentCount > 1) {
|
2983 | for (let i = 0; i < ret.length; i++) {
|
2984 | ret[i].patchFlag = -2 ;
|
2985 | }
|
2986 | }
|
2987 | return ret;
|
2988 | }
|
2989 |
|
2990 |
|
2991 | function defineComponent(options) {
|
2992 | return isFunction(options) ? { setup: options, name: options.name } : options;
|
2993 | }
|
2994 |
|
2995 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
2996 | function defineAsyncComponent(source) {
|
2997 | if (isFunction(source)) {
|
2998 | source = { loader: source };
|
2999 | }
|
3000 | const { loader, loadingComponent, errorComponent, delay = 200, timeout,
|
3001 | suspensible = true, onError: userOnError } = source;
|
3002 | let pendingRequest = null;
|
3003 | let resolvedComp;
|
3004 | let retries = 0;
|
3005 | const retry = () => {
|
3006 | retries++;
|
3007 | pendingRequest = null;
|
3008 | return load();
|
3009 | };
|
3010 | const load = () => {
|
3011 | let thisRequest;
|
3012 | return (pendingRequest ||
|
3013 | (thisRequest = pendingRequest =
|
3014 | loader()
|
3015 | .catch(err => {
|
3016 | err = err instanceof Error ? err : new Error(String(err));
|
3017 | if (userOnError) {
|
3018 | return new Promise((resolve, reject) => {
|
3019 | const userRetry = () => resolve(retry());
|
3020 | const userFail = () => reject(err);
|
3021 | userOnError(err, userRetry, userFail, retries + 1);
|
3022 | });
|
3023 | }
|
3024 | else {
|
3025 | throw err;
|
3026 | }
|
3027 | })
|
3028 | .then((comp) => {
|
3029 | if (thisRequest !== pendingRequest && pendingRequest) {
|
3030 | return pendingRequest;
|
3031 | }
|
3032 | if (!comp) {
|
3033 | warn$1(`Async component loader resolved to undefined. ` +
|
3034 | `If you are using retry(), make sure to return its return value.`);
|
3035 | }
|
3036 |
|
3037 | if (comp &&
|
3038 | (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
|
3039 | comp = comp.default;
|
3040 | }
|
3041 | if (comp && !isObject(comp) && !isFunction(comp)) {
|
3042 | throw new Error(`Invalid async component load result: ${comp}`);
|
3043 | }
|
3044 | resolvedComp = comp;
|
3045 | return comp;
|
3046 | })));
|
3047 | };
|
3048 | return defineComponent({
|
3049 | name: 'AsyncComponentWrapper',
|
3050 | __asyncLoader: load,
|
3051 | get __asyncResolved() {
|
3052 | return resolvedComp;
|
3053 | },
|
3054 | setup() {
|
3055 | const instance = currentInstance;
|
3056 |
|
3057 | if (resolvedComp) {
|
3058 | return () => createInnerComp(resolvedComp, instance);
|
3059 | }
|
3060 | const onError = (err) => {
|
3061 | pendingRequest = null;
|
3062 | handleError(err, instance, 13 , !errorComponent );
|
3063 | };
|
3064 |
|
3065 | if ((suspensible && instance.suspense) ||
|
3066 | (false )) {
|
3067 | return load()
|
3068 | .then(comp => {
|
3069 | return () => createInnerComp(comp, instance);
|
3070 | })
|
3071 | .catch(err => {
|
3072 | onError(err);
|
3073 | return () => errorComponent
|
3074 | ? createVNode(errorComponent, {
|
3075 | error: err
|
3076 | })
|
3077 | : null;
|
3078 | });
|
3079 | }
|
3080 | const loaded = ref(false);
|
3081 | const error = ref();
|
3082 | const delayed = ref(!!delay);
|
3083 | if (delay) {
|
3084 | setTimeout(() => {
|
3085 | delayed.value = false;
|
3086 | }, delay);
|
3087 | }
|
3088 | if (timeout != null) {
|
3089 | setTimeout(() => {
|
3090 | if (!loaded.value && !error.value) {
|
3091 | const err = new Error(`Async component timed out after ${timeout}ms.`);
|
3092 | onError(err);
|
3093 | error.value = err;
|
3094 | }
|
3095 | }, timeout);
|
3096 | }
|
3097 | load()
|
3098 | .then(() => {
|
3099 | loaded.value = true;
|
3100 | if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
3101 |
|
3102 |
|
3103 | queueJob(instance.parent.update);
|
3104 | }
|
3105 | })
|
3106 | .catch(err => {
|
3107 | onError(err);
|
3108 | error.value = err;
|
3109 | });
|
3110 | return () => {
|
3111 | if (loaded.value && resolvedComp) {
|
3112 | return createInnerComp(resolvedComp, instance);
|
3113 | }
|
3114 | else if (error.value && errorComponent) {
|
3115 | return createVNode(errorComponent, {
|
3116 | error: error.value
|
3117 | });
|
3118 | }
|
3119 | else if (loadingComponent && !delayed.value) {
|
3120 | return createVNode(loadingComponent);
|
3121 | }
|
3122 | };
|
3123 | }
|
3124 | });
|
3125 | }
|
3126 | function createInnerComp(comp, { vnode: { ref, props, children } }) {
|
3127 | const vnode = createVNode(comp, props, children);
|
3128 |
|
3129 | vnode.ref = ref;
|
3130 | return vnode;
|
3131 | }
|
3132 |
|
3133 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
3134 | const KeepAliveImpl = {
|
3135 | name: `KeepAlive`,
|
3136 |
|
3137 |
|
3138 |
|
3139 | __isKeepAlive: true,
|
3140 | props: {
|
3141 | include: [String, RegExp, Array],
|
3142 | exclude: [String, RegExp, Array],
|
3143 | max: [String, Number]
|
3144 | },
|
3145 | setup(props, { slots }) {
|
3146 | const instance = getCurrentInstance();
|
3147 |
|
3148 |
|
3149 |
|
3150 |
|
3151 |
|
3152 | const sharedContext = instance.ctx;
|
3153 |
|
3154 |
|
3155 | if (!sharedContext.renderer) {
|
3156 | return slots.default;
|
3157 | }
|
3158 | const cache = new Map();
|
3159 | const keys = new Set();
|
3160 | let current = null;
|
3161 | {
|
3162 | instance.__v_cache = cache;
|
3163 | }
|
3164 | const parentSuspense = instance.suspense;
|
3165 | const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
|
3166 | const storageContainer = createElement('div');
|
3167 | sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
|
3168 | const instance = vnode.component;
|
3169 | move(vnode, container, anchor, 0 , parentSuspense);
|
3170 |
|
3171 | patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
|
3172 | queuePostRenderEffect(() => {
|
3173 | instance.isDeactivated = false;
|
3174 | if (instance.a) {
|
3175 | invokeArrayFns(instance.a);
|
3176 | }
|
3177 | const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
3178 | if (vnodeHook) {
|
3179 | invokeVNodeHook(vnodeHook, instance.parent, vnode);
|
3180 | }
|
3181 | }, parentSuspense);
|
3182 | {
|
3183 |
|
3184 | devtoolsComponentAdded(instance);
|
3185 | }
|
3186 | };
|
3187 | sharedContext.deactivate = (vnode) => {
|
3188 | const instance = vnode.component;
|
3189 | move(vnode, storageContainer, null, 1 , parentSuspense);
|
3190 | queuePostRenderEffect(() => {
|
3191 | if (instance.da) {
|
3192 | invokeArrayFns(instance.da);
|
3193 | }
|
3194 | const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
3195 | if (vnodeHook) {
|
3196 | invokeVNodeHook(vnodeHook, instance.parent, vnode);
|
3197 | }
|
3198 | instance.isDeactivated = true;
|
3199 | }, parentSuspense);
|
3200 | {
|
3201 |
|
3202 | devtoolsComponentAdded(instance);
|
3203 | }
|
3204 | };
|
3205 | function unmount(vnode) {
|
3206 |
|
3207 | resetShapeFlag(vnode);
|
3208 | _unmount(vnode, instance, parentSuspense);
|
3209 | }
|
3210 | function pruneCache(filter) {
|
3211 | cache.forEach((vnode, key) => {
|
3212 | const name = getComponentName(vnode.type);
|
3213 | if (name && (!filter || !filter(name))) {
|
3214 | pruneCacheEntry(key);
|
3215 | }
|
3216 | });
|
3217 | }
|
3218 | function pruneCacheEntry(key) {
|
3219 | const cached = cache.get(key);
|
3220 | if (!current || cached.type !== current.type) {
|
3221 | unmount(cached);
|
3222 | }
|
3223 | else if (current) {
|
3224 |
|
3225 |
|
3226 | resetShapeFlag(current);
|
3227 | }
|
3228 | cache.delete(key);
|
3229 | keys.delete(key);
|
3230 | }
|
3231 |
|
3232 | watch(() => [props.include, props.exclude], ([include, exclude]) => {
|
3233 | include && pruneCache(name => matches(include, name));
|
3234 | exclude && pruneCache(name => !matches(exclude, name));
|
3235 | },
|
3236 |
|
3237 | { flush: 'post', deep: true });
|
3238 |
|
3239 | let pendingCacheKey = null;
|
3240 | const cacheSubtree = () => {
|
3241 |
|
3242 | if (pendingCacheKey != null) {
|
3243 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
3244 | }
|
3245 | };
|
3246 | onMounted(cacheSubtree);
|
3247 | onUpdated(cacheSubtree);
|
3248 | onBeforeUnmount(() => {
|
3249 | cache.forEach(cached => {
|
3250 | const { subTree, suspense } = instance;
|
3251 | const vnode = getInnerChild(subTree);
|
3252 | if (cached.type === vnode.type) {
|
3253 |
|
3254 | resetShapeFlag(vnode);
|
3255 |
|
3256 | const da = vnode.component.da;
|
3257 | da && queuePostRenderEffect(da, suspense);
|
3258 | return;
|
3259 | }
|
3260 | unmount(cached);
|
3261 | });
|
3262 | });
|
3263 | return () => {
|
3264 | pendingCacheKey = null;
|
3265 | if (!slots.default) {
|
3266 | return null;
|
3267 | }
|
3268 | const children = slots.default();
|
3269 | const rawVNode = children[0];
|
3270 | if (children.length > 1) {
|
3271 | {
|
3272 | warn$1(`KeepAlive should contain exactly one component child.`);
|
3273 | }
|
3274 | current = null;
|
3275 | return children;
|
3276 | }
|
3277 | else if (!isVNode(rawVNode) ||
|
3278 | (!(rawVNode.shapeFlag & 4 ) &&
|
3279 | !(rawVNode.shapeFlag & 128 ))) {
|
3280 | current = null;
|
3281 | return rawVNode;
|
3282 | }
|
3283 | let vnode = getInnerChild(rawVNode);
|
3284 | const comp = vnode.type;
|
3285 |
|
3286 |
|
3287 | const name = getComponentName(isAsyncWrapper(vnode)
|
3288 | ? vnode.type.__asyncResolved || {}
|
3289 | : comp);
|
3290 | const { include, exclude, max } = props;
|
3291 | if ((include && (!name || !matches(include, name))) ||
|
3292 | (exclude && name && matches(exclude, name))) {
|
3293 | current = vnode;
|
3294 | return rawVNode;
|
3295 | }
|
3296 | const key = vnode.key == null ? comp : vnode.key;
|
3297 | const cachedVNode = cache.get(key);
|
3298 |
|
3299 | if (vnode.el) {
|
3300 | vnode = cloneVNode(vnode);
|
3301 | if (rawVNode.shapeFlag & 128 ) {
|
3302 | rawVNode.ssContent = vnode;
|
3303 | }
|
3304 | }
|
3305 |
|
3306 |
|
3307 |
|
3308 |
|
3309 |
|
3310 | pendingCacheKey = key;
|
3311 | if (cachedVNode) {
|
3312 |
|
3313 | vnode.el = cachedVNode.el;
|
3314 | vnode.component = cachedVNode.component;
|
3315 | if (vnode.transition) {
|
3316 |
|
3317 | setTransitionHooks(vnode, vnode.transition);
|
3318 | }
|
3319 |
|
3320 | vnode.shapeFlag |= 512 ;
|
3321 |
|
3322 | keys.delete(key);
|
3323 | keys.add(key);
|
3324 | }
|
3325 | else {
|
3326 | keys.add(key);
|
3327 |
|
3328 | if (max && keys.size > parseInt(max, 10)) {
|
3329 | pruneCacheEntry(keys.values().next().value);
|
3330 | }
|
3331 | }
|
3332 |
|
3333 | vnode.shapeFlag |= 256 ;
|
3334 | current = vnode;
|
3335 | return rawVNode;
|
3336 | };
|
3337 | }
|
3338 | };
|
3339 |
|
3340 |
|
3341 | const KeepAlive = KeepAliveImpl;
|
3342 | function matches(pattern, name) {
|
3343 | if (isArray(pattern)) {
|
3344 | return pattern.some((p) => matches(p, name));
|
3345 | }
|
3346 | else if (isString(pattern)) {
|
3347 | return pattern.split(',').indexOf(name) > -1;
|
3348 | }
|
3349 | else if (pattern.test) {
|
3350 | return pattern.test(name);
|
3351 | }
|
3352 |
|
3353 | return false;
|
3354 | }
|
3355 | function onActivated(hook, target) {
|
3356 | registerKeepAliveHook(hook, "a" , target);
|
3357 | }
|
3358 | function onDeactivated(hook, target) {
|
3359 | registerKeepAliveHook(hook, "da" , target);
|
3360 | }
|
3361 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
3362 |
|
3363 |
|
3364 |
|
3365 | const wrappedHook = hook.__wdc ||
|
3366 | (hook.__wdc = () => {
|
3367 |
|
3368 | let current = target;
|
3369 | while (current) {
|
3370 | if (current.isDeactivated) {
|
3371 | return;
|
3372 | }
|
3373 | current = current.parent;
|
3374 | }
|
3375 | hook();
|
3376 | });
|
3377 | injectHook(type, wrappedHook, target);
|
3378 |
|
3379 |
|
3380 |
|
3381 |
|
3382 |
|
3383 | if (target) {
|
3384 | let current = target.parent;
|
3385 | while (current && current.parent) {
|
3386 | if (isKeepAlive(current.parent.vnode)) {
|
3387 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
3388 | }
|
3389 | current = current.parent;
|
3390 | }
|
3391 | }
|
3392 | }
|
3393 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
3394 |
|
3395 |
|
3396 | const injected = injectHook(type, hook, keepAliveRoot, true );
|
3397 | onUnmounted(() => {
|
3398 | remove(keepAliveRoot[type], injected);
|
3399 | }, target);
|
3400 | }
|
3401 | function resetShapeFlag(vnode) {
|
3402 | let shapeFlag = vnode.shapeFlag;
|
3403 | if (shapeFlag & 256 ) {
|
3404 | shapeFlag -= 256 ;
|
3405 | }
|
3406 | if (shapeFlag & 512 ) {
|
3407 | shapeFlag -= 512 ;
|
3408 | }
|
3409 | vnode.shapeFlag = shapeFlag;
|
3410 | }
|
3411 | function getInnerChild(vnode) {
|
3412 | return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
3413 | }
|
3414 |
|
3415 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
3416 | if (target) {
|
3417 | const hooks = target[type] || (target[type] = []);
|
3418 |
|
3419 |
|
3420 |
|
3421 | const wrappedHook = hook.__weh ||
|
3422 | (hook.__weh = (...args) => {
|
3423 | if (target.isUnmounted) {
|
3424 | return;
|
3425 | }
|
3426 |
|
3427 |
|
3428 | pauseTracking();
|
3429 |
|
3430 |
|
3431 |
|
3432 | setCurrentInstance(target);
|
3433 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
3434 | unsetCurrentInstance();
|
3435 | resetTracking();
|
3436 | return res;
|
3437 | });
|
3438 | if (prepend) {
|
3439 | hooks.unshift(wrappedHook);
|
3440 | }
|
3441 | else {
|
3442 | hooks.push(wrappedHook);
|
3443 | }
|
3444 | return wrappedHook;
|
3445 | }
|
3446 | else {
|
3447 | const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
|
3448 | warn$1(`${apiName} is called when there is no active component instance to be ` +
|
3449 | `associated with. ` +
|
3450 | `Lifecycle injection APIs can only be used during execution of setup().` +
|
3451 | (` If you are using async setup(), make sure to register lifecycle ` +
|
3452 | `hooks before the first await statement.`
|
3453 | ));
|
3454 | }
|
3455 | }
|
3456 | const createHook = (lifecycle) => (hook, target = currentInstance) =>
|
3457 |
|
3458 | (!isInSSRComponentSetup || lifecycle === "sp" ) &&
|
3459 | injectHook(lifecycle, hook, target);
|
3460 | const onBeforeMount = createHook("bm" );
|
3461 | const onMounted = createHook("m" );
|
3462 | const onBeforeUpdate = createHook("bu" );
|
3463 | const onUpdated = createHook("u" );
|
3464 | const onBeforeUnmount = createHook("bum" );
|
3465 | const onUnmounted = createHook("um" );
|
3466 | const onServerPrefetch = createHook("sp" );
|
3467 | const onRenderTriggered = createHook("rtg" );
|
3468 | const onRenderTracked = createHook("rtc" );
|
3469 | function onErrorCaptured(hook, target = currentInstance) {
|
3470 | injectHook("ec" , hook, target);
|
3471 | }
|
3472 |
|
3473 | function createDuplicateChecker() {
|
3474 | const cache = Object.create(null);
|
3475 | return (type, key) => {
|
3476 | if (cache[key]) {
|
3477 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
3478 | }
|
3479 | else {
|
3480 | cache[key] = type;
|
3481 | }
|
3482 | };
|
3483 | }
|
3484 | let shouldCacheAccess = true;
|
3485 | function applyOptions(instance) {
|
3486 | const options = resolveMergedOptions(instance);
|
3487 | const publicThis = instance.proxy;
|
3488 | const ctx = instance.ctx;
|
3489 |
|
3490 | shouldCacheAccess = false;
|
3491 |
|
3492 |
|
3493 | if (options.beforeCreate) {
|
3494 | callHook(options.beforeCreate, instance, "bc" );
|
3495 | }
|
3496 | const {
|
3497 |
|
3498 | data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
|
3499 |
|
3500 | created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
|
3501 |
|
3502 | expose, inheritAttrs,
|
3503 |
|
3504 | components, directives, filters } = options;
|
3505 | const checkDuplicateProperties = createDuplicateChecker() ;
|
3506 | {
|
3507 | const [propsOptions] = instance.propsOptions;
|
3508 | if (propsOptions) {
|
3509 | for (const key in propsOptions) {
|
3510 | checkDuplicateProperties("Props" , key);
|
3511 | }
|
3512 | }
|
3513 | }
|
3514 |
|
3515 |
|
3516 |
|
3517 |
|
3518 |
|
3519 |
|
3520 |
|
3521 | if (injectOptions) {
|
3522 | resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
|
3523 | }
|
3524 | if (methods) {
|
3525 | for (const key in methods) {
|
3526 | const methodHandler = methods[key];
|
3527 | if (isFunction(methodHandler)) {
|
3528 |
|
3529 |
|
3530 |
|
3531 | {
|
3532 | Object.defineProperty(ctx, key, {
|
3533 | value: methodHandler.bind(publicThis),
|
3534 | configurable: true,
|
3535 | enumerable: true,
|
3536 | writable: true
|
3537 | });
|
3538 | }
|
3539 | {
|
3540 | checkDuplicateProperties("Methods" , key);
|
3541 | }
|
3542 | }
|
3543 | else {
|
3544 | warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
|
3545 | `Did you reference the function correctly?`);
|
3546 | }
|
3547 | }
|
3548 | }
|
3549 | if (dataOptions) {
|
3550 | if (!isFunction(dataOptions)) {
|
3551 | warn$1(`The data option must be a function. ` +
|
3552 | `Plain object usage is no longer supported.`);
|
3553 | }
|
3554 | const data = dataOptions.call(publicThis, publicThis);
|
3555 | if (isPromise(data)) {
|
3556 | warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
|
3557 | `intend to perform data fetching before component renders, use ` +
|
3558 | `async setup() + <Suspense>.`);
|
3559 | }
|
3560 | if (!isObject(data)) {
|
3561 | warn$1(`data() should return an object.`);
|
3562 | }
|
3563 | else {
|
3564 | instance.data = reactive(data);
|
3565 | {
|
3566 | for (const key in data) {
|
3567 | checkDuplicateProperties("Data" , key);
|
3568 |
|
3569 | if (key[0] !== '$' && key[0] !== '_') {
|
3570 | Object.defineProperty(ctx, key, {
|
3571 | configurable: true,
|
3572 | enumerable: true,
|
3573 | get: () => data[key],
|
3574 | set: NOOP
|
3575 | });
|
3576 | }
|
3577 | }
|
3578 | }
|
3579 | }
|
3580 | }
|
3581 | // state initialization complete at this point - start caching access
|
3582 | shouldCacheAccess = true;
|
3583 | if (computedOptions) {
|
3584 | for (const key in computedOptions) {
|
3585 | const opt = computedOptions[key];
|
3586 | const get = isFunction(opt)
|
3587 | ? opt.bind(publicThis, publicThis)
|
3588 | : isFunction(opt.get)
|
3589 | ? opt.get.bind(publicThis, publicThis)
|
3590 | : NOOP;
|
3591 | if (get === NOOP) {
|
3592 | warn$1(`Computed property "${key}" has no getter.`);
|
3593 | }
|
3594 | const set = !isFunction(opt) && isFunction(opt.set)
|
3595 | ? opt.set.bind(publicThis)
|
3596 | : () => {
|
3597 | warn$1(`Write operation failed: computed property "${key}" is readonly.`);
|
3598 | }
|
3599 | ;
|
3600 | const c = computed({
|
3601 | get,
|
3602 | set
|
3603 | });
|
3604 | Object.defineProperty(ctx, key, {
|
3605 | enumerable: true,
|
3606 | configurable: true,
|
3607 | get: () => c.value,
|
3608 | set: v => (c.value = v)
|
3609 | });
|
3610 | {
|
3611 | checkDuplicateProperties("Computed" , key);
|
3612 | }
|
3613 | }
|
3614 | }
|
3615 | if (watchOptions) {
|
3616 | for (const key in watchOptions) {
|
3617 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
3618 | }
|
3619 | }
|
3620 | if (provideOptions) {
|
3621 | const provides = isFunction(provideOptions)
|
3622 | ? provideOptions.call(publicThis)
|
3623 | : provideOptions;
|
3624 | Reflect.ownKeys(provides).forEach(key => {
|
3625 | provide(key, provides[key]);
|
3626 | });
|
3627 | }
|
3628 | if (created) {
|
3629 | callHook(created, instance, "c" );
|
3630 | }
|
3631 | function registerLifecycleHook(register, hook) {
|
3632 | if (isArray(hook)) {
|
3633 | hook.forEach(_hook => register(_hook.bind(publicThis)));
|
3634 | }
|
3635 | else if (hook) {
|
3636 | register(hook.bind(publicThis));
|
3637 | }
|
3638 | }
|
3639 | registerLifecycleHook(onBeforeMount, beforeMount);
|
3640 | registerLifecycleHook(onMounted, mounted);
|
3641 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
3642 | registerLifecycleHook(onUpdated, updated);
|
3643 | registerLifecycleHook(onActivated, activated);
|
3644 | registerLifecycleHook(onDeactivated, deactivated);
|
3645 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
3646 | registerLifecycleHook(onRenderTracked, renderTracked);
|
3647 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
3648 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
3649 | registerLifecycleHook(onUnmounted, unmounted);
|
3650 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
3651 | if (isArray(expose)) {
|
3652 | if (expose.length) {
|
3653 | const exposed = instance.exposed || (instance.exposed = {});
|
3654 | expose.forEach(key => {
|
3655 | Object.defineProperty(exposed, key, {
|
3656 | get: () => publicThis[key],
|
3657 | set: val => (publicThis[key] = val)
|
3658 | });
|
3659 | });
|
3660 | }
|
3661 | else if (!instance.exposed) {
|
3662 | instance.exposed = {};
|
3663 | }
|
3664 | }
|
3665 |
|
3666 |
|
3667 | if (render && instance.render === NOOP) {
|
3668 | instance.render = render;
|
3669 | }
|
3670 | if (inheritAttrs != null) {
|
3671 | instance.inheritAttrs = inheritAttrs;
|
3672 | }
|
3673 |
|
3674 | if (components)
|
3675 | instance.components = components;
|
3676 | if (directives)
|
3677 | instance.directives = directives;
|
3678 | }
|
3679 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
|
3680 | if (isArray(injectOptions)) {
|
3681 | injectOptions = normalizeInject(injectOptions);
|
3682 | }
|
3683 | for (const key in injectOptions) {
|
3684 | const opt = injectOptions[key];
|
3685 | let injected;
|
3686 | if (isObject(opt)) {
|
3687 | if ('default' in opt) {
|
3688 | injected = inject(opt.from || key, opt.default, true );
|
3689 | }
|
3690 | else {
|
3691 | injected = inject(opt.from || key);
|
3692 | }
|
3693 | }
|
3694 | else {
|
3695 | injected = inject(opt);
|
3696 | }
|
3697 | if (isRef(injected)) {
|
3698 |
|
3699 | if (unwrapRef) {
|
3700 | Object.defineProperty(ctx, key, {
|
3701 | enumerable: true,
|
3702 | configurable: true,
|
3703 | get: () => injected.value,
|
3704 | set: v => (injected.value = v)
|
3705 | });
|
3706 | }
|
3707 | else {
|
3708 | {
|
3709 | warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
|
3710 | `and no longer needs \`.value\` in the next minor release. ` +
|
3711 | `To opt-in to the new behavior now, ` +
|
3712 | `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
|
3713 | `temporary and will not be needed in the future.)`);
|
3714 | }
|
3715 | ctx[key] = injected;
|
3716 | }
|
3717 | }
|
3718 | else {
|
3719 | ctx[key] = injected;
|
3720 | }
|
3721 | {
|
3722 | checkDuplicateProperties("Inject" , key);
|
3723 | }
|
3724 | }
|
3725 | }
|
3726 | function callHook(hook, instance, type) {
|
3727 | callWithAsyncErrorHandling(isArray(hook)
|
3728 | ? hook.map(h => h.bind(instance.proxy))
|
3729 | : hook.bind(instance.proxy), instance, type);
|
3730 | }
|
3731 | function createWatcher(raw, ctx, publicThis, key) {
|
3732 | const getter = key.includes('.')
|
3733 | ? createPathGetter(publicThis, key)
|
3734 | : () => publicThis[key];
|
3735 | if (isString(raw)) {
|
3736 | const handler = ctx[raw];
|
3737 | if (isFunction(handler)) {
|
3738 | watch(getter, handler);
|
3739 | }
|
3740 | else {
|
3741 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
3742 | }
|
3743 | }
|
3744 | else if (isFunction(raw)) {
|
3745 | watch(getter, raw.bind(publicThis));
|
3746 | }
|
3747 | else if (isObject(raw)) {
|
3748 | if (isArray(raw)) {
|
3749 | raw.forEach(r => createWatcher(r, ctx, publicThis, key));
|
3750 | }
|
3751 | else {
|
3752 | const handler = isFunction(raw.handler)
|
3753 | ? raw.handler.bind(publicThis)
|
3754 | : ctx[raw.handler];
|
3755 | if (isFunction(handler)) {
|
3756 | watch(getter, handler, raw);
|
3757 | }
|
3758 | else {
|
3759 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
3760 | }
|
3761 | }
|
3762 | }
|
3763 | else {
|
3764 | warn$1(`Invalid watch option: "${key}"`, raw);
|
3765 | }
|
3766 | }
|
3767 | |
3768 |
|
3769 |
|
3770 |
|
3771 |
|
3772 | function resolveMergedOptions(instance) {
|
3773 | const base = instance.type;
|
3774 | const { mixins, extends: extendsOptions } = base;
|
3775 | const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
|
3776 | const cached = cache.get(base);
|
3777 | let resolved;
|
3778 | if (cached) {
|
3779 | resolved = cached;
|
3780 | }
|
3781 | else if (!globalMixins.length && !mixins && !extendsOptions) {
|
3782 | {
|
3783 | resolved = base;
|
3784 | }
|
3785 | }
|
3786 | else {
|
3787 | resolved = {};
|
3788 | if (globalMixins.length) {
|
3789 | globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
|
3790 | }
|
3791 | mergeOptions(resolved, base, optionMergeStrategies);
|
3792 | }
|
3793 | cache.set(base, resolved);
|
3794 | return resolved;
|
3795 | }
|
3796 | function mergeOptions(to, from, strats, asMixin = false) {
|
3797 | const { mixins, extends: extendsOptions } = from;
|
3798 | if (extendsOptions) {
|
3799 | mergeOptions(to, extendsOptions, strats, true);
|
3800 | }
|
3801 | if (mixins) {
|
3802 | mixins.forEach((m) => mergeOptions(to, m, strats, true));
|
3803 | }
|
3804 | for (const key in from) {
|
3805 | if (asMixin && key === 'expose') {
|
3806 | warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
|
3807 | `It should only be declared in the base component itself.`);
|
3808 | }
|
3809 | else {
|
3810 | const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
|
3811 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
3812 | }
|
3813 | }
|
3814 | return to;
|
3815 | }
|
3816 | const internalOptionMergeStrats = {
|
3817 | data: mergeDataFn,
|
3818 | props: mergeObjectOptions,
|
3819 | emits: mergeObjectOptions,
|
3820 |
|
3821 | methods: mergeObjectOptions,
|
3822 | computed: mergeObjectOptions,
|
3823 |
|
3824 | beforeCreate: mergeAsArray,
|
3825 | created: mergeAsArray,
|
3826 | beforeMount: mergeAsArray,
|
3827 | mounted: mergeAsArray,
|
3828 | beforeUpdate: mergeAsArray,
|
3829 | updated: mergeAsArray,
|
3830 | beforeDestroy: mergeAsArray,
|
3831 | beforeUnmount: mergeAsArray,
|
3832 | destroyed: mergeAsArray,
|
3833 | unmounted: mergeAsArray,
|
3834 | activated: mergeAsArray,
|
3835 | deactivated: mergeAsArray,
|
3836 | errorCaptured: mergeAsArray,
|
3837 | serverPrefetch: mergeAsArray,
|
3838 |
|
3839 | components: mergeObjectOptions,
|
3840 | directives: mergeObjectOptions,
|
3841 |
|
3842 | watch: mergeWatchOptions,
|
3843 |
|
3844 | provide: mergeDataFn,
|
3845 | inject: mergeInject
|
3846 | };
|
3847 | function mergeDataFn(to, from) {
|
3848 | if (!from) {
|
3849 | return to;
|
3850 | }
|
3851 | if (!to) {
|
3852 | return from;
|
3853 | }
|
3854 | return function mergedDataFn() {
|
3855 | return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
|
3856 | };
|
3857 | }
|
3858 | function mergeInject(to, from) {
|
3859 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
3860 | }
|
3861 | function normalizeInject(raw) {
|
3862 | if (isArray(raw)) {
|
3863 | const res = {};
|
3864 | for (let i = 0; i < raw.length; i++) {
|
3865 | res[raw[i]] = raw[i];
|
3866 | }
|
3867 | return res;
|
3868 | }
|
3869 | return raw;
|
3870 | }
|
3871 | function mergeAsArray(to, from) {
|
3872 | return to ? [...new Set([].concat(to, from))] : from;
|
3873 | }
|
3874 | function mergeObjectOptions(to, from) {
|
3875 | return to ? extend(extend(Object.create(null), to), from) : from;
|
3876 | }
|
3877 | function mergeWatchOptions(to, from) {
|
3878 | if (!to)
|
3879 | return from;
|
3880 | if (!from)
|
3881 | return to;
|
3882 | const merged = extend(Object.create(null), to);
|
3883 | for (const key in from) {
|
3884 | merged[key] = mergeAsArray(to[key], from[key]);
|
3885 | }
|
3886 | return merged;
|
3887 | }
|
3888 |
|
3889 | function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
|
3890 | isSSR = false) {
|
3891 | const props = {};
|
3892 | const attrs = {};
|
3893 | def(attrs, InternalObjectKey, 1);
|
3894 | instance.propsDefaults = Object.create(null);
|
3895 | setFullProps(instance, rawProps, props, attrs);
|
3896 |
|
3897 | for (const key in instance.propsOptions[0]) {
|
3898 | if (!(key in props)) {
|
3899 | props[key] = undefined;
|
3900 | }
|
3901 | }
|
3902 |
|
3903 | {
|
3904 | validateProps(rawProps || {}, props, instance);
|
3905 | }
|
3906 | if (isStateful) {
|
3907 |
|
3908 | instance.props = isSSR ? props : shallowReactive(props);
|
3909 | }
|
3910 | else {
|
3911 | if (!instance.type.props) {
|
3912 |
|
3913 | instance.props = attrs;
|
3914 | }
|
3915 | else {
|
3916 |
|
3917 | instance.props = props;
|
3918 | }
|
3919 | }
|
3920 | instance.attrs = attrs;
|
3921 | }
|
3922 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
3923 | const { props, attrs, vnode: { patchFlag } } = instance;
|
3924 | const rawCurrentProps = toRaw(props);
|
3925 | const [options] = instance.propsOptions;
|
3926 | let hasAttrsChanged = false;
|
3927 | if (
|
3928 |
|
3929 |
|
3930 |
|
3931 | !((instance.type.__hmrId ||
|
3932 | (instance.parent && instance.parent.type.__hmrId))) &&
|
3933 | (optimized || patchFlag > 0) &&
|
3934 | !(patchFlag & 16 )) {
|
3935 | if (patchFlag & 8 ) {
|
3936 |
|
3937 |
|
3938 | const propsToUpdate = instance.vnode.dynamicProps;
|
3939 | for (let i = 0; i < propsToUpdate.length; i++) {
|
3940 | let key = propsToUpdate[i];
|
3941 |
|
3942 | const value = rawProps[key];
|
3943 | if (options) {
|
3944 |
|
3945 |
|
3946 | if (hasOwn(attrs, key)) {
|
3947 | if (value !== attrs[key]) {
|
3948 | attrs[key] = value;
|
3949 | hasAttrsChanged = true;
|
3950 | }
|
3951 | }
|
3952 | else {
|
3953 | const camelizedKey = camelize(key);
|
3954 | props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false );
|
3955 | }
|
3956 | }
|
3957 | else {
|
3958 | if (value !== attrs[key]) {
|
3959 | attrs[key] = value;
|
3960 | hasAttrsChanged = true;
|
3961 | }
|
3962 | }
|
3963 | }
|
3964 | }
|
3965 | }
|
3966 | else {
|
3967 |
|
3968 | if (setFullProps(instance, rawProps, props, attrs)) {
|
3969 | hasAttrsChanged = true;
|
3970 | }
|
3971 |
|
3972 |
|
3973 | let kebabKey;
|
3974 | for (const key in rawCurrentProps) {
|
3975 | if (!rawProps ||
|
3976 |
|
3977 | (!hasOwn(rawProps, key) &&
|
3978 |
|
3979 |
|
3980 | ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
|
3981 | if (options) {
|
3982 | if (rawPrevProps &&
|
3983 |
|
3984 | (rawPrevProps[key] !== undefined ||
|
3985 |
|
3986 | rawPrevProps[kebabKey] !== undefined)) {
|
3987 | props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true );
|
3988 | }
|
3989 | }
|
3990 | else {
|
3991 | delete props[key];
|
3992 | }
|
3993 | }
|
3994 | }
|
3995 |
|
3996 |
|
3997 | if (attrs !== rawCurrentProps) {
|
3998 | for (const key in attrs) {
|
3999 | if (!rawProps || !hasOwn(rawProps, key)) {
|
4000 | delete attrs[key];
|
4001 | hasAttrsChanged = true;
|
4002 | }
|
4003 | }
|
4004 | }
|
4005 | }
|
4006 |
|
4007 | if (hasAttrsChanged) {
|
4008 | trigger(instance, "set" , '$attrs');
|
4009 | }
|
4010 | {
|
4011 | validateProps(rawProps || {}, props, instance);
|
4012 | }
|
4013 | }
|
4014 | function setFullProps(instance, rawProps, props, attrs) {
|
4015 | const [options, needCastKeys] = instance.propsOptions;
|
4016 | let hasAttrsChanged = false;
|
4017 | let rawCastValues;
|
4018 | if (rawProps) {
|
4019 | for (let key in rawProps) {
|
4020 |
|
4021 | if (isReservedProp(key)) {
|
4022 | continue;
|
4023 | }
|
4024 | const value = rawProps[key];
|
4025 |
|
4026 |
|
4027 | let camelKey;
|
4028 | if (options && hasOwn(options, (camelKey = camelize(key)))) {
|
4029 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
4030 | props[camelKey] = value;
|
4031 | }
|
4032 | else {
|
4033 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
4034 | }
|
4035 | }
|
4036 | else if (!isEmitListener(instance.emitsOptions, key)) {
|
4037 | if (value !== attrs[key]) {
|
4038 | attrs[key] = value;
|
4039 | hasAttrsChanged = true;
|
4040 | }
|
4041 | }
|
4042 | }
|
4043 | }
|
4044 | if (needCastKeys) {
|
4045 | const rawCurrentProps = toRaw(props);
|
4046 | const castValues = rawCastValues || EMPTY_OBJ;
|
4047 | for (let i = 0; i < needCastKeys.length; i++) {
|
4048 | const key = needCastKeys[i];
|
4049 | props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
|
4050 | }
|
4051 | }
|
4052 | return hasAttrsChanged;
|
4053 | }
|
4054 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
4055 | const opt = options[key];
|
4056 | if (opt != null) {
|
4057 | const hasDefault = hasOwn(opt, 'default');
|
4058 |
|
4059 | if (hasDefault && value === undefined) {
|
4060 | const defaultValue = opt.default;
|
4061 | if (opt.type !== Function && isFunction(defaultValue)) {
|
4062 | const { propsDefaults } = instance;
|
4063 | if (key in propsDefaults) {
|
4064 | value = propsDefaults[key];
|
4065 | }
|
4066 | else {
|
4067 | setCurrentInstance(instance);
|
4068 | value = propsDefaults[key] = defaultValue.call(null, props);
|
4069 | unsetCurrentInstance();
|
4070 | }
|
4071 | }
|
4072 | else {
|
4073 | value = defaultValue;
|
4074 | }
|
4075 | }
|
4076 |
|
4077 | if (opt[0 ]) {
|
4078 | if (isAbsent && !hasDefault) {
|
4079 | value = false;
|
4080 | }
|
4081 | else if (opt[1 ] &&
|
4082 | (value === '' || value === hyphenate(key))) {
|
4083 | value = true;
|
4084 | }
|
4085 | }
|
4086 | }
|
4087 | return value;
|
4088 | }
|
4089 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
4090 | const cache = appContext.propsCache;
|
4091 | const cached = cache.get(comp);
|
4092 | if (cached) {
|
4093 | return cached;
|
4094 | }
|
4095 | const raw = comp.props;
|
4096 | const normalized = {};
|
4097 | const needCastKeys = [];
|
4098 |
|
4099 | let hasExtends = false;
|
4100 | if (!isFunction(comp)) {
|
4101 | const extendProps = (raw) => {
|
4102 | hasExtends = true;
|
4103 | const [props, keys] = normalizePropsOptions(raw, appContext, true);
|
4104 | extend(normalized, props);
|
4105 | if (keys)
|
4106 | needCastKeys.push(...keys);
|
4107 | };
|
4108 | if (!asMixin && appContext.mixins.length) {
|
4109 | appContext.mixins.forEach(extendProps);
|
4110 | }
|
4111 | if (comp.extends) {
|
4112 | extendProps(comp.extends);
|
4113 | }
|
4114 | if (comp.mixins) {
|
4115 | comp.mixins.forEach(extendProps);
|
4116 | }
|
4117 | }
|
4118 | if (!raw && !hasExtends) {
|
4119 | cache.set(comp, EMPTY_ARR);
|
4120 | return EMPTY_ARR;
|
4121 | }
|
4122 | if (isArray(raw)) {
|
4123 | for (let i = 0; i < raw.length; i++) {
|
4124 | if (!isString(raw[i])) {
|
4125 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
4126 | }
|
4127 | const normalizedKey = camelize(raw[i]);
|
4128 | if (validatePropName(normalizedKey)) {
|
4129 | normalized[normalizedKey] = EMPTY_OBJ;
|
4130 | }
|
4131 | }
|
4132 | }
|
4133 | else if (raw) {
|
4134 | if (!isObject(raw)) {
|
4135 | warn$1(`invalid props options`, raw);
|
4136 | }
|
4137 | for (const key in raw) {
|
4138 | const normalizedKey = camelize(key);
|
4139 | if (validatePropName(normalizedKey)) {
|
4140 | const opt = raw[key];
|
4141 | const prop = (normalized[normalizedKey] =
|
4142 | isArray(opt) || isFunction(opt) ? { type: opt } : opt);
|
4143 | if (prop) {
|
4144 | const booleanIndex = getTypeIndex(Boolean, prop.type);
|
4145 | const stringIndex = getTypeIndex(String, prop.type);
|
4146 | prop[0 ] = booleanIndex > -1;
|
4147 | prop[1 ] =
|
4148 | stringIndex < 0 || booleanIndex < stringIndex;
|
4149 |
|
4150 | if (booleanIndex > -1 || hasOwn(prop, 'default')) {
|
4151 | needCastKeys.push(normalizedKey);
|
4152 | }
|
4153 | }
|
4154 | }
|
4155 | }
|
4156 | }
|
4157 | const res = [normalized, needCastKeys];
|
4158 | cache.set(comp, res);
|
4159 | return res;
|
4160 | }
|
4161 | function validatePropName(key) {
|
4162 | if (key[0] !== '$') {
|
4163 | return true;
|
4164 | }
|
4165 | else {
|
4166 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
4167 | }
|
4168 | return false;
|
4169 | }
|
4170 |
|
4171 |
|
4172 | function getType(ctor) {
|
4173 | const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
|
4174 | return match ? match[1] : ctor === null ? 'null' : '';
|
4175 | }
|
4176 | function isSameType(a, b) {
|
4177 | return getType(a) === getType(b);
|
4178 | }
|
4179 | function getTypeIndex(type, expectedTypes) {
|
4180 | if (isArray(expectedTypes)) {
|
4181 | return expectedTypes.findIndex(t => isSameType(t, type));
|
4182 | }
|
4183 | else if (isFunction(expectedTypes)) {
|
4184 | return isSameType(expectedTypes, type) ? 0 : -1;
|
4185 | }
|
4186 | return -1;
|
4187 | }
|
4188 | |
4189 |
|
4190 |
|
4191 | function validateProps(rawProps, props, instance) {
|
4192 | const resolvedValues = toRaw(props);
|
4193 | const options = instance.propsOptions[0];
|
4194 | for (const key in options) {
|
4195 | let opt = options[key];
|
4196 | if (opt == null)
|
4197 | continue;
|
4198 | validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
|
4199 | }
|
4200 | }
|
4201 | |
4202 |
|
4203 |
|
4204 | function validateProp(name, value, prop, isAbsent) {
|
4205 | const { type, required, validator } = prop;
|
4206 |
|
4207 | if (required && isAbsent) {
|
4208 | warn$1('Missing required prop: "' + name + '"');
|
4209 | return;
|
4210 | }
|
4211 |
|
4212 | if (value == null && !prop.required) {
|
4213 | return;
|
4214 | }
|
4215 |
|
4216 | if (type != null && type !== true) {
|
4217 | let isValid = false;
|
4218 | const types = isArray(type) ? type : [type];
|
4219 | const expectedTypes = [];
|
4220 |
|
4221 | for (let i = 0; i < types.length && !isValid; i++) {
|
4222 | const { valid, expectedType } = assertType(value, types[i]);
|
4223 | expectedTypes.push(expectedType || '');
|
4224 | isValid = valid;
|
4225 | }
|
4226 | if (!isValid) {
|
4227 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
4228 | return;
|
4229 | }
|
4230 | }
|
4231 |
|
4232 | if (validator && !validator(value)) {
|
4233 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
4234 | }
|
4235 | }
|
4236 | const isSimpleType = makeMap('String,Number,Boolean,Function,Symbol,BigInt');
|
4237 | |
4238 |
|
4239 |
|
4240 | function assertType(value, type) {
|
4241 | let valid;
|
4242 | const expectedType = getType(type);
|
4243 | if (isSimpleType(expectedType)) {
|
4244 | const t = typeof value;
|
4245 | valid = t === expectedType.toLowerCase();
|
4246 |
|
4247 | if (!valid && t === 'object') {
|
4248 | valid = value instanceof type;
|
4249 | }
|
4250 | }
|
4251 | else if (expectedType === 'Object') {
|
4252 | valid = isObject(value);
|
4253 | }
|
4254 | else if (expectedType === 'Array') {
|
4255 | valid = isArray(value);
|
4256 | }
|
4257 | else if (expectedType === 'null') {
|
4258 | valid = value === null;
|
4259 | }
|
4260 | else {
|
4261 | valid = value instanceof type;
|
4262 | }
|
4263 | return {
|
4264 | valid,
|
4265 | expectedType
|
4266 | };
|
4267 | }
|
4268 | |
4269 |
|
4270 |
|
4271 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
4272 | let message = `Invalid prop: type check failed for prop "${name}".` +
|
4273 | ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
|
4274 | const expectedType = expectedTypes[0];
|
4275 | const receivedType = toRawType(value);
|
4276 | const expectedValue = styleValue(value, expectedType);
|
4277 | const receivedValue = styleValue(value, receivedType);
|
4278 |
|
4279 | if (expectedTypes.length === 1 &&
|
4280 | isExplicable(expectedType) &&
|
4281 | !isBoolean(expectedType, receivedType)) {
|
4282 | message += ` with value ${expectedValue}`;
|
4283 | }
|
4284 | message += `, got ${receivedType} `;
|
4285 |
|
4286 | if (isExplicable(receivedType)) {
|
4287 | message += `with value ${receivedValue}.`;
|
4288 | }
|
4289 | return message;
|
4290 | }
|
4291 | |
4292 |
|
4293 |
|
4294 | function styleValue(value, type) {
|
4295 | if (type === 'String') {
|
4296 | return `"${value}"`;
|
4297 | }
|
4298 | else if (type === 'Number') {
|
4299 | return `${Number(value)}`;
|
4300 | }
|
4301 | else {
|
4302 | return `${value}`;
|
4303 | }
|
4304 | }
|
4305 | |
4306 |
|
4307 |
|
4308 | function isExplicable(type) {
|
4309 | const explicitTypes = ['string', 'number', 'boolean'];
|
4310 | return explicitTypes.some(elem => type.toLowerCase() === elem);
|
4311 | }
|
4312 | |
4313 |
|
4314 |
|
4315 | function isBoolean(...args) {
|
4316 | return args.some(elem => elem.toLowerCase() === 'boolean');
|
4317 | }
|
4318 |
|
4319 | const isInternalKey = (key) => key[0] === '_' || key === '$stable';
|
4320 | const normalizeSlotValue = (value) => isArray(value)
|
4321 | ? value.map(normalizeVNode)
|
4322 | : [normalizeVNode(value)];
|
4323 | const normalizeSlot = (key, rawSlot, ctx) => {
|
4324 | const normalized = withCtx((...args) => {
|
4325 | if (currentInstance) {
|
4326 | warn$1(`Slot "${key}" invoked outside of the render function: ` +
|
4327 | `this will not track dependencies used in the slot. ` +
|
4328 | `Invoke the slot function inside the render function instead.`);
|
4329 | }
|
4330 | return normalizeSlotValue(rawSlot(...args));
|
4331 | }, ctx);
|
4332 | normalized._c = false;
|
4333 | return normalized;
|
4334 | };
|
4335 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
4336 | const ctx = rawSlots._ctx;
|
4337 | for (const key in rawSlots) {
|
4338 | if (isInternalKey(key))
|
4339 | continue;
|
4340 | const value = rawSlots[key];
|
4341 | if (isFunction(value)) {
|
4342 | slots[key] = normalizeSlot(key, value, ctx);
|
4343 | }
|
4344 | else if (value != null) {
|
4345 | {
|
4346 | warn$1(`Non-function value encountered for slot "${key}". ` +
|
4347 | `Prefer function slots for better performance.`);
|
4348 | }
|
4349 | const normalized = normalizeSlotValue(value);
|
4350 | slots[key] = () => normalized;
|
4351 | }
|
4352 | }
|
4353 | };
|
4354 | const normalizeVNodeSlots = (instance, children) => {
|
4355 | if (!isKeepAlive(instance.vnode) &&
|
4356 | !(false )) {
|
4357 | warn$1(`Non-function value encountered for default slot. ` +
|
4358 | `Prefer function slots for better performance.`);
|
4359 | }
|
4360 | const normalized = normalizeSlotValue(children);
|
4361 | instance.slots.default = () => normalized;
|
4362 | };
|
4363 | const initSlots = (instance, children) => {
|
4364 | if (instance.vnode.shapeFlag & 32 ) {
|
4365 | const type = children._;
|
4366 | if (type) {
|
4367 |
|
4368 |
|
4369 | instance.slots = toRaw(children);
|
4370 |
|
4371 | def(children, '_', type);
|
4372 | }
|
4373 | else {
|
4374 | normalizeObjectSlots(children, (instance.slots = {}));
|
4375 | }
|
4376 | }
|
4377 | else {
|
4378 | instance.slots = {};
|
4379 | if (children) {
|
4380 | normalizeVNodeSlots(instance, children);
|
4381 | }
|
4382 | }
|
4383 | def(instance.slots, InternalObjectKey, 1);
|
4384 | };
|
4385 | const updateSlots = (instance, children, optimized) => {
|
4386 | const { vnode, slots } = instance;
|
4387 | let needDeletionCheck = true;
|
4388 | let deletionComparisonTarget = EMPTY_OBJ;
|
4389 | if (vnode.shapeFlag & 32 ) {
|
4390 | const type = children._;
|
4391 | if (type) {
|
4392 |
|
4393 | if (isHmrUpdating) {
|
4394 |
|
4395 |
|
4396 | extend(slots, children);
|
4397 | }
|
4398 | else if (optimized && type === 1 ) {
|
4399 |
|
4400 |
|
4401 | needDeletionCheck = false;
|
4402 | }
|
4403 | else {
|
4404 |
|
4405 |
|
4406 | extend(slots, children);
|
4407 |
|
4408 |
|
4409 |
|
4410 |
|
4411 | if (!optimized && type === 1 ) {
|
4412 | delete slots._;
|
4413 | }
|
4414 | }
|
4415 | }
|
4416 | else {
|
4417 | needDeletionCheck = !children.$stable;
|
4418 | normalizeObjectSlots(children, slots);
|
4419 | }
|
4420 | deletionComparisonTarget = children;
|
4421 | }
|
4422 | else if (children) {
|
4423 |
|
4424 | normalizeVNodeSlots(instance, children);
|
4425 | deletionComparisonTarget = { default: 1 };
|
4426 | }
|
4427 |
|
4428 | if (needDeletionCheck) {
|
4429 | for (const key in slots) {
|
4430 | if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
|
4431 | delete slots[key];
|
4432 | }
|
4433 | }
|
4434 | }
|
4435 | };
|
4436 |
|
4437 | |
4438 |
|
4439 |
|
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 |
|
4445 |
|
4446 |
|
4447 |
|
4448 |
|
4449 | const isBuiltInDirective = makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
|
4450 | function validateDirectiveName(name) {
|
4451 | if (isBuiltInDirective(name)) {
|
4452 | warn$1('Do not use built-in directive ids as custom directive id: ' + name);
|
4453 | }
|
4454 | }
|
4455 | |
4456 |
|
4457 |
|
4458 | function withDirectives(vnode, directives) {
|
4459 | const internalInstance = currentRenderingInstance;
|
4460 | if (internalInstance === null) {
|
4461 | warn$1(`withDirectives can only be used inside render functions.`);
|
4462 | return vnode;
|
4463 | }
|
4464 | const instance = internalInstance.proxy;
|
4465 | const bindings = vnode.dirs || (vnode.dirs = []);
|
4466 | for (let i = 0; i < directives.length; i++) {
|
4467 | let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
|
4468 | if (isFunction(dir)) {
|
4469 | dir = {
|
4470 | mounted: dir,
|
4471 | updated: dir
|
4472 | };
|
4473 | }
|
4474 | if (dir.deep) {
|
4475 | traverse(value);
|
4476 | }
|
4477 | bindings.push({
|
4478 | dir,
|
4479 | instance,
|
4480 | value,
|
4481 | oldValue: void 0,
|
4482 | arg,
|
4483 | modifiers
|
4484 | });
|
4485 | }
|
4486 | return vnode;
|
4487 | }
|
4488 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
4489 | const bindings = vnode.dirs;
|
4490 | const oldBindings = prevVNode && prevVNode.dirs;
|
4491 | for (let i = 0; i < bindings.length; i++) {
|
4492 | const binding = bindings[i];
|
4493 | if (oldBindings) {
|
4494 | binding.oldValue = oldBindings[i].value;
|
4495 | }
|
4496 | let hook = binding.dir[name];
|
4497 | if (hook) {
|
4498 |
|
4499 |
|
4500 | pauseTracking();
|
4501 | callWithAsyncErrorHandling(hook, instance, 8 , [
|
4502 | vnode.el,
|
4503 | binding,
|
4504 | vnode,
|
4505 | prevVNode
|
4506 | ]);
|
4507 | resetTracking();
|
4508 | }
|
4509 | }
|
4510 | }
|
4511 |
|
4512 | function createAppContext() {
|
4513 | return {
|
4514 | app: null,
|
4515 | config: {
|
4516 | isNativeTag: NO,
|
4517 | performance: false,
|
4518 | globalProperties: {},
|
4519 | optionMergeStrategies: {},
|
4520 | errorHandler: undefined,
|
4521 | warnHandler: undefined,
|
4522 | compilerOptions: {}
|
4523 | },
|
4524 | mixins: [],
|
4525 | components: {},
|
4526 | directives: {},
|
4527 | provides: Object.create(null),
|
4528 | optionsCache: new WeakMap(),
|
4529 | propsCache: new WeakMap(),
|
4530 | emitsCache: new WeakMap()
|
4531 | };
|
4532 | }
|
4533 | let uid = 0;
|
4534 | function createAppAPI(render, hydrate) {
|
4535 | return function createApp(rootComponent, rootProps = null) {
|
4536 | if (rootProps != null && !isObject(rootProps)) {
|
4537 | warn$1(`root props passed to app.mount() must be an object.`);
|
4538 | rootProps = null;
|
4539 | }
|
4540 | const context = createAppContext();
|
4541 | const installedPlugins = new Set();
|
4542 | let isMounted = false;
|
4543 | const app = (context.app = {
|
4544 | _uid: uid++,
|
4545 | _component: rootComponent,
|
4546 | _props: rootProps,
|
4547 | _container: null,
|
4548 | _context: context,
|
4549 | _instance: null,
|
4550 | version,
|
4551 | get config() {
|
4552 | return context.config;
|
4553 | },
|
4554 | set config(v) {
|
4555 | {
|
4556 | warn$1(`app.config cannot be replaced. Modify individual options instead.`);
|
4557 | }
|
4558 | },
|
4559 | use(plugin, ...options) {
|
4560 | if (installedPlugins.has(plugin)) {
|
4561 | warn$1(`Plugin has already been applied to target app.`);
|
4562 | }
|
4563 | else if (plugin && isFunction(plugin.install)) {
|
4564 | installedPlugins.add(plugin);
|
4565 | plugin.install(app, ...options);
|
4566 | }
|
4567 | else if (isFunction(plugin)) {
|
4568 | installedPlugins.add(plugin);
|
4569 | plugin(app, ...options);
|
4570 | }
|
4571 | else {
|
4572 | warn$1(`A plugin must either be a function or an object with an "install" ` +
|
4573 | `function.`);
|
4574 | }
|
4575 | return app;
|
4576 | },
|
4577 | mixin(mixin) {
|
4578 | {
|
4579 | if (!context.mixins.includes(mixin)) {
|
4580 | context.mixins.push(mixin);
|
4581 | }
|
4582 | else {
|
4583 | warn$1('Mixin has already been applied to target app' +
|
4584 | (mixin.name ? `: ${mixin.name}` : ''));
|
4585 | }
|
4586 | }
|
4587 | return app;
|
4588 | },
|
4589 | component(name, component) {
|
4590 | {
|
4591 | validateComponentName(name, context.config);
|
4592 | }
|
4593 | if (!component) {
|
4594 | return context.components[name];
|
4595 | }
|
4596 | if (context.components[name]) {
|
4597 | warn$1(`Component "${name}" has already been registered in target app.`);
|
4598 | }
|
4599 | context.components[name] = component;
|
4600 | return app;
|
4601 | },
|
4602 | directive(name, directive) {
|
4603 | {
|
4604 | validateDirectiveName(name);
|
4605 | }
|
4606 | if (!directive) {
|
4607 | return context.directives[name];
|
4608 | }
|
4609 | if (context.directives[name]) {
|
4610 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
4611 | }
|
4612 | context.directives[name] = directive;
|
4613 | return app;
|
4614 | },
|
4615 | mount(rootContainer, isHydrate, isSVG) {
|
4616 | if (!isMounted) {
|
4617 | const vnode = createVNode(rootComponent, rootProps);
|
4618 |
|
4619 |
|
4620 | vnode.appContext = context;
|
4621 |
|
4622 | {
|
4623 | context.reload = () => {
|
4624 | render(cloneVNode(vnode), rootContainer, isSVG);
|
4625 | };
|
4626 | }
|
4627 | if (isHydrate && hydrate) {
|
4628 | hydrate(vnode, rootContainer);
|
4629 | }
|
4630 | else {
|
4631 | render(vnode, rootContainer, isSVG);
|
4632 | }
|
4633 | isMounted = true;
|
4634 | app._container = rootContainer;
|
4635 | rootContainer.__vue_app__ = app;
|
4636 | {
|
4637 | app._instance = vnode.component;
|
4638 | devtoolsInitApp(app, version);
|
4639 | }
|
4640 | return getExposeProxy(vnode.component) || vnode.component.proxy;
|
4641 | }
|
4642 | else {
|
4643 | warn$1(`App has already been mounted.\n` +
|
4644 | `If you want to remount the same app, move your app creation logic ` +
|
4645 | `into a factory function and create fresh app instances for each ` +
|
4646 | `mount - e.g. \`const createMyApp = () => createApp(App)\``);
|
4647 | }
|
4648 | },
|
4649 | unmount() {
|
4650 | if (isMounted) {
|
4651 | render(null, app._container);
|
4652 | {
|
4653 | app._instance = null;
|
4654 | devtoolsUnmountApp(app);
|
4655 | }
|
4656 | delete app._container.__vue_app__;
|
4657 | }
|
4658 | else {
|
4659 | warn$1(`Cannot unmount an app that is not mounted.`);
|
4660 | }
|
4661 | },
|
4662 | provide(key, value) {
|
4663 | if (key in context.provides) {
|
4664 | warn$1(`App already provides property with key "${String(key)}". ` +
|
4665 | `It will be overwritten with the new value.`);
|
4666 | }
|
4667 |
|
4668 |
|
4669 | context.provides[key] = value;
|
4670 | return app;
|
4671 | }
|
4672 | });
|
4673 | return app;
|
4674 | };
|
4675 | }
|
4676 |
|
4677 | let hasMismatch = false;
|
4678 | const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
|
4679 | const isComment = (node) => node.nodeType === 8 ;
|
4680 |
|
4681 |
|
4682 |
|
4683 |
|
4684 |
|
4685 | function createHydrationFunctions(rendererInternals) {
|
4686 | const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
|
4687 | const hydrate = (vnode, container) => {
|
4688 | if (!container.hasChildNodes()) {
|
4689 | warn$1(`Attempting to hydrate existing markup but container is empty. ` +
|
4690 | `Performing full mount instead.`);
|
4691 | patch(null, vnode, container);
|
4692 | flushPostFlushCbs();
|
4693 | return;
|
4694 | }
|
4695 | hasMismatch = false;
|
4696 | hydrateNode(container.firstChild, vnode, null, null, null);
|
4697 | flushPostFlushCbs();
|
4698 | if (hasMismatch && !false) {
|
4699 |
|
4700 | console.error(`Hydration completed but contains mismatches.`);
|
4701 | }
|
4702 | };
|
4703 | const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
4704 | const isFragmentStart = isComment(node) && node.data === '[';
|
4705 | const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
|
4706 | const { type, ref, shapeFlag } = vnode;
|
4707 | const domType = node.nodeType;
|
4708 | vnode.el = node;
|
4709 | let nextNode = null;
|
4710 | switch (type) {
|
4711 | case Text:
|
4712 | if (domType !== 3 ) {
|
4713 | nextNode = onMismatch();
|
4714 | }
|
4715 | else {
|
4716 | if (node.data !== vnode.children) {
|
4717 | hasMismatch = true;
|
4718 | warn$1(`Hydration text mismatch:` +
|
4719 | `\n- Client: ${JSON.stringify(node.data)}` +
|
4720 | `\n- Server: ${JSON.stringify(vnode.children)}`);
|
4721 | node.data = vnode.children;
|
4722 | }
|
4723 | nextNode = nextSibling(node);
|
4724 | }
|
4725 | break;
|
4726 | case Comment:
|
4727 | if (domType !== 8 || isFragmentStart) {
|
4728 | nextNode = onMismatch();
|
4729 | }
|
4730 | else {
|
4731 | nextNode = nextSibling(node);
|
4732 | }
|
4733 | break;
|
4734 | case Static:
|
4735 | if (domType !== 1 ) {
|
4736 | nextNode = onMismatch();
|
4737 | }
|
4738 | else {
|
4739 |
|
4740 | nextNode = node;
|
4741 |
|
4742 |
|
4743 | const needToAdoptContent = !vnode.children.length;
|
4744 | for (let i = 0; i < vnode.staticCount; i++) {
|
4745 | if (needToAdoptContent)
|
4746 | vnode.children += nextNode.outerHTML;
|
4747 | if (i === vnode.staticCount - 1) {
|
4748 | vnode.anchor = nextNode;
|
4749 | }
|
4750 | nextNode = nextSibling(nextNode);
|
4751 | }
|
4752 | return nextNode;
|
4753 | }
|
4754 | break;
|
4755 | case Fragment:
|
4756 | if (!isFragmentStart) {
|
4757 | nextNode = onMismatch();
|
4758 | }
|
4759 | else {
|
4760 | nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
4761 | }
|
4762 | break;
|
4763 | default:
|
4764 | if (shapeFlag & 1 ) {
|
4765 | if (domType !== 1 ||
|
4766 | vnode.type.toLowerCase() !==
|
4767 | node.tagName.toLowerCase()) {
|
4768 | nextNode = onMismatch();
|
4769 | }
|
4770 | else {
|
4771 | nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
4772 | }
|
4773 | }
|
4774 | else if (shapeFlag & 6 ) {
|
4775 |
|
4776 |
|
4777 |
|
4778 | vnode.slotScopeIds = slotScopeIds;
|
4779 | const container = parentNode(node);
|
4780 | mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
|
4781 |
|
4782 |
|
4783 |
|
4784 | nextNode = isFragmentStart
|
4785 | ? locateClosingAsyncAnchor(node)
|
4786 | : nextSibling(node);
|
4787 |
|
4788 |
|
4789 |
|
4790 |
|
4791 | if (isAsyncWrapper(vnode)) {
|
4792 | let subTree;
|
4793 | if (isFragmentStart) {
|
4794 | subTree = createVNode(Fragment);
|
4795 | subTree.anchor = nextNode
|
4796 | ? nextNode.previousSibling
|
4797 | : container.lastChild;
|
4798 | }
|
4799 | else {
|
4800 | subTree =
|
4801 | node.nodeType === 3 ? createTextVNode('') : createVNode('div');
|
4802 | }
|
4803 | subTree.el = node;
|
4804 | vnode.component.subTree = subTree;
|
4805 | }
|
4806 | }
|
4807 | else if (shapeFlag & 64 ) {
|
4808 | if (domType !== 8 ) {
|
4809 | nextNode = onMismatch();
|
4810 | }
|
4811 | else {
|
4812 | nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
|
4813 | }
|
4814 | }
|
4815 | else if (shapeFlag & 128 ) {
|
4816 | nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
|
4817 | }
|
4818 | else {
|
4819 | warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
|
4820 | }
|
4821 | }
|
4822 | if (ref != null) {
|
4823 | setRef(ref, null, parentSuspense, vnode);
|
4824 | }
|
4825 | return nextNode;
|
4826 | };
|
4827 | const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
4828 | optimized = optimized || !!vnode.dynamicChildren;
|
4829 | const { type, props, patchFlag, shapeFlag, dirs } = vnode;
|
4830 |
|
4831 |
|
4832 | const forcePatchValue = (type === 'input' && dirs) || type === 'option';
|
4833 |
|
4834 | if (forcePatchValue || patchFlag !== -1 ) {
|
4835 | if (dirs) {
|
4836 | invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
4837 | }
|
4838 |
|
4839 | if (props) {
|
4840 | if (forcePatchValue ||
|
4841 | !optimized ||
|
4842 | patchFlag & (16 | 32 )) {
|
4843 | for (const key in props) {
|
4844 | if ((forcePatchValue && key.endsWith('value')) ||
|
4845 | (isOn(key) && !isReservedProp(key))) {
|
4846 | patchProp(el, key, null, props[key], false, undefined, parentComponent);
|
4847 | }
|
4848 | }
|
4849 | }
|
4850 | else if (props.onClick) {
|
4851 |
|
4852 |
|
4853 | patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
|
4854 | }
|
4855 | }
|
4856 |
|
4857 | let vnodeHooks;
|
4858 | if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
|
4859 | invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
4860 | }
|
4861 | if (dirs) {
|
4862 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
|
4863 | }
|
4864 | if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
|
4865 | queueEffectWithSuspense(() => {
|
4866 | vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
4867 | dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
|
4868 | }, parentSuspense);
|
4869 | }
|
4870 |
|
4871 | if (shapeFlag & 16 &&
|
4872 |
|
4873 | !(props && (props.innerHTML || props.textContent))) {
|
4874 | let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
|
4875 | let hasWarned = false;
|
4876 | while (next) {
|
4877 | hasMismatch = true;
|
4878 | if (!hasWarned) {
|
4879 | warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
|
4880 | `server rendered element contains more child nodes than client vdom.`);
|
4881 | hasWarned = true;
|
4882 | }
|
4883 |
|
4884 | const cur = next;
|
4885 | next = next.nextSibling;
|
4886 | remove(cur);
|
4887 | }
|
4888 | }
|
4889 | else if (shapeFlag & 8 ) {
|
4890 | if (el.textContent !== vnode.children) {
|
4891 | hasMismatch = true;
|
4892 | warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
|
4893 | `- Client: ${el.textContent}\n` +
|
4894 | `- Server: ${vnode.children}`);
|
4895 | el.textContent = vnode.children;
|
4896 | }
|
4897 | }
|
4898 | }
|
4899 | return el.nextSibling;
|
4900 | };
|
4901 | const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
4902 | optimized = optimized || !!parentVNode.dynamicChildren;
|
4903 | const children = parentVNode.children;
|
4904 | const l = children.length;
|
4905 | let hasWarned = false;
|
4906 | for (let i = 0; i < l; i++) {
|
4907 | const vnode = optimized
|
4908 | ? children[i]
|
4909 | : (children[i] = normalizeVNode(children[i]));
|
4910 | if (node) {
|
4911 | node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
|
4912 | }
|
4913 | else if (vnode.type === Text && !vnode.children) {
|
4914 | continue;
|
4915 | }
|
4916 | else {
|
4917 | hasMismatch = true;
|
4918 | if (!hasWarned) {
|
4919 | warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
|
4920 | `server rendered element contains fewer child nodes than client vdom.`);
|
4921 | hasWarned = true;
|
4922 | }
|
4923 |
|
4924 | patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
|
4925 | }
|
4926 | }
|
4927 | return node;
|
4928 | };
|
4929 | const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
4930 | const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
4931 | if (fragmentSlotScopeIds) {
|
4932 | slotScopeIds = slotScopeIds
|
4933 | ? slotScopeIds.concat(fragmentSlotScopeIds)
|
4934 | : fragmentSlotScopeIds;
|
4935 | }
|
4936 | const container = parentNode(node);
|
4937 | const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
|
4938 | if (next && isComment(next) && next.data === ']') {
|
4939 | return nextSibling((vnode.anchor = next));
|
4940 | }
|
4941 | else {
|
4942 |
|
4943 |
|
4944 | hasMismatch = true;
|
4945 |
|
4946 | insert((vnode.anchor = createComment(`]`)), container, next);
|
4947 | return next;
|
4948 | }
|
4949 | };
|
4950 | const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
4951 | hasMismatch = true;
|
4952 | warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3
|
4953 | ? `(text)`
|
4954 | : isComment(node) && node.data === '['
|
4955 | ? `(start of fragment)`
|
4956 | : ``);
|
4957 | vnode.el = null;
|
4958 | if (isFragment) {
|
4959 |
|
4960 | const end = locateClosingAsyncAnchor(node);
|
4961 | while (true) {
|
4962 | const next = nextSibling(node);
|
4963 | if (next && next !== end) {
|
4964 | remove(next);
|
4965 | }
|
4966 | else {
|
4967 | break;
|
4968 | }
|
4969 | }
|
4970 | }
|
4971 | const next = nextSibling(node);
|
4972 | const container = parentNode(node);
|
4973 | remove(node);
|
4974 | patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
|
4975 | return next;
|
4976 | };
|
4977 | const locateClosingAsyncAnchor = (node) => {
|
4978 | let match = 0;
|
4979 | while (node) {
|
4980 | node = nextSibling(node);
|
4981 | if (node && isComment(node)) {
|
4982 | if (node.data === '[')
|
4983 | match++;
|
4984 | if (node.data === ']') {
|
4985 | if (match === 0) {
|
4986 | return nextSibling(node);
|
4987 | }
|
4988 | else {
|
4989 | match--;
|
4990 | }
|
4991 | }
|
4992 | }
|
4993 | }
|
4994 | return node;
|
4995 | };
|
4996 | return [hydrate, hydrateNode];
|
4997 | }
|
4998 |
|
4999 | let supported;
|
5000 | let perf;
|
5001 | function startMeasure(instance, type) {
|
5002 | if (instance.appContext.config.performance && isSupported()) {
|
5003 | perf.mark(`vue-${type}-${instance.uid}`);
|
5004 | }
|
5005 | {
|
5006 | devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
|
5007 | }
|
5008 | }
|
5009 | function endMeasure(instance, type) {
|
5010 | if (instance.appContext.config.performance && isSupported()) {
|
5011 | const startTag = `vue-${type}-${instance.uid}`;
|
5012 | const endTag = startTag + `:end`;
|
5013 | perf.mark(endTag);
|
5014 | perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
|
5015 | perf.clearMarks(startTag);
|
5016 | perf.clearMarks(endTag);
|
5017 | }
|
5018 | {
|
5019 | devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
|
5020 | }
|
5021 | }
|
5022 | function isSupported() {
|
5023 | if (supported !== undefined) {
|
5024 | return supported;
|
5025 | }
|
5026 |
|
5027 | if (typeof window !== 'undefined' && window.performance) {
|
5028 | supported = true;
|
5029 | perf = window.performance;
|
5030 | }
|
5031 | else {
|
5032 | supported = false;
|
5033 | }
|
5034 |
|
5035 | return supported;
|
5036 | }
|
5037 |
|
5038 | const queuePostRenderEffect = queueEffectWithSuspense
|
5039 | ;
|
5040 | |
5041 |
|
5042 |
|
5043 |
|
5044 |
|
5045 |
|
5046 |
|
5047 |
|
5048 |
|
5049 |
|
5050 |
|
5051 |
|
5052 |
|
5053 |
|
5054 |
|
5055 | function createRenderer(options) {
|
5056 | return baseCreateRenderer(options);
|
5057 | }
|
5058 |
|
5059 |
|
5060 |
|
5061 | function createHydrationRenderer(options) {
|
5062 | return baseCreateRenderer(options, createHydrationFunctions);
|
5063 | }
|
5064 |
|
5065 | function baseCreateRenderer(options, createHydrationFns) {
|
5066 | const target = getGlobalThis();
|
5067 | target.__VUE__ = true;
|
5068 | {
|
5069 | setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
5070 | }
|
5071 | 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;
|
5072 |
|
5073 |
|
5074 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
5075 | if (n1 === n2) {
|
5076 | return;
|
5077 | }
|
5078 |
|
5079 | if (n1 && !isSameVNodeType(n1, n2)) {
|
5080 | anchor = getNextHostNode(n1);
|
5081 | unmount(n1, parentComponent, parentSuspense, true);
|
5082 | n1 = null;
|
5083 | }
|
5084 | if (n2.patchFlag === -2 ) {
|
5085 | optimized = false;
|
5086 | n2.dynamicChildren = null;
|
5087 | }
|
5088 | const { type, ref, shapeFlag } = n2;
|
5089 | switch (type) {
|
5090 | case Text:
|
5091 | processText(n1, n2, container, anchor);
|
5092 | break;
|
5093 | case Comment:
|
5094 | processCommentNode(n1, n2, container, anchor);
|
5095 | break;
|
5096 | case Static:
|
5097 | if (n1 == null) {
|
5098 | mountStaticNode(n2, container, anchor, isSVG);
|
5099 | }
|
5100 | else {
|
5101 | patchStaticNode(n1, n2, container, isSVG);
|
5102 | }
|
5103 | break;
|
5104 | case Fragment:
|
5105 | processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5106 | break;
|
5107 | default:
|
5108 | if (shapeFlag & 1 ) {
|
5109 | processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5110 | }
|
5111 | else if (shapeFlag & 6 ) {
|
5112 | processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5113 | }
|
5114 | else if (shapeFlag & 64 ) {
|
5115 | type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
|
5116 | }
|
5117 | else if (shapeFlag & 128 ) {
|
5118 | type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
|
5119 | }
|
5120 | else {
|
5121 | warn$1('Invalid VNode type:', type, `(${typeof type})`);
|
5122 | }
|
5123 | }
|
5124 |
|
5125 | if (ref != null && parentComponent) {
|
5126 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
5127 | }
|
5128 | };
|
5129 | const processText = (n1, n2, container, anchor) => {
|
5130 | if (n1 == null) {
|
5131 | hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
|
5132 | }
|
5133 | else {
|
5134 | const el = (n2.el = n1.el);
|
5135 | if (n2.children !== n1.children) {
|
5136 | hostSetText(el, n2.children);
|
5137 | }
|
5138 | }
|
5139 | };
|
5140 | const processCommentNode = (n1, n2, container, anchor) => {
|
5141 | if (n1 == null) {
|
5142 | hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
|
5143 | }
|
5144 | else {
|
5145 |
|
5146 | n2.el = n1.el;
|
5147 | }
|
5148 | };
|
5149 | const mountStaticNode = (n2, container, anchor, isSVG) => {
|
5150 | [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
|
5151 | };
|
5152 | |
5153 |
|
5154 |
|
5155 | const patchStaticNode = (n1, n2, container, isSVG) => {
|
5156 |
|
5157 | if (n2.children !== n1.children) {
|
5158 | const anchor = hostNextSibling(n1.anchor);
|
5159 |
|
5160 | removeStaticNode(n1);
|
5161 | [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
|
5162 | }
|
5163 | else {
|
5164 | n2.el = n1.el;
|
5165 | n2.anchor = n1.anchor;
|
5166 | }
|
5167 | };
|
5168 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
5169 | let next;
|
5170 | while (el && el !== anchor) {
|
5171 | next = hostNextSibling(el);
|
5172 | hostInsert(el, container, nextSibling);
|
5173 | el = next;
|
5174 | }
|
5175 | hostInsert(anchor, container, nextSibling);
|
5176 | };
|
5177 | const removeStaticNode = ({ el, anchor }) => {
|
5178 | let next;
|
5179 | while (el && el !== anchor) {
|
5180 | next = hostNextSibling(el);
|
5181 | hostRemove(el);
|
5182 | el = next;
|
5183 | }
|
5184 | hostRemove(anchor);
|
5185 | };
|
5186 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5187 | isSVG = isSVG || n2.type === 'svg';
|
5188 | if (n1 == null) {
|
5189 | mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5190 | }
|
5191 | else {
|
5192 | patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5193 | }
|
5194 | };
|
5195 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5196 | let el;
|
5197 | let vnodeHook;
|
5198 | const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
|
5199 | {
|
5200 | el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
|
5201 |
|
5202 |
|
5203 | if (shapeFlag & 8 ) {
|
5204 | hostSetElementText(el, vnode.children);
|
5205 | }
|
5206 | else if (shapeFlag & 16 ) {
|
5207 | mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
|
5208 | }
|
5209 | if (dirs) {
|
5210 | invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
5211 | }
|
5212 |
|
5213 | if (props) {
|
5214 | for (const key in props) {
|
5215 | if (key !== 'value' && !isReservedProp(key)) {
|
5216 | hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5217 | }
|
5218 | }
|
5219 | |
5220 |
|
5221 |
|
5222 |
|
5223 |
|
5224 |
|
5225 |
|
5226 |
|
5227 |
|
5228 | if ('value' in props) {
|
5229 | hostPatchProp(el, 'value', null, props.value);
|
5230 | }
|
5231 | if ((vnodeHook = props.onVnodeBeforeMount)) {
|
5232 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
5233 | }
|
5234 | }
|
5235 |
|
5236 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
5237 | }
|
5238 | {
|
5239 | Object.defineProperty(el, '__vnode', {
|
5240 | value: vnode,
|
5241 | enumerable: false
|
5242 | });
|
5243 | Object.defineProperty(el, '__vueParentComponent', {
|
5244 | value: parentComponent,
|
5245 | enumerable: false
|
5246 | });
|
5247 | }
|
5248 | if (dirs) {
|
5249 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
|
5250 | }
|
5251 |
|
5252 |
|
5253 | const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
|
5254 | transition &&
|
5255 | !transition.persisted;
|
5256 | if (needCallTransitionHooks) {
|
5257 | transition.beforeEnter(el);
|
5258 | }
|
5259 | hostInsert(el, container, anchor);
|
5260 | if ((vnodeHook = props && props.onVnodeMounted) ||
|
5261 | needCallTransitionHooks ||
|
5262 | dirs) {
|
5263 | queuePostRenderEffect(() => {
|
5264 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
5265 | needCallTransitionHooks && transition.enter(el);
|
5266 | dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
|
5267 | }, parentSuspense);
|
5268 | }
|
5269 | };
|
5270 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
5271 | if (scopeId) {
|
5272 | hostSetScopeId(el, scopeId);
|
5273 | }
|
5274 | if (slotScopeIds) {
|
5275 | for (let i = 0; i < slotScopeIds.length; i++) {
|
5276 | hostSetScopeId(el, slotScopeIds[i]);
|
5277 | }
|
5278 | }
|
5279 | if (parentComponent) {
|
5280 | let subTree = parentComponent.subTree;
|
5281 | if (subTree.patchFlag > 0 &&
|
5282 | subTree.patchFlag & 2048 ) {
|
5283 | subTree =
|
5284 | filterSingleRoot(subTree.children) || subTree;
|
5285 | }
|
5286 | if (vnode === subTree) {
|
5287 | const parentVNode = parentComponent.vnode;
|
5288 | setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
|
5289 | }
|
5290 | }
|
5291 | };
|
5292 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
|
5293 | for (let i = start; i < children.length; i++) {
|
5294 | const child = (children[i] = optimized
|
5295 | ? cloneIfMounted(children[i])
|
5296 | : normalizeVNode(children[i]));
|
5297 | patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5298 | }
|
5299 | };
|
5300 | const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5301 | const el = (n2.el = n1.el);
|
5302 | let { patchFlag, dynamicChildren, dirs } = n2;
|
5303 |
|
5304 |
|
5305 | patchFlag |= n1.patchFlag & 16 ;
|
5306 | const oldProps = n1.props || EMPTY_OBJ;
|
5307 | const newProps = n2.props || EMPTY_OBJ;
|
5308 | let vnodeHook;
|
5309 | if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
|
5310 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
5311 | }
|
5312 | if (dirs) {
|
5313 | invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
|
5314 | }
|
5315 | if (isHmrUpdating) {
|
5316 |
|
5317 | patchFlag = 0;
|
5318 | optimized = false;
|
5319 | dynamicChildren = null;
|
5320 | }
|
5321 | const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
|
5322 | if (dynamicChildren) {
|
5323 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
|
5324 | if (parentComponent && parentComponent.type.__hmrId) {
|
5325 | traverseStaticChildren(n1, n2);
|
5326 | }
|
5327 | }
|
5328 | else if (!optimized) {
|
5329 |
|
5330 | patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
|
5331 | }
|
5332 | if (patchFlag > 0) {
|
5333 |
|
5334 |
|
5335 |
|
5336 |
|
5337 | if (patchFlag & 16 ) {
|
5338 |
|
5339 | patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
|
5340 | }
|
5341 | else {
|
5342 |
|
5343 |
|
5344 | if (patchFlag & 2 ) {
|
5345 | if (oldProps.class !== newProps.class) {
|
5346 | hostPatchProp(el, 'class', null, newProps.class, isSVG);
|
5347 | }
|
5348 | }
|
5349 |
|
5350 |
|
5351 | if (patchFlag & 4 ) {
|
5352 | hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
|
5353 | }
|
5354 |
|
5355 |
|
5356 |
|
5357 |
|
5358 |
|
5359 |
|
5360 | if (patchFlag & 8 ) {
|
5361 |
|
5362 | const propsToUpdate = n2.dynamicProps;
|
5363 | for (let i = 0; i < propsToUpdate.length; i++) {
|
5364 | const key = propsToUpdate[i];
|
5365 | const prev = oldProps[key];
|
5366 | const next = newProps[key];
|
5367 |
|
5368 | if (next !== prev || key === 'value') {
|
5369 | hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
|
5370 | }
|
5371 | }
|
5372 | }
|
5373 | }
|
5374 |
|
5375 |
|
5376 | if (patchFlag & 1 ) {
|
5377 | if (n1.children !== n2.children) {
|
5378 | hostSetElementText(el, n2.children);
|
5379 | }
|
5380 | }
|
5381 | }
|
5382 | else if (!optimized && dynamicChildren == null) {
|
5383 |
|
5384 | patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
|
5385 | }
|
5386 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
5387 | queuePostRenderEffect(() => {
|
5388 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
5389 | dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
|
5390 | }, parentSuspense);
|
5391 | }
|
5392 | };
|
5393 |
|
5394 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
|
5395 | for (let i = 0; i < newChildren.length; i++) {
|
5396 | const oldVNode = oldChildren[i];
|
5397 | const newVNode = newChildren[i];
|
5398 |
|
5399 | const container =
|
5400 |
|
5401 |
|
5402 | oldVNode.el &&
|
5403 |
|
5404 |
|
5405 | (oldVNode.type === Fragment ||
|
5406 |
|
5407 |
|
5408 | !isSameVNodeType(oldVNode, newVNode) ||
|
5409 |
|
5410 | oldVNode.shapeFlag & (6 | 64 ))
|
5411 | ? hostParentNode(oldVNode.el)
|
5412 | :
|
5413 |
|
5414 | fallbackContainer;
|
5415 | patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
|
5416 | }
|
5417 | };
|
5418 | const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
|
5419 | if (oldProps !== newProps) {
|
5420 | for (const key in newProps) {
|
5421 |
|
5422 | if (isReservedProp(key))
|
5423 | continue;
|
5424 | const next = newProps[key];
|
5425 | const prev = oldProps[key];
|
5426 |
|
5427 | if (next !== prev && key !== 'value') {
|
5428 | hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5429 | }
|
5430 | }
|
5431 | if (oldProps !== EMPTY_OBJ) {
|
5432 | for (const key in oldProps) {
|
5433 | if (!isReservedProp(key) && !(key in newProps)) {
|
5434 | hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
|
5435 | }
|
5436 | }
|
5437 | }
|
5438 | if ('value' in newProps) {
|
5439 | hostPatchProp(el, 'value', oldProps.value, newProps.value);
|
5440 | }
|
5441 | }
|
5442 | };
|
5443 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5444 | const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
|
5445 | const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
|
5446 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
5447 | if (isHmrUpdating) {
|
5448 |
|
5449 | patchFlag = 0;
|
5450 | optimized = false;
|
5451 | dynamicChildren = null;
|
5452 | }
|
5453 |
|
5454 | if (fragmentSlotScopeIds) {
|
5455 | slotScopeIds = slotScopeIds
|
5456 | ? slotScopeIds.concat(fragmentSlotScopeIds)
|
5457 | : fragmentSlotScopeIds;
|
5458 | }
|
5459 | if (n1 == null) {
|
5460 | hostInsert(fragmentStartAnchor, container, anchor);
|
5461 | hostInsert(fragmentEndAnchor, container, anchor);
|
5462 |
|
5463 |
|
5464 |
|
5465 | mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5466 | }
|
5467 | else {
|
5468 | if (patchFlag > 0 &&
|
5469 | patchFlag & 64 &&
|
5470 | dynamicChildren &&
|
5471 |
|
5472 |
|
5473 | n1.dynamicChildren) {
|
5474 |
|
5475 |
|
5476 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
|
5477 | if (parentComponent && parentComponent.type.__hmrId) {
|
5478 | traverseStaticChildren(n1, n2);
|
5479 | }
|
5480 | else if (
|
5481 |
|
5482 |
|
5483 |
|
5484 |
|
5485 | n2.key != null ||
|
5486 | (parentComponent && n2 === parentComponent.subTree)) {
|
5487 | traverseStaticChildren(n1, n2, true );
|
5488 | }
|
5489 | }
|
5490 | else {
|
5491 |
|
5492 |
|
5493 |
|
5494 |
|
5495 | patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5496 | }
|
5497 | }
|
5498 | };
|
5499 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5500 | n2.slotScopeIds = slotScopeIds;
|
5501 | if (n1 == null) {
|
5502 | if (n2.shapeFlag & 512 ) {
|
5503 | parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
|
5504 | }
|
5505 | else {
|
5506 | mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
|
5507 | }
|
5508 | }
|
5509 | else {
|
5510 | updateComponent(n1, n2, optimized);
|
5511 | }
|
5512 | };
|
5513 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
|
5514 | const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
|
5515 | if (instance.type.__hmrId) {
|
5516 | registerHMR(instance);
|
5517 | }
|
5518 | {
|
5519 | pushWarningContext(initialVNode);
|
5520 | startMeasure(instance, `mount`);
|
5521 | }
|
5522 |
|
5523 | if (isKeepAlive(initialVNode)) {
|
5524 | instance.ctx.renderer = internals;
|
5525 | }
|
5526 |
|
5527 | {
|
5528 | {
|
5529 | startMeasure(instance, `init`);
|
5530 | }
|
5531 | setupComponent(instance);
|
5532 | {
|
5533 | endMeasure(instance, `init`);
|
5534 | }
|
5535 | }
|
5536 |
|
5537 |
|
5538 | if (instance.asyncDep) {
|
5539 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
|
5540 |
|
5541 |
|
5542 | if (!initialVNode.el) {
|
5543 | const placeholder = (instance.subTree = createVNode(Comment));
|
5544 | processCommentNode(null, placeholder, container, anchor);
|
5545 | }
|
5546 | return;
|
5547 | }
|
5548 | setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
|
5549 | {
|
5550 | popWarningContext();
|
5551 | endMeasure(instance, `mount`);
|
5552 | }
|
5553 | };
|
5554 | const updateComponent = (n1, n2, optimized) => {
|
5555 | const instance = (n2.component = n1.component);
|
5556 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
5557 | if (instance.asyncDep &&
|
5558 | !instance.asyncResolved) {
|
5559 |
|
5560 |
|
5561 | {
|
5562 | pushWarningContext(n2);
|
5563 | }
|
5564 | updateComponentPreRender(instance, n2, optimized);
|
5565 | {
|
5566 | popWarningContext();
|
5567 | }
|
5568 | return;
|
5569 | }
|
5570 | else {
|
5571 |
|
5572 | instance.next = n2;
|
5573 |
|
5574 |
|
5575 | invalidateJob(instance.update);
|
5576 |
|
5577 | instance.update();
|
5578 | }
|
5579 | }
|
5580 | else {
|
5581 |
|
5582 | n2.component = n1.component;
|
5583 | n2.el = n1.el;
|
5584 | instance.vnode = n2;
|
5585 | }
|
5586 | };
|
5587 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
|
5588 | const componentUpdateFn = () => {
|
5589 | if (!instance.isMounted) {
|
5590 | let vnodeHook;
|
5591 | const { el, props } = initialVNode;
|
5592 | const { bm, m, parent } = instance;
|
5593 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
5594 | effect.allowRecurse = false;
|
5595 |
|
5596 | if (bm) {
|
5597 | invokeArrayFns(bm);
|
5598 | }
|
5599 |
|
5600 | if (!isAsyncWrapperVNode &&
|
5601 | (vnodeHook = props && props.onVnodeBeforeMount)) {
|
5602 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
5603 | }
|
5604 | effect.allowRecurse = true;
|
5605 | if (el && hydrateNode) {
|
5606 |
|
5607 | const hydrateSubTree = () => {
|
5608 | {
|
5609 | startMeasure(instance, `render`);
|
5610 | }
|
5611 | instance.subTree = renderComponentRoot(instance);
|
5612 | {
|
5613 | endMeasure(instance, `render`);
|
5614 | }
|
5615 | {
|
5616 | startMeasure(instance, `hydrate`);
|
5617 | }
|
5618 | hydrateNode(el, instance.subTree, instance, parentSuspense, null);
|
5619 | {
|
5620 | endMeasure(instance, `hydrate`);
|
5621 | }
|
5622 | };
|
5623 | if (isAsyncWrapperVNode) {
|
5624 | initialVNode.type.__asyncLoader().then(
|
5625 |
|
5626 |
|
5627 |
|
5628 |
|
5629 | () => !instance.isUnmounted && hydrateSubTree());
|
5630 | }
|
5631 | else {
|
5632 | hydrateSubTree();
|
5633 | }
|
5634 | }
|
5635 | else {
|
5636 | {
|
5637 | startMeasure(instance, `render`);
|
5638 | }
|
5639 | const subTree = (instance.subTree = renderComponentRoot(instance));
|
5640 | {
|
5641 | endMeasure(instance, `render`);
|
5642 | }
|
5643 | {
|
5644 | startMeasure(instance, `patch`);
|
5645 | }
|
5646 | patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
|
5647 | {
|
5648 | endMeasure(instance, `patch`);
|
5649 | }
|
5650 | initialVNode.el = subTree.el;
|
5651 | }
|
5652 |
|
5653 | if (m) {
|
5654 | queuePostRenderEffect(m, parentSuspense);
|
5655 | }
|
5656 |
|
5657 | if (!isAsyncWrapperVNode &&
|
5658 | (vnodeHook = props && props.onVnodeMounted)) {
|
5659 | const scopedInitialVNode = initialVNode;
|
5660 | queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
|
5661 | }
|
5662 |
|
5663 |
|
5664 |
|
5665 | if (initialVNode.shapeFlag & 256 ) {
|
5666 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
5667 | }
|
5668 | instance.isMounted = true;
|
5669 | {
|
5670 | devtoolsComponentAdded(instance);
|
5671 | }
|
5672 |
|
5673 | initialVNode = container = anchor = null;
|
5674 | }
|
5675 | else {
|
5676 |
|
5677 |
|
5678 |
|
5679 | let { next, bu, u, parent, vnode } = instance;
|
5680 | let originNext = next;
|
5681 | let vnodeHook;
|
5682 | {
|
5683 | pushWarningContext(next || instance.vnode);
|
5684 | }
|
5685 |
|
5686 | effect.allowRecurse = false;
|
5687 | if (next) {
|
5688 | next.el = vnode.el;
|
5689 | updateComponentPreRender(instance, next, optimized);
|
5690 | }
|
5691 | else {
|
5692 | next = vnode;
|
5693 | }
|
5694 |
|
5695 | if (bu) {
|
5696 | invokeArrayFns(bu);
|
5697 | }
|
5698 |
|
5699 | if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
|
5700 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
5701 | }
|
5702 | effect.allowRecurse = true;
|
5703 |
|
5704 | {
|
5705 | startMeasure(instance, `render`);
|
5706 | }
|
5707 | const nextTree = renderComponentRoot(instance);
|
5708 | {
|
5709 | endMeasure(instance, `render`);
|
5710 | }
|
5711 | const prevTree = instance.subTree;
|
5712 | instance.subTree = nextTree;
|
5713 | {
|
5714 | startMeasure(instance, `patch`);
|
5715 | }
|
5716 | patch(prevTree, nextTree,
|
5717 |
|
5718 | hostParentNode(prevTree.el),
|
5719 |
|
5720 | getNextHostNode(prevTree), instance, parentSuspense, isSVG);
|
5721 | {
|
5722 | endMeasure(instance, `patch`);
|
5723 | }
|
5724 | next.el = nextTree.el;
|
5725 | if (originNext === null) {
|
5726 |
|
5727 |
|
5728 |
|
5729 | updateHOCHostEl(instance, nextTree.el);
|
5730 | }
|
5731 |
|
5732 | if (u) {
|
5733 | queuePostRenderEffect(u, parentSuspense);
|
5734 | }
|
5735 |
|
5736 | if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
|
5737 | queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
|
5738 | }
|
5739 | {
|
5740 | devtoolsComponentUpdated(instance);
|
5741 | }
|
5742 | {
|
5743 | popWarningContext();
|
5744 | }
|
5745 | }
|
5746 | };
|
5747 |
|
5748 | const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope
|
5749 | );
|
5750 | const update = (instance.update = effect.run.bind(effect));
|
5751 | update.id = instance.uid;
|
5752 |
|
5753 |
|
5754 | effect.allowRecurse = update.allowRecurse = true;
|
5755 | {
|
5756 | effect.onTrack = instance.rtc
|
5757 | ? e => invokeArrayFns(instance.rtc, e)
|
5758 | : void 0;
|
5759 | effect.onTrigger = instance.rtg
|
5760 | ? e => invokeArrayFns(instance.rtg, e)
|
5761 | : void 0;
|
5762 |
|
5763 | update.ownerInstance = instance;
|
5764 | }
|
5765 | update();
|
5766 | };
|
5767 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
5768 | nextVNode.component = instance;
|
5769 | const prevProps = instance.vnode.props;
|
5770 | instance.vnode = nextVNode;
|
5771 | instance.next = null;
|
5772 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
5773 | updateSlots(instance, nextVNode.children, optimized);
|
5774 | pauseTracking();
|
5775 |
|
5776 |
|
5777 | flushPreFlushCbs(undefined, instance.update);
|
5778 | resetTracking();
|
5779 | };
|
5780 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
|
5781 | const c1 = n1 && n1.children;
|
5782 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
5783 | const c2 = n2.children;
|
5784 | const { patchFlag, shapeFlag } = n2;
|
5785 |
|
5786 | if (patchFlag > 0) {
|
5787 | if (patchFlag & 128 ) {
|
5788 |
|
5789 |
|
5790 | patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5791 | return;
|
5792 | }
|
5793 | else if (patchFlag & 256 ) {
|
5794 |
|
5795 | patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5796 | return;
|
5797 | }
|
5798 | }
|
5799 |
|
5800 | if (shapeFlag & 8 ) {
|
5801 |
|
5802 | if (prevShapeFlag & 16 ) {
|
5803 | unmountChildren(c1, parentComponent, parentSuspense);
|
5804 | }
|
5805 | if (c2 !== c1) {
|
5806 | hostSetElementText(container, c2);
|
5807 | }
|
5808 | }
|
5809 | else {
|
5810 | if (prevShapeFlag & 16 ) {
|
5811 |
|
5812 | if (shapeFlag & 16 ) {
|
5813 |
|
5814 | patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5815 | }
|
5816 | else {
|
5817 |
|
5818 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
5819 | }
|
5820 | }
|
5821 | else {
|
5822 |
|
5823 |
|
5824 | if (prevShapeFlag & 8 ) {
|
5825 | hostSetElementText(container, '');
|
5826 | }
|
5827 |
|
5828 | if (shapeFlag & 16 ) {
|
5829 | mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5830 | }
|
5831 | }
|
5832 | }
|
5833 | };
|
5834 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5835 | c1 = c1 || EMPTY_ARR;
|
5836 | c2 = c2 || EMPTY_ARR;
|
5837 | const oldLength = c1.length;
|
5838 | const newLength = c2.length;
|
5839 | const commonLength = Math.min(oldLength, newLength);
|
5840 | let i;
|
5841 | for (i = 0; i < commonLength; i++) {
|
5842 | const nextChild = (c2[i] = optimized
|
5843 | ? cloneIfMounted(c2[i])
|
5844 | : normalizeVNode(c2[i]));
|
5845 | patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5846 | }
|
5847 | if (oldLength > newLength) {
|
5848 |
|
5849 | unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
|
5850 | }
|
5851 | else {
|
5852 |
|
5853 | mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
|
5854 | }
|
5855 | };
|
5856 |
|
5857 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
|
5858 | let i = 0;
|
5859 | const l2 = c2.length;
|
5860 | let e1 = c1.length - 1;
|
5861 | let e2 = l2 - 1;
|
5862 |
|
5863 |
|
5864 |
|
5865 | while (i <= e1 && i <= e2) {
|
5866 | const n1 = c1[i];
|
5867 | const n2 = (c2[i] = optimized
|
5868 | ? cloneIfMounted(c2[i])
|
5869 | : normalizeVNode(c2[i]));
|
5870 | if (isSameVNodeType(n1, n2)) {
|
5871 | patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5872 | }
|
5873 | else {
|
5874 | break;
|
5875 | }
|
5876 | i++;
|
5877 | }
|
5878 |
|
5879 |
|
5880 |
|
5881 | while (i <= e1 && i <= e2) {
|
5882 | const n1 = c1[e1];
|
5883 | const n2 = (c2[e2] = optimized
|
5884 | ? cloneIfMounted(c2[e2])
|
5885 | : normalizeVNode(c2[e2]));
|
5886 | if (isSameVNodeType(n1, n2)) {
|
5887 | patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5888 | }
|
5889 | else {
|
5890 | break;
|
5891 | }
|
5892 | e1--;
|
5893 | e2--;
|
5894 | }
|
5895 |
|
5896 |
|
5897 |
|
5898 |
|
5899 |
|
5900 |
|
5901 |
|
5902 | if (i > e1) {
|
5903 | if (i <= e2) {
|
5904 | const nextPos = e2 + 1;
|
5905 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
5906 | while (i <= e2) {
|
5907 | patch(null, (c2[i] = optimized
|
5908 | ? cloneIfMounted(c2[i])
|
5909 | : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5910 | i++;
|
5911 | }
|
5912 | }
|
5913 | }
|
5914 |
|
5915 |
|
5916 |
|
5917 |
|
5918 |
|
5919 |
|
5920 |
|
5921 | else if (i > e2) {
|
5922 | while (i <= e1) {
|
5923 | unmount(c1[i], parentComponent, parentSuspense, true);
|
5924 | i++;
|
5925 | }
|
5926 | }
|
5927 |
|
5928 |
|
5929 |
|
5930 |
|
5931 | else {
|
5932 | const s1 = i;
|
5933 | const s2 = i;
|
5934 |
|
5935 | const keyToNewIndexMap = new Map();
|
5936 | for (i = s2; i <= e2; i++) {
|
5937 | const nextChild = (c2[i] = optimized
|
5938 | ? cloneIfMounted(c2[i])
|
5939 | : normalizeVNode(c2[i]));
|
5940 | if (nextChild.key != null) {
|
5941 | if (keyToNewIndexMap.has(nextChild.key)) {
|
5942 | warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
|
5943 | }
|
5944 | keyToNewIndexMap.set(nextChild.key, i);
|
5945 | }
|
5946 | }
|
5947 |
|
5948 |
|
5949 | let j;
|
5950 | let patched = 0;
|
5951 | const toBePatched = e2 - s2 + 1;
|
5952 | let moved = false;
|
5953 |
|
5954 | let maxNewIndexSoFar = 0;
|
5955 |
|
5956 |
|
5957 |
|
5958 |
|
5959 |
|
5960 | const newIndexToOldIndexMap = new Array(toBePatched);
|
5961 | for (i = 0; i < toBePatched; i++)
|
5962 | newIndexToOldIndexMap[i] = 0;
|
5963 | for (i = s1; i <= e1; i++) {
|
5964 | const prevChild = c1[i];
|
5965 | if (patched >= toBePatched) {
|
5966 |
|
5967 | unmount(prevChild, parentComponent, parentSuspense, true);
|
5968 | continue;
|
5969 | }
|
5970 | let newIndex;
|
5971 | if (prevChild.key != null) {
|
5972 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
5973 | }
|
5974 | else {
|
5975 |
|
5976 | for (j = s2; j <= e2; j++) {
|
5977 | if (newIndexToOldIndexMap[j - s2] === 0 &&
|
5978 | isSameVNodeType(prevChild, c2[j])) {
|
5979 | newIndex = j;
|
5980 | break;
|
5981 | }
|
5982 | }
|
5983 | }
|
5984 | if (newIndex === undefined) {
|
5985 | unmount(prevChild, parentComponent, parentSuspense, true);
|
5986 | }
|
5987 | else {
|
5988 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
5989 | if (newIndex >= maxNewIndexSoFar) {
|
5990 | maxNewIndexSoFar = newIndex;
|
5991 | }
|
5992 | else {
|
5993 | moved = true;
|
5994 | }
|
5995 | patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
5996 | patched++;
|
5997 | }
|
5998 | }
|
5999 |
|
6000 |
|
6001 | const increasingNewIndexSequence = moved
|
6002 | ? getSequence(newIndexToOldIndexMap)
|
6003 | : EMPTY_ARR;
|
6004 | j = increasingNewIndexSequence.length - 1;
|
6005 |
|
6006 | for (i = toBePatched - 1; i >= 0; i--) {
|
6007 | const nextIndex = s2 + i;
|
6008 | const nextChild = c2[nextIndex];
|
6009 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
6010 | if (newIndexToOldIndexMap[i] === 0) {
|
6011 |
|
6012 | patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6013 | }
|
6014 | else if (moved) {
|
6015 |
|
6016 |
|
6017 |
|
6018 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
6019 | move(nextChild, container, anchor, 2 );
|
6020 | }
|
6021 | else {
|
6022 | j--;
|
6023 | }
|
6024 | }
|
6025 | }
|
6026 | }
|
6027 | };
|
6028 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
6029 | const { el, type, transition, children, shapeFlag } = vnode;
|
6030 | if (shapeFlag & 6 ) {
|
6031 | move(vnode.component.subTree, container, anchor, moveType);
|
6032 | return;
|
6033 | }
|
6034 | if (shapeFlag & 128 ) {
|
6035 | vnode.suspense.move(container, anchor, moveType);
|
6036 | return;
|
6037 | }
|
6038 | if (shapeFlag & 64 ) {
|
6039 | type.move(vnode, container, anchor, internals);
|
6040 | return;
|
6041 | }
|
6042 | if (type === Fragment) {
|
6043 | hostInsert(el, container, anchor);
|
6044 | for (let i = 0; i < children.length; i++) {
|
6045 | move(children[i], container, anchor, moveType);
|
6046 | }
|
6047 | hostInsert(vnode.anchor, container, anchor);
|
6048 | return;
|
6049 | }
|
6050 | if (type === Static) {
|
6051 | moveStaticNode(vnode, container, anchor);
|
6052 | return;
|
6053 | }
|
6054 |
|
6055 | const needTransition = moveType !== 2 &&
|
6056 | shapeFlag & 1 &&
|
6057 | transition;
|
6058 | if (needTransition) {
|
6059 | if (moveType === 0 ) {
|
6060 | transition.beforeEnter(el);
|
6061 | hostInsert(el, container, anchor);
|
6062 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
6063 | }
|
6064 | else {
|
6065 | const { leave, delayLeave, afterLeave } = transition;
|
6066 | const remove = () => hostInsert(el, container, anchor);
|
6067 | const performLeave = () => {
|
6068 | leave(el, () => {
|
6069 | remove();
|
6070 | afterLeave && afterLeave();
|
6071 | });
|
6072 | };
|
6073 | if (delayLeave) {
|
6074 | delayLeave(el, remove, performLeave);
|
6075 | }
|
6076 | else {
|
6077 | performLeave();
|
6078 | }
|
6079 | }
|
6080 | }
|
6081 | else {
|
6082 | hostInsert(el, container, anchor);
|
6083 | }
|
6084 | };
|
6085 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
6086 | const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
|
6087 |
|
6088 | if (ref != null) {
|
6089 | setRef(ref, null, parentSuspense, vnode, true);
|
6090 | }
|
6091 | if (shapeFlag & 256 ) {
|
6092 | parentComponent.ctx.deactivate(vnode);
|
6093 | return;
|
6094 | }
|
6095 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
6096 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
6097 | let vnodeHook;
|
6098 | if (shouldInvokeVnodeHook &&
|
6099 | (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
6100 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
6101 | }
|
6102 | if (shapeFlag & 6 ) {
|
6103 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
6104 | }
|
6105 | else {
|
6106 | if (shapeFlag & 128 ) {
|
6107 | vnode.suspense.unmount(parentSuspense, doRemove);
|
6108 | return;
|
6109 | }
|
6110 | if (shouldInvokeDirs) {
|
6111 | invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
|
6112 | }
|
6113 | if (shapeFlag & 64 ) {
|
6114 | vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
|
6115 | }
|
6116 | else if (dynamicChildren &&
|
6117 |
|
6118 | (type !== Fragment ||
|
6119 | (patchFlag > 0 && patchFlag & 64 ))) {
|
6120 |
|
6121 | unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
|
6122 | }
|
6123 | else if ((type === Fragment &&
|
6124 | patchFlag &
|
6125 | (128 | 256 )) ||
|
6126 | (!optimized && shapeFlag & 16 )) {
|
6127 | unmountChildren(children, parentComponent, parentSuspense);
|
6128 | }
|
6129 | if (doRemove) {
|
6130 | remove(vnode);
|
6131 | }
|
6132 | }
|
6133 | if ((shouldInvokeVnodeHook &&
|
6134 | (vnodeHook = props && props.onVnodeUnmounted)) ||
|
6135 | shouldInvokeDirs) {
|
6136 | queuePostRenderEffect(() => {
|
6137 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
6138 | shouldInvokeDirs &&
|
6139 | invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
|
6140 | }, parentSuspense);
|
6141 | }
|
6142 | };
|
6143 | const remove = vnode => {
|
6144 | const { type, el, anchor, transition } = vnode;
|
6145 | if (type === Fragment) {
|
6146 | removeFragment(el, anchor);
|
6147 | return;
|
6148 | }
|
6149 | if (type === Static) {
|
6150 | removeStaticNode(vnode);
|
6151 | return;
|
6152 | }
|
6153 | const performRemove = () => {
|
6154 | hostRemove(el);
|
6155 | if (transition && !transition.persisted && transition.afterLeave) {
|
6156 | transition.afterLeave();
|
6157 | }
|
6158 | };
|
6159 | if (vnode.shapeFlag & 1 &&
|
6160 | transition &&
|
6161 | !transition.persisted) {
|
6162 | const { leave, delayLeave } = transition;
|
6163 | const performLeave = () => leave(el, performRemove);
|
6164 | if (delayLeave) {
|
6165 | delayLeave(vnode.el, performRemove, performLeave);
|
6166 | }
|
6167 | else {
|
6168 | performLeave();
|
6169 | }
|
6170 | }
|
6171 | else {
|
6172 | performRemove();
|
6173 | }
|
6174 | };
|
6175 | const removeFragment = (cur, end) => {
|
6176 |
|
6177 |
|
6178 | let next;
|
6179 | while (cur !== end) {
|
6180 | next = hostNextSibling(cur);
|
6181 | hostRemove(cur);
|
6182 | cur = next;
|
6183 | }
|
6184 | hostRemove(end);
|
6185 | };
|
6186 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
6187 | if (instance.type.__hmrId) {
|
6188 | unregisterHMR(instance);
|
6189 | }
|
6190 | const { bum, scope, update, subTree, um } = instance;
|
6191 |
|
6192 | if (bum) {
|
6193 | invokeArrayFns(bum);
|
6194 | }
|
6195 |
|
6196 | scope.stop();
|
6197 |
|
6198 |
|
6199 | if (update) {
|
6200 |
|
6201 | update.active = false;
|
6202 | unmount(subTree, instance, parentSuspense, doRemove);
|
6203 | }
|
6204 |
|
6205 | if (um) {
|
6206 | queuePostRenderEffect(um, parentSuspense);
|
6207 | }
|
6208 | queuePostRenderEffect(() => {
|
6209 | instance.isUnmounted = true;
|
6210 | }, parentSuspense);
|
6211 |
|
6212 |
|
6213 |
|
6214 | if (parentSuspense &&
|
6215 | parentSuspense.pendingBranch &&
|
6216 | !parentSuspense.isUnmounted &&
|
6217 | instance.asyncDep &&
|
6218 | !instance.asyncResolved &&
|
6219 | instance.suspenseId === parentSuspense.pendingId) {
|
6220 | parentSuspense.deps--;
|
6221 | if (parentSuspense.deps === 0) {
|
6222 | parentSuspense.resolve();
|
6223 | }
|
6224 | }
|
6225 | {
|
6226 | devtoolsComponentRemoved(instance);
|
6227 | }
|
6228 | };
|
6229 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
6230 | for (let i = start; i < children.length; i++) {
|
6231 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
6232 | }
|
6233 | };
|
6234 | const getNextHostNode = vnode => {
|
6235 | if (vnode.shapeFlag & 6 ) {
|
6236 | return getNextHostNode(vnode.component.subTree);
|
6237 | }
|
6238 | if (vnode.shapeFlag & 128 ) {
|
6239 | return vnode.suspense.next();
|
6240 | }
|
6241 | return hostNextSibling((vnode.anchor || vnode.el));
|
6242 | };
|
6243 | const render = (vnode, container, isSVG) => {
|
6244 | if (vnode == null) {
|
6245 | if (container._vnode) {
|
6246 | unmount(container._vnode, null, null, true);
|
6247 | }
|
6248 | }
|
6249 | else {
|
6250 | patch(container._vnode || null, vnode, container, null, null, null, isSVG);
|
6251 | }
|
6252 | flushPostFlushCbs();
|
6253 | container._vnode = vnode;
|
6254 | };
|
6255 | const internals = {
|
6256 | p: patch,
|
6257 | um: unmount,
|
6258 | m: move,
|
6259 | r: remove,
|
6260 | mt: mountComponent,
|
6261 | mc: mountChildren,
|
6262 | pc: patchChildren,
|
6263 | pbc: patchBlockChildren,
|
6264 | n: getNextHostNode,
|
6265 | o: options
|
6266 | };
|
6267 | let hydrate;
|
6268 | let hydrateNode;
|
6269 | if (createHydrationFns) {
|
6270 | [hydrate, hydrateNode] = createHydrationFns(internals);
|
6271 | }
|
6272 | return {
|
6273 | render,
|
6274 | hydrate,
|
6275 | createApp: createAppAPI(render, hydrate)
|
6276 | };
|
6277 | }
|
6278 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
6279 | if (isArray(rawRef)) {
|
6280 | rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
|
6281 | return;
|
6282 | }
|
6283 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
6284 |
|
6285 |
|
6286 | return;
|
6287 | }
|
6288 | const refValue = vnode.shapeFlag & 4
|
6289 | ? getExposeProxy(vnode.component) || vnode.component.proxy
|
6290 | : vnode.el;
|
6291 | const value = isUnmount ? null : refValue;
|
6292 | const { i: owner, r: ref } = rawRef;
|
6293 | if (!owner) {
|
6294 | warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
|
6295 | `A vnode with ref must be created inside the render function.`);
|
6296 | return;
|
6297 | }
|
6298 | const oldRef = oldRawRef && oldRawRef.r;
|
6299 | const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
|
6300 | const setupState = owner.setupState;
|
6301 |
|
6302 | if (oldRef != null && oldRef !== ref) {
|
6303 | if (isString(oldRef)) {
|
6304 | refs[oldRef] = null;
|
6305 | if (hasOwn(setupState, oldRef)) {
|
6306 | setupState[oldRef] = null;
|
6307 | }
|
6308 | }
|
6309 | else if (isRef(oldRef)) {
|
6310 | oldRef.value = null;
|
6311 | }
|
6312 | }
|
6313 | if (isString(ref)) {
|
6314 | const doSet = () => {
|
6315 | {
|
6316 | refs[ref] = value;
|
6317 | }
|
6318 | if (hasOwn(setupState, ref)) {
|
6319 | setupState[ref] = value;
|
6320 | }
|
6321 | };
|
6322 |
|
6323 |
|
6324 |
|
6325 | if (value) {
|
6326 | doSet.id = -1;
|
6327 | queuePostRenderEffect(doSet, parentSuspense);
|
6328 | }
|
6329 | else {
|
6330 | doSet();
|
6331 | }
|
6332 | }
|
6333 | else if (isRef(ref)) {
|
6334 | const doSet = () => {
|
6335 | ref.value = value;
|
6336 | };
|
6337 | if (value) {
|
6338 | doSet.id = -1;
|
6339 | queuePostRenderEffect(doSet, parentSuspense);
|
6340 | }
|
6341 | else {
|
6342 | doSet();
|
6343 | }
|
6344 | }
|
6345 | else if (isFunction(ref)) {
|
6346 | callWithErrorHandling(ref, owner, 12 , [value, refs]);
|
6347 | }
|
6348 | else {
|
6349 | warn$1('Invalid template ref type:', value, `(${typeof value})`);
|
6350 | }
|
6351 | }
|
6352 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
6353 | callWithAsyncErrorHandling(hook, instance, 7 , [
|
6354 | vnode,
|
6355 | prevVNode
|
6356 | ]);
|
6357 | }
|
6358 | |
6359 |
|
6360 |
|
6361 |
|
6362 |
|
6363 |
|
6364 |
|
6365 |
|
6366 |
|
6367 |
|
6368 |
|
6369 | function traverseStaticChildren(n1, n2, shallow = false) {
|
6370 | const ch1 = n1.children;
|
6371 | const ch2 = n2.children;
|
6372 | if (isArray(ch1) && isArray(ch2)) {
|
6373 | for (let i = 0; i < ch1.length; i++) {
|
6374 |
|
6375 |
|
6376 | const c1 = ch1[i];
|
6377 | let c2 = ch2[i];
|
6378 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
6379 | if (c2.patchFlag <= 0 || c2.patchFlag === 32 ) {
|
6380 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
6381 | c2.el = c1.el;
|
6382 | }
|
6383 | if (!shallow)
|
6384 | traverseStaticChildren(c1, c2);
|
6385 | }
|
6386 |
|
6387 |
|
6388 | if (c2.type === Comment && !c2.el) {
|
6389 | c2.el = c1.el;
|
6390 | }
|
6391 | }
|
6392 | }
|
6393 | }
|
6394 |
|
6395 | function getSequence(arr) {
|
6396 | const p = arr.slice();
|
6397 | const result = [0];
|
6398 | let i, j, u, v, c;
|
6399 | const len = arr.length;
|
6400 | for (i = 0; i < len; i++) {
|
6401 | const arrI = arr[i];
|
6402 | if (arrI !== 0) {
|
6403 | j = result[result.length - 1];
|
6404 | if (arr[j] < arrI) {
|
6405 | p[i] = j;
|
6406 | result.push(i);
|
6407 | continue;
|
6408 | }
|
6409 | u = 0;
|
6410 | v = result.length - 1;
|
6411 | while (u < v) {
|
6412 | c = (u + v) >> 1;
|
6413 | if (arr[result[c]] < arrI) {
|
6414 | u = c + 1;
|
6415 | }
|
6416 | else {
|
6417 | v = c;
|
6418 | }
|
6419 | }
|
6420 | if (arrI < arr[result[u]]) {
|
6421 | if (u > 0) {
|
6422 | p[i] = result[u - 1];
|
6423 | }
|
6424 | result[u] = i;
|
6425 | }
|
6426 | }
|
6427 | }
|
6428 | u = result.length;
|
6429 | v = result[u - 1];
|
6430 | while (u-- > 0) {
|
6431 | result[u] = v;
|
6432 | v = p[v];
|
6433 | }
|
6434 | return result;
|
6435 | }
|
6436 |
|
6437 | const isTeleport = (type) => type.__isTeleport;
|
6438 | const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
|
6439 | const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
|
6440 | const resolveTarget = (props, select) => {
|
6441 | const targetSelector = props && props.to;
|
6442 | if (isString(targetSelector)) {
|
6443 | if (!select) {
|
6444 | warn$1(`Current renderer does not support string target for Teleports. ` +
|
6445 | `(missing querySelector renderer option)`);
|
6446 | return null;
|
6447 | }
|
6448 | else {
|
6449 | const target = select(targetSelector);
|
6450 | if (!target) {
|
6451 | warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
|
6452 | `Note the target element must exist before the component is mounted - ` +
|
6453 | `i.e. the target cannot be rendered by the component itself, and ` +
|
6454 | `ideally should be outside of the entire Vue component tree.`);
|
6455 | }
|
6456 | return target;
|
6457 | }
|
6458 | }
|
6459 | else {
|
6460 | if (!targetSelector && !isTeleportDisabled(props)) {
|
6461 | warn$1(`Invalid Teleport target: ${targetSelector}`);
|
6462 | }
|
6463 | return targetSelector;
|
6464 | }
|
6465 | };
|
6466 | const TeleportImpl = {
|
6467 | __isTeleport: true,
|
6468 | process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
|
6469 | const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
|
6470 | const disabled = isTeleportDisabled(n2.props);
|
6471 | let { shapeFlag, children, dynamicChildren } = n2;
|
6472 |
|
6473 |
|
6474 | if (isHmrUpdating) {
|
6475 | optimized = false;
|
6476 | dynamicChildren = null;
|
6477 | }
|
6478 | if (n1 == null) {
|
6479 |
|
6480 | const placeholder = (n2.el = createComment('teleport start')
|
6481 | );
|
6482 | const mainAnchor = (n2.anchor = createComment('teleport end')
|
6483 | );
|
6484 | insert(placeholder, container, anchor);
|
6485 | insert(mainAnchor, container, anchor);
|
6486 | const target = (n2.target = resolveTarget(n2.props, querySelector));
|
6487 | const targetAnchor = (n2.targetAnchor = createText(''));
|
6488 | if (target) {
|
6489 | insert(targetAnchor, target);
|
6490 |
|
6491 | isSVG = isSVG || isTargetSVG(target);
|
6492 | }
|
6493 | else if (!disabled) {
|
6494 | warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
|
6495 | }
|
6496 | const mount = (container, anchor) => {
|
6497 |
|
6498 |
|
6499 | if (shapeFlag & 16 ) {
|
6500 | mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
|
6501 | }
|
6502 | };
|
6503 | if (disabled) {
|
6504 | mount(container, mainAnchor);
|
6505 | }
|
6506 | else if (target) {
|
6507 | mount(target, targetAnchor);
|
6508 | }
|
6509 | }
|
6510 | else {
|
6511 |
|
6512 | n2.el = n1.el;
|
6513 | const mainAnchor = (n2.anchor = n1.anchor);
|
6514 | const target = (n2.target = n1.target);
|
6515 | const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
|
6516 | const wasDisabled = isTeleportDisabled(n1.props);
|
6517 | const currentContainer = wasDisabled ? container : target;
|
6518 | const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
6519 | isSVG = isSVG || isTargetSVG(target);
|
6520 | if (dynamicChildren) {
|
6521 |
|
6522 | patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
|
6523 |
|
6524 |
|
6525 |
|
6526 | traverseStaticChildren(n1, n2, true);
|
6527 | }
|
6528 | else if (!optimized) {
|
6529 | patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
|
6530 | }
|
6531 | if (disabled) {
|
6532 | if (!wasDisabled) {
|
6533 |
|
6534 |
|
6535 | moveTeleport(n2, container, mainAnchor, internals, 1 );
|
6536 | }
|
6537 | }
|
6538 | else {
|
6539 |
|
6540 | if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
6541 | const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
|
6542 | if (nextTarget) {
|
6543 | moveTeleport(n2, nextTarget, null, internals, 0 );
|
6544 | }
|
6545 | else {
|
6546 | warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
|
6547 | }
|
6548 | }
|
6549 | else if (wasDisabled) {
|
6550 |
|
6551 |
|
6552 | moveTeleport(n2, target, targetAnchor, internals, 1 );
|
6553 | }
|
6554 | }
|
6555 | }
|
6556 | },
|
6557 | remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
|
6558 | const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
|
6559 | if (target) {
|
6560 | hostRemove(targetAnchor);
|
6561 | }
|
6562 |
|
6563 | if (doRemove || !isTeleportDisabled(props)) {
|
6564 | hostRemove(anchor);
|
6565 | if (shapeFlag & 16 ) {
|
6566 | for (let i = 0; i < children.length; i++) {
|
6567 | const child = children[i];
|
6568 | unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
|
6569 | }
|
6570 | }
|
6571 | }
|
6572 | },
|
6573 | move: moveTeleport,
|
6574 | hydrate: hydrateTeleport
|
6575 | };
|
6576 | function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
|
6577 |
|
6578 | if (moveType === 0 ) {
|
6579 | insert(vnode.targetAnchor, container, parentAnchor);
|
6580 | }
|
6581 | const { el, anchor, shapeFlag, children, props } = vnode;
|
6582 | const isReorder = moveType === 2 ;
|
6583 |
|
6584 | if (isReorder) {
|
6585 | insert(el, container, parentAnchor);
|
6586 | }
|
6587 |
|
6588 |
|
6589 |
|
6590 | if (!isReorder || isTeleportDisabled(props)) {
|
6591 |
|
6592 | if (shapeFlag & 16 ) {
|
6593 | for (let i = 0; i < children.length; i++) {
|
6594 | move(children[i], container, parentAnchor, 2 );
|
6595 | }
|
6596 | }
|
6597 | }
|
6598 |
|
6599 | if (isReorder) {
|
6600 | insert(anchor, container, parentAnchor);
|
6601 | }
|
6602 | }
|
6603 | function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
|
6604 | const target = (vnode.target = resolveTarget(vnode.props, querySelector));
|
6605 | if (target) {
|
6606 |
|
6607 |
|
6608 | const targetNode = target._lpa || target.firstChild;
|
6609 | if (vnode.shapeFlag & 16 ) {
|
6610 | if (isTeleportDisabled(vnode.props)) {
|
6611 | vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
|
6612 | vnode.targetAnchor = targetNode;
|
6613 | }
|
6614 | else {
|
6615 | vnode.anchor = nextSibling(node);
|
6616 | vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
|
6617 | }
|
6618 | target._lpa =
|
6619 | vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
6620 | }
|
6621 | }
|
6622 | return vnode.anchor && nextSibling(vnode.anchor);
|
6623 | }
|
6624 |
|
6625 | const Teleport = TeleportImpl;
|
6626 |
|
6627 | const COMPONENTS = 'components';
|
6628 | const DIRECTIVES = 'directives';
|
6629 | |
6630 |
|
6631 |
|
6632 | function resolveComponent(name, maybeSelfReference) {
|
6633 | return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
6634 | }
|
6635 | const NULL_DYNAMIC_COMPONENT = Symbol();
|
6636 | |
6637 |
|
6638 |
|
6639 | function resolveDynamicComponent(component) {
|
6640 | if (isString(component)) {
|
6641 | return resolveAsset(COMPONENTS, component, false) || component;
|
6642 | }
|
6643 | else {
|
6644 |
|
6645 | return (component || NULL_DYNAMIC_COMPONENT);
|
6646 | }
|
6647 | }
|
6648 | |
6649 |
|
6650 |
|
6651 | function resolveDirective(name) {
|
6652 | return resolveAsset(DIRECTIVES, name);
|
6653 | }
|
6654 |
|
6655 | function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
6656 | const instance = currentRenderingInstance || currentInstance;
|
6657 | if (instance) {
|
6658 | const Component = instance.type;
|
6659 |
|
6660 | if (type === COMPONENTS) {
|
6661 | const selfName = getComponentName(Component);
|
6662 | if (selfName &&
|
6663 | (selfName === name ||
|
6664 | selfName === camelize(name) ||
|
6665 | selfName === capitalize(camelize(name)))) {
|
6666 | return Component;
|
6667 | }
|
6668 | }
|
6669 | const res =
|
6670 |
|
6671 |
|
6672 | resolve(instance[type] || Component[type], name) ||
|
6673 |
|
6674 | resolve(instance.appContext[type], name);
|
6675 | if (!res && maybeSelfReference) {
|
6676 |
|
6677 | return Component;
|
6678 | }
|
6679 | if (warnMissing && !res) {
|
6680 | const extra = type === COMPONENTS
|
6681 | ? `\nIf this is a native custom element, make sure to exclude it from ` +
|
6682 | `component resolution via compilerOptions.isCustomElement.`
|
6683 | : ``;
|
6684 | warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
6685 | }
|
6686 | return res;
|
6687 | }
|
6688 | else {
|
6689 | warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
|
6690 | `can only be used in render() or setup().`);
|
6691 | }
|
6692 | }
|
6693 | function resolve(registry, name) {
|
6694 | return (registry &&
|
6695 | (registry[name] ||
|
6696 | registry[camelize(name)] ||
|
6697 | registry[capitalize(camelize(name))]));
|
6698 | }
|
6699 |
|
6700 | const Fragment = Symbol('Fragment' );
|
6701 | const Text = Symbol('Text' );
|
6702 | const Comment = Symbol('Comment' );
|
6703 | const Static = Symbol('Static' );
|
6704 |
|
6705 |
|
6706 |
|
6707 |
|
6708 |
|
6709 | const blockStack = [];
|
6710 | let currentBlock = null;
|
6711 | |
6712 |
|
6713 |
|
6714 |
|
6715 |
|
6716 |
|
6717 |
|
6718 |
|
6719 |
|
6720 |
|
6721 |
|
6722 |
|
6723 |
|
6724 |
|
6725 |
|
6726 |
|
6727 | function openBlock(disableTracking = false) {
|
6728 | blockStack.push((currentBlock = disableTracking ? null : []));
|
6729 | }
|
6730 | function closeBlock() {
|
6731 | blockStack.pop();
|
6732 | currentBlock = blockStack[blockStack.length - 1] || null;
|
6733 | }
|
6734 |
|
6735 |
|
6736 |
|
6737 |
|
6738 | let isBlockTreeEnabled = 1;
|
6739 | |
6740 |
|
6741 |
|
6742 |
|
6743 |
|
6744 |
|
6745 |
|
6746 |
|
6747 |
|
6748 |
|
6749 |
|
6750 |
|
6751 |
|
6752 |
|
6753 |
|
6754 |
|
6755 | function setBlockTracking(value) {
|
6756 | isBlockTreeEnabled += value;
|
6757 | }
|
6758 | function setupBlock(vnode) {
|
6759 |
|
6760 | vnode.dynamicChildren =
|
6761 | isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
|
6762 |
|
6763 | closeBlock();
|
6764 |
|
6765 |
|
6766 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
6767 | currentBlock.push(vnode);
|
6768 | }
|
6769 | return vnode;
|
6770 | }
|
6771 | |
6772 |
|
6773 |
|
6774 | function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
6775 | return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true ));
|
6776 | }
|
6777 | |
6778 |
|
6779 |
|
6780 |
|
6781 |
|
6782 |
|
6783 |
|
6784 | function createBlock(type, props, children, patchFlag, dynamicProps) {
|
6785 | return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true ));
|
6786 | }
|
6787 | function isVNode(value) {
|
6788 | return value ? value.__v_isVNode === true : false;
|
6789 | }
|
6790 | function isSameVNodeType(n1, n2) {
|
6791 | if (n2.shapeFlag & 6 &&
|
6792 | hmrDirtyComponents.has(n2.type)) {
|
6793 |
|
6794 | return false;
|
6795 | }
|
6796 | return n1.type === n2.type && n1.key === n2.key;
|
6797 | }
|
6798 | let vnodeArgsTransformer;
|
6799 | |
6800 |
|
6801 |
|
6802 |
|
6803 |
|
6804 |
|
6805 | function transformVNodeArgs(transformer) {
|
6806 | vnodeArgsTransformer = transformer;
|
6807 | }
|
6808 | const createVNodeWithArgsTransform = (...args) => {
|
6809 | return _createVNode(...(vnodeArgsTransformer
|
6810 | ? vnodeArgsTransformer(args, currentRenderingInstance)
|
6811 | : args));
|
6812 | };
|
6813 | const InternalObjectKey = `__vInternal`;
|
6814 | const normalizeKey = ({ key }) => key != null ? key : null;
|
6815 | const normalizeRef = ({ ref }) => {
|
6816 | return (ref != null
|
6817 | ? isString(ref) || isRef(ref) || isFunction(ref)
|
6818 | ? { i: currentRenderingInstance, r: ref }
|
6819 | : ref
|
6820 | : null);
|
6821 | };
|
6822 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
|
6823 | const vnode = {
|
6824 | __v_isVNode: true,
|
6825 | __v_skip: true,
|
6826 | type,
|
6827 | props,
|
6828 | key: props && normalizeKey(props),
|
6829 | ref: props && normalizeRef(props),
|
6830 | scopeId: currentScopeId,
|
6831 | slotScopeIds: null,
|
6832 | children,
|
6833 | component: null,
|
6834 | suspense: null,
|
6835 | ssContent: null,
|
6836 | ssFallback: null,
|
6837 | dirs: null,
|
6838 | transition: null,
|
6839 | el: null,
|
6840 | anchor: null,
|
6841 | target: null,
|
6842 | targetAnchor: null,
|
6843 | staticCount: 0,
|
6844 | shapeFlag,
|
6845 | patchFlag,
|
6846 | dynamicProps,
|
6847 | dynamicChildren: null,
|
6848 | appContext: null
|
6849 | };
|
6850 | if (needFullChildrenNormalization) {
|
6851 | normalizeChildren(vnode, children);
|
6852 |
|
6853 | if (shapeFlag & 128 ) {
|
6854 | type.normalize(vnode);
|
6855 | }
|
6856 | }
|
6857 | else if (children) {
|
6858 |
|
6859 |
|
6860 | vnode.shapeFlag |= isString(children)
|
6861 | ? 8
|
6862 | : 16 ;
|
6863 | }
|
6864 |
|
6865 | if (vnode.key !== vnode.key) {
|
6866 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
6867 | }
|
6868 |
|
6869 | if (isBlockTreeEnabled > 0 &&
|
6870 |
|
6871 | !isBlockNode &&
|
6872 |
|
6873 | currentBlock &&
|
6874 |
|
6875 |
|
6876 |
|
6877 |
|
6878 | (vnode.patchFlag > 0 || shapeFlag & 6 ) &&
|
6879 |
|
6880 |
|
6881 | vnode.patchFlag !== 32 ) {
|
6882 | currentBlock.push(vnode);
|
6883 | }
|
6884 | return vnode;
|
6885 | }
|
6886 | const createVNode = (createVNodeWithArgsTransform );
|
6887 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
6888 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
6889 | if (!type) {
|
6890 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
6891 | }
|
6892 | type = Comment;
|
6893 | }
|
6894 | if (isVNode(type)) {
|
6895 |
|
6896 |
|
6897 |
|
6898 | const cloned = cloneVNode(type, props, true );
|
6899 | if (children) {
|
6900 | normalizeChildren(cloned, children);
|
6901 | }
|
6902 | return cloned;
|
6903 | }
|
6904 |
|
6905 | if (isClassComponent(type)) {
|
6906 | type = type.__vccOpts;
|
6907 | }
|
6908 |
|
6909 | if (props) {
|
6910 |
|
6911 | props = guardReactiveProps(props);
|
6912 | let { class: klass, style } = props;
|
6913 | if (klass && !isString(klass)) {
|
6914 | props.class = normalizeClass(klass);
|
6915 | }
|
6916 | if (isObject(style)) {
|
6917 |
|
6918 |
|
6919 | if (isProxy(style) && !isArray(style)) {
|
6920 | style = extend({}, style);
|
6921 | }
|
6922 | props.style = normalizeStyle(style);
|
6923 | }
|
6924 | }
|
6925 |
|
6926 | const shapeFlag = isString(type)
|
6927 | ? 1
|
6928 | : isSuspense(type)
|
6929 | ? 128
|
6930 | : isTeleport(type)
|
6931 | ? 64
|
6932 | : isObject(type)
|
6933 | ? 4
|
6934 | : isFunction(type)
|
6935 | ? 2
|
6936 | : 0;
|
6937 | if (shapeFlag & 4 && isProxy(type)) {
|
6938 | type = toRaw(type);
|
6939 | warn$1(`Vue received a Component which was made a reactive object. This can ` +
|
6940 | `lead to unnecessary performance overhead, and should be avoided by ` +
|
6941 | `marking the component with \`markRaw\` or using \`shallowRef\` ` +
|
6942 | `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
|
6943 | }
|
6944 | return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
|
6945 | }
|
6946 | function guardReactiveProps(props) {
|
6947 | if (!props)
|
6948 | return null;
|
6949 | return isProxy(props) || InternalObjectKey in props
|
6950 | ? extend({}, props)
|
6951 | : props;
|
6952 | }
|
6953 | function cloneVNode(vnode, extraProps, mergeRef = false) {
|
6954 |
|
6955 |
|
6956 | const { props, ref, patchFlag, children } = vnode;
|
6957 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
6958 | const cloned = {
|
6959 | __v_isVNode: true,
|
6960 | __v_skip: true,
|
6961 | type: vnode.type,
|
6962 | props: mergedProps,
|
6963 | key: mergedProps && normalizeKey(mergedProps),
|
6964 | ref: extraProps && extraProps.ref
|
6965 | ?
|
6966 |
|
6967 |
|
6968 | mergeRef && ref
|
6969 | ? isArray(ref)
|
6970 | ? ref.concat(normalizeRef(extraProps))
|
6971 | : [ref, normalizeRef(extraProps)]
|
6972 | : normalizeRef(extraProps)
|
6973 | : ref,
|
6974 | scopeId: vnode.scopeId,
|
6975 | slotScopeIds: vnode.slotScopeIds,
|
6976 | children: patchFlag === -1 && isArray(children)
|
6977 | ? children.map(deepCloneVNode)
|
6978 | : children,
|
6979 | target: vnode.target,
|
6980 | targetAnchor: vnode.targetAnchor,
|
6981 | staticCount: vnode.staticCount,
|
6982 | shapeFlag: vnode.shapeFlag,
|
6983 |
|
6984 |
|
6985 |
|
6986 |
|
6987 | patchFlag: extraProps && vnode.type !== Fragment
|
6988 | ? patchFlag === -1
|
6989 | ? 16
|
6990 | : patchFlag | 16
|
6991 | : patchFlag,
|
6992 | dynamicProps: vnode.dynamicProps,
|
6993 | dynamicChildren: vnode.dynamicChildren,
|
6994 | appContext: vnode.appContext,
|
6995 | dirs: vnode.dirs,
|
6996 | transition: vnode.transition,
|
6997 |
|
6998 |
|
6999 |
|
7000 |
|
7001 | component: vnode.component,
|
7002 | suspense: vnode.suspense,
|
7003 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
7004 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
7005 | el: vnode.el,
|
7006 | anchor: vnode.anchor
|
7007 | };
|
7008 | return cloned;
|
7009 | }
|
7010 | |
7011 |
|
7012 |
|
7013 |
|
7014 | function deepCloneVNode(vnode) {
|
7015 | const cloned = cloneVNode(vnode);
|
7016 | if (isArray(vnode.children)) {
|
7017 | cloned.children = vnode.children.map(deepCloneVNode);
|
7018 | }
|
7019 | return cloned;
|
7020 | }
|
7021 | |
7022 |
|
7023 |
|
7024 | function createTextVNode(text = ' ', flag = 0) {
|
7025 | return createVNode(Text, null, text, flag);
|
7026 | }
|
7027 | |
7028 |
|
7029 |
|
7030 | function createStaticVNode(content, numberOfNodes) {
|
7031 |
|
7032 |
|
7033 | const vnode = createVNode(Static, null, content);
|
7034 | vnode.staticCount = numberOfNodes;
|
7035 | return vnode;
|
7036 | }
|
7037 | |
7038 |
|
7039 |
|
7040 | function createCommentVNode(text = '',
|
7041 | // when used as the v-else branch, the comment node must be created as a
|
7042 | // block to ensure correct updates.
|
7043 | asBlock = false) {
|
7044 | return asBlock
|
7045 | ? (openBlock(), createBlock(Comment, null, text))
|
7046 | : createVNode(Comment, null, text);
|
7047 | }
|
7048 | function normalizeVNode(child) {
|
7049 | if (child == null || typeof child === 'boolean') {
|
7050 |
|
7051 | return createVNode(Comment);
|
7052 | }
|
7053 | else if (isArray(child)) {
|
7054 |
|
7055 | return createVNode(Fragment, null,
|
7056 |
|
7057 | child.slice());
|
7058 | }
|
7059 | else if (typeof child === 'object') {
|
7060 |
|
7061 |
|
7062 | return cloneIfMounted(child);
|
7063 | }
|
7064 | else {
|
7065 |
|
7066 | return createVNode(Text, null, String(child));
|
7067 | }
|
7068 | }
|
7069 |
|
7070 | function cloneIfMounted(child) {
|
7071 | return child.el === null || child.memo ? child : cloneVNode(child);
|
7072 | }
|
7073 | function normalizeChildren(vnode, children) {
|
7074 | let type = 0;
|
7075 | const { shapeFlag } = vnode;
|
7076 | if (children == null) {
|
7077 | children = null;
|
7078 | }
|
7079 | else if (isArray(children)) {
|
7080 | type = 16 ;
|
7081 | }
|
7082 | else if (typeof children === 'object') {
|
7083 | if (shapeFlag & (1 | 64 )) {
|
7084 |
|
7085 | const slot = children.default;
|
7086 | if (slot) {
|
7087 |
|
7088 | slot._c && (slot._d = false);
|
7089 | normalizeChildren(vnode, slot());
|
7090 | slot._c && (slot._d = true);
|
7091 | }
|
7092 | return;
|
7093 | }
|
7094 | else {
|
7095 | type = 32 ;
|
7096 | const slotFlag = children._;
|
7097 | if (!slotFlag && !(InternalObjectKey in children)) {
|
7098 | children._ctx = currentRenderingInstance;
|
7099 | }
|
7100 | else if (slotFlag === 3 && currentRenderingInstance) {
|
7101 |
|
7102 |
|
7103 | if (currentRenderingInstance.slots._ === 1 ) {
|
7104 | children._ = 1 ;
|
7105 | }
|
7106 | else {
|
7107 | children._ = 2 ;
|
7108 | vnode.patchFlag |= 1024 ;
|
7109 | }
|
7110 | }
|
7111 | }
|
7112 | }
|
7113 | else if (isFunction(children)) {
|
7114 | children = { default: children, _ctx: currentRenderingInstance };
|
7115 | type = 32 ;
|
7116 | }
|
7117 | else {
|
7118 | children = String(children);
|
7119 |
|
7120 | if (shapeFlag & 64 ) {
|
7121 | type = 16 ;
|
7122 | children = [createTextVNode(children)];
|
7123 | }
|
7124 | else {
|
7125 | type = 8 ;
|
7126 | }
|
7127 | }
|
7128 | vnode.children = children;
|
7129 | vnode.shapeFlag |= type;
|
7130 | }
|
7131 | function mergeProps(...args) {
|
7132 | const ret = {};
|
7133 | for (let i = 0; i < args.length; i++) {
|
7134 | const toMerge = args[i];
|
7135 | for (const key in toMerge) {
|
7136 | if (key === 'class') {
|
7137 | if (ret.class !== toMerge.class) {
|
7138 | ret.class = normalizeClass([ret.class, toMerge.class]);
|
7139 | }
|
7140 | }
|
7141 | else if (key === 'style') {
|
7142 | ret.style = normalizeStyle([ret.style, toMerge.style]);
|
7143 | }
|
7144 | else if (isOn(key)) {
|
7145 | const existing = ret[key];
|
7146 | const incoming = toMerge[key];
|
7147 | if (existing !== incoming) {
|
7148 | ret[key] = existing
|
7149 | ? [].concat(existing, incoming)
|
7150 | : incoming;
|
7151 | }
|
7152 | }
|
7153 | else if (key !== '') {
|
7154 | ret[key] = toMerge[key];
|
7155 | }
|
7156 | }
|
7157 | }
|
7158 | return ret;
|
7159 | }
|
7160 |
|
7161 | |
7162 |
|
7163 |
|
7164 | function renderList(source, renderItem, cache, index) {
|
7165 | let ret;
|
7166 | const cached = (cache && cache[index]);
|
7167 | if (isArray(source) || isString(source)) {
|
7168 | ret = new Array(source.length);
|
7169 | for (let i = 0, l = source.length; i < l; i++) {
|
7170 | ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
|
7171 | }
|
7172 | }
|
7173 | else if (typeof source === 'number') {
|
7174 | if (!Number.isInteger(source)) {
|
7175 | warn$1(`The v-for range expect an integer value but got ${source}.`);
|
7176 | return [];
|
7177 | }
|
7178 | ret = new Array(source);
|
7179 | for (let i = 0; i < source; i++) {
|
7180 | ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
|
7181 | }
|
7182 | }
|
7183 | else if (isObject(source)) {
|
7184 | if (source[Symbol.iterator]) {
|
7185 | ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
|
7186 | }
|
7187 | else {
|
7188 | const keys = Object.keys(source);
|
7189 | ret = new Array(keys.length);
|
7190 | for (let i = 0, l = keys.length; i < l; i++) {
|
7191 | const key = keys[i];
|
7192 | ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
7193 | }
|
7194 | }
|
7195 | }
|
7196 | else {
|
7197 | ret = [];
|
7198 | }
|
7199 | if (cache) {
|
7200 | cache[index] = ret;
|
7201 | }
|
7202 | return ret;
|
7203 | }
|
7204 |
|
7205 | |
7206 |
|
7207 |
|
7208 |
|
7209 | function createSlots(slots, dynamicSlots) {
|
7210 | for (let i = 0; i < dynamicSlots.length; i++) {
|
7211 | const slot = dynamicSlots[i];
|
7212 |
|
7213 | if (isArray(slot)) {
|
7214 | for (let j = 0; j < slot.length; j++) {
|
7215 | slots[slot[j].name] = slot[j].fn;
|
7216 | }
|
7217 | }
|
7218 | else if (slot) {
|
7219 |
|
7220 | slots[slot.name] = slot.fn;
|
7221 | }
|
7222 | }
|
7223 | return slots;
|
7224 | }
|
7225 |
|
7226 | |
7227 |
|
7228 |
|
7229 |
|
7230 | function renderSlot(slots, name, props = {},
|
7231 | // this is not a user-facing function, so the fallback is always generated by
|
7232 | // the compiler and guaranteed to be a function returning an array
|
7233 | fallback, noSlotted) {
|
7234 | if (currentRenderingInstance.isCE) {
|
7235 | return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
|
7236 | }
|
7237 | let slot = slots[name];
|
7238 | if (slot && slot.length > 1) {
|
7239 | warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
|
7240 | `function. You need to mark this component with $dynamic-slots in the ` +
|
7241 | `parent template.`);
|
7242 | slot = () => [];
|
7243 | }
|
7244 |
|
7245 |
|
7246 |
|
7247 |
|
7248 | if (slot && slot._c) {
|
7249 | slot._d = false;
|
7250 | }
|
7251 | openBlock();
|
7252 | const validSlotContent = slot && ensureValidVNode(slot(props));
|
7253 | const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1
|
7254 | ? 64
|
7255 | : -2 );
|
7256 | if (!noSlotted && rendered.scopeId) {
|
7257 | rendered.slotScopeIds = [rendered.scopeId + '-s'];
|
7258 | }
|
7259 | if (slot && slot._c) {
|
7260 | slot._d = true;
|
7261 | }
|
7262 | return rendered;
|
7263 | }
|
7264 | function ensureValidVNode(vnodes) {
|
7265 | return vnodes.some(child => {
|
7266 | if (!isVNode(child))
|
7267 | return true;
|
7268 | if (child.type === Comment)
|
7269 | return false;
|
7270 | if (child.type === Fragment &&
|
7271 | !ensureValidVNode(child.children))
|
7272 | return false;
|
7273 | return true;
|
7274 | })
|
7275 | ? vnodes
|
7276 | : null;
|
7277 | }
|
7278 |
|
7279 | |
7280 |
|
7281 |
|
7282 |
|
7283 | function toHandlers(obj) {
|
7284 | const ret = {};
|
7285 | if (!isObject(obj)) {
|
7286 | warn$1(`v-on with no argument expects an object value.`);
|
7287 | return ret;
|
7288 | }
|
7289 | for (const key in obj) {
|
7290 | ret[toHandlerKey(key)] = obj[key];
|
7291 | }
|
7292 | return ret;
|
7293 | }
|
7294 |
|
7295 | |
7296 |
|
7297 |
|
7298 |
|
7299 |
|
7300 | const getPublicInstance = (i) => {
|
7301 | if (!i)
|
7302 | return null;
|
7303 | if (isStatefulComponent(i))
|
7304 | return getExposeProxy(i) || i.proxy;
|
7305 | return getPublicInstance(i.parent);
|
7306 | };
|
7307 | const publicPropertiesMap = extend(Object.create(null), {
|
7308 | $: i => i,
|
7309 | $el: i => i.vnode.el,
|
7310 | $data: i => i.data,
|
7311 | $props: i => (shallowReadonly(i.props) ),
|
7312 | $attrs: i => (shallowReadonly(i.attrs) ),
|
7313 | $slots: i => (shallowReadonly(i.slots) ),
|
7314 | $refs: i => (shallowReadonly(i.refs) ),
|
7315 | $parent: i => getPublicInstance(i.parent),
|
7316 | $root: i => getPublicInstance(i.root),
|
7317 | $emit: i => i.emit,
|
7318 | $options: i => (resolveMergedOptions(i) ),
|
7319 | $forceUpdate: i => () => queueJob(i.update),
|
7320 | $nextTick: i => nextTick.bind(i.proxy),
|
7321 | $watch: i => (instanceWatch.bind(i) )
|
7322 | });
|
7323 | const PublicInstanceProxyHandlers = {
|
7324 | get({ _: instance }, key) {
|
7325 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
7326 |
|
7327 | if (key === '__isVue') {
|
7328 | return true;
|
7329 | }
|
7330 |
|
7331 |
|
7332 |
|
7333 |
|
7334 | if (setupState !== EMPTY_OBJ &&
|
7335 | setupState.__isScriptSetup &&
|
7336 | hasOwn(setupState, key)) {
|
7337 | return setupState[key];
|
7338 | }
|
7339 |
|
7340 |
|
7341 |
|
7342 |
|
7343 |
|
7344 |
|
7345 | let normalizedProps;
|
7346 | if (key[0] !== '$') {
|
7347 | const n = accessCache[key];
|
7348 | if (n !== undefined) {
|
7349 | switch (n) {
|
7350 | case 0 :
|
7351 | return setupState[key];
|
7352 | case 1 :
|
7353 | return data[key];
|
7354 | case 3 :
|
7355 | return ctx[key];
|
7356 | case 2 :
|
7357 | return props[key];
|
7358 |
|
7359 | }
|
7360 | }
|
7361 | else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
7362 | accessCache[key] = 0 ;
|
7363 | return setupState[key];
|
7364 | }
|
7365 | else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
7366 | accessCache[key] = 1 ;
|
7367 | return data[key];
|
7368 | }
|
7369 | else if (
|
7370 |
|
7371 |
|
7372 | (normalizedProps = instance.propsOptions[0]) &&
|
7373 | hasOwn(normalizedProps, key)) {
|
7374 | accessCache[key] = 2 ;
|
7375 | return props[key];
|
7376 | }
|
7377 | else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
7378 | accessCache[key] = 3 ;
|
7379 | return ctx[key];
|
7380 | }
|
7381 | else if (shouldCacheAccess) {
|
7382 | accessCache[key] = 4 ;
|
7383 | }
|
7384 | }
|
7385 | const publicGetter = publicPropertiesMap[key];
|
7386 | let cssModule, globalProperties;
|
7387 |
|
7388 | if (publicGetter) {
|
7389 | if (key === '$attrs') {
|
7390 | track(instance, "get" , key);
|
7391 | markAttrsAccessed();
|
7392 | }
|
7393 | return publicGetter(instance);
|
7394 | }
|
7395 | else if (
|
7396 |
|
7397 | (cssModule = type.__cssModules) &&
|
7398 | (cssModule = cssModule[key])) {
|
7399 | return cssModule;
|
7400 | }
|
7401 | else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
|
7402 |
|
7403 | accessCache[key] = 3 ;
|
7404 | return ctx[key];
|
7405 | }
|
7406 | else if (
|
7407 |
|
7408 | ((globalProperties = appContext.config.globalProperties),
|
7409 | hasOwn(globalProperties, key))) {
|
7410 | {
|
7411 | return globalProperties[key];
|
7412 | }
|
7413 | }
|
7414 | else if (currentRenderingInstance &&
|
7415 | (!isString(key) ||
|
7416 |
|
7417 |
|
7418 | key.indexOf('__v') !== 0)) {
|
7419 | if (data !== EMPTY_OBJ &&
|
7420 | (key[0] === '$' || key[0] === '_') &&
|
7421 | hasOwn(data, key)) {
|
7422 | warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
|
7423 | `character ("$" or "_") and is not proxied on the render context.`);
|
7424 | }
|
7425 | else if (instance === currentRenderingInstance) {
|
7426 | warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
|
7427 | `but is not defined on instance.`);
|
7428 | }
|
7429 | }
|
7430 | },
|
7431 | set({ _: instance }, key, value) {
|
7432 | const { data, setupState, ctx } = instance;
|
7433 | if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
|
7434 | setupState[key] = value;
|
7435 | }
|
7436 | else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
7437 | data[key] = value;
|
7438 | }
|
7439 | else if (hasOwn(instance.props, key)) {
|
7440 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
|
7441 | return false;
|
7442 | }
|
7443 | if (key[0] === '$' && key.slice(1) in instance) {
|
7444 | warn$1(`Attempting to mutate public property "${key}". ` +
|
7445 | `Properties starting with $ are reserved and readonly.`, instance);
|
7446 | return false;
|
7447 | }
|
7448 | else {
|
7449 | if (key in instance.appContext.config.globalProperties) {
|
7450 | Object.defineProperty(ctx, key, {
|
7451 | enumerable: true,
|
7452 | configurable: true,
|
7453 | value
|
7454 | });
|
7455 | }
|
7456 | else {
|
7457 | ctx[key] = value;
|
7458 | }
|
7459 | }
|
7460 | return true;
|
7461 | },
|
7462 | has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
|
7463 | let normalizedProps;
|
7464 | return (accessCache[key] !== undefined ||
|
7465 | (data !== EMPTY_OBJ && hasOwn(data, key)) ||
|
7466 | (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
|
7467 | ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
|
7468 | hasOwn(ctx, key) ||
|
7469 | hasOwn(publicPropertiesMap, key) ||
|
7470 | hasOwn(appContext.config.globalProperties, key));
|
7471 | }
|
7472 | };
|
7473 | {
|
7474 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
7475 | warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
|
7476 | `The keys will be empty in production mode to avoid performance overhead.`);
|
7477 | return Reflect.ownKeys(target);
|
7478 | };
|
7479 | }
|
7480 | const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, {
|
7481 | get(target, key) {
|
7482 |
|
7483 | if (key === Symbol.unscopables) {
|
7484 | return;
|
7485 | }
|
7486 | return PublicInstanceProxyHandlers.get(target, key, target);
|
7487 | },
|
7488 | has(_, key) {
|
7489 | const has = key[0] !== '_' && !isGloballyWhitelisted(key);
|
7490 | if (!has && PublicInstanceProxyHandlers.has(_, key)) {
|
7491 | warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
|
7492 | }
|
7493 | return has;
|
7494 | }
|
7495 | });
|
7496 |
|
7497 |
|
7498 |
|
7499 |
|
7500 | function createDevRenderContext(instance) {
|
7501 | const target = {};
|
7502 |
|
7503 | Object.defineProperty(target, `_`, {
|
7504 | configurable: true,
|
7505 | enumerable: false,
|
7506 | get: () => instance
|
7507 | });
|
7508 | // expose public properties
|
7509 | Object.keys(publicPropertiesMap).forEach(key => {
|
7510 | Object.defineProperty(target, key, {
|
7511 | configurable: true,
|
7512 | enumerable: false,
|
7513 | get: () => publicPropertiesMap[key](instance),
|
7514 | // intercepted by the proxy so no need for implementation,
|
7515 | // but needed to prevent set errors
|
7516 | set: NOOP
|
7517 | });
|
7518 | });
|
7519 | return target;
|
7520 | }
|
7521 | // dev only
|
7522 | function exposePropsOnRenderContext(instance) {
|
7523 | const { ctx, propsOptions: [propsOptions] } = instance;
|
7524 | if (propsOptions) {
|
7525 | Object.keys(propsOptions).forEach(key => {
|
7526 | Object.defineProperty(ctx, key, {
|
7527 | enumerable: true,
|
7528 | configurable: true,
|
7529 | get: () => instance.props[key],
|
7530 | set: NOOP
|
7531 | });
|
7532 | });
|
7533 | }
|
7534 | }
|
7535 | // dev only
|
7536 | function exposeSetupStateOnRenderContext(instance) {
|
7537 | const { ctx, setupState } = instance;
|
7538 | Object.keys(toRaw(setupState)).forEach(key => {
|
7539 | if (!setupState.__isScriptSetup) {
|
7540 | if (key[0] === '$' || key[0] === '_') {
|
7541 | warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
|
7542 | `which are reserved prefixes for Vue internals.`);
|
7543 | return;
|
7544 | }
|
7545 | Object.defineProperty(ctx, key, {
|
7546 | enumerable: true,
|
7547 | configurable: true,
|
7548 | get: () => setupState[key],
|
7549 | set: NOOP
|
7550 | });
|
7551 | }
|
7552 | });
|
7553 | }
|
7554 |
|
7555 | const emptyAppContext = createAppContext();
|
7556 | let uid$1 = 0;
|
7557 | function createComponentInstance(vnode, parent, suspense) {
|
7558 | const type = vnode.type;
|
7559 |
|
7560 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
7561 | const instance = {
|
7562 | uid: uid$1++,
|
7563 | vnode,
|
7564 | type,
|
7565 | parent,
|
7566 | appContext,
|
7567 | root: null,
|
7568 | next: null,
|
7569 | subTree: null,
|
7570 | update: null,
|
7571 | scope: new EffectScope(true ),
|
7572 | render: null,
|
7573 | proxy: null,
|
7574 | exposed: null,
|
7575 | exposeProxy: null,
|
7576 | withProxy: null,
|
7577 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
7578 | accessCache: null,
|
7579 | renderCache: [],
|
7580 |
|
7581 | components: null,
|
7582 | directives: null,
|
7583 |
|
7584 | propsOptions: normalizePropsOptions(type, appContext),
|
7585 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
7586 |
|
7587 | emit: null,
|
7588 | emitted: null,
|
7589 |
|
7590 | propsDefaults: EMPTY_OBJ,
|
7591 |
|
7592 | inheritAttrs: type.inheritAttrs,
|
7593 |
|
7594 | ctx: EMPTY_OBJ,
|
7595 | data: EMPTY_OBJ,
|
7596 | props: EMPTY_OBJ,
|
7597 | attrs: EMPTY_OBJ,
|
7598 | slots: EMPTY_OBJ,
|
7599 | refs: EMPTY_OBJ,
|
7600 | setupState: EMPTY_OBJ,
|
7601 | setupContext: null,
|
7602 |
|
7603 | suspense,
|
7604 | suspenseId: suspense ? suspense.pendingId : 0,
|
7605 | asyncDep: null,
|
7606 | asyncResolved: false,
|
7607 |
|
7608 |
|
7609 | isMounted: false,
|
7610 | isUnmounted: false,
|
7611 | isDeactivated: false,
|
7612 | bc: null,
|
7613 | c: null,
|
7614 | bm: null,
|
7615 | m: null,
|
7616 | bu: null,
|
7617 | u: null,
|
7618 | um: null,
|
7619 | bum: null,
|
7620 | da: null,
|
7621 | a: null,
|
7622 | rtg: null,
|
7623 | rtc: null,
|
7624 | ec: null,
|
7625 | sp: null
|
7626 | };
|
7627 | {
|
7628 | instance.ctx = createDevRenderContext(instance);
|
7629 | }
|
7630 | instance.root = parent ? parent.root : instance;
|
7631 | instance.emit = emit$1.bind(null, instance);
|
7632 |
|
7633 | if (vnode.ce) {
|
7634 | vnode.ce(instance);
|
7635 | }
|
7636 | return instance;
|
7637 | }
|
7638 | let currentInstance = null;
|
7639 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
7640 | const setCurrentInstance = (instance) => {
|
7641 | currentInstance = instance;
|
7642 | instance.scope.on();
|
7643 | };
|
7644 | const unsetCurrentInstance = () => {
|
7645 | currentInstance && currentInstance.scope.off();
|
7646 | currentInstance = null;
|
7647 | };
|
7648 | const isBuiltInTag = makeMap('slot,component');
|
7649 | function validateComponentName(name, config) {
|
7650 | const appIsNativeTag = config.isNativeTag || NO;
|
7651 | if (isBuiltInTag(name) || appIsNativeTag(name)) {
|
7652 | warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
|
7653 | }
|
7654 | }
|
7655 | function isStatefulComponent(instance) {
|
7656 | return instance.vnode.shapeFlag & 4 ;
|
7657 | }
|
7658 | let isInSSRComponentSetup = false;
|
7659 | function setupComponent(instance, isSSR = false) {
|
7660 | isInSSRComponentSetup = isSSR;
|
7661 | const { props, children } = instance.vnode;
|
7662 | const isStateful = isStatefulComponent(instance);
|
7663 | initProps(instance, props, isStateful, isSSR);
|
7664 | initSlots(instance, children);
|
7665 | const setupResult = isStateful
|
7666 | ? setupStatefulComponent(instance, isSSR)
|
7667 | : undefined;
|
7668 | isInSSRComponentSetup = false;
|
7669 | return setupResult;
|
7670 | }
|
7671 | function setupStatefulComponent(instance, isSSR) {
|
7672 | const Component = instance.type;
|
7673 | {
|
7674 | if (Component.name) {
|
7675 | validateComponentName(Component.name, instance.appContext.config);
|
7676 | }
|
7677 | if (Component.components) {
|
7678 | const names = Object.keys(Component.components);
|
7679 | for (let i = 0; i < names.length; i++) {
|
7680 | validateComponentName(names[i], instance.appContext.config);
|
7681 | }
|
7682 | }
|
7683 | if (Component.directives) {
|
7684 | const names = Object.keys(Component.directives);
|
7685 | for (let i = 0; i < names.length; i++) {
|
7686 | validateDirectiveName(names[i]);
|
7687 | }
|
7688 | }
|
7689 | if (Component.compilerOptions && isRuntimeOnly()) {
|
7690 | warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
|
7691 | `includes the runtime compiler. Since you are using a runtime-only ` +
|
7692 | `build, the options should be passed via your build tool config instead.`);
|
7693 | }
|
7694 | }
|
7695 |
|
7696 | instance.accessCache = Object.create(null);
|
7697 |
|
7698 |
|
7699 | instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
7700 | {
|
7701 | exposePropsOnRenderContext(instance);
|
7702 | }
|
7703 |
|
7704 | const { setup } = Component;
|
7705 | if (setup) {
|
7706 | const setupContext = (instance.setupContext =
|
7707 | setup.length > 1 ? createSetupContext(instance) : null);
|
7708 | setCurrentInstance(instance);
|
7709 | pauseTracking();
|
7710 | const setupResult = callWithErrorHandling(setup, instance, 0 , [shallowReadonly(instance.props) , setupContext]);
|
7711 | resetTracking();
|
7712 | unsetCurrentInstance();
|
7713 | if (isPromise(setupResult)) {
|
7714 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
7715 | if (isSSR) {
|
7716 |
|
7717 | return setupResult
|
7718 | .then((resolvedResult) => {
|
7719 | handleSetupResult(instance, resolvedResult, isSSR);
|
7720 | })
|
7721 | .catch(e => {
|
7722 | handleError(e, instance, 0 );
|
7723 | });
|
7724 | }
|
7725 | else {
|
7726 |
|
7727 |
|
7728 | instance.asyncDep = setupResult;
|
7729 | }
|
7730 | }
|
7731 | else {
|
7732 | handleSetupResult(instance, setupResult, isSSR);
|
7733 | }
|
7734 | }
|
7735 | else {
|
7736 | finishComponentSetup(instance, isSSR);
|
7737 | }
|
7738 | }
|
7739 | function handleSetupResult(instance, setupResult, isSSR) {
|
7740 | if (isFunction(setupResult)) {
|
7741 |
|
7742 | {
|
7743 | instance.render = setupResult;
|
7744 | }
|
7745 | }
|
7746 | else if (isObject(setupResult)) {
|
7747 | if (isVNode(setupResult)) {
|
7748 | warn$1(`setup() should not return VNodes directly - ` +
|
7749 | `return a render function instead.`);
|
7750 | }
|
7751 |
|
7752 |
|
7753 | {
|
7754 | instance.devtoolsRawSetupState = setupResult;
|
7755 | }
|
7756 | instance.setupState = proxyRefs(setupResult);
|
7757 | {
|
7758 | exposeSetupStateOnRenderContext(instance);
|
7759 | }
|
7760 | }
|
7761 | else if (setupResult !== undefined) {
|
7762 | warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
|
7763 | }
|
7764 | finishComponentSetup(instance, isSSR);
|
7765 | }
|
7766 | let compile;
|
7767 | let installWithProxy;
|
7768 | |
7769 |
|
7770 |
|
7771 |
|
7772 | function registerRuntimeCompiler(_compile) {
|
7773 | compile = _compile;
|
7774 | installWithProxy = i => {
|
7775 | if (i.render._rc) {
|
7776 | i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
7777 | }
|
7778 | };
|
7779 | }
|
7780 |
|
7781 | const isRuntimeOnly = () => !compile;
|
7782 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
7783 | const Component = instance.type;
|
7784 |
|
7785 |
|
7786 | if (!instance.render) {
|
7787 |
|
7788 |
|
7789 | if (!isSSR && compile && !Component.render) {
|
7790 | const template = Component.template;
|
7791 | if (template) {
|
7792 | {
|
7793 | startMeasure(instance, `compile`);
|
7794 | }
|
7795 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
7796 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
7797 | const finalCompilerOptions = extend(extend({
|
7798 | isCustomElement,
|
7799 | delimiters
|
7800 | }, compilerOptions), componentCompilerOptions);
|
7801 | Component.render = compile(template, finalCompilerOptions);
|
7802 | {
|
7803 | endMeasure(instance, `compile`);
|
7804 | }
|
7805 | }
|
7806 | }
|
7807 | instance.render = (Component.render || NOOP);
|
7808 |
|
7809 |
|
7810 |
|
7811 | if (installWithProxy) {
|
7812 | installWithProxy(instance);
|
7813 | }
|
7814 | }
|
7815 |
|
7816 | {
|
7817 | setCurrentInstance(instance);
|
7818 | pauseTracking();
|
7819 | applyOptions(instance);
|
7820 | resetTracking();
|
7821 | unsetCurrentInstance();
|
7822 | }
|
7823 |
|
7824 |
|
7825 | if (!Component.render && instance.render === NOOP && !isSSR) {
|
7826 |
|
7827 | if (!compile && Component.template) {
|
7828 | warn$1(`Component provided template option but ` +
|
7829 | `runtime compilation is not supported in this build of Vue.` +
|
7830 | (` Use "vue.global.js" instead.`
|
7831 | ) );
|
7832 | }
|
7833 | else {
|
7834 | warn$1(`Component is missing template or render function.`);
|
7835 | }
|
7836 | }
|
7837 | }
|
7838 | function createAttrsProxy(instance) {
|
7839 | return new Proxy(instance.attrs, {
|
7840 | get(target, key) {
|
7841 | markAttrsAccessed();
|
7842 | track(instance, "get" , '$attrs');
|
7843 | return target[key];
|
7844 | },
|
7845 | set() {
|
7846 | warn$1(`setupContext.attrs is readonly.`);
|
7847 | return false;
|
7848 | },
|
7849 | deleteProperty() {
|
7850 | warn$1(`setupContext.attrs is readonly.`);
|
7851 | return false;
|
7852 | }
|
7853 | }
|
7854 | );
|
7855 | }
|
7856 | function createSetupContext(instance) {
|
7857 | const expose = exposed => {
|
7858 | if (instance.exposed) {
|
7859 | warn$1(`expose() should be called only once per setup().`);
|
7860 | }
|
7861 | instance.exposed = exposed || {};
|
7862 | };
|
7863 | let attrs;
|
7864 | {
|
7865 |
|
7866 |
|
7867 | return Object.freeze({
|
7868 | get attrs() {
|
7869 | return attrs || (attrs = createAttrsProxy(instance));
|
7870 | },
|
7871 | get slots() {
|
7872 | return shallowReadonly(instance.slots);
|
7873 | },
|
7874 | get emit() {
|
7875 | return (event, ...args) => instance.emit(event, ...args);
|
7876 | },
|
7877 | expose
|
7878 | });
|
7879 | }
|
7880 | }
|
7881 | function getExposeProxy(instance) {
|
7882 | if (instance.exposed) {
|
7883 | return (instance.exposeProxy ||
|
7884 | (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
7885 | get(target, key) {
|
7886 | if (key in target) {
|
7887 | return target[key];
|
7888 | }
|
7889 | else if (key in publicPropertiesMap) {
|
7890 | return publicPropertiesMap[key](instance);
|
7891 | }
|
7892 | }
|
7893 | })));
|
7894 | }
|
7895 | }
|
7896 | const classifyRE = /(?:^|[-_])(\w)/g;
|
7897 | const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
|
7898 | function getComponentName(Component) {
|
7899 | return isFunction(Component)
|
7900 | ? Component.displayName || Component.name
|
7901 | : Component.name;
|
7902 | }
|
7903 |
|
7904 | function formatComponentName(instance, Component, isRoot = false) {
|
7905 | let name = getComponentName(Component);
|
7906 | if (!name && Component.__file) {
|
7907 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
7908 | if (match) {
|
7909 | name = match[1];
|
7910 | }
|
7911 | }
|
7912 | if (!name && instance && instance.parent) {
|
7913 |
|
7914 | const inferFromRegistry = (registry) => {
|
7915 | for (const key in registry) {
|
7916 | if (registry[key] === Component) {
|
7917 | return key;
|
7918 | }
|
7919 | }
|
7920 | };
|
7921 | name =
|
7922 | inferFromRegistry(instance.components ||
|
7923 | instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
7924 | }
|
7925 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
7926 | }
|
7927 | function isClassComponent(value) {
|
7928 | return isFunction(value) && '__vccOpts' in value;
|
7929 | }
|
7930 |
|
7931 | const stack = [];
|
7932 | function pushWarningContext(vnode) {
|
7933 | stack.push(vnode);
|
7934 | }
|
7935 | function popWarningContext() {
|
7936 | stack.pop();
|
7937 | }
|
7938 | function warn$1(msg, ...args) {
|
7939 |
|
7940 |
|
7941 | pauseTracking();
|
7942 | const instance = stack.length ? stack[stack.length - 1].component : null;
|
7943 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
7944 | const trace = getComponentTrace();
|
7945 | if (appWarnHandler) {
|
7946 | callWithErrorHandling(appWarnHandler, instance, 11 , [
|
7947 | msg + args.join(''),
|
7948 | instance && instance.proxy,
|
7949 | trace
|
7950 | .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
|
7951 | .join('\n'),
|
7952 | trace
|
7953 | ]);
|
7954 | }
|
7955 | else {
|
7956 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
7957 |
|
7958 | if (trace.length &&
|
7959 |
|
7960 | !false) {
|
7961 | warnArgs.push(`\n`, ...formatTrace(trace));
|
7962 | }
|
7963 | console.warn(...warnArgs);
|
7964 | }
|
7965 | resetTracking();
|
7966 | }
|
7967 | function getComponentTrace() {
|
7968 | let currentVNode = stack[stack.length - 1];
|
7969 | if (!currentVNode) {
|
7970 | return [];
|
7971 | }
|
7972 |
|
7973 |
|
7974 |
|
7975 | const normalizedStack = [];
|
7976 | while (currentVNode) {
|
7977 | const last = normalizedStack[0];
|
7978 | if (last && last.vnode === currentVNode) {
|
7979 | last.recurseCount++;
|
7980 | }
|
7981 | else {
|
7982 | normalizedStack.push({
|
7983 | vnode: currentVNode,
|
7984 | recurseCount: 0
|
7985 | });
|
7986 | }
|
7987 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
7988 | currentVNode = parentInstance && parentInstance.vnode;
|
7989 | }
|
7990 | return normalizedStack;
|
7991 | }
|
7992 |
|
7993 | function formatTrace(trace) {
|
7994 | const logs = [];
|
7995 | trace.forEach((entry, i) => {
|
7996 | logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
|
7997 | });
|
7998 | return logs;
|
7999 | }
|
8000 | function formatTraceEntry({ vnode, recurseCount }) {
|
8001 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
8002 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
8003 | const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
|
8004 | const close = `>` + postfix;
|
8005 | return vnode.props
|
8006 | ? [open, ...formatProps(vnode.props), close]
|
8007 | : [open + close];
|
8008 | }
|
8009 |
|
8010 | function formatProps(props) {
|
8011 | const res = [];
|
8012 | const keys = Object.keys(props);
|
8013 | keys.slice(0, 3).forEach(key => {
|
8014 | res.push(...formatProp(key, props[key]));
|
8015 | });
|
8016 | if (keys.length > 3) {
|
8017 | res.push(` ...`);
|
8018 | }
|
8019 | return res;
|
8020 | }
|
8021 |
|
8022 | function formatProp(key, value, raw) {
|
8023 | if (isString(value)) {
|
8024 | value = JSON.stringify(value);
|
8025 | return raw ? value : [`${key}=${value}`];
|
8026 | }
|
8027 | else if (typeof value === 'number' ||
|
8028 | typeof value === 'boolean' ||
|
8029 | value == null) {
|
8030 | return raw ? value : [`${key}=${value}`];
|
8031 | }
|
8032 | else if (isRef(value)) {
|
8033 | value = formatProp(key, toRaw(value.value), true);
|
8034 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
8035 | }
|
8036 | else if (isFunction(value)) {
|
8037 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
8038 | }
|
8039 | else {
|
8040 | value = toRaw(value);
|
8041 | return raw ? value : [`${key}=`, value];
|
8042 | }
|
8043 | }
|
8044 |
|
8045 | const ErrorTypeStrings = {
|
8046 | ["sp" ]: 'serverPrefetch hook',
|
8047 | ["bc" ]: 'beforeCreate hook',
|
8048 | ["c" ]: 'created hook',
|
8049 | ["bm" ]: 'beforeMount hook',
|
8050 | ["m" ]: 'mounted hook',
|
8051 | ["bu" ]: 'beforeUpdate hook',
|
8052 | ["u" ]: 'updated',
|
8053 | ["bum" ]: 'beforeUnmount hook',
|
8054 | ["um" ]: 'unmounted hook',
|
8055 | ["a" ]: 'activated hook',
|
8056 | ["da" ]: 'deactivated hook',
|
8057 | ["ec" ]: 'errorCaptured hook',
|
8058 | ["rtc" ]: 'renderTracked hook',
|
8059 | ["rtg" ]: 'renderTriggered hook',
|
8060 | [0 ]: 'setup function',
|
8061 | [1 ]: 'render function',
|
8062 | [2 ]: 'watcher getter',
|
8063 | [3 ]: 'watcher callback',
|
8064 | [4 ]: 'watcher cleanup function',
|
8065 | [5 ]: 'native event handler',
|
8066 | [6 ]: 'component event handler',
|
8067 | [7 ]: 'vnode hook',
|
8068 | [8 ]: 'directive hook',
|
8069 | [9 ]: 'transition hook',
|
8070 | [10 ]: 'app errorHandler',
|
8071 | [11 ]: 'app warnHandler',
|
8072 | [12 ]: 'ref function',
|
8073 | [13 ]: 'async component loader',
|
8074 | [14 ]: 'scheduler flush. This is likely a Vue internals bug. ' +
|
8075 | 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
|
8076 | };
|
8077 | function callWithErrorHandling(fn, instance, type, args) {
|
8078 | let res;
|
8079 | try {
|
8080 | res = args ? fn(...args) : fn();
|
8081 | }
|
8082 | catch (err) {
|
8083 | handleError(err, instance, type);
|
8084 | }
|
8085 | return res;
|
8086 | }
|
8087 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
8088 | if (isFunction(fn)) {
|
8089 | const res = callWithErrorHandling(fn, instance, type, args);
|
8090 | if (res && isPromise(res)) {
|
8091 | res.catch(err => {
|
8092 | handleError(err, instance, type);
|
8093 | });
|
8094 | }
|
8095 | return res;
|
8096 | }
|
8097 | const values = [];
|
8098 | for (let i = 0; i < fn.length; i++) {
|
8099 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
8100 | }
|
8101 | return values;
|
8102 | }
|
8103 | function handleError(err, instance, type, throwInDev = true) {
|
8104 | const contextVNode = instance ? instance.vnode : null;
|
8105 | if (instance) {
|
8106 | let cur = instance.parent;
|
8107 |
|
8108 | const exposedInstance = instance.proxy;
|
8109 |
|
8110 | const errorInfo = ErrorTypeStrings[type] ;
|
8111 | while (cur) {
|
8112 | const errorCapturedHooks = cur.ec;
|
8113 | if (errorCapturedHooks) {
|
8114 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
8115 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
8116 | return;
|
8117 | }
|
8118 | }
|
8119 | }
|
8120 | cur = cur.parent;
|
8121 | }
|
8122 |
|
8123 | const appErrorHandler = instance.appContext.config.errorHandler;
|
8124 | if (appErrorHandler) {
|
8125 | callWithErrorHandling(appErrorHandler, null, 10 , [err, exposedInstance, errorInfo]);
|
8126 | return;
|
8127 | }
|
8128 | }
|
8129 | logError(err, type, contextVNode, throwInDev);
|
8130 | }
|
8131 | function logError(err, type, contextVNode, throwInDev = true) {
|
8132 | {
|
8133 | const info = ErrorTypeStrings[type];
|
8134 | if (contextVNode) {
|
8135 | pushWarningContext(contextVNode);
|
8136 | }
|
8137 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
8138 | if (contextVNode) {
|
8139 | popWarningContext();
|
8140 | }
|
8141 |
|
8142 | if (throwInDev) {
|
8143 | throw err;
|
8144 | }
|
8145 | else {
|
8146 | console.error(err);
|
8147 | }
|
8148 | }
|
8149 | }
|
8150 |
|
8151 | let isFlushing = false;
|
8152 | let isFlushPending = false;
|
8153 | const queue = [];
|
8154 | let flushIndex = 0;
|
8155 | const pendingPreFlushCbs = [];
|
8156 | let activePreFlushCbs = null;
|
8157 | let preFlushIndex = 0;
|
8158 | const pendingPostFlushCbs = [];
|
8159 | let activePostFlushCbs = null;
|
8160 | let postFlushIndex = 0;
|
8161 | const resolvedPromise = Promise.resolve();
|
8162 | let currentFlushPromise = null;
|
8163 | let currentPreFlushParentJob = null;
|
8164 | const RECURSION_LIMIT = 100;
|
8165 | function nextTick(fn) {
|
8166 | const p = currentFlushPromise || resolvedPromise;
|
8167 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
8168 | }
|
8169 |
|
8170 |
|
8171 |
|
8172 |
|
8173 | function findInsertionIndex(id) {
|
8174 |
|
8175 | let start = flushIndex + 1;
|
8176 | let end = queue.length;
|
8177 | while (start < end) {
|
8178 | const middle = (start + end) >>> 1;
|
8179 | const middleJobId = getId(queue[middle]);
|
8180 | middleJobId < id ? (start = middle + 1) : (end = middle);
|
8181 | }
|
8182 | return start;
|
8183 | }
|
8184 | function queueJob(job) {
|
8185 |
|
8186 |
|
8187 |
|
8188 |
|
8189 |
|
8190 |
|
8191 | if ((!queue.length ||
|
8192 | !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
|
8193 | job !== currentPreFlushParentJob) {
|
8194 | if (job.id == null) {
|
8195 | queue.push(job);
|
8196 | }
|
8197 | else {
|
8198 | queue.splice(findInsertionIndex(job.id), 0, job);
|
8199 | }
|
8200 | queueFlush();
|
8201 | }
|
8202 | }
|
8203 | function queueFlush() {
|
8204 | if (!isFlushing && !isFlushPending) {
|
8205 | isFlushPending = true;
|
8206 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
8207 | }
|
8208 | }
|
8209 | function invalidateJob(job) {
|
8210 | const i = queue.indexOf(job);
|
8211 | if (i > flushIndex) {
|
8212 | queue.splice(i, 1);
|
8213 | }
|
8214 | }
|
8215 | function queueCb(cb, activeQueue, pendingQueue, index) {
|
8216 | if (!isArray(cb)) {
|
8217 | if (!activeQueue ||
|
8218 | !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
|
8219 | pendingQueue.push(cb);
|
8220 | }
|
8221 | }
|
8222 | else {
|
8223 |
|
8224 |
|
8225 |
|
8226 | pendingQueue.push(...cb);
|
8227 | }
|
8228 | queueFlush();
|
8229 | }
|
8230 | function queuePreFlushCb(cb) {
|
8231 | queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
|
8232 | }
|
8233 | function queuePostFlushCb(cb) {
|
8234 | queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
|
8235 | }
|
8236 | function flushPreFlushCbs(seen, parentJob = null) {
|
8237 | if (pendingPreFlushCbs.length) {
|
8238 | currentPreFlushParentJob = parentJob;
|
8239 | activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
|
8240 | pendingPreFlushCbs.length = 0;
|
8241 | {
|
8242 | seen = seen || new Map();
|
8243 | }
|
8244 | for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
|
8245 | if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
|
8246 | continue;
|
8247 | }
|
8248 | activePreFlushCbs[preFlushIndex]();
|
8249 | }
|
8250 | activePreFlushCbs = null;
|
8251 | preFlushIndex = 0;
|
8252 | currentPreFlushParentJob = null;
|
8253 |
|
8254 | flushPreFlushCbs(seen, parentJob);
|
8255 | }
|
8256 | }
|
8257 | function flushPostFlushCbs(seen) {
|
8258 | if (pendingPostFlushCbs.length) {
|
8259 | const deduped = [...new Set(pendingPostFlushCbs)];
|
8260 | pendingPostFlushCbs.length = 0;
|
8261 |
|
8262 | if (activePostFlushCbs) {
|
8263 | activePostFlushCbs.push(...deduped);
|
8264 | return;
|
8265 | }
|
8266 | activePostFlushCbs = deduped;
|
8267 | {
|
8268 | seen = seen || new Map();
|
8269 | }
|
8270 | activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
|
8271 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
8272 | if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
|
8273 | continue;
|
8274 | }
|
8275 | activePostFlushCbs[postFlushIndex]();
|
8276 | }
|
8277 | activePostFlushCbs = null;
|
8278 | postFlushIndex = 0;
|
8279 | }
|
8280 | }
|
8281 | const getId = (job) => job.id == null ? Infinity : job.id;
|
8282 | function flushJobs(seen) {
|
8283 | isFlushPending = false;
|
8284 | isFlushing = true;
|
8285 | {
|
8286 | seen = seen || new Map();
|
8287 | }
|
8288 | flushPreFlushCbs(seen);
|
8289 |
|
8290 |
|
8291 |
|
8292 |
|
8293 |
|
8294 |
|
8295 |
|
8296 | queue.sort((a, b) => getId(a) - getId(b));
|
8297 |
|
8298 |
|
8299 |
|
8300 |
|
8301 |
|
8302 | const check = (job) => checkRecursiveUpdates(seen, job)
|
8303 | ;
|
8304 | try {
|
8305 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
8306 | const job = queue[flushIndex];
|
8307 | if (job && job.active !== false) {
|
8308 | if (true && check(job)) {
|
8309 | continue;
|
8310 | }
|
8311 |
|
8312 | callWithErrorHandling(job, null, 14 );
|
8313 | }
|
8314 | }
|
8315 | }
|
8316 | finally {
|
8317 | flushIndex = 0;
|
8318 | queue.length = 0;
|
8319 | flushPostFlushCbs(seen);
|
8320 | isFlushing = false;
|
8321 | currentFlushPromise = null;
|
8322 |
|
8323 |
|
8324 | if (queue.length ||
|
8325 | pendingPreFlushCbs.length ||
|
8326 | pendingPostFlushCbs.length) {
|
8327 | flushJobs(seen);
|
8328 | }
|
8329 | }
|
8330 | }
|
8331 | function checkRecursiveUpdates(seen, fn) {
|
8332 | if (!seen.has(fn)) {
|
8333 | seen.set(fn, 1);
|
8334 | }
|
8335 | else {
|
8336 | const count = seen.get(fn);
|
8337 | if (count > RECURSION_LIMIT) {
|
8338 | const instance = fn.ownerInstance;
|
8339 | const componentName = instance && getComponentName(instance.type);
|
8340 | warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
|
8341 | `This means you have a reactive effect that is mutating its own ` +
|
8342 | `dependencies and thus recursively triggering itself. Possible sources ` +
|
8343 | `include component template, render function, updated hook or ` +
|
8344 | `watcher source function.`);
|
8345 | return true;
|
8346 | }
|
8347 | else {
|
8348 | seen.set(fn, count + 1);
|
8349 | }
|
8350 | }
|
8351 | }
|
8352 |
|
8353 |
|
8354 | function watchEffect(effect, options) {
|
8355 | return doWatch(effect, null, options);
|
8356 | }
|
8357 | function watchPostEffect(effect, options) {
|
8358 | return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
|
8359 | ));
|
8360 | }
|
8361 | function watchSyncEffect(effect, options) {
|
8362 | return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
|
8363 | ));
|
8364 | }
|
8365 |
|
8366 | const INITIAL_WATCHER_VALUE = {};
|
8367 |
|
8368 | function watch(source, cb, options) {
|
8369 | if (!isFunction(cb)) {
|
8370 | warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
|
8371 | `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
|
8372 | `supports \`watch(source, cb, options?) signature.`);
|
8373 | }
|
8374 | return doWatch(source, cb, options);
|
8375 | }
|
8376 | function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
|
8377 | if (!cb) {
|
8378 | if (immediate !== undefined) {
|
8379 | warn$1(`watch() "immediate" option is only respected when using the ` +
|
8380 | `watch(source, callback, options?) signature.`);
|
8381 | }
|
8382 | if (deep !== undefined) {
|
8383 | warn$1(`watch() "deep" option is only respected when using the ` +
|
8384 | `watch(source, callback, options?) signature.`);
|
8385 | }
|
8386 | }
|
8387 | const warnInvalidSource = (s) => {
|
8388 | warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
|
8389 | `a reactive object, or an array of these types.`);
|
8390 | };
|
8391 | const instance = currentInstance;
|
8392 | let getter;
|
8393 | let forceTrigger = false;
|
8394 | let isMultiSource = false;
|
8395 | if (isRef(source)) {
|
8396 | getter = () => source.value;
|
8397 | forceTrigger = !!source._shallow;
|
8398 | }
|
8399 | else if (isReactive(source)) {
|
8400 | getter = () => source;
|
8401 | deep = true;
|
8402 | }
|
8403 | else if (isArray(source)) {
|
8404 | isMultiSource = true;
|
8405 | forceTrigger = source.some(isReactive);
|
8406 | getter = () => source.map(s => {
|
8407 | if (isRef(s)) {
|
8408 | return s.value;
|
8409 | }
|
8410 | else if (isReactive(s)) {
|
8411 | return traverse(s);
|
8412 | }
|
8413 | else if (isFunction(s)) {
|
8414 | return callWithErrorHandling(s, instance, 2 );
|
8415 | }
|
8416 | else {
|
8417 | warnInvalidSource(s);
|
8418 | }
|
8419 | });
|
8420 | }
|
8421 | else if (isFunction(source)) {
|
8422 | if (cb) {
|
8423 |
|
8424 | getter = () => callWithErrorHandling(source, instance, 2 );
|
8425 | }
|
8426 | else {
|
8427 |
|
8428 | getter = () => {
|
8429 | if (instance && instance.isUnmounted) {
|
8430 | return;
|
8431 | }
|
8432 | if (cleanup) {
|
8433 | cleanup();
|
8434 | }
|
8435 | return callWithAsyncErrorHandling(source, instance, 3 , [onInvalidate]);
|
8436 | };
|
8437 | }
|
8438 | }
|
8439 | else {
|
8440 | getter = NOOP;
|
8441 | warnInvalidSource(source);
|
8442 | }
|
8443 | if (cb && deep) {
|
8444 | const baseGetter = getter;
|
8445 | getter = () => traverse(baseGetter());
|
8446 | }
|
8447 | let cleanup;
|
8448 | let onInvalidate = (fn) => {
|
8449 | cleanup = effect.onStop = () => {
|
8450 | callWithErrorHandling(fn, instance, 4 );
|
8451 | };
|
8452 | };
|
8453 | let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
|
8454 | const job = () => {
|
8455 | if (!effect.active) {
|
8456 | return;
|
8457 | }
|
8458 | if (cb) {
|
8459 |
|
8460 | const newValue = effect.run();
|
8461 | if (deep ||
|
8462 | forceTrigger ||
|
8463 | (isMultiSource
|
8464 | ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
|
8465 | : hasChanged(newValue, oldValue)) ||
|
8466 | (false )) {
|
8467 |
|
8468 | if (cleanup) {
|
8469 | cleanup();
|
8470 | }
|
8471 | callWithAsyncErrorHandling(cb, instance, 3 , [
|
8472 | newValue,
|
8473 |
|
8474 | oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
|
8475 | onInvalidate
|
8476 | ]);
|
8477 | oldValue = newValue;
|
8478 | }
|
8479 | }
|
8480 | else {
|
8481 |
|
8482 | effect.run();
|
8483 | }
|
8484 | };
|
8485 |
|
8486 |
|
8487 | job.allowRecurse = !!cb;
|
8488 | let scheduler;
|
8489 | if (flush === 'sync') {
|
8490 | scheduler = job;
|
8491 | }
|
8492 | else if (flush === 'post') {
|
8493 | scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
|
8494 | }
|
8495 | else {
|
8496 |
|
8497 | scheduler = () => {
|
8498 | if (!instance || instance.isMounted) {
|
8499 | queuePreFlushCb(job);
|
8500 | }
|
8501 | else {
|
8502 |
|
8503 |
|
8504 | job();
|
8505 | }
|
8506 | };
|
8507 | }
|
8508 | const effect = new ReactiveEffect(getter, scheduler);
|
8509 | {
|
8510 | effect.onTrack = onTrack;
|
8511 | effect.onTrigger = onTrigger;
|
8512 | }
|
8513 |
|
8514 | if (cb) {
|
8515 | if (immediate) {
|
8516 | job();
|
8517 | }
|
8518 | else {
|
8519 | oldValue = effect.run();
|
8520 | }
|
8521 | }
|
8522 | else if (flush === 'post') {
|
8523 | queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
|
8524 | }
|
8525 | else {
|
8526 | effect.run();
|
8527 | }
|
8528 | return () => {
|
8529 | effect.stop();
|
8530 | if (instance && instance.scope) {
|
8531 | remove(instance.scope.effects, effect);
|
8532 | }
|
8533 | };
|
8534 | }
|
8535 |
|
8536 | function instanceWatch(source, value, options) {
|
8537 | const publicThis = this.proxy;
|
8538 | const getter = isString(source)
|
8539 | ? source.includes('.')
|
8540 | ? createPathGetter(publicThis, source)
|
8541 | : () => publicThis[source]
|
8542 | : source.bind(publicThis, publicThis);
|
8543 | let cb;
|
8544 | if (isFunction(value)) {
|
8545 | cb = value;
|
8546 | }
|
8547 | else {
|
8548 | cb = value.handler;
|
8549 | options = value;
|
8550 | }
|
8551 | const cur = currentInstance;
|
8552 | setCurrentInstance(this);
|
8553 | const res = doWatch(getter, cb.bind(publicThis), options);
|
8554 | if (cur) {
|
8555 | setCurrentInstance(cur);
|
8556 | }
|
8557 | else {
|
8558 | unsetCurrentInstance();
|
8559 | }
|
8560 | return res;
|
8561 | }
|
8562 | function createPathGetter(ctx, path) {
|
8563 | const segments = path.split('.');
|
8564 | return () => {
|
8565 | let cur = ctx;
|
8566 | for (let i = 0; i < segments.length && cur; i++) {
|
8567 | cur = cur[segments[i]];
|
8568 | }
|
8569 | return cur;
|
8570 | };
|
8571 | }
|
8572 | function traverse(value, seen) {
|
8573 | if (!isObject(value) || value["__v_skip" ]) {
|
8574 | return value;
|
8575 | }
|
8576 | seen = seen || new Set();
|
8577 | if (seen.has(value)) {
|
8578 | return value;
|
8579 | }
|
8580 | seen.add(value);
|
8581 | if (isRef(value)) {
|
8582 | traverse(value.value, seen);
|
8583 | }
|
8584 | else if (isArray(value)) {
|
8585 | for (let i = 0; i < value.length; i++) {
|
8586 | traverse(value[i], seen);
|
8587 | }
|
8588 | }
|
8589 | else if (isSet(value) || isMap(value)) {
|
8590 | value.forEach((v) => {
|
8591 | traverse(v, seen);
|
8592 | });
|
8593 | }
|
8594 | else if (isPlainObject(value)) {
|
8595 | for (const key in value) {
|
8596 | traverse(value[key], seen);
|
8597 | }
|
8598 | }
|
8599 | return value;
|
8600 | }
|
8601 |
|
8602 |
|
8603 | const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
|
8604 | `<script setup> of a single file component. Its arguments should be ` +
|
8605 | `compiled away and passing it at runtime has no effect.`);
|
8606 |
|
8607 | function defineProps() {
|
8608 | {
|
8609 | warnRuntimeUsage(`defineProps`);
|
8610 | }
|
8611 | return null;
|
8612 | }
|
8613 |
|
8614 | function defineEmits() {
|
8615 | {
|
8616 | warnRuntimeUsage(`defineEmits`);
|
8617 | }
|
8618 | return null;
|
8619 | }
|
8620 | |
8621 |
|
8622 |
|
8623 |
|
8624 |
|
8625 |
|
8626 |
|
8627 |
|
8628 |
|
8629 |
|
8630 |
|
8631 |
|
8632 | function defineExpose(exposed) {
|
8633 | {
|
8634 | warnRuntimeUsage(`defineExpose`);
|
8635 | }
|
8636 | }
|
8637 | |
8638 |
|
8639 |
|
8640 |
|
8641 |
|
8642 |
|
8643 |
|
8644 |
|
8645 |
|
8646 |
|
8647 |
|
8648 |
|
8649 |
|
8650 |
|
8651 |
|
8652 |
|
8653 |
|
8654 |
|
8655 | function withDefaults(props, defaults) {
|
8656 | {
|
8657 | warnRuntimeUsage(`withDefaults`);
|
8658 | }
|
8659 | return null;
|
8660 | }
|
8661 | function useSlots() {
|
8662 | return getContext().slots;
|
8663 | }
|
8664 | function useAttrs() {
|
8665 | return getContext().attrs;
|
8666 | }
|
8667 | function getContext() {
|
8668 | const i = getCurrentInstance();
|
8669 | if (!i) {
|
8670 | warn$1(`useContext() called without active instance.`);
|
8671 | }
|
8672 | return i.setupContext || (i.setupContext = createSetupContext(i));
|
8673 | }
|
8674 | |
8675 |
|
8676 |
|
8677 |
|
8678 |
|
8679 | function mergeDefaults(
|
8680 | // the base props is compiler-generated and guaranteed to be in this shape.
|
8681 | props, defaults) {
|
8682 | for (const key in defaults) {
|
8683 | const val = props[key];
|
8684 | if (val) {
|
8685 | val.default = defaults[key];
|
8686 | }
|
8687 | else if (val === null) {
|
8688 | props[key] = { default: defaults[key] };
|
8689 | }
|
8690 | else {
|
8691 | warn$1(`props default key "${key}" has no corresponding declaration.`);
|
8692 | }
|
8693 | }
|
8694 | return props;
|
8695 | }
|
8696 | |
8697 |
|
8698 |
|
8699 |
|
8700 |
|
8701 |
|
8702 |
|
8703 |
|
8704 |
|
8705 |
|
8706 |
|
8707 |
|
8708 |
|
8709 |
|
8710 |
|
8711 |
|
8712 |
|
8713 |
|
8714 | function withAsyncContext(getAwaitable) {
|
8715 | const ctx = getCurrentInstance();
|
8716 | if (!ctx) {
|
8717 | warn$1(`withAsyncContext called without active current instance. ` +
|
8718 | `This is likely a bug.`);
|
8719 | }
|
8720 | let awaitable = getAwaitable();
|
8721 | unsetCurrentInstance();
|
8722 | if (isPromise(awaitable)) {
|
8723 | awaitable = awaitable.catch(e => {
|
8724 | setCurrentInstance(ctx);
|
8725 | throw e;
|
8726 | });
|
8727 | }
|
8728 | return [awaitable, () => setCurrentInstance(ctx)];
|
8729 | }
|
8730 |
|
8731 |
|
8732 | function h(type, propsOrChildren, children) {
|
8733 | const l = arguments.length;
|
8734 | if (l === 2) {
|
8735 | if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
|
8736 |
|
8737 | if (isVNode(propsOrChildren)) {
|
8738 | return createVNode(type, null, [propsOrChildren]);
|
8739 | }
|
8740 |
|
8741 | return createVNode(type, propsOrChildren);
|
8742 | }
|
8743 | else {
|
8744 |
|
8745 | return createVNode(type, null, propsOrChildren);
|
8746 | }
|
8747 | }
|
8748 | else {
|
8749 | if (l > 3) {
|
8750 | children = Array.prototype.slice.call(arguments, 2);
|
8751 | }
|
8752 | else if (l === 3 && isVNode(children)) {
|
8753 | children = [children];
|
8754 | }
|
8755 | return createVNode(type, propsOrChildren, children);
|
8756 | }
|
8757 | }
|
8758 |
|
8759 | const ssrContextKey = Symbol(`ssrContext` );
|
8760 | const useSSRContext = () => {
|
8761 | {
|
8762 | warn$1(`useSSRContext() is not supported in the global build.`);
|
8763 | }
|
8764 | };
|
8765 |
|
8766 | function initCustomFormatter() {
|
8767 |
|
8768 | if (typeof window === 'undefined') {
|
8769 | return;
|
8770 | }
|
8771 | const vueStyle = { style: 'color:#3ba776' };
|
8772 | const numberStyle = { style: 'color:#0b1bc9' };
|
8773 | const stringStyle = { style: 'color:#b62e24' };
|
8774 | const keywordStyle = { style: 'color:#9d288c' };
|
8775 |
|
8776 |
|
8777 | const formatter = {
|
8778 | header(obj) {
|
8779 |
|
8780 | if (!isObject(obj)) {
|
8781 | return null;
|
8782 | }
|
8783 | if (obj.__isVue) {
|
8784 | return ['div', vueStyle, `VueInstance`];
|
8785 | }
|
8786 | else if (isRef(obj)) {
|
8787 | return [
|
8788 | 'div',
|
8789 | {},
|
8790 | ['span', vueStyle, genRefFlag(obj)],
|
8791 | '<',
|
8792 | formatValue(obj.value),
|
8793 | `>`
|
8794 | ];
|
8795 | }
|
8796 | else if (isReactive(obj)) {
|
8797 | return [
|
8798 | 'div',
|
8799 | {},
|
8800 | ['span', vueStyle, 'Reactive'],
|
8801 | '<',
|
8802 | formatValue(obj),
|
8803 | `>${isReadonly(obj) ? ` (readonly)` : ``}`
|
8804 | ];
|
8805 | }
|
8806 | else if (isReadonly(obj)) {
|
8807 | return [
|
8808 | 'div',
|
8809 | {},
|
8810 | ['span', vueStyle, 'Readonly'],
|
8811 | '<',
|
8812 | formatValue(obj),
|
8813 | '>'
|
8814 | ];
|
8815 | }
|
8816 | return null;
|
8817 | },
|
8818 | hasBody(obj) {
|
8819 | return obj && obj.__isVue;
|
8820 | },
|
8821 | body(obj) {
|
8822 | if (obj && obj.__isVue) {
|
8823 | return [
|
8824 | 'div',
|
8825 | {},
|
8826 | ...formatInstance(obj.$)
|
8827 | ];
|
8828 | }
|
8829 | }
|
8830 | };
|
8831 | function formatInstance(instance) {
|
8832 | const blocks = [];
|
8833 | if (instance.type.props && instance.props) {
|
8834 | blocks.push(createInstanceBlock('props', toRaw(instance.props)));
|
8835 | }
|
8836 | if (instance.setupState !== EMPTY_OBJ) {
|
8837 | blocks.push(createInstanceBlock('setup', instance.setupState));
|
8838 | }
|
8839 | if (instance.data !== EMPTY_OBJ) {
|
8840 | blocks.push(createInstanceBlock('data', toRaw(instance.data)));
|
8841 | }
|
8842 | const computed = extractKeys(instance, 'computed');
|
8843 | if (computed) {
|
8844 | blocks.push(createInstanceBlock('computed', computed));
|
8845 | }
|
8846 | const injected = extractKeys(instance, 'inject');
|
8847 | if (injected) {
|
8848 | blocks.push(createInstanceBlock('injected', injected));
|
8849 | }
|
8850 | blocks.push([
|
8851 | 'div',
|
8852 | {},
|
8853 | [
|
8854 | 'span',
|
8855 | {
|
8856 | style: keywordStyle.style + ';opacity:0.66'
|
8857 | },
|
8858 | '$ (internal): '
|
8859 | ],
|
8860 | ['object', { object: instance }]
|
8861 | ]);
|
8862 | return blocks;
|
8863 | }
|
8864 | function createInstanceBlock(type, target) {
|
8865 | target = extend({}, target);
|
8866 | if (!Object.keys(target).length) {
|
8867 | return ['span', {}];
|
8868 | }
|
8869 | return [
|
8870 | 'div',
|
8871 | { style: 'line-height:1.25em;margin-bottom:0.6em' },
|
8872 | [
|
8873 | 'div',
|
8874 | {
|
8875 | style: 'color:#476582'
|
8876 | },
|
8877 | type
|
8878 | ],
|
8879 | [
|
8880 | 'div',
|
8881 | {
|
8882 | style: 'padding-left:1.25em'
|
8883 | },
|
8884 | ...Object.keys(target).map(key => {
|
8885 | return [
|
8886 | 'div',
|
8887 | {},
|
8888 | ['span', keywordStyle, key + ': '],
|
8889 | formatValue(target[key], false)
|
8890 | ];
|
8891 | })
|
8892 | ]
|
8893 | ];
|
8894 | }
|
8895 | function formatValue(v, asRaw = true) {
|
8896 | if (typeof v === 'number') {
|
8897 | return ['span', numberStyle, v];
|
8898 | }
|
8899 | else if (typeof v === 'string') {
|
8900 | return ['span', stringStyle, JSON.stringify(v)];
|
8901 | }
|
8902 | else if (typeof v === 'boolean') {
|
8903 | return ['span', keywordStyle, v];
|
8904 | }
|
8905 | else if (isObject(v)) {
|
8906 | return ['object', { object: asRaw ? toRaw(v) : v }];
|
8907 | }
|
8908 | else {
|
8909 | return ['span', stringStyle, String(v)];
|
8910 | }
|
8911 | }
|
8912 | function extractKeys(instance, type) {
|
8913 | const Comp = instance.type;
|
8914 | if (isFunction(Comp)) {
|
8915 | return;
|
8916 | }
|
8917 | const extracted = {};
|
8918 | for (const key in instance.ctx) {
|
8919 | if (isKeyOfType(Comp, key, type)) {
|
8920 | extracted[key] = instance.ctx[key];
|
8921 | }
|
8922 | }
|
8923 | return extracted;
|
8924 | }
|
8925 | function isKeyOfType(Comp, key, type) {
|
8926 | const opts = Comp[type];
|
8927 | if ((isArray(opts) && opts.includes(key)) ||
|
8928 | (isObject(opts) && key in opts)) {
|
8929 | return true;
|
8930 | }
|
8931 | if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
8932 | return true;
|
8933 | }
|
8934 | if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
|
8935 | return true;
|
8936 | }
|
8937 | }
|
8938 | function genRefFlag(v) {
|
8939 | if (v._shallow) {
|
8940 | return `ShallowRef`;
|
8941 | }
|
8942 | if (v.effect) {
|
8943 | return `ComputedRef`;
|
8944 | }
|
8945 | return `Ref`;
|
8946 | }
|
8947 | if (window.devtoolsFormatters) {
|
8948 | window.devtoolsFormatters.push(formatter);
|
8949 | }
|
8950 | else {
|
8951 | window.devtoolsFormatters = [formatter];
|
8952 | }
|
8953 | }
|
8954 |
|
8955 | function withMemo(memo, render, cache, index) {
|
8956 | const cached = cache[index];
|
8957 | if (cached && isMemoSame(cached, memo)) {
|
8958 | return cached;
|
8959 | }
|
8960 | const ret = render();
|
8961 |
|
8962 | ret.memo = memo.slice();
|
8963 | return (cache[index] = ret);
|
8964 | }
|
8965 | function isMemoSame(cached, memo) {
|
8966 | const prev = cached.memo;
|
8967 | if (prev.length != memo.length) {
|
8968 | return false;
|
8969 | }
|
8970 | for (let i = 0; i < prev.length; i++) {
|
8971 | if (prev[i] !== memo[i]) {
|
8972 | return false;
|
8973 | }
|
8974 | }
|
8975 |
|
8976 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
8977 | currentBlock.push(cached);
|
8978 | }
|
8979 | return true;
|
8980 | }
|
8981 |
|
8982 |
|
8983 | const version = "3.2.19";
|
8984 | |
8985 |
|
8986 |
|
8987 |
|
8988 | const ssrUtils = (null);
|
8989 | |
8990 |
|
8991 |
|
8992 | const resolveFilter = null;
|
8993 | |
8994 |
|
8995 |
|
8996 | const compatUtils = (null);
|
8997 |
|
8998 | const svgNS = 'http://www.w3.org/2000/svg';
|
8999 | const doc = (typeof document !== 'undefined' ? document : null);
|
9000 | const staticTemplateCache = new Map();
|
9001 | const nodeOps = {
|
9002 | insert: (child, parent, anchor) => {
|
9003 | parent.insertBefore(child, anchor || null);
|
9004 | },
|
9005 | remove: child => {
|
9006 | const parent = child.parentNode;
|
9007 | if (parent) {
|
9008 | parent.removeChild(child);
|
9009 | }
|
9010 | },
|
9011 | createElement: (tag, isSVG, is, props) => {
|
9012 | const el = isSVG
|
9013 | ? doc.createElementNS(svgNS, tag)
|
9014 | : doc.createElement(tag, is ? { is } : undefined);
|
9015 | if (tag === 'select' && props && props.multiple != null) {
|
9016 | el.setAttribute('multiple', props.multiple);
|
9017 | }
|
9018 | return el;
|
9019 | },
|
9020 | createText: text => doc.createTextNode(text),
|
9021 | createComment: text => doc.createComment(text),
|
9022 | setText: (node, text) => {
|
9023 | node.nodeValue = text;
|
9024 | },
|
9025 | setElementText: (el, text) => {
|
9026 | el.textContent = text;
|
9027 | },
|
9028 | parentNode: node => node.parentNode,
|
9029 | nextSibling: node => node.nextSibling,
|
9030 | querySelector: selector => doc.querySelector(selector),
|
9031 | setScopeId(el, id) {
|
9032 | el.setAttribute(id, '');
|
9033 | },
|
9034 | cloneNode(el) {
|
9035 | const cloned = el.cloneNode(true);
|
9036 |
|
9037 |
|
9038 |
|
9039 |
|
9040 |
|
9041 |
|
9042 |
|
9043 |
|
9044 |
|
9045 | if (`_value` in el) {
|
9046 | cloned._value = el._value;
|
9047 | }
|
9048 | return cloned;
|
9049 | },
|
9050 |
|
9051 |
|
9052 |
|
9053 |
|
9054 | insertStaticContent(content, parent, anchor, isSVG) {
|
9055 |
|
9056 | const before = anchor ? anchor.previousSibling : parent.lastChild;
|
9057 | let template = staticTemplateCache.get(content);
|
9058 | if (!template) {
|
9059 | const t = doc.createElement('template');
|
9060 | t.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
|
9061 | template = t.content;
|
9062 | if (isSVG) {
|
9063 |
|
9064 | const wrapper = template.firstChild;
|
9065 | while (wrapper.firstChild) {
|
9066 | template.appendChild(wrapper.firstChild);
|
9067 | }
|
9068 | template.removeChild(wrapper);
|
9069 | }
|
9070 | staticTemplateCache.set(content, template);
|
9071 | }
|
9072 | parent.insertBefore(template.cloneNode(true), anchor);
|
9073 | return [
|
9074 |
|
9075 | before ? before.nextSibling : parent.firstChild,
|
9076 |
|
9077 | anchor ? anchor.previousSibling : parent.lastChild
|
9078 | ];
|
9079 | }
|
9080 | };
|
9081 |
|
9082 |
|
9083 |
|
9084 | function patchClass(el, value, isSVG) {
|
9085 |
|
9086 |
|
9087 |
|
9088 | const transitionClasses = el._vtc;
|
9089 | if (transitionClasses) {
|
9090 | value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
|
9091 | }
|
9092 | if (value == null) {
|
9093 | el.removeAttribute('class');
|
9094 | }
|
9095 | else if (isSVG) {
|
9096 | el.setAttribute('class', value);
|
9097 | }
|
9098 | else {
|
9099 | el.className = value;
|
9100 | }
|
9101 | }
|
9102 |
|
9103 | function patchStyle(el, prev, next) {
|
9104 | const style = el.style;
|
9105 | const currentDisplay = style.display;
|
9106 | if (!next) {
|
9107 | el.removeAttribute('style');
|
9108 | }
|
9109 | else if (isString(next)) {
|
9110 | if (prev !== next) {
|
9111 | style.cssText = next;
|
9112 | }
|
9113 | }
|
9114 | else {
|
9115 | for (const key in next) {
|
9116 | setStyle(style, key, next[key]);
|
9117 | }
|
9118 | if (prev && !isString(prev)) {
|
9119 | for (const key in prev) {
|
9120 | if (next[key] == null) {
|
9121 | setStyle(style, key, '');
|
9122 | }
|
9123 | }
|
9124 | }
|
9125 | }
|
9126 |
|
9127 |
|
9128 |
|
9129 | if ('_vod' in el) {
|
9130 | style.display = currentDisplay;
|
9131 | }
|
9132 | }
|
9133 | const importantRE = /\s*!important$/;
|
9134 | function setStyle(style, name, val) {
|
9135 | if (isArray(val)) {
|
9136 | val.forEach(v => setStyle(style, name, v));
|
9137 | }
|
9138 | else {
|
9139 | if (name.startsWith('--')) {
|
9140 |
|
9141 | style.setProperty(name, val);
|
9142 | }
|
9143 | else {
|
9144 | const prefixed = autoPrefix(style, name);
|
9145 | if (importantRE.test(val)) {
|
9146 |
|
9147 | style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
|
9148 | }
|
9149 | else {
|
9150 | style[prefixed] = val;
|
9151 | }
|
9152 | }
|
9153 | }
|
9154 | }
|
9155 | const prefixes = ['Webkit', 'Moz', 'ms'];
|
9156 | const prefixCache = {};
|
9157 | function autoPrefix(style, rawName) {
|
9158 | const cached = prefixCache[rawName];
|
9159 | if (cached) {
|
9160 | return cached;
|
9161 | }
|
9162 | let name = camelize(rawName);
|
9163 | if (name !== 'filter' && name in style) {
|
9164 | return (prefixCache[rawName] = name);
|
9165 | }
|
9166 | name = capitalize(name);
|
9167 | for (let i = 0; i < prefixes.length; i++) {
|
9168 | const prefixed = prefixes[i] + name;
|
9169 | if (prefixed in style) {
|
9170 | return (prefixCache[rawName] = prefixed);
|
9171 | }
|
9172 | }
|
9173 | return rawName;
|
9174 | }
|
9175 |
|
9176 | const xlinkNS = 'http://www.w3.org/1999/xlink';
|
9177 | function patchAttr(el, key, value, isSVG, instance) {
|
9178 | if (isSVG && key.startsWith('xlink:')) {
|
9179 | if (value == null) {
|
9180 | el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
9181 | }
|
9182 | else {
|
9183 | el.setAttributeNS(xlinkNS, key, value);
|
9184 | }
|
9185 | }
|
9186 | else {
|
9187 |
|
9188 |
|
9189 | const isBoolean = isSpecialBooleanAttr(key);
|
9190 | if (value == null || (isBoolean && !includeBooleanAttr(value))) {
|
9191 | el.removeAttribute(key);
|
9192 | }
|
9193 | else {
|
9194 | el.setAttribute(key, isBoolean ? '' : value);
|
9195 | }
|
9196 | }
|
9197 | }
|
9198 |
|
9199 |
|
9200 |
|
9201 | function patchDOMProp(el, key, value,
|
9202 | // the following args are passed only due to potential innerHTML/textContent
|
9203 |
|
9204 |
|
9205 | prevChildren, parentComponent, parentSuspense, unmountChildren) {
|
9206 | if (key === 'innerHTML' || key === 'textContent') {
|
9207 | if (prevChildren) {
|
9208 | unmountChildren(prevChildren, parentComponent, parentSuspense);
|
9209 | }
|
9210 | el[key] = value == null ? '' : value;
|
9211 | return;
|
9212 | }
|
9213 | if (key === 'value' && el.tagName !== 'PROGRESS') {
|
9214 |
|
9215 |
|
9216 | el._value = value;
|
9217 | const newValue = value == null ? '' : value;
|
9218 | if (el.value !== newValue) {
|
9219 | el.value = newValue;
|
9220 | }
|
9221 | if (value == null) {
|
9222 | el.removeAttribute(key);
|
9223 | }
|
9224 | return;
|
9225 | }
|
9226 | if (value === '' || value == null) {
|
9227 | const type = typeof el[key];
|
9228 | if (type === 'boolean') {
|
9229 |
|
9230 | el[key] = includeBooleanAttr(value);
|
9231 | return;
|
9232 | }
|
9233 | else if (value == null && type === 'string') {
|
9234 |
|
9235 | el[key] = '';
|
9236 | el.removeAttribute(key);
|
9237 | return;
|
9238 | }
|
9239 | else if (type === 'number') {
|
9240 |
|
9241 |
|
9242 | try {
|
9243 | el[key] = 0;
|
9244 | }
|
9245 | catch (_a) { }
|
9246 | el.removeAttribute(key);
|
9247 | return;
|
9248 | }
|
9249 | }
|
9250 |
|
9251 | try {
|
9252 | el[key] = value;
|
9253 | }
|
9254 | catch (e) {
|
9255 | {
|
9256 | warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
|
9257 | `value ${value} is invalid.`, e);
|
9258 | }
|
9259 | }
|
9260 | }
|
9261 |
|
9262 |
|
9263 | let _getNow = Date.now;
|
9264 | let skipTimestampCheck = false;
|
9265 | if (typeof window !== 'undefined') {
|
9266 |
|
9267 |
|
9268 |
|
9269 |
|
9270 | if (_getNow() > document.createEvent('Event').timeStamp) {
|
9271 |
|
9272 |
|
9273 |
|
9274 | _getNow = () => performance.now();
|
9275 | }
|
9276 |
|
9277 |
|
9278 | const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
|
9279 | skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
|
9280 | }
|
9281 |
|
9282 |
|
9283 | let cachedNow = 0;
|
9284 | const p = Promise.resolve();
|
9285 | const reset = () => {
|
9286 | cachedNow = 0;
|
9287 | };
|
9288 | const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
|
9289 | function addEventListener(el, event, handler, options) {
|
9290 | el.addEventListener(event, handler, options);
|
9291 | }
|
9292 | function removeEventListener(el, event, handler, options) {
|
9293 | el.removeEventListener(event, handler, options);
|
9294 | }
|
9295 | function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
9296 |
|
9297 | const invokers = el._vei || (el._vei = {});
|
9298 | const existingInvoker = invokers[rawName];
|
9299 | if (nextValue && existingInvoker) {
|
9300 |
|
9301 | existingInvoker.value = nextValue;
|
9302 | }
|
9303 | else {
|
9304 | const [name, options] = parseName(rawName);
|
9305 | if (nextValue) {
|
9306 |
|
9307 | const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
|
9308 | addEventListener(el, name, invoker, options);
|
9309 | }
|
9310 | else if (existingInvoker) {
|
9311 |
|
9312 | removeEventListener(el, name, existingInvoker, options);
|
9313 | invokers[rawName] = undefined;
|
9314 | }
|
9315 | }
|
9316 | }
|
9317 | const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
9318 | function parseName(name) {
|
9319 | let options;
|
9320 | if (optionsModifierRE.test(name)) {
|
9321 | options = {};
|
9322 | let m;
|
9323 | while ((m = name.match(optionsModifierRE))) {
|
9324 | name = name.slice(0, name.length - m[0].length);
|
9325 | options[m[0].toLowerCase()] = true;
|
9326 | }
|
9327 | }
|
9328 | return [hyphenate(name.slice(2)), options];
|
9329 | }
|
9330 | function createInvoker(initialValue, instance) {
|
9331 | const invoker = (e) => {
|
9332 |
|
9333 |
|
9334 |
|
9335 |
|
9336 |
|
9337 |
|
9338 | const timeStamp = e.timeStamp || _getNow();
|
9339 | if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
|
9340 | callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 , [e]);
|
9341 | }
|
9342 | };
|
9343 | invoker.value = initialValue;
|
9344 | invoker.attached = getNow();
|
9345 | return invoker;
|
9346 | }
|
9347 | function patchStopImmediatePropagation(e, value) {
|
9348 | if (isArray(value)) {
|
9349 | const originalStop = e.stopImmediatePropagation;
|
9350 | e.stopImmediatePropagation = () => {
|
9351 | originalStop.call(e);
|
9352 | e._stopped = true;
|
9353 | };
|
9354 | return value.map(fn => (e) => !e._stopped && fn(e));
|
9355 | }
|
9356 | else {
|
9357 | return value;
|
9358 | }
|
9359 | }
|
9360 |
|
9361 | const nativeOnRE = /^on[a-z]/;
|
9362 | const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
|
9363 | if (key === 'class') {
|
9364 | patchClass(el, nextValue, isSVG);
|
9365 | }
|
9366 | else if (key === 'style') {
|
9367 | patchStyle(el, prevValue, nextValue);
|
9368 | }
|
9369 | else if (isOn(key)) {
|
9370 |
|
9371 | if (!isModelListener(key)) {
|
9372 | patchEvent(el, key, prevValue, nextValue, parentComponent);
|
9373 | }
|
9374 | }
|
9375 | else if (key[0] === '.'
|
9376 | ? ((key = key.slice(1)), true)
|
9377 | : key[0] === '^'
|
9378 | ? ((key = key.slice(1)), false)
|
9379 | : shouldSetAsProp(el, key, nextValue, isSVG)) {
|
9380 | patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
|
9381 | }
|
9382 | else {
|
9383 |
|
9384 |
|
9385 |
|
9386 |
|
9387 | if (key === 'true-value') {
|
9388 | el._trueValue = nextValue;
|
9389 | }
|
9390 | else if (key === 'false-value') {
|
9391 | el._falseValue = nextValue;
|
9392 | }
|
9393 | patchAttr(el, key, nextValue, isSVG);
|
9394 | }
|
9395 | };
|
9396 | function shouldSetAsProp(el, key, value, isSVG) {
|
9397 | if (isSVG) {
|
9398 |
|
9399 |
|
9400 | if (key === 'innerHTML' || key === 'textContent') {
|
9401 | return true;
|
9402 | }
|
9403 |
|
9404 | if (key in el && nativeOnRE.test(key) && isFunction(value)) {
|
9405 | return true;
|
9406 | }
|
9407 | return false;
|
9408 | }
|
9409 |
|
9410 |
|
9411 |
|
9412 |
|
9413 |
|
9414 |
|
9415 | if (key === 'spellcheck' || key === 'draggable') {
|
9416 | return false;
|
9417 | }
|
9418 |
|
9419 |
|
9420 | if (key === 'form') {
|
9421 | return false;
|
9422 | }
|
9423 |
|
9424 | if (key === 'list' && el.tagName === 'INPUT') {
|
9425 | return false;
|
9426 | }
|
9427 |
|
9428 | if (key === 'type' && el.tagName === 'TEXTAREA') {
|
9429 | return false;
|
9430 | }
|
9431 |
|
9432 | if (nativeOnRE.test(key) && isString(value)) {
|
9433 | return false;
|
9434 | }
|
9435 | return key in el;
|
9436 | }
|
9437 |
|
9438 | function defineCustomElement(options, hydate) {
|
9439 | const Comp = defineComponent(options);
|
9440 | class VueCustomElement extends VueElement {
|
9441 | constructor(initialProps) {
|
9442 | super(Comp, initialProps, hydate);
|
9443 | }
|
9444 | }
|
9445 | VueCustomElement.def = Comp;
|
9446 | return VueCustomElement;
|
9447 | }
|
9448 | const defineSSRCustomElement = ((options) => {
|
9449 |
|
9450 | return defineCustomElement(options, hydrate);
|
9451 | });
|
9452 | const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
|
9453 | });
|
9454 | class VueElement extends BaseClass {
|
9455 | constructor(_def, _props = {}, hydrate) {
|
9456 | super();
|
9457 | this._def = _def;
|
9458 | this._props = _props;
|
9459 | |
9460 |
|
9461 |
|
9462 | this._instance = null;
|
9463 | this._connected = false;
|
9464 | this._resolved = false;
|
9465 | this._numberProps = null;
|
9466 | if (this.shadowRoot && hydrate) {
|
9467 | hydrate(this._createVNode(), this.shadowRoot);
|
9468 | }
|
9469 | else {
|
9470 | if (this.shadowRoot) {
|
9471 | warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
|
9472 | `defined as hydratable. Use \`defineSSRCustomElement\`.`);
|
9473 | }
|
9474 | this.attachShadow({ mode: 'open' });
|
9475 | }
|
9476 |
|
9477 | for (let i = 0; i < this.attributes.length; i++) {
|
9478 | this._setAttr(this.attributes[i].name);
|
9479 | }
|
9480 |
|
9481 | new MutationObserver(mutations => {
|
9482 | for (const m of mutations) {
|
9483 | this._setAttr(m.attributeName);
|
9484 | }
|
9485 | }).observe(this, { attributes: true });
|
9486 | }
|
9487 | connectedCallback() {
|
9488 | this._connected = true;
|
9489 | if (!this._instance) {
|
9490 | this._resolveDef();
|
9491 | this._update();
|
9492 | }
|
9493 | }
|
9494 | disconnectedCallback() {
|
9495 | this._connected = false;
|
9496 | nextTick(() => {
|
9497 | if (!this._connected) {
|
9498 | render(null, this.shadowRoot);
|
9499 | this._instance = null;
|
9500 | }
|
9501 | });
|
9502 | }
|
9503 | |
9504 |
|
9505 |
|
9506 | _resolveDef() {
|
9507 | if (this._resolved) {
|
9508 | return;
|
9509 | }
|
9510 | const resolve = (def) => {
|
9511 | this._resolved = true;
|
9512 | const { props, styles } = def;
|
9513 | const hasOptions = !isArray(props);
|
9514 | const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
|
9515 |
|
9516 | let numberProps;
|
9517 | if (hasOptions) {
|
9518 | for (const key in this._props) {
|
9519 | const opt = props[key];
|
9520 | if (opt === Number || (opt && opt.type === Number)) {
|
9521 | this._props[key] = toNumber(this._props[key]);
|
9522 | (numberProps || (numberProps = Object.create(null)))[key] = true;
|
9523 | }
|
9524 | }
|
9525 | }
|
9526 | if (numberProps) {
|
9527 | this._numberProps = numberProps;
|
9528 | this._update();
|
9529 | }
|
9530 |
|
9531 | for (const key of Object.keys(this)) {
|
9532 | if (key[0] !== '_') {
|
9533 | this._setProp(key, this[key]);
|
9534 | }
|
9535 | }
|
9536 |
|
9537 | for (const key of rawKeys.map(camelize)) {
|
9538 | Object.defineProperty(this, key, {
|
9539 | get() {
|
9540 | return this._getProp(key);
|
9541 | },
|
9542 | set(val) {
|
9543 | this._setProp(key, val);
|
9544 | }
|
9545 | });
|
9546 | }
|
9547 | this._applyStyles(styles);
|
9548 | };
|
9549 | const asyncDef = this._def.__asyncLoader;
|
9550 | if (asyncDef) {
|
9551 | asyncDef().then(resolve);
|
9552 | }
|
9553 | else {
|
9554 | resolve(this._def);
|
9555 | }
|
9556 | }
|
9557 | _setAttr(key) {
|
9558 | let value = this.getAttribute(key);
|
9559 | if (this._numberProps && this._numberProps[key]) {
|
9560 | value = toNumber(value);
|
9561 | }
|
9562 | this._setProp(camelize(key), value, false);
|
9563 | }
|
9564 | |
9565 |
|
9566 |
|
9567 | _getProp(key) {
|
9568 | return this._props[key];
|
9569 | }
|
9570 | |
9571 |
|
9572 |
|
9573 | _setProp(key, val, shouldReflect = true) {
|
9574 | if (val !== this._props[key]) {
|
9575 | this._props[key] = val;
|
9576 | if (this._instance) {
|
9577 | this._update();
|
9578 | }
|
9579 |
|
9580 | if (shouldReflect) {
|
9581 | if (val === true) {
|
9582 | this.setAttribute(hyphenate(key), '');
|
9583 | }
|
9584 | else if (typeof val === 'string' || typeof val === 'number') {
|
9585 | this.setAttribute(hyphenate(key), val + '');
|
9586 | }
|
9587 | else if (!val) {
|
9588 | this.removeAttribute(hyphenate(key));
|
9589 | }
|
9590 | }
|
9591 | }
|
9592 | }
|
9593 | _update() {
|
9594 | render(this._createVNode(), this.shadowRoot);
|
9595 | }
|
9596 | _createVNode() {
|
9597 | const vnode = createVNode(this._def, extend({}, this._props));
|
9598 | if (!this._instance) {
|
9599 | vnode.ce = instance => {
|
9600 | this._instance = instance;
|
9601 | instance.isCE = true;
|
9602 |
|
9603 | {
|
9604 | instance.ceReload = newStyles => {
|
9605 |
|
9606 | if (this._styles) {
|
9607 | this._styles.forEach(s => this.shadowRoot.removeChild(s));
|
9608 | this._styles.length = 0;
|
9609 | }
|
9610 | this._applyStyles(newStyles);
|
9611 |
|
9612 |
|
9613 | if (!this._def.__asyncLoader) {
|
9614 |
|
9615 | this._instance = null;
|
9616 | this._update();
|
9617 | }
|
9618 | };
|
9619 | }
|
9620 |
|
9621 | instance.emit = (event, ...args) => {
|
9622 | this.dispatchEvent(new CustomEvent(event, {
|
9623 | detail: args
|
9624 | }));
|
9625 | };
|
9626 |
|
9627 | let parent = this;
|
9628 | while ((parent =
|
9629 | parent && (parent.parentNode || parent.host))) {
|
9630 | if (parent instanceof VueElement) {
|
9631 | instance.parent = parent._instance;
|
9632 | break;
|
9633 | }
|
9634 | }
|
9635 | };
|
9636 | }
|
9637 | return vnode;
|
9638 | }
|
9639 | _applyStyles(styles) {
|
9640 | if (styles) {
|
9641 | styles.forEach(css => {
|
9642 | const s = document.createElement('style');
|
9643 | s.textContent = css;
|
9644 | this.shadowRoot.appendChild(s);
|
9645 |
|
9646 | {
|
9647 | (this._styles || (this._styles = [])).push(s);
|
9648 | }
|
9649 | });
|
9650 | }
|
9651 | }
|
9652 | }
|
9653 |
|
9654 | function useCssModule(name = '$style') {
|
9655 |
|
9656 | {
|
9657 | {
|
9658 | warn$1(`useCssModule() is not supported in the global build.`);
|
9659 | }
|
9660 | return EMPTY_OBJ;
|
9661 | }
|
9662 | }
|
9663 |
|
9664 | |
9665 |
|
9666 |
|
9667 |
|
9668 | function useCssVars(getter) {
|
9669 | const instance = getCurrentInstance();
|
9670 |
|
9671 | if (!instance) {
|
9672 | warn$1(`useCssVars is called without current active component instance.`);
|
9673 | return;
|
9674 | }
|
9675 | const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
|
9676 | watchPostEffect(setVars);
|
9677 | onMounted(() => {
|
9678 | const ob = new MutationObserver(setVars);
|
9679 | ob.observe(instance.subTree.el.parentNode, { childList: true });
|
9680 | onUnmounted(() => ob.disconnect());
|
9681 | });
|
9682 | }
|
9683 | function setVarsOnVNode(vnode, vars) {
|
9684 | if (vnode.shapeFlag & 128 ) {
|
9685 | const suspense = vnode.suspense;
|
9686 | vnode = suspense.activeBranch;
|
9687 | if (suspense.pendingBranch && !suspense.isHydrating) {
|
9688 | suspense.effects.push(() => {
|
9689 | setVarsOnVNode(suspense.activeBranch, vars);
|
9690 | });
|
9691 | }
|
9692 | }
|
9693 |
|
9694 | while (vnode.component) {
|
9695 | vnode = vnode.component.subTree;
|
9696 | }
|
9697 | if (vnode.shapeFlag & 1 && vnode.el) {
|
9698 | setVarsOnNode(vnode.el, vars);
|
9699 | }
|
9700 | else if (vnode.type === Fragment) {
|
9701 | vnode.children.forEach(c => setVarsOnVNode(c, vars));
|
9702 | }
|
9703 | else if (vnode.type === Static) {
|
9704 | let { el, anchor } = vnode;
|
9705 | while (el) {
|
9706 | setVarsOnNode(el, vars);
|
9707 | if (el === anchor)
|
9708 | break;
|
9709 | el = el.nextSibling;
|
9710 | }
|
9711 | }
|
9712 | }
|
9713 | function setVarsOnNode(el, vars) {
|
9714 | if (el.nodeType === 1) {
|
9715 | const style = el.style;
|
9716 | for (const key in vars) {
|
9717 | style.setProperty(`--${key}`, vars[key]);
|
9718 | }
|
9719 | }
|
9720 | }
|
9721 |
|
9722 | const TRANSITION = 'transition';
|
9723 | const ANIMATION = 'animation';
|
9724 |
|
9725 |
|
9726 | const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
|
9727 | Transition.displayName = 'Transition';
|
9728 | const DOMTransitionPropsValidators = {
|
9729 | name: String,
|
9730 | type: String,
|
9731 | css: {
|
9732 | type: Boolean,
|
9733 | default: true
|
9734 | },
|
9735 | duration: [String, Number, Object],
|
9736 | enterFromClass: String,
|
9737 | enterActiveClass: String,
|
9738 | enterToClass: String,
|
9739 | appearFromClass: String,
|
9740 | appearActiveClass: String,
|
9741 | appearToClass: String,
|
9742 | leaveFromClass: String,
|
9743 | leaveActiveClass: String,
|
9744 | leaveToClass: String
|
9745 | };
|
9746 | const TransitionPropsValidators = (Transition.props =
|
9747 | extend({}, BaseTransition.props, DOMTransitionPropsValidators));
|
9748 | |
9749 |
|
9750 |
|
9751 |
|
9752 | const callHook$1 = (hook, args = []) => {
|
9753 | if (isArray(hook)) {
|
9754 | hook.forEach(h => h(...args));
|
9755 | }
|
9756 | else if (hook) {
|
9757 | hook(...args);
|
9758 | }
|
9759 | };
|
9760 | |
9761 |
|
9762 |
|
9763 |
|
9764 | const hasExplicitCallback = (hook) => {
|
9765 | return hook
|
9766 | ? isArray(hook)
|
9767 | ? hook.some(h => h.length > 1)
|
9768 | : hook.length > 1
|
9769 | : false;
|
9770 | };
|
9771 | function resolveTransitionProps(rawProps) {
|
9772 | const baseProps = {};
|
9773 | for (const key in rawProps) {
|
9774 | if (!(key in DOMTransitionPropsValidators)) {
|
9775 | baseProps[key] = rawProps[key];
|
9776 | }
|
9777 | }
|
9778 | if (rawProps.css === false) {
|
9779 | return baseProps;
|
9780 | }
|
9781 | 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;
|
9782 | const durations = normalizeDuration(duration);
|
9783 | const enterDuration = durations && durations[0];
|
9784 | const leaveDuration = durations && durations[1];
|
9785 | const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
|
9786 | const finishEnter = (el, isAppear, done) => {
|
9787 | removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9788 | removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
|
9789 | done && done();
|
9790 | };
|
9791 | const finishLeave = (el, done) => {
|
9792 | removeTransitionClass(el, leaveToClass);
|
9793 | removeTransitionClass(el, leaveActiveClass);
|
9794 | done && done();
|
9795 | };
|
9796 | const makeEnterHook = (isAppear) => {
|
9797 | return (el, done) => {
|
9798 | const hook = isAppear ? onAppear : onEnter;
|
9799 | const resolve = () => finishEnter(el, isAppear, done);
|
9800 | callHook$1(hook, [el, resolve]);
|
9801 | nextFrame(() => {
|
9802 | removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
|
9803 | addTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
9804 | if (!hasExplicitCallback(hook)) {
|
9805 | whenTransitionEnds(el, type, enterDuration, resolve);
|
9806 | }
|
9807 | });
|
9808 | };
|
9809 | };
|
9810 | return extend(baseProps, {
|
9811 | onBeforeEnter(el) {
|
9812 | callHook$1(onBeforeEnter, [el]);
|
9813 | addTransitionClass(el, enterFromClass);
|
9814 | addTransitionClass(el, enterActiveClass);
|
9815 | },
|
9816 | onBeforeAppear(el) {
|
9817 | callHook$1(onBeforeAppear, [el]);
|
9818 | addTransitionClass(el, appearFromClass);
|
9819 | addTransitionClass(el, appearActiveClass);
|
9820 | },
|
9821 | onEnter: makeEnterHook(false),
|
9822 | onAppear: makeEnterHook(true),
|
9823 | onLeave(el, done) {
|
9824 | const resolve = () => finishLeave(el, done);
|
9825 | addTransitionClass(el, leaveFromClass);
|
9826 |
|
9827 | forceReflow();
|
9828 | addTransitionClass(el, leaveActiveClass);
|
9829 | nextFrame(() => {
|
9830 | removeTransitionClass(el, leaveFromClass);
|
9831 | addTransitionClass(el, leaveToClass);
|
9832 | if (!hasExplicitCallback(onLeave)) {
|
9833 | whenTransitionEnds(el, type, leaveDuration, resolve);
|
9834 | }
|
9835 | });
|
9836 | callHook$1(onLeave, [el, resolve]);
|
9837 | },
|
9838 | onEnterCancelled(el) {
|
9839 | finishEnter(el, false);
|
9840 | callHook$1(onEnterCancelled, [el]);
|
9841 | },
|
9842 | onAppearCancelled(el) {
|
9843 | finishEnter(el, true);
|
9844 | callHook$1(onAppearCancelled, [el]);
|
9845 | },
|
9846 | onLeaveCancelled(el) {
|
9847 | finishLeave(el);
|
9848 | callHook$1(onLeaveCancelled, [el]);
|
9849 | }
|
9850 | });
|
9851 | }
|
9852 | function normalizeDuration(duration) {
|
9853 | if (duration == null) {
|
9854 | return null;
|
9855 | }
|
9856 | else if (isObject(duration)) {
|
9857 | return [NumberOf(duration.enter), NumberOf(duration.leave)];
|
9858 | }
|
9859 | else {
|
9860 | const n = NumberOf(duration);
|
9861 | return [n, n];
|
9862 | }
|
9863 | }
|
9864 | function NumberOf(val) {
|
9865 | const res = toNumber(val);
|
9866 | validateDuration(res);
|
9867 | return res;
|
9868 | }
|
9869 | function validateDuration(val) {
|
9870 | if (typeof val !== 'number') {
|
9871 | warn$1(`<transition> explicit duration is not a valid number - ` +
|
9872 | `got ${JSON.stringify(val)}.`);
|
9873 | }
|
9874 | else if (isNaN(val)) {
|
9875 | warn$1(`<transition> explicit duration is NaN - ` +
|
9876 | 'the duration expression might be incorrect.');
|
9877 | }
|
9878 | }
|
9879 | function addTransitionClass(el, cls) {
|
9880 | cls.split(/\s+/).forEach(c => c && el.classList.add(c));
|
9881 | (el._vtc ||
|
9882 | (el._vtc = new Set())).add(cls);
|
9883 | }
|
9884 | function removeTransitionClass(el, cls) {
|
9885 | cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
|
9886 | const { _vtc } = el;
|
9887 | if (_vtc) {
|
9888 | _vtc.delete(cls);
|
9889 | if (!_vtc.size) {
|
9890 | el._vtc = undefined;
|
9891 | }
|
9892 | }
|
9893 | }
|
9894 | function nextFrame(cb) {
|
9895 | requestAnimationFrame(() => {
|
9896 | requestAnimationFrame(cb);
|
9897 | });
|
9898 | }
|
9899 | let endId = 0;
|
9900 | function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
|
9901 | const id = (el._endId = ++endId);
|
9902 | const resolveIfNotStale = () => {
|
9903 | if (id === el._endId) {
|
9904 | resolve();
|
9905 | }
|
9906 | };
|
9907 | if (explicitTimeout) {
|
9908 | return setTimeout(resolveIfNotStale, explicitTimeout);
|
9909 | }
|
9910 | const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
|
9911 | if (!type) {
|
9912 | return resolve();
|
9913 | }
|
9914 | const endEvent = type + 'end';
|
9915 | let ended = 0;
|
9916 | const end = () => {
|
9917 | el.removeEventListener(endEvent, onEnd);
|
9918 | resolveIfNotStale();
|
9919 | };
|
9920 | const onEnd = (e) => {
|
9921 | if (e.target === el && ++ended >= propCount) {
|
9922 | end();
|
9923 | }
|
9924 | };
|
9925 | setTimeout(() => {
|
9926 | if (ended < propCount) {
|
9927 | end();
|
9928 | }
|
9929 | }, timeout + 1);
|
9930 | el.addEventListener(endEvent, onEnd);
|
9931 | }
|
9932 | function getTransitionInfo(el, expectedType) {
|
9933 | const styles = window.getComputedStyle(el);
|
9934 |
|
9935 | const getStyleProperties = (key) => (styles[key] || '').split(', ');
|
9936 | const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
|
9937 | const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
|
9938 | const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
9939 | const animationDelays = getStyleProperties(ANIMATION + 'Delay');
|
9940 | const animationDurations = getStyleProperties(ANIMATION + 'Duration');
|
9941 | const animationTimeout = getTimeout(animationDelays, animationDurations);
|
9942 | let type = null;
|
9943 | let timeout = 0;
|
9944 | let propCount = 0;
|
9945 |
|
9946 | if (expectedType === TRANSITION) {
|
9947 | if (transitionTimeout > 0) {
|
9948 | type = TRANSITION;
|
9949 | timeout = transitionTimeout;
|
9950 | propCount = transitionDurations.length;
|
9951 | }
|
9952 | }
|
9953 | else if (expectedType === ANIMATION) {
|
9954 | if (animationTimeout > 0) {
|
9955 | type = ANIMATION;
|
9956 | timeout = animationTimeout;
|
9957 | propCount = animationDurations.length;
|
9958 | }
|
9959 | }
|
9960 | else {
|
9961 | timeout = Math.max(transitionTimeout, animationTimeout);
|
9962 | type =
|
9963 | timeout > 0
|
9964 | ? transitionTimeout > animationTimeout
|
9965 | ? TRANSITION
|
9966 | : ANIMATION
|
9967 | : null;
|
9968 | propCount = type
|
9969 | ? type === TRANSITION
|
9970 | ? transitionDurations.length
|
9971 | : animationDurations.length
|
9972 | : 0;
|
9973 | }
|
9974 | const hasTransform = type === TRANSITION &&
|
9975 | /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
|
9976 | return {
|
9977 | type,
|
9978 | timeout,
|
9979 | propCount,
|
9980 | hasTransform
|
9981 | };
|
9982 | }
|
9983 | function getTimeout(delays, durations) {
|
9984 | while (delays.length < durations.length) {
|
9985 | delays = delays.concat(delays);
|
9986 | }
|
9987 | return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
|
9988 | }
|
9989 |
|
9990 |
|
9991 |
|
9992 |
|
9993 | function toMs(s) {
|
9994 | return Number(s.slice(0, -1).replace(',', '.')) * 1000;
|
9995 | }
|
9996 |
|
9997 | function forceReflow() {
|
9998 | return document.body.offsetHeight;
|
9999 | }
|
10000 |
|
10001 | const positionMap = new WeakMap();
|
10002 | const newPositionMap = new WeakMap();
|
10003 | const TransitionGroupImpl = {
|
10004 | name: 'TransitionGroup',
|
10005 | props: extend({}, TransitionPropsValidators, {
|
10006 | tag: String,
|
10007 | moveClass: String
|
10008 | }),
|
10009 | setup(props, { slots }) {
|
10010 | const instance = getCurrentInstance();
|
10011 | const state = useTransitionState();
|
10012 | let prevChildren;
|
10013 | let children;
|
10014 | onUpdated(() => {
|
10015 |
|
10016 | if (!prevChildren.length) {
|
10017 | return;
|
10018 | }
|
10019 | const moveClass = props.moveClass || `${props.name || 'v'}-move`;
|
10020 | if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
|
10021 | return;
|
10022 | }
|
10023 |
|
10024 |
|
10025 | prevChildren.forEach(callPendingCbs);
|
10026 | prevChildren.forEach(recordPosition);
|
10027 | const movedChildren = prevChildren.filter(applyTranslation);
|
10028 |
|
10029 | forceReflow();
|
10030 | movedChildren.forEach(c => {
|
10031 | const el = c.el;
|
10032 | const style = el.style;
|
10033 | addTransitionClass(el, moveClass);
|
10034 | style.transform = style.webkitTransform = style.transitionDuration = '';
|
10035 | const cb = (el._moveCb = (e) => {
|
10036 | if (e && e.target !== el) {
|
10037 | return;
|
10038 | }
|
10039 | if (!e || /transform$/.test(e.propertyName)) {
|
10040 | el.removeEventListener('transitionend', cb);
|
10041 | el._moveCb = null;
|
10042 | removeTransitionClass(el, moveClass);
|
10043 | }
|
10044 | });
|
10045 | el.addEventListener('transitionend', cb);
|
10046 | });
|
10047 | });
|
10048 | return () => {
|
10049 | const rawProps = toRaw(props);
|
10050 | const cssTransitionProps = resolveTransitionProps(rawProps);
|
10051 | let tag = rawProps.tag || Fragment;
|
10052 | prevChildren = children;
|
10053 | children = slots.default ? getTransitionRawChildren(slots.default()) : [];
|
10054 | for (let i = 0; i < children.length; i++) {
|
10055 | const child = children[i];
|
10056 | if (child.key != null) {
|
10057 | setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
|
10058 | }
|
10059 | else {
|
10060 | warn$1(`<TransitionGroup> children must be keyed.`);
|
10061 | }
|
10062 | }
|
10063 | if (prevChildren) {
|
10064 | for (let i = 0; i < prevChildren.length; i++) {
|
10065 | const child = prevChildren[i];
|
10066 | setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
|
10067 | positionMap.set(child, child.el.getBoundingClientRect());
|
10068 | }
|
10069 | }
|
10070 | return createVNode(tag, null, children);
|
10071 | };
|
10072 | }
|
10073 | };
|
10074 | const TransitionGroup = TransitionGroupImpl;
|
10075 | function callPendingCbs(c) {
|
10076 | const el = c.el;
|
10077 | if (el._moveCb) {
|
10078 | el._moveCb();
|
10079 | }
|
10080 | if (el._enterCb) {
|
10081 | el._enterCb();
|
10082 | }
|
10083 | }
|
10084 | function recordPosition(c) {
|
10085 | newPositionMap.set(c, c.el.getBoundingClientRect());
|
10086 | }
|
10087 | function applyTranslation(c) {
|
10088 | const oldPos = positionMap.get(c);
|
10089 | const newPos = newPositionMap.get(c);
|
10090 | const dx = oldPos.left - newPos.left;
|
10091 | const dy = oldPos.top - newPos.top;
|
10092 | if (dx || dy) {
|
10093 | const s = c.el.style;
|
10094 | s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
|
10095 | s.transitionDuration = '0s';
|
10096 | return c;
|
10097 | }
|
10098 | }
|
10099 | function hasCSSTransform(el, root, moveClass) {
|
10100 |
|
10101 |
|
10102 |
|
10103 |
|
10104 |
|
10105 | const clone = el.cloneNode();
|
10106 | if (el._vtc) {
|
10107 | el._vtc.forEach(cls => {
|
10108 | cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
|
10109 | });
|
10110 | }
|
10111 | moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
|
10112 | clone.style.display = 'none';
|
10113 | const container = (root.nodeType === 1 ? root : root.parentNode);
|
10114 | container.appendChild(clone);
|
10115 | const { hasTransform } = getTransitionInfo(clone);
|
10116 | container.removeChild(clone);
|
10117 | return hasTransform;
|
10118 | }
|
10119 |
|
10120 | const getModelAssigner = (vnode) => {
|
10121 | const fn = vnode.props['onUpdate:modelValue'];
|
10122 | return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
|
10123 | };
|
10124 | function onCompositionStart(e) {
|
10125 | e.target.composing = true;
|
10126 | }
|
10127 | function onCompositionEnd(e) {
|
10128 | const target = e.target;
|
10129 | if (target.composing) {
|
10130 | target.composing = false;
|
10131 | trigger$1(target, 'input');
|
10132 | }
|
10133 | }
|
10134 | function trigger$1(el, type) {
|
10135 | const e = document.createEvent('HTMLEvents');
|
10136 | e.initEvent(type, true, true);
|
10137 | el.dispatchEvent(e);
|
10138 | }
|
10139 |
|
10140 |
|
10141 | const vModelText = {
|
10142 | created(el, { modifiers: { lazy, trim, number } }, vnode) {
|
10143 | el._assign = getModelAssigner(vnode);
|
10144 | const castToNumber = number || (vnode.props && vnode.props.type === 'number');
|
10145 | addEventListener(el, lazy ? 'change' : 'input', e => {
|
10146 | if (e.target.composing)
|
10147 | return;
|
10148 | let domValue = el.value;
|
10149 | if (trim) {
|
10150 | domValue = domValue.trim();
|
10151 | }
|
10152 | else if (castToNumber) {
|
10153 | domValue = toNumber(domValue);
|
10154 | }
|
10155 | el._assign(domValue);
|
10156 | });
|
10157 | if (trim) {
|
10158 | addEventListener(el, 'change', () => {
|
10159 | el.value = el.value.trim();
|
10160 | });
|
10161 | }
|
10162 | if (!lazy) {
|
10163 | addEventListener(el, 'compositionstart', onCompositionStart);
|
10164 | addEventListener(el, 'compositionend', onCompositionEnd);
|
10165 |
|
10166 |
|
10167 |
|
10168 |
|
10169 | addEventListener(el, 'change', onCompositionEnd);
|
10170 | }
|
10171 | },
|
10172 |
|
10173 | mounted(el, { value }) {
|
10174 | el.value = value == null ? '' : value;
|
10175 | },
|
10176 | beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
|
10177 | el._assign = getModelAssigner(vnode);
|
10178 |
|
10179 | if (el.composing)
|
10180 | return;
|
10181 | if (document.activeElement === el) {
|
10182 | if (lazy) {
|
10183 | return;
|
10184 | }
|
10185 | if (trim && el.value.trim() === value) {
|
10186 | return;
|
10187 | }
|
10188 | if ((number || el.type === 'number') && toNumber(el.value) === value) {
|
10189 | return;
|
10190 | }
|
10191 | }
|
10192 | const newValue = value == null ? '' : value;
|
10193 | if (el.value !== newValue) {
|
10194 | el.value = newValue;
|
10195 | }
|
10196 | }
|
10197 | };
|
10198 | const vModelCheckbox = {
|
10199 |
|
10200 | deep: true,
|
10201 | created(el, _, vnode) {
|
10202 | el._assign = getModelAssigner(vnode);
|
10203 | addEventListener(el, 'change', () => {
|
10204 | const modelValue = el._modelValue;
|
10205 | const elementValue = getValue(el);
|
10206 | const checked = el.checked;
|
10207 | const assign = el._assign;
|
10208 | if (isArray(modelValue)) {
|
10209 | const index = looseIndexOf(modelValue, elementValue);
|
10210 | const found = index !== -1;
|
10211 | if (checked && !found) {
|
10212 | assign(modelValue.concat(elementValue));
|
10213 | }
|
10214 | else if (!checked && found) {
|
10215 | const filtered = [...modelValue];
|
10216 | filtered.splice(index, 1);
|
10217 | assign(filtered);
|
10218 | }
|
10219 | }
|
10220 | else if (isSet(modelValue)) {
|
10221 | const cloned = new Set(modelValue);
|
10222 | if (checked) {
|
10223 | cloned.add(elementValue);
|
10224 | }
|
10225 | else {
|
10226 | cloned.delete(elementValue);
|
10227 | }
|
10228 | assign(cloned);
|
10229 | }
|
10230 | else {
|
10231 | assign(getCheckboxValue(el, checked));
|
10232 | }
|
10233 | });
|
10234 | },
|
10235 |
|
10236 | mounted: setChecked,
|
10237 | beforeUpdate(el, binding, vnode) {
|
10238 | el._assign = getModelAssigner(vnode);
|
10239 | setChecked(el, binding, vnode);
|
10240 | }
|
10241 | };
|
10242 | function setChecked(el, { value, oldValue }, vnode) {
|
10243 | el._modelValue = value;
|
10244 | if (isArray(value)) {
|
10245 | el.checked = looseIndexOf(value, vnode.props.value) > -1;
|
10246 | }
|
10247 | else if (isSet(value)) {
|
10248 | el.checked = value.has(vnode.props.value);
|
10249 | }
|
10250 | else if (value !== oldValue) {
|
10251 | el.checked = looseEqual(value, getCheckboxValue(el, true));
|
10252 | }
|
10253 | }
|
10254 | const vModelRadio = {
|
10255 | created(el, { value }, vnode) {
|
10256 | el.checked = looseEqual(value, vnode.props.value);
|
10257 | el._assign = getModelAssigner(vnode);
|
10258 | addEventListener(el, 'change', () => {
|
10259 | el._assign(getValue(el));
|
10260 | });
|
10261 | },
|
10262 | beforeUpdate(el, { value, oldValue }, vnode) {
|
10263 | el._assign = getModelAssigner(vnode);
|
10264 | if (value !== oldValue) {
|
10265 | el.checked = looseEqual(value, vnode.props.value);
|
10266 | }
|
10267 | }
|
10268 | };
|
10269 | const vModelSelect = {
|
10270 |
|
10271 | deep: true,
|
10272 | created(el, { value, modifiers: { number } }, vnode) {
|
10273 | const isSetModel = isSet(value);
|
10274 | addEventListener(el, 'change', () => {
|
10275 | const selectedVal = Array.prototype.filter
|
10276 | .call(el.options, (o) => o.selected)
|
10277 | .map((o) => number ? toNumber(getValue(o)) : getValue(o));
|
10278 | el._assign(el.multiple
|
10279 | ? isSetModel
|
10280 | ? new Set(selectedVal)
|
10281 | : selectedVal
|
10282 | : selectedVal[0]);
|
10283 | });
|
10284 | el._assign = getModelAssigner(vnode);
|
10285 | },
|
10286 |
|
10287 |
|
10288 | mounted(el, { value }) {
|
10289 | setSelected(el, value);
|
10290 | },
|
10291 | beforeUpdate(el, _binding, vnode) {
|
10292 | el._assign = getModelAssigner(vnode);
|
10293 | },
|
10294 | updated(el, { value }) {
|
10295 | setSelected(el, value);
|
10296 | }
|
10297 | };
|
10298 | function setSelected(el, value) {
|
10299 | const isMultiple = el.multiple;
|
10300 | if (isMultiple && !isArray(value) && !isSet(value)) {
|
10301 | warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
|
10302 | `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
|
10303 | return;
|
10304 | }
|
10305 | for (let i = 0, l = el.options.length; i < l; i++) {
|
10306 | const option = el.options[i];
|
10307 | const optionValue = getValue(option);
|
10308 | if (isMultiple) {
|
10309 | if (isArray(value)) {
|
10310 | option.selected = looseIndexOf(value, optionValue) > -1;
|
10311 | }
|
10312 | else {
|
10313 | option.selected = value.has(optionValue);
|
10314 | }
|
10315 | }
|
10316 | else {
|
10317 | if (looseEqual(getValue(option), value)) {
|
10318 | if (el.selectedIndex !== i)
|
10319 | el.selectedIndex = i;
|
10320 | return;
|
10321 | }
|
10322 | }
|
10323 | }
|
10324 | if (!isMultiple && el.selectedIndex !== -1) {
|
10325 | el.selectedIndex = -1;
|
10326 | }
|
10327 | }
|
10328 |
|
10329 | function getValue(el) {
|
10330 | return '_value' in el ? el._value : el.value;
|
10331 | }
|
10332 |
|
10333 | function getCheckboxValue(el, checked) {
|
10334 | const key = checked ? '_trueValue' : '_falseValue';
|
10335 | return key in el ? el[key] : checked;
|
10336 | }
|
10337 | const vModelDynamic = {
|
10338 | created(el, binding, vnode) {
|
10339 | callModelHook(el, binding, vnode, null, 'created');
|
10340 | },
|
10341 | mounted(el, binding, vnode) {
|
10342 | callModelHook(el, binding, vnode, null, 'mounted');
|
10343 | },
|
10344 | beforeUpdate(el, binding, vnode, prevVNode) {
|
10345 | callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
|
10346 | },
|
10347 | updated(el, binding, vnode, prevVNode) {
|
10348 | callModelHook(el, binding, vnode, prevVNode, 'updated');
|
10349 | }
|
10350 | };
|
10351 | function callModelHook(el, binding, vnode, prevVNode, hook) {
|
10352 | let modelToUse;
|
10353 | switch (el.tagName) {
|
10354 | case 'SELECT':
|
10355 | modelToUse = vModelSelect;
|
10356 | break;
|
10357 | case 'TEXTAREA':
|
10358 | modelToUse = vModelText;
|
10359 | break;
|
10360 | default:
|
10361 | switch (vnode.props && vnode.props.type) {
|
10362 | case 'checkbox':
|
10363 | modelToUse = vModelCheckbox;
|
10364 | break;
|
10365 | case 'radio':
|
10366 | modelToUse = vModelRadio;
|
10367 | break;
|
10368 | default:
|
10369 | modelToUse = vModelText;
|
10370 | }
|
10371 | }
|
10372 | const fn = modelToUse[hook];
|
10373 | fn && fn(el, binding, vnode, prevVNode);
|
10374 | }
|
10375 |
|
10376 | const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
|
10377 | const modifierGuards = {
|
10378 | stop: e => e.stopPropagation(),
|
10379 | prevent: e => e.preventDefault(),
|
10380 | self: e => e.target !== e.currentTarget,
|
10381 | ctrl: e => !e.ctrlKey,
|
10382 | shift: e => !e.shiftKey,
|
10383 | alt: e => !e.altKey,
|
10384 | meta: e => !e.metaKey,
|
10385 | left: e => 'button' in e && e.button !== 0,
|
10386 | middle: e => 'button' in e && e.button !== 1,
|
10387 | right: e => 'button' in e && e.button !== 2,
|
10388 | exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
|
10389 | };
|
10390 | |
10391 |
|
10392 |
|
10393 | const withModifiers = (fn, modifiers) => {
|
10394 | return (event, ...args) => {
|
10395 | for (let i = 0; i < modifiers.length; i++) {
|
10396 | const guard = modifierGuards[modifiers[i]];
|
10397 | if (guard && guard(event, modifiers))
|
10398 | return;
|
10399 | }
|
10400 | return fn(event, ...args);
|
10401 | };
|
10402 | };
|
10403 |
|
10404 |
|
10405 | const keyNames = {
|
10406 | esc: 'escape',
|
10407 | space: ' ',
|
10408 | up: 'arrow-up',
|
10409 | left: 'arrow-left',
|
10410 | right: 'arrow-right',
|
10411 | down: 'arrow-down',
|
10412 | delete: 'backspace'
|
10413 | };
|
10414 | |
10415 |
|
10416 |
|
10417 | const withKeys = (fn, modifiers) => {
|
10418 | return (event) => {
|
10419 | if (!('key' in event)) {
|
10420 | return;
|
10421 | }
|
10422 | const eventKey = hyphenate(event.key);
|
10423 | if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
|
10424 | return fn(event);
|
10425 | }
|
10426 | };
|
10427 | };
|
10428 |
|
10429 | const vShow = {
|
10430 | beforeMount(el, { value }, { transition }) {
|
10431 | el._vod = el.style.display === 'none' ? '' : el.style.display;
|
10432 | if (transition && value) {
|
10433 | transition.beforeEnter(el);
|
10434 | }
|
10435 | else {
|
10436 | setDisplay(el, value);
|
10437 | }
|
10438 | },
|
10439 | mounted(el, { value }, { transition }) {
|
10440 | if (transition && value) {
|
10441 | transition.enter(el);
|
10442 | }
|
10443 | },
|
10444 | updated(el, { value, oldValue }, { transition }) {
|
10445 | if (!value === !oldValue)
|
10446 | return;
|
10447 | if (transition) {
|
10448 | if (value) {
|
10449 | transition.beforeEnter(el);
|
10450 | setDisplay(el, true);
|
10451 | transition.enter(el);
|
10452 | }
|
10453 | else {
|
10454 | transition.leave(el, () => {
|
10455 | setDisplay(el, false);
|
10456 | });
|
10457 | }
|
10458 | }
|
10459 | else {
|
10460 | setDisplay(el, value);
|
10461 | }
|
10462 | },
|
10463 | beforeUnmount(el, { value }) {
|
10464 | setDisplay(el, value);
|
10465 | }
|
10466 | };
|
10467 | function setDisplay(el, value) {
|
10468 | el.style.display = value ? el._vod : 'none';
|
10469 | }
|
10470 |
|
10471 | const rendererOptions = extend({ patchProp }, nodeOps);
|
10472 |
|
10473 |
|
10474 | let renderer;
|
10475 | let enabledHydration = false;
|
10476 | function ensureRenderer() {
|
10477 | return (renderer ||
|
10478 | (renderer = createRenderer(rendererOptions)));
|
10479 | }
|
10480 | function ensureHydrationRenderer() {
|
10481 | renderer = enabledHydration
|
10482 | ? renderer
|
10483 | : createHydrationRenderer(rendererOptions);
|
10484 | enabledHydration = true;
|
10485 | return renderer;
|
10486 | }
|
10487 |
|
10488 | const render = ((...args) => {
|
10489 | ensureRenderer().render(...args);
|
10490 | });
|
10491 | const hydrate = ((...args) => {
|
10492 | ensureHydrationRenderer().hydrate(...args);
|
10493 | });
|
10494 | const createApp = ((...args) => {
|
10495 | const app = ensureRenderer().createApp(...args);
|
10496 | {
|
10497 | injectNativeTagCheck(app);
|
10498 | injectCompilerOptionsCheck(app);
|
10499 | }
|
10500 | const { mount } = app;
|
10501 | app.mount = (containerOrSelector) => {
|
10502 | const container = normalizeContainer(containerOrSelector);
|
10503 | if (!container)
|
10504 | return;
|
10505 | const component = app._component;
|
10506 | if (!isFunction(component) && !component.render && !component.template) {
|
10507 |
|
10508 |
|
10509 |
|
10510 |
|
10511 | component.template = container.innerHTML;
|
10512 | }
|
10513 |
|
10514 | container.innerHTML = '';
|
10515 | const proxy = mount(container, false, container instanceof SVGElement);
|
10516 | if (container instanceof Element) {
|
10517 | container.removeAttribute('v-cloak');
|
10518 | container.setAttribute('data-v-app', '');
|
10519 | }
|
10520 | return proxy;
|
10521 | };
|
10522 | return app;
|
10523 | });
|
10524 | const createSSRApp = ((...args) => {
|
10525 | const app = ensureHydrationRenderer().createApp(...args);
|
10526 | {
|
10527 | injectNativeTagCheck(app);
|
10528 | injectCompilerOptionsCheck(app);
|
10529 | }
|
10530 | const { mount } = app;
|
10531 | app.mount = (containerOrSelector) => {
|
10532 | const container = normalizeContainer(containerOrSelector);
|
10533 | if (container) {
|
10534 | return mount(container, true, container instanceof SVGElement);
|
10535 | }
|
10536 | };
|
10537 | return app;
|
10538 | });
|
10539 | function injectNativeTagCheck(app) {
|
10540 |
|
10541 |
|
10542 | Object.defineProperty(app.config, 'isNativeTag', {
|
10543 | value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
10544 | writable: false
|
10545 | });
|
10546 | }
|
10547 |
|
10548 | function injectCompilerOptionsCheck(app) {
|
10549 | if (isRuntimeOnly()) {
|
10550 | const isCustomElement = app.config.isCustomElement;
|
10551 | Object.defineProperty(app.config, 'isCustomElement', {
|
10552 | get() {
|
10553 | return isCustomElement;
|
10554 | },
|
10555 | set() {
|
10556 | warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
|
10557 | `\`compilerOptions.isCustomElement\` instead.`);
|
10558 | }
|
10559 | });
|
10560 | const compilerOptions = app.config.compilerOptions;
|
10561 | const msg = `The \`compilerOptions\` config option is only respected when using ` +
|
10562 | `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
|
10563 | `Since you are using the runtime-only build, \`compilerOptions\` ` +
|
10564 | `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
|
10565 | `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
|
10566 | `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
|
10567 | `- 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`;
|
10568 | Object.defineProperty(app.config, 'compilerOptions', {
|
10569 | get() {
|
10570 | warn$1(msg);
|
10571 | return compilerOptions;
|
10572 | },
|
10573 | set() {
|
10574 | warn$1(msg);
|
10575 | }
|
10576 | });
|
10577 | }
|
10578 | }
|
10579 | function normalizeContainer(container) {
|
10580 | if (isString(container)) {
|
10581 | const res = document.querySelector(container);
|
10582 | if (!res) {
|
10583 | warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
|
10584 | }
|
10585 | return res;
|
10586 | }
|
10587 | if (window.ShadowRoot &&
|
10588 | container instanceof window.ShadowRoot &&
|
10589 | container.mode === 'closed') {
|
10590 | warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
|
10591 | }
|
10592 | return container;
|
10593 | }
|
10594 | |
10595 |
|
10596 |
|
10597 | const initDirectivesForSSR = NOOP;
|
10598 |
|
10599 | function initDev() {
|
10600 | {
|
10601 | {
|
10602 | console.info(`You are running a development build of Vue.\n` +
|
10603 | `Make sure to use the production build (*.prod.js) when deploying for production.`);
|
10604 | }
|
10605 | initCustomFormatter();
|
10606 | }
|
10607 | }
|
10608 |
|
10609 | function defaultOnError(error) {
|
10610 | throw error;
|
10611 | }
|
10612 | function defaultOnWarn(msg) {
|
10613 | console.warn(`[Vue warn] ${msg.message}`);
|
10614 | }
|
10615 | function createCompilerError(code, loc, messages, additionalMessage) {
|
10616 | const msg = (messages || errorMessages)[code] + (additionalMessage || ``)
|
10617 | ;
|
10618 | const error = new SyntaxError(String(msg));
|
10619 | error.code = code;
|
10620 | error.loc = loc;
|
10621 | return error;
|
10622 | }
|
10623 | const errorMessages = {
|
10624 |
|
10625 | [0 ]: 'Illegal comment.',
|
10626 | [1 ]: 'CDATA section is allowed only in XML context.',
|
10627 | [2 ]: 'Duplicate attribute.',
|
10628 | [3 ]: 'End tag cannot have attributes.',
|
10629 | [4 ]: "Illegal '/' in tags.",
|
10630 | [5 ]: 'Unexpected EOF in tag.',
|
10631 | [6 ]: 'Unexpected EOF in CDATA section.',
|
10632 | [7 ]: 'Unexpected EOF in comment.',
|
10633 | [8 ]: 'Unexpected EOF in script.',
|
10634 | [9 ]: 'Unexpected EOF in tag.',
|
10635 | [10 ]: 'Incorrectly closed comment.',
|
10636 | [11 ]: 'Incorrectly opened comment.',
|
10637 | [12 ]: "Illegal tag name. Use '<' to print '<'.",
|
10638 | [13 ]: 'Attribute value was expected.',
|
10639 | [14 ]: 'End tag name was expected.',
|
10640 | [15 ]: 'Whitespace was expected.',
|
10641 | [16 ]: "Unexpected '<!--' in comment.",
|
10642 | [17 ]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
|
10643 | [18 ]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
|
10644 | [19 ]: "Attribute name cannot start with '='.",
|
10645 | [21 ]: "'<?' is allowed only in XML context.",
|
10646 | [20 ]: `Unexpected null character.`,
|
10647 | [22 ]: "Illegal '/' in tags.",
|
10648 |
|
10649 | [23 ]: 'Invalid end tag.',
|
10650 | [24 ]: 'Element is missing end tag.',
|
10651 | [25 ]: 'Interpolation end sign was not found.',
|
10652 | [27 ]: 'End bracket for dynamic directive argument was not found. ' +
|
10653 | 'Note that dynamic directive argument cannot contain spaces.',
|
10654 | [26 ]: 'Legal directive name was expected.',
|
10655 |
|
10656 | [28 ]: `v-if/v-else-if is missing expression.`,
|
10657 | [29 ]: `v-if/else branches must use unique keys.`,
|
10658 | [30 ]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
10659 | [31 ]: `v-for is missing expression.`,
|
10660 | [32 ]: `v-for has invalid expression.`,
|
10661 | [33 ]: `<template v-for> key should be placed on the <template> tag.`,
|
10662 | [34 ]: `v-bind is missing expression.`,
|
10663 | [35 ]: `v-on is missing expression.`,
|
10664 | [36 ]: `Unexpected custom directive on <slot> outlet.`,
|
10665 | [37 ]: `Mixed v-slot usage on both the component and nested <template>.` +
|
10666 | `When there are multiple named slots, all slots should use <template> ` +
|
10667 | `syntax to avoid scope ambiguity.`,
|
10668 | [38 ]: `Duplicate slot names found. `,
|
10669 | [39 ]: `Extraneous children found when component already has explicitly named ` +
|
10670 | `default slot. These children will be ignored.`,
|
10671 | [40 ]: `v-slot can only be used on components or <template> tags.`,
|
10672 | [41 ]: `v-model is missing expression.`,
|
10673 | [42 ]: `v-model value must be a valid JavaScript member expression.`,
|
10674 | [43 ]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
10675 | [44 ]: `Error parsing JavaScript expression: `,
|
10676 | [45 ]: `<KeepAlive> expects exactly one child component.`,
|
10677 |
|
10678 | [46 ]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
10679 | [47 ]: `ES module mode is not supported in this build of compiler.`,
|
10680 | [48 ]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
10681 | [49 ]: `"scopeId" option is only supported in module mode.`,
|
10682 |
|
10683 | [50 ]: ``
|
10684 | };
|
10685 |
|
10686 | const FRAGMENT = Symbol(`Fragment` );
|
10687 | const TELEPORT = Symbol(`Teleport` );
|
10688 | const SUSPENSE = Symbol(`Suspense` );
|
10689 | const KEEP_ALIVE = Symbol(`KeepAlive` );
|
10690 | const BASE_TRANSITION = Symbol(`BaseTransition` );
|
10691 | const OPEN_BLOCK = Symbol(`openBlock` );
|
10692 | const CREATE_BLOCK = Symbol(`createBlock` );
|
10693 | const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
|
10694 | const CREATE_VNODE = Symbol(`createVNode` );
|
10695 | const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
|
10696 | const CREATE_COMMENT = Symbol(`createCommentVNode` );
|
10697 | const CREATE_TEXT = Symbol(`createTextVNode` );
|
10698 | const CREATE_STATIC = Symbol(`createStaticVNode` );
|
10699 | const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
|
10700 | const RESOLVE_DYNAMIC_COMPONENT = Symbol(`resolveDynamicComponent` );
|
10701 | const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
|
10702 | const RESOLVE_FILTER = Symbol(`resolveFilter` );
|
10703 | const WITH_DIRECTIVES = Symbol(`withDirectives` );
|
10704 | const RENDER_LIST = Symbol(`renderList` );
|
10705 | const RENDER_SLOT = Symbol(`renderSlot` );
|
10706 | const CREATE_SLOTS = Symbol(`createSlots` );
|
10707 | const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
|
10708 | const MERGE_PROPS = Symbol(`mergeProps` );
|
10709 | const NORMALIZE_CLASS = Symbol(`normalizeClass` );
|
10710 | const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
|
10711 | const NORMALIZE_PROPS = Symbol(`normalizeProps` );
|
10712 | const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
|
10713 | const TO_HANDLERS = Symbol(`toHandlers` );
|
10714 | const CAMELIZE = Symbol(`camelize` );
|
10715 | const CAPITALIZE = Symbol(`capitalize` );
|
10716 | const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
|
10717 | const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
|
10718 | const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
|
10719 | const POP_SCOPE_ID = Symbol(`popScopeId` );
|
10720 | const WITH_CTX = Symbol(`withCtx` );
|
10721 | const UNREF = Symbol(`unref` );
|
10722 | const IS_REF = Symbol(`isRef` );
|
10723 | const WITH_MEMO = Symbol(`withMemo` );
|
10724 | const IS_MEMO_SAME = Symbol(`isMemoSame` );
|
10725 |
|
10726 |
|
10727 |
|
10728 | const helperNameMap = {
|
10729 | [FRAGMENT]: `Fragment`,
|
10730 | [TELEPORT]: `Teleport`,
|
10731 | [SUSPENSE]: `Suspense`,
|
10732 | [KEEP_ALIVE]: `KeepAlive`,
|
10733 | [BASE_TRANSITION]: `BaseTransition`,
|
10734 | [OPEN_BLOCK]: `openBlock`,
|
10735 | [CREATE_BLOCK]: `createBlock`,
|
10736 | [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
|
10737 | [CREATE_VNODE]: `createVNode`,
|
10738 | [CREATE_ELEMENT_VNODE]: `createElementVNode`,
|
10739 | [CREATE_COMMENT]: `createCommentVNode`,
|
10740 | [CREATE_TEXT]: `createTextVNode`,
|
10741 | [CREATE_STATIC]: `createStaticVNode`,
|
10742 | [RESOLVE_COMPONENT]: `resolveComponent`,
|
10743 | [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
|
10744 | [RESOLVE_DIRECTIVE]: `resolveDirective`,
|
10745 | [RESOLVE_FILTER]: `resolveFilter`,
|
10746 | [WITH_DIRECTIVES]: `withDirectives`,
|
10747 | [RENDER_LIST]: `renderList`,
|
10748 | [RENDER_SLOT]: `renderSlot`,
|
10749 | [CREATE_SLOTS]: `createSlots`,
|
10750 | [TO_DISPLAY_STRING]: `toDisplayString`,
|
10751 | [MERGE_PROPS]: `mergeProps`,
|
10752 | [NORMALIZE_CLASS]: `normalizeClass`,
|
10753 | [NORMALIZE_STYLE]: `normalizeStyle`,
|
10754 | [NORMALIZE_PROPS]: `normalizeProps`,
|
10755 | [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
|
10756 | [TO_HANDLERS]: `toHandlers`,
|
10757 | [CAMELIZE]: `camelize`,
|
10758 | [CAPITALIZE]: `capitalize`,
|
10759 | [TO_HANDLER_KEY]: `toHandlerKey`,
|
10760 | [SET_BLOCK_TRACKING]: `setBlockTracking`,
|
10761 | [PUSH_SCOPE_ID]: `pushScopeId`,
|
10762 | [POP_SCOPE_ID]: `popScopeId`,
|
10763 | [WITH_CTX]: `withCtx`,
|
10764 | [UNREF]: `unref`,
|
10765 | [IS_REF]: `isRef`,
|
10766 | [WITH_MEMO]: `withMemo`,
|
10767 | [IS_MEMO_SAME]: `isMemoSame`
|
10768 | };
|
10769 | function registerRuntimeHelpers(helpers) {
|
10770 | Object.getOwnPropertySymbols(helpers).forEach(s => {
|
10771 | helperNameMap[s] = helpers[s];
|
10772 | });
|
10773 | }
|
10774 |
|
10775 |
|
10776 |
|
10777 |
|
10778 |
|
10779 | const locStub = {
|
10780 | source: '',
|
10781 | start: { line: 1, column: 1, offset: 0 },
|
10782 | end: { line: 1, column: 1, offset: 0 }
|
10783 | };
|
10784 | function createRoot(children, loc = locStub) {
|
10785 | return {
|
10786 | type: 0 ,
|
10787 | children,
|
10788 | helpers: [],
|
10789 | components: [],
|
10790 | directives: [],
|
10791 | hoists: [],
|
10792 | imports: [],
|
10793 | cached: 0,
|
10794 | temps: 0,
|
10795 | codegenNode: undefined,
|
10796 | loc
|
10797 | };
|
10798 | }
|
10799 | function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
|
10800 | if (context) {
|
10801 | if (isBlock) {
|
10802 | context.helper(OPEN_BLOCK);
|
10803 | context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
|
10804 | }
|
10805 | else {
|
10806 | context.helper(getVNodeHelper(context.inSSR, isComponent));
|
10807 | }
|
10808 | if (directives) {
|
10809 | context.helper(WITH_DIRECTIVES);
|
10810 | }
|
10811 | }
|
10812 | return {
|
10813 | type: 13 ,
|
10814 | tag,
|
10815 | props,
|
10816 | children,
|
10817 | patchFlag,
|
10818 | dynamicProps,
|
10819 | directives,
|
10820 | isBlock,
|
10821 | disableTracking,
|
10822 | isComponent,
|
10823 | loc
|
10824 | };
|
10825 | }
|
10826 | function createArrayExpression(elements, loc = locStub) {
|
10827 | return {
|
10828 | type: 17 ,
|
10829 | loc,
|
10830 | elements
|
10831 | };
|
10832 | }
|
10833 | function createObjectExpression(properties, loc = locStub) {
|
10834 | return {
|
10835 | type: 15 ,
|
10836 | loc,
|
10837 | properties
|
10838 | };
|
10839 | }
|
10840 | function createObjectProperty(key, value) {
|
10841 | return {
|
10842 | type: 16 ,
|
10843 | loc: locStub,
|
10844 | key: isString(key) ? createSimpleExpression(key, true) : key,
|
10845 | value
|
10846 | };
|
10847 | }
|
10848 | function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* NOT_CONSTANT */) {
|
10849 | return {
|
10850 | type: 4 ,
|
10851 | loc,
|
10852 | content,
|
10853 | isStatic,
|
10854 | constType: isStatic ? 3 : constType
|
10855 | };
|
10856 | }
|
10857 | function createCompoundExpression(children, loc = locStub) {
|
10858 | return {
|
10859 | type: 8 ,
|
10860 | loc,
|
10861 | children
|
10862 | };
|
10863 | }
|
10864 | function createCallExpression(callee, args = [], loc = locStub) {
|
10865 | return {
|
10866 | type: 14 ,
|
10867 | loc,
|
10868 | callee,
|
10869 | arguments: args
|
10870 | };
|
10871 | }
|
10872 | function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
|
10873 | return {
|
10874 | type: 18 ,
|
10875 | params,
|
10876 | returns,
|
10877 | newline,
|
10878 | isSlot,
|
10879 | loc
|
10880 | };
|
10881 | }
|
10882 | function createConditionalExpression(test, consequent, alternate, newline = true) {
|
10883 | return {
|
10884 | type: 19 ,
|
10885 | test,
|
10886 | consequent,
|
10887 | alternate,
|
10888 | newline,
|
10889 | loc: locStub
|
10890 | };
|
10891 | }
|
10892 | function createCacheExpression(index, value, isVNode = false) {
|
10893 | return {
|
10894 | type: 20 ,
|
10895 | index,
|
10896 | value,
|
10897 | isVNode,
|
10898 | loc: locStub
|
10899 | };
|
10900 | }
|
10901 | function createBlockStatement(body) {
|
10902 | return {
|
10903 | type: 21 ,
|
10904 | body,
|
10905 | loc: locStub
|
10906 | };
|
10907 | }
|
10908 |
|
10909 | const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
10910 | const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
|
10911 | function isCoreComponent(tag) {
|
10912 | if (isBuiltInType(tag, 'Teleport')) {
|
10913 | return TELEPORT;
|
10914 | }
|
10915 | else if (isBuiltInType(tag, 'Suspense')) {
|
10916 | return SUSPENSE;
|
10917 | }
|
10918 | else if (isBuiltInType(tag, 'KeepAlive')) {
|
10919 | return KEEP_ALIVE;
|
10920 | }
|
10921 | else if (isBuiltInType(tag, 'BaseTransition')) {
|
10922 | return BASE_TRANSITION;
|
10923 | }
|
10924 | }
|
10925 | const nonIdentifierRE = /^\d|[^\$\w]/;
|
10926 | const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
10927 | const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
10928 | const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
10929 | const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
10930 | |
10931 |
|
10932 |
|
10933 |
|
10934 |
|
10935 |
|
10936 | const isMemberExpressionBrowser = (path) => {
|
10937 |
|
10938 | path = path.trim().replace(whitespaceRE, s => s.trim());
|
10939 | let state = 0 ;
|
10940 | let stateStack = [];
|
10941 | let currentOpenBracketCount = 0;
|
10942 | let currentOpenParensCount = 0;
|
10943 | let currentStringType = null;
|
10944 | for (let i = 0; i < path.length; i++) {
|
10945 | const char = path.charAt(i);
|
10946 | switch (state) {
|
10947 | case 0 :
|
10948 | if (char === '[') {
|
10949 | stateStack.push(state);
|
10950 | state = 1 ;
|
10951 | currentOpenBracketCount++;
|
10952 | }
|
10953 | else if (char === '(') {
|
10954 | stateStack.push(state);
|
10955 | state = 2 ;
|
10956 | currentOpenParensCount++;
|
10957 | }
|
10958 | else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
10959 | return false;
|
10960 | }
|
10961 | break;
|
10962 | case 1 :
|
10963 | if (char === `'` || char === `"` || char === '`') {
|
10964 | stateStack.push(state);
|
10965 | state = 3 ;
|
10966 | currentStringType = char;
|
10967 | }
|
10968 | else if (char === `[`) {
|
10969 | currentOpenBracketCount++;
|
10970 | }
|
10971 | else if (char === `]`) {
|
10972 | if (!--currentOpenBracketCount) {
|
10973 | state = stateStack.pop();
|
10974 | }
|
10975 | }
|
10976 | break;
|
10977 | case 2 :
|
10978 | if (char === `'` || char === `"` || char === '`') {
|
10979 | stateStack.push(state);
|
10980 | state = 3 ;
|
10981 | currentStringType = char;
|
10982 | }
|
10983 | else if (char === `(`) {
|
10984 | currentOpenParensCount++;
|
10985 | }
|
10986 | else if (char === `)`) {
|
10987 |
|
10988 | if (i === path.length - 1) {
|
10989 | return false;
|
10990 | }
|
10991 | if (!--currentOpenParensCount) {
|
10992 | state = stateStack.pop();
|
10993 | }
|
10994 | }
|
10995 | break;
|
10996 | case 3 :
|
10997 | if (char === currentStringType) {
|
10998 | state = stateStack.pop();
|
10999 | currentStringType = null;
|
11000 | }
|
11001 | break;
|
11002 | }
|
11003 | }
|
11004 | return !currentOpenBracketCount && !currentOpenParensCount;
|
11005 | };
|
11006 | const isMemberExpression = isMemberExpressionBrowser
|
11007 | ;
|
11008 | function getInnerRange(loc, offset, length) {
|
11009 | const source = loc.source.substr(offset, length);
|
11010 | const newLoc = {
|
11011 | source,
|
11012 | start: advancePositionWithClone(loc.start, loc.source, offset),
|
11013 | end: loc.end
|
11014 | };
|
11015 | if (length != null) {
|
11016 | newLoc.end = advancePositionWithClone(loc.start, loc.source, offset + length);
|
11017 | }
|
11018 | return newLoc;
|
11019 | }
|
11020 | function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
|
11021 | return advancePositionWithMutation(extend({}, pos), source, numberOfCharacters);
|
11022 | }
|
11023 |
|
11024 |
|
11025 | function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
|
11026 | let linesCount = 0;
|
11027 | let lastNewLinePos = -1;
|
11028 | for (let i = 0; i < numberOfCharacters; i++) {
|
11029 | if (source.charCodeAt(i) === 10 ) {
|
11030 | linesCount++;
|
11031 | lastNewLinePos = i;
|
11032 | }
|
11033 | }
|
11034 | pos.offset += numberOfCharacters;
|
11035 | pos.line += linesCount;
|
11036 | pos.column =
|
11037 | lastNewLinePos === -1
|
11038 | ? pos.column + numberOfCharacters
|
11039 | : numberOfCharacters - lastNewLinePos;
|
11040 | return pos;
|
11041 | }
|
11042 | function assert(condition, msg) {
|
11043 |
|
11044 | if (!condition) {
|
11045 | throw new Error(msg || `unexpected compiler condition`);
|
11046 | }
|
11047 | }
|
11048 | function findDir(node, name, allowEmpty = false) {
|
11049 | for (let i = 0; i < node.props.length; i++) {
|
11050 | const p = node.props[i];
|
11051 | if (p.type === 7 &&
|
11052 | (allowEmpty || p.exp) &&
|
11053 | (isString(name) ? p.name === name : name.test(p.name))) {
|
11054 | return p;
|
11055 | }
|
11056 | }
|
11057 | }
|
11058 | function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
11059 | for (let i = 0; i < node.props.length; i++) {
|
11060 | const p = node.props[i];
|
11061 | if (p.type === 6 ) {
|
11062 | if (dynamicOnly)
|
11063 | continue;
|
11064 | if (p.name === name && (p.value || allowEmpty)) {
|
11065 | return p;
|
11066 | }
|
11067 | }
|
11068 | else if (p.name === 'bind' &&
|
11069 | (p.exp || allowEmpty) &&
|
11070 | isBindKey(p.arg, name)) {
|
11071 | return p;
|
11072 | }
|
11073 | }
|
11074 | }
|
11075 | function isBindKey(arg, name) {
|
11076 | return !!(arg && isStaticExp(arg) && arg.content === name);
|
11077 | }
|
11078 | function hasDynamicKeyVBind(node) {
|
11079 | return node.props.some(p => p.type === 7 &&
|
11080 | p.name === 'bind' &&
|
11081 | (!p.arg ||
|
11082 | p.arg.type !== 4 ||
|
11083 | !p.arg.isStatic)
|
11084 | );
|
11085 | }
|
11086 | function isText(node) {
|
11087 | return node.type === 5 || node.type === 2 ;
|
11088 | }
|
11089 | function isVSlot(p) {
|
11090 | return p.type === 7 && p.name === 'slot';
|
11091 | }
|
11092 | function isTemplateNode(node) {
|
11093 | return (node.type === 1 && node.tagType === 3 );
|
11094 | }
|
11095 | function isSlotOutlet(node) {
|
11096 | return node.type === 1 && node.tagType === 2 ;
|
11097 | }
|
11098 | function getVNodeHelper(ssr, isComponent) {
|
11099 | return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
11100 | }
|
11101 | function getVNodeBlockHelper(ssr, isComponent) {
|
11102 | return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
11103 | }
|
11104 | const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
11105 | function getUnnormalizedProps(props, callPath = []) {
|
11106 | if (props &&
|
11107 | !isString(props) &&
|
11108 | props.type === 14 ) {
|
11109 | const callee = props.callee;
|
11110 | if (!isString(callee) && propsHelperSet.has(callee)) {
|
11111 | return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
|
11112 | }
|
11113 | }
|
11114 | return [props, callPath];
|
11115 | }
|
11116 | function injectProp(node, prop, context) {
|
11117 | let propsWithInjection;
|
11118 | const originalProps = node.type === 13 ? node.props : node.arguments[2];
|
11119 | |
11120 |
|
11121 |
|
11122 |
|
11123 |
|
11124 |
|
11125 |
|
11126 |
|
11127 | let props = originalProps;
|
11128 | let callPath = [];
|
11129 | let parentCall;
|
11130 | if (props &&
|
11131 | !isString(props) &&
|
11132 | props.type === 14 ) {
|
11133 | const ret = getUnnormalizedProps(props);
|
11134 | props = ret[0];
|
11135 | callPath = ret[1];
|
11136 | parentCall = callPath[callPath.length - 1];
|
11137 | }
|
11138 | if (props == null || isString(props)) {
|
11139 | propsWithInjection = createObjectExpression([prop]);
|
11140 | }
|
11141 | else if (props.type === 14 ) {
|
11142 |
|
11143 |
|
11144 |
|
11145 | const first = props.arguments[0];
|
11146 | if (!isString(first) && first.type === 15 ) {
|
11147 | first.properties.unshift(prop);
|
11148 | }
|
11149 | else {
|
11150 | if (props.callee === TO_HANDLERS) {
|
11151 |
|
11152 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
11153 | createObjectExpression([prop]),
|
11154 | props
|
11155 | ]);
|
11156 | }
|
11157 | else {
|
11158 | props.arguments.unshift(createObjectExpression([prop]));
|
11159 | }
|
11160 | }
|
11161 | !propsWithInjection && (propsWithInjection = props);
|
11162 | }
|
11163 | else if (props.type === 15 ) {
|
11164 | let alreadyExists = false;
|
11165 |
|
11166 | if (prop.key.type === 4 ) {
|
11167 | const propKeyName = prop.key.content;
|
11168 | alreadyExists = props.properties.some(p => p.key.type === 4 &&
|
11169 | p.key.content === propKeyName);
|
11170 | }
|
11171 | if (!alreadyExists) {
|
11172 | props.properties.unshift(prop);
|
11173 | }
|
11174 | propsWithInjection = props;
|
11175 | }
|
11176 | else {
|
11177 |
|
11178 | propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
|
11179 | createObjectExpression([prop]),
|
11180 | props
|
11181 | ]);
|
11182 |
|
11183 |
|
11184 |
|
11185 | if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
|
11186 | parentCall = callPath[callPath.length - 2];
|
11187 | }
|
11188 | }
|
11189 | if (node.type === 13 ) {
|
11190 | if (parentCall) {
|
11191 | parentCall.arguments[0] = propsWithInjection;
|
11192 | }
|
11193 | else {
|
11194 | node.props = propsWithInjection;
|
11195 | }
|
11196 | }
|
11197 | else {
|
11198 | if (parentCall) {
|
11199 | parentCall.arguments[0] = propsWithInjection;
|
11200 | }
|
11201 | else {
|
11202 | node.arguments[2] = propsWithInjection;
|
11203 | }
|
11204 | }
|
11205 | }
|
11206 | function toValidAssetId(name, type) {
|
11207 |
|
11208 | return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
|
11209 | return searchValue === '-' ? '_' : name.charCodeAt(replaceValue).toString();
|
11210 | })}`;
|
11211 | }
|
11212 | function getMemoedVNodeCall(node) {
|
11213 | if (node.type === 14 && node.callee === WITH_MEMO) {
|
11214 | return node.arguments[1].returns;
|
11215 | }
|
11216 | else {
|
11217 | return node;
|
11218 | }
|
11219 | }
|
11220 | function makeBlock(node, { helper, removeHelper, inSSR }) {
|
11221 | if (!node.isBlock) {
|
11222 | node.isBlock = true;
|
11223 | removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
11224 | helper(OPEN_BLOCK);
|
11225 | helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
11226 | }
|
11227 | }
|
11228 |
|
11229 | const deprecationData = {
|
11230 | ["COMPILER_IS_ON_ELEMENT" ]: {
|
11231 | message: `Platform-native elements with "is" prop will no longer be ` +
|
11232 | `treated as components in Vue 3 unless the "is" value is explicitly ` +
|
11233 | `prefixed with "vue:".`,
|
11234 | link: `https://v3.vuejs.org/guide/migration/custom-elements-interop.html`
|
11235 | },
|
11236 | ["COMPILER_V_BIND_SYNC" ]: {
|
11237 | message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
|
11238 | `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
|
11239 | `\`v-model:${key}\`.`,
|
11240 | link: `https://v3.vuejs.org/guide/migration/v-model.html`
|
11241 | },
|
11242 | ["COMPILER_V_BIND_PROP" ]: {
|
11243 | message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
|
11244 | `Vue 3 will automatically set a binding as DOM property when appropriate.`
|
11245 | },
|
11246 | ["COMPILER_V_BIND_OBJECT_ORDER" ]: {
|
11247 | message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
|
11248 | `object spread: it will now overwrite an existing non-mergeable attribute ` +
|
11249 | `that appears before v-bind in the case of conflict. ` +
|
11250 | `To retain 2.x behavior, move v-bind to make it the first attribute. ` +
|
11251 | `You can also suppress this warning if the usage is intended.`,
|
11252 | link: `https://v3.vuejs.org/guide/migration/v-bind.html`
|
11253 | },
|
11254 | ["COMPILER_V_ON_NATIVE" ]: {
|
11255 | message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
11256 | link: `https://v3.vuejs.org/guide/migration/v-on-native-modifier-removed.html`
|
11257 | },
|
11258 | ["COMPILER_V_IF_V_FOR_PRECEDENCE" ]: {
|
11259 | message: `v-if / v-for precedence when used on the same element has changed ` +
|
11260 | `in Vue 3: v-if now takes higher precedence and will no longer have ` +
|
11261 | `access to v-for scope variables. It is best to avoid the ambiguity ` +
|
11262 | `with <template> tags or use a computed property that filters v-for ` +
|
11263 | `data source.`,
|
11264 | link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
|
11265 | },
|
11266 | ["COMPILER_V_FOR_REF" ]: {
|
11267 | message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
|
11268 | `Consider using function refs or refactor to avoid ref usage altogether.`,
|
11269 | link: `https://v3.vuejs.org/guide/migration/array-refs.html`
|
11270 | },
|
11271 | ["COMPILER_NATIVE_TEMPLATE" ]: {
|
11272 | message: `<template> with no special directives will render as a native template ` +
|
11273 | `element instead of its inner content in Vue 3.`
|
11274 | },
|
11275 | ["COMPILER_INLINE_TEMPLATE" ]: {
|
11276 | message: `"inline-template" has been removed in Vue 3.`,
|
11277 | link: `https://v3.vuejs.org/guide/migration/inline-template-attribute.html`
|
11278 | },
|
11279 | ["COMPILER_FILTER" ]: {
|
11280 | message: `filters have been removed in Vue 3. ` +
|
11281 | `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
11282 | `Use method calls or computed properties instead.`,
|
11283 | link: `https://v3.vuejs.org/guide/migration/filters.html`
|
11284 | }
|
11285 | };
|
11286 | function getCompatValue(key, context) {
|
11287 | const config = context.options
|
11288 | ? context.options.compatConfig
|
11289 | : context.compatConfig;
|
11290 | const value = config && config[key];
|
11291 | if (key === 'MODE') {
|
11292 | return value || 3;
|
11293 | }
|
11294 | else {
|
11295 | return value;
|
11296 | }
|
11297 | }
|
11298 | function isCompatEnabled(key, context) {
|
11299 | const mode = getCompatValue('MODE', context);
|
11300 | const value = getCompatValue(key, context);
|
11301 |
|
11302 |
|
11303 | return mode === 3 ? value === true : value !== false;
|
11304 | }
|
11305 | function checkCompatEnabled(key, context, loc, ...args) {
|
11306 | const enabled = isCompatEnabled(key, context);
|
11307 | if (enabled) {
|
11308 | warnDeprecation(key, context, loc, ...args);
|
11309 | }
|
11310 | return enabled;
|
11311 | }
|
11312 | function warnDeprecation(key, context, loc, ...args) {
|
11313 | const val = getCompatValue(key, context);
|
11314 | if (val === 'suppress-warning') {
|
11315 | return;
|
11316 | }
|
11317 | const { message, link } = deprecationData[key];
|
11318 | const msg = `(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`;
|
11319 | const err = new SyntaxError(msg);
|
11320 | err.code = key;
|
11321 | if (loc)
|
11322 | err.loc = loc;
|
11323 | context.onWarn(err);
|
11324 | }
|
11325 |
|
11326 |
|
11327 |
|
11328 |
|
11329 | const decodeRE = /&(gt|lt|amp|apos|quot);/g;
|
11330 | const decodeMap = {
|
11331 | gt: '>',
|
11332 | lt: '<',
|
11333 | amp: '&',
|
11334 | apos: "'",
|
11335 | quot: '"'
|
11336 | };
|
11337 | const defaultParserOptions = {
|
11338 | delimiters: [`{{`, `}}`],
|
11339 | getNamespace: () => 0 ,
|
11340 | getTextMode: () => 0 ,
|
11341 | isVoidTag: NO,
|
11342 | isPreTag: NO,
|
11343 | isCustomElement: NO,
|
11344 | decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
|
11345 | onError: defaultOnError,
|
11346 | onWarn: defaultOnWarn,
|
11347 | comments: true
|
11348 | };
|
11349 | function baseParse(content, options = {}) {
|
11350 | const context = createParserContext(content, options);
|
11351 | const start = getCursor(context);
|
11352 | return createRoot(parseChildren(context, 0 , []), getSelection(context, start));
|
11353 | }
|
11354 | function createParserContext(content, rawOptions) {
|
11355 | const options = extend({}, defaultParserOptions);
|
11356 | let key;
|
11357 | for (key in rawOptions) {
|
11358 |
|
11359 | options[key] =
|
11360 | rawOptions[key] === undefined
|
11361 | ? defaultParserOptions[key]
|
11362 | : rawOptions[key];
|
11363 | }
|
11364 | return {
|
11365 | options,
|
11366 | column: 1,
|
11367 | line: 1,
|
11368 | offset: 0,
|
11369 | originalSource: content,
|
11370 | source: content,
|
11371 | inPre: false,
|
11372 | inVPre: false,
|
11373 | onWarn: options.onWarn
|
11374 | };
|
11375 | }
|
11376 | function parseChildren(context, mode, ancestors) {
|
11377 | const parent = last(ancestors);
|
11378 | const ns = parent ? parent.ns : 0 ;
|
11379 | const nodes = [];
|
11380 | while (!isEnd(context, mode, ancestors)) {
|
11381 | const s = context.source;
|
11382 | let node = undefined;
|
11383 | if (mode === 0 || mode === 1 ) {
|
11384 | if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
|
11385 |
|
11386 | node = parseInterpolation(context, mode);
|
11387 | }
|
11388 | else if (mode === 0 && s[0] === '<') {
|
11389 |
|
11390 | if (s.length === 1) {
|
11391 | emitError(context, 5 , 1);
|
11392 | }
|
11393 | else if (s[1] === '!') {
|
11394 |
|
11395 | if (startsWith(s, '<!--')) {
|
11396 | node = parseComment(context);
|
11397 | }
|
11398 | else if (startsWith(s, '<!DOCTYPE')) {
|
11399 |
|
11400 | node = parseBogusComment(context);
|
11401 | }
|
11402 | else if (startsWith(s, '<![CDATA[')) {
|
11403 | if (ns !== 0 ) {
|
11404 | node = parseCDATA(context, ancestors);
|
11405 | }
|
11406 | else {
|
11407 | emitError(context, 1 );
|
11408 | node = parseBogusComment(context);
|
11409 | }
|
11410 | }
|
11411 | else {
|
11412 | emitError(context, 11 );
|
11413 | node = parseBogusComment(context);
|
11414 | }
|
11415 | }
|
11416 | else if (s[1] === '/') {
|
11417 |
|
11418 | if (s.length === 2) {
|
11419 | emitError(context, 5 , 2);
|
11420 | }
|
11421 | else if (s[2] === '>') {
|
11422 | emitError(context, 14 , 2);
|
11423 | advanceBy(context, 3);
|
11424 | continue;
|
11425 | }
|
11426 | else if (/[a-z]/i.test(s[2])) {
|
11427 | emitError(context, 23 );
|
11428 | parseTag(context, 1 , parent);
|
11429 | continue;
|
11430 | }
|
11431 | else {
|
11432 | emitError(context, 12 , 2);
|
11433 | node = parseBogusComment(context);
|
11434 | }
|
11435 | }
|
11436 | else if (/[a-z]/i.test(s[1])) {
|
11437 | node = parseElement(context, ancestors);
|
11438 | }
|
11439 | else if (s[1] === '?') {
|
11440 | emitError(context, 21 , 1);
|
11441 | node = parseBogusComment(context);
|
11442 | }
|
11443 | else {
|
11444 | emitError(context, 12 , 1);
|
11445 | }
|
11446 | }
|
11447 | }
|
11448 | if (!node) {
|
11449 | node = parseText(context, mode);
|
11450 | }
|
11451 | if (isArray(node)) {
|
11452 | for (let i = 0; i < node.length; i++) {
|
11453 | pushNode(nodes, node[i]);
|
11454 | }
|
11455 | }
|
11456 | else {
|
11457 | pushNode(nodes, node);
|
11458 | }
|
11459 | }
|
11460 |
|
11461 | let removedWhitespace = false;
|
11462 | if (mode !== 2 && mode !== 1 ) {
|
11463 | const shouldCondense = context.options.whitespace !== 'preserve';
|
11464 | for (let i = 0; i < nodes.length; i++) {
|
11465 | const node = nodes[i];
|
11466 | if (!context.inPre && node.type === 2 ) {
|
11467 | if (!/[^\t\r\n\f ]/.test(node.content)) {
|
11468 | const prev = nodes[i - 1];
|
11469 | const next = nodes[i + 1];
|
11470 |
|
11471 |
|
11472 |
|
11473 |
|
11474 | if (!prev ||
|
11475 | !next ||
|
11476 | (shouldCondense &&
|
11477 | (prev.type === 3 ||
|
11478 | next.type === 3 ||
|
11479 | (prev.type === 1 &&
|
11480 | next.type === 1 &&
|
11481 | /[\r\n]/.test(node.content))))) {
|
11482 | removedWhitespace = true;
|
11483 | nodes[i] = null;
|
11484 | }
|
11485 | else {
|
11486 |
|
11487 | node.content = ' ';
|
11488 | }
|
11489 | }
|
11490 | else if (shouldCondense) {
|
11491 |
|
11492 |
|
11493 | node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
|
11494 | }
|
11495 | }
|
11496 |
|
11497 | else if (node.type === 3 && !context.options.comments) {
|
11498 | removedWhitespace = true;
|
11499 | nodes[i] = null;
|
11500 | }
|
11501 | }
|
11502 | if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
|
11503 |
|
11504 |
|
11505 | const first = nodes[0];
|
11506 | if (first && first.type === 2 ) {
|
11507 | first.content = first.content.replace(/^\r?\n/, '');
|
11508 | }
|
11509 | }
|
11510 | }
|
11511 | return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
11512 | }
|
11513 | function pushNode(nodes, node) {
|
11514 | if (node.type === 2 ) {
|
11515 | const prev = last(nodes);
|
11516 |
|
11517 |
|
11518 | if (prev &&
|
11519 | prev.type === 2 &&
|
11520 | prev.loc.end.offset === node.loc.start.offset) {
|
11521 | prev.content += node.content;
|
11522 | prev.loc.end = node.loc.end;
|
11523 | prev.loc.source += node.loc.source;
|
11524 | return;
|
11525 | }
|
11526 | }
|
11527 | nodes.push(node);
|
11528 | }
|
11529 | function parseCDATA(context, ancestors) {
|
11530 | advanceBy(context, 9);
|
11531 | const nodes = parseChildren(context, 3 , ancestors);
|
11532 | if (context.source.length === 0) {
|
11533 | emitError(context, 6 );
|
11534 | }
|
11535 | else {
|
11536 | advanceBy(context, 3);
|
11537 | }
|
11538 | return nodes;
|
11539 | }
|
11540 | function parseComment(context) {
|
11541 | const start = getCursor(context);
|
11542 | let content;
|
11543 |
|
11544 | const match = /--(\!)?>/.exec(context.source);
|
11545 | if (!match) {
|
11546 | content = context.source.slice(4);
|
11547 | advanceBy(context, context.source.length);
|
11548 | emitError(context, 7 );
|
11549 | }
|
11550 | else {
|
11551 | if (match.index <= 3) {
|
11552 | emitError(context, 0 );
|
11553 | }
|
11554 | if (match[1]) {
|
11555 | emitError(context, 10 );
|
11556 | }
|
11557 | content = context.source.slice(4, match.index);
|
11558 |
|
11559 | const s = context.source.slice(0, match.index);
|
11560 | let prevIndex = 1, nestedIndex = 0;
|
11561 | while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
|
11562 | advanceBy(context, nestedIndex - prevIndex + 1);
|
11563 | if (nestedIndex + 4 < s.length) {
|
11564 | emitError(context, 16 );
|
11565 | }
|
11566 | prevIndex = nestedIndex + 1;
|
11567 | }
|
11568 | advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
11569 | }
|
11570 | return {
|
11571 | type: 3 ,
|
11572 | content,
|
11573 | loc: getSelection(context, start)
|
11574 | };
|
11575 | }
|
11576 | function parseBogusComment(context) {
|
11577 | const start = getCursor(context);
|
11578 | const contentStart = context.source[1] === '?' ? 1 : 2;
|
11579 | let content;
|
11580 | const closeIndex = context.source.indexOf('>');
|
11581 | if (closeIndex === -1) {
|
11582 | content = context.source.slice(contentStart);
|
11583 | advanceBy(context, context.source.length);
|
11584 | }
|
11585 | else {
|
11586 | content = context.source.slice(contentStart, closeIndex);
|
11587 | advanceBy(context, closeIndex + 1);
|
11588 | }
|
11589 | return {
|
11590 | type: 3 ,
|
11591 | content,
|
11592 | loc: getSelection(context, start)
|
11593 | };
|
11594 | }
|
11595 | function parseElement(context, ancestors) {
|
11596 |
|
11597 | const wasInPre = context.inPre;
|
11598 | const wasInVPre = context.inVPre;
|
11599 | const parent = last(ancestors);
|
11600 | const element = parseTag(context, 0 , parent);
|
11601 | const isPreBoundary = context.inPre && !wasInPre;
|
11602 | const isVPreBoundary = context.inVPre && !wasInVPre;
|
11603 | if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
11604 |
|
11605 | if (isPreBoundary) {
|
11606 | context.inPre = false;
|
11607 | }
|
11608 | if (isVPreBoundary) {
|
11609 | context.inVPre = false;
|
11610 | }
|
11611 | return element;
|
11612 | }
|
11613 |
|
11614 | ancestors.push(element);
|
11615 | const mode = context.options.getTextMode(element, parent);
|
11616 | const children = parseChildren(context, mode, ancestors);
|
11617 | ancestors.pop();
|
11618 | element.children = children;
|
11619 |
|
11620 | if (startsWithEndTagOpen(context.source, element.tag)) {
|
11621 | parseTag(context, 1 , parent);
|
11622 | }
|
11623 | else {
|
11624 | emitError(context, 24 , 0, element.loc.start);
|
11625 | if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
|
11626 | const first = children[0];
|
11627 | if (first && startsWith(first.loc.source, '<!--')) {
|
11628 | emitError(context, 8 );
|
11629 | }
|
11630 | }
|
11631 | }
|
11632 | element.loc = getSelection(context, element.loc.start);
|
11633 | if (isPreBoundary) {
|
11634 | context.inPre = false;
|
11635 | }
|
11636 | if (isVPreBoundary) {
|
11637 | context.inVPre = false;
|
11638 | }
|
11639 | return element;
|
11640 | }
|
11641 | const isSpecialTemplateDirective = makeMap(`if,else,else-if,for,slot`);
|
11642 | function parseTag(context, type, parent) {
|
11643 |
|
11644 | const start = getCursor(context);
|
11645 | const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
|
11646 | const tag = match[1];
|
11647 | const ns = context.options.getNamespace(tag, parent);
|
11648 | advanceBy(context, match[0].length);
|
11649 | advanceSpaces(context);
|
11650 |
|
11651 | const cursor = getCursor(context);
|
11652 | const currentSource = context.source;
|
11653 |
|
11654 | if (context.options.isPreTag(tag)) {
|
11655 | context.inPre = true;
|
11656 | }
|
11657 |
|
11658 | let props = parseAttributes(context, type);
|
11659 |
|
11660 | if (type === 0 &&
|
11661 | !context.inVPre &&
|
11662 | props.some(p => p.type === 7 && p.name === 'pre')) {
|
11663 | context.inVPre = true;
|
11664 |
|
11665 | extend(context, cursor);
|
11666 | context.source = currentSource;
|
11667 |
|
11668 | props = parseAttributes(context, type).filter(p => p.name !== 'v-pre');
|
11669 | }
|
11670 |
|
11671 | let isSelfClosing = false;
|
11672 | if (context.source.length === 0) {
|
11673 | emitError(context, 9 );
|
11674 | }
|
11675 | else {
|
11676 | isSelfClosing = startsWith(context.source, '/>');
|
11677 | if (type === 1 && isSelfClosing) {
|
11678 | emitError(context, 4 );
|
11679 | }
|
11680 | advanceBy(context, isSelfClosing ? 2 : 1);
|
11681 | }
|
11682 | if (type === 1 ) {
|
11683 | return;
|
11684 | }
|
11685 | let tagType = 0 ;
|
11686 | if (!context.inVPre) {
|
11687 | if (tag === 'slot') {
|
11688 | tagType = 2 ;
|
11689 | }
|
11690 | else if (tag === 'template') {
|
11691 | if (props.some(p => p.type === 7 && isSpecialTemplateDirective(p.name))) {
|
11692 | tagType = 3 ;
|
11693 | }
|
11694 | }
|
11695 | else if (isComponent(tag, props, context)) {
|
11696 | tagType = 1 ;
|
11697 | }
|
11698 | }
|
11699 | return {
|
11700 | type: 1 ,
|
11701 | ns,
|
11702 | tag,
|
11703 | tagType,
|
11704 | props,
|
11705 | isSelfClosing,
|
11706 | children: [],
|
11707 | loc: getSelection(context, start),
|
11708 | codegenNode: undefined
|
11709 | };
|
11710 | }
|
11711 | function isComponent(tag, props, context) {
|
11712 | const options = context.options;
|
11713 | if (options.isCustomElement(tag)) {
|
11714 | return false;
|
11715 | }
|
11716 | if (tag === 'component' ||
|
11717 | /^[A-Z]/.test(tag) ||
|
11718 | isCoreComponent(tag) ||
|
11719 | (options.isBuiltInComponent && options.isBuiltInComponent(tag)) ||
|
11720 | (options.isNativeTag && !options.isNativeTag(tag))) {
|
11721 | return true;
|
11722 | }
|
11723 |
|
11724 |
|
11725 | for (let i = 0; i < props.length; i++) {
|
11726 | const p = props[i];
|
11727 | if (p.type === 6 ) {
|
11728 | if (p.name === 'is' && p.value) {
|
11729 | if (p.value.content.startsWith('vue:')) {
|
11730 | return true;
|
11731 | }
|
11732 | }
|
11733 | }
|
11734 | else {
|
11735 |
|
11736 |
|
11737 | if (p.name === 'is') {
|
11738 | return true;
|
11739 | }
|
11740 | else if (
|
11741 |
|
11742 | p.name === 'bind' &&
|
11743 | isBindKey(p.arg, 'is') &&
|
11744 | false &&
|
11745 | checkCompatEnabled("COMPILER_IS_ON_ELEMENT" , context, p.loc)) {
|
11746 | return true;
|
11747 | }
|
11748 | }
|
11749 | }
|
11750 | }
|
11751 | function parseAttributes(context, type) {
|
11752 | const props = [];
|
11753 | const attributeNames = new Set();
|
11754 | while (context.source.length > 0 &&
|
11755 | !startsWith(context.source, '>') &&
|
11756 | !startsWith(context.source, '/>')) {
|
11757 | if (startsWith(context.source, '/')) {
|
11758 | emitError(context, 22 );
|
11759 | advanceBy(context, 1);
|
11760 | advanceSpaces(context);
|
11761 | continue;
|
11762 | }
|
11763 | if (type === 1 ) {
|
11764 | emitError(context, 3 );
|
11765 | }
|
11766 | const attr = parseAttribute(context, attributeNames);
|
11767 |
|
11768 |
|
11769 | if (attr.type === 6 &&
|
11770 | attr.value &&
|
11771 | attr.name === 'class') {
|
11772 | attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
|
11773 | }
|
11774 | if (type === 0 ) {
|
11775 | props.push(attr);
|
11776 | }
|
11777 | if (/^[^\t\r\n\f />]/.test(context.source)) {
|
11778 | emitError(context, 15 );
|
11779 | }
|
11780 | advanceSpaces(context);
|
11781 | }
|
11782 | return props;
|
11783 | }
|
11784 | function parseAttribute(context, nameSet) {
|
11785 |
|
11786 | const start = getCursor(context);
|
11787 | const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
|
11788 | const name = match[0];
|
11789 | if (nameSet.has(name)) {
|
11790 | emitError(context, 2 );
|
11791 | }
|
11792 | nameSet.add(name);
|
11793 | if (name[0] === '=') {
|
11794 | emitError(context, 19 );
|
11795 | }
|
11796 | {
|
11797 | const pattern = /["'<]/g;
|
11798 | let m;
|
11799 | while ((m = pattern.exec(name))) {
|
11800 | emitError(context, 17 , m.index);
|
11801 | }
|
11802 | }
|
11803 | advanceBy(context, name.length);
|
11804 |
|
11805 | let value = undefined;
|
11806 | if (/^[\t\r\n\f ]*=/.test(context.source)) {
|
11807 | advanceSpaces(context);
|
11808 | advanceBy(context, 1);
|
11809 | advanceSpaces(context);
|
11810 | value = parseAttributeValue(context);
|
11811 | if (!value) {
|
11812 | emitError(context, 13 );
|
11813 | }
|
11814 | }
|
11815 | const loc = getSelection(context, start);
|
11816 | if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
|
11817 | const match = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(name);
|
11818 | let isPropShorthand = startsWith(name, '.');
|
11819 | let dirName = match[1] ||
|
11820 | (isPropShorthand || startsWith(name, ':')
|
11821 | ? 'bind'
|
11822 | : startsWith(name, '@')
|
11823 | ? 'on'
|
11824 | : 'slot');
|
11825 | let arg;
|
11826 | if (match[2]) {
|
11827 | const isSlot = dirName === 'slot';
|
11828 | const startOffset = name.lastIndexOf(match[2]);
|
11829 | const loc = getSelection(context, getNewPosition(context, start, startOffset), getNewPosition(context, start, startOffset + match[2].length + ((isSlot && match[3]) || '').length));
|
11830 | let content = match[2];
|
11831 | let isStatic = true;
|
11832 | if (content.startsWith('[')) {
|
11833 | isStatic = false;
|
11834 | if (!content.endsWith(']')) {
|
11835 | emitError(context, 27 );
|
11836 | content = content.substr(1);
|
11837 | }
|
11838 | else {
|
11839 | content = content.substr(1, content.length - 2);
|
11840 | }
|
11841 | }
|
11842 | else if (isSlot) {
|
11843 |
|
11844 |
|
11845 |
|
11846 | content += match[3] || '';
|
11847 | }
|
11848 | arg = {
|
11849 | type: 4 ,
|
11850 | content,
|
11851 | isStatic,
|
11852 | constType: isStatic
|
11853 | ? 3
|
11854 | : 0 ,
|
11855 | loc
|
11856 | };
|
11857 | }
|
11858 | if (value && value.isQuoted) {
|
11859 | const valueLoc = value.loc;
|
11860 | valueLoc.start.offset++;
|
11861 | valueLoc.start.column++;
|
11862 | valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
11863 | valueLoc.source = valueLoc.source.slice(1, -1);
|
11864 | }
|
11865 | const modifiers = match[3] ? match[3].substr(1).split('.') : [];
|
11866 | if (isPropShorthand)
|
11867 | modifiers.push('prop');
|
11868 | return {
|
11869 | type: 7 ,
|
11870 | name: dirName,
|
11871 | exp: value && {
|
11872 | type: 4 ,
|
11873 | content: value.content,
|
11874 | isStatic: false,
|
11875 |
|
11876 |
|
11877 | constType: 0 ,
|
11878 | loc: value.loc
|
11879 | },
|
11880 | arg,
|
11881 | modifiers,
|
11882 | loc
|
11883 | };
|
11884 | }
|
11885 |
|
11886 | if (!context.inVPre && startsWith(name, 'v-')) {
|
11887 | emitError(context, 26 );
|
11888 | }
|
11889 | return {
|
11890 | type: 6 ,
|
11891 | name,
|
11892 | value: value && {
|
11893 | type: 2 ,
|
11894 | content: value.content,
|
11895 | loc: value.loc
|
11896 | },
|
11897 | loc
|
11898 | };
|
11899 | }
|
11900 | function parseAttributeValue(context) {
|
11901 | const start = getCursor(context);
|
11902 | let content;
|
11903 | const quote = context.source[0];
|
11904 | const isQuoted = quote === `"` || quote === `'`;
|
11905 | if (isQuoted) {
|
11906 |
|
11907 | advanceBy(context, 1);
|
11908 | const endIndex = context.source.indexOf(quote);
|
11909 | if (endIndex === -1) {
|
11910 | content = parseTextData(context, context.source.length, 4 );
|
11911 | }
|
11912 | else {
|
11913 | content = parseTextData(context, endIndex, 4 );
|
11914 | advanceBy(context, 1);
|
11915 | }
|
11916 | }
|
11917 | else {
|
11918 |
|
11919 | const match = /^[^\t\r\n\f >]+/.exec(context.source);
|
11920 | if (!match) {
|
11921 | return undefined;
|
11922 | }
|
11923 | const unexpectedChars = /["'<=`]/g;
|
11924 | let m;
|
11925 | while ((m = unexpectedChars.exec(match[0]))) {
|
11926 | emitError(context, 18 , m.index);
|
11927 | }
|
11928 | content = parseTextData(context, match[0].length, 4 );
|
11929 | }
|
11930 | return { content, isQuoted, loc: getSelection(context, start) };
|
11931 | }
|
11932 | function parseInterpolation(context, mode) {
|
11933 | const [open, close] = context.options.delimiters;
|
11934 | const closeIndex = context.source.indexOf(close, open.length);
|
11935 | if (closeIndex === -1) {
|
11936 | emitError(context, 25 );
|
11937 | return undefined;
|
11938 | }
|
11939 | const start = getCursor(context);
|
11940 | advanceBy(context, open.length);
|
11941 | const innerStart = getCursor(context);
|
11942 | const innerEnd = getCursor(context);
|
11943 | const rawContentLength = closeIndex - open.length;
|
11944 | const rawContent = context.source.slice(0, rawContentLength);
|
11945 | const preTrimContent = parseTextData(context, rawContentLength, mode);
|
11946 | const content = preTrimContent.trim();
|
11947 | const startOffset = preTrimContent.indexOf(content);
|
11948 | if (startOffset > 0) {
|
11949 | advancePositionWithMutation(innerStart, rawContent, startOffset);
|
11950 | }
|
11951 | const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
|
11952 | advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
11953 | advanceBy(context, close.length);
|
11954 | return {
|
11955 | type: 5 ,
|
11956 | content: {
|
11957 | type: 4 ,
|
11958 | isStatic: false,
|
11959 |
|
11960 | constType: 0 ,
|
11961 | content,
|
11962 | loc: getSelection(context, innerStart, innerEnd)
|
11963 | },
|
11964 | loc: getSelection(context, start)
|
11965 | };
|
11966 | }
|
11967 | function parseText(context, mode) {
|
11968 | const endTokens = mode === 3 ? [']]>'] : ['<', context.options.delimiters[0]];
|
11969 | let endIndex = context.source.length;
|
11970 | for (let i = 0; i < endTokens.length; i++) {
|
11971 | const index = context.source.indexOf(endTokens[i], 1);
|
11972 | if (index !== -1 && endIndex > index) {
|
11973 | endIndex = index;
|
11974 | }
|
11975 | }
|
11976 | const start = getCursor(context);
|
11977 | const content = parseTextData(context, endIndex, mode);
|
11978 | return {
|
11979 | type: 2 ,
|
11980 | content,
|
11981 | loc: getSelection(context, start)
|
11982 | };
|
11983 | }
|
11984 | |
11985 |
|
11986 |
|
11987 |
|
11988 | function parseTextData(context, length, mode) {
|
11989 | const rawText = context.source.slice(0, length);
|
11990 | advanceBy(context, length);
|
11991 | if (mode === 2 ||
|
11992 | mode === 3 ||
|
11993 | rawText.indexOf('&') === -1) {
|
11994 | return rawText;
|
11995 | }
|
11996 | else {
|
11997 |
|
11998 | return context.options.decodeEntities(rawText, mode === 4 );
|
11999 | }
|
12000 | }
|
12001 | function getCursor(context) {
|
12002 | const { column, line, offset } = context;
|
12003 | return { column, line, offset };
|
12004 | }
|
12005 | function getSelection(context, start, end) {
|
12006 | end = end || getCursor(context);
|
12007 | return {
|
12008 | start,
|
12009 | end,
|
12010 | source: context.originalSource.slice(start.offset, end.offset)
|
12011 | };
|
12012 | }
|
12013 | function last(xs) {
|
12014 | return xs[xs.length - 1];
|
12015 | }
|
12016 | function startsWith(source, searchString) {
|
12017 | return source.startsWith(searchString);
|
12018 | }
|
12019 | function advanceBy(context, numberOfCharacters) {
|
12020 | const { source } = context;
|
12021 | advancePositionWithMutation(context, source, numberOfCharacters);
|
12022 | context.source = source.slice(numberOfCharacters);
|
12023 | }
|
12024 | function advanceSpaces(context) {
|
12025 | const match = /^[\t\r\n\f ]+/.exec(context.source);
|
12026 | if (match) {
|
12027 | advanceBy(context, match[0].length);
|
12028 | }
|
12029 | }
|
12030 | function getNewPosition(context, start, numberOfCharacters) {
|
12031 | return advancePositionWithClone(start, context.originalSource.slice(start.offset, numberOfCharacters), numberOfCharacters);
|
12032 | }
|
12033 | function emitError(context, code, offset, loc = getCursor(context)) {
|
12034 | if (offset) {
|
12035 | loc.offset += offset;
|
12036 | loc.column += offset;
|
12037 | }
|
12038 | context.options.onError(createCompilerError(code, {
|
12039 | start: loc,
|
12040 | end: loc,
|
12041 | source: ''
|
12042 | }));
|
12043 | }
|
12044 | function isEnd(context, mode, ancestors) {
|
12045 | const s = context.source;
|
12046 | switch (mode) {
|
12047 | case 0 :
|
12048 | if (startsWith(s, '</')) {
|
12049 |
|
12050 | for (let i = ancestors.length - 1; i >= 0; --i) {
|
12051 | if (startsWithEndTagOpen(s, ancestors[i].tag)) {
|
12052 | return true;
|
12053 | }
|
12054 | }
|
12055 | }
|
12056 | break;
|
12057 | case 1 :
|
12058 | case 2 : {
|
12059 | const parent = last(ancestors);
|
12060 | if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
12061 | return true;
|
12062 | }
|
12063 | break;
|
12064 | }
|
12065 | case 3 :
|
12066 | if (startsWith(s, ']]>')) {
|
12067 | return true;
|
12068 | }
|
12069 | break;
|
12070 | }
|
12071 | return !s;
|
12072 | }
|
12073 | function startsWithEndTagOpen(source, tag) {
|
12074 | return (startsWith(source, '</') &&
|
12075 | source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
|
12076 | /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
|
12077 | }
|
12078 |
|
12079 | function hoistStatic(root, context) {
|
12080 | walk(root, context,
|
12081 |
|
12082 |
|
12083 | isSingleElementRoot(root, root.children[0]));
|
12084 | }
|
12085 | function isSingleElementRoot(root, child) {
|
12086 | const { children } = root;
|
12087 | return (children.length === 1 &&
|
12088 | child.type === 1 &&
|
12089 | !isSlotOutlet(child));
|
12090 | }
|
12091 | function walk(node, context, doNotHoistNode = false) {
|
12092 |
|
12093 |
|
12094 |
|
12095 |
|
12096 |
|
12097 |
|
12098 |
|
12099 |
|
12100 | let canStringify = true;
|
12101 | const { children } = node;
|
12102 | const originalCount = children.length;
|
12103 | let hoistedCount = 0;
|
12104 | for (let i = 0; i < children.length; i++) {
|
12105 | const child = children[i];
|
12106 |
|
12107 | if (child.type === 1 &&
|
12108 | child.tagType === 0 ) {
|
12109 | const constantType = doNotHoistNode
|
12110 | ? 0
|
12111 | : getConstantType(child, context);
|
12112 | if (constantType > 0 ) {
|
12113 | if (constantType < 3 ) {
|
12114 | canStringify = false;
|
12115 | }
|
12116 | if (constantType >= 2 ) {
|
12117 | child.codegenNode.patchFlag =
|
12118 | -1 + (` /* HOISTED */` );
|
12119 | child.codegenNode = context.hoist(child.codegenNode);
|
12120 | hoistedCount++;
|
12121 | continue;
|
12122 | }
|
12123 | }
|
12124 | else {
|
12125 |
|
12126 |
|
12127 | const codegenNode = child.codegenNode;
|
12128 | if (codegenNode.type === 13 ) {
|
12129 | const flag = getPatchFlag(codegenNode);
|
12130 | if ((!flag ||
|
12131 | flag === 512 ||
|
12132 | flag === 1 ) &&
|
12133 | getGeneratedPropsConstantType(child, context) >=
|
12134 | 2 ) {
|
12135 | const props = getNodeProps(child);
|
12136 | if (props) {
|
12137 | codegenNode.props = context.hoist(props);
|
12138 | }
|
12139 | }
|
12140 | if (codegenNode.dynamicProps) {
|
12141 | codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
|
12142 | }
|
12143 | }
|
12144 | }
|
12145 | }
|
12146 | else if (child.type === 12 ) {
|
12147 | const contentType = getConstantType(child.content, context);
|
12148 | if (contentType > 0) {
|
12149 | if (contentType < 3 ) {
|
12150 | canStringify = false;
|
12151 | }
|
12152 | if (contentType >= 2 ) {
|
12153 | child.codegenNode = context.hoist(child.codegenNode);
|
12154 | hoistedCount++;
|
12155 | }
|
12156 | }
|
12157 | }
|
12158 |
|
12159 | if (child.type === 1 ) {
|
12160 | const isComponent = child.tagType === 1 ;
|
12161 | if (isComponent) {
|
12162 | context.scopes.vSlot++;
|
12163 | }
|
12164 | walk(child, context);
|
12165 | if (isComponent) {
|
12166 | context.scopes.vSlot--;
|
12167 | }
|
12168 | }
|
12169 | else if (child.type === 11 ) {
|
12170 |
|
12171 | walk(child, context, child.children.length === 1);
|
12172 | }
|
12173 | else if (child.type === 9 ) {
|
12174 | for (let i = 0; i < child.branches.length; i++) {
|
12175 |
|
12176 | walk(child.branches[i], context, child.branches[i].children.length === 1);
|
12177 | }
|
12178 | }
|
12179 | }
|
12180 | if (canStringify && hoistedCount && context.transformHoist) {
|
12181 | context.transformHoist(children, context, node);
|
12182 | }
|
12183 |
|
12184 | if (hoistedCount &&
|
12185 | hoistedCount === originalCount &&
|
12186 | node.type === 1 &&
|
12187 | node.tagType === 0 &&
|
12188 | node.codegenNode &&
|
12189 | node.codegenNode.type === 13 &&
|
12190 | isArray(node.codegenNode.children)) {
|
12191 | node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
|
12192 | }
|
12193 | }
|
12194 | function getConstantType(node, context) {
|
12195 | const { constantCache } = context;
|
12196 | switch (node.type) {
|
12197 | case 1 :
|
12198 | if (node.tagType !== 0 ) {
|
12199 | return 0 ;
|
12200 | }
|
12201 | const cached = constantCache.get(node);
|
12202 | if (cached !== undefined) {
|
12203 | return cached;
|
12204 | }
|
12205 | const codegenNode = node.codegenNode;
|
12206 | if (codegenNode.type !== 13 ) {
|
12207 | return 0 ;
|
12208 | }
|
12209 | const flag = getPatchFlag(codegenNode);
|
12210 | if (!flag) {
|
12211 | let returnType = 3 ;
|
12212 |
|
12213 |
|
12214 |
|
12215 |
|
12216 |
|
12217 | const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
12218 | if (generatedPropsType === 0 ) {
|
12219 | constantCache.set(node, 0 );
|
12220 | return 0 ;
|
12221 | }
|
12222 | if (generatedPropsType < returnType) {
|
12223 | returnType = generatedPropsType;
|
12224 | }
|
12225 |
|
12226 | for (let i = 0; i < node.children.length; i++) {
|
12227 | const childType = getConstantType(node.children[i], context);
|
12228 | if (childType === 0 ) {
|
12229 | constantCache.set(node, 0 );
|
12230 | return 0 ;
|
12231 | }
|
12232 | if (childType < returnType) {
|
12233 | returnType = childType;
|
12234 | }
|
12235 | }
|
12236 |
|
12237 |
|
12238 |
|
12239 |
|
12240 | if (returnType > 1 ) {
|
12241 | for (let i = 0; i < node.props.length; i++) {
|
12242 | const p = node.props[i];
|
12243 | if (p.type === 7 && p.name === 'bind' && p.exp) {
|
12244 | const expType = getConstantType(p.exp, context);
|
12245 | if (expType === 0 ) {
|
12246 | constantCache.set(node, 0 );
|
12247 | return 0 ;
|
12248 | }
|
12249 | if (expType < returnType) {
|
12250 | returnType = expType;
|
12251 | }
|
12252 | }
|
12253 | }
|
12254 | }
|
12255 |
|
12256 |
|
12257 |
|
12258 | if (codegenNode.isBlock) {
|
12259 | context.removeHelper(OPEN_BLOCK);
|
12260 | context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
|
12261 | codegenNode.isBlock = false;
|
12262 | context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
|
12263 | }
|
12264 | constantCache.set(node, returnType);
|
12265 | return returnType;
|
12266 | }
|
12267 | else {
|
12268 | constantCache.set(node, 0 );
|
12269 | return 0 ;
|
12270 | }
|
12271 | case 2 :
|
12272 | case 3 :
|
12273 | return 3 ;
|
12274 | case 9 :
|
12275 | case 11 :
|
12276 | case 10 :
|
12277 | return 0 ;
|
12278 | case 5 :
|
12279 | case 12 :
|
12280 | return getConstantType(node.content, context);
|
12281 | case 4 :
|
12282 | return node.constType;
|
12283 | case 8 :
|
12284 | let returnType = 3 ;
|
12285 | for (let i = 0; i < node.children.length; i++) {
|
12286 | const child = node.children[i];
|
12287 | if (isString(child) || isSymbol(child)) {
|
12288 | continue;
|
12289 | }
|
12290 | const childType = getConstantType(child, context);
|
12291 | if (childType === 0 ) {
|
12292 | return 0 ;
|
12293 | }
|
12294 | else if (childType < returnType) {
|
12295 | returnType = childType;
|
12296 | }
|
12297 | }
|
12298 | return returnType;
|
12299 | default:
|
12300 | return 0 ;
|
12301 | }
|
12302 | }
|
12303 | const allowHoistedHelperSet = new Set([
|
12304 | NORMALIZE_CLASS,
|
12305 | NORMALIZE_STYLE,
|
12306 | NORMALIZE_PROPS,
|
12307 | GUARD_REACTIVE_PROPS
|
12308 | ]);
|
12309 | function getConstantTypeOfHelperCall(value, context) {
|
12310 | if (value.type === 14 &&
|
12311 | !isString(value.callee) &&
|
12312 | allowHoistedHelperSet.has(value.callee)) {
|
12313 | const arg = value.arguments[0];
|
12314 | if (arg.type === 4 ) {
|
12315 | return getConstantType(arg, context);
|
12316 | }
|
12317 | else if (arg.type === 14 ) {
|
12318 |
|
12319 | return getConstantTypeOfHelperCall(arg, context);
|
12320 | }
|
12321 | }
|
12322 | return 0 ;
|
12323 | }
|
12324 | function getGeneratedPropsConstantType(node, context) {
|
12325 | let returnType = 3 ;
|
12326 | const props = getNodeProps(node);
|
12327 | if (props && props.type === 15 ) {
|
12328 | const { properties } = props;
|
12329 | for (let i = 0; i < properties.length; i++) {
|
12330 | const { key, value } = properties[i];
|
12331 | const keyType = getConstantType(key, context);
|
12332 | if (keyType === 0 ) {
|
12333 | return keyType;
|
12334 | }
|
12335 | if (keyType < returnType) {
|
12336 | returnType = keyType;
|
12337 | }
|
12338 | let valueType;
|
12339 | if (value.type === 4 ) {
|
12340 | valueType = getConstantType(value, context);
|
12341 | }
|
12342 | else if (value.type === 14 ) {
|
12343 |
|
12344 |
|
12345 |
|
12346 | valueType = getConstantTypeOfHelperCall(value, context);
|
12347 | }
|
12348 | else {
|
12349 | valueType = 0 ;
|
12350 | }
|
12351 | if (valueType === 0 ) {
|
12352 | return valueType;
|
12353 | }
|
12354 | if (valueType < returnType) {
|
12355 | returnType = valueType;
|
12356 | }
|
12357 | }
|
12358 | }
|
12359 | return returnType;
|
12360 | }
|
12361 | function getNodeProps(node) {
|
12362 | const codegenNode = node.codegenNode;
|
12363 | if (codegenNode.type === 13 ) {
|
12364 | return codegenNode.props;
|
12365 | }
|
12366 | }
|
12367 | function getPatchFlag(node) {
|
12368 | const flag = node.patchFlag;
|
12369 | return flag ? parseInt(flag, 10) : undefined;
|
12370 | }
|
12371 |
|
12372 | 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 }) {
|
12373 | const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/);
|
12374 | const context = {
|
12375 |
|
12376 | selfName: nameMatch && capitalize(camelize(nameMatch[1])),
|
12377 | prefixIdentifiers,
|
12378 | hoistStatic,
|
12379 | cacheHandlers,
|
12380 | nodeTransforms,
|
12381 | directiveTransforms,
|
12382 | transformHoist,
|
12383 | isBuiltInComponent,
|
12384 | isCustomElement,
|
12385 | expressionPlugins,
|
12386 | scopeId,
|
12387 | slotted,
|
12388 | ssr,
|
12389 | inSSR,
|
12390 | ssrCssVars,
|
12391 | bindingMetadata,
|
12392 | inline,
|
12393 | isTS,
|
12394 | onError,
|
12395 | onWarn,
|
12396 | compatConfig,
|
12397 |
|
12398 | root,
|
12399 | helpers: new Map(),
|
12400 | components: new Set(),
|
12401 | directives: new Set(),
|
12402 | hoists: [],
|
12403 | imports: [],
|
12404 | constantCache: new Map(),
|
12405 | temps: 0,
|
12406 | cached: 0,
|
12407 | identifiers: Object.create(null),
|
12408 | scopes: {
|
12409 | vFor: 0,
|
12410 | vSlot: 0,
|
12411 | vPre: 0,
|
12412 | vOnce: 0
|
12413 | },
|
12414 | parent: null,
|
12415 | currentNode: root,
|
12416 | childIndex: 0,
|
12417 | inVOnce: false,
|
12418 |
|
12419 | helper(name) {
|
12420 | const count = context.helpers.get(name) || 0;
|
12421 | context.helpers.set(name, count + 1);
|
12422 | return name;
|
12423 | },
|
12424 | removeHelper(name) {
|
12425 | const count = context.helpers.get(name);
|
12426 | if (count) {
|
12427 | const currentCount = count - 1;
|
12428 | if (!currentCount) {
|
12429 | context.helpers.delete(name);
|
12430 | }
|
12431 | else {
|
12432 | context.helpers.set(name, currentCount);
|
12433 | }
|
12434 | }
|
12435 | },
|
12436 | helperString(name) {
|
12437 | return `_${helperNameMap[context.helper(name)]}`;
|
12438 | },
|
12439 | replaceNode(node) {
|
12440 |
|
12441 | {
|
12442 | if (!context.currentNode) {
|
12443 | throw new Error(`Node being replaced is already removed.`);
|
12444 | }
|
12445 | if (!context.parent) {
|
12446 | throw new Error(`Cannot replace root node.`);
|
12447 | }
|
12448 | }
|
12449 | context.parent.children[context.childIndex] = context.currentNode = node;
|
12450 | },
|
12451 | removeNode(node) {
|
12452 | if (!context.parent) {
|
12453 | throw new Error(`Cannot remove root node.`);
|
12454 | }
|
12455 | const list = context.parent.children;
|
12456 | const removalIndex = node
|
12457 | ? list.indexOf(node)
|
12458 | : context.currentNode
|
12459 | ? context.childIndex
|
12460 | : -1;
|
12461 |
|
12462 | if (removalIndex < 0) {
|
12463 | throw new Error(`node being removed is not a child of current parent`);
|
12464 | }
|
12465 | if (!node || node === context.currentNode) {
|
12466 |
|
12467 | context.currentNode = null;
|
12468 | context.onNodeRemoved();
|
12469 | }
|
12470 | else {
|
12471 |
|
12472 | if (context.childIndex > removalIndex) {
|
12473 | context.childIndex--;
|
12474 | context.onNodeRemoved();
|
12475 | }
|
12476 | }
|
12477 | context.parent.children.splice(removalIndex, 1);
|
12478 | },
|
12479 | onNodeRemoved: () => { },
|
12480 | addIdentifiers(exp) {
|
12481 | },
|
12482 | removeIdentifiers(exp) {
|
12483 | },
|
12484 | hoist(exp) {
|
12485 | if (isString(exp))
|
12486 | exp = createSimpleExpression(exp);
|
12487 | context.hoists.push(exp);
|
12488 | const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 );
|
12489 | identifier.hoisted = exp;
|
12490 | return identifier;
|
12491 | },
|
12492 | cache(exp, isVNode = false) {
|
12493 | return createCacheExpression(context.cached++, exp, isVNode);
|
12494 | }
|
12495 | };
|
12496 | return context;
|
12497 | }
|
12498 | function transform(root, options) {
|
12499 | const context = createTransformContext(root, options);
|
12500 | traverseNode(root, context);
|
12501 | if (options.hoistStatic) {
|
12502 | hoistStatic(root, context);
|
12503 | }
|
12504 | if (!options.ssr) {
|
12505 | createRootCodegen(root, context);
|
12506 | }
|
12507 |
|
12508 | root.helpers = [...context.helpers.keys()];
|
12509 | root.components = [...context.components];
|
12510 | root.directives = [...context.directives];
|
12511 | root.imports = context.imports;
|
12512 | root.hoists = context.hoists;
|
12513 | root.temps = context.temps;
|
12514 | root.cached = context.cached;
|
12515 | }
|
12516 | function createRootCodegen(root, context) {
|
12517 | const { helper } = context;
|
12518 | const { children } = root;
|
12519 | if (children.length === 1) {
|
12520 | const child = children[0];
|
12521 |
|
12522 | if (isSingleElementRoot(root, child) && child.codegenNode) {
|
12523 |
|
12524 |
|
12525 | const codegenNode = child.codegenNode;
|
12526 | if (codegenNode.type === 13 ) {
|
12527 | makeBlock(codegenNode, context);
|
12528 | }
|
12529 | root.codegenNode = codegenNode;
|
12530 | }
|
12531 | else {
|
12532 |
|
12533 |
|
12534 |
|
12535 | root.codegenNode = child;
|
12536 | }
|
12537 | }
|
12538 | else if (children.length > 1) {
|
12539 |
|
12540 | let patchFlag = 64 ;
|
12541 | let patchFlagText = PatchFlagNames[64 ];
|
12542 |
|
12543 |
|
12544 | if (children.filter(c => c.type !== 3 ).length === 1) {
|
12545 | patchFlag |= 2048 ;
|
12546 | patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
12547 | }
|
12548 | root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, undefined, false );
|
12549 | }
|
12550 | else ;
|
12551 | }
|
12552 | function traverseChildren(parent, context) {
|
12553 | let i = 0;
|
12554 | const nodeRemoved = () => {
|
12555 | i--;
|
12556 | };
|
12557 | for (; i < parent.children.length; i++) {
|
12558 | const child = parent.children[i];
|
12559 | if (isString(child))
|
12560 | continue;
|
12561 | context.parent = parent;
|
12562 | context.childIndex = i;
|
12563 | context.onNodeRemoved = nodeRemoved;
|
12564 | traverseNode(child, context);
|
12565 | }
|
12566 | }
|
12567 | function traverseNode(node, context) {
|
12568 | context.currentNode = node;
|
12569 |
|
12570 | const { nodeTransforms } = context;
|
12571 | const exitFns = [];
|
12572 | for (let i = 0; i < nodeTransforms.length; i++) {
|
12573 | const onExit = nodeTransforms[i](node, context);
|
12574 | if (onExit) {
|
12575 | if (isArray(onExit)) {
|
12576 | exitFns.push(...onExit);
|
12577 | }
|
12578 | else {
|
12579 | exitFns.push(onExit);
|
12580 | }
|
12581 | }
|
12582 | if (!context.currentNode) {
|
12583 |
|
12584 | return;
|
12585 | }
|
12586 | else {
|
12587 |
|
12588 | node = context.currentNode;
|
12589 | }
|
12590 | }
|
12591 | switch (node.type) {
|
12592 | case 3 :
|
12593 | if (!context.ssr) {
|
12594 |
|
12595 |
|
12596 | context.helper(CREATE_COMMENT);
|
12597 | }
|
12598 | break;
|
12599 | case 5 :
|
12600 |
|
12601 | if (!context.ssr) {
|
12602 | context.helper(TO_DISPLAY_STRING);
|
12603 | }
|
12604 | break;
|
12605 |
|
12606 | case 9 :
|
12607 | for (let i = 0; i < node.branches.length; i++) {
|
12608 | traverseNode(node.branches[i], context);
|
12609 | }
|
12610 | break;
|
12611 | case 10 :
|
12612 | case 11 :
|
12613 | case 1 :
|
12614 | case 0 :
|
12615 | traverseChildren(node, context);
|
12616 | break;
|
12617 | }
|
12618 |
|
12619 | context.currentNode = node;
|
12620 | let i = exitFns.length;
|
12621 | while (i--) {
|
12622 | exitFns[i]();
|
12623 | }
|
12624 | }
|
12625 | function createStructuralDirectiveTransform(name, fn) {
|
12626 | const matches = isString(name)
|
12627 | ? (n) => n === name
|
12628 | : (n) => name.test(n);
|
12629 | return (node, context) => {
|
12630 | if (node.type === 1 ) {
|
12631 | const { props } = node;
|
12632 |
|
12633 |
|
12634 | if (node.tagType === 3 && props.some(isVSlot)) {
|
12635 | return;
|
12636 | }
|
12637 | const exitFns = [];
|
12638 | for (let i = 0; i < props.length; i++) {
|
12639 | const prop = props[i];
|
12640 | if (prop.type === 7 && matches(prop.name)) {
|
12641 |
|
12642 |
|
12643 |
|
12644 | props.splice(i, 1);
|
12645 | i--;
|
12646 | const onExit = fn(node, prop, context);
|
12647 | if (onExit)
|
12648 | exitFns.push(onExit);
|
12649 | }
|
12650 | }
|
12651 | return exitFns;
|
12652 | }
|
12653 | };
|
12654 | }
|
12655 |
|
12656 | const PURE_ANNOTATION = `/*#__PURE__*/`;
|
12657 | function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
12658 | const context = {
|
12659 | mode,
|
12660 | prefixIdentifiers,
|
12661 | sourceMap,
|
12662 | filename,
|
12663 | scopeId,
|
12664 | optimizeImports,
|
12665 | runtimeGlobalName,
|
12666 | runtimeModuleName,
|
12667 | ssrRuntimeModuleName,
|
12668 | ssr,
|
12669 | isTS,
|
12670 | inSSR,
|
12671 | source: ast.loc.source,
|
12672 | code: ``,
|
12673 | column: 1,
|
12674 | line: 1,
|
12675 | offset: 0,
|
12676 | indentLevel: 0,
|
12677 | pure: false,
|
12678 | map: undefined,
|
12679 | helper(key) {
|
12680 | return `_${helperNameMap[key]}`;
|
12681 | },
|
12682 | push(code, node) {
|
12683 | context.code += code;
|
12684 | },
|
12685 | indent() {
|
12686 | newline(++context.indentLevel);
|
12687 | },
|
12688 | deindent(withoutNewLine = false) {
|
12689 | if (withoutNewLine) {
|
12690 | --context.indentLevel;
|
12691 | }
|
12692 | else {
|
12693 | newline(--context.indentLevel);
|
12694 | }
|
12695 | },
|
12696 | newline() {
|
12697 | newline(context.indentLevel);
|
12698 | }
|
12699 | };
|
12700 | function newline(n) {
|
12701 | context.push('\n' + ` `.repeat(n));
|
12702 | }
|
12703 | return context;
|
12704 | }
|
12705 | function generate(ast, options = {}) {
|
12706 | const context = createCodegenContext(ast, options);
|
12707 | if (options.onContextCreated)
|
12708 | options.onContextCreated(context);
|
12709 | const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
|
12710 | const hasHelpers = ast.helpers.length > 0;
|
12711 | const useWithBlock = !prefixIdentifiers && mode !== 'module';
|
12712 |
|
12713 |
|
12714 |
|
12715 | const preambleContext = context;
|
12716 | {
|
12717 | genFunctionPreamble(ast, preambleContext);
|
12718 | }
|
12719 |
|
12720 | const functionName = ssr ? `ssrRender` : `render`;
|
12721 | const args = ssr ? ['_ctx', '_push', '_parent', '_attrs'] : ['_ctx', '_cache'];
|
12722 | const signature = args.join(', ');
|
12723 | {
|
12724 | push(`function ${functionName}(${signature}) {`);
|
12725 | }
|
12726 | indent();
|
12727 | if (useWithBlock) {
|
12728 | push(`with (_ctx) {`);
|
12729 | indent();
|
12730 |
|
12731 |
|
12732 | if (hasHelpers) {
|
12733 | push(`const { ${ast.helpers
|
12734 | .map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
12735 | .join(', ')} } = _Vue`);
|
12736 | push(`\n`);
|
12737 | newline();
|
12738 | }
|
12739 | }
|
12740 |
|
12741 | if (ast.components.length) {
|
12742 | genAssets(ast.components, 'component', context);
|
12743 | if (ast.directives.length || ast.temps > 0) {
|
12744 | newline();
|
12745 | }
|
12746 | }
|
12747 | if (ast.directives.length) {
|
12748 | genAssets(ast.directives, 'directive', context);
|
12749 | if (ast.temps > 0) {
|
12750 | newline();
|
12751 | }
|
12752 | }
|
12753 | if (ast.temps > 0) {
|
12754 | push(`let `);
|
12755 | for (let i = 0; i < ast.temps; i++) {
|
12756 | push(`${i > 0 ? `, ` : ``}_temp${i}`);
|
12757 | }
|
12758 | }
|
12759 | if (ast.components.length || ast.directives.length || ast.temps) {
|
12760 | push(`\n`);
|
12761 | newline();
|
12762 | }
|
12763 |
|
12764 | if (!ssr) {
|
12765 | push(`return `);
|
12766 | }
|
12767 | if (ast.codegenNode) {
|
12768 | genNode(ast.codegenNode, context);
|
12769 | }
|
12770 | else {
|
12771 | push(`null`);
|
12772 | }
|
12773 | if (useWithBlock) {
|
12774 | deindent();
|
12775 | push(`}`);
|
12776 | }
|
12777 | deindent();
|
12778 | push(`}`);
|
12779 | return {
|
12780 | ast,
|
12781 | code: context.code,
|
12782 | preamble: ``,
|
12783 |
|
12784 | map: context.map ? context.map.toJSON() : undefined
|
12785 | };
|
12786 | }
|
12787 | function genFunctionPreamble(ast, context) {
|
12788 | const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
12789 | const VueBinding = runtimeGlobalName;
|
12790 | const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
12791 |
|
12792 |
|
12793 |
|
12794 |
|
12795 | if (ast.helpers.length > 0) {
|
12796 | {
|
12797 |
|
12798 |
|
12799 | push(`const _Vue = ${VueBinding}\n`);
|
12800 |
|
12801 |
|
12802 |
|
12803 | if (ast.hoists.length) {
|
12804 | const staticHelpers = [
|
12805 | CREATE_VNODE,
|
12806 | CREATE_ELEMENT_VNODE,
|
12807 | CREATE_COMMENT,
|
12808 | CREATE_TEXT,
|
12809 | CREATE_STATIC
|
12810 | ]
|
12811 | .filter(helper => ast.helpers.includes(helper))
|
12812 | .map(aliasHelper)
|
12813 | .join(', ');
|
12814 | push(`const { ${staticHelpers} } = _Vue\n`);
|
12815 | }
|
12816 | }
|
12817 | }
|
12818 | genHoists(ast.hoists, context);
|
12819 | newline();
|
12820 | push(`return `);
|
12821 | }
|
12822 | function genAssets(assets, type, { helper, push, newline, isTS }) {
|
12823 | const resolver = helper(type === 'component'
|
12824 | ? RESOLVE_COMPONENT
|
12825 | : RESOLVE_DIRECTIVE);
|
12826 | for (let i = 0; i < assets.length; i++) {
|
12827 | let id = assets[i];
|
12828 |
|
12829 | const maybeSelfReference = id.endsWith('__self');
|
12830 | if (maybeSelfReference) {
|
12831 | id = id.slice(0, -6);
|
12832 | }
|
12833 | push(`const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`);
|
12834 | if (i < assets.length - 1) {
|
12835 | newline();
|
12836 | }
|
12837 | }
|
12838 | }
|
12839 | function genHoists(hoists, context) {
|
12840 | if (!hoists.length) {
|
12841 | return;
|
12842 | }
|
12843 | context.pure = true;
|
12844 | const { push, newline, helper, scopeId, mode } = context;
|
12845 | newline();
|
12846 | for (let i = 0; i < hoists.length; i++) {
|
12847 | const exp = hoists[i];
|
12848 | if (exp) {
|
12849 | push(`const _hoisted_${i + 1} = ${``}`);
|
12850 | genNode(exp, context);
|
12851 | newline();
|
12852 | }
|
12853 | }
|
12854 | context.pure = false;
|
12855 | }
|
12856 | function isText$1(n) {
|
12857 | return (isString(n) ||
|
12858 | n.type === 4 ||
|
12859 | n.type === 2 ||
|
12860 | n.type === 5 ||
|
12861 | n.type === 8 );
|
12862 | }
|
12863 | function genNodeListAsArray(nodes, context) {
|
12864 | const multilines = nodes.length > 3 ||
|
12865 | (nodes.some(n => isArray(n) || !isText$1(n)));
|
12866 | context.push(`[`);
|
12867 | multilines && context.indent();
|
12868 | genNodeList(nodes, context, multilines);
|
12869 | multilines && context.deindent();
|
12870 | context.push(`]`);
|
12871 | }
|
12872 | function genNodeList(nodes, context, multilines = false, comma = true) {
|
12873 | const { push, newline } = context;
|
12874 | for (let i = 0; i < nodes.length; i++) {
|
12875 | const node = nodes[i];
|
12876 | if (isString(node)) {
|
12877 | push(node);
|
12878 | }
|
12879 | else if (isArray(node)) {
|
12880 | genNodeListAsArray(node, context);
|
12881 | }
|
12882 | else {
|
12883 | genNode(node, context);
|
12884 | }
|
12885 | if (i < nodes.length - 1) {
|
12886 | if (multilines) {
|
12887 | comma && push(',');
|
12888 | newline();
|
12889 | }
|
12890 | else {
|
12891 | comma && push(', ');
|
12892 | }
|
12893 | }
|
12894 | }
|
12895 | }
|
12896 | function genNode(node, context) {
|
12897 | if (isString(node)) {
|
12898 | context.push(node);
|
12899 | return;
|
12900 | }
|
12901 | if (isSymbol(node)) {
|
12902 | context.push(context.helper(node));
|
12903 | return;
|
12904 | }
|
12905 | switch (node.type) {
|
12906 | case 1 :
|
12907 | case 9 :
|
12908 | case 11 :
|
12909 | assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. ` +
|
12910 | `Apply appropriate transforms first.`);
|
12911 | genNode(node.codegenNode, context);
|
12912 | break;
|
12913 | case 2 :
|
12914 | genText(node, context);
|
12915 | break;
|
12916 | case 4 :
|
12917 | genExpression(node, context);
|
12918 | break;
|
12919 | case 5 :
|
12920 | genInterpolation(node, context);
|
12921 | break;
|
12922 | case 12 :
|
12923 | genNode(node.codegenNode, context);
|
12924 | break;
|
12925 | case 8 :
|
12926 | genCompoundExpression(node, context);
|
12927 | break;
|
12928 | case 3 :
|
12929 | genComment(node, context);
|
12930 | break;
|
12931 | case 13 :
|
12932 | genVNodeCall(node, context);
|
12933 | break;
|
12934 | case 14 :
|
12935 | genCallExpression(node, context);
|
12936 | break;
|
12937 | case 15 :
|
12938 | genObjectExpression(node, context);
|
12939 | break;
|
12940 | case 17 :
|
12941 | genArrayExpression(node, context);
|
12942 | break;
|
12943 | case 18 :
|
12944 | genFunctionExpression(node, context);
|
12945 | break;
|
12946 | case 19 :
|
12947 | genConditionalExpression(node, context);
|
12948 | break;
|
12949 | case 20 :
|
12950 | genCacheExpression(node, context);
|
12951 | break;
|
12952 | case 21 :
|
12953 | genNodeList(node.body, context, true, false);
|
12954 | break;
|
12955 |
|
12956 | case 22 :
|
12957 | break;
|
12958 | case 23 :
|
12959 | break;
|
12960 | case 24 :
|
12961 | break;
|
12962 | case 25 :
|
12963 | break;
|
12964 | case 26 :
|
12965 | break;
|
12966 |
|
12967 | case 10 :
|
12968 |
|
12969 | break;
|
12970 | default:
|
12971 | {
|
12972 | assert(false, `unhandled codegen node type: ${node.type}`);
|
12973 |
|
12974 | const exhaustiveCheck = node;
|
12975 | return exhaustiveCheck;
|
12976 | }
|
12977 | }
|
12978 | }
|
12979 | function genText(node, context) {
|
12980 | context.push(JSON.stringify(node.content), node);
|
12981 | }
|
12982 | function genExpression(node, context) {
|
12983 | const { content, isStatic } = node;
|
12984 | context.push(isStatic ? JSON.stringify(content) : content, node);
|
12985 | }
|
12986 | function genInterpolation(node, context) {
|
12987 | const { push, helper, pure } = context;
|
12988 | if (pure)
|
12989 | push(PURE_ANNOTATION);
|
12990 | push(`${helper(TO_DISPLAY_STRING)}(`);
|
12991 | genNode(node.content, context);
|
12992 | push(`)`);
|
12993 | }
|
12994 | function genCompoundExpression(node, context) {
|
12995 | for (let i = 0; i < node.children.length; i++) {
|
12996 | const child = node.children[i];
|
12997 | if (isString(child)) {
|
12998 | context.push(child);
|
12999 | }
|
13000 | else {
|
13001 | genNode(child, context);
|
13002 | }
|
13003 | }
|
13004 | }
|
13005 | function genExpressionAsPropertyKey(node, context) {
|
13006 | const { push } = context;
|
13007 | if (node.type === 8 ) {
|
13008 | push(`[`);
|
13009 | genCompoundExpression(node, context);
|
13010 | push(`]`);
|
13011 | }
|
13012 | else if (node.isStatic) {
|
13013 |
|
13014 | const text = isSimpleIdentifier(node.content)
|
13015 | ? node.content
|
13016 | : JSON.stringify(node.content);
|
13017 | push(text, node);
|
13018 | }
|
13019 | else {
|
13020 | push(`[${node.content}]`, node);
|
13021 | }
|
13022 | }
|
13023 | function genComment(node, context) {
|
13024 | const { push, helper, pure } = context;
|
13025 | if (pure) {
|
13026 | push(PURE_ANNOTATION);
|
13027 | }
|
13028 | push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
|
13029 | }
|
13030 | function genVNodeCall(node, context) {
|
13031 | const { push, helper, pure } = context;
|
13032 | const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
|
13033 | if (directives) {
|
13034 | push(helper(WITH_DIRECTIVES) + `(`);
|
13035 | }
|
13036 | if (isBlock) {
|
13037 | push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
|
13038 | }
|
13039 | if (pure) {
|
13040 | push(PURE_ANNOTATION);
|
13041 | }
|
13042 | const callHelper = isBlock
|
13043 | ? getVNodeBlockHelper(context.inSSR, isComponent)
|
13044 | : getVNodeHelper(context.inSSR, isComponent);
|
13045 | push(helper(callHelper) + `(`, node);
|
13046 | genNodeList(genNullableArgs([tag, props, children, patchFlag, dynamicProps]), context);
|
13047 | push(`)`);
|
13048 | if (isBlock) {
|
13049 | push(`)`);
|
13050 | }
|
13051 | if (directives) {
|
13052 | push(`, `);
|
13053 | genNode(directives, context);
|
13054 | push(`)`);
|
13055 | }
|
13056 | }
|
13057 | function genNullableArgs(args) {
|
13058 | let i = args.length;
|
13059 | while (i--) {
|
13060 | if (args[i] != null)
|
13061 | break;
|
13062 | }
|
13063 | return args.slice(0, i + 1).map(arg => arg || `null`);
|
13064 | }
|
13065 |
|
13066 | function genCallExpression(node, context) {
|
13067 | const { push, helper, pure } = context;
|
13068 | const callee = isString(node.callee) ? node.callee : helper(node.callee);
|
13069 | if (pure) {
|
13070 | push(PURE_ANNOTATION);
|
13071 | }
|
13072 | push(callee + `(`, node);
|
13073 | genNodeList(node.arguments, context);
|
13074 | push(`)`);
|
13075 | }
|
13076 | function genObjectExpression(node, context) {
|
13077 | const { push, indent, deindent, newline } = context;
|
13078 | const { properties } = node;
|
13079 | if (!properties.length) {
|
13080 | push(`{}`, node);
|
13081 | return;
|
13082 | }
|
13083 | const multilines = properties.length > 1 ||
|
13084 | (properties.some(p => p.value.type !== 4 ));
|
13085 | push(multilines ? `{` : `{ `);
|
13086 | multilines && indent();
|
13087 | for (let i = 0; i < properties.length; i++) {
|
13088 | const { key, value } = properties[i];
|
13089 |
|
13090 | genExpressionAsPropertyKey(key, context);
|
13091 | push(`: `);
|
13092 |
|
13093 | genNode(value, context);
|
13094 | if (i < properties.length - 1) {
|
13095 |
|
13096 | push(`,`);
|
13097 | newline();
|
13098 | }
|
13099 | }
|
13100 | multilines && deindent();
|
13101 | push(multilines ? `}` : ` }`);
|
13102 | }
|
13103 | function genArrayExpression(node, context) {
|
13104 | genNodeListAsArray(node.elements, context);
|
13105 | }
|
13106 | function genFunctionExpression(node, context) {
|
13107 | const { push, indent, deindent } = context;
|
13108 | const { params, returns, body, newline, isSlot } = node;
|
13109 | if (isSlot) {
|
13110 |
|
13111 | push(`_${helperNameMap[WITH_CTX]}(`);
|
13112 | }
|
13113 | push(`(`, node);
|
13114 | if (isArray(params)) {
|
13115 | genNodeList(params, context);
|
13116 | }
|
13117 | else if (params) {
|
13118 | genNode(params, context);
|
13119 | }
|
13120 | push(`) => `);
|
13121 | if (newline || body) {
|
13122 | push(`{`);
|
13123 | indent();
|
13124 | }
|
13125 | if (returns) {
|
13126 | if (newline) {
|
13127 | push(`return `);
|
13128 | }
|
13129 | if (isArray(returns)) {
|
13130 | genNodeListAsArray(returns, context);
|
13131 | }
|
13132 | else {
|
13133 | genNode(returns, context);
|
13134 | }
|
13135 | }
|
13136 | else if (body) {
|
13137 | genNode(body, context);
|
13138 | }
|
13139 | if (newline || body) {
|
13140 | deindent();
|
13141 | push(`}`);
|
13142 | }
|
13143 | if (isSlot) {
|
13144 | push(`)`);
|
13145 | }
|
13146 | }
|
13147 | function genConditionalExpression(node, context) {
|
13148 | const { test, consequent, alternate, newline: needNewline } = node;
|
13149 | const { push, indent, deindent, newline } = context;
|
13150 | if (test.type === 4 ) {
|
13151 | const needsParens = !isSimpleIdentifier(test.content);
|
13152 | needsParens && push(`(`);
|
13153 | genExpression(test, context);
|
13154 | needsParens && push(`)`);
|
13155 | }
|
13156 | else {
|
13157 | push(`(`);
|
13158 | genNode(test, context);
|
13159 | push(`)`);
|
13160 | }
|
13161 | needNewline && indent();
|
13162 | context.indentLevel++;
|
13163 | needNewline || push(` `);
|
13164 | push(`? `);
|
13165 | genNode(consequent, context);
|
13166 | context.indentLevel--;
|
13167 | needNewline && newline();
|
13168 | needNewline || push(` `);
|
13169 | push(`: `);
|
13170 | const isNested = alternate.type === 19 ;
|
13171 | if (!isNested) {
|
13172 | context.indentLevel++;
|
13173 | }
|
13174 | genNode(alternate, context);
|
13175 | if (!isNested) {
|
13176 | context.indentLevel--;
|
13177 | }
|
13178 | needNewline && deindent(true );
|
13179 | }
|
13180 | function genCacheExpression(node, context) {
|
13181 | const { push, helper, indent, deindent, newline } = context;
|
13182 | push(`_cache[${node.index}] || (`);
|
13183 | if (node.isVNode) {
|
13184 | indent();
|
13185 | push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
|
13186 | newline();
|
13187 | }
|
13188 | push(`_cache[${node.index}] = `);
|
13189 | genNode(node.value, context);
|
13190 | if (node.isVNode) {
|
13191 | push(`,`);
|
13192 | newline();
|
13193 | push(`${helper(SET_BLOCK_TRACKING)}(1),`);
|
13194 | newline();
|
13195 | push(`_cache[${node.index}]`);
|
13196 | deindent();
|
13197 | }
|
13198 | push(`)`);
|
13199 | }
|
13200 |
|
13201 |
|
13202 |
|
13203 | const prohibitedKeywordRE = new RegExp('\\b' +
|
13204 | ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
|
13205 | 'super,throw,while,yield,delete,export,import,return,switch,default,' +
|
13206 | 'extends,finally,continue,debugger,function,arguments,typeof,void')
|
13207 | .split(',')
|
13208 | .join('\\b|\\b') +
|
13209 | '\\b');
|
13210 |
|
13211 | const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
13212 | |
13213 |
|
13214 |
|
13215 |
|
13216 |
|
13217 | function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
|
13218 | const exp = node.content;
|
13219 |
|
13220 |
|
13221 | if (!exp.trim()) {
|
13222 | return;
|
13223 | }
|
13224 | try {
|
13225 | new Function(asRawStatements
|
13226 | ? ` ${exp} `
|
13227 | : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`);
|
13228 | }
|
13229 | catch (e) {
|
13230 | let message = e.message;
|
13231 | const keywordMatch = exp
|
13232 | .replace(stripStringRE, '')
|
13233 | .match(prohibitedKeywordRE);
|
13234 | if (keywordMatch) {
|
13235 | message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
|
13236 | }
|
13237 | context.onError(createCompilerError(44 , node.loc, undefined, message));
|
13238 | }
|
13239 | }
|
13240 |
|
13241 | const transformExpression = (node, context) => {
|
13242 | if (node.type === 5 ) {
|
13243 | node.content = processExpression(node.content, context);
|
13244 | }
|
13245 | else if (node.type === 1 ) {
|
13246 |
|
13247 | for (let i = 0; i < node.props.length; i++) {
|
13248 | const dir = node.props[i];
|
13249 |
|
13250 | if (dir.type === 7 && dir.name !== 'for') {
|
13251 | const exp = dir.exp;
|
13252 | const arg = dir.arg;
|
13253 |
|
13254 |
|
13255 | if (exp &&
|
13256 | exp.type === 4 &&
|
13257 | !(dir.name === 'on' && arg)) {
|
13258 | dir.exp = processExpression(exp, context,
|
13259 |
|
13260 | dir.name === 'slot');
|
13261 | }
|
13262 | if (arg && arg.type === 4 && !arg.isStatic) {
|
13263 | dir.arg = processExpression(arg, context);
|
13264 | }
|
13265 | }
|
13266 | }
|
13267 | }
|
13268 | };
|
13269 |
|
13270 |
|
13271 |
|
13272 | function processExpression(node, context,
|
13273 | // some expressions like v-slot props & v-for aliases should be parsed as
|
13274 | // function params
|
13275 | asParams = false,
|
13276 | // v-on handler values may contain multiple statements
|
13277 | asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
13278 | {
|
13279 | {
|
13280 |
|
13281 | validateBrowserExpression(node, context, asParams, asRawStatements);
|
13282 | }
|
13283 | return node;
|
13284 | }
|
13285 | }
|
13286 |
|
13287 | const transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (node, dir, context) => {
|
13288 | return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
13289 |
|
13290 |
|
13291 |
|
13292 | const siblings = context.parent.children;
|
13293 | let i = siblings.indexOf(ifNode);
|
13294 | let key = 0;
|
13295 | while (i-- >= 0) {
|
13296 | const sibling = siblings[i];
|
13297 | if (sibling && sibling.type === 9 ) {
|
13298 | key += sibling.branches.length;
|
13299 | }
|
13300 | }
|
13301 |
|
13302 |
|
13303 | return () => {
|
13304 | if (isRoot) {
|
13305 | ifNode.codegenNode = createCodegenNodeForBranch(branch, key, context);
|
13306 | }
|
13307 | else {
|
13308 |
|
13309 | const parentCondition = getParentCondition(ifNode.codegenNode);
|
13310 | parentCondition.alternate = createCodegenNodeForBranch(branch, key + ifNode.branches.length - 1, context);
|
13311 | }
|
13312 | };
|
13313 | });
|
13314 | });
|
13315 |
|
13316 | function processIf(node, dir, context, processCodegen) {
|
13317 | if (dir.name !== 'else' &&
|
13318 | (!dir.exp || !dir.exp.content.trim())) {
|
13319 | const loc = dir.exp ? dir.exp.loc : node.loc;
|
13320 | context.onError(createCompilerError(28 , dir.loc));
|
13321 | dir.exp = createSimpleExpression(`true`, false, loc);
|
13322 | }
|
13323 | if (dir.exp) {
|
13324 | validateBrowserExpression(dir.exp, context);
|
13325 | }
|
13326 | if (dir.name === 'if') {
|
13327 | const branch = createIfBranch(node, dir);
|
13328 | const ifNode = {
|
13329 | type: 9 ,
|
13330 | loc: node.loc,
|
13331 | branches: [branch]
|
13332 | };
|
13333 | context.replaceNode(ifNode);
|
13334 | if (processCodegen) {
|
13335 | return processCodegen(ifNode, branch, true);
|
13336 | }
|
13337 | }
|
13338 | else {
|
13339 |
|
13340 | const siblings = context.parent.children;
|
13341 | const comments = [];
|
13342 | let i = siblings.indexOf(node);
|
13343 | while (i-- >= -1) {
|
13344 | const sibling = siblings[i];
|
13345 | if (sibling && sibling.type === 3 ) {
|
13346 | context.removeNode(sibling);
|
13347 | comments.unshift(sibling);
|
13348 | continue;
|
13349 | }
|
13350 | if (sibling &&
|
13351 | sibling.type === 2 &&
|
13352 | !sibling.content.trim().length) {
|
13353 | context.removeNode(sibling);
|
13354 | continue;
|
13355 | }
|
13356 | if (sibling && sibling.type === 9 ) {
|
13357 |
|
13358 | if (dir.name === 'else-if' &&
|
13359 | sibling.branches[sibling.branches.length - 1].condition === undefined) {
|
13360 | context.onError(createCompilerError(30 , node.loc));
|
13361 | }
|
13362 |
|
13363 | context.removeNode();
|
13364 | const branch = createIfBranch(node, dir);
|
13365 | if (comments.length &&
|
13366 |
|
13367 | !(context.parent &&
|
13368 | context.parent.type === 1 &&
|
13369 | isBuiltInType(context.parent.tag, 'transition'))) {
|
13370 | branch.children = [...comments, ...branch.children];
|
13371 | }
|
13372 |
|
13373 | {
|
13374 | const key = branch.userKey;
|
13375 | if (key) {
|
13376 | sibling.branches.forEach(({ userKey }) => {
|
13377 | if (isSameKey(userKey, key)) {
|
13378 | context.onError(createCompilerError(29 , branch.userKey.loc));
|
13379 | }
|
13380 | });
|
13381 | }
|
13382 | }
|
13383 | sibling.branches.push(branch);
|
13384 | const onExit = processCodegen && processCodegen(sibling, branch, false);
|
13385 |
|
13386 |
|
13387 | traverseNode(branch, context);
|
13388 |
|
13389 | if (onExit)
|
13390 | onExit();
|
13391 |
|
13392 |
|
13393 | context.currentNode = null;
|
13394 | }
|
13395 | else {
|
13396 | context.onError(createCompilerError(30 , node.loc));
|
13397 | }
|
13398 | break;
|
13399 | }
|
13400 | }
|
13401 | }
|
13402 | function createIfBranch(node, dir) {
|
13403 | return {
|
13404 | type: 10 ,
|
13405 | loc: node.loc,
|
13406 | condition: dir.name === 'else' ? undefined : dir.exp,
|
13407 | children: node.tagType === 3 && !findDir(node, 'for')
|
13408 | ? node.children
|
13409 | : [node],
|
13410 | userKey: findProp(node, `key`)
|
13411 | };
|
13412 | }
|
13413 | function createCodegenNodeForBranch(branch, keyIndex, context) {
|
13414 | if (branch.condition) {
|
13415 | return createConditionalExpression(branch.condition, createChildrenCodegenNode(branch, keyIndex, context),
|
13416 |
|
13417 |
|
13418 | createCallExpression(context.helper(CREATE_COMMENT), [
|
13419 | '"v-if"' ,
|
13420 | 'true'
|
13421 | ]));
|
13422 | }
|
13423 | else {
|
13424 | return createChildrenCodegenNode(branch, keyIndex, context);
|
13425 | }
|
13426 | }
|
13427 | function createChildrenCodegenNode(branch, keyIndex, context) {
|
13428 | const { helper } = context;
|
13429 | const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 ));
|
13430 | const { children } = branch;
|
13431 | const firstChild = children[0];
|
13432 | const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 ;
|
13433 | if (needFragmentWrapper) {
|
13434 | if (children.length === 1 && firstChild.type === 11 ) {
|
13435 |
|
13436 | const vnodeCall = firstChild.codegenNode;
|
13437 | injectProp(vnodeCall, keyProperty, context);
|
13438 | return vnodeCall;
|
13439 | }
|
13440 | else {
|
13441 | let patchFlag = 64 ;
|
13442 | let patchFlagText = PatchFlagNames[64 ];
|
13443 |
|
13444 |
|
13445 | if (children.filter(c => c.type !== 3 ).length === 1) {
|
13446 | patchFlag |= 2048 ;
|
13447 | patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
13448 | }
|
13449 | return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, false, false , branch.loc);
|
13450 | }
|
13451 | }
|
13452 | else {
|
13453 | const ret = firstChild.codegenNode;
|
13454 | const vnodeCall = getMemoedVNodeCall(ret);
|
13455 |
|
13456 | if (vnodeCall.type === 13 ) {
|
13457 | makeBlock(vnodeCall, context);
|
13458 | }
|
13459 |
|
13460 | injectProp(vnodeCall, keyProperty, context);
|
13461 | return ret;
|
13462 | }
|
13463 | }
|
13464 | function isSameKey(a, b) {
|
13465 | if (!a || a.type !== b.type) {
|
13466 | return false;
|
13467 | }
|
13468 | if (a.type === 6 ) {
|
13469 | if (a.value.content !== b.value.content) {
|
13470 | return false;
|
13471 | }
|
13472 | }
|
13473 | else {
|
13474 |
|
13475 | const exp = a.exp;
|
13476 | const branchExp = b.exp;
|
13477 | if (exp.type !== branchExp.type) {
|
13478 | return false;
|
13479 | }
|
13480 | if (exp.type !== 4 ||
|
13481 | exp.isStatic !== branchExp.isStatic ||
|
13482 | exp.content !== branchExp.content) {
|
13483 | return false;
|
13484 | }
|
13485 | }
|
13486 | return true;
|
13487 | }
|
13488 | function getParentCondition(node) {
|
13489 | while (true) {
|
13490 | if (node.type === 19 ) {
|
13491 | if (node.alternate.type === 19 ) {
|
13492 | node = node.alternate;
|
13493 | }
|
13494 | else {
|
13495 | return node;
|
13496 | }
|
13497 | }
|
13498 | else if (node.type === 20 ) {
|
13499 | node = node.value;
|
13500 | }
|
13501 | }
|
13502 | }
|
13503 |
|
13504 | const transformFor = createStructuralDirectiveTransform('for', (node, dir, context) => {
|
13505 | const { helper, removeHelper } = context;
|
13506 | return processFor(node, dir, context, forNode => {
|
13507 |
|
13508 |
|
13509 | const renderExp = createCallExpression(helper(RENDER_LIST), [
|
13510 | forNode.source
|
13511 | ]);
|
13512 | const memo = findDir(node, 'memo');
|
13513 | const keyProp = findProp(node, `key`);
|
13514 | const keyExp = keyProp &&
|
13515 | (keyProp.type === 6
|
13516 | ? createSimpleExpression(keyProp.value.content, true)
|
13517 | : keyProp.exp);
|
13518 | const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
13519 | const isStableFragment = forNode.source.type === 4 &&
|
13520 | forNode.source.constType > 0 ;
|
13521 | const fragmentFlag = isStableFragment
|
13522 | ? 64
|
13523 | : keyProp
|
13524 | ? 128
|
13525 | : 256 ;
|
13526 | forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
|
13527 | (` /* ${PatchFlagNames[fragmentFlag]} */` ), undefined, undefined, true , !isStableFragment , false , node.loc);
|
13528 | return () => {
|
13529 |
|
13530 | let childBlock;
|
13531 | const isTemplate = isTemplateNode(node);
|
13532 | const { children } = forNode;
|
13533 |
|
13534 | if (isTemplate) {
|
13535 | node.children.some(c => {
|
13536 | if (c.type === 1 ) {
|
13537 | const key = findProp(c, 'key');
|
13538 | if (key) {
|
13539 | context.onError(createCompilerError(33 , key.loc));
|
13540 | return true;
|
13541 | }
|
13542 | }
|
13543 | });
|
13544 | }
|
13545 | const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 ;
|
13546 | const slotOutlet = isSlotOutlet(node)
|
13547 | ? node
|
13548 | : isTemplate &&
|
13549 | node.children.length === 1 &&
|
13550 | isSlotOutlet(node.children[0])
|
13551 | ? node.children[0]
|
13552 | : null;
|
13553 | if (slotOutlet) {
|
13554 |
|
13555 | childBlock = slotOutlet.codegenNode;
|
13556 | if (isTemplate && keyProperty) {
|
13557 |
|
13558 |
|
13559 |
|
13560 | injectProp(childBlock, keyProperty, context);
|
13561 | }
|
13562 | }
|
13563 | else if (needFragmentWrapper) {
|
13564 |
|
13565 |
|
13566 | childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 +
|
13567 | (` /* ${PatchFlagNames[64 /* STABLE_FRAGMENT */]} */`
|
13568 | ), undefined, undefined, true, undefined, false );
|
13569 | }
|
13570 | else {
|
13571 |
|
13572 |
|
13573 | childBlock = children[0]
|
13574 | .codegenNode;
|
13575 | if (isTemplate && keyProperty) {
|
13576 | injectProp(childBlock, keyProperty, context);
|
13577 | }
|
13578 | if (childBlock.isBlock !== !isStableFragment) {
|
13579 | if (childBlock.isBlock) {
|
13580 |
|
13581 | removeHelper(OPEN_BLOCK);
|
13582 | removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
13583 | }
|
13584 | else {
|
13585 |
|
13586 | removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
13587 | }
|
13588 | }
|
13589 | childBlock.isBlock = !isStableFragment;
|
13590 | if (childBlock.isBlock) {
|
13591 | helper(OPEN_BLOCK);
|
13592 | helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
|
13593 | }
|
13594 | else {
|
13595 | helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
|
13596 | }
|
13597 | }
|
13598 | if (memo) {
|
13599 | const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [
|
13600 | createSimpleExpression(`_cached`)
|
13601 | ]));
|
13602 | loop.body = createBlockStatement([
|
13603 | createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
|
13604 | createCompoundExpression([
|
13605 | `if (_cached`,
|
13606 | ...(keyExp ? [` && _cached.key === `, keyExp] : []),
|
13607 | ` && ${context.helperString(IS_MEMO_SAME)}(_cached, _memo)) return _cached`
|
13608 | ]),
|
13609 | createCompoundExpression([`const _item = `, childBlock]),
|
13610 | createSimpleExpression(`_item.memo = _memo`),
|
13611 | createSimpleExpression(`return _item`)
|
13612 | ]);
|
13613 | renderExp.arguments.push(loop, createSimpleExpression(`_cache`), createSimpleExpression(String(context.cached++)));
|
13614 | }
|
13615 | else {
|
13616 | renderExp.arguments.push(createFunctionExpression(createForLoopParams(forNode.parseResult), childBlock, true ));
|
13617 | }
|
13618 | };
|
13619 | });
|
13620 | });
|
13621 |
|
13622 | function processFor(node, dir, context, processCodegen) {
|
13623 | if (!dir.exp) {
|
13624 | context.onError(createCompilerError(31 , dir.loc));
|
13625 | return;
|
13626 | }
|
13627 | const parseResult = parseForExpression(
|
13628 |
|
13629 |
|
13630 | dir.exp, context);
|
13631 | if (!parseResult) {
|
13632 | context.onError(createCompilerError(32 , dir.loc));
|
13633 | return;
|
13634 | }
|
13635 | const { addIdentifiers, removeIdentifiers, scopes } = context;
|
13636 | const { source, value, key, index } = parseResult;
|
13637 | const forNode = {
|
13638 | type: 11 ,
|
13639 | loc: dir.loc,
|
13640 | source,
|
13641 | valueAlias: value,
|
13642 | keyAlias: key,
|
13643 | objectIndexAlias: index,
|
13644 | parseResult,
|
13645 | children: isTemplateNode(node) ? node.children : [node]
|
13646 | };
|
13647 | context.replaceNode(forNode);
|
13648 |
|
13649 | scopes.vFor++;
|
13650 | const onExit = processCodegen && processCodegen(forNode);
|
13651 | return () => {
|
13652 | scopes.vFor--;
|
13653 | if (onExit)
|
13654 | onExit();
|
13655 | };
|
13656 | }
|
13657 | const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
13658 |
|
13659 |
|
13660 | const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
13661 | const stripParensRE = /^\(|\)$/g;
|
13662 | function parseForExpression(input, context) {
|
13663 | const loc = input.loc;
|
13664 | const exp = input.content;
|
13665 | const inMatch = exp.match(forAliasRE);
|
13666 | if (!inMatch)
|
13667 | return;
|
13668 | const [, LHS, RHS] = inMatch;
|
13669 | const result = {
|
13670 | source: createAliasExpression(loc, RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
13671 | value: undefined,
|
13672 | key: undefined,
|
13673 | index: undefined
|
13674 | };
|
13675 | {
|
13676 | validateBrowserExpression(result.source, context);
|
13677 | }
|
13678 | let valueContent = LHS.trim().replace(stripParensRE, '').trim();
|
13679 | const trimmedOffset = LHS.indexOf(valueContent);
|
13680 | const iteratorMatch = valueContent.match(forIteratorRE);
|
13681 | if (iteratorMatch) {
|
13682 | valueContent = valueContent.replace(forIteratorRE, '').trim();
|
13683 | const keyContent = iteratorMatch[1].trim();
|
13684 | let keyOffset;
|
13685 | if (keyContent) {
|
13686 | keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
13687 | result.key = createAliasExpression(loc, keyContent, keyOffset);
|
13688 | {
|
13689 | validateBrowserExpression(result.key, context, true);
|
13690 | }
|
13691 | }
|
13692 | if (iteratorMatch[2]) {
|
13693 | const indexContent = iteratorMatch[2].trim();
|
13694 | if (indexContent) {
|
13695 | result.index = createAliasExpression(loc, indexContent, exp.indexOf(indexContent, result.key
|
13696 | ? keyOffset + keyContent.length
|
13697 | : trimmedOffset + valueContent.length));
|
13698 | {
|
13699 | validateBrowserExpression(result.index, context, true);
|
13700 | }
|
13701 | }
|
13702 | }
|
13703 | }
|
13704 | if (valueContent) {
|
13705 | result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
13706 | {
|
13707 | validateBrowserExpression(result.value, context, true);
|
13708 | }
|
13709 | }
|
13710 | return result;
|
13711 | }
|
13712 | function createAliasExpression(range, content, offset) {
|
13713 | return createSimpleExpression(content, false, getInnerRange(range, offset, content.length));
|
13714 | }
|
13715 | function createForLoopParams({ value, key, index }, memoArgs = []) {
|
13716 | return createParamsList([value, key, index, ...memoArgs]);
|
13717 | }
|
13718 | function createParamsList(args) {
|
13719 | let i = args.length;
|
13720 | while (i--) {
|
13721 | if (args[i])
|
13722 | break;
|
13723 | }
|
13724 | return args
|
13725 | .slice(0, i + 1)
|
13726 | .map((arg, i) => arg || createSimpleExpression(`_`.repeat(i + 1), false));
|
13727 | }
|
13728 |
|
13729 | const defaultFallback = createSimpleExpression(`undefined`, false);
|
13730 |
|
13731 |
|
13732 |
|
13733 |
|
13734 |
|
13735 |
|
13736 |
|
13737 | const trackSlotScopes = (node, context) => {
|
13738 | if (node.type === 1 &&
|
13739 | (node.tagType === 1 ||
|
13740 | node.tagType === 3 )) {
|
13741 |
|
13742 |
|
13743 | const vSlot = findDir(node, 'slot');
|
13744 | if (vSlot) {
|
13745 | vSlot.exp;
|
13746 | context.scopes.vSlot++;
|
13747 | return () => {
|
13748 | context.scopes.vSlot--;
|
13749 | };
|
13750 | }
|
13751 | }
|
13752 | };
|
13753 | const buildClientSlotFn = (props, children, loc) => createFunctionExpression(props, children, false , true , children.length ? children[0].loc : loc);
|
13754 |
|
13755 |
|
13756 | function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
13757 | context.helper(WITH_CTX);
|
13758 | const { children, loc } = node;
|
13759 | const slotsProperties = [];
|
13760 | const dynamicSlots = [];
|
13761 |
|
13762 |
|
13763 | let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
13764 |
|
13765 |
|
13766 | const onComponentSlot = findDir(node, 'slot', true);
|
13767 | if (onComponentSlot) {
|
13768 | const { arg, exp } = onComponentSlot;
|
13769 | if (arg && !isStaticExp(arg)) {
|
13770 | hasDynamicSlots = true;
|
13771 | }
|
13772 | slotsProperties.push(createObjectProperty(arg || createSimpleExpression('default', true), buildSlotFn(exp, children, loc)));
|
13773 | }
|
13774 |
|
13775 |
|
13776 | let hasTemplateSlots = false;
|
13777 | let hasNamedDefaultSlot = false;
|
13778 | const implicitDefaultChildren = [];
|
13779 | const seenSlotNames = new Set();
|
13780 | for (let i = 0; i < children.length; i++) {
|
13781 | const slotElement = children[i];
|
13782 | let slotDir;
|
13783 | if (!isTemplateNode(slotElement) ||
|
13784 | !(slotDir = findDir(slotElement, 'slot', true))) {
|
13785 |
|
13786 | if (slotElement.type !== 3 ) {
|
13787 | implicitDefaultChildren.push(slotElement);
|
13788 | }
|
13789 | continue;
|
13790 | }
|
13791 | if (onComponentSlot) {
|
13792 |
|
13793 | context.onError(createCompilerError(37 , slotDir.loc));
|
13794 | break;
|
13795 | }
|
13796 | hasTemplateSlots = true;
|
13797 | const { children: slotChildren, loc: slotLoc } = slotElement;
|
13798 | const { arg: slotName = createSimpleExpression(`default`, true), exp: slotProps, loc: dirLoc } = slotDir;
|
13799 |
|
13800 | let staticSlotName;
|
13801 | if (isStaticExp(slotName)) {
|
13802 | staticSlotName = slotName ? slotName.content : `default`;
|
13803 | }
|
13804 | else {
|
13805 | hasDynamicSlots = true;
|
13806 | }
|
13807 | const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
|
13808 |
|
13809 | let vIf;
|
13810 | let vElse;
|
13811 | let vFor;
|
13812 | if ((vIf = findDir(slotElement, 'if'))) {
|
13813 | hasDynamicSlots = true;
|
13814 | dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
|
13815 | }
|
13816 | else if ((vElse = findDir(slotElement, /^else(-if)?$/, true ))) {
|
13817 |
|
13818 | let j = i;
|
13819 | let prev;
|
13820 | while (j--) {
|
13821 | prev = children[j];
|
13822 | if (prev.type !== 3 ) {
|
13823 | break;
|
13824 | }
|
13825 | }
|
13826 | if (prev && isTemplateNode(prev) && findDir(prev, 'if')) {
|
13827 |
|
13828 | children.splice(i, 1);
|
13829 | i--;
|
13830 |
|
13831 | let conditional = dynamicSlots[dynamicSlots.length - 1];
|
13832 | while (conditional.alternate.type === 19 ) {
|
13833 | conditional = conditional.alternate;
|
13834 | }
|
13835 | conditional.alternate = vElse.exp
|
13836 | ? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback)
|
13837 | : buildDynamicSlot(slotName, slotFunction);
|
13838 | }
|
13839 | else {
|
13840 | context.onError(createCompilerError(30 , vElse.loc));
|
13841 | }
|
13842 | }
|
13843 | else if ((vFor = findDir(slotElement, 'for'))) {
|
13844 | hasDynamicSlots = true;
|
13845 | const parseResult = vFor.parseResult ||
|
13846 | parseForExpression(vFor.exp, context);
|
13847 | if (parseResult) {
|
13848 |
|
13849 |
|
13850 | dynamicSlots.push(createCallExpression(context.helper(RENDER_LIST), [
|
13851 | parseResult.source,
|
13852 | createFunctionExpression(createForLoopParams(parseResult), buildDynamicSlot(slotName, slotFunction), true )
|
13853 | ]));
|
13854 | }
|
13855 | else {
|
13856 | context.onError(createCompilerError(32 , vFor.loc));
|
13857 | }
|
13858 | }
|
13859 | else {
|
13860 |
|
13861 | if (staticSlotName) {
|
13862 | if (seenSlotNames.has(staticSlotName)) {
|
13863 | context.onError(createCompilerError(38 , dirLoc));
|
13864 | continue;
|
13865 | }
|
13866 | seenSlotNames.add(staticSlotName);
|
13867 | if (staticSlotName === 'default') {
|
13868 | hasNamedDefaultSlot = true;
|
13869 | }
|
13870 | }
|
13871 | slotsProperties.push(createObjectProperty(slotName, slotFunction));
|
13872 | }
|
13873 | }
|
13874 | if (!onComponentSlot) {
|
13875 | const buildDefaultSlotProperty = (props, children) => {
|
13876 | const fn = buildSlotFn(props, children, loc);
|
13877 | return createObjectProperty(`default`, fn);
|
13878 | };
|
13879 | if (!hasTemplateSlots) {
|
13880 |
|
13881 | slotsProperties.push(buildDefaultSlotProperty(undefined, children));
|
13882 | }
|
13883 | else if (implicitDefaultChildren.length &&
|
13884 |
|
13885 |
|
13886 |
|
13887 | implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
|
13888 |
|
13889 | if (hasNamedDefaultSlot) {
|
13890 | context.onError(createCompilerError(39 , implicitDefaultChildren[0].loc));
|
13891 | }
|
13892 | else {
|
13893 | slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
|
13894 | }
|
13895 | }
|
13896 | }
|
13897 | const slotFlag = hasDynamicSlots
|
13898 | ? 2
|
13899 | : hasForwardedSlots(node.children)
|
13900 | ? 3
|
13901 | : 1 ;
|
13902 | let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
|
13903 |
|
13904 |
|
13905 | createSimpleExpression(slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ), false))), loc);
|
13906 | if (dynamicSlots.length) {
|
13907 | slots = createCallExpression(context.helper(CREATE_SLOTS), [
|
13908 | slots,
|
13909 | createArrayExpression(dynamicSlots)
|
13910 | ]);
|
13911 | }
|
13912 | return {
|
13913 | slots,
|
13914 | hasDynamicSlots
|
13915 | };
|
13916 | }
|
13917 | function buildDynamicSlot(name, fn) {
|
13918 | return createObjectExpression([
|
13919 | createObjectProperty(`name`, name),
|
13920 | createObjectProperty(`fn`, fn)
|
13921 | ]);
|
13922 | }
|
13923 | function hasForwardedSlots(children) {
|
13924 | for (let i = 0; i < children.length; i++) {
|
13925 | const child = children[i];
|
13926 | switch (child.type) {
|
13927 | case 1 :
|
13928 | if (child.tagType === 2 ||
|
13929 | hasForwardedSlots(child.children)) {
|
13930 | return true;
|
13931 | }
|
13932 | break;
|
13933 | case 9 :
|
13934 | if (hasForwardedSlots(child.branches))
|
13935 | return true;
|
13936 | break;
|
13937 | case 10 :
|
13938 | case 11 :
|
13939 | if (hasForwardedSlots(child.children))
|
13940 | return true;
|
13941 | break;
|
13942 | }
|
13943 | }
|
13944 | return false;
|
13945 | }
|
13946 | function isNonWhitespaceContent(node) {
|
13947 | if (node.type !== 2 && node.type !== 12 )
|
13948 | return true;
|
13949 | return node.type === 2
|
13950 | ? !!node.content.trim()
|
13951 | : isNonWhitespaceContent(node.content);
|
13952 | }
|
13953 |
|
13954 |
|
13955 |
|
13956 | const directiveImportMap = new WeakMap();
|
13957 |
|
13958 | const transformElement = (node, context) => {
|
13959 |
|
13960 |
|
13961 | return function postTransformElement() {
|
13962 | node = context.currentNode;
|
13963 | if (!(node.type === 1 &&
|
13964 | (node.tagType === 0 ||
|
13965 | node.tagType === 1 ))) {
|
13966 | return;
|
13967 | }
|
13968 | const { tag, props } = node;
|
13969 | const isComponent = node.tagType === 1 ;
|
13970 |
|
13971 |
|
13972 | let vnodeTag = isComponent
|
13973 | ? resolveComponentType(node, context)
|
13974 | : `"${tag}"`;
|
13975 | const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
13976 | let vnodeProps;
|
13977 | let vnodeChildren;
|
13978 | let vnodePatchFlag;
|
13979 | let patchFlag = 0;
|
13980 | let vnodeDynamicProps;
|
13981 | let dynamicPropNames;
|
13982 | let vnodeDirectives;
|
13983 | let shouldUseBlock =
|
13984 |
|
13985 | isDynamicComponent ||
|
13986 | vnodeTag === TELEPORT ||
|
13987 | vnodeTag === SUSPENSE ||
|
13988 | (!isComponent &&
|
13989 |
|
13990 |
|
13991 |
|
13992 |
|
13993 | (tag === 'svg' ||
|
13994 | tag === 'foreignObject' ||
|
13995 |
|
13996 | findProp(node, 'key', true)));
|
13997 |
|
13998 | if (props.length > 0) {
|
13999 | const propsBuildResult = buildProps(node, context);
|
14000 | vnodeProps = propsBuildResult.props;
|
14001 | patchFlag = propsBuildResult.patchFlag;
|
14002 | dynamicPropNames = propsBuildResult.dynamicPropNames;
|
14003 | const directives = propsBuildResult.directives;
|
14004 | vnodeDirectives =
|
14005 | directives && directives.length
|
14006 | ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
|
14007 | : undefined;
|
14008 | }
|
14009 |
|
14010 | if (node.children.length > 0) {
|
14011 | if (vnodeTag === KEEP_ALIVE) {
|
14012 |
|
14013 |
|
14014 |
|
14015 |
|
14016 |
|
14017 |
|
14018 | shouldUseBlock = true;
|
14019 |
|
14020 | patchFlag |= 1024 ;
|
14021 | if (node.children.length > 1) {
|
14022 | context.onError(createCompilerError(45 , {
|
14023 | start: node.children[0].loc.start,
|
14024 | end: node.children[node.children.length - 1].loc.end,
|
14025 | source: ''
|
14026 | }));
|
14027 | }
|
14028 | }
|
14029 | const shouldBuildAsSlots = isComponent &&
|
14030 |
|
14031 | vnodeTag !== TELEPORT &&
|
14032 |
|
14033 | vnodeTag !== KEEP_ALIVE;
|
14034 | if (shouldBuildAsSlots) {
|
14035 | const { slots, hasDynamicSlots } = buildSlots(node, context);
|
14036 | vnodeChildren = slots;
|
14037 | if (hasDynamicSlots) {
|
14038 | patchFlag |= 1024 ;
|
14039 | }
|
14040 | }
|
14041 | else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
14042 | const child = node.children[0];
|
14043 | const type = child.type;
|
14044 |
|
14045 | const hasDynamicTextChild = type === 5 ||
|
14046 | type === 8 ;
|
14047 | if (hasDynamicTextChild &&
|
14048 | getConstantType(child, context) === 0 ) {
|
14049 | patchFlag |= 1 ;
|
14050 | }
|
14051 |
|
14052 |
|
14053 | if (hasDynamicTextChild || type === 2 ) {
|
14054 | vnodeChildren = child;
|
14055 | }
|
14056 | else {
|
14057 | vnodeChildren = node.children;
|
14058 | }
|
14059 | }
|
14060 | else {
|
14061 | vnodeChildren = node.children;
|
14062 | }
|
14063 | }
|
14064 |
|
14065 | if (patchFlag !== 0) {
|
14066 | {
|
14067 | if (patchFlag < 0) {
|
14068 |
|
14069 | vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
|
14070 | }
|
14071 | else {
|
14072 |
|
14073 | const flagNames = Object.keys(PatchFlagNames)
|
14074 | .map(Number)
|
14075 | .filter(n => n > 0 && patchFlag & n)
|
14076 | .map(n => PatchFlagNames[n])
|
14077 | .join(`, `);
|
14078 | vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
|
14079 | }
|
14080 | }
|
14081 | if (dynamicPropNames && dynamicPropNames.length) {
|
14082 | vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
|
14083 | }
|
14084 | }
|
14085 | node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, vnodePatchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false , isComponent, node.loc);
|
14086 | };
|
14087 | };
|
14088 | function resolveComponentType(node, context, ssr = false) {
|
14089 | let { tag } = node;
|
14090 |
|
14091 | const isExplicitDynamic = isComponentTag(tag);
|
14092 | const isProp = findProp(node, 'is');
|
14093 | if (isProp) {
|
14094 | if (isExplicitDynamic ||
|
14095 | (false )) {
|
14096 | const exp = isProp.type === 6
|
14097 | ? isProp.value && createSimpleExpression(isProp.value.content, true)
|
14098 | : isProp.exp;
|
14099 | if (exp) {
|
14100 | return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
14101 | exp
|
14102 | ]);
|
14103 | }
|
14104 | }
|
14105 | else if (isProp.type === 6 &&
|
14106 | isProp.value.content.startsWith('vue:')) {
|
14107 |
|
14108 |
|
14109 |
|
14110 |
|
14111 | tag = isProp.value.content.slice(4);
|
14112 | }
|
14113 | }
|
14114 |
|
14115 | const isDir = !isExplicitDynamic && findDir(node, 'is');
|
14116 | if (isDir && isDir.exp) {
|
14117 | return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
14118 | isDir.exp
|
14119 | ]);
|
14120 | }
|
14121 |
|
14122 | const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
14123 | if (builtIn) {
|
14124 |
|
14125 |
|
14126 | if (!ssr)
|
14127 | context.helper(builtIn);
|
14128 | return builtIn;
|
14129 | }
|
14130 |
|
14131 | context.helper(RESOLVE_COMPONENT);
|
14132 | context.components.add(tag);
|
14133 | return toValidAssetId(tag, `component`);
|
14134 | }
|
14135 | function buildProps(node, context, props = node.props, ssr = false) {
|
14136 | const { tag, loc: elementLoc } = node;
|
14137 | const isComponent = node.tagType === 1 ;
|
14138 | let properties = [];
|
14139 | const mergeArgs = [];
|
14140 | const runtimeDirectives = [];
|
14141 |
|
14142 | let patchFlag = 0;
|
14143 | let hasRef = false;
|
14144 | let hasClassBinding = false;
|
14145 | let hasStyleBinding = false;
|
14146 | let hasHydrationEventBinding = false;
|
14147 | let hasDynamicKeys = false;
|
14148 | let hasVnodeHook = false;
|
14149 | const dynamicPropNames = [];
|
14150 | const analyzePatchFlag = ({ key, value }) => {
|
14151 | if (isStaticExp(key)) {
|
14152 | const name = key.content;
|
14153 | const isEventHandler = isOn(name);
|
14154 | if (!isComponent &&
|
14155 | isEventHandler &&
|
14156 |
|
14157 |
|
14158 | name.toLowerCase() !== 'onclick' &&
|
14159 |
|
14160 | name !== 'onUpdate:modelValue' &&
|
14161 |
|
14162 | !isReservedProp(name)) {
|
14163 | hasHydrationEventBinding = true;
|
14164 | }
|
14165 | if (isEventHandler && isReservedProp(name)) {
|
14166 | hasVnodeHook = true;
|
14167 | }
|
14168 | if (value.type === 20 ||
|
14169 | ((value.type === 4 ||
|
14170 | value.type === 8 ) &&
|
14171 | getConstantType(value, context) > 0)) {
|
14172 |
|
14173 | return;
|
14174 | }
|
14175 | if (name === 'ref') {
|
14176 | hasRef = true;
|
14177 | }
|
14178 | else if (name === 'class') {
|
14179 | hasClassBinding = true;
|
14180 | }
|
14181 | else if (name === 'style') {
|
14182 | hasStyleBinding = true;
|
14183 | }
|
14184 | else if (name !== 'key' && !dynamicPropNames.includes(name)) {
|
14185 | dynamicPropNames.push(name);
|
14186 | }
|
14187 |
|
14188 | if (isComponent &&
|
14189 | (name === 'class' || name === 'style') &&
|
14190 | !dynamicPropNames.includes(name)) {
|
14191 | dynamicPropNames.push(name);
|
14192 | }
|
14193 | }
|
14194 | else {
|
14195 | hasDynamicKeys = true;
|
14196 | }
|
14197 | };
|
14198 | for (let i = 0; i < props.length; i++) {
|
14199 |
|
14200 | const prop = props[i];
|
14201 | if (prop.type === 6 ) {
|
14202 | const { loc, name, value } = prop;
|
14203 | let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
|
14204 | if (name === 'ref') {
|
14205 | hasRef = true;
|
14206 | }
|
14207 |
|
14208 | if (name === 'is' &&
|
14209 | (isComponentTag(tag) ||
|
14210 | (value && value.content.startsWith('vue:')) ||
|
14211 | (false ))) {
|
14212 | continue;
|
14213 | }
|
14214 | properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
|
14215 | }
|
14216 | else {
|
14217 |
|
14218 | const { name, arg, exp, loc } = prop;
|
14219 | const isVBind = name === 'bind';
|
14220 | const isVOn = name === 'on';
|
14221 |
|
14222 | if (name === 'slot') {
|
14223 | if (!isComponent) {
|
14224 | context.onError(createCompilerError(40 , loc));
|
14225 | }
|
14226 | continue;
|
14227 | }
|
14228 |
|
14229 | if (name === 'once' || name === 'memo') {
|
14230 | continue;
|
14231 | }
|
14232 |
|
14233 | if (name === 'is' ||
|
14234 | (isVBind &&
|
14235 | isBindKey(arg, 'is') &&
|
14236 | (isComponentTag(tag) ||
|
14237 | (false )))) {
|
14238 | continue;
|
14239 | }
|
14240 |
|
14241 | if (isVOn && ssr) {
|
14242 | continue;
|
14243 | }
|
14244 |
|
14245 | if (!arg && (isVBind || isVOn)) {
|
14246 | hasDynamicKeys = true;
|
14247 | if (exp) {
|
14248 | if (properties.length) {
|
14249 | mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
|
14250 | properties = [];
|
14251 | }
|
14252 | if (isVBind) {
|
14253 | mergeArgs.push(exp);
|
14254 | }
|
14255 | else {
|
14256 |
|
14257 | mergeArgs.push({
|
14258 | type: 14 ,
|
14259 | loc,
|
14260 | callee: context.helper(TO_HANDLERS),
|
14261 | arguments: [exp]
|
14262 | });
|
14263 | }
|
14264 | }
|
14265 | else {
|
14266 | context.onError(createCompilerError(isVBind
|
14267 | ? 34
|
14268 | : 35 , loc));
|
14269 | }
|
14270 | continue;
|
14271 | }
|
14272 | const directiveTransform = context.directiveTransforms[name];
|
14273 | if (directiveTransform) {
|
14274 |
|
14275 | const { props, needRuntime } = directiveTransform(prop, node, context);
|
14276 | !ssr && props.forEach(analyzePatchFlag);
|
14277 | properties.push(...props);
|
14278 | if (needRuntime) {
|
14279 | runtimeDirectives.push(prop);
|
14280 | if (isSymbol(needRuntime)) {
|
14281 | directiveImportMap.set(prop, needRuntime);
|
14282 | }
|
14283 | }
|
14284 | }
|
14285 | else {
|
14286 |
|
14287 | runtimeDirectives.push(prop);
|
14288 | }
|
14289 | }
|
14290 | }
|
14291 | let propsExpression = undefined;
|
14292 |
|
14293 | if (mergeArgs.length) {
|
14294 | if (properties.length) {
|
14295 | mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
|
14296 | }
|
14297 | if (mergeArgs.length > 1) {
|
14298 | propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
|
14299 | }
|
14300 | else {
|
14301 |
|
14302 | propsExpression = mergeArgs[0];
|
14303 | }
|
14304 | }
|
14305 | else if (properties.length) {
|
14306 | propsExpression = createObjectExpression(dedupeProperties(properties), elementLoc);
|
14307 | }
|
14308 |
|
14309 | if (hasDynamicKeys) {
|
14310 | patchFlag |= 16 ;
|
14311 | }
|
14312 | else {
|
14313 | if (hasClassBinding && !isComponent) {
|
14314 | patchFlag |= 2 ;
|
14315 | }
|
14316 | if (hasStyleBinding && !isComponent) {
|
14317 | patchFlag |= 4 ;
|
14318 | }
|
14319 | if (dynamicPropNames.length) {
|
14320 | patchFlag |= 8 ;
|
14321 | }
|
14322 | if (hasHydrationEventBinding) {
|
14323 | patchFlag |= 32 ;
|
14324 | }
|
14325 | }
|
14326 | if ((patchFlag === 0 || patchFlag === 32 ) &&
|
14327 | (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
14328 | patchFlag |= 512 ;
|
14329 | }
|
14330 |
|
14331 | if (!context.inSSR && propsExpression) {
|
14332 | switch (propsExpression.type) {
|
14333 | case 15 :
|
14334 |
|
14335 |
|
14336 | let classKeyIndex = -1;
|
14337 | let styleKeyIndex = -1;
|
14338 | let hasDynamicKey = false;
|
14339 | for (let i = 0; i < propsExpression.properties.length; i++) {
|
14340 | const key = propsExpression.properties[i].key;
|
14341 | if (isStaticExp(key)) {
|
14342 | if (key.content === 'class') {
|
14343 | classKeyIndex = i;
|
14344 | }
|
14345 | else if (key.content === 'style') {
|
14346 | styleKeyIndex = i;
|
14347 | }
|
14348 | }
|
14349 | else if (!key.isHandlerKey) {
|
14350 | hasDynamicKey = true;
|
14351 | }
|
14352 | }
|
14353 | const classProp = propsExpression.properties[classKeyIndex];
|
14354 | const styleProp = propsExpression.properties[styleKeyIndex];
|
14355 |
|
14356 | if (!hasDynamicKey) {
|
14357 | if (classProp && !isStaticExp(classProp.value)) {
|
14358 | classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
14359 | }
|
14360 | if (styleProp &&
|
14361 | !isStaticExp(styleProp.value) &&
|
14362 |
|
14363 |
|
14364 | (hasStyleBinding ||
|
14365 |
|
14366 |
|
14367 | styleProp.value.type === 17 )) {
|
14368 | styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
|
14369 | }
|
14370 | }
|
14371 | else {
|
14372 |
|
14373 | propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
|
14374 | }
|
14375 | break;
|
14376 | case 14 :
|
14377 |
|
14378 | break;
|
14379 | default:
|
14380 |
|
14381 | propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [
|
14382 | createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
|
14383 | propsExpression
|
14384 | ])
|
14385 | ]);
|
14386 | break;
|
14387 | }
|
14388 | }
|
14389 | return {
|
14390 | props: propsExpression,
|
14391 | directives: runtimeDirectives,
|
14392 | patchFlag,
|
14393 | dynamicPropNames
|
14394 | };
|
14395 | }
|
14396 |
|
14397 |
|
14398 |
|
14399 |
|
14400 |
|
14401 |
|
14402 | function dedupeProperties(properties) {
|
14403 | const knownProps = new Map();
|
14404 | const deduped = [];
|
14405 | for (let i = 0; i < properties.length; i++) {
|
14406 | const prop = properties[i];
|
14407 |
|
14408 | if (prop.key.type === 8 || !prop.key.isStatic) {
|
14409 | deduped.push(prop);
|
14410 | continue;
|
14411 | }
|
14412 | const name = prop.key.content;
|
14413 | const existing = knownProps.get(name);
|
14414 | if (existing) {
|
14415 | if (name === 'style' || name === 'class' || isOn(name)) {
|
14416 | mergeAsArray$1(existing, prop);
|
14417 | }
|
14418 |
|
14419 | }
|
14420 | else {
|
14421 | knownProps.set(name, prop);
|
14422 | deduped.push(prop);
|
14423 | }
|
14424 | }
|
14425 | return deduped;
|
14426 | }
|
14427 | function mergeAsArray$1(existing, incoming) {
|
14428 | if (existing.value.type === 17 ) {
|
14429 | existing.value.elements.push(incoming.value);
|
14430 | }
|
14431 | else {
|
14432 | existing.value = createArrayExpression([existing.value, incoming.value], existing.loc);
|
14433 | }
|
14434 | }
|
14435 | function buildDirectiveArgs(dir, context) {
|
14436 | const dirArgs = [];
|
14437 | const runtime = directiveImportMap.get(dir);
|
14438 | if (runtime) {
|
14439 |
|
14440 | dirArgs.push(context.helperString(runtime));
|
14441 | }
|
14442 | else {
|
14443 | {
|
14444 |
|
14445 | context.helper(RESOLVE_DIRECTIVE);
|
14446 | context.directives.add(dir.name);
|
14447 | dirArgs.push(toValidAssetId(dir.name, `directive`));
|
14448 | }
|
14449 | }
|
14450 | const { loc } = dir;
|
14451 | if (dir.exp)
|
14452 | dirArgs.push(dir.exp);
|
14453 | if (dir.arg) {
|
14454 | if (!dir.exp) {
|
14455 | dirArgs.push(`void 0`);
|
14456 | }
|
14457 | dirArgs.push(dir.arg);
|
14458 | }
|
14459 | if (Object.keys(dir.modifiers).length) {
|
14460 | if (!dir.arg) {
|
14461 | if (!dir.exp) {
|
14462 | dirArgs.push(`void 0`);
|
14463 | }
|
14464 | dirArgs.push(`void 0`);
|
14465 | }
|
14466 | const trueExpression = createSimpleExpression(`true`, false, loc);
|
14467 | dirArgs.push(createObjectExpression(dir.modifiers.map(modifier => createObjectProperty(modifier, trueExpression)), loc));
|
14468 | }
|
14469 | return createArrayExpression(dirArgs, dir.loc);
|
14470 | }
|
14471 | function stringifyDynamicPropNames(props) {
|
14472 | let propsNamesString = `[`;
|
14473 | for (let i = 0, l = props.length; i < l; i++) {
|
14474 | propsNamesString += JSON.stringify(props[i]);
|
14475 | if (i < l - 1)
|
14476 | propsNamesString += ', ';
|
14477 | }
|
14478 | return propsNamesString + `]`;
|
14479 | }
|
14480 | function isComponentTag(tag) {
|
14481 | return tag[0].toLowerCase() + tag.slice(1) === 'component';
|
14482 | }
|
14483 |
|
14484 | const transformSlotOutlet = (node, context) => {
|
14485 | if (isSlotOutlet(node)) {
|
14486 | const { children, loc } = node;
|
14487 | const { slotName, slotProps } = processSlotOutlet(node, context);
|
14488 | const slotArgs = [
|
14489 | context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
|
14490 | slotName,
|
14491 | '{}',
|
14492 | 'undefined',
|
14493 | 'true'
|
14494 | ];
|
14495 | let expectedLen = 2;
|
14496 | if (slotProps) {
|
14497 | slotArgs[2] = slotProps;
|
14498 | expectedLen = 3;
|
14499 | }
|
14500 | if (children.length) {
|
14501 | slotArgs[3] = createFunctionExpression([], children, false, false, loc);
|
14502 | expectedLen = 4;
|
14503 | }
|
14504 | if (context.scopeId && !context.slotted) {
|
14505 | expectedLen = 5;
|
14506 | }
|
14507 | slotArgs.splice(expectedLen);
|
14508 | node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
|
14509 | }
|
14510 | };
|
14511 | function processSlotOutlet(node, context) {
|
14512 | let slotName = `"default"`;
|
14513 | let slotProps = undefined;
|
14514 | const nonNameProps = [];
|
14515 | for (let i = 0; i < node.props.length; i++) {
|
14516 | const p = node.props[i];
|
14517 | if (p.type === 6 ) {
|
14518 | if (p.value) {
|
14519 | if (p.name === 'name') {
|
14520 | slotName = JSON.stringify(p.value.content);
|
14521 | }
|
14522 | else {
|
14523 | p.name = camelize(p.name);
|
14524 | nonNameProps.push(p);
|
14525 | }
|
14526 | }
|
14527 | }
|
14528 | else {
|
14529 | if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
|
14530 | if (p.exp)
|
14531 | slotName = p.exp;
|
14532 | }
|
14533 | else {
|
14534 | if (p.name === 'bind' && p.arg && isStaticExp(p.arg)) {
|
14535 | p.arg.content = camelize(p.arg.content);
|
14536 | }
|
14537 | nonNameProps.push(p);
|
14538 | }
|
14539 | }
|
14540 | }
|
14541 | if (nonNameProps.length > 0) {
|
14542 | const { props, directives } = buildProps(node, context, nonNameProps);
|
14543 | slotProps = props;
|
14544 | if (directives.length) {
|
14545 | context.onError(createCompilerError(36 , directives[0].loc));
|
14546 | }
|
14547 | }
|
14548 | return {
|
14549 | slotName,
|
14550 | slotProps
|
14551 | };
|
14552 | }
|
14553 |
|
14554 | const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
14555 | const transformOn = (dir, node, context, augmentor) => {
|
14556 | const { loc, modifiers, arg } = dir;
|
14557 | if (!dir.exp && !modifiers.length) {
|
14558 | context.onError(createCompilerError(35 , loc));
|
14559 | }
|
14560 | let eventName;
|
14561 | if (arg.type === 4 ) {
|
14562 | if (arg.isStatic) {
|
14563 | const rawName = arg.content;
|
14564 |
|
14565 | eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
|
14566 | }
|
14567 | else {
|
14568 |
|
14569 | eventName = createCompoundExpression([
|
14570 | `${context.helperString(TO_HANDLER_KEY)}(`,
|
14571 | arg,
|
14572 | `)`
|
14573 | ]);
|
14574 | }
|
14575 | }
|
14576 | else {
|
14577 |
|
14578 | eventName = arg;
|
14579 | eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
|
14580 | eventName.children.push(`)`);
|
14581 | }
|
14582 |
|
14583 | let exp = dir.exp;
|
14584 | if (exp && !exp.content.trim()) {
|
14585 | exp = undefined;
|
14586 | }
|
14587 | let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
|
14588 | if (exp) {
|
14589 | const isMemberExp = isMemberExpression(exp.content);
|
14590 | const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
|
14591 | const hasMultipleStatements = exp.content.includes(`;`);
|
14592 | {
|
14593 | validateBrowserExpression(exp, context, false, hasMultipleStatements);
|
14594 | }
|
14595 | if (isInlineStatement || (shouldCache && isMemberExp)) {
|
14596 |
|
14597 | exp = createCompoundExpression([
|
14598 | `${isInlineStatement
|
14599 | ? `$event`
|
14600 | : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
|
14601 | exp,
|
14602 | hasMultipleStatements ? `}` : `)`
|
14603 | ]);
|
14604 | }
|
14605 | }
|
14606 | let ret = {
|
14607 | props: [
|
14608 | createObjectProperty(eventName, exp || createSimpleExpression(`() => {}`, false, loc))
|
14609 | ]
|
14610 | };
|
14611 |
|
14612 | if (augmentor) {
|
14613 | ret = augmentor(ret);
|
14614 | }
|
14615 | if (shouldCache) {
|
14616 |
|
14617 |
|
14618 |
|
14619 | ret.props[0].value = context.cache(ret.props[0].value);
|
14620 | }
|
14621 |
|
14622 | ret.props.forEach(p => (p.key.isHandlerKey = true));
|
14623 | return ret;
|
14624 | };
|
14625 |
|
14626 |
|
14627 |
|
14628 |
|
14629 | const transformBind = (dir, _node, context) => {
|
14630 | const { exp, modifiers, loc } = dir;
|
14631 | const arg = dir.arg;
|
14632 | if (arg.type !== 4 ) {
|
14633 | arg.children.unshift(`(`);
|
14634 | arg.children.push(`) || ""`);
|
14635 | }
|
14636 | else if (!arg.isStatic) {
|
14637 | arg.content = `${arg.content} || ""`;
|
14638 | }
|
14639 |
|
14640 | if (modifiers.includes('camel')) {
|
14641 | if (arg.type === 4 ) {
|
14642 | if (arg.isStatic) {
|
14643 | arg.content = camelize(arg.content);
|
14644 | }
|
14645 | else {
|
14646 | arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
14647 | }
|
14648 | }
|
14649 | else {
|
14650 | arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
14651 | arg.children.push(`)`);
|
14652 | }
|
14653 | }
|
14654 | if (!context.inSSR) {
|
14655 | if (modifiers.includes('prop')) {
|
14656 | injectPrefix(arg, '.');
|
14657 | }
|
14658 | if (modifiers.includes('attr')) {
|
14659 | injectPrefix(arg, '^');
|
14660 | }
|
14661 | }
|
14662 | if (!exp ||
|
14663 | (exp.type === 4 && !exp.content.trim())) {
|
14664 | context.onError(createCompilerError(34 , loc));
|
14665 | return {
|
14666 | props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
|
14667 | };
|
14668 | }
|
14669 | return {
|
14670 | props: [createObjectProperty(arg, exp)]
|
14671 | };
|
14672 | };
|
14673 | const injectPrefix = (arg, prefix) => {
|
14674 | if (arg.type === 4 ) {
|
14675 | if (arg.isStatic) {
|
14676 | arg.content = prefix + arg.content;
|
14677 | }
|
14678 | else {
|
14679 | arg.content = `\`${prefix}\${${arg.content}}\``;
|
14680 | }
|
14681 | }
|
14682 | else {
|
14683 | arg.children.unshift(`'${prefix}' + (`);
|
14684 | arg.children.push(`)`);
|
14685 | }
|
14686 | };
|
14687 |
|
14688 |
|
14689 |
|
14690 | const transformText = (node, context) => {
|
14691 | if (node.type === 0 ||
|
14692 | node.type === 1 ||
|
14693 | node.type === 11 ||
|
14694 | node.type === 10 ) {
|
14695 |
|
14696 |
|
14697 | return () => {
|
14698 | const children = node.children;
|
14699 | let currentContainer = undefined;
|
14700 | let hasText = false;
|
14701 | for (let i = 0; i < children.length; i++) {
|
14702 | const child = children[i];
|
14703 | if (isText(child)) {
|
14704 | hasText = true;
|
14705 | for (let j = i + 1; j < children.length; j++) {
|
14706 | const next = children[j];
|
14707 | if (isText(next)) {
|
14708 | if (!currentContainer) {
|
14709 | currentContainer = children[i] = {
|
14710 | type: 8 ,
|
14711 | loc: child.loc,
|
14712 | children: [child]
|
14713 | };
|
14714 | }
|
14715 |
|
14716 | currentContainer.children.push(` + `, next);
|
14717 | children.splice(j, 1);
|
14718 | j--;
|
14719 | }
|
14720 | else {
|
14721 | currentContainer = undefined;
|
14722 | break;
|
14723 | }
|
14724 | }
|
14725 | }
|
14726 | }
|
14727 | if (!hasText ||
|
14728 |
|
14729 |
|
14730 |
|
14731 |
|
14732 | (children.length === 1 &&
|
14733 | (node.type === 0 ||
|
14734 | (node.type === 1 &&
|
14735 | node.tagType === 0 &&
|
14736 |
|
14737 |
|
14738 |
|
14739 |
|
14740 |
|
14741 | !node.props.find(p => p.type === 7 &&
|
14742 | !context.directiveTransforms[p.name]) &&
|
14743 |
|
14744 |
|
14745 |
|
14746 | !(false ))))) {
|
14747 | return;
|
14748 | }
|
14749 |
|
14750 |
|
14751 | for (let i = 0; i < children.length; i++) {
|
14752 | const child = children[i];
|
14753 | if (isText(child) || child.type === 8 ) {
|
14754 | const callArgs = [];
|
14755 |
|
14756 |
|
14757 | if (child.type !== 2 || child.content !== ' ') {
|
14758 | callArgs.push(child);
|
14759 | }
|
14760 |
|
14761 | if (!context.ssr &&
|
14762 | getConstantType(child, context) === 0 ) {
|
14763 | callArgs.push(1 +
|
14764 | (` /* ${PatchFlagNames[1 /* TEXT */]} */` ));
|
14765 | }
|
14766 | children[i] = {
|
14767 | type: 12 ,
|
14768 | content: child,
|
14769 | loc: child.loc,
|
14770 | codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
|
14771 | };
|
14772 | }
|
14773 | }
|
14774 | };
|
14775 | }
|
14776 | };
|
14777 |
|
14778 | const seen = new WeakSet();
|
14779 | const transformOnce = (node, context) => {
|
14780 | if (node.type === 1 && findDir(node, 'once', true)) {
|
14781 | if (seen.has(node) || context.inVOnce) {
|
14782 | return;
|
14783 | }
|
14784 | seen.add(node);
|
14785 | context.inVOnce = true;
|
14786 | context.helper(SET_BLOCK_TRACKING);
|
14787 | return () => {
|
14788 | context.inVOnce = false;
|
14789 | const cur = context.currentNode;
|
14790 | if (cur.codegenNode) {
|
14791 | cur.codegenNode = context.cache(cur.codegenNode, true );
|
14792 | }
|
14793 | };
|
14794 | }
|
14795 | };
|
14796 |
|
14797 | const transformModel = (dir, node, context) => {
|
14798 | const { exp, arg } = dir;
|
14799 | if (!exp) {
|
14800 | context.onError(createCompilerError(41 , dir.loc));
|
14801 | return createTransformProps();
|
14802 | }
|
14803 | const rawExp = exp.loc.source;
|
14804 | const expString = exp.type === 4 ? exp.content : rawExp;
|
14805 |
|
14806 |
|
14807 | context.bindingMetadata[rawExp];
|
14808 | const maybeRef = !true ;
|
14809 | if (!expString.trim() ||
|
14810 | (!isMemberExpression(expString) && !maybeRef)) {
|
14811 | context.onError(createCompilerError(42 , exp.loc));
|
14812 | return createTransformProps();
|
14813 | }
|
14814 | const propName = arg ? arg : createSimpleExpression('modelValue', true);
|
14815 | const eventName = arg
|
14816 | ? isStaticExp(arg)
|
14817 | ? `onUpdate:${arg.content}`
|
14818 | : createCompoundExpression(['"onUpdate:" + ', arg])
|
14819 | : `onUpdate:modelValue`;
|
14820 | let assignmentExp;
|
14821 | const eventArg = context.isTS ? `($event: any)` : `$event`;
|
14822 | {
|
14823 | assignmentExp = createCompoundExpression([
|
14824 | `${eventArg} => ((`,
|
14825 | exp,
|
14826 | `) = $event)`
|
14827 | ]);
|
14828 | }
|
14829 | const props = [
|
14830 |
|
14831 | createObjectProperty(propName, dir.exp),
|
14832 |
|
14833 | createObjectProperty(eventName, assignmentExp)
|
14834 | ];
|
14835 |
|
14836 | if (dir.modifiers.length && node.tagType === 1 ) {
|
14837 | const modifiers = dir.modifiers
|
14838 | .map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
|
14839 | .join(`, `);
|
14840 | const modifiersKey = arg
|
14841 | ? isStaticExp(arg)
|
14842 | ? `${arg.content}Modifiers`
|
14843 | : createCompoundExpression([arg, ' + "Modifiers"'])
|
14844 | : `modelModifiers`;
|
14845 | props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 )));
|
14846 | }
|
14847 | return createTransformProps(props);
|
14848 | };
|
14849 | function createTransformProps(props = []) {
|
14850 | return { props };
|
14851 | }
|
14852 |
|
14853 | const seen$1 = new WeakSet();
|
14854 | const transformMemo = (node, context) => {
|
14855 | if (node.type === 1 ) {
|
14856 | const dir = findDir(node, 'memo');
|
14857 | if (!dir || seen$1.has(node)) {
|
14858 | return;
|
14859 | }
|
14860 | seen$1.add(node);
|
14861 | return () => {
|
14862 | const codegenNode = node.codegenNode ||
|
14863 | context.currentNode.codegenNode;
|
14864 | if (codegenNode && codegenNode.type === 13 ) {
|
14865 |
|
14866 | if (node.tagType !== 1 ) {
|
14867 | makeBlock(codegenNode, context);
|
14868 | }
|
14869 | node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
14870 | dir.exp,
|
14871 | createFunctionExpression(undefined, codegenNode),
|
14872 | `_cache`,
|
14873 | String(context.cached++)
|
14874 | ]);
|
14875 | }
|
14876 | };
|
14877 | }
|
14878 | };
|
14879 |
|
14880 | function getBaseTransformPreset(prefixIdentifiers) {
|
14881 | return [
|
14882 | [
|
14883 | transformOnce,
|
14884 | transformIf,
|
14885 | transformMemo,
|
14886 | transformFor,
|
14887 | ...([]),
|
14888 | ...([transformExpression]
|
14889 | ),
|
14890 | transformSlotOutlet,
|
14891 | transformElement,
|
14892 | trackSlotScopes,
|
14893 | transformText
|
14894 | ],
|
14895 | {
|
14896 | on: transformOn,
|
14897 | bind: transformBind,
|
14898 | model: transformModel
|
14899 | }
|
14900 | ];
|
14901 | }
|
14902 |
|
14903 |
|
14904 | function baseCompile(template, options = {}) {
|
14905 | const onError = options.onError || defaultOnError;
|
14906 | const isModuleMode = options.mode === 'module';
|
14907 |
|
14908 | {
|
14909 | if (options.prefixIdentifiers === true) {
|
14910 | onError(createCompilerError(46 ));
|
14911 | }
|
14912 | else if (isModuleMode) {
|
14913 | onError(createCompilerError(47 ));
|
14914 | }
|
14915 | }
|
14916 | const prefixIdentifiers = !true ;
|
14917 | if (options.cacheHandlers) {
|
14918 | onError(createCompilerError(48 ));
|
14919 | }
|
14920 | if (options.scopeId && !isModuleMode) {
|
14921 | onError(createCompilerError(49 ));
|
14922 | }
|
14923 | const ast = isString(template) ? baseParse(template, options) : template;
|
14924 | const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
14925 | transform(ast, extend({}, options, {
|
14926 | prefixIdentifiers,
|
14927 | nodeTransforms: [
|
14928 | ...nodeTransforms,
|
14929 | ...(options.nodeTransforms || [])
|
14930 | ],
|
14931 | directiveTransforms: extend({}, directiveTransforms, options.directiveTransforms || {}
|
14932 | )
|
14933 | }));
|
14934 | return generate(ast, extend({}, options, {
|
14935 | prefixIdentifiers
|
14936 | }));
|
14937 | }
|
14938 |
|
14939 | const noopDirectiveTransform = () => ({ props: [] });
|
14940 |
|
14941 | const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
14942 | const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
|
14943 | const V_MODEL_TEXT = Symbol(`vModelText` );
|
14944 | const V_MODEL_SELECT = Symbol(`vModelSelect` );
|
14945 | const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
|
14946 | const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
|
14947 | const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
|
14948 | const V_SHOW = Symbol(`vShow` );
|
14949 | const TRANSITION$1 = Symbol(`Transition` );
|
14950 | const TRANSITION_GROUP = Symbol(`TransitionGroup` );
|
14951 | registerRuntimeHelpers({
|
14952 | [V_MODEL_RADIO]: `vModelRadio`,
|
14953 | [V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
14954 | [V_MODEL_TEXT]: `vModelText`,
|
14955 | [V_MODEL_SELECT]: `vModelSelect`,
|
14956 | [V_MODEL_DYNAMIC]: `vModelDynamic`,
|
14957 | [V_ON_WITH_MODIFIERS]: `withModifiers`,
|
14958 | [V_ON_WITH_KEYS]: `withKeys`,
|
14959 | [V_SHOW]: `vShow`,
|
14960 | [TRANSITION$1]: `Transition`,
|
14961 | [TRANSITION_GROUP]: `TransitionGroup`
|
14962 | });
|
14963 |
|
14964 |
|
14965 | let decoder;
|
14966 | function decodeHtmlBrowser(raw, asAttr = false) {
|
14967 | if (!decoder) {
|
14968 | decoder = document.createElement('div');
|
14969 | }
|
14970 | if (asAttr) {
|
14971 | decoder.innerHTML = `<div foo="${raw.replace(/"/g, '"')}">`;
|
14972 | return decoder.children[0].getAttribute('foo');
|
14973 | }
|
14974 | else {
|
14975 | decoder.innerHTML = raw;
|
14976 | return decoder.textContent;
|
14977 | }
|
14978 | }
|
14979 |
|
14980 | const isRawTextContainer = makeMap('style,iframe,script,noscript', true);
|
14981 | const parserOptions = {
|
14982 | isVoidTag,
|
14983 | isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag),
|
14984 | isPreTag: tag => tag === 'pre',
|
14985 | decodeEntities: decodeHtmlBrowser ,
|
14986 | isBuiltInComponent: (tag) => {
|
14987 | if (isBuiltInType(tag, `Transition`)) {
|
14988 | return TRANSITION$1;
|
14989 | }
|
14990 | else if (isBuiltInType(tag, `TransitionGroup`)) {
|
14991 | return TRANSITION_GROUP;
|
14992 | }
|
14993 | },
|
14994 |
|
14995 | getNamespace(tag, parent) {
|
14996 | let ns = parent ? parent.ns : 0 ;
|
14997 | if (parent && ns === 2 ) {
|
14998 | if (parent.tag === 'annotation-xml') {
|
14999 | if (tag === 'svg') {
|
15000 | return 1 ;
|
15001 | }
|
15002 | if (parent.props.some(a => a.type === 6 &&
|
15003 | a.name === 'encoding' &&
|
15004 | a.value != null &&
|
15005 | (a.value.content === 'text/html' ||
|
15006 | a.value.content === 'application/xhtml+xml'))) {
|
15007 | ns = 0 ;
|
15008 | }
|
15009 | }
|
15010 | else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
|
15011 | tag !== 'mglyph' &&
|
15012 | tag !== 'malignmark') {
|
15013 | ns = 0 ;
|
15014 | }
|
15015 | }
|
15016 | else if (parent && ns === 1 ) {
|
15017 | if (parent.tag === 'foreignObject' ||
|
15018 | parent.tag === 'desc' ||
|
15019 | parent.tag === 'title') {
|
15020 | ns = 0 ;
|
15021 | }
|
15022 | }
|
15023 | if (ns === 0 ) {
|
15024 | if (tag === 'svg') {
|
15025 | return 1 ;
|
15026 | }
|
15027 | if (tag === 'math') {
|
15028 | return 2 ;
|
15029 | }
|
15030 | }
|
15031 | return ns;
|
15032 | },
|
15033 |
|
15034 | getTextMode({ tag, ns }) {
|
15035 | if (ns === 0 ) {
|
15036 | if (tag === 'textarea' || tag === 'title') {
|
15037 | return 1 ;
|
15038 | }
|
15039 | if (isRawTextContainer(tag)) {
|
15040 | return 2 ;
|
15041 | }
|
15042 | }
|
15043 | return 0 ;
|
15044 | }
|
15045 | };
|
15046 |
|
15047 |
|
15048 |
|
15049 |
|
15050 |
|
15051 |
|
15052 |
|
15053 | const transformStyle = node => {
|
15054 | if (node.type === 1 ) {
|
15055 | node.props.forEach((p, i) => {
|
15056 | if (p.type === 6 && p.name === 'style' && p.value) {
|
15057 |
|
15058 | node.props[i] = {
|
15059 | type: 7 ,
|
15060 | name: `bind`,
|
15061 | arg: createSimpleExpression(`style`, true, p.loc),
|
15062 | exp: parseInlineCSS(p.value.content, p.loc),
|
15063 | modifiers: [],
|
15064 | loc: p.loc
|
15065 | };
|
15066 | }
|
15067 | });
|
15068 | }
|
15069 | };
|
15070 | const parseInlineCSS = (cssText, loc) => {
|
15071 | const normalized = parseStringStyle(cssText);
|
15072 | return createSimpleExpression(JSON.stringify(normalized), false, loc, 3 );
|
15073 | };
|
15074 |
|
15075 | function createDOMCompilerError(code, loc) {
|
15076 | return createCompilerError(code, loc, DOMErrorMessages );
|
15077 | }
|
15078 | const DOMErrorMessages = {
|
15079 | [50 ]: `v-html is missing expression.`,
|
15080 | [51 ]: `v-html will override element children.`,
|
15081 | [52 ]: `v-text is missing expression.`,
|
15082 | [53 ]: `v-text will override element children.`,
|
15083 | [54 ]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
15084 | [55 ]: `v-model argument is not supported on plain elements.`,
|
15085 | [56 ]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
15086 | [57 ]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
15087 | [58 ]: `v-show is missing expression.`,
|
15088 | [59 ]: `<Transition> expects exactly one child element or component.`,
|
15089 | [60 ]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
15090 | };
|
15091 |
|
15092 | const transformVHtml = (dir, node, context) => {
|
15093 | const { exp, loc } = dir;
|
15094 | if (!exp) {
|
15095 | context.onError(createDOMCompilerError(50 , loc));
|
15096 | }
|
15097 | if (node.children.length) {
|
15098 | context.onError(createDOMCompilerError(51 , loc));
|
15099 | node.children.length = 0;
|
15100 | }
|
15101 | return {
|
15102 | props: [
|
15103 | createObjectProperty(createSimpleExpression(`innerHTML`, true, loc), exp || createSimpleExpression('', true))
|
15104 | ]
|
15105 | };
|
15106 | };
|
15107 |
|
15108 | const transformVText = (dir, node, context) => {
|
15109 | const { exp, loc } = dir;
|
15110 | if (!exp) {
|
15111 | context.onError(createDOMCompilerError(52 , loc));
|
15112 | }
|
15113 | if (node.children.length) {
|
15114 | context.onError(createDOMCompilerError(53 , loc));
|
15115 | node.children.length = 0;
|
15116 | }
|
15117 | return {
|
15118 | props: [
|
15119 | createObjectProperty(createSimpleExpression(`textContent`, true), exp
|
15120 | ? createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
|
15121 | : createSimpleExpression('', true))
|
15122 | ]
|
15123 | };
|
15124 | };
|
15125 |
|
15126 | const transformModel$1 = (dir, node, context) => {
|
15127 | const baseResult = transformModel(dir, node, context);
|
15128 |
|
15129 | if (!baseResult.props.length || node.tagType === 1 ) {
|
15130 | return baseResult;
|
15131 | }
|
15132 | if (dir.arg) {
|
15133 | context.onError(createDOMCompilerError(55 , dir.arg.loc));
|
15134 | }
|
15135 | function checkDuplicatedValue() {
|
15136 | const value = findProp(node, 'value');
|
15137 | if (value) {
|
15138 | context.onError(createDOMCompilerError(57 , value.loc));
|
15139 | }
|
15140 | }
|
15141 | const { tag } = node;
|
15142 | const isCustomElement = context.isCustomElement(tag);
|
15143 | if (tag === 'input' ||
|
15144 | tag === 'textarea' ||
|
15145 | tag === 'select' ||
|
15146 | isCustomElement) {
|
15147 | let directiveToUse = V_MODEL_TEXT;
|
15148 | let isInvalidType = false;
|
15149 | if (tag === 'input' || isCustomElement) {
|
15150 | const type = findProp(node, `type`);
|
15151 | if (type) {
|
15152 | if (type.type === 7 ) {
|
15153 |
|
15154 | directiveToUse = V_MODEL_DYNAMIC;
|
15155 | }
|
15156 | else if (type.value) {
|
15157 | switch (type.value.content) {
|
15158 | case 'radio':
|
15159 | directiveToUse = V_MODEL_RADIO;
|
15160 | break;
|
15161 | case 'checkbox':
|
15162 | directiveToUse = V_MODEL_CHECKBOX;
|
15163 | break;
|
15164 | case 'file':
|
15165 | isInvalidType = true;
|
15166 | context.onError(createDOMCompilerError(56 , dir.loc));
|
15167 | break;
|
15168 | default:
|
15169 |
|
15170 | checkDuplicatedValue();
|
15171 | break;
|
15172 | }
|
15173 | }
|
15174 | }
|
15175 | else if (hasDynamicKeyVBind(node)) {
|
15176 |
|
15177 |
|
15178 | directiveToUse = V_MODEL_DYNAMIC;
|
15179 | }
|
15180 | else {
|
15181 |
|
15182 | checkDuplicatedValue();
|
15183 | }
|
15184 | }
|
15185 | else if (tag === 'select') {
|
15186 | directiveToUse = V_MODEL_SELECT;
|
15187 | }
|
15188 | else {
|
15189 |
|
15190 | checkDuplicatedValue();
|
15191 | }
|
15192 |
|
15193 |
|
15194 |
|
15195 | if (!isInvalidType) {
|
15196 | baseResult.needRuntime = context.helper(directiveToUse);
|
15197 | }
|
15198 | }
|
15199 | else {
|
15200 | context.onError(createDOMCompilerError(54 , dir.loc));
|
15201 | }
|
15202 |
|
15203 |
|
15204 | baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 &&
|
15205 | p.key.content === 'modelValue'));
|
15206 | return baseResult;
|
15207 | };
|
15208 |
|
15209 | const isEventOptionModifier = makeMap(`passive,once,capture`);
|
15210 | const isNonKeyModifier = makeMap(
|
15211 |
|
15212 | `stop,prevent,self,` +
|
15213 |
|
15214 | `ctrl,shift,alt,meta,exact,` +
|
15215 |
|
15216 | `middle`);
|
15217 |
|
15218 | const maybeKeyModifier = makeMap('left,right');
|
15219 | const isKeyboardEvent = makeMap(`onkeyup,onkeydown,onkeypress`, true);
|
15220 | const resolveModifiers = (key, modifiers, context, loc) => {
|
15221 | const keyModifiers = [];
|
15222 | const nonKeyModifiers = [];
|
15223 | const eventOptionModifiers = [];
|
15224 | for (let i = 0; i < modifiers.length; i++) {
|
15225 | const modifier = modifiers[i];
|
15226 | if (isEventOptionModifier(modifier)) {
|
15227 |
|
15228 |
|
15229 | eventOptionModifiers.push(modifier);
|
15230 | }
|
15231 | else {
|
15232 |
|
15233 | if (maybeKeyModifier(modifier)) {
|
15234 | if (isStaticExp(key)) {
|
15235 | if (isKeyboardEvent(key.content)) {
|
15236 | keyModifiers.push(modifier);
|
15237 | }
|
15238 | else {
|
15239 | nonKeyModifiers.push(modifier);
|
15240 | }
|
15241 | }
|
15242 | else {
|
15243 | keyModifiers.push(modifier);
|
15244 | nonKeyModifiers.push(modifier);
|
15245 | }
|
15246 | }
|
15247 | else {
|
15248 | if (isNonKeyModifier(modifier)) {
|
15249 | nonKeyModifiers.push(modifier);
|
15250 | }
|
15251 | else {
|
15252 | keyModifiers.push(modifier);
|
15253 | }
|
15254 | }
|
15255 | }
|
15256 | }
|
15257 | return {
|
15258 | keyModifiers,
|
15259 | nonKeyModifiers,
|
15260 | eventOptionModifiers
|
15261 | };
|
15262 | };
|
15263 | const transformClick = (key, event) => {
|
15264 | const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === 'onclick';
|
15265 | return isStaticClick
|
15266 | ? createSimpleExpression(event, true)
|
15267 | : key.type !== 4
|
15268 | ? createCompoundExpression([
|
15269 | `(`,
|
15270 | key,
|
15271 | `) === "onClick" ? "${event}" : (`,
|
15272 | key,
|
15273 | `)`
|
15274 | ])
|
15275 | : key;
|
15276 | };
|
15277 | const transformOn$1 = (dir, node, context) => {
|
15278 | return transformOn(dir, node, context, baseResult => {
|
15279 | const { modifiers } = dir;
|
15280 | if (!modifiers.length)
|
15281 | return baseResult;
|
15282 | let { key, value: handlerExp } = baseResult.props[0];
|
15283 | const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
15284 |
|
15285 | if (nonKeyModifiers.includes('right')) {
|
15286 | key = transformClick(key, `onContextmenu`);
|
15287 | }
|
15288 | if (nonKeyModifiers.includes('middle')) {
|
15289 | key = transformClick(key, `onMouseup`);
|
15290 | }
|
15291 | if (nonKeyModifiers.length) {
|
15292 | handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
15293 | handlerExp,
|
15294 | JSON.stringify(nonKeyModifiers)
|
15295 | ]);
|
15296 | }
|
15297 | if (keyModifiers.length &&
|
15298 |
|
15299 | (!isStaticExp(key) || isKeyboardEvent(key.content))) {
|
15300 | handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
15301 | handlerExp,
|
15302 | JSON.stringify(keyModifiers)
|
15303 | ]);
|
15304 | }
|
15305 | if (eventOptionModifiers.length) {
|
15306 | const modifierPostfix = eventOptionModifiers.map(capitalize).join('');
|
15307 | key = isStaticExp(key)
|
15308 | ? createSimpleExpression(`${key.content}${modifierPostfix}`, true)
|
15309 | : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
15310 | }
|
15311 | return {
|
15312 | props: [createObjectProperty(key, handlerExp)]
|
15313 | };
|
15314 | });
|
15315 | };
|
15316 |
|
15317 | const transformShow = (dir, node, context) => {
|
15318 | const { exp, loc } = dir;
|
15319 | if (!exp) {
|
15320 | context.onError(createDOMCompilerError(58 , loc));
|
15321 | }
|
15322 | return {
|
15323 | props: [],
|
15324 | needRuntime: context.helper(V_SHOW)
|
15325 | };
|
15326 | };
|
15327 |
|
15328 | const warnTransitionChildren = (node, context) => {
|
15329 | if (node.type === 1 &&
|
15330 | node.tagType === 1 ) {
|
15331 | const component = context.isBuiltInComponent(node.tag);
|
15332 | if (component === TRANSITION$1) {
|
15333 | return () => {
|
15334 | if (node.children.length && hasMultipleChildren(node)) {
|
15335 | context.onError(createDOMCompilerError(59 , {
|
15336 | start: node.children[0].loc.start,
|
15337 | end: node.children[node.children.length - 1].loc.end,
|
15338 | source: ''
|
15339 | }));
|
15340 | }
|
15341 | };
|
15342 | }
|
15343 | }
|
15344 | };
|
15345 | function hasMultipleChildren(node) {
|
15346 |
|
15347 | const children = (node.children = node.children.filter(c => c.type !== 3 &&
|
15348 | !(c.type === 2 && !c.content.trim())));
|
15349 | const child = children[0];
|
15350 | return (children.length !== 1 ||
|
15351 | child.type === 11 ||
|
15352 | (child.type === 9 && child.branches.some(hasMultipleChildren)));
|
15353 | }
|
15354 |
|
15355 | const ignoreSideEffectTags = (node, context) => {
|
15356 | if (node.type === 1 &&
|
15357 | node.tagType === 0 &&
|
15358 | (node.tag === 'script' || node.tag === 'style')) {
|
15359 | context.onError(createDOMCompilerError(60 , node.loc));
|
15360 | context.removeNode();
|
15361 | }
|
15362 | };
|
15363 |
|
15364 | const DOMNodeTransforms = [
|
15365 | transformStyle,
|
15366 | ...([warnTransitionChildren] )
|
15367 | ];
|
15368 | const DOMDirectiveTransforms = {
|
15369 | cloak: noopDirectiveTransform,
|
15370 | html: transformVHtml,
|
15371 | text: transformVText,
|
15372 | model: transformModel$1,
|
15373 | on: transformOn$1,
|
15374 | show: transformShow
|
15375 | };
|
15376 | function compile$1(template, options = {}) {
|
15377 | return baseCompile(template, extend({}, parserOptions, options, {
|
15378 | nodeTransforms: [
|
15379 |
|
15380 |
|
15381 |
|
15382 | ignoreSideEffectTags,
|
15383 | ...DOMNodeTransforms,
|
15384 | ...(options.nodeTransforms || [])
|
15385 | ],
|
15386 | directiveTransforms: extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
|
15387 | transformHoist: null
|
15388 | }));
|
15389 | }
|
15390 |
|
15391 |
|
15392 | {
|
15393 | initDev();
|
15394 | }
|
15395 | const compileCache = Object.create(null);
|
15396 | function compileToFunction(template, options) {
|
15397 | if (!isString(template)) {
|
15398 | if (template.nodeType) {
|
15399 | template = template.innerHTML;
|
15400 | }
|
15401 | else {
|
15402 | warn$1(`invalid template option: `, template);
|
15403 | return NOOP;
|
15404 | }
|
15405 | }
|
15406 | const key = template;
|
15407 | const cached = compileCache[key];
|
15408 | if (cached) {
|
15409 | return cached;
|
15410 | }
|
15411 | if (template[0] === '#') {
|
15412 | const el = document.querySelector(template);
|
15413 | if (!el) {
|
15414 | warn$1(`Template element not found or is empty: ${template}`);
|
15415 | }
|
15416 |
|
15417 |
|
15418 |
|
15419 |
|
15420 | template = el ? el.innerHTML : ``;
|
15421 | }
|
15422 | const { code } = compile$1(template, extend({
|
15423 | hoistStatic: true,
|
15424 | onError: onError ,
|
15425 | onWarn: e => onError(e, true)
|
15426 | }, options));
|
15427 | function onError(err, asWarning = false) {
|
15428 | const message = asWarning
|
15429 | ? err.message
|
15430 | : `Template compilation error: ${err.message}`;
|
15431 | const codeFrame = err.loc &&
|
15432 | generateCodeFrame(template, err.loc.start.offset, err.loc.end.offset);
|
15433 | warn$1(codeFrame ? `${message}\n${codeFrame}` : message);
|
15434 | }
|
15435 |
|
15436 |
|
15437 |
|
15438 |
|
15439 | const render = (new Function(code)() );
|
15440 | render._rc = true;
|
15441 | return (compileCache[key] = render);
|
15442 | }
|
15443 | registerRuntimeCompiler(compileToFunction);
|
15444 |
|
15445 | exports.BaseTransition = BaseTransition;
|
15446 | exports.Comment = Comment;
|
15447 | exports.EffectScope = EffectScope;
|
15448 | exports.Fragment = Fragment;
|
15449 | exports.KeepAlive = KeepAlive;
|
15450 | exports.ReactiveEffect = ReactiveEffect;
|
15451 | exports.Static = Static;
|
15452 | exports.Suspense = Suspense;
|
15453 | exports.Teleport = Teleport;
|
15454 | exports.Text = Text;
|
15455 | exports.Transition = Transition;
|
15456 | exports.TransitionGroup = TransitionGroup;
|
15457 | exports.VueElement = VueElement;
|
15458 | exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
|
15459 | exports.callWithErrorHandling = callWithErrorHandling;
|
15460 | exports.camelize = camelize;
|
15461 | exports.capitalize = capitalize;
|
15462 | exports.cloneVNode = cloneVNode;
|
15463 | exports.compatUtils = compatUtils;
|
15464 | exports.compile = compileToFunction;
|
15465 | exports.computed = computed;
|
15466 | exports.createApp = createApp;
|
15467 | exports.createBlock = createBlock;
|
15468 | exports.createCommentVNode = createCommentVNode;
|
15469 | exports.createElementBlock = createElementBlock;
|
15470 | exports.createElementVNode = createBaseVNode;
|
15471 | exports.createHydrationRenderer = createHydrationRenderer;
|
15472 | exports.createRenderer = createRenderer;
|
15473 | exports.createSSRApp = createSSRApp;
|
15474 | exports.createSlots = createSlots;
|
15475 | exports.createStaticVNode = createStaticVNode;
|
15476 | exports.createTextVNode = createTextVNode;
|
15477 | exports.createVNode = createVNode;
|
15478 | exports.customRef = customRef;
|
15479 | exports.defineAsyncComponent = defineAsyncComponent;
|
15480 | exports.defineComponent = defineComponent;
|
15481 | exports.defineCustomElement = defineCustomElement;
|
15482 | exports.defineEmits = defineEmits;
|
15483 | exports.defineExpose = defineExpose;
|
15484 | exports.defineProps = defineProps;
|
15485 | exports.defineSSRCustomElement = defineSSRCustomElement;
|
15486 | exports.effect = effect;
|
15487 | exports.effectScope = effectScope;
|
15488 | exports.getCurrentInstance = getCurrentInstance;
|
15489 | exports.getCurrentScope = getCurrentScope;
|
15490 | exports.getTransitionRawChildren = getTransitionRawChildren;
|
15491 | exports.guardReactiveProps = guardReactiveProps;
|
15492 | exports.h = h;
|
15493 | exports.handleError = handleError;
|
15494 | exports.hydrate = hydrate;
|
15495 | exports.initCustomFormatter = initCustomFormatter;
|
15496 | exports.initDirectivesForSSR = initDirectivesForSSR;
|
15497 | exports.inject = inject;
|
15498 | exports.isMemoSame = isMemoSame;
|
15499 | exports.isProxy = isProxy;
|
15500 | exports.isReactive = isReactive;
|
15501 | exports.isReadonly = isReadonly;
|
15502 | exports.isRef = isRef;
|
15503 | exports.isRuntimeOnly = isRuntimeOnly;
|
15504 | exports.isVNode = isVNode;
|
15505 | exports.markRaw = markRaw;
|
15506 | exports.mergeDefaults = mergeDefaults;
|
15507 | exports.mergeProps = mergeProps;
|
15508 | exports.nextTick = nextTick;
|
15509 | exports.normalizeClass = normalizeClass;
|
15510 | exports.normalizeProps = normalizeProps;
|
15511 | exports.normalizeStyle = normalizeStyle;
|
15512 | exports.onActivated = onActivated;
|
15513 | exports.onBeforeMount = onBeforeMount;
|
15514 | exports.onBeforeUnmount = onBeforeUnmount;
|
15515 | exports.onBeforeUpdate = onBeforeUpdate;
|
15516 | exports.onDeactivated = onDeactivated;
|
15517 | exports.onErrorCaptured = onErrorCaptured;
|
15518 | exports.onMounted = onMounted;
|
15519 | exports.onRenderTracked = onRenderTracked;
|
15520 | exports.onRenderTriggered = onRenderTriggered;
|
15521 | exports.onScopeDispose = onScopeDispose;
|
15522 | exports.onServerPrefetch = onServerPrefetch;
|
15523 | exports.onUnmounted = onUnmounted;
|
15524 | exports.onUpdated = onUpdated;
|
15525 | exports.openBlock = openBlock;
|
15526 | exports.popScopeId = popScopeId;
|
15527 | exports.provide = provide;
|
15528 | exports.proxyRefs = proxyRefs;
|
15529 | exports.pushScopeId = pushScopeId;
|
15530 | exports.queuePostFlushCb = queuePostFlushCb;
|
15531 | exports.reactive = reactive;
|
15532 | exports.readonly = readonly;
|
15533 | exports.ref = ref;
|
15534 | exports.registerRuntimeCompiler = registerRuntimeCompiler;
|
15535 | exports.render = render;
|
15536 | exports.renderList = renderList;
|
15537 | exports.renderSlot = renderSlot;
|
15538 | exports.resolveComponent = resolveComponent;
|
15539 | exports.resolveDirective = resolveDirective;
|
15540 | exports.resolveDynamicComponent = resolveDynamicComponent;
|
15541 | exports.resolveFilter = resolveFilter;
|
15542 | exports.resolveTransitionHooks = resolveTransitionHooks;
|
15543 | exports.setBlockTracking = setBlockTracking;
|
15544 | exports.setDevtoolsHook = setDevtoolsHook;
|
15545 | exports.setTransitionHooks = setTransitionHooks;
|
15546 | exports.shallowReactive = shallowReactive;
|
15547 | exports.shallowReadonly = shallowReadonly;
|
15548 | exports.shallowRef = shallowRef;
|
15549 | exports.ssrContextKey = ssrContextKey;
|
15550 | exports.ssrUtils = ssrUtils;
|
15551 | exports.stop = stop;
|
15552 | exports.toDisplayString = toDisplayString;
|
15553 | exports.toHandlerKey = toHandlerKey;
|
15554 | exports.toHandlers = toHandlers;
|
15555 | exports.toRaw = toRaw;
|
15556 | exports.toRef = toRef;
|
15557 | exports.toRefs = toRefs;
|
15558 | exports.transformVNodeArgs = transformVNodeArgs;
|
15559 | exports.triggerRef = triggerRef;
|
15560 | exports.unref = unref;
|
15561 | exports.useAttrs = useAttrs;
|
15562 | exports.useCssModule = useCssModule;
|
15563 | exports.useCssVars = useCssVars;
|
15564 | exports.useSSRContext = useSSRContext;
|
15565 | exports.useSlots = useSlots;
|
15566 | exports.useTransitionState = useTransitionState;
|
15567 | exports.vModelCheckbox = vModelCheckbox;
|
15568 | exports.vModelDynamic = vModelDynamic;
|
15569 | exports.vModelRadio = vModelRadio;
|
15570 | exports.vModelSelect = vModelSelect;
|
15571 | exports.vModelText = vModelText;
|
15572 | exports.vShow = vShow;
|
15573 | exports.version = version;
|
15574 | exports.warn = warn$1;
|
15575 | exports.watch = watch;
|
15576 | exports.watchEffect = watchEffect;
|
15577 | exports.watchPostEffect = watchPostEffect;
|
15578 | exports.watchSyncEffect = watchSyncEffect;
|
15579 | exports.withAsyncContext = withAsyncContext;
|
15580 | exports.withCtx = withCtx;
|
15581 | exports.withDefaults = withDefaults;
|
15582 | exports.withDirectives = withDirectives;
|
15583 | exports.withKeys = withKeys;
|
15584 | exports.withMemo = withMemo;
|
15585 | exports.withModifiers = withModifiers;
|
15586 | exports.withScopeId = withScopeId;
|
15587 |
|
15588 | Object.defineProperty(exports, '__esModule', { value: true });
|
15589 |
|
15590 | return exports;
|
15591 |
|
15592 | }({}));
|