1 | /**
|
---|
2 | * @vue/runtime-core v3.5.13
|
---|
3 | * (c) 2018-present Yuxi (Evan) You and Vue contributors
|
---|
4 | * @license MIT
|
---|
5 | **/
|
---|
6 | 'use strict';
|
---|
7 |
|
---|
8 | Object.defineProperty(exports, '__esModule', { value: true });
|
---|
9 |
|
---|
10 | var reactivity = require('@vue/reactivity');
|
---|
11 | var shared = require('@vue/shared');
|
---|
12 |
|
---|
13 | const stack = [];
|
---|
14 | function pushWarningContext(vnode) {
|
---|
15 | stack.push(vnode);
|
---|
16 | }
|
---|
17 | function popWarningContext() {
|
---|
18 | stack.pop();
|
---|
19 | }
|
---|
20 | let isWarning = false;
|
---|
21 | function warn$1(msg, ...args) {
|
---|
22 | if (isWarning) return;
|
---|
23 | isWarning = true;
|
---|
24 | reactivity.pauseTracking();
|
---|
25 | const instance = stack.length ? stack[stack.length - 1].component : null;
|
---|
26 | const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
---|
27 | const trace = getComponentTrace();
|
---|
28 | if (appWarnHandler) {
|
---|
29 | callWithErrorHandling(
|
---|
30 | appWarnHandler,
|
---|
31 | instance,
|
---|
32 | 11,
|
---|
33 | [
|
---|
34 | // eslint-disable-next-line no-restricted-syntax
|
---|
35 | msg + args.map((a) => {
|
---|
36 | var _a, _b;
|
---|
37 | return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
|
---|
38 | }).join(""),
|
---|
39 | instance && instance.proxy,
|
---|
40 | trace.map(
|
---|
41 | ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
---|
42 | ).join("\n"),
|
---|
43 | trace
|
---|
44 | ]
|
---|
45 | );
|
---|
46 | } else {
|
---|
47 | const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
---|
48 | if (trace.length && // avoid spamming console during tests
|
---|
49 | true) {
|
---|
50 | warnArgs.push(`
|
---|
51 | `, ...formatTrace(trace));
|
---|
52 | }
|
---|
53 | console.warn(...warnArgs);
|
---|
54 | }
|
---|
55 | reactivity.resetTracking();
|
---|
56 | isWarning = false;
|
---|
57 | }
|
---|
58 | function getComponentTrace() {
|
---|
59 | let currentVNode = stack[stack.length - 1];
|
---|
60 | if (!currentVNode) {
|
---|
61 | return [];
|
---|
62 | }
|
---|
63 | const normalizedStack = [];
|
---|
64 | while (currentVNode) {
|
---|
65 | const last = normalizedStack[0];
|
---|
66 | if (last && last.vnode === currentVNode) {
|
---|
67 | last.recurseCount++;
|
---|
68 | } else {
|
---|
69 | normalizedStack.push({
|
---|
70 | vnode: currentVNode,
|
---|
71 | recurseCount: 0
|
---|
72 | });
|
---|
73 | }
|
---|
74 | const parentInstance = currentVNode.component && currentVNode.component.parent;
|
---|
75 | currentVNode = parentInstance && parentInstance.vnode;
|
---|
76 | }
|
---|
77 | return normalizedStack;
|
---|
78 | }
|
---|
79 | function formatTrace(trace) {
|
---|
80 | const logs = [];
|
---|
81 | trace.forEach((entry, i) => {
|
---|
82 | logs.push(...i === 0 ? [] : [`
|
---|
83 | `], ...formatTraceEntry(entry));
|
---|
84 | });
|
---|
85 | return logs;
|
---|
86 | }
|
---|
87 | function formatTraceEntry({ vnode, recurseCount }) {
|
---|
88 | const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
---|
89 | const isRoot = vnode.component ? vnode.component.parent == null : false;
|
---|
90 | const open = ` at <${formatComponentName(
|
---|
91 | vnode.component,
|
---|
92 | vnode.type,
|
---|
93 | isRoot
|
---|
94 | )}`;
|
---|
95 | const close = `>` + postfix;
|
---|
96 | return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
---|
97 | }
|
---|
98 | function formatProps(props) {
|
---|
99 | const res = [];
|
---|
100 | const keys = Object.keys(props);
|
---|
101 | keys.slice(0, 3).forEach((key) => {
|
---|
102 | res.push(...formatProp(key, props[key]));
|
---|
103 | });
|
---|
104 | if (keys.length > 3) {
|
---|
105 | res.push(` ...`);
|
---|
106 | }
|
---|
107 | return res;
|
---|
108 | }
|
---|
109 | function formatProp(key, value, raw) {
|
---|
110 | if (shared.isString(value)) {
|
---|
111 | value = JSON.stringify(value);
|
---|
112 | return raw ? value : [`${key}=${value}`];
|
---|
113 | } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
---|
114 | return raw ? value : [`${key}=${value}`];
|
---|
115 | } else if (reactivity.isRef(value)) {
|
---|
116 | value = formatProp(key, reactivity.toRaw(value.value), true);
|
---|
117 | return raw ? value : [`${key}=Ref<`, value, `>`];
|
---|
118 | } else if (shared.isFunction(value)) {
|
---|
119 | return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
---|
120 | } else {
|
---|
121 | value = reactivity.toRaw(value);
|
---|
122 | return raw ? value : [`${key}=`, value];
|
---|
123 | }
|
---|
124 | }
|
---|
125 | function assertNumber(val, type) {
|
---|
126 | if (val === void 0) {
|
---|
127 | return;
|
---|
128 | } else if (typeof val !== "number") {
|
---|
129 | warn$1(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
|
---|
130 | } else if (isNaN(val)) {
|
---|
131 | warn$1(`${type} is NaN - the duration expression might be incorrect.`);
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | const ErrorCodes = {
|
---|
136 | "SETUP_FUNCTION": 0,
|
---|
137 | "0": "SETUP_FUNCTION",
|
---|
138 | "RENDER_FUNCTION": 1,
|
---|
139 | "1": "RENDER_FUNCTION",
|
---|
140 | "NATIVE_EVENT_HANDLER": 5,
|
---|
141 | "5": "NATIVE_EVENT_HANDLER",
|
---|
142 | "COMPONENT_EVENT_HANDLER": 6,
|
---|
143 | "6": "COMPONENT_EVENT_HANDLER",
|
---|
144 | "VNODE_HOOK": 7,
|
---|
145 | "7": "VNODE_HOOK",
|
---|
146 | "DIRECTIVE_HOOK": 8,
|
---|
147 | "8": "DIRECTIVE_HOOK",
|
---|
148 | "TRANSITION_HOOK": 9,
|
---|
149 | "9": "TRANSITION_HOOK",
|
---|
150 | "APP_ERROR_HANDLER": 10,
|
---|
151 | "10": "APP_ERROR_HANDLER",
|
---|
152 | "APP_WARN_HANDLER": 11,
|
---|
153 | "11": "APP_WARN_HANDLER",
|
---|
154 | "FUNCTION_REF": 12,
|
---|
155 | "12": "FUNCTION_REF",
|
---|
156 | "ASYNC_COMPONENT_LOADER": 13,
|
---|
157 | "13": "ASYNC_COMPONENT_LOADER",
|
---|
158 | "SCHEDULER": 14,
|
---|
159 | "14": "SCHEDULER",
|
---|
160 | "COMPONENT_UPDATE": 15,
|
---|
161 | "15": "COMPONENT_UPDATE",
|
---|
162 | "APP_UNMOUNT_CLEANUP": 16,
|
---|
163 | "16": "APP_UNMOUNT_CLEANUP"
|
---|
164 | };
|
---|
165 | const ErrorTypeStrings$1 = {
|
---|
166 | ["sp"]: "serverPrefetch hook",
|
---|
167 | ["bc"]: "beforeCreate hook",
|
---|
168 | ["c"]: "created hook",
|
---|
169 | ["bm"]: "beforeMount hook",
|
---|
170 | ["m"]: "mounted hook",
|
---|
171 | ["bu"]: "beforeUpdate hook",
|
---|
172 | ["u"]: "updated",
|
---|
173 | ["bum"]: "beforeUnmount hook",
|
---|
174 | ["um"]: "unmounted hook",
|
---|
175 | ["a"]: "activated hook",
|
---|
176 | ["da"]: "deactivated hook",
|
---|
177 | ["ec"]: "errorCaptured hook",
|
---|
178 | ["rtc"]: "renderTracked hook",
|
---|
179 | ["rtg"]: "renderTriggered hook",
|
---|
180 | [0]: "setup function",
|
---|
181 | [1]: "render function",
|
---|
182 | [2]: "watcher getter",
|
---|
183 | [3]: "watcher callback",
|
---|
184 | [4]: "watcher cleanup function",
|
---|
185 | [5]: "native event handler",
|
---|
186 | [6]: "component event handler",
|
---|
187 | [7]: "vnode hook",
|
---|
188 | [8]: "directive hook",
|
---|
189 | [9]: "transition hook",
|
---|
190 | [10]: "app errorHandler",
|
---|
191 | [11]: "app warnHandler",
|
---|
192 | [12]: "ref function",
|
---|
193 | [13]: "async component loader",
|
---|
194 | [14]: "scheduler flush",
|
---|
195 | [15]: "component update",
|
---|
196 | [16]: "app unmount cleanup function"
|
---|
197 | };
|
---|
198 | function callWithErrorHandling(fn, instance, type, args) {
|
---|
199 | try {
|
---|
200 | return args ? fn(...args) : fn();
|
---|
201 | } catch (err) {
|
---|
202 | handleError(err, instance, type);
|
---|
203 | }
|
---|
204 | }
|
---|
205 | function callWithAsyncErrorHandling(fn, instance, type, args) {
|
---|
206 | if (shared.isFunction(fn)) {
|
---|
207 | const res = callWithErrorHandling(fn, instance, type, args);
|
---|
208 | if (res && shared.isPromise(res)) {
|
---|
209 | res.catch((err) => {
|
---|
210 | handleError(err, instance, type);
|
---|
211 | });
|
---|
212 | }
|
---|
213 | return res;
|
---|
214 | }
|
---|
215 | if (shared.isArray(fn)) {
|
---|
216 | const values = [];
|
---|
217 | for (let i = 0; i < fn.length; i++) {
|
---|
218 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
---|
219 | }
|
---|
220 | return values;
|
---|
221 | } else {
|
---|
222 | warn$1(
|
---|
223 | `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`
|
---|
224 | );
|
---|
225 | }
|
---|
226 | }
|
---|
227 | function handleError(err, instance, type, throwInDev = true) {
|
---|
228 | const contextVNode = instance ? instance.vnode : null;
|
---|
229 | const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || shared.EMPTY_OBJ;
|
---|
230 | if (instance) {
|
---|
231 | let cur = instance.parent;
|
---|
232 | const exposedInstance = instance.proxy;
|
---|
233 | const errorInfo = ErrorTypeStrings$1[type] ;
|
---|
234 | while (cur) {
|
---|
235 | const errorCapturedHooks = cur.ec;
|
---|
236 | if (errorCapturedHooks) {
|
---|
237 | for (let i = 0; i < errorCapturedHooks.length; i++) {
|
---|
238 | if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
---|
239 | return;
|
---|
240 | }
|
---|
241 | }
|
---|
242 | }
|
---|
243 | cur = cur.parent;
|
---|
244 | }
|
---|
245 | if (errorHandler) {
|
---|
246 | reactivity.pauseTracking();
|
---|
247 | callWithErrorHandling(errorHandler, null, 10, [
|
---|
248 | err,
|
---|
249 | exposedInstance,
|
---|
250 | errorInfo
|
---|
251 | ]);
|
---|
252 | reactivity.resetTracking();
|
---|
253 | return;
|
---|
254 | }
|
---|
255 | }
|
---|
256 | logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction);
|
---|
257 | }
|
---|
258 | function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) {
|
---|
259 | {
|
---|
260 | const info = ErrorTypeStrings$1[type];
|
---|
261 | if (contextVNode) {
|
---|
262 | pushWarningContext(contextVNode);
|
---|
263 | }
|
---|
264 | warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
---|
265 | if (contextVNode) {
|
---|
266 | popWarningContext();
|
---|
267 | }
|
---|
268 | if (throwInDev) {
|
---|
269 | throw err;
|
---|
270 | } else {
|
---|
271 | console.error(err);
|
---|
272 | }
|
---|
273 | }
|
---|
274 | }
|
---|
275 |
|
---|
276 | const queue = [];
|
---|
277 | let flushIndex = -1;
|
---|
278 | const pendingPostFlushCbs = [];
|
---|
279 | let activePostFlushCbs = null;
|
---|
280 | let postFlushIndex = 0;
|
---|
281 | const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
---|
282 | let currentFlushPromise = null;
|
---|
283 | const RECURSION_LIMIT = 100;
|
---|
284 | function nextTick(fn) {
|
---|
285 | const p = currentFlushPromise || resolvedPromise;
|
---|
286 | return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
---|
287 | }
|
---|
288 | function findInsertionIndex(id) {
|
---|
289 | let start = flushIndex + 1;
|
---|
290 | let end = queue.length;
|
---|
291 | while (start < end) {
|
---|
292 | const middle = start + end >>> 1;
|
---|
293 | const middleJob = queue[middle];
|
---|
294 | const middleJobId = getId(middleJob);
|
---|
295 | if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
|
---|
296 | start = middle + 1;
|
---|
297 | } else {
|
---|
298 | end = middle;
|
---|
299 | }
|
---|
300 | }
|
---|
301 | return start;
|
---|
302 | }
|
---|
303 | function queueJob(job) {
|
---|
304 | if (!(job.flags & 1)) {
|
---|
305 | const jobId = getId(job);
|
---|
306 | const lastJob = queue[queue.length - 1];
|
---|
307 | if (!lastJob || // fast path when the job id is larger than the tail
|
---|
308 | !(job.flags & 2) && jobId >= getId(lastJob)) {
|
---|
309 | queue.push(job);
|
---|
310 | } else {
|
---|
311 | queue.splice(findInsertionIndex(jobId), 0, job);
|
---|
312 | }
|
---|
313 | job.flags |= 1;
|
---|
314 | queueFlush();
|
---|
315 | }
|
---|
316 | }
|
---|
317 | function queueFlush() {
|
---|
318 | if (!currentFlushPromise) {
|
---|
319 | currentFlushPromise = resolvedPromise.then(flushJobs);
|
---|
320 | }
|
---|
321 | }
|
---|
322 | function queuePostFlushCb(cb) {
|
---|
323 | if (!shared.isArray(cb)) {
|
---|
324 | if (activePostFlushCbs && cb.id === -1) {
|
---|
325 | activePostFlushCbs.splice(postFlushIndex + 1, 0, cb);
|
---|
326 | } else if (!(cb.flags & 1)) {
|
---|
327 | pendingPostFlushCbs.push(cb);
|
---|
328 | cb.flags |= 1;
|
---|
329 | }
|
---|
330 | } else {
|
---|
331 | pendingPostFlushCbs.push(...cb);
|
---|
332 | }
|
---|
333 | queueFlush();
|
---|
334 | }
|
---|
335 | function flushPreFlushCbs(instance, seen, i = flushIndex + 1) {
|
---|
336 | {
|
---|
337 | seen = seen || /* @__PURE__ */ new Map();
|
---|
338 | }
|
---|
339 | for (; i < queue.length; i++) {
|
---|
340 | const cb = queue[i];
|
---|
341 | if (cb && cb.flags & 2) {
|
---|
342 | if (instance && cb.id !== instance.uid) {
|
---|
343 | continue;
|
---|
344 | }
|
---|
345 | if (checkRecursiveUpdates(seen, cb)) {
|
---|
346 | continue;
|
---|
347 | }
|
---|
348 | queue.splice(i, 1);
|
---|
349 | i--;
|
---|
350 | if (cb.flags & 4) {
|
---|
351 | cb.flags &= ~1;
|
---|
352 | }
|
---|
353 | cb();
|
---|
354 | if (!(cb.flags & 4)) {
|
---|
355 | cb.flags &= ~1;
|
---|
356 | }
|
---|
357 | }
|
---|
358 | }
|
---|
359 | }
|
---|
360 | function flushPostFlushCbs(seen) {
|
---|
361 | if (pendingPostFlushCbs.length) {
|
---|
362 | const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
---|
363 | (a, b) => getId(a) - getId(b)
|
---|
364 | );
|
---|
365 | pendingPostFlushCbs.length = 0;
|
---|
366 | if (activePostFlushCbs) {
|
---|
367 | activePostFlushCbs.push(...deduped);
|
---|
368 | return;
|
---|
369 | }
|
---|
370 | activePostFlushCbs = deduped;
|
---|
371 | {
|
---|
372 | seen = seen || /* @__PURE__ */ new Map();
|
---|
373 | }
|
---|
374 | for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
---|
375 | const cb = activePostFlushCbs[postFlushIndex];
|
---|
376 | if (checkRecursiveUpdates(seen, cb)) {
|
---|
377 | continue;
|
---|
378 | }
|
---|
379 | if (cb.flags & 4) {
|
---|
380 | cb.flags &= ~1;
|
---|
381 | }
|
---|
382 | if (!(cb.flags & 8)) cb();
|
---|
383 | cb.flags &= ~1;
|
---|
384 | }
|
---|
385 | activePostFlushCbs = null;
|
---|
386 | postFlushIndex = 0;
|
---|
387 | }
|
---|
388 | }
|
---|
389 | const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
|
---|
390 | function flushJobs(seen) {
|
---|
391 | {
|
---|
392 | seen = seen || /* @__PURE__ */ new Map();
|
---|
393 | }
|
---|
394 | const check = (job) => checkRecursiveUpdates(seen, job) ;
|
---|
395 | try {
|
---|
396 | for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
---|
397 | const job = queue[flushIndex];
|
---|
398 | if (job && !(job.flags & 8)) {
|
---|
399 | if (check(job)) {
|
---|
400 | continue;
|
---|
401 | }
|
---|
402 | if (job.flags & 4) {
|
---|
403 | job.flags &= ~1;
|
---|
404 | }
|
---|
405 | callWithErrorHandling(
|
---|
406 | job,
|
---|
407 | job.i,
|
---|
408 | job.i ? 15 : 14
|
---|
409 | );
|
---|
410 | if (!(job.flags & 4)) {
|
---|
411 | job.flags &= ~1;
|
---|
412 | }
|
---|
413 | }
|
---|
414 | }
|
---|
415 | } finally {
|
---|
416 | for (; flushIndex < queue.length; flushIndex++) {
|
---|
417 | const job = queue[flushIndex];
|
---|
418 | if (job) {
|
---|
419 | job.flags &= ~1;
|
---|
420 | }
|
---|
421 | }
|
---|
422 | flushIndex = -1;
|
---|
423 | queue.length = 0;
|
---|
424 | flushPostFlushCbs(seen);
|
---|
425 | currentFlushPromise = null;
|
---|
426 | if (queue.length || pendingPostFlushCbs.length) {
|
---|
427 | flushJobs(seen);
|
---|
428 | }
|
---|
429 | }
|
---|
430 | }
|
---|
431 | function checkRecursiveUpdates(seen, fn) {
|
---|
432 | const count = seen.get(fn) || 0;
|
---|
433 | if (count > RECURSION_LIMIT) {
|
---|
434 | const instance = fn.i;
|
---|
435 | const componentName = instance && getComponentName(instance.type);
|
---|
436 | handleError(
|
---|
437 | `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
|
---|
438 | null,
|
---|
439 | 10
|
---|
440 | );
|
---|
441 | return true;
|
---|
442 | }
|
---|
443 | seen.set(fn, count + 1);
|
---|
444 | return false;
|
---|
445 | }
|
---|
446 |
|
---|
447 | let isHmrUpdating = false;
|
---|
448 | const hmrDirtyComponents = /* @__PURE__ */ new Map();
|
---|
449 | {
|
---|
450 | shared.getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
---|
451 | createRecord: tryWrap(createRecord),
|
---|
452 | rerender: tryWrap(rerender),
|
---|
453 | reload: tryWrap(reload)
|
---|
454 | };
|
---|
455 | }
|
---|
456 | const map = /* @__PURE__ */ new Map();
|
---|
457 | function registerHMR(instance) {
|
---|
458 | const id = instance.type.__hmrId;
|
---|
459 | let record = map.get(id);
|
---|
460 | if (!record) {
|
---|
461 | createRecord(id, instance.type);
|
---|
462 | record = map.get(id);
|
---|
463 | }
|
---|
464 | record.instances.add(instance);
|
---|
465 | }
|
---|
466 | function unregisterHMR(instance) {
|
---|
467 | map.get(instance.type.__hmrId).instances.delete(instance);
|
---|
468 | }
|
---|
469 | function createRecord(id, initialDef) {
|
---|
470 | if (map.has(id)) {
|
---|
471 | return false;
|
---|
472 | }
|
---|
473 | map.set(id, {
|
---|
474 | initialDef: normalizeClassComponent(initialDef),
|
---|
475 | instances: /* @__PURE__ */ new Set()
|
---|
476 | });
|
---|
477 | return true;
|
---|
478 | }
|
---|
479 | function normalizeClassComponent(component) {
|
---|
480 | return isClassComponent(component) ? component.__vccOpts : component;
|
---|
481 | }
|
---|
482 | function rerender(id, newRender) {
|
---|
483 | const record = map.get(id);
|
---|
484 | if (!record) {
|
---|
485 | return;
|
---|
486 | }
|
---|
487 | record.initialDef.render = newRender;
|
---|
488 | [...record.instances].forEach((instance) => {
|
---|
489 | if (newRender) {
|
---|
490 | instance.render = newRender;
|
---|
491 | normalizeClassComponent(instance.type).render = newRender;
|
---|
492 | }
|
---|
493 | instance.renderCache = [];
|
---|
494 | isHmrUpdating = true;
|
---|
495 | instance.update();
|
---|
496 | isHmrUpdating = false;
|
---|
497 | });
|
---|
498 | }
|
---|
499 | function reload(id, newComp) {
|
---|
500 | const record = map.get(id);
|
---|
501 | if (!record) return;
|
---|
502 | newComp = normalizeClassComponent(newComp);
|
---|
503 | updateComponentDef(record.initialDef, newComp);
|
---|
504 | const instances = [...record.instances];
|
---|
505 | for (let i = 0; i < instances.length; i++) {
|
---|
506 | const instance = instances[i];
|
---|
507 | const oldComp = normalizeClassComponent(instance.type);
|
---|
508 | let dirtyInstances = hmrDirtyComponents.get(oldComp);
|
---|
509 | if (!dirtyInstances) {
|
---|
510 | if (oldComp !== record.initialDef) {
|
---|
511 | updateComponentDef(oldComp, newComp);
|
---|
512 | }
|
---|
513 | hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
|
---|
514 | }
|
---|
515 | dirtyInstances.add(instance);
|
---|
516 | instance.appContext.propsCache.delete(instance.type);
|
---|
517 | instance.appContext.emitsCache.delete(instance.type);
|
---|
518 | instance.appContext.optionsCache.delete(instance.type);
|
---|
519 | if (instance.ceReload) {
|
---|
520 | dirtyInstances.add(instance);
|
---|
521 | instance.ceReload(newComp.styles);
|
---|
522 | dirtyInstances.delete(instance);
|
---|
523 | } else if (instance.parent) {
|
---|
524 | queueJob(() => {
|
---|
525 | isHmrUpdating = true;
|
---|
526 | instance.parent.update();
|
---|
527 | isHmrUpdating = false;
|
---|
528 | dirtyInstances.delete(instance);
|
---|
529 | });
|
---|
530 | } else if (instance.appContext.reload) {
|
---|
531 | instance.appContext.reload();
|
---|
532 | } else if (typeof window !== "undefined") {
|
---|
533 | window.location.reload();
|
---|
534 | } else {
|
---|
535 | console.warn(
|
---|
536 | "[HMR] Root or manually mounted instance modified. Full reload required."
|
---|
537 | );
|
---|
538 | }
|
---|
539 | if (instance.root.ce && instance !== instance.root) {
|
---|
540 | instance.root.ce._removeChildStyle(oldComp);
|
---|
541 | }
|
---|
542 | }
|
---|
543 | queuePostFlushCb(() => {
|
---|
544 | hmrDirtyComponents.clear();
|
---|
545 | });
|
---|
546 | }
|
---|
547 | function updateComponentDef(oldComp, newComp) {
|
---|
548 | shared.extend(oldComp, newComp);
|
---|
549 | for (const key in oldComp) {
|
---|
550 | if (key !== "__file" && !(key in newComp)) {
|
---|
551 | delete oldComp[key];
|
---|
552 | }
|
---|
553 | }
|
---|
554 | }
|
---|
555 | function tryWrap(fn) {
|
---|
556 | return (id, arg) => {
|
---|
557 | try {
|
---|
558 | return fn(id, arg);
|
---|
559 | } catch (e) {
|
---|
560 | console.error(e);
|
---|
561 | console.warn(
|
---|
562 | `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
|
---|
563 | );
|
---|
564 | }
|
---|
565 | };
|
---|
566 | }
|
---|
567 |
|
---|
568 | let devtools$1;
|
---|
569 | let buffer = [];
|
---|
570 | let devtoolsNotInstalled = false;
|
---|
571 | function emit$1(event, ...args) {
|
---|
572 | if (devtools$1) {
|
---|
573 | devtools$1.emit(event, ...args);
|
---|
574 | } else if (!devtoolsNotInstalled) {
|
---|
575 | buffer.push({ event, args });
|
---|
576 | }
|
---|
577 | }
|
---|
578 | function setDevtoolsHook$1(hook, target) {
|
---|
579 | var _a, _b;
|
---|
580 | devtools$1 = hook;
|
---|
581 | if (devtools$1) {
|
---|
582 | devtools$1.enabled = true;
|
---|
583 | buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
|
---|
584 | buffer = [];
|
---|
585 | } else if (
|
---|
586 | // handle late devtools injection - only do this if we are in an actual
|
---|
587 | // browser environment to avoid the timer handle stalling test runner exit
|
---|
588 | // (#4815)
|
---|
589 | typeof window !== "undefined" && // some envs mock window but not fully
|
---|
590 | window.HTMLElement && // also exclude jsdom
|
---|
591 | // eslint-disable-next-line no-restricted-syntax
|
---|
592 | !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
|
---|
593 | ) {
|
---|
594 | const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
|
---|
595 | replay.push((newHook) => {
|
---|
596 | setDevtoolsHook$1(newHook, target);
|
---|
597 | });
|
---|
598 | setTimeout(() => {
|
---|
599 | if (!devtools$1) {
|
---|
600 | target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
---|
601 | devtoolsNotInstalled = true;
|
---|
602 | buffer = [];
|
---|
603 | }
|
---|
604 | }, 3e3);
|
---|
605 | } else {
|
---|
606 | devtoolsNotInstalled = true;
|
---|
607 | buffer = [];
|
---|
608 | }
|
---|
609 | }
|
---|
610 | function devtoolsInitApp(app, version) {
|
---|
611 | emit$1("app:init" /* APP_INIT */, app, version, {
|
---|
612 | Fragment,
|
---|
613 | Text,
|
---|
614 | Comment,
|
---|
615 | Static
|
---|
616 | });
|
---|
617 | }
|
---|
618 | function devtoolsUnmountApp(app) {
|
---|
619 | emit$1("app:unmount" /* APP_UNMOUNT */, app);
|
---|
620 | }
|
---|
621 | const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
|
---|
622 | const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
|
---|
623 | const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
|
---|
624 | "component:removed" /* COMPONENT_REMOVED */
|
---|
625 | );
|
---|
626 | const devtoolsComponentRemoved = (component) => {
|
---|
627 | if (devtools$1 && typeof devtools$1.cleanupBuffer === "function" && // remove the component if it wasn't buffered
|
---|
628 | !devtools$1.cleanupBuffer(component)) {
|
---|
629 | _devtoolsComponentRemoved(component);
|
---|
630 | }
|
---|
631 | };
|
---|
632 | /*! #__NO_SIDE_EFFECTS__ */
|
---|
633 | // @__NO_SIDE_EFFECTS__
|
---|
634 | function createDevtoolsComponentHook(hook) {
|
---|
635 | return (component) => {
|
---|
636 | emit$1(
|
---|
637 | hook,
|
---|
638 | component.appContext.app,
|
---|
639 | component.uid,
|
---|
640 | component.parent ? component.parent.uid : void 0,
|
---|
641 | component
|
---|
642 | );
|
---|
643 | };
|
---|
644 | }
|
---|
645 | const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
|
---|
646 | const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
|
---|
647 | function createDevtoolsPerformanceHook(hook) {
|
---|
648 | return (component, type, time) => {
|
---|
649 | emit$1(hook, component.appContext.app, component.uid, component, type, time);
|
---|
650 | };
|
---|
651 | }
|
---|
652 | function devtoolsComponentEmit(component, event, params) {
|
---|
653 | emit$1(
|
---|
654 | "component:emit" /* COMPONENT_EMIT */,
|
---|
655 | component.appContext.app,
|
---|
656 | component,
|
---|
657 | event,
|
---|
658 | params
|
---|
659 | );
|
---|
660 | }
|
---|
661 |
|
---|
662 | let currentRenderingInstance = null;
|
---|
663 | let currentScopeId = null;
|
---|
664 | function setCurrentRenderingInstance(instance) {
|
---|
665 | const prev = currentRenderingInstance;
|
---|
666 | currentRenderingInstance = instance;
|
---|
667 | currentScopeId = instance && instance.type.__scopeId || null;
|
---|
668 | return prev;
|
---|
669 | }
|
---|
670 | function pushScopeId(id) {
|
---|
671 | currentScopeId = id;
|
---|
672 | }
|
---|
673 | function popScopeId() {
|
---|
674 | currentScopeId = null;
|
---|
675 | }
|
---|
676 | const withScopeId = (_id) => withCtx;
|
---|
677 | function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
|
---|
678 | if (!ctx) return fn;
|
---|
679 | if (fn._n) {
|
---|
680 | return fn;
|
---|
681 | }
|
---|
682 | const renderFnWithContext = (...args) => {
|
---|
683 | if (renderFnWithContext._d) {
|
---|
684 | setBlockTracking(-1);
|
---|
685 | }
|
---|
686 | const prevInstance = setCurrentRenderingInstance(ctx);
|
---|
687 | let res;
|
---|
688 | try {
|
---|
689 | res = fn(...args);
|
---|
690 | } finally {
|
---|
691 | setCurrentRenderingInstance(prevInstance);
|
---|
692 | if (renderFnWithContext._d) {
|
---|
693 | setBlockTracking(1);
|
---|
694 | }
|
---|
695 | }
|
---|
696 | {
|
---|
697 | devtoolsComponentUpdated(ctx);
|
---|
698 | }
|
---|
699 | return res;
|
---|
700 | };
|
---|
701 | renderFnWithContext._n = true;
|
---|
702 | renderFnWithContext._c = true;
|
---|
703 | renderFnWithContext._d = true;
|
---|
704 | return renderFnWithContext;
|
---|
705 | }
|
---|
706 |
|
---|
707 | function validateDirectiveName(name) {
|
---|
708 | if (shared.isBuiltInDirective(name)) {
|
---|
709 | warn$1("Do not use built-in directive ids as custom directive id: " + name);
|
---|
710 | }
|
---|
711 | }
|
---|
712 | function withDirectives(vnode, directives) {
|
---|
713 | if (currentRenderingInstance === null) {
|
---|
714 | warn$1(`withDirectives can only be used inside render functions.`);
|
---|
715 | return vnode;
|
---|
716 | }
|
---|
717 | const instance = getComponentPublicInstance(currentRenderingInstance);
|
---|
718 | const bindings = vnode.dirs || (vnode.dirs = []);
|
---|
719 | for (let i = 0; i < directives.length; i++) {
|
---|
720 | let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
|
---|
721 | if (dir) {
|
---|
722 | if (shared.isFunction(dir)) {
|
---|
723 | dir = {
|
---|
724 | mounted: dir,
|
---|
725 | updated: dir
|
---|
726 | };
|
---|
727 | }
|
---|
728 | if (dir.deep) {
|
---|
729 | reactivity.traverse(value);
|
---|
730 | }
|
---|
731 | bindings.push({
|
---|
732 | dir,
|
---|
733 | instance,
|
---|
734 | value,
|
---|
735 | oldValue: void 0,
|
---|
736 | arg,
|
---|
737 | modifiers
|
---|
738 | });
|
---|
739 | }
|
---|
740 | }
|
---|
741 | return vnode;
|
---|
742 | }
|
---|
743 | function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
---|
744 | const bindings = vnode.dirs;
|
---|
745 | const oldBindings = prevVNode && prevVNode.dirs;
|
---|
746 | for (let i = 0; i < bindings.length; i++) {
|
---|
747 | const binding = bindings[i];
|
---|
748 | if (oldBindings) {
|
---|
749 | binding.oldValue = oldBindings[i].value;
|
---|
750 | }
|
---|
751 | let hook = binding.dir[name];
|
---|
752 | if (hook) {
|
---|
753 | reactivity.pauseTracking();
|
---|
754 | callWithAsyncErrorHandling(hook, instance, 8, [
|
---|
755 | vnode.el,
|
---|
756 | binding,
|
---|
757 | vnode,
|
---|
758 | prevVNode
|
---|
759 | ]);
|
---|
760 | reactivity.resetTracking();
|
---|
761 | }
|
---|
762 | }
|
---|
763 | }
|
---|
764 |
|
---|
765 | const TeleportEndKey = Symbol("_vte");
|
---|
766 | const isTeleport = (type) => type.__isTeleport;
|
---|
767 | const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
|
---|
768 | const isTeleportDeferred = (props) => props && (props.defer || props.defer === "");
|
---|
769 | const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
|
---|
770 | const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
|
---|
771 | const resolveTarget = (props, select) => {
|
---|
772 | const targetSelector = props && props.to;
|
---|
773 | if (shared.isString(targetSelector)) {
|
---|
774 | if (!select) {
|
---|
775 | warn$1(
|
---|
776 | `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
|
---|
777 | );
|
---|
778 | return null;
|
---|
779 | } else {
|
---|
780 | const target = select(targetSelector);
|
---|
781 | if (!target && !isTeleportDisabled(props)) {
|
---|
782 | warn$1(
|
---|
783 | `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`
|
---|
784 | );
|
---|
785 | }
|
---|
786 | return target;
|
---|
787 | }
|
---|
788 | } else {
|
---|
789 | if (!targetSelector && !isTeleportDisabled(props)) {
|
---|
790 | warn$1(`Invalid Teleport target: ${targetSelector}`);
|
---|
791 | }
|
---|
792 | return targetSelector;
|
---|
793 | }
|
---|
794 | };
|
---|
795 | const TeleportImpl = {
|
---|
796 | name: "Teleport",
|
---|
797 | __isTeleport: true,
|
---|
798 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) {
|
---|
799 | const {
|
---|
800 | mc: mountChildren,
|
---|
801 | pc: patchChildren,
|
---|
802 | pbc: patchBlockChildren,
|
---|
803 | o: { insert, querySelector, createText, createComment }
|
---|
804 | } = internals;
|
---|
805 | const disabled = isTeleportDisabled(n2.props);
|
---|
806 | let { shapeFlag, children, dynamicChildren } = n2;
|
---|
807 | if (isHmrUpdating) {
|
---|
808 | optimized = false;
|
---|
809 | dynamicChildren = null;
|
---|
810 | }
|
---|
811 | if (n1 == null) {
|
---|
812 | const placeholder = n2.el = createComment("teleport start") ;
|
---|
813 | const mainAnchor = n2.anchor = createComment("teleport end") ;
|
---|
814 | insert(placeholder, container, anchor);
|
---|
815 | insert(mainAnchor, container, anchor);
|
---|
816 | const mount = (container2, anchor2) => {
|
---|
817 | if (shapeFlag & 16) {
|
---|
818 | if (parentComponent && parentComponent.isCE) {
|
---|
819 | parentComponent.ce._teleportTarget = container2;
|
---|
820 | }
|
---|
821 | mountChildren(
|
---|
822 | children,
|
---|
823 | container2,
|
---|
824 | anchor2,
|
---|
825 | parentComponent,
|
---|
826 | parentSuspense,
|
---|
827 | namespace,
|
---|
828 | slotScopeIds,
|
---|
829 | optimized
|
---|
830 | );
|
---|
831 | }
|
---|
832 | };
|
---|
833 | const mountToTarget = () => {
|
---|
834 | const target = n2.target = resolveTarget(n2.props, querySelector);
|
---|
835 | const targetAnchor = prepareAnchor(target, n2, createText, insert);
|
---|
836 | if (target) {
|
---|
837 | if (namespace !== "svg" && isTargetSVG(target)) {
|
---|
838 | namespace = "svg";
|
---|
839 | } else if (namespace !== "mathml" && isTargetMathML(target)) {
|
---|
840 | namespace = "mathml";
|
---|
841 | }
|
---|
842 | if (!disabled) {
|
---|
843 | mount(target, targetAnchor);
|
---|
844 | updateCssVars(n2, false);
|
---|
845 | }
|
---|
846 | } else if (!disabled) {
|
---|
847 | warn$1(
|
---|
848 | "Invalid Teleport target on mount:",
|
---|
849 | target,
|
---|
850 | `(${typeof target})`
|
---|
851 | );
|
---|
852 | }
|
---|
853 | };
|
---|
854 | if (disabled) {
|
---|
855 | mount(container, mainAnchor);
|
---|
856 | updateCssVars(n2, true);
|
---|
857 | }
|
---|
858 | if (isTeleportDeferred(n2.props)) {
|
---|
859 | queuePostRenderEffect(() => {
|
---|
860 | mountToTarget();
|
---|
861 | n2.el.__isMounted = true;
|
---|
862 | }, parentSuspense);
|
---|
863 | } else {
|
---|
864 | mountToTarget();
|
---|
865 | }
|
---|
866 | } else {
|
---|
867 | if (isTeleportDeferred(n2.props) && !n1.el.__isMounted) {
|
---|
868 | queuePostRenderEffect(() => {
|
---|
869 | TeleportImpl.process(
|
---|
870 | n1,
|
---|
871 | n2,
|
---|
872 | container,
|
---|
873 | anchor,
|
---|
874 | parentComponent,
|
---|
875 | parentSuspense,
|
---|
876 | namespace,
|
---|
877 | slotScopeIds,
|
---|
878 | optimized,
|
---|
879 | internals
|
---|
880 | );
|
---|
881 | delete n1.el.__isMounted;
|
---|
882 | }, parentSuspense);
|
---|
883 | return;
|
---|
884 | }
|
---|
885 | n2.el = n1.el;
|
---|
886 | n2.targetStart = n1.targetStart;
|
---|
887 | const mainAnchor = n2.anchor = n1.anchor;
|
---|
888 | const target = n2.target = n1.target;
|
---|
889 | const targetAnchor = n2.targetAnchor = n1.targetAnchor;
|
---|
890 | const wasDisabled = isTeleportDisabled(n1.props);
|
---|
891 | const currentContainer = wasDisabled ? container : target;
|
---|
892 | const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
---|
893 | if (namespace === "svg" || isTargetSVG(target)) {
|
---|
894 | namespace = "svg";
|
---|
895 | } else if (namespace === "mathml" || isTargetMathML(target)) {
|
---|
896 | namespace = "mathml";
|
---|
897 | }
|
---|
898 | if (dynamicChildren) {
|
---|
899 | patchBlockChildren(
|
---|
900 | n1.dynamicChildren,
|
---|
901 | dynamicChildren,
|
---|
902 | currentContainer,
|
---|
903 | parentComponent,
|
---|
904 | parentSuspense,
|
---|
905 | namespace,
|
---|
906 | slotScopeIds
|
---|
907 | );
|
---|
908 | traverseStaticChildren(n1, n2, true);
|
---|
909 | } else if (!optimized) {
|
---|
910 | patchChildren(
|
---|
911 | n1,
|
---|
912 | n2,
|
---|
913 | currentContainer,
|
---|
914 | currentAnchor,
|
---|
915 | parentComponent,
|
---|
916 | parentSuspense,
|
---|
917 | namespace,
|
---|
918 | slotScopeIds,
|
---|
919 | false
|
---|
920 | );
|
---|
921 | }
|
---|
922 | if (disabled) {
|
---|
923 | if (!wasDisabled) {
|
---|
924 | moveTeleport(
|
---|
925 | n2,
|
---|
926 | container,
|
---|
927 | mainAnchor,
|
---|
928 | internals,
|
---|
929 | 1
|
---|
930 | );
|
---|
931 | } else {
|
---|
932 | if (n2.props && n1.props && n2.props.to !== n1.props.to) {
|
---|
933 | n2.props.to = n1.props.to;
|
---|
934 | }
|
---|
935 | }
|
---|
936 | } else {
|
---|
937 | if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
---|
938 | const nextTarget = n2.target = resolveTarget(
|
---|
939 | n2.props,
|
---|
940 | querySelector
|
---|
941 | );
|
---|
942 | if (nextTarget) {
|
---|
943 | moveTeleport(
|
---|
944 | n2,
|
---|
945 | nextTarget,
|
---|
946 | null,
|
---|
947 | internals,
|
---|
948 | 0
|
---|
949 | );
|
---|
950 | } else {
|
---|
951 | warn$1(
|
---|
952 | "Invalid Teleport target on update:",
|
---|
953 | target,
|
---|
954 | `(${typeof target})`
|
---|
955 | );
|
---|
956 | }
|
---|
957 | } else if (wasDisabled) {
|
---|
958 | moveTeleport(
|
---|
959 | n2,
|
---|
960 | target,
|
---|
961 | targetAnchor,
|
---|
962 | internals,
|
---|
963 | 1
|
---|
964 | );
|
---|
965 | }
|
---|
966 | }
|
---|
967 | updateCssVars(n2, disabled);
|
---|
968 | }
|
---|
969 | },
|
---|
970 | remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
|
---|
971 | const {
|
---|
972 | shapeFlag,
|
---|
973 | children,
|
---|
974 | anchor,
|
---|
975 | targetStart,
|
---|
976 | targetAnchor,
|
---|
977 | target,
|
---|
978 | props
|
---|
979 | } = vnode;
|
---|
980 | if (target) {
|
---|
981 | hostRemove(targetStart);
|
---|
982 | hostRemove(targetAnchor);
|
---|
983 | }
|
---|
984 | doRemove && hostRemove(anchor);
|
---|
985 | if (shapeFlag & 16) {
|
---|
986 | const shouldRemove = doRemove || !isTeleportDisabled(props);
|
---|
987 | for (let i = 0; i < children.length; i++) {
|
---|
988 | const child = children[i];
|
---|
989 | unmount(
|
---|
990 | child,
|
---|
991 | parentComponent,
|
---|
992 | parentSuspense,
|
---|
993 | shouldRemove,
|
---|
994 | !!child.dynamicChildren
|
---|
995 | );
|
---|
996 | }
|
---|
997 | }
|
---|
998 | },
|
---|
999 | move: moveTeleport,
|
---|
1000 | hydrate: hydrateTeleport
|
---|
1001 | };
|
---|
1002 | function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
|
---|
1003 | if (moveType === 0) {
|
---|
1004 | insert(vnode.targetAnchor, container, parentAnchor);
|
---|
1005 | }
|
---|
1006 | const { el, anchor, shapeFlag, children, props } = vnode;
|
---|
1007 | const isReorder = moveType === 2;
|
---|
1008 | if (isReorder) {
|
---|
1009 | insert(el, container, parentAnchor);
|
---|
1010 | }
|
---|
1011 | if (!isReorder || isTeleportDisabled(props)) {
|
---|
1012 | if (shapeFlag & 16) {
|
---|
1013 | for (let i = 0; i < children.length; i++) {
|
---|
1014 | move(
|
---|
1015 | children[i],
|
---|
1016 | container,
|
---|
1017 | parentAnchor,
|
---|
1018 | 2
|
---|
1019 | );
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 | if (isReorder) {
|
---|
1024 | insert(anchor, container, parentAnchor);
|
---|
1025 | }
|
---|
1026 | }
|
---|
1027 | function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
|
---|
1028 | o: { nextSibling, parentNode, querySelector, insert, createText }
|
---|
1029 | }, hydrateChildren) {
|
---|
1030 | const target = vnode.target = resolveTarget(
|
---|
1031 | vnode.props,
|
---|
1032 | querySelector
|
---|
1033 | );
|
---|
1034 | if (target) {
|
---|
1035 | const disabled = isTeleportDisabled(vnode.props);
|
---|
1036 | const targetNode = target._lpa || target.firstChild;
|
---|
1037 | if (vnode.shapeFlag & 16) {
|
---|
1038 | if (disabled) {
|
---|
1039 | vnode.anchor = hydrateChildren(
|
---|
1040 | nextSibling(node),
|
---|
1041 | vnode,
|
---|
1042 | parentNode(node),
|
---|
1043 | parentComponent,
|
---|
1044 | parentSuspense,
|
---|
1045 | slotScopeIds,
|
---|
1046 | optimized
|
---|
1047 | );
|
---|
1048 | vnode.targetStart = targetNode;
|
---|
1049 | vnode.targetAnchor = targetNode && nextSibling(targetNode);
|
---|
1050 | } else {
|
---|
1051 | vnode.anchor = nextSibling(node);
|
---|
1052 | let targetAnchor = targetNode;
|
---|
1053 | while (targetAnchor) {
|
---|
1054 | if (targetAnchor && targetAnchor.nodeType === 8) {
|
---|
1055 | if (targetAnchor.data === "teleport start anchor") {
|
---|
1056 | vnode.targetStart = targetAnchor;
|
---|
1057 | } else if (targetAnchor.data === "teleport anchor") {
|
---|
1058 | vnode.targetAnchor = targetAnchor;
|
---|
1059 | target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
---|
1060 | break;
|
---|
1061 | }
|
---|
1062 | }
|
---|
1063 | targetAnchor = nextSibling(targetAnchor);
|
---|
1064 | }
|
---|
1065 | if (!vnode.targetAnchor) {
|
---|
1066 | prepareAnchor(target, vnode, createText, insert);
|
---|
1067 | }
|
---|
1068 | hydrateChildren(
|
---|
1069 | targetNode && nextSibling(targetNode),
|
---|
1070 | vnode,
|
---|
1071 | target,
|
---|
1072 | parentComponent,
|
---|
1073 | parentSuspense,
|
---|
1074 | slotScopeIds,
|
---|
1075 | optimized
|
---|
1076 | );
|
---|
1077 | }
|
---|
1078 | }
|
---|
1079 | updateCssVars(vnode, disabled);
|
---|
1080 | }
|
---|
1081 | return vnode.anchor && nextSibling(vnode.anchor);
|
---|
1082 | }
|
---|
1083 | const Teleport = TeleportImpl;
|
---|
1084 | function updateCssVars(vnode, isDisabled) {
|
---|
1085 | const ctx = vnode.ctx;
|
---|
1086 | if (ctx && ctx.ut) {
|
---|
1087 | let node, anchor;
|
---|
1088 | if (isDisabled) {
|
---|
1089 | node = vnode.el;
|
---|
1090 | anchor = vnode.anchor;
|
---|
1091 | } else {
|
---|
1092 | node = vnode.targetStart;
|
---|
1093 | anchor = vnode.targetAnchor;
|
---|
1094 | }
|
---|
1095 | while (node && node !== anchor) {
|
---|
1096 | if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
|
---|
1097 | node = node.nextSibling;
|
---|
1098 | }
|
---|
1099 | ctx.ut();
|
---|
1100 | }
|
---|
1101 | }
|
---|
1102 | function prepareAnchor(target, vnode, createText, insert) {
|
---|
1103 | const targetStart = vnode.targetStart = createText("");
|
---|
1104 | const targetAnchor = vnode.targetAnchor = createText("");
|
---|
1105 | targetStart[TeleportEndKey] = targetAnchor;
|
---|
1106 | if (target) {
|
---|
1107 | insert(targetStart, target);
|
---|
1108 | insert(targetAnchor, target);
|
---|
1109 | }
|
---|
1110 | return targetAnchor;
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | const leaveCbKey = Symbol("_leaveCb");
|
---|
1114 | const enterCbKey = Symbol("_enterCb");
|
---|
1115 | function useTransitionState() {
|
---|
1116 | const state = {
|
---|
1117 | isMounted: false,
|
---|
1118 | isLeaving: false,
|
---|
1119 | isUnmounting: false,
|
---|
1120 | leavingVNodes: /* @__PURE__ */ new Map()
|
---|
1121 | };
|
---|
1122 | onMounted(() => {
|
---|
1123 | state.isMounted = true;
|
---|
1124 | });
|
---|
1125 | onBeforeUnmount(() => {
|
---|
1126 | state.isUnmounting = true;
|
---|
1127 | });
|
---|
1128 | return state;
|
---|
1129 | }
|
---|
1130 | const TransitionHookValidator = [Function, Array];
|
---|
1131 | const BaseTransitionPropsValidators = {
|
---|
1132 | mode: String,
|
---|
1133 | appear: Boolean,
|
---|
1134 | persisted: Boolean,
|
---|
1135 | // enter
|
---|
1136 | onBeforeEnter: TransitionHookValidator,
|
---|
1137 | onEnter: TransitionHookValidator,
|
---|
1138 | onAfterEnter: TransitionHookValidator,
|
---|
1139 | onEnterCancelled: TransitionHookValidator,
|
---|
1140 | // leave
|
---|
1141 | onBeforeLeave: TransitionHookValidator,
|
---|
1142 | onLeave: TransitionHookValidator,
|
---|
1143 | onAfterLeave: TransitionHookValidator,
|
---|
1144 | onLeaveCancelled: TransitionHookValidator,
|
---|
1145 | // appear
|
---|
1146 | onBeforeAppear: TransitionHookValidator,
|
---|
1147 | onAppear: TransitionHookValidator,
|
---|
1148 | onAfterAppear: TransitionHookValidator,
|
---|
1149 | onAppearCancelled: TransitionHookValidator
|
---|
1150 | };
|
---|
1151 | const recursiveGetSubtree = (instance) => {
|
---|
1152 | const subTree = instance.subTree;
|
---|
1153 | return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
|
---|
1154 | };
|
---|
1155 | const BaseTransitionImpl = {
|
---|
1156 | name: `BaseTransition`,
|
---|
1157 | props: BaseTransitionPropsValidators,
|
---|
1158 | setup(props, { slots }) {
|
---|
1159 | const instance = getCurrentInstance();
|
---|
1160 | const state = useTransitionState();
|
---|
1161 | return () => {
|
---|
1162 | const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
---|
1163 | if (!children || !children.length) {
|
---|
1164 | return;
|
---|
1165 | }
|
---|
1166 | const child = findNonCommentChild(children);
|
---|
1167 | const rawProps = reactivity.toRaw(props);
|
---|
1168 | const { mode } = rawProps;
|
---|
1169 | if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
|
---|
1170 | warn$1(`invalid <transition> mode: ${mode}`);
|
---|
1171 | }
|
---|
1172 | if (state.isLeaving) {
|
---|
1173 | return emptyPlaceholder(child);
|
---|
1174 | }
|
---|
1175 | const innerChild = getInnerChild$1(child);
|
---|
1176 | if (!innerChild) {
|
---|
1177 | return emptyPlaceholder(child);
|
---|
1178 | }
|
---|
1179 | let enterHooks = resolveTransitionHooks(
|
---|
1180 | innerChild,
|
---|
1181 | rawProps,
|
---|
1182 | state,
|
---|
1183 | instance,
|
---|
1184 | // #11061, ensure enterHooks is fresh after clone
|
---|
1185 | (hooks) => enterHooks = hooks
|
---|
1186 | );
|
---|
1187 | if (innerChild.type !== Comment) {
|
---|
1188 | setTransitionHooks(innerChild, enterHooks);
|
---|
1189 | }
|
---|
1190 | let oldInnerChild = instance.subTree && getInnerChild$1(instance.subTree);
|
---|
1191 | if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
|
---|
1192 | let leavingHooks = resolveTransitionHooks(
|
---|
1193 | oldInnerChild,
|
---|
1194 | rawProps,
|
---|
1195 | state,
|
---|
1196 | instance
|
---|
1197 | );
|
---|
1198 | setTransitionHooks(oldInnerChild, leavingHooks);
|
---|
1199 | if (mode === "out-in" && innerChild.type !== Comment) {
|
---|
1200 | state.isLeaving = true;
|
---|
1201 | leavingHooks.afterLeave = () => {
|
---|
1202 | state.isLeaving = false;
|
---|
1203 | if (!(instance.job.flags & 8)) {
|
---|
1204 | instance.update();
|
---|
1205 | }
|
---|
1206 | delete leavingHooks.afterLeave;
|
---|
1207 | oldInnerChild = void 0;
|
---|
1208 | };
|
---|
1209 | return emptyPlaceholder(child);
|
---|
1210 | } else if (mode === "in-out" && innerChild.type !== Comment) {
|
---|
1211 | leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
---|
1212 | const leavingVNodesCache = getLeavingNodesForType(
|
---|
1213 | state,
|
---|
1214 | oldInnerChild
|
---|
1215 | );
|
---|
1216 | leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
---|
1217 | el[leaveCbKey] = () => {
|
---|
1218 | earlyRemove();
|
---|
1219 | el[leaveCbKey] = void 0;
|
---|
1220 | delete enterHooks.delayedLeave;
|
---|
1221 | oldInnerChild = void 0;
|
---|
1222 | };
|
---|
1223 | enterHooks.delayedLeave = () => {
|
---|
1224 | delayedLeave();
|
---|
1225 | delete enterHooks.delayedLeave;
|
---|
1226 | oldInnerChild = void 0;
|
---|
1227 | };
|
---|
1228 | };
|
---|
1229 | } else {
|
---|
1230 | oldInnerChild = void 0;
|
---|
1231 | }
|
---|
1232 | } else if (oldInnerChild) {
|
---|
1233 | oldInnerChild = void 0;
|
---|
1234 | }
|
---|
1235 | return child;
|
---|
1236 | };
|
---|
1237 | }
|
---|
1238 | };
|
---|
1239 | function findNonCommentChild(children) {
|
---|
1240 | let child = children[0];
|
---|
1241 | if (children.length > 1) {
|
---|
1242 | let hasFound = false;
|
---|
1243 | for (const c of children) {
|
---|
1244 | if (c.type !== Comment) {
|
---|
1245 | if (hasFound) {
|
---|
1246 | warn$1(
|
---|
1247 | "<transition> can only be used on a single element or component. Use <transition-group> for lists."
|
---|
1248 | );
|
---|
1249 | break;
|
---|
1250 | }
|
---|
1251 | child = c;
|
---|
1252 | hasFound = true;
|
---|
1253 | }
|
---|
1254 | }
|
---|
1255 | }
|
---|
1256 | return child;
|
---|
1257 | }
|
---|
1258 | const BaseTransition = BaseTransitionImpl;
|
---|
1259 | function getLeavingNodesForType(state, vnode) {
|
---|
1260 | const { leavingVNodes } = state;
|
---|
1261 | let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
---|
1262 | if (!leavingVNodesCache) {
|
---|
1263 | leavingVNodesCache = /* @__PURE__ */ Object.create(null);
|
---|
1264 | leavingVNodes.set(vnode.type, leavingVNodesCache);
|
---|
1265 | }
|
---|
1266 | return leavingVNodesCache;
|
---|
1267 | }
|
---|
1268 | function resolveTransitionHooks(vnode, props, state, instance, postClone) {
|
---|
1269 | const {
|
---|
1270 | appear,
|
---|
1271 | mode,
|
---|
1272 | persisted = false,
|
---|
1273 | onBeforeEnter,
|
---|
1274 | onEnter,
|
---|
1275 | onAfterEnter,
|
---|
1276 | onEnterCancelled,
|
---|
1277 | onBeforeLeave,
|
---|
1278 | onLeave,
|
---|
1279 | onAfterLeave,
|
---|
1280 | onLeaveCancelled,
|
---|
1281 | onBeforeAppear,
|
---|
1282 | onAppear,
|
---|
1283 | onAfterAppear,
|
---|
1284 | onAppearCancelled
|
---|
1285 | } = props;
|
---|
1286 | const key = String(vnode.key);
|
---|
1287 | const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
---|
1288 | const callHook = (hook, args) => {
|
---|
1289 | hook && callWithAsyncErrorHandling(
|
---|
1290 | hook,
|
---|
1291 | instance,
|
---|
1292 | 9,
|
---|
1293 | args
|
---|
1294 | );
|
---|
1295 | };
|
---|
1296 | const callAsyncHook = (hook, args) => {
|
---|
1297 | const done = args[1];
|
---|
1298 | callHook(hook, args);
|
---|
1299 | if (shared.isArray(hook)) {
|
---|
1300 | if (hook.every((hook2) => hook2.length <= 1)) done();
|
---|
1301 | } else if (hook.length <= 1) {
|
---|
1302 | done();
|
---|
1303 | }
|
---|
1304 | };
|
---|
1305 | const hooks = {
|
---|
1306 | mode,
|
---|
1307 | persisted,
|
---|
1308 | beforeEnter(el) {
|
---|
1309 | let hook = onBeforeEnter;
|
---|
1310 | if (!state.isMounted) {
|
---|
1311 | if (appear) {
|
---|
1312 | hook = onBeforeAppear || onBeforeEnter;
|
---|
1313 | } else {
|
---|
1314 | return;
|
---|
1315 | }
|
---|
1316 | }
|
---|
1317 | if (el[leaveCbKey]) {
|
---|
1318 | el[leaveCbKey](
|
---|
1319 | true
|
---|
1320 | /* cancelled */
|
---|
1321 | );
|
---|
1322 | }
|
---|
1323 | const leavingVNode = leavingVNodesCache[key];
|
---|
1324 | if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
|
---|
1325 | leavingVNode.el[leaveCbKey]();
|
---|
1326 | }
|
---|
1327 | callHook(hook, [el]);
|
---|
1328 | },
|
---|
1329 | enter(el) {
|
---|
1330 | let hook = onEnter;
|
---|
1331 | let afterHook = onAfterEnter;
|
---|
1332 | let cancelHook = onEnterCancelled;
|
---|
1333 | if (!state.isMounted) {
|
---|
1334 | if (appear) {
|
---|
1335 | hook = onAppear || onEnter;
|
---|
1336 | afterHook = onAfterAppear || onAfterEnter;
|
---|
1337 | cancelHook = onAppearCancelled || onEnterCancelled;
|
---|
1338 | } else {
|
---|
1339 | return;
|
---|
1340 | }
|
---|
1341 | }
|
---|
1342 | let called = false;
|
---|
1343 | const done = el[enterCbKey] = (cancelled) => {
|
---|
1344 | if (called) return;
|
---|
1345 | called = true;
|
---|
1346 | if (cancelled) {
|
---|
1347 | callHook(cancelHook, [el]);
|
---|
1348 | } else {
|
---|
1349 | callHook(afterHook, [el]);
|
---|
1350 | }
|
---|
1351 | if (hooks.delayedLeave) {
|
---|
1352 | hooks.delayedLeave();
|
---|
1353 | }
|
---|
1354 | el[enterCbKey] = void 0;
|
---|
1355 | };
|
---|
1356 | if (hook) {
|
---|
1357 | callAsyncHook(hook, [el, done]);
|
---|
1358 | } else {
|
---|
1359 | done();
|
---|
1360 | }
|
---|
1361 | },
|
---|
1362 | leave(el, remove) {
|
---|
1363 | const key2 = String(vnode.key);
|
---|
1364 | if (el[enterCbKey]) {
|
---|
1365 | el[enterCbKey](
|
---|
1366 | true
|
---|
1367 | /* cancelled */
|
---|
1368 | );
|
---|
1369 | }
|
---|
1370 | if (state.isUnmounting) {
|
---|
1371 | return remove();
|
---|
1372 | }
|
---|
1373 | callHook(onBeforeLeave, [el]);
|
---|
1374 | let called = false;
|
---|
1375 | const done = el[leaveCbKey] = (cancelled) => {
|
---|
1376 | if (called) return;
|
---|
1377 | called = true;
|
---|
1378 | remove();
|
---|
1379 | if (cancelled) {
|
---|
1380 | callHook(onLeaveCancelled, [el]);
|
---|
1381 | } else {
|
---|
1382 | callHook(onAfterLeave, [el]);
|
---|
1383 | }
|
---|
1384 | el[leaveCbKey] = void 0;
|
---|
1385 | if (leavingVNodesCache[key2] === vnode) {
|
---|
1386 | delete leavingVNodesCache[key2];
|
---|
1387 | }
|
---|
1388 | };
|
---|
1389 | leavingVNodesCache[key2] = vnode;
|
---|
1390 | if (onLeave) {
|
---|
1391 | callAsyncHook(onLeave, [el, done]);
|
---|
1392 | } else {
|
---|
1393 | done();
|
---|
1394 | }
|
---|
1395 | },
|
---|
1396 | clone(vnode2) {
|
---|
1397 | const hooks2 = resolveTransitionHooks(
|
---|
1398 | vnode2,
|
---|
1399 | props,
|
---|
1400 | state,
|
---|
1401 | instance,
|
---|
1402 | postClone
|
---|
1403 | );
|
---|
1404 | if (postClone) postClone(hooks2);
|
---|
1405 | return hooks2;
|
---|
1406 | }
|
---|
1407 | };
|
---|
1408 | return hooks;
|
---|
1409 | }
|
---|
1410 | function emptyPlaceholder(vnode) {
|
---|
1411 | if (isKeepAlive(vnode)) {
|
---|
1412 | vnode = cloneVNode(vnode);
|
---|
1413 | vnode.children = null;
|
---|
1414 | return vnode;
|
---|
1415 | }
|
---|
1416 | }
|
---|
1417 | function getInnerChild$1(vnode) {
|
---|
1418 | if (!isKeepAlive(vnode)) {
|
---|
1419 | if (isTeleport(vnode.type) && vnode.children) {
|
---|
1420 | return findNonCommentChild(vnode.children);
|
---|
1421 | }
|
---|
1422 | return vnode;
|
---|
1423 | }
|
---|
1424 | if (vnode.component) {
|
---|
1425 | return vnode.component.subTree;
|
---|
1426 | }
|
---|
1427 | const { shapeFlag, children } = vnode;
|
---|
1428 | if (children) {
|
---|
1429 | if (shapeFlag & 16) {
|
---|
1430 | return children[0];
|
---|
1431 | }
|
---|
1432 | if (shapeFlag & 32 && shared.isFunction(children.default)) {
|
---|
1433 | return children.default();
|
---|
1434 | }
|
---|
1435 | }
|
---|
1436 | }
|
---|
1437 | function setTransitionHooks(vnode, hooks) {
|
---|
1438 | if (vnode.shapeFlag & 6 && vnode.component) {
|
---|
1439 | vnode.transition = hooks;
|
---|
1440 | setTransitionHooks(vnode.component.subTree, hooks);
|
---|
1441 | } else if (vnode.shapeFlag & 128) {
|
---|
1442 | vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
---|
1443 | vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
---|
1444 | } else {
|
---|
1445 | vnode.transition = hooks;
|
---|
1446 | }
|
---|
1447 | }
|
---|
1448 | function getTransitionRawChildren(children, keepComment = false, parentKey) {
|
---|
1449 | let ret = [];
|
---|
1450 | let keyedFragmentCount = 0;
|
---|
1451 | for (let i = 0; i < children.length; i++) {
|
---|
1452 | let child = children[i];
|
---|
1453 | const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
|
---|
1454 | if (child.type === Fragment) {
|
---|
1455 | if (child.patchFlag & 128) keyedFragmentCount++;
|
---|
1456 | ret = ret.concat(
|
---|
1457 | getTransitionRawChildren(child.children, keepComment, key)
|
---|
1458 | );
|
---|
1459 | } else if (keepComment || child.type !== Comment) {
|
---|
1460 | ret.push(key != null ? cloneVNode(child, { key }) : child);
|
---|
1461 | }
|
---|
1462 | }
|
---|
1463 | if (keyedFragmentCount > 1) {
|
---|
1464 | for (let i = 0; i < ret.length; i++) {
|
---|
1465 | ret[i].patchFlag = -2;
|
---|
1466 | }
|
---|
1467 | }
|
---|
1468 | return ret;
|
---|
1469 | }
|
---|
1470 |
|
---|
1471 | /*! #__NO_SIDE_EFFECTS__ */
|
---|
1472 | // @__NO_SIDE_EFFECTS__
|
---|
1473 | function defineComponent(options, extraOptions) {
|
---|
1474 | return shared.isFunction(options) ? (
|
---|
1475 | // #8236: extend call and options.name access are considered side-effects
|
---|
1476 | // by Rollup, so we have to wrap it in a pure-annotated IIFE.
|
---|
1477 | /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
|
---|
1478 | ) : options;
|
---|
1479 | }
|
---|
1480 |
|
---|
1481 | function useId() {
|
---|
1482 | const i = getCurrentInstance();
|
---|
1483 | if (i) {
|
---|
1484 | return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++;
|
---|
1485 | } else {
|
---|
1486 | warn$1(
|
---|
1487 | `useId() is called when there is no active component instance to be associated with.`
|
---|
1488 | );
|
---|
1489 | }
|
---|
1490 | return "";
|
---|
1491 | }
|
---|
1492 | function markAsyncBoundary(instance) {
|
---|
1493 | instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
|
---|
1494 | }
|
---|
1495 |
|
---|
1496 | const knownTemplateRefs = /* @__PURE__ */ new WeakSet();
|
---|
1497 | function useTemplateRef(key) {
|
---|
1498 | const i = getCurrentInstance();
|
---|
1499 | const r = reactivity.shallowRef(null);
|
---|
1500 | if (i) {
|
---|
1501 | const refs = i.refs === shared.EMPTY_OBJ ? i.refs = {} : i.refs;
|
---|
1502 | let desc;
|
---|
1503 | if ((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable) {
|
---|
1504 | warn$1(`useTemplateRef('${key}') already exists.`);
|
---|
1505 | } else {
|
---|
1506 | Object.defineProperty(refs, key, {
|
---|
1507 | enumerable: true,
|
---|
1508 | get: () => r.value,
|
---|
1509 | set: (val) => r.value = val
|
---|
1510 | });
|
---|
1511 | }
|
---|
1512 | } else {
|
---|
1513 | warn$1(
|
---|
1514 | `useTemplateRef() is called when there is no active component instance to be associated with.`
|
---|
1515 | );
|
---|
1516 | }
|
---|
1517 | const ret = reactivity.readonly(r) ;
|
---|
1518 | {
|
---|
1519 | knownTemplateRefs.add(ret);
|
---|
1520 | }
|
---|
1521 | return ret;
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
---|
1525 | if (shared.isArray(rawRef)) {
|
---|
1526 | rawRef.forEach(
|
---|
1527 | (r, i) => setRef(
|
---|
1528 | r,
|
---|
1529 | oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
|
---|
1530 | parentSuspense,
|
---|
1531 | vnode,
|
---|
1532 | isUnmount
|
---|
1533 | )
|
---|
1534 | );
|
---|
1535 | return;
|
---|
1536 | }
|
---|
1537 | if (isAsyncWrapper(vnode) && !isUnmount) {
|
---|
1538 | if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
|
---|
1539 | setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
|
---|
1540 | }
|
---|
1541 | return;
|
---|
1542 | }
|
---|
1543 | const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
|
---|
1544 | const value = isUnmount ? null : refValue;
|
---|
1545 | const { i: owner, r: ref } = rawRef;
|
---|
1546 | if (!owner) {
|
---|
1547 | warn$1(
|
---|
1548 | `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
|
---|
1549 | );
|
---|
1550 | return;
|
---|
1551 | }
|
---|
1552 | const oldRef = oldRawRef && oldRawRef.r;
|
---|
1553 | const refs = owner.refs === shared.EMPTY_OBJ ? owner.refs = {} : owner.refs;
|
---|
1554 | const setupState = owner.setupState;
|
---|
1555 | const rawSetupState = reactivity.toRaw(setupState);
|
---|
1556 | const canSetSetupRef = setupState === shared.EMPTY_OBJ ? () => false : (key) => {
|
---|
1557 | {
|
---|
1558 | if (shared.hasOwn(rawSetupState, key) && !reactivity.isRef(rawSetupState[key])) {
|
---|
1559 | warn$1(
|
---|
1560 | `Template ref "${key}" used on a non-ref value. It will not work in the production build.`
|
---|
1561 | );
|
---|
1562 | }
|
---|
1563 | if (knownTemplateRefs.has(rawSetupState[key])) {
|
---|
1564 | return false;
|
---|
1565 | }
|
---|
1566 | }
|
---|
1567 | return shared.hasOwn(rawSetupState, key);
|
---|
1568 | };
|
---|
1569 | if (oldRef != null && oldRef !== ref) {
|
---|
1570 | if (shared.isString(oldRef)) {
|
---|
1571 | refs[oldRef] = null;
|
---|
1572 | if (canSetSetupRef(oldRef)) {
|
---|
1573 | setupState[oldRef] = null;
|
---|
1574 | }
|
---|
1575 | } else if (reactivity.isRef(oldRef)) {
|
---|
1576 | oldRef.value = null;
|
---|
1577 | }
|
---|
1578 | }
|
---|
1579 | if (shared.isFunction(ref)) {
|
---|
1580 | callWithErrorHandling(ref, owner, 12, [value, refs]);
|
---|
1581 | } else {
|
---|
1582 | const _isString = shared.isString(ref);
|
---|
1583 | const _isRef = reactivity.isRef(ref);
|
---|
1584 | if (_isString || _isRef) {
|
---|
1585 | const doSet = () => {
|
---|
1586 | if (rawRef.f) {
|
---|
1587 | const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : ref.value;
|
---|
1588 | if (isUnmount) {
|
---|
1589 | shared.isArray(existing) && shared.remove(existing, refValue);
|
---|
1590 | } else {
|
---|
1591 | if (!shared.isArray(existing)) {
|
---|
1592 | if (_isString) {
|
---|
1593 | refs[ref] = [refValue];
|
---|
1594 | if (canSetSetupRef(ref)) {
|
---|
1595 | setupState[ref] = refs[ref];
|
---|
1596 | }
|
---|
1597 | } else {
|
---|
1598 | ref.value = [refValue];
|
---|
1599 | if (rawRef.k) refs[rawRef.k] = ref.value;
|
---|
1600 | }
|
---|
1601 | } else if (!existing.includes(refValue)) {
|
---|
1602 | existing.push(refValue);
|
---|
1603 | }
|
---|
1604 | }
|
---|
1605 | } else if (_isString) {
|
---|
1606 | refs[ref] = value;
|
---|
1607 | if (canSetSetupRef(ref)) {
|
---|
1608 | setupState[ref] = value;
|
---|
1609 | }
|
---|
1610 | } else if (_isRef) {
|
---|
1611 | ref.value = value;
|
---|
1612 | if (rawRef.k) refs[rawRef.k] = value;
|
---|
1613 | } else {
|
---|
1614 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
---|
1615 | }
|
---|
1616 | };
|
---|
1617 | if (value) {
|
---|
1618 | doSet.id = -1;
|
---|
1619 | queuePostRenderEffect(doSet, parentSuspense);
|
---|
1620 | } else {
|
---|
1621 | doSet();
|
---|
1622 | }
|
---|
1623 | } else {
|
---|
1624 | warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
|
---|
1625 | }
|
---|
1626 | }
|
---|
1627 | }
|
---|
1628 |
|
---|
1629 | let hasLoggedMismatchError = false;
|
---|
1630 | const logMismatchError = () => {
|
---|
1631 | if (hasLoggedMismatchError) {
|
---|
1632 | return;
|
---|
1633 | }
|
---|
1634 | console.error("Hydration completed but contains mismatches.");
|
---|
1635 | hasLoggedMismatchError = true;
|
---|
1636 | };
|
---|
1637 | const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
|
---|
1638 | const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
|
---|
1639 | const getContainerType = (container) => {
|
---|
1640 | if (container.nodeType !== 1) return void 0;
|
---|
1641 | if (isSVGContainer(container)) return "svg";
|
---|
1642 | if (isMathMLContainer(container)) return "mathml";
|
---|
1643 | return void 0;
|
---|
1644 | };
|
---|
1645 | const isComment = (node) => node.nodeType === 8;
|
---|
1646 | function createHydrationFunctions(rendererInternals) {
|
---|
1647 | const {
|
---|
1648 | mt: mountComponent,
|
---|
1649 | p: patch,
|
---|
1650 | o: {
|
---|
1651 | patchProp,
|
---|
1652 | createText,
|
---|
1653 | nextSibling,
|
---|
1654 | parentNode,
|
---|
1655 | remove,
|
---|
1656 | insert,
|
---|
1657 | createComment
|
---|
1658 | }
|
---|
1659 | } = rendererInternals;
|
---|
1660 | const hydrate = (vnode, container) => {
|
---|
1661 | if (!container.hasChildNodes()) {
|
---|
1662 | warn$1(
|
---|
1663 | `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
|
---|
1664 | );
|
---|
1665 | patch(null, vnode, container);
|
---|
1666 | flushPostFlushCbs();
|
---|
1667 | container._vnode = vnode;
|
---|
1668 | return;
|
---|
1669 | }
|
---|
1670 | hydrateNode(container.firstChild, vnode, null, null, null);
|
---|
1671 | flushPostFlushCbs();
|
---|
1672 | container._vnode = vnode;
|
---|
1673 | };
|
---|
1674 | const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
---|
1675 | optimized = optimized || !!vnode.dynamicChildren;
|
---|
1676 | const isFragmentStart = isComment(node) && node.data === "[";
|
---|
1677 | const onMismatch = () => handleMismatch(
|
---|
1678 | node,
|
---|
1679 | vnode,
|
---|
1680 | parentComponent,
|
---|
1681 | parentSuspense,
|
---|
1682 | slotScopeIds,
|
---|
1683 | isFragmentStart
|
---|
1684 | );
|
---|
1685 | const { type, ref, shapeFlag, patchFlag } = vnode;
|
---|
1686 | let domType = node.nodeType;
|
---|
1687 | vnode.el = node;
|
---|
1688 | {
|
---|
1689 | shared.def(node, "__vnode", vnode, true);
|
---|
1690 | shared.def(node, "__vueParentComponent", parentComponent, true);
|
---|
1691 | }
|
---|
1692 | if (patchFlag === -2) {
|
---|
1693 | optimized = false;
|
---|
1694 | vnode.dynamicChildren = null;
|
---|
1695 | }
|
---|
1696 | let nextNode = null;
|
---|
1697 | switch (type) {
|
---|
1698 | case Text:
|
---|
1699 | if (domType !== 3) {
|
---|
1700 | if (vnode.children === "") {
|
---|
1701 | insert(vnode.el = createText(""), parentNode(node), node);
|
---|
1702 | nextNode = node;
|
---|
1703 | } else {
|
---|
1704 | nextNode = onMismatch();
|
---|
1705 | }
|
---|
1706 | } else {
|
---|
1707 | if (node.data !== vnode.children) {
|
---|
1708 | warn$1(
|
---|
1709 | `Hydration text mismatch in`,
|
---|
1710 | node.parentNode,
|
---|
1711 | `
|
---|
1712 | - rendered on server: ${JSON.stringify(
|
---|
1713 | node.data
|
---|
1714 | )}
|
---|
1715 | - expected on client: ${JSON.stringify(vnode.children)}`
|
---|
1716 | );
|
---|
1717 | logMismatchError();
|
---|
1718 | node.data = vnode.children;
|
---|
1719 | }
|
---|
1720 | nextNode = nextSibling(node);
|
---|
1721 | }
|
---|
1722 | break;
|
---|
1723 | case Comment:
|
---|
1724 | if (isTemplateNode(node)) {
|
---|
1725 | nextNode = nextSibling(node);
|
---|
1726 | replaceNode(
|
---|
1727 | vnode.el = node.content.firstChild,
|
---|
1728 | node,
|
---|
1729 | parentComponent
|
---|
1730 | );
|
---|
1731 | } else if (domType !== 8 || isFragmentStart) {
|
---|
1732 | nextNode = onMismatch();
|
---|
1733 | } else {
|
---|
1734 | nextNode = nextSibling(node);
|
---|
1735 | }
|
---|
1736 | break;
|
---|
1737 | case Static:
|
---|
1738 | if (isFragmentStart) {
|
---|
1739 | node = nextSibling(node);
|
---|
1740 | domType = node.nodeType;
|
---|
1741 | }
|
---|
1742 | if (domType === 1 || domType === 3) {
|
---|
1743 | nextNode = node;
|
---|
1744 | const needToAdoptContent = !vnode.children.length;
|
---|
1745 | for (let i = 0; i < vnode.staticCount; i++) {
|
---|
1746 | if (needToAdoptContent)
|
---|
1747 | vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
|
---|
1748 | if (i === vnode.staticCount - 1) {
|
---|
1749 | vnode.anchor = nextNode;
|
---|
1750 | }
|
---|
1751 | nextNode = nextSibling(nextNode);
|
---|
1752 | }
|
---|
1753 | return isFragmentStart ? nextSibling(nextNode) : nextNode;
|
---|
1754 | } else {
|
---|
1755 | onMismatch();
|
---|
1756 | }
|
---|
1757 | break;
|
---|
1758 | case Fragment:
|
---|
1759 | if (!isFragmentStart) {
|
---|
1760 | nextNode = onMismatch();
|
---|
1761 | } else {
|
---|
1762 | nextNode = hydrateFragment(
|
---|
1763 | node,
|
---|
1764 | vnode,
|
---|
1765 | parentComponent,
|
---|
1766 | parentSuspense,
|
---|
1767 | slotScopeIds,
|
---|
1768 | optimized
|
---|
1769 | );
|
---|
1770 | }
|
---|
1771 | break;
|
---|
1772 | default:
|
---|
1773 | if (shapeFlag & 1) {
|
---|
1774 | if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
|
---|
1775 | nextNode = onMismatch();
|
---|
1776 | } else {
|
---|
1777 | nextNode = hydrateElement(
|
---|
1778 | node,
|
---|
1779 | vnode,
|
---|
1780 | parentComponent,
|
---|
1781 | parentSuspense,
|
---|
1782 | slotScopeIds,
|
---|
1783 | optimized
|
---|
1784 | );
|
---|
1785 | }
|
---|
1786 | } else if (shapeFlag & 6) {
|
---|
1787 | vnode.slotScopeIds = slotScopeIds;
|
---|
1788 | const container = parentNode(node);
|
---|
1789 | if (isFragmentStart) {
|
---|
1790 | nextNode = locateClosingAnchor(node);
|
---|
1791 | } else if (isComment(node) && node.data === "teleport start") {
|
---|
1792 | nextNode = locateClosingAnchor(node, node.data, "teleport end");
|
---|
1793 | } else {
|
---|
1794 | nextNode = nextSibling(node);
|
---|
1795 | }
|
---|
1796 | mountComponent(
|
---|
1797 | vnode,
|
---|
1798 | container,
|
---|
1799 | null,
|
---|
1800 | parentComponent,
|
---|
1801 | parentSuspense,
|
---|
1802 | getContainerType(container),
|
---|
1803 | optimized
|
---|
1804 | );
|
---|
1805 | if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
|
---|
1806 | let subTree;
|
---|
1807 | if (isFragmentStart) {
|
---|
1808 | subTree = createVNode(Fragment);
|
---|
1809 | subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
|
---|
1810 | } else {
|
---|
1811 | subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
|
---|
1812 | }
|
---|
1813 | subTree.el = node;
|
---|
1814 | vnode.component.subTree = subTree;
|
---|
1815 | }
|
---|
1816 | } else if (shapeFlag & 64) {
|
---|
1817 | if (domType !== 8) {
|
---|
1818 | nextNode = onMismatch();
|
---|
1819 | } else {
|
---|
1820 | nextNode = vnode.type.hydrate(
|
---|
1821 | node,
|
---|
1822 | vnode,
|
---|
1823 | parentComponent,
|
---|
1824 | parentSuspense,
|
---|
1825 | slotScopeIds,
|
---|
1826 | optimized,
|
---|
1827 | rendererInternals,
|
---|
1828 | hydrateChildren
|
---|
1829 | );
|
---|
1830 | }
|
---|
1831 | } else if (shapeFlag & 128) {
|
---|
1832 | nextNode = vnode.type.hydrate(
|
---|
1833 | node,
|
---|
1834 | vnode,
|
---|
1835 | parentComponent,
|
---|
1836 | parentSuspense,
|
---|
1837 | getContainerType(parentNode(node)),
|
---|
1838 | slotScopeIds,
|
---|
1839 | optimized,
|
---|
1840 | rendererInternals,
|
---|
1841 | hydrateNode
|
---|
1842 | );
|
---|
1843 | } else {
|
---|
1844 | warn$1("Invalid HostVNode type:", type, `(${typeof type})`);
|
---|
1845 | }
|
---|
1846 | }
|
---|
1847 | if (ref != null) {
|
---|
1848 | setRef(ref, null, parentSuspense, vnode);
|
---|
1849 | }
|
---|
1850 | return nextNode;
|
---|
1851 | };
|
---|
1852 | const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
---|
1853 | optimized = optimized || !!vnode.dynamicChildren;
|
---|
1854 | const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
|
---|
1855 | const forcePatch = type === "input" || type === "option";
|
---|
1856 | {
|
---|
1857 | if (dirs) {
|
---|
1858 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
---|
1859 | }
|
---|
1860 | let needCallTransitionHooks = false;
|
---|
1861 | if (isTemplateNode(el)) {
|
---|
1862 | needCallTransitionHooks = needTransition(
|
---|
1863 | null,
|
---|
1864 | // no need check parentSuspense in hydration
|
---|
1865 | transition
|
---|
1866 | ) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
|
---|
1867 | const content = el.content.firstChild;
|
---|
1868 | if (needCallTransitionHooks) {
|
---|
1869 | transition.beforeEnter(content);
|
---|
1870 | }
|
---|
1871 | replaceNode(content, el, parentComponent);
|
---|
1872 | vnode.el = el = content;
|
---|
1873 | }
|
---|
1874 | if (shapeFlag & 16 && // skip if element has innerHTML / textContent
|
---|
1875 | !(props && (props.innerHTML || props.textContent))) {
|
---|
1876 | let next = hydrateChildren(
|
---|
1877 | el.firstChild,
|
---|
1878 | vnode,
|
---|
1879 | el,
|
---|
1880 | parentComponent,
|
---|
1881 | parentSuspense,
|
---|
1882 | slotScopeIds,
|
---|
1883 | optimized
|
---|
1884 | );
|
---|
1885 | let hasWarned = false;
|
---|
1886 | while (next) {
|
---|
1887 | if (!isMismatchAllowed(el, 1 /* CHILDREN */)) {
|
---|
1888 | if (!hasWarned) {
|
---|
1889 | warn$1(
|
---|
1890 | `Hydration children mismatch on`,
|
---|
1891 | el,
|
---|
1892 | `
|
---|
1893 | Server rendered element contains more child nodes than client vdom.`
|
---|
1894 | );
|
---|
1895 | hasWarned = true;
|
---|
1896 | }
|
---|
1897 | logMismatchError();
|
---|
1898 | }
|
---|
1899 | const cur = next;
|
---|
1900 | next = next.nextSibling;
|
---|
1901 | remove(cur);
|
---|
1902 | }
|
---|
1903 | } else if (shapeFlag & 8) {
|
---|
1904 | let clientText = vnode.children;
|
---|
1905 | if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
|
---|
1906 | clientText = clientText.slice(1);
|
---|
1907 | }
|
---|
1908 | if (el.textContent !== clientText) {
|
---|
1909 | if (!isMismatchAllowed(el, 0 /* TEXT */)) {
|
---|
1910 | warn$1(
|
---|
1911 | `Hydration text content mismatch on`,
|
---|
1912 | el,
|
---|
1913 | `
|
---|
1914 | - rendered on server: ${el.textContent}
|
---|
1915 | - expected on client: ${vnode.children}`
|
---|
1916 | );
|
---|
1917 | logMismatchError();
|
---|
1918 | }
|
---|
1919 | el.textContent = vnode.children;
|
---|
1920 | }
|
---|
1921 | }
|
---|
1922 | if (props) {
|
---|
1923 | {
|
---|
1924 | const isCustomElement = el.tagName.includes("-");
|
---|
1925 | for (const key in props) {
|
---|
1926 | if (// #11189 skip if this node has directives that have created hooks
|
---|
1927 | // as it could have mutated the DOM in any possible way
|
---|
1928 | !(dirs && dirs.some((d) => d.dir.created)) && propHasMismatch(el, key, props[key], vnode, parentComponent)) {
|
---|
1929 | logMismatchError();
|
---|
1930 | }
|
---|
1931 | if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
|
---|
1932 | key[0] === "." || isCustomElement) {
|
---|
1933 | patchProp(el, key, null, props[key], void 0, parentComponent);
|
---|
1934 | }
|
---|
1935 | }
|
---|
1936 | }
|
---|
1937 | }
|
---|
1938 | let vnodeHooks;
|
---|
1939 | if (vnodeHooks = props && props.onVnodeBeforeMount) {
|
---|
1940 | invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
---|
1941 | }
|
---|
1942 | if (dirs) {
|
---|
1943 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
---|
1944 | }
|
---|
1945 | if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
|
---|
1946 | queueEffectWithSuspense(() => {
|
---|
1947 | vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
---|
1948 | needCallTransitionHooks && transition.enter(el);
|
---|
1949 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
---|
1950 | }, parentSuspense);
|
---|
1951 | }
|
---|
1952 | }
|
---|
1953 | return el.nextSibling;
|
---|
1954 | };
|
---|
1955 | const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
---|
1956 | optimized = optimized || !!parentVNode.dynamicChildren;
|
---|
1957 | const children = parentVNode.children;
|
---|
1958 | const l = children.length;
|
---|
1959 | let hasWarned = false;
|
---|
1960 | for (let i = 0; i < l; i++) {
|
---|
1961 | const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
|
---|
1962 | const isText = vnode.type === Text;
|
---|
1963 | if (node) {
|
---|
1964 | if (isText && !optimized) {
|
---|
1965 | if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
|
---|
1966 | insert(
|
---|
1967 | createText(
|
---|
1968 | node.data.slice(vnode.children.length)
|
---|
1969 | ),
|
---|
1970 | container,
|
---|
1971 | nextSibling(node)
|
---|
1972 | );
|
---|
1973 | node.data = vnode.children;
|
---|
1974 | }
|
---|
1975 | }
|
---|
1976 | node = hydrateNode(
|
---|
1977 | node,
|
---|
1978 | vnode,
|
---|
1979 | parentComponent,
|
---|
1980 | parentSuspense,
|
---|
1981 | slotScopeIds,
|
---|
1982 | optimized
|
---|
1983 | );
|
---|
1984 | } else if (isText && !vnode.children) {
|
---|
1985 | insert(vnode.el = createText(""), container);
|
---|
1986 | } else {
|
---|
1987 | if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
|
---|
1988 | if (!hasWarned) {
|
---|
1989 | warn$1(
|
---|
1990 | `Hydration children mismatch on`,
|
---|
1991 | container,
|
---|
1992 | `
|
---|
1993 | Server rendered element contains fewer child nodes than client vdom.`
|
---|
1994 | );
|
---|
1995 | hasWarned = true;
|
---|
1996 | }
|
---|
1997 | logMismatchError();
|
---|
1998 | }
|
---|
1999 | patch(
|
---|
2000 | null,
|
---|
2001 | vnode,
|
---|
2002 | container,
|
---|
2003 | null,
|
---|
2004 | parentComponent,
|
---|
2005 | parentSuspense,
|
---|
2006 | getContainerType(container),
|
---|
2007 | slotScopeIds
|
---|
2008 | );
|
---|
2009 | }
|
---|
2010 | }
|
---|
2011 | return node;
|
---|
2012 | };
|
---|
2013 | const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
---|
2014 | const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
---|
2015 | if (fragmentSlotScopeIds) {
|
---|
2016 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
---|
2017 | }
|
---|
2018 | const container = parentNode(node);
|
---|
2019 | const next = hydrateChildren(
|
---|
2020 | nextSibling(node),
|
---|
2021 | vnode,
|
---|
2022 | container,
|
---|
2023 | parentComponent,
|
---|
2024 | parentSuspense,
|
---|
2025 | slotScopeIds,
|
---|
2026 | optimized
|
---|
2027 | );
|
---|
2028 | if (next && isComment(next) && next.data === "]") {
|
---|
2029 | return nextSibling(vnode.anchor = next);
|
---|
2030 | } else {
|
---|
2031 | logMismatchError();
|
---|
2032 | insert(vnode.anchor = createComment(`]`), container, next);
|
---|
2033 | return next;
|
---|
2034 | }
|
---|
2035 | };
|
---|
2036 | const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
---|
2037 | if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
|
---|
2038 | warn$1(
|
---|
2039 | `Hydration node mismatch:
|
---|
2040 | - rendered on server:`,
|
---|
2041 | node,
|
---|
2042 | node.nodeType === 3 ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``,
|
---|
2043 | `
|
---|
2044 | - expected on client:`,
|
---|
2045 | vnode.type
|
---|
2046 | );
|
---|
2047 | logMismatchError();
|
---|
2048 | }
|
---|
2049 | vnode.el = null;
|
---|
2050 | if (isFragment) {
|
---|
2051 | const end = locateClosingAnchor(node);
|
---|
2052 | while (true) {
|
---|
2053 | const next2 = nextSibling(node);
|
---|
2054 | if (next2 && next2 !== end) {
|
---|
2055 | remove(next2);
|
---|
2056 | } else {
|
---|
2057 | break;
|
---|
2058 | }
|
---|
2059 | }
|
---|
2060 | }
|
---|
2061 | const next = nextSibling(node);
|
---|
2062 | const container = parentNode(node);
|
---|
2063 | remove(node);
|
---|
2064 | patch(
|
---|
2065 | null,
|
---|
2066 | vnode,
|
---|
2067 | container,
|
---|
2068 | next,
|
---|
2069 | parentComponent,
|
---|
2070 | parentSuspense,
|
---|
2071 | getContainerType(container),
|
---|
2072 | slotScopeIds
|
---|
2073 | );
|
---|
2074 | if (parentComponent) {
|
---|
2075 | parentComponent.vnode.el = vnode.el;
|
---|
2076 | updateHOCHostEl(parentComponent, vnode.el);
|
---|
2077 | }
|
---|
2078 | return next;
|
---|
2079 | };
|
---|
2080 | const locateClosingAnchor = (node, open = "[", close = "]") => {
|
---|
2081 | let match = 0;
|
---|
2082 | while (node) {
|
---|
2083 | node = nextSibling(node);
|
---|
2084 | if (node && isComment(node)) {
|
---|
2085 | if (node.data === open) match++;
|
---|
2086 | if (node.data === close) {
|
---|
2087 | if (match === 0) {
|
---|
2088 | return nextSibling(node);
|
---|
2089 | } else {
|
---|
2090 | match--;
|
---|
2091 | }
|
---|
2092 | }
|
---|
2093 | }
|
---|
2094 | }
|
---|
2095 | return node;
|
---|
2096 | };
|
---|
2097 | const replaceNode = (newNode, oldNode, parentComponent) => {
|
---|
2098 | const parentNode2 = oldNode.parentNode;
|
---|
2099 | if (parentNode2) {
|
---|
2100 | parentNode2.replaceChild(newNode, oldNode);
|
---|
2101 | }
|
---|
2102 | let parent = parentComponent;
|
---|
2103 | while (parent) {
|
---|
2104 | if (parent.vnode.el === oldNode) {
|
---|
2105 | parent.vnode.el = parent.subTree.el = newNode;
|
---|
2106 | }
|
---|
2107 | parent = parent.parent;
|
---|
2108 | }
|
---|
2109 | };
|
---|
2110 | const isTemplateNode = (node) => {
|
---|
2111 | return node.nodeType === 1 && node.tagName === "TEMPLATE";
|
---|
2112 | };
|
---|
2113 | return [hydrate, hydrateNode];
|
---|
2114 | }
|
---|
2115 | function propHasMismatch(el, key, clientValue, vnode, instance) {
|
---|
2116 | let mismatchType;
|
---|
2117 | let mismatchKey;
|
---|
2118 | let actual;
|
---|
2119 | let expected;
|
---|
2120 | if (key === "class") {
|
---|
2121 | actual = el.getAttribute("class");
|
---|
2122 | expected = shared.normalizeClass(clientValue);
|
---|
2123 | if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
|
---|
2124 | mismatchType = 2 /* CLASS */;
|
---|
2125 | mismatchKey = `class`;
|
---|
2126 | }
|
---|
2127 | } else if (key === "style") {
|
---|
2128 | actual = el.getAttribute("style") || "";
|
---|
2129 | expected = shared.isString(clientValue) ? clientValue : shared.stringifyStyle(shared.normalizeStyle(clientValue));
|
---|
2130 | const actualMap = toStyleMap(actual);
|
---|
2131 | const expectedMap = toStyleMap(expected);
|
---|
2132 | if (vnode.dirs) {
|
---|
2133 | for (const { dir, value } of vnode.dirs) {
|
---|
2134 | if (dir.name === "show" && !value) {
|
---|
2135 | expectedMap.set("display", "none");
|
---|
2136 | }
|
---|
2137 | }
|
---|
2138 | }
|
---|
2139 | if (instance) {
|
---|
2140 | resolveCssVars(instance, vnode, expectedMap);
|
---|
2141 | }
|
---|
2142 | if (!isMapEqual(actualMap, expectedMap)) {
|
---|
2143 | mismatchType = 3 /* STYLE */;
|
---|
2144 | mismatchKey = "style";
|
---|
2145 | }
|
---|
2146 | } else if (el instanceof SVGElement && shared.isKnownSvgAttr(key) || el instanceof HTMLElement && (shared.isBooleanAttr(key) || shared.isKnownHtmlAttr(key))) {
|
---|
2147 | if (shared.isBooleanAttr(key)) {
|
---|
2148 | actual = el.hasAttribute(key);
|
---|
2149 | expected = shared.includeBooleanAttr(clientValue);
|
---|
2150 | } else if (clientValue == null) {
|
---|
2151 | actual = el.hasAttribute(key);
|
---|
2152 | expected = false;
|
---|
2153 | } else {
|
---|
2154 | if (el.hasAttribute(key)) {
|
---|
2155 | actual = el.getAttribute(key);
|
---|
2156 | } else if (key === "value" && el.tagName === "TEXTAREA") {
|
---|
2157 | actual = el.value;
|
---|
2158 | } else {
|
---|
2159 | actual = false;
|
---|
2160 | }
|
---|
2161 | expected = shared.isRenderableAttrValue(clientValue) ? String(clientValue) : false;
|
---|
2162 | }
|
---|
2163 | if (actual !== expected) {
|
---|
2164 | mismatchType = 4 /* ATTRIBUTE */;
|
---|
2165 | mismatchKey = key;
|
---|
2166 | }
|
---|
2167 | }
|
---|
2168 | if (mismatchType != null && !isMismatchAllowed(el, mismatchType)) {
|
---|
2169 | const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
|
---|
2170 | const preSegment = `Hydration ${MismatchTypeString[mismatchType]} mismatch on`;
|
---|
2171 | const postSegment = `
|
---|
2172 | - rendered on server: ${format(actual)}
|
---|
2173 | - expected on client: ${format(expected)}
|
---|
2174 | Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
|
---|
2175 | You should fix the source of the mismatch.`;
|
---|
2176 | {
|
---|
2177 | warn$1(preSegment, el, postSegment);
|
---|
2178 | }
|
---|
2179 | return true;
|
---|
2180 | }
|
---|
2181 | return false;
|
---|
2182 | }
|
---|
2183 | function toClassSet(str) {
|
---|
2184 | return new Set(str.trim().split(/\s+/));
|
---|
2185 | }
|
---|
2186 | function isSetEqual(a, b) {
|
---|
2187 | if (a.size !== b.size) {
|
---|
2188 | return false;
|
---|
2189 | }
|
---|
2190 | for (const s of a) {
|
---|
2191 | if (!b.has(s)) {
|
---|
2192 | return false;
|
---|
2193 | }
|
---|
2194 | }
|
---|
2195 | return true;
|
---|
2196 | }
|
---|
2197 | function toStyleMap(str) {
|
---|
2198 | const styleMap = /* @__PURE__ */ new Map();
|
---|
2199 | for (const item of str.split(";")) {
|
---|
2200 | let [key, value] = item.split(":");
|
---|
2201 | key = key.trim();
|
---|
2202 | value = value && value.trim();
|
---|
2203 | if (key && value) {
|
---|
2204 | styleMap.set(key, value);
|
---|
2205 | }
|
---|
2206 | }
|
---|
2207 | return styleMap;
|
---|
2208 | }
|
---|
2209 | function isMapEqual(a, b) {
|
---|
2210 | if (a.size !== b.size) {
|
---|
2211 | return false;
|
---|
2212 | }
|
---|
2213 | for (const [key, value] of a) {
|
---|
2214 | if (value !== b.get(key)) {
|
---|
2215 | return false;
|
---|
2216 | }
|
---|
2217 | }
|
---|
2218 | return true;
|
---|
2219 | }
|
---|
2220 | function resolveCssVars(instance, vnode, expectedMap) {
|
---|
2221 | const root = instance.subTree;
|
---|
2222 | if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
|
---|
2223 | const cssVars = instance.getCssVars();
|
---|
2224 | for (const key in cssVars) {
|
---|
2225 | expectedMap.set(
|
---|
2226 | `--${shared.getEscapedCssVarName(key, false)}`,
|
---|
2227 | String(cssVars[key])
|
---|
2228 | );
|
---|
2229 | }
|
---|
2230 | }
|
---|
2231 | if (vnode === root && instance.parent) {
|
---|
2232 | resolveCssVars(instance.parent, instance.vnode, expectedMap);
|
---|
2233 | }
|
---|
2234 | }
|
---|
2235 | const allowMismatchAttr = "data-allow-mismatch";
|
---|
2236 | const MismatchTypeString = {
|
---|
2237 | [0 /* TEXT */]: "text",
|
---|
2238 | [1 /* CHILDREN */]: "children",
|
---|
2239 | [2 /* CLASS */]: "class",
|
---|
2240 | [3 /* STYLE */]: "style",
|
---|
2241 | [4 /* ATTRIBUTE */]: "attribute"
|
---|
2242 | };
|
---|
2243 | function isMismatchAllowed(el, allowedType) {
|
---|
2244 | if (allowedType === 0 /* TEXT */ || allowedType === 1 /* CHILDREN */) {
|
---|
2245 | while (el && !el.hasAttribute(allowMismatchAttr)) {
|
---|
2246 | el = el.parentElement;
|
---|
2247 | }
|
---|
2248 | }
|
---|
2249 | const allowedAttr = el && el.getAttribute(allowMismatchAttr);
|
---|
2250 | if (allowedAttr == null) {
|
---|
2251 | return false;
|
---|
2252 | } else if (allowedAttr === "") {
|
---|
2253 | return true;
|
---|
2254 | } else {
|
---|
2255 | const list = allowedAttr.split(",");
|
---|
2256 | if (allowedType === 0 /* TEXT */ && list.includes("children")) {
|
---|
2257 | return true;
|
---|
2258 | }
|
---|
2259 | return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
|
---|
2260 | }
|
---|
2261 | }
|
---|
2262 |
|
---|
2263 | const requestIdleCallback = shared.getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
|
---|
2264 | const cancelIdleCallback = shared.getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
|
---|
2265 | const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
|
---|
2266 | const id = requestIdleCallback(hydrate, { timeout });
|
---|
2267 | return () => cancelIdleCallback(id);
|
---|
2268 | };
|
---|
2269 | function elementIsVisibleInViewport(el) {
|
---|
2270 | const { top, left, bottom, right } = el.getBoundingClientRect();
|
---|
2271 | const { innerHeight, innerWidth } = window;
|
---|
2272 | return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
|
---|
2273 | }
|
---|
2274 | const hydrateOnVisible = (opts) => (hydrate, forEach) => {
|
---|
2275 | const ob = new IntersectionObserver((entries) => {
|
---|
2276 | for (const e of entries) {
|
---|
2277 | if (!e.isIntersecting) continue;
|
---|
2278 | ob.disconnect();
|
---|
2279 | hydrate();
|
---|
2280 | break;
|
---|
2281 | }
|
---|
2282 | }, opts);
|
---|
2283 | forEach((el) => {
|
---|
2284 | if (!(el instanceof Element)) return;
|
---|
2285 | if (elementIsVisibleInViewport(el)) {
|
---|
2286 | hydrate();
|
---|
2287 | ob.disconnect();
|
---|
2288 | return false;
|
---|
2289 | }
|
---|
2290 | ob.observe(el);
|
---|
2291 | });
|
---|
2292 | return () => ob.disconnect();
|
---|
2293 | };
|
---|
2294 | const hydrateOnMediaQuery = (query) => (hydrate) => {
|
---|
2295 | if (query) {
|
---|
2296 | const mql = matchMedia(query);
|
---|
2297 | if (mql.matches) {
|
---|
2298 | hydrate();
|
---|
2299 | } else {
|
---|
2300 | mql.addEventListener("change", hydrate, { once: true });
|
---|
2301 | return () => mql.removeEventListener("change", hydrate);
|
---|
2302 | }
|
---|
2303 | }
|
---|
2304 | };
|
---|
2305 | const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => {
|
---|
2306 | if (shared.isString(interactions)) interactions = [interactions];
|
---|
2307 | let hasHydrated = false;
|
---|
2308 | const doHydrate = (e) => {
|
---|
2309 | if (!hasHydrated) {
|
---|
2310 | hasHydrated = true;
|
---|
2311 | teardown();
|
---|
2312 | hydrate();
|
---|
2313 | e.target.dispatchEvent(new e.constructor(e.type, e));
|
---|
2314 | }
|
---|
2315 | };
|
---|
2316 | const teardown = () => {
|
---|
2317 | forEach((el) => {
|
---|
2318 | for (const i of interactions) {
|
---|
2319 | el.removeEventListener(i, doHydrate);
|
---|
2320 | }
|
---|
2321 | });
|
---|
2322 | };
|
---|
2323 | forEach((el) => {
|
---|
2324 | for (const i of interactions) {
|
---|
2325 | el.addEventListener(i, doHydrate, { once: true });
|
---|
2326 | }
|
---|
2327 | });
|
---|
2328 | return teardown;
|
---|
2329 | };
|
---|
2330 | function forEachElement(node, cb) {
|
---|
2331 | if (isComment(node) && node.data === "[") {
|
---|
2332 | let depth = 1;
|
---|
2333 | let next = node.nextSibling;
|
---|
2334 | while (next) {
|
---|
2335 | if (next.nodeType === 1) {
|
---|
2336 | const result = cb(next);
|
---|
2337 | if (result === false) {
|
---|
2338 | break;
|
---|
2339 | }
|
---|
2340 | } else if (isComment(next)) {
|
---|
2341 | if (next.data === "]") {
|
---|
2342 | if (--depth === 0) break;
|
---|
2343 | } else if (next.data === "[") {
|
---|
2344 | depth++;
|
---|
2345 | }
|
---|
2346 | }
|
---|
2347 | next = next.nextSibling;
|
---|
2348 | }
|
---|
2349 | } else {
|
---|
2350 | cb(node);
|
---|
2351 | }
|
---|
2352 | }
|
---|
2353 |
|
---|
2354 | const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
---|
2355 | /*! #__NO_SIDE_EFFECTS__ */
|
---|
2356 | // @__NO_SIDE_EFFECTS__
|
---|
2357 | function defineAsyncComponent(source) {
|
---|
2358 | if (shared.isFunction(source)) {
|
---|
2359 | source = { loader: source };
|
---|
2360 | }
|
---|
2361 | const {
|
---|
2362 | loader,
|
---|
2363 | loadingComponent,
|
---|
2364 | errorComponent,
|
---|
2365 | delay = 200,
|
---|
2366 | hydrate: hydrateStrategy,
|
---|
2367 | timeout,
|
---|
2368 | // undefined = never times out
|
---|
2369 | suspensible = true,
|
---|
2370 | onError: userOnError
|
---|
2371 | } = source;
|
---|
2372 | let pendingRequest = null;
|
---|
2373 | let resolvedComp;
|
---|
2374 | let retries = 0;
|
---|
2375 | const retry = () => {
|
---|
2376 | retries++;
|
---|
2377 | pendingRequest = null;
|
---|
2378 | return load();
|
---|
2379 | };
|
---|
2380 | const load = () => {
|
---|
2381 | let thisRequest;
|
---|
2382 | return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
|
---|
2383 | err = err instanceof Error ? err : new Error(String(err));
|
---|
2384 | if (userOnError) {
|
---|
2385 | return new Promise((resolve, reject) => {
|
---|
2386 | const userRetry = () => resolve(retry());
|
---|
2387 | const userFail = () => reject(err);
|
---|
2388 | userOnError(err, userRetry, userFail, retries + 1);
|
---|
2389 | });
|
---|
2390 | } else {
|
---|
2391 | throw err;
|
---|
2392 | }
|
---|
2393 | }).then((comp) => {
|
---|
2394 | if (thisRequest !== pendingRequest && pendingRequest) {
|
---|
2395 | return pendingRequest;
|
---|
2396 | }
|
---|
2397 | if (!comp) {
|
---|
2398 | warn$1(
|
---|
2399 | `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
|
---|
2400 | );
|
---|
2401 | }
|
---|
2402 | if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
|
---|
2403 | comp = comp.default;
|
---|
2404 | }
|
---|
2405 | if (comp && !shared.isObject(comp) && !shared.isFunction(comp)) {
|
---|
2406 | throw new Error(`Invalid async component load result: ${comp}`);
|
---|
2407 | }
|
---|
2408 | resolvedComp = comp;
|
---|
2409 | return comp;
|
---|
2410 | }));
|
---|
2411 | };
|
---|
2412 | return defineComponent({
|
---|
2413 | name: "AsyncComponentWrapper",
|
---|
2414 | __asyncLoader: load,
|
---|
2415 | __asyncHydrate(el, instance, hydrate) {
|
---|
2416 | const doHydrate = hydrateStrategy ? () => {
|
---|
2417 | const teardown = hydrateStrategy(
|
---|
2418 | hydrate,
|
---|
2419 | (cb) => forEachElement(el, cb)
|
---|
2420 | );
|
---|
2421 | if (teardown) {
|
---|
2422 | (instance.bum || (instance.bum = [])).push(teardown);
|
---|
2423 | }
|
---|
2424 | } : hydrate;
|
---|
2425 | if (resolvedComp) {
|
---|
2426 | doHydrate();
|
---|
2427 | } else {
|
---|
2428 | load().then(() => !instance.isUnmounted && doHydrate());
|
---|
2429 | }
|
---|
2430 | },
|
---|
2431 | get __asyncResolved() {
|
---|
2432 | return resolvedComp;
|
---|
2433 | },
|
---|
2434 | setup() {
|
---|
2435 | const instance = currentInstance;
|
---|
2436 | markAsyncBoundary(instance);
|
---|
2437 | if (resolvedComp) {
|
---|
2438 | return () => createInnerComp(resolvedComp, instance);
|
---|
2439 | }
|
---|
2440 | const onError = (err) => {
|
---|
2441 | pendingRequest = null;
|
---|
2442 | handleError(
|
---|
2443 | err,
|
---|
2444 | instance,
|
---|
2445 | 13,
|
---|
2446 | !errorComponent
|
---|
2447 | );
|
---|
2448 | };
|
---|
2449 | if (suspensible && instance.suspense || isInSSRComponentSetup) {
|
---|
2450 | return load().then((comp) => {
|
---|
2451 | return () => createInnerComp(comp, instance);
|
---|
2452 | }).catch((err) => {
|
---|
2453 | onError(err);
|
---|
2454 | return () => errorComponent ? createVNode(errorComponent, {
|
---|
2455 | error: err
|
---|
2456 | }) : null;
|
---|
2457 | });
|
---|
2458 | }
|
---|
2459 | const loaded = reactivity.ref(false);
|
---|
2460 | const error = reactivity.ref();
|
---|
2461 | const delayed = reactivity.ref(!!delay);
|
---|
2462 | if (delay) {
|
---|
2463 | setTimeout(() => {
|
---|
2464 | delayed.value = false;
|
---|
2465 | }, delay);
|
---|
2466 | }
|
---|
2467 | if (timeout != null) {
|
---|
2468 | setTimeout(() => {
|
---|
2469 | if (!loaded.value && !error.value) {
|
---|
2470 | const err = new Error(
|
---|
2471 | `Async component timed out after ${timeout}ms.`
|
---|
2472 | );
|
---|
2473 | onError(err);
|
---|
2474 | error.value = err;
|
---|
2475 | }
|
---|
2476 | }, timeout);
|
---|
2477 | }
|
---|
2478 | load().then(() => {
|
---|
2479 | loaded.value = true;
|
---|
2480 | if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
---|
2481 | instance.parent.update();
|
---|
2482 | }
|
---|
2483 | }).catch((err) => {
|
---|
2484 | onError(err);
|
---|
2485 | error.value = err;
|
---|
2486 | });
|
---|
2487 | return () => {
|
---|
2488 | if (loaded.value && resolvedComp) {
|
---|
2489 | return createInnerComp(resolvedComp, instance);
|
---|
2490 | } else if (error.value && errorComponent) {
|
---|
2491 | return createVNode(errorComponent, {
|
---|
2492 | error: error.value
|
---|
2493 | });
|
---|
2494 | } else if (loadingComponent && !delayed.value) {
|
---|
2495 | return createVNode(loadingComponent);
|
---|
2496 | }
|
---|
2497 | };
|
---|
2498 | }
|
---|
2499 | });
|
---|
2500 | }
|
---|
2501 | function createInnerComp(comp, parent) {
|
---|
2502 | const { ref: ref2, props, children, ce } = parent.vnode;
|
---|
2503 | const vnode = createVNode(comp, props, children);
|
---|
2504 | vnode.ref = ref2;
|
---|
2505 | vnode.ce = ce;
|
---|
2506 | delete parent.vnode.ce;
|
---|
2507 | return vnode;
|
---|
2508 | }
|
---|
2509 |
|
---|
2510 | const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
---|
2511 | const KeepAliveImpl = {
|
---|
2512 | name: `KeepAlive`,
|
---|
2513 | // Marker for special handling inside the renderer. We are not using a ===
|
---|
2514 | // check directly on KeepAlive in the renderer, because importing it directly
|
---|
2515 | // would prevent it from being tree-shaken.
|
---|
2516 | __isKeepAlive: true,
|
---|
2517 | props: {
|
---|
2518 | include: [String, RegExp, Array],
|
---|
2519 | exclude: [String, RegExp, Array],
|
---|
2520 | max: [String, Number]
|
---|
2521 | },
|
---|
2522 | setup(props, { slots }) {
|
---|
2523 | const instance = getCurrentInstance();
|
---|
2524 | const sharedContext = instance.ctx;
|
---|
2525 | if (!sharedContext.renderer) {
|
---|
2526 | return () => {
|
---|
2527 | const children = slots.default && slots.default();
|
---|
2528 | return children && children.length === 1 ? children[0] : children;
|
---|
2529 | };
|
---|
2530 | }
|
---|
2531 | const cache = /* @__PURE__ */ new Map();
|
---|
2532 | const keys = /* @__PURE__ */ new Set();
|
---|
2533 | let current = null;
|
---|
2534 | {
|
---|
2535 | instance.__v_cache = cache;
|
---|
2536 | }
|
---|
2537 | const parentSuspense = instance.suspense;
|
---|
2538 | const {
|
---|
2539 | renderer: {
|
---|
2540 | p: patch,
|
---|
2541 | m: move,
|
---|
2542 | um: _unmount,
|
---|
2543 | o: { createElement }
|
---|
2544 | }
|
---|
2545 | } = sharedContext;
|
---|
2546 | const storageContainer = createElement("div");
|
---|
2547 | sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
|
---|
2548 | const instance2 = vnode.component;
|
---|
2549 | move(vnode, container, anchor, 0, parentSuspense);
|
---|
2550 | patch(
|
---|
2551 | instance2.vnode,
|
---|
2552 | vnode,
|
---|
2553 | container,
|
---|
2554 | anchor,
|
---|
2555 | instance2,
|
---|
2556 | parentSuspense,
|
---|
2557 | namespace,
|
---|
2558 | vnode.slotScopeIds,
|
---|
2559 | optimized
|
---|
2560 | );
|
---|
2561 | queuePostRenderEffect(() => {
|
---|
2562 | instance2.isDeactivated = false;
|
---|
2563 | if (instance2.a) {
|
---|
2564 | shared.invokeArrayFns(instance2.a);
|
---|
2565 | }
|
---|
2566 | const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
---|
2567 | if (vnodeHook) {
|
---|
2568 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
---|
2569 | }
|
---|
2570 | }, parentSuspense);
|
---|
2571 | {
|
---|
2572 | devtoolsComponentAdded(instance2);
|
---|
2573 | }
|
---|
2574 | };
|
---|
2575 | sharedContext.deactivate = (vnode) => {
|
---|
2576 | const instance2 = vnode.component;
|
---|
2577 | invalidateMount(instance2.m);
|
---|
2578 | invalidateMount(instance2.a);
|
---|
2579 | move(vnode, storageContainer, null, 1, parentSuspense);
|
---|
2580 | queuePostRenderEffect(() => {
|
---|
2581 | if (instance2.da) {
|
---|
2582 | shared.invokeArrayFns(instance2.da);
|
---|
2583 | }
|
---|
2584 | const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
---|
2585 | if (vnodeHook) {
|
---|
2586 | invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
---|
2587 | }
|
---|
2588 | instance2.isDeactivated = true;
|
---|
2589 | }, parentSuspense);
|
---|
2590 | {
|
---|
2591 | devtoolsComponentAdded(instance2);
|
---|
2592 | }
|
---|
2593 | };
|
---|
2594 | function unmount(vnode) {
|
---|
2595 | resetShapeFlag(vnode);
|
---|
2596 | _unmount(vnode, instance, parentSuspense, true);
|
---|
2597 | }
|
---|
2598 | function pruneCache(filter) {
|
---|
2599 | cache.forEach((vnode, key) => {
|
---|
2600 | const name = getComponentName(vnode.type);
|
---|
2601 | if (name && !filter(name)) {
|
---|
2602 | pruneCacheEntry(key);
|
---|
2603 | }
|
---|
2604 | });
|
---|
2605 | }
|
---|
2606 | function pruneCacheEntry(key) {
|
---|
2607 | const cached = cache.get(key);
|
---|
2608 | if (cached && (!current || !isSameVNodeType(cached, current))) {
|
---|
2609 | unmount(cached);
|
---|
2610 | } else if (current) {
|
---|
2611 | resetShapeFlag(current);
|
---|
2612 | }
|
---|
2613 | cache.delete(key);
|
---|
2614 | keys.delete(key);
|
---|
2615 | }
|
---|
2616 | watch(
|
---|
2617 | () => [props.include, props.exclude],
|
---|
2618 | ([include, exclude]) => {
|
---|
2619 | include && pruneCache((name) => matches(include, name));
|
---|
2620 | exclude && pruneCache((name) => !matches(exclude, name));
|
---|
2621 | },
|
---|
2622 | // prune post-render after `current` has been updated
|
---|
2623 | { flush: "post", deep: true }
|
---|
2624 | );
|
---|
2625 | let pendingCacheKey = null;
|
---|
2626 | const cacheSubtree = () => {
|
---|
2627 | if (pendingCacheKey != null) {
|
---|
2628 | if (isSuspense(instance.subTree.type)) {
|
---|
2629 | queuePostRenderEffect(() => {
|
---|
2630 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
---|
2631 | }, instance.subTree.suspense);
|
---|
2632 | } else {
|
---|
2633 | cache.set(pendingCacheKey, getInnerChild(instance.subTree));
|
---|
2634 | }
|
---|
2635 | }
|
---|
2636 | };
|
---|
2637 | onMounted(cacheSubtree);
|
---|
2638 | onUpdated(cacheSubtree);
|
---|
2639 | onBeforeUnmount(() => {
|
---|
2640 | cache.forEach((cached) => {
|
---|
2641 | const { subTree, suspense } = instance;
|
---|
2642 | const vnode = getInnerChild(subTree);
|
---|
2643 | if (cached.type === vnode.type && cached.key === vnode.key) {
|
---|
2644 | resetShapeFlag(vnode);
|
---|
2645 | const da = vnode.component.da;
|
---|
2646 | da && queuePostRenderEffect(da, suspense);
|
---|
2647 | return;
|
---|
2648 | }
|
---|
2649 | unmount(cached);
|
---|
2650 | });
|
---|
2651 | });
|
---|
2652 | return () => {
|
---|
2653 | pendingCacheKey = null;
|
---|
2654 | if (!slots.default) {
|
---|
2655 | return current = null;
|
---|
2656 | }
|
---|
2657 | const children = slots.default();
|
---|
2658 | const rawVNode = children[0];
|
---|
2659 | if (children.length > 1) {
|
---|
2660 | {
|
---|
2661 | warn$1(`KeepAlive should contain exactly one component child.`);
|
---|
2662 | }
|
---|
2663 | current = null;
|
---|
2664 | return children;
|
---|
2665 | } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
|
---|
2666 | current = null;
|
---|
2667 | return rawVNode;
|
---|
2668 | }
|
---|
2669 | let vnode = getInnerChild(rawVNode);
|
---|
2670 | if (vnode.type === Comment) {
|
---|
2671 | current = null;
|
---|
2672 | return vnode;
|
---|
2673 | }
|
---|
2674 | const comp = vnode.type;
|
---|
2675 | const name = getComponentName(
|
---|
2676 | isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
|
---|
2677 | );
|
---|
2678 | const { include, exclude, max } = props;
|
---|
2679 | if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
|
---|
2680 | vnode.shapeFlag &= ~256;
|
---|
2681 | current = vnode;
|
---|
2682 | return rawVNode;
|
---|
2683 | }
|
---|
2684 | const key = vnode.key == null ? comp : vnode.key;
|
---|
2685 | const cachedVNode = cache.get(key);
|
---|
2686 | if (vnode.el) {
|
---|
2687 | vnode = cloneVNode(vnode);
|
---|
2688 | if (rawVNode.shapeFlag & 128) {
|
---|
2689 | rawVNode.ssContent = vnode;
|
---|
2690 | }
|
---|
2691 | }
|
---|
2692 | pendingCacheKey = key;
|
---|
2693 | if (cachedVNode) {
|
---|
2694 | vnode.el = cachedVNode.el;
|
---|
2695 | vnode.component = cachedVNode.component;
|
---|
2696 | if (vnode.transition) {
|
---|
2697 | setTransitionHooks(vnode, vnode.transition);
|
---|
2698 | }
|
---|
2699 | vnode.shapeFlag |= 512;
|
---|
2700 | keys.delete(key);
|
---|
2701 | keys.add(key);
|
---|
2702 | } else {
|
---|
2703 | keys.add(key);
|
---|
2704 | if (max && keys.size > parseInt(max, 10)) {
|
---|
2705 | pruneCacheEntry(keys.values().next().value);
|
---|
2706 | }
|
---|
2707 | }
|
---|
2708 | vnode.shapeFlag |= 256;
|
---|
2709 | current = vnode;
|
---|
2710 | return isSuspense(rawVNode.type) ? rawVNode : vnode;
|
---|
2711 | };
|
---|
2712 | }
|
---|
2713 | };
|
---|
2714 | const KeepAlive = KeepAliveImpl;
|
---|
2715 | function matches(pattern, name) {
|
---|
2716 | if (shared.isArray(pattern)) {
|
---|
2717 | return pattern.some((p) => matches(p, name));
|
---|
2718 | } else if (shared.isString(pattern)) {
|
---|
2719 | return pattern.split(",").includes(name);
|
---|
2720 | } else if (shared.isRegExp(pattern)) {
|
---|
2721 | pattern.lastIndex = 0;
|
---|
2722 | return pattern.test(name);
|
---|
2723 | }
|
---|
2724 | return false;
|
---|
2725 | }
|
---|
2726 | function onActivated(hook, target) {
|
---|
2727 | registerKeepAliveHook(hook, "a", target);
|
---|
2728 | }
|
---|
2729 | function onDeactivated(hook, target) {
|
---|
2730 | registerKeepAliveHook(hook, "da", target);
|
---|
2731 | }
|
---|
2732 | function registerKeepAliveHook(hook, type, target = currentInstance) {
|
---|
2733 | const wrappedHook = hook.__wdc || (hook.__wdc = () => {
|
---|
2734 | let current = target;
|
---|
2735 | while (current) {
|
---|
2736 | if (current.isDeactivated) {
|
---|
2737 | return;
|
---|
2738 | }
|
---|
2739 | current = current.parent;
|
---|
2740 | }
|
---|
2741 | return hook();
|
---|
2742 | });
|
---|
2743 | injectHook(type, wrappedHook, target);
|
---|
2744 | if (target) {
|
---|
2745 | let current = target.parent;
|
---|
2746 | while (current && current.parent) {
|
---|
2747 | if (isKeepAlive(current.parent.vnode)) {
|
---|
2748 | injectToKeepAliveRoot(wrappedHook, type, target, current);
|
---|
2749 | }
|
---|
2750 | current = current.parent;
|
---|
2751 | }
|
---|
2752 | }
|
---|
2753 | }
|
---|
2754 | function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
---|
2755 | const injected = injectHook(
|
---|
2756 | type,
|
---|
2757 | hook,
|
---|
2758 | keepAliveRoot,
|
---|
2759 | true
|
---|
2760 | /* prepend */
|
---|
2761 | );
|
---|
2762 | onUnmounted(() => {
|
---|
2763 | shared.remove(keepAliveRoot[type], injected);
|
---|
2764 | }, target);
|
---|
2765 | }
|
---|
2766 | function resetShapeFlag(vnode) {
|
---|
2767 | vnode.shapeFlag &= ~256;
|
---|
2768 | vnode.shapeFlag &= ~512;
|
---|
2769 | }
|
---|
2770 | function getInnerChild(vnode) {
|
---|
2771 | return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
---|
2772 | }
|
---|
2773 |
|
---|
2774 | function injectHook(type, hook, target = currentInstance, prepend = false) {
|
---|
2775 | if (target) {
|
---|
2776 | const hooks = target[type] || (target[type] = []);
|
---|
2777 | const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
---|
2778 | reactivity.pauseTracking();
|
---|
2779 | const reset = setCurrentInstance(target);
|
---|
2780 | const res = callWithAsyncErrorHandling(hook, target, type, args);
|
---|
2781 | reset();
|
---|
2782 | reactivity.resetTracking();
|
---|
2783 | return res;
|
---|
2784 | });
|
---|
2785 | if (prepend) {
|
---|
2786 | hooks.unshift(wrappedHook);
|
---|
2787 | } else {
|
---|
2788 | hooks.push(wrappedHook);
|
---|
2789 | }
|
---|
2790 | return wrappedHook;
|
---|
2791 | } else {
|
---|
2792 | const apiName = shared.toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
|
---|
2793 | warn$1(
|
---|
2794 | `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
|
---|
2795 | );
|
---|
2796 | }
|
---|
2797 | }
|
---|
2798 | const createHook = (lifecycle) => (hook, target = currentInstance) => {
|
---|
2799 | if (!isInSSRComponentSetup || lifecycle === "sp") {
|
---|
2800 | injectHook(lifecycle, (...args) => hook(...args), target);
|
---|
2801 | }
|
---|
2802 | };
|
---|
2803 | const onBeforeMount = createHook("bm");
|
---|
2804 | const onMounted = createHook("m");
|
---|
2805 | const onBeforeUpdate = createHook(
|
---|
2806 | "bu"
|
---|
2807 | );
|
---|
2808 | const onUpdated = createHook("u");
|
---|
2809 | const onBeforeUnmount = createHook(
|
---|
2810 | "bum"
|
---|
2811 | );
|
---|
2812 | const onUnmounted = createHook("um");
|
---|
2813 | const onServerPrefetch = createHook(
|
---|
2814 | "sp"
|
---|
2815 | );
|
---|
2816 | const onRenderTriggered = createHook("rtg");
|
---|
2817 | const onRenderTracked = createHook("rtc");
|
---|
2818 | function onErrorCaptured(hook, target = currentInstance) {
|
---|
2819 | injectHook("ec", hook, target);
|
---|
2820 | }
|
---|
2821 |
|
---|
2822 | const COMPONENTS = "components";
|
---|
2823 | const DIRECTIVES = "directives";
|
---|
2824 | function resolveComponent(name, maybeSelfReference) {
|
---|
2825 | return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
---|
2826 | }
|
---|
2827 | const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
---|
2828 | function resolveDynamicComponent(component) {
|
---|
2829 | if (shared.isString(component)) {
|
---|
2830 | return resolveAsset(COMPONENTS, component, false) || component;
|
---|
2831 | } else {
|
---|
2832 | return component || NULL_DYNAMIC_COMPONENT;
|
---|
2833 | }
|
---|
2834 | }
|
---|
2835 | function resolveDirective(name) {
|
---|
2836 | return resolveAsset(DIRECTIVES, name);
|
---|
2837 | }
|
---|
2838 | function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
---|
2839 | const instance = currentRenderingInstance || currentInstance;
|
---|
2840 | if (instance) {
|
---|
2841 | const Component = instance.type;
|
---|
2842 | if (type === COMPONENTS) {
|
---|
2843 | const selfName = getComponentName(
|
---|
2844 | Component,
|
---|
2845 | false
|
---|
2846 | );
|
---|
2847 | if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
|
---|
2848 | return Component;
|
---|
2849 | }
|
---|
2850 | }
|
---|
2851 | const res = (
|
---|
2852 | // local registration
|
---|
2853 | // check instance[type] first which is resolved for options API
|
---|
2854 | resolve(instance[type] || Component[type], name) || // global registration
|
---|
2855 | resolve(instance.appContext[type], name)
|
---|
2856 | );
|
---|
2857 | if (!res && maybeSelfReference) {
|
---|
2858 | return Component;
|
---|
2859 | }
|
---|
2860 | if (warnMissing && !res) {
|
---|
2861 | const extra = type === COMPONENTS ? `
|
---|
2862 | If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
|
---|
2863 | warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
|
---|
2864 | }
|
---|
2865 | return res;
|
---|
2866 | } else {
|
---|
2867 | warn$1(
|
---|
2868 | `resolve${shared.capitalize(type.slice(0, -1))} can only be used in render() or setup().`
|
---|
2869 | );
|
---|
2870 | }
|
---|
2871 | }
|
---|
2872 | function resolve(registry, name) {
|
---|
2873 | return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
|
---|
2874 | }
|
---|
2875 |
|
---|
2876 | function renderList(source, renderItem, cache, index) {
|
---|
2877 | let ret;
|
---|
2878 | const cached = cache && cache[index];
|
---|
2879 | const sourceIsArray = shared.isArray(source);
|
---|
2880 | if (sourceIsArray || shared.isString(source)) {
|
---|
2881 | const sourceIsReactiveArray = sourceIsArray && reactivity.isReactive(source);
|
---|
2882 | let needsWrap = false;
|
---|
2883 | if (sourceIsReactiveArray) {
|
---|
2884 | needsWrap = !reactivity.isShallow(source);
|
---|
2885 | source = reactivity.shallowReadArray(source);
|
---|
2886 | }
|
---|
2887 | ret = new Array(source.length);
|
---|
2888 | for (let i = 0, l = source.length; i < l; i++) {
|
---|
2889 | ret[i] = renderItem(
|
---|
2890 | needsWrap ? reactivity.toReactive(source[i]) : source[i],
|
---|
2891 | i,
|
---|
2892 | void 0,
|
---|
2893 | cached && cached[i]
|
---|
2894 | );
|
---|
2895 | }
|
---|
2896 | } else if (typeof source === "number") {
|
---|
2897 | if (!Number.isInteger(source)) {
|
---|
2898 | warn$1(`The v-for range expect an integer value but got ${source}.`);
|
---|
2899 | }
|
---|
2900 | ret = new Array(source);
|
---|
2901 | for (let i = 0; i < source; i++) {
|
---|
2902 | ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
|
---|
2903 | }
|
---|
2904 | } else if (shared.isObject(source)) {
|
---|
2905 | if (source[Symbol.iterator]) {
|
---|
2906 | ret = Array.from(
|
---|
2907 | source,
|
---|
2908 | (item, i) => renderItem(item, i, void 0, cached && cached[i])
|
---|
2909 | );
|
---|
2910 | } else {
|
---|
2911 | const keys = Object.keys(source);
|
---|
2912 | ret = new Array(keys.length);
|
---|
2913 | for (let i = 0, l = keys.length; i < l; i++) {
|
---|
2914 | const key = keys[i];
|
---|
2915 | ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
---|
2916 | }
|
---|
2917 | }
|
---|
2918 | } else {
|
---|
2919 | ret = [];
|
---|
2920 | }
|
---|
2921 | if (cache) {
|
---|
2922 | cache[index] = ret;
|
---|
2923 | }
|
---|
2924 | return ret;
|
---|
2925 | }
|
---|
2926 |
|
---|
2927 | function createSlots(slots, dynamicSlots) {
|
---|
2928 | for (let i = 0; i < dynamicSlots.length; i++) {
|
---|
2929 | const slot = dynamicSlots[i];
|
---|
2930 | if (shared.isArray(slot)) {
|
---|
2931 | for (let j = 0; j < slot.length; j++) {
|
---|
2932 | slots[slot[j].name] = slot[j].fn;
|
---|
2933 | }
|
---|
2934 | } else if (slot) {
|
---|
2935 | slots[slot.name] = slot.key ? (...args) => {
|
---|
2936 | const res = slot.fn(...args);
|
---|
2937 | if (res) res.key = slot.key;
|
---|
2938 | return res;
|
---|
2939 | } : slot.fn;
|
---|
2940 | }
|
---|
2941 | }
|
---|
2942 | return slots;
|
---|
2943 | }
|
---|
2944 |
|
---|
2945 | function renderSlot(slots, name, props = {}, fallback, noSlotted) {
|
---|
2946 | if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
|
---|
2947 | if (name !== "default") props.name = name;
|
---|
2948 | return openBlock(), createBlock(
|
---|
2949 | Fragment,
|
---|
2950 | null,
|
---|
2951 | [createVNode("slot", props, fallback && fallback())],
|
---|
2952 | 64
|
---|
2953 | );
|
---|
2954 | }
|
---|
2955 | let slot = slots[name];
|
---|
2956 | if (slot && slot.length > 1) {
|
---|
2957 | warn$1(
|
---|
2958 | `SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`
|
---|
2959 | );
|
---|
2960 | slot = () => [];
|
---|
2961 | }
|
---|
2962 | if (slot && slot._c) {
|
---|
2963 | slot._d = false;
|
---|
2964 | }
|
---|
2965 | openBlock();
|
---|
2966 | const validSlotContent = slot && ensureValidVNode(slot(props));
|
---|
2967 | const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
|
---|
2968 | // key attached in the `createSlots` helper, respect that
|
---|
2969 | validSlotContent && validSlotContent.key;
|
---|
2970 | const rendered = createBlock(
|
---|
2971 | Fragment,
|
---|
2972 | {
|
---|
2973 | key: (slotKey && !shared.isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
|
---|
2974 | (!validSlotContent && fallback ? "_fb" : "")
|
---|
2975 | },
|
---|
2976 | validSlotContent || (fallback ? fallback() : []),
|
---|
2977 | validSlotContent && slots._ === 1 ? 64 : -2
|
---|
2978 | );
|
---|
2979 | if (!noSlotted && rendered.scopeId) {
|
---|
2980 | rendered.slotScopeIds = [rendered.scopeId + "-s"];
|
---|
2981 | }
|
---|
2982 | if (slot && slot._c) {
|
---|
2983 | slot._d = true;
|
---|
2984 | }
|
---|
2985 | return rendered;
|
---|
2986 | }
|
---|
2987 | function ensureValidVNode(vnodes) {
|
---|
2988 | return vnodes.some((child) => {
|
---|
2989 | if (!isVNode(child)) return true;
|
---|
2990 | if (child.type === Comment) return false;
|
---|
2991 | if (child.type === Fragment && !ensureValidVNode(child.children))
|
---|
2992 | return false;
|
---|
2993 | return true;
|
---|
2994 | }) ? vnodes : null;
|
---|
2995 | }
|
---|
2996 |
|
---|
2997 | function toHandlers(obj, preserveCaseIfNecessary) {
|
---|
2998 | const ret = {};
|
---|
2999 | if (!shared.isObject(obj)) {
|
---|
3000 | warn$1(`v-on with no argument expects an object value.`);
|
---|
3001 | return ret;
|
---|
3002 | }
|
---|
3003 | for (const key in obj) {
|
---|
3004 | ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : shared.toHandlerKey(key)] = obj[key];
|
---|
3005 | }
|
---|
3006 | return ret;
|
---|
3007 | }
|
---|
3008 |
|
---|
3009 | const getPublicInstance = (i) => {
|
---|
3010 | if (!i) return null;
|
---|
3011 | if (isStatefulComponent(i)) return getComponentPublicInstance(i);
|
---|
3012 | return getPublicInstance(i.parent);
|
---|
3013 | };
|
---|
3014 | const publicPropertiesMap = (
|
---|
3015 | // Move PURE marker to new line to workaround compiler discarding it
|
---|
3016 | // due to type annotation
|
---|
3017 | /* @__PURE__ */ shared.extend(/* @__PURE__ */ Object.create(null), {
|
---|
3018 | $: (i) => i,
|
---|
3019 | $el: (i) => i.vnode.el,
|
---|
3020 | $data: (i) => i.data,
|
---|
3021 | $props: (i) => reactivity.shallowReadonly(i.props) ,
|
---|
3022 | $attrs: (i) => reactivity.shallowReadonly(i.attrs) ,
|
---|
3023 | $slots: (i) => reactivity.shallowReadonly(i.slots) ,
|
---|
3024 | $refs: (i) => reactivity.shallowReadonly(i.refs) ,
|
---|
3025 | $parent: (i) => getPublicInstance(i.parent),
|
---|
3026 | $root: (i) => getPublicInstance(i.root),
|
---|
3027 | $host: (i) => i.ce,
|
---|
3028 | $emit: (i) => i.emit,
|
---|
3029 | $options: (i) => resolveMergedOptions(i) ,
|
---|
3030 | $forceUpdate: (i) => i.f || (i.f = () => {
|
---|
3031 | queueJob(i.update);
|
---|
3032 | }),
|
---|
3033 | $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
---|
3034 | $watch: (i) => instanceWatch.bind(i)
|
---|
3035 | })
|
---|
3036 | );
|
---|
3037 | const isReservedPrefix = (key) => key === "_" || key === "$";
|
---|
3038 | const hasSetupBinding = (state, key) => state !== shared.EMPTY_OBJ && !state.__isScriptSetup && shared.hasOwn(state, key);
|
---|
3039 | const PublicInstanceProxyHandlers = {
|
---|
3040 | get({ _: instance }, key) {
|
---|
3041 | if (key === "__v_skip") {
|
---|
3042 | return true;
|
---|
3043 | }
|
---|
3044 | const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
---|
3045 | if (key === "__isVue") {
|
---|
3046 | return true;
|
---|
3047 | }
|
---|
3048 | let normalizedProps;
|
---|
3049 | if (key[0] !== "$") {
|
---|
3050 | const n = accessCache[key];
|
---|
3051 | if (n !== void 0) {
|
---|
3052 | switch (n) {
|
---|
3053 | case 1 /* SETUP */:
|
---|
3054 | return setupState[key];
|
---|
3055 | case 2 /* DATA */:
|
---|
3056 | return data[key];
|
---|
3057 | case 4 /* CONTEXT */:
|
---|
3058 | return ctx[key];
|
---|
3059 | case 3 /* PROPS */:
|
---|
3060 | return props[key];
|
---|
3061 | }
|
---|
3062 | } else if (hasSetupBinding(setupState, key)) {
|
---|
3063 | accessCache[key] = 1 /* SETUP */;
|
---|
3064 | return setupState[key];
|
---|
3065 | } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
|
---|
3066 | accessCache[key] = 2 /* DATA */;
|
---|
3067 | return data[key];
|
---|
3068 | } else if (
|
---|
3069 | // only cache other properties when instance has declared (thus stable)
|
---|
3070 | // props
|
---|
3071 | (normalizedProps = instance.propsOptions[0]) && shared.hasOwn(normalizedProps, key)
|
---|
3072 | ) {
|
---|
3073 | accessCache[key] = 3 /* PROPS */;
|
---|
3074 | return props[key];
|
---|
3075 | } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
|
---|
3076 | accessCache[key] = 4 /* CONTEXT */;
|
---|
3077 | return ctx[key];
|
---|
3078 | } else if (shouldCacheAccess) {
|
---|
3079 | accessCache[key] = 0 /* OTHER */;
|
---|
3080 | }
|
---|
3081 | }
|
---|
3082 | const publicGetter = publicPropertiesMap[key];
|
---|
3083 | let cssModule, globalProperties;
|
---|
3084 | if (publicGetter) {
|
---|
3085 | if (key === "$attrs") {
|
---|
3086 | reactivity.track(instance.attrs, "get", "");
|
---|
3087 | markAttrsAccessed();
|
---|
3088 | } else if (key === "$slots") {
|
---|
3089 | reactivity.track(instance, "get", key);
|
---|
3090 | }
|
---|
3091 | return publicGetter(instance);
|
---|
3092 | } else if (
|
---|
3093 | // css module (injected by vue-loader)
|
---|
3094 | (cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
---|
3095 | ) {
|
---|
3096 | return cssModule;
|
---|
3097 | } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
|
---|
3098 | accessCache[key] = 4 /* CONTEXT */;
|
---|
3099 | return ctx[key];
|
---|
3100 | } else if (
|
---|
3101 | // global properties
|
---|
3102 | globalProperties = appContext.config.globalProperties, shared.hasOwn(globalProperties, key)
|
---|
3103 | ) {
|
---|
3104 | {
|
---|
3105 | return globalProperties[key];
|
---|
3106 | }
|
---|
3107 | } else if (currentRenderingInstance && (!shared.isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
|
---|
3108 | // to infinite warning loop
|
---|
3109 | key.indexOf("__v") !== 0)) {
|
---|
3110 | if (data !== shared.EMPTY_OBJ && isReservedPrefix(key[0]) && shared.hasOwn(data, key)) {
|
---|
3111 | warn$1(
|
---|
3112 | `Property ${JSON.stringify(
|
---|
3113 | key
|
---|
3114 | )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
|
---|
3115 | );
|
---|
3116 | } else if (instance === currentRenderingInstance) {
|
---|
3117 | warn$1(
|
---|
3118 | `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
|
---|
3119 | );
|
---|
3120 | }
|
---|
3121 | }
|
---|
3122 | },
|
---|
3123 | set({ _: instance }, key, value) {
|
---|
3124 | const { data, setupState, ctx } = instance;
|
---|
3125 | if (hasSetupBinding(setupState, key)) {
|
---|
3126 | setupState[key] = value;
|
---|
3127 | return true;
|
---|
3128 | } else if (setupState.__isScriptSetup && shared.hasOwn(setupState, key)) {
|
---|
3129 | warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
|
---|
3130 | return false;
|
---|
3131 | } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
|
---|
3132 | data[key] = value;
|
---|
3133 | return true;
|
---|
3134 | } else if (shared.hasOwn(instance.props, key)) {
|
---|
3135 | warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
|
---|
3136 | return false;
|
---|
3137 | }
|
---|
3138 | if (key[0] === "$" && key.slice(1) in instance) {
|
---|
3139 | warn$1(
|
---|
3140 | `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
|
---|
3141 | );
|
---|
3142 | return false;
|
---|
3143 | } else {
|
---|
3144 | if (key in instance.appContext.config.globalProperties) {
|
---|
3145 | Object.defineProperty(ctx, key, {
|
---|
3146 | enumerable: true,
|
---|
3147 | configurable: true,
|
---|
3148 | value
|
---|
3149 | });
|
---|
3150 | } else {
|
---|
3151 | ctx[key] = value;
|
---|
3152 | }
|
---|
3153 | }
|
---|
3154 | return true;
|
---|
3155 | },
|
---|
3156 | has({
|
---|
3157 | _: { data, setupState, accessCache, ctx, appContext, propsOptions }
|
---|
3158 | }, key) {
|
---|
3159 | let normalizedProps;
|
---|
3160 | return !!accessCache[key] || data !== shared.EMPTY_OBJ && shared.hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && shared.hasOwn(normalizedProps, key) || shared.hasOwn(ctx, key) || shared.hasOwn(publicPropertiesMap, key) || shared.hasOwn(appContext.config.globalProperties, key);
|
---|
3161 | },
|
---|
3162 | defineProperty(target, key, descriptor) {
|
---|
3163 | if (descriptor.get != null) {
|
---|
3164 | target._.accessCache[key] = 0;
|
---|
3165 | } else if (shared.hasOwn(descriptor, "value")) {
|
---|
3166 | this.set(target, key, descriptor.value, null);
|
---|
3167 | }
|
---|
3168 | return Reflect.defineProperty(target, key, descriptor);
|
---|
3169 | }
|
---|
3170 | };
|
---|
3171 | {
|
---|
3172 | PublicInstanceProxyHandlers.ownKeys = (target) => {
|
---|
3173 | warn$1(
|
---|
3174 | `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
|
---|
3175 | );
|
---|
3176 | return Reflect.ownKeys(target);
|
---|
3177 | };
|
---|
3178 | }
|
---|
3179 | const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ shared.extend({}, PublicInstanceProxyHandlers, {
|
---|
3180 | get(target, key) {
|
---|
3181 | if (key === Symbol.unscopables) {
|
---|
3182 | return;
|
---|
3183 | }
|
---|
3184 | return PublicInstanceProxyHandlers.get(target, key, target);
|
---|
3185 | },
|
---|
3186 | has(_, key) {
|
---|
3187 | const has = key[0] !== "_" && !shared.isGloballyAllowed(key);
|
---|
3188 | if (!has && PublicInstanceProxyHandlers.has(_, key)) {
|
---|
3189 | warn$1(
|
---|
3190 | `Property ${JSON.stringify(
|
---|
3191 | key
|
---|
3192 | )} should not start with _ which is a reserved prefix for Vue internals.`
|
---|
3193 | );
|
---|
3194 | }
|
---|
3195 | return has;
|
---|
3196 | }
|
---|
3197 | });
|
---|
3198 | function createDevRenderContext(instance) {
|
---|
3199 | const target = {};
|
---|
3200 | Object.defineProperty(target, `_`, {
|
---|
3201 | configurable: true,
|
---|
3202 | enumerable: false,
|
---|
3203 | get: () => instance
|
---|
3204 | });
|
---|
3205 | Object.keys(publicPropertiesMap).forEach((key) => {
|
---|
3206 | Object.defineProperty(target, key, {
|
---|
3207 | configurable: true,
|
---|
3208 | enumerable: false,
|
---|
3209 | get: () => publicPropertiesMap[key](instance),
|
---|
3210 | // intercepted by the proxy so no need for implementation,
|
---|
3211 | // but needed to prevent set errors
|
---|
3212 | set: shared.NOOP
|
---|
3213 | });
|
---|
3214 | });
|
---|
3215 | return target;
|
---|
3216 | }
|
---|
3217 | function exposePropsOnRenderContext(instance) {
|
---|
3218 | const {
|
---|
3219 | ctx,
|
---|
3220 | propsOptions: [propsOptions]
|
---|
3221 | } = instance;
|
---|
3222 | if (propsOptions) {
|
---|
3223 | Object.keys(propsOptions).forEach((key) => {
|
---|
3224 | Object.defineProperty(ctx, key, {
|
---|
3225 | enumerable: true,
|
---|
3226 | configurable: true,
|
---|
3227 | get: () => instance.props[key],
|
---|
3228 | set: shared.NOOP
|
---|
3229 | });
|
---|
3230 | });
|
---|
3231 | }
|
---|
3232 | }
|
---|
3233 | function exposeSetupStateOnRenderContext(instance) {
|
---|
3234 | const { ctx, setupState } = instance;
|
---|
3235 | Object.keys(reactivity.toRaw(setupState)).forEach((key) => {
|
---|
3236 | if (!setupState.__isScriptSetup) {
|
---|
3237 | if (isReservedPrefix(key[0])) {
|
---|
3238 | warn$1(
|
---|
3239 | `setup() return property ${JSON.stringify(
|
---|
3240 | key
|
---|
3241 | )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
|
---|
3242 | );
|
---|
3243 | return;
|
---|
3244 | }
|
---|
3245 | Object.defineProperty(ctx, key, {
|
---|
3246 | enumerable: true,
|
---|
3247 | configurable: true,
|
---|
3248 | get: () => setupState[key],
|
---|
3249 | set: shared.NOOP
|
---|
3250 | });
|
---|
3251 | }
|
---|
3252 | });
|
---|
3253 | }
|
---|
3254 |
|
---|
3255 | const warnRuntimeUsage = (method) => warn$1(
|
---|
3256 | `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`
|
---|
3257 | );
|
---|
3258 | function defineProps() {
|
---|
3259 | {
|
---|
3260 | warnRuntimeUsage(`defineProps`);
|
---|
3261 | }
|
---|
3262 | return null;
|
---|
3263 | }
|
---|
3264 | function defineEmits() {
|
---|
3265 | {
|
---|
3266 | warnRuntimeUsage(`defineEmits`);
|
---|
3267 | }
|
---|
3268 | return null;
|
---|
3269 | }
|
---|
3270 | function defineExpose(exposed) {
|
---|
3271 | {
|
---|
3272 | warnRuntimeUsage(`defineExpose`);
|
---|
3273 | }
|
---|
3274 | }
|
---|
3275 | function defineOptions(options) {
|
---|
3276 | {
|
---|
3277 | warnRuntimeUsage(`defineOptions`);
|
---|
3278 | }
|
---|
3279 | }
|
---|
3280 | function defineSlots() {
|
---|
3281 | {
|
---|
3282 | warnRuntimeUsage(`defineSlots`);
|
---|
3283 | }
|
---|
3284 | return null;
|
---|
3285 | }
|
---|
3286 | function defineModel() {
|
---|
3287 | {
|
---|
3288 | warnRuntimeUsage("defineModel");
|
---|
3289 | }
|
---|
3290 | }
|
---|
3291 | function withDefaults(props, defaults) {
|
---|
3292 | {
|
---|
3293 | warnRuntimeUsage(`withDefaults`);
|
---|
3294 | }
|
---|
3295 | return null;
|
---|
3296 | }
|
---|
3297 | function useSlots() {
|
---|
3298 | return getContext().slots;
|
---|
3299 | }
|
---|
3300 | function useAttrs() {
|
---|
3301 | return getContext().attrs;
|
---|
3302 | }
|
---|
3303 | function getContext() {
|
---|
3304 | const i = getCurrentInstance();
|
---|
3305 | if (!i) {
|
---|
3306 | warn$1(`useContext() called without active instance.`);
|
---|
3307 | }
|
---|
3308 | return i.setupContext || (i.setupContext = createSetupContext(i));
|
---|
3309 | }
|
---|
3310 | function normalizePropsOrEmits(props) {
|
---|
3311 | return shared.isArray(props) ? props.reduce(
|
---|
3312 | (normalized, p) => (normalized[p] = null, normalized),
|
---|
3313 | {}
|
---|
3314 | ) : props;
|
---|
3315 | }
|
---|
3316 | function mergeDefaults(raw, defaults) {
|
---|
3317 | const props = normalizePropsOrEmits(raw);
|
---|
3318 | for (const key in defaults) {
|
---|
3319 | if (key.startsWith("__skip")) continue;
|
---|
3320 | let opt = props[key];
|
---|
3321 | if (opt) {
|
---|
3322 | if (shared.isArray(opt) || shared.isFunction(opt)) {
|
---|
3323 | opt = props[key] = { type: opt, default: defaults[key] };
|
---|
3324 | } else {
|
---|
3325 | opt.default = defaults[key];
|
---|
3326 | }
|
---|
3327 | } else if (opt === null) {
|
---|
3328 | opt = props[key] = { default: defaults[key] };
|
---|
3329 | } else {
|
---|
3330 | warn$1(`props default key "${key}" has no corresponding declaration.`);
|
---|
3331 | }
|
---|
3332 | if (opt && defaults[`__skip_${key}`]) {
|
---|
3333 | opt.skipFactory = true;
|
---|
3334 | }
|
---|
3335 | }
|
---|
3336 | return props;
|
---|
3337 | }
|
---|
3338 | function mergeModels(a, b) {
|
---|
3339 | if (!a || !b) return a || b;
|
---|
3340 | if (shared.isArray(a) && shared.isArray(b)) return a.concat(b);
|
---|
3341 | return shared.extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
|
---|
3342 | }
|
---|
3343 | function createPropsRestProxy(props, excludedKeys) {
|
---|
3344 | const ret = {};
|
---|
3345 | for (const key in props) {
|
---|
3346 | if (!excludedKeys.includes(key)) {
|
---|
3347 | Object.defineProperty(ret, key, {
|
---|
3348 | enumerable: true,
|
---|
3349 | get: () => props[key]
|
---|
3350 | });
|
---|
3351 | }
|
---|
3352 | }
|
---|
3353 | return ret;
|
---|
3354 | }
|
---|
3355 | function withAsyncContext(getAwaitable) {
|
---|
3356 | const ctx = getCurrentInstance();
|
---|
3357 | if (!ctx) {
|
---|
3358 | warn$1(
|
---|
3359 | `withAsyncContext called without active current instance. This is likely a bug.`
|
---|
3360 | );
|
---|
3361 | }
|
---|
3362 | let awaitable = getAwaitable();
|
---|
3363 | unsetCurrentInstance();
|
---|
3364 | if (shared.isPromise(awaitable)) {
|
---|
3365 | awaitable = awaitable.catch((e) => {
|
---|
3366 | setCurrentInstance(ctx);
|
---|
3367 | throw e;
|
---|
3368 | });
|
---|
3369 | }
|
---|
3370 | return [awaitable, () => setCurrentInstance(ctx)];
|
---|
3371 | }
|
---|
3372 |
|
---|
3373 | function createDuplicateChecker() {
|
---|
3374 | const cache = /* @__PURE__ */ Object.create(null);
|
---|
3375 | return (type, key) => {
|
---|
3376 | if (cache[key]) {
|
---|
3377 | warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
|
---|
3378 | } else {
|
---|
3379 | cache[key] = type;
|
---|
3380 | }
|
---|
3381 | };
|
---|
3382 | }
|
---|
3383 | let shouldCacheAccess = true;
|
---|
3384 | function applyOptions(instance) {
|
---|
3385 | const options = resolveMergedOptions(instance);
|
---|
3386 | const publicThis = instance.proxy;
|
---|
3387 | const ctx = instance.ctx;
|
---|
3388 | shouldCacheAccess = false;
|
---|
3389 | if (options.beforeCreate) {
|
---|
3390 | callHook(options.beforeCreate, instance, "bc");
|
---|
3391 | }
|
---|
3392 | const {
|
---|
3393 | // state
|
---|
3394 | data: dataOptions,
|
---|
3395 | computed: computedOptions,
|
---|
3396 | methods,
|
---|
3397 | watch: watchOptions,
|
---|
3398 | provide: provideOptions,
|
---|
3399 | inject: injectOptions,
|
---|
3400 | // lifecycle
|
---|
3401 | created,
|
---|
3402 | beforeMount,
|
---|
3403 | mounted,
|
---|
3404 | beforeUpdate,
|
---|
3405 | updated,
|
---|
3406 | activated,
|
---|
3407 | deactivated,
|
---|
3408 | beforeDestroy,
|
---|
3409 | beforeUnmount,
|
---|
3410 | destroyed,
|
---|
3411 | unmounted,
|
---|
3412 | render,
|
---|
3413 | renderTracked,
|
---|
3414 | renderTriggered,
|
---|
3415 | errorCaptured,
|
---|
3416 | serverPrefetch,
|
---|
3417 | // public API
|
---|
3418 | expose,
|
---|
3419 | inheritAttrs,
|
---|
3420 | // assets
|
---|
3421 | components,
|
---|
3422 | directives,
|
---|
3423 | filters
|
---|
3424 | } = options;
|
---|
3425 | const checkDuplicateProperties = createDuplicateChecker() ;
|
---|
3426 | {
|
---|
3427 | const [propsOptions] = instance.propsOptions;
|
---|
3428 | if (propsOptions) {
|
---|
3429 | for (const key in propsOptions) {
|
---|
3430 | checkDuplicateProperties("Props" /* PROPS */, key);
|
---|
3431 | }
|
---|
3432 | }
|
---|
3433 | }
|
---|
3434 | if (injectOptions) {
|
---|
3435 | resolveInjections(injectOptions, ctx, checkDuplicateProperties);
|
---|
3436 | }
|
---|
3437 | if (methods) {
|
---|
3438 | for (const key in methods) {
|
---|
3439 | const methodHandler = methods[key];
|
---|
3440 | if (shared.isFunction(methodHandler)) {
|
---|
3441 | {
|
---|
3442 | Object.defineProperty(ctx, key, {
|
---|
3443 | value: methodHandler.bind(publicThis),
|
---|
3444 | configurable: true,
|
---|
3445 | enumerable: true,
|
---|
3446 | writable: true
|
---|
3447 | });
|
---|
3448 | }
|
---|
3449 | {
|
---|
3450 | checkDuplicateProperties("Methods" /* METHODS */, key);
|
---|
3451 | }
|
---|
3452 | } else {
|
---|
3453 | warn$1(
|
---|
3454 | `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
|
---|
3455 | );
|
---|
3456 | }
|
---|
3457 | }
|
---|
3458 | }
|
---|
3459 | if (dataOptions) {
|
---|
3460 | if (!shared.isFunction(dataOptions)) {
|
---|
3461 | warn$1(
|
---|
3462 | `The data option must be a function. Plain object usage is no longer supported.`
|
---|
3463 | );
|
---|
3464 | }
|
---|
3465 | const data = dataOptions.call(publicThis, publicThis);
|
---|
3466 | if (shared.isPromise(data)) {
|
---|
3467 | warn$1(
|
---|
3468 | `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
|
---|
3469 | );
|
---|
3470 | }
|
---|
3471 | if (!shared.isObject(data)) {
|
---|
3472 | warn$1(`data() should return an object.`);
|
---|
3473 | } else {
|
---|
3474 | instance.data = reactivity.reactive(data);
|
---|
3475 | {
|
---|
3476 | for (const key in data) {
|
---|
3477 | checkDuplicateProperties("Data" /* DATA */, key);
|
---|
3478 | if (!isReservedPrefix(key[0])) {
|
---|
3479 | Object.defineProperty(ctx, key, {
|
---|
3480 | configurable: true,
|
---|
3481 | enumerable: true,
|
---|
3482 | get: () => data[key],
|
---|
3483 | set: shared.NOOP
|
---|
3484 | });
|
---|
3485 | }
|
---|
3486 | }
|
---|
3487 | }
|
---|
3488 | }
|
---|
3489 | }
|
---|
3490 | shouldCacheAccess = true;
|
---|
3491 | if (computedOptions) {
|
---|
3492 | for (const key in computedOptions) {
|
---|
3493 | const opt = computedOptions[key];
|
---|
3494 | const get = shared.isFunction(opt) ? opt.bind(publicThis, publicThis) : shared.isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : shared.NOOP;
|
---|
3495 | if (get === shared.NOOP) {
|
---|
3496 | warn$1(`Computed property "${key}" has no getter.`);
|
---|
3497 | }
|
---|
3498 | const set = !shared.isFunction(opt) && shared.isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
|
---|
3499 | warn$1(
|
---|
3500 | `Write operation failed: computed property "${key}" is readonly.`
|
---|
3501 | );
|
---|
3502 | } ;
|
---|
3503 | const c = computed({
|
---|
3504 | get,
|
---|
3505 | set
|
---|
3506 | });
|
---|
3507 | Object.defineProperty(ctx, key, {
|
---|
3508 | enumerable: true,
|
---|
3509 | configurable: true,
|
---|
3510 | get: () => c.value,
|
---|
3511 | set: (v) => c.value = v
|
---|
3512 | });
|
---|
3513 | {
|
---|
3514 | checkDuplicateProperties("Computed" /* COMPUTED */, key);
|
---|
3515 | }
|
---|
3516 | }
|
---|
3517 | }
|
---|
3518 | if (watchOptions) {
|
---|
3519 | for (const key in watchOptions) {
|
---|
3520 | createWatcher(watchOptions[key], ctx, publicThis, key);
|
---|
3521 | }
|
---|
3522 | }
|
---|
3523 | if (provideOptions) {
|
---|
3524 | const provides = shared.isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
|
---|
3525 | Reflect.ownKeys(provides).forEach((key) => {
|
---|
3526 | provide(key, provides[key]);
|
---|
3527 | });
|
---|
3528 | }
|
---|
3529 | if (created) {
|
---|
3530 | callHook(created, instance, "c");
|
---|
3531 | }
|
---|
3532 | function registerLifecycleHook(register, hook) {
|
---|
3533 | if (shared.isArray(hook)) {
|
---|
3534 | hook.forEach((_hook) => register(_hook.bind(publicThis)));
|
---|
3535 | } else if (hook) {
|
---|
3536 | register(hook.bind(publicThis));
|
---|
3537 | }
|
---|
3538 | }
|
---|
3539 | registerLifecycleHook(onBeforeMount, beforeMount);
|
---|
3540 | registerLifecycleHook(onMounted, mounted);
|
---|
3541 | registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
---|
3542 | registerLifecycleHook(onUpdated, updated);
|
---|
3543 | registerLifecycleHook(onActivated, activated);
|
---|
3544 | registerLifecycleHook(onDeactivated, deactivated);
|
---|
3545 | registerLifecycleHook(onErrorCaptured, errorCaptured);
|
---|
3546 | registerLifecycleHook(onRenderTracked, renderTracked);
|
---|
3547 | registerLifecycleHook(onRenderTriggered, renderTriggered);
|
---|
3548 | registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
---|
3549 | registerLifecycleHook(onUnmounted, unmounted);
|
---|
3550 | registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
---|
3551 | if (shared.isArray(expose)) {
|
---|
3552 | if (expose.length) {
|
---|
3553 | const exposed = instance.exposed || (instance.exposed = {});
|
---|
3554 | expose.forEach((key) => {
|
---|
3555 | Object.defineProperty(exposed, key, {
|
---|
3556 | get: () => publicThis[key],
|
---|
3557 | set: (val) => publicThis[key] = val
|
---|
3558 | });
|
---|
3559 | });
|
---|
3560 | } else if (!instance.exposed) {
|
---|
3561 | instance.exposed = {};
|
---|
3562 | }
|
---|
3563 | }
|
---|
3564 | if (render && instance.render === shared.NOOP) {
|
---|
3565 | instance.render = render;
|
---|
3566 | }
|
---|
3567 | if (inheritAttrs != null) {
|
---|
3568 | instance.inheritAttrs = inheritAttrs;
|
---|
3569 | }
|
---|
3570 | if (components) instance.components = components;
|
---|
3571 | if (directives) instance.directives = directives;
|
---|
3572 | if (serverPrefetch) {
|
---|
3573 | markAsyncBoundary(instance);
|
---|
3574 | }
|
---|
3575 | }
|
---|
3576 | function resolveInjections(injectOptions, ctx, checkDuplicateProperties = shared.NOOP) {
|
---|
3577 | if (shared.isArray(injectOptions)) {
|
---|
3578 | injectOptions = normalizeInject(injectOptions);
|
---|
3579 | }
|
---|
3580 | for (const key in injectOptions) {
|
---|
3581 | const opt = injectOptions[key];
|
---|
3582 | let injected;
|
---|
3583 | if (shared.isObject(opt)) {
|
---|
3584 | if ("default" in opt) {
|
---|
3585 | injected = inject(
|
---|
3586 | opt.from || key,
|
---|
3587 | opt.default,
|
---|
3588 | true
|
---|
3589 | );
|
---|
3590 | } else {
|
---|
3591 | injected = inject(opt.from || key);
|
---|
3592 | }
|
---|
3593 | } else {
|
---|
3594 | injected = inject(opt);
|
---|
3595 | }
|
---|
3596 | if (reactivity.isRef(injected)) {
|
---|
3597 | Object.defineProperty(ctx, key, {
|
---|
3598 | enumerable: true,
|
---|
3599 | configurable: true,
|
---|
3600 | get: () => injected.value,
|
---|
3601 | set: (v) => injected.value = v
|
---|
3602 | });
|
---|
3603 | } else {
|
---|
3604 | ctx[key] = injected;
|
---|
3605 | }
|
---|
3606 | {
|
---|
3607 | checkDuplicateProperties("Inject" /* INJECT */, key);
|
---|
3608 | }
|
---|
3609 | }
|
---|
3610 | }
|
---|
3611 | function callHook(hook, instance, type) {
|
---|
3612 | callWithAsyncErrorHandling(
|
---|
3613 | shared.isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
|
---|
3614 | instance,
|
---|
3615 | type
|
---|
3616 | );
|
---|
3617 | }
|
---|
3618 | function createWatcher(raw, ctx, publicThis, key) {
|
---|
3619 | let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
---|
3620 | if (shared.isString(raw)) {
|
---|
3621 | const handler = ctx[raw];
|
---|
3622 | if (shared.isFunction(handler)) {
|
---|
3623 | {
|
---|
3624 | watch(getter, handler);
|
---|
3625 | }
|
---|
3626 | } else {
|
---|
3627 | warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
|
---|
3628 | }
|
---|
3629 | } else if (shared.isFunction(raw)) {
|
---|
3630 | {
|
---|
3631 | watch(getter, raw.bind(publicThis));
|
---|
3632 | }
|
---|
3633 | } else if (shared.isObject(raw)) {
|
---|
3634 | if (shared.isArray(raw)) {
|
---|
3635 | raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
|
---|
3636 | } else {
|
---|
3637 | const handler = shared.isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
|
---|
3638 | if (shared.isFunction(handler)) {
|
---|
3639 | watch(getter, handler, raw);
|
---|
3640 | } else {
|
---|
3641 | warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
|
---|
3642 | }
|
---|
3643 | }
|
---|
3644 | } else {
|
---|
3645 | warn$1(`Invalid watch option: "${key}"`, raw);
|
---|
3646 | }
|
---|
3647 | }
|
---|
3648 | function resolveMergedOptions(instance) {
|
---|
3649 | const base = instance.type;
|
---|
3650 | const { mixins, extends: extendsOptions } = base;
|
---|
3651 | const {
|
---|
3652 | mixins: globalMixins,
|
---|
3653 | optionsCache: cache,
|
---|
3654 | config: { optionMergeStrategies }
|
---|
3655 | } = instance.appContext;
|
---|
3656 | const cached = cache.get(base);
|
---|
3657 | let resolved;
|
---|
3658 | if (cached) {
|
---|
3659 | resolved = cached;
|
---|
3660 | } else if (!globalMixins.length && !mixins && !extendsOptions) {
|
---|
3661 | {
|
---|
3662 | resolved = base;
|
---|
3663 | }
|
---|
3664 | } else {
|
---|
3665 | resolved = {};
|
---|
3666 | if (globalMixins.length) {
|
---|
3667 | globalMixins.forEach(
|
---|
3668 | (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
|
---|
3669 | );
|
---|
3670 | }
|
---|
3671 | mergeOptions(resolved, base, optionMergeStrategies);
|
---|
3672 | }
|
---|
3673 | if (shared.isObject(base)) {
|
---|
3674 | cache.set(base, resolved);
|
---|
3675 | }
|
---|
3676 | return resolved;
|
---|
3677 | }
|
---|
3678 | function mergeOptions(to, from, strats, asMixin = false) {
|
---|
3679 | const { mixins, extends: extendsOptions } = from;
|
---|
3680 | if (extendsOptions) {
|
---|
3681 | mergeOptions(to, extendsOptions, strats, true);
|
---|
3682 | }
|
---|
3683 | if (mixins) {
|
---|
3684 | mixins.forEach(
|
---|
3685 | (m) => mergeOptions(to, m, strats, true)
|
---|
3686 | );
|
---|
3687 | }
|
---|
3688 | for (const key in from) {
|
---|
3689 | if (asMixin && key === "expose") {
|
---|
3690 | warn$1(
|
---|
3691 | `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
|
---|
3692 | );
|
---|
3693 | } else {
|
---|
3694 | const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
---|
3695 | to[key] = strat ? strat(to[key], from[key]) : from[key];
|
---|
3696 | }
|
---|
3697 | }
|
---|
3698 | return to;
|
---|
3699 | }
|
---|
3700 | const internalOptionMergeStrats = {
|
---|
3701 | data: mergeDataFn,
|
---|
3702 | props: mergeEmitsOrPropsOptions,
|
---|
3703 | emits: mergeEmitsOrPropsOptions,
|
---|
3704 | // objects
|
---|
3705 | methods: mergeObjectOptions,
|
---|
3706 | computed: mergeObjectOptions,
|
---|
3707 | // lifecycle
|
---|
3708 | beforeCreate: mergeAsArray,
|
---|
3709 | created: mergeAsArray,
|
---|
3710 | beforeMount: mergeAsArray,
|
---|
3711 | mounted: mergeAsArray,
|
---|
3712 | beforeUpdate: mergeAsArray,
|
---|
3713 | updated: mergeAsArray,
|
---|
3714 | beforeDestroy: mergeAsArray,
|
---|
3715 | beforeUnmount: mergeAsArray,
|
---|
3716 | destroyed: mergeAsArray,
|
---|
3717 | unmounted: mergeAsArray,
|
---|
3718 | activated: mergeAsArray,
|
---|
3719 | deactivated: mergeAsArray,
|
---|
3720 | errorCaptured: mergeAsArray,
|
---|
3721 | serverPrefetch: mergeAsArray,
|
---|
3722 | // assets
|
---|
3723 | components: mergeObjectOptions,
|
---|
3724 | directives: mergeObjectOptions,
|
---|
3725 | // watch
|
---|
3726 | watch: mergeWatchOptions,
|
---|
3727 | // provide / inject
|
---|
3728 | provide: mergeDataFn,
|
---|
3729 | inject: mergeInject
|
---|
3730 | };
|
---|
3731 | function mergeDataFn(to, from) {
|
---|
3732 | if (!from) {
|
---|
3733 | return to;
|
---|
3734 | }
|
---|
3735 | if (!to) {
|
---|
3736 | return from;
|
---|
3737 | }
|
---|
3738 | return function mergedDataFn() {
|
---|
3739 | return (shared.extend)(
|
---|
3740 | shared.isFunction(to) ? to.call(this, this) : to,
|
---|
3741 | shared.isFunction(from) ? from.call(this, this) : from
|
---|
3742 | );
|
---|
3743 | };
|
---|
3744 | }
|
---|
3745 | function mergeInject(to, from) {
|
---|
3746 | return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
---|
3747 | }
|
---|
3748 | function normalizeInject(raw) {
|
---|
3749 | if (shared.isArray(raw)) {
|
---|
3750 | const res = {};
|
---|
3751 | for (let i = 0; i < raw.length; i++) {
|
---|
3752 | res[raw[i]] = raw[i];
|
---|
3753 | }
|
---|
3754 | return res;
|
---|
3755 | }
|
---|
3756 | return raw;
|
---|
3757 | }
|
---|
3758 | function mergeAsArray(to, from) {
|
---|
3759 | return to ? [...new Set([].concat(to, from))] : from;
|
---|
3760 | }
|
---|
3761 | function mergeObjectOptions(to, from) {
|
---|
3762 | return to ? shared.extend(/* @__PURE__ */ Object.create(null), to, from) : from;
|
---|
3763 | }
|
---|
3764 | function mergeEmitsOrPropsOptions(to, from) {
|
---|
3765 | if (to) {
|
---|
3766 | if (shared.isArray(to) && shared.isArray(from)) {
|
---|
3767 | return [.../* @__PURE__ */ new Set([...to, ...from])];
|
---|
3768 | }
|
---|
3769 | return shared.extend(
|
---|
3770 | /* @__PURE__ */ Object.create(null),
|
---|
3771 | normalizePropsOrEmits(to),
|
---|
3772 | normalizePropsOrEmits(from != null ? from : {})
|
---|
3773 | );
|
---|
3774 | } else {
|
---|
3775 | return from;
|
---|
3776 | }
|
---|
3777 | }
|
---|
3778 | function mergeWatchOptions(to, from) {
|
---|
3779 | if (!to) return from;
|
---|
3780 | if (!from) return to;
|
---|
3781 | const merged = shared.extend(/* @__PURE__ */ Object.create(null), to);
|
---|
3782 | for (const key in from) {
|
---|
3783 | merged[key] = mergeAsArray(to[key], from[key]);
|
---|
3784 | }
|
---|
3785 | return merged;
|
---|
3786 | }
|
---|
3787 |
|
---|
3788 | function createAppContext() {
|
---|
3789 | return {
|
---|
3790 | app: null,
|
---|
3791 | config: {
|
---|
3792 | isNativeTag: shared.NO,
|
---|
3793 | performance: false,
|
---|
3794 | globalProperties: {},
|
---|
3795 | optionMergeStrategies: {},
|
---|
3796 | errorHandler: void 0,
|
---|
3797 | warnHandler: void 0,
|
---|
3798 | compilerOptions: {}
|
---|
3799 | },
|
---|
3800 | mixins: [],
|
---|
3801 | components: {},
|
---|
3802 | directives: {},
|
---|
3803 | provides: /* @__PURE__ */ Object.create(null),
|
---|
3804 | optionsCache: /* @__PURE__ */ new WeakMap(),
|
---|
3805 | propsCache: /* @__PURE__ */ new WeakMap(),
|
---|
3806 | emitsCache: /* @__PURE__ */ new WeakMap()
|
---|
3807 | };
|
---|
3808 | }
|
---|
3809 | let uid$1 = 0;
|
---|
3810 | function createAppAPI(render, hydrate) {
|
---|
3811 | return function createApp(rootComponent, rootProps = null) {
|
---|
3812 | if (!shared.isFunction(rootComponent)) {
|
---|
3813 | rootComponent = shared.extend({}, rootComponent);
|
---|
3814 | }
|
---|
3815 | if (rootProps != null && !shared.isObject(rootProps)) {
|
---|
3816 | warn$1(`root props passed to app.mount() must be an object.`);
|
---|
3817 | rootProps = null;
|
---|
3818 | }
|
---|
3819 | const context = createAppContext();
|
---|
3820 | const installedPlugins = /* @__PURE__ */ new WeakSet();
|
---|
3821 | const pluginCleanupFns = [];
|
---|
3822 | let isMounted = false;
|
---|
3823 | const app = context.app = {
|
---|
3824 | _uid: uid$1++,
|
---|
3825 | _component: rootComponent,
|
---|
3826 | _props: rootProps,
|
---|
3827 | _container: null,
|
---|
3828 | _context: context,
|
---|
3829 | _instance: null,
|
---|
3830 | version,
|
---|
3831 | get config() {
|
---|
3832 | return context.config;
|
---|
3833 | },
|
---|
3834 | set config(v) {
|
---|
3835 | {
|
---|
3836 | warn$1(
|
---|
3837 | `app.config cannot be replaced. Modify individual options instead.`
|
---|
3838 | );
|
---|
3839 | }
|
---|
3840 | },
|
---|
3841 | use(plugin, ...options) {
|
---|
3842 | if (installedPlugins.has(plugin)) {
|
---|
3843 | warn$1(`Plugin has already been applied to target app.`);
|
---|
3844 | } else if (plugin && shared.isFunction(plugin.install)) {
|
---|
3845 | installedPlugins.add(plugin);
|
---|
3846 | plugin.install(app, ...options);
|
---|
3847 | } else if (shared.isFunction(plugin)) {
|
---|
3848 | installedPlugins.add(plugin);
|
---|
3849 | plugin(app, ...options);
|
---|
3850 | } else {
|
---|
3851 | warn$1(
|
---|
3852 | `A plugin must either be a function or an object with an "install" function.`
|
---|
3853 | );
|
---|
3854 | }
|
---|
3855 | return app;
|
---|
3856 | },
|
---|
3857 | mixin(mixin) {
|
---|
3858 | {
|
---|
3859 | if (!context.mixins.includes(mixin)) {
|
---|
3860 | context.mixins.push(mixin);
|
---|
3861 | } else {
|
---|
3862 | warn$1(
|
---|
3863 | "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
|
---|
3864 | );
|
---|
3865 | }
|
---|
3866 | }
|
---|
3867 | return app;
|
---|
3868 | },
|
---|
3869 | component(name, component) {
|
---|
3870 | {
|
---|
3871 | validateComponentName(name, context.config);
|
---|
3872 | }
|
---|
3873 | if (!component) {
|
---|
3874 | return context.components[name];
|
---|
3875 | }
|
---|
3876 | if (context.components[name]) {
|
---|
3877 | warn$1(`Component "${name}" has already been registered in target app.`);
|
---|
3878 | }
|
---|
3879 | context.components[name] = component;
|
---|
3880 | return app;
|
---|
3881 | },
|
---|
3882 | directive(name, directive) {
|
---|
3883 | {
|
---|
3884 | validateDirectiveName(name);
|
---|
3885 | }
|
---|
3886 | if (!directive) {
|
---|
3887 | return context.directives[name];
|
---|
3888 | }
|
---|
3889 | if (context.directives[name]) {
|
---|
3890 | warn$1(`Directive "${name}" has already been registered in target app.`);
|
---|
3891 | }
|
---|
3892 | context.directives[name] = directive;
|
---|
3893 | return app;
|
---|
3894 | },
|
---|
3895 | mount(rootContainer, isHydrate, namespace) {
|
---|
3896 | if (!isMounted) {
|
---|
3897 | if (rootContainer.__vue_app__) {
|
---|
3898 | warn$1(
|
---|
3899 | `There is already an app instance mounted on the host container.
|
---|
3900 | If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
|
---|
3901 | );
|
---|
3902 | }
|
---|
3903 | const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
|
---|
3904 | vnode.appContext = context;
|
---|
3905 | if (namespace === true) {
|
---|
3906 | namespace = "svg";
|
---|
3907 | } else if (namespace === false) {
|
---|
3908 | namespace = void 0;
|
---|
3909 | }
|
---|
3910 | {
|
---|
3911 | context.reload = () => {
|
---|
3912 | render(
|
---|
3913 | cloneVNode(vnode),
|
---|
3914 | rootContainer,
|
---|
3915 | namespace
|
---|
3916 | );
|
---|
3917 | };
|
---|
3918 | }
|
---|
3919 | if (isHydrate && hydrate) {
|
---|
3920 | hydrate(vnode, rootContainer);
|
---|
3921 | } else {
|
---|
3922 | render(vnode, rootContainer, namespace);
|
---|
3923 | }
|
---|
3924 | isMounted = true;
|
---|
3925 | app._container = rootContainer;
|
---|
3926 | rootContainer.__vue_app__ = app;
|
---|
3927 | {
|
---|
3928 | app._instance = vnode.component;
|
---|
3929 | devtoolsInitApp(app, version);
|
---|
3930 | }
|
---|
3931 | return getComponentPublicInstance(vnode.component);
|
---|
3932 | } else {
|
---|
3933 | warn$1(
|
---|
3934 | `App has already been mounted.
|
---|
3935 | If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
|
---|
3936 | );
|
---|
3937 | }
|
---|
3938 | },
|
---|
3939 | onUnmount(cleanupFn) {
|
---|
3940 | if (typeof cleanupFn !== "function") {
|
---|
3941 | warn$1(
|
---|
3942 | `Expected function as first argument to app.onUnmount(), but got ${typeof cleanupFn}`
|
---|
3943 | );
|
---|
3944 | }
|
---|
3945 | pluginCleanupFns.push(cleanupFn);
|
---|
3946 | },
|
---|
3947 | unmount() {
|
---|
3948 | if (isMounted) {
|
---|
3949 | callWithAsyncErrorHandling(
|
---|
3950 | pluginCleanupFns,
|
---|
3951 | app._instance,
|
---|
3952 | 16
|
---|
3953 | );
|
---|
3954 | render(null, app._container);
|
---|
3955 | {
|
---|
3956 | app._instance = null;
|
---|
3957 | devtoolsUnmountApp(app);
|
---|
3958 | }
|
---|
3959 | delete app._container.__vue_app__;
|
---|
3960 | } else {
|
---|
3961 | warn$1(`Cannot unmount an app that is not mounted.`);
|
---|
3962 | }
|
---|
3963 | },
|
---|
3964 | provide(key, value) {
|
---|
3965 | if (key in context.provides) {
|
---|
3966 | warn$1(
|
---|
3967 | `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
|
---|
3968 | );
|
---|
3969 | }
|
---|
3970 | context.provides[key] = value;
|
---|
3971 | return app;
|
---|
3972 | },
|
---|
3973 | runWithContext(fn) {
|
---|
3974 | const lastApp = currentApp;
|
---|
3975 | currentApp = app;
|
---|
3976 | try {
|
---|
3977 | return fn();
|
---|
3978 | } finally {
|
---|
3979 | currentApp = lastApp;
|
---|
3980 | }
|
---|
3981 | }
|
---|
3982 | };
|
---|
3983 | return app;
|
---|
3984 | };
|
---|
3985 | }
|
---|
3986 | let currentApp = null;
|
---|
3987 |
|
---|
3988 | function provide(key, value) {
|
---|
3989 | if (!currentInstance) {
|
---|
3990 | {
|
---|
3991 | warn$1(`provide() can only be used inside setup().`);
|
---|
3992 | }
|
---|
3993 | } else {
|
---|
3994 | let provides = currentInstance.provides;
|
---|
3995 | const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
---|
3996 | if (parentProvides === provides) {
|
---|
3997 | provides = currentInstance.provides = Object.create(parentProvides);
|
---|
3998 | }
|
---|
3999 | provides[key] = value;
|
---|
4000 | }
|
---|
4001 | }
|
---|
4002 | function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
---|
4003 | const instance = currentInstance || currentRenderingInstance;
|
---|
4004 | if (instance || currentApp) {
|
---|
4005 | const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
|
---|
4006 | if (provides && key in provides) {
|
---|
4007 | return provides[key];
|
---|
4008 | } else if (arguments.length > 1) {
|
---|
4009 | return treatDefaultAsFactory && shared.isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
---|
4010 | } else {
|
---|
4011 | warn$1(`injection "${String(key)}" not found.`);
|
---|
4012 | }
|
---|
4013 | } else {
|
---|
4014 | warn$1(`inject() can only be used inside setup() or functional components.`);
|
---|
4015 | }
|
---|
4016 | }
|
---|
4017 | function hasInjectionContext() {
|
---|
4018 | return !!(currentInstance || currentRenderingInstance || currentApp);
|
---|
4019 | }
|
---|
4020 |
|
---|
4021 | const internalObjectProto = {};
|
---|
4022 | const createInternalObject = () => Object.create(internalObjectProto);
|
---|
4023 | const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
|
---|
4024 |
|
---|
4025 | function initProps(instance, rawProps, isStateful, isSSR = false) {
|
---|
4026 | const props = {};
|
---|
4027 | const attrs = createInternalObject();
|
---|
4028 | instance.propsDefaults = /* @__PURE__ */ Object.create(null);
|
---|
4029 | setFullProps(instance, rawProps, props, attrs);
|
---|
4030 | for (const key in instance.propsOptions[0]) {
|
---|
4031 | if (!(key in props)) {
|
---|
4032 | props[key] = void 0;
|
---|
4033 | }
|
---|
4034 | }
|
---|
4035 | {
|
---|
4036 | validateProps(rawProps || {}, props, instance);
|
---|
4037 | }
|
---|
4038 | if (isStateful) {
|
---|
4039 | instance.props = isSSR ? props : reactivity.shallowReactive(props);
|
---|
4040 | } else {
|
---|
4041 | if (!instance.type.props) {
|
---|
4042 | instance.props = attrs;
|
---|
4043 | } else {
|
---|
4044 | instance.props = props;
|
---|
4045 | }
|
---|
4046 | }
|
---|
4047 | instance.attrs = attrs;
|
---|
4048 | }
|
---|
4049 | function isInHmrContext(instance) {
|
---|
4050 | while (instance) {
|
---|
4051 | if (instance.type.__hmrId) return true;
|
---|
4052 | instance = instance.parent;
|
---|
4053 | }
|
---|
4054 | }
|
---|
4055 | function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
---|
4056 | const {
|
---|
4057 | props,
|
---|
4058 | attrs,
|
---|
4059 | vnode: { patchFlag }
|
---|
4060 | } = instance;
|
---|
4061 | const rawCurrentProps = reactivity.toRaw(props);
|
---|
4062 | const [options] = instance.propsOptions;
|
---|
4063 | let hasAttrsChanged = false;
|
---|
4064 | if (
|
---|
4065 | // always force full diff in dev
|
---|
4066 | // - #1942 if hmr is enabled with sfc component
|
---|
4067 | // - vite#872 non-sfc component used by sfc component
|
---|
4068 | !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
|
---|
4069 | ) {
|
---|
4070 | if (patchFlag & 8) {
|
---|
4071 | const propsToUpdate = instance.vnode.dynamicProps;
|
---|
4072 | for (let i = 0; i < propsToUpdate.length; i++) {
|
---|
4073 | let key = propsToUpdate[i];
|
---|
4074 | if (isEmitListener(instance.emitsOptions, key)) {
|
---|
4075 | continue;
|
---|
4076 | }
|
---|
4077 | const value = rawProps[key];
|
---|
4078 | if (options) {
|
---|
4079 | if (shared.hasOwn(attrs, key)) {
|
---|
4080 | if (value !== attrs[key]) {
|
---|
4081 | attrs[key] = value;
|
---|
4082 | hasAttrsChanged = true;
|
---|
4083 | }
|
---|
4084 | } else {
|
---|
4085 | const camelizedKey = shared.camelize(key);
|
---|
4086 | props[camelizedKey] = resolvePropValue(
|
---|
4087 | options,
|
---|
4088 | rawCurrentProps,
|
---|
4089 | camelizedKey,
|
---|
4090 | value,
|
---|
4091 | instance,
|
---|
4092 | false
|
---|
4093 | );
|
---|
4094 | }
|
---|
4095 | } else {
|
---|
4096 | if (value !== attrs[key]) {
|
---|
4097 | attrs[key] = value;
|
---|
4098 | hasAttrsChanged = true;
|
---|
4099 | }
|
---|
4100 | }
|
---|
4101 | }
|
---|
4102 | }
|
---|
4103 | } else {
|
---|
4104 | if (setFullProps(instance, rawProps, props, attrs)) {
|
---|
4105 | hasAttrsChanged = true;
|
---|
4106 | }
|
---|
4107 | let kebabKey;
|
---|
4108 | for (const key in rawCurrentProps) {
|
---|
4109 | if (!rawProps || // for camelCase
|
---|
4110 | !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
|
---|
4111 | // and converted to camelCase (#955)
|
---|
4112 | ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
|
---|
4113 | if (options) {
|
---|
4114 | if (rawPrevProps && // for camelCase
|
---|
4115 | (rawPrevProps[key] !== void 0 || // for kebab-case
|
---|
4116 | rawPrevProps[kebabKey] !== void 0)) {
|
---|
4117 | props[key] = resolvePropValue(
|
---|
4118 | options,
|
---|
4119 | rawCurrentProps,
|
---|
4120 | key,
|
---|
4121 | void 0,
|
---|
4122 | instance,
|
---|
4123 | true
|
---|
4124 | );
|
---|
4125 | }
|
---|
4126 | } else {
|
---|
4127 | delete props[key];
|
---|
4128 | }
|
---|
4129 | }
|
---|
4130 | }
|
---|
4131 | if (attrs !== rawCurrentProps) {
|
---|
4132 | for (const key in attrs) {
|
---|
4133 | if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
|
---|
4134 | delete attrs[key];
|
---|
4135 | hasAttrsChanged = true;
|
---|
4136 | }
|
---|
4137 | }
|
---|
4138 | }
|
---|
4139 | }
|
---|
4140 | if (hasAttrsChanged) {
|
---|
4141 | reactivity.trigger(instance.attrs, "set", "");
|
---|
4142 | }
|
---|
4143 | {
|
---|
4144 | validateProps(rawProps || {}, props, instance);
|
---|
4145 | }
|
---|
4146 | }
|
---|
4147 | function setFullProps(instance, rawProps, props, attrs) {
|
---|
4148 | const [options, needCastKeys] = instance.propsOptions;
|
---|
4149 | let hasAttrsChanged = false;
|
---|
4150 | let rawCastValues;
|
---|
4151 | if (rawProps) {
|
---|
4152 | for (let key in rawProps) {
|
---|
4153 | if (shared.isReservedProp(key)) {
|
---|
4154 | continue;
|
---|
4155 | }
|
---|
4156 | const value = rawProps[key];
|
---|
4157 | let camelKey;
|
---|
4158 | if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
|
---|
4159 | if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
---|
4160 | props[camelKey] = value;
|
---|
4161 | } else {
|
---|
4162 | (rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
---|
4163 | }
|
---|
4164 | } else if (!isEmitListener(instance.emitsOptions, key)) {
|
---|
4165 | if (!(key in attrs) || value !== attrs[key]) {
|
---|
4166 | attrs[key] = value;
|
---|
4167 | hasAttrsChanged = true;
|
---|
4168 | }
|
---|
4169 | }
|
---|
4170 | }
|
---|
4171 | }
|
---|
4172 | if (needCastKeys) {
|
---|
4173 | const rawCurrentProps = reactivity.toRaw(props);
|
---|
4174 | const castValues = rawCastValues || shared.EMPTY_OBJ;
|
---|
4175 | for (let i = 0; i < needCastKeys.length; i++) {
|
---|
4176 | const key = needCastKeys[i];
|
---|
4177 | props[key] = resolvePropValue(
|
---|
4178 | options,
|
---|
4179 | rawCurrentProps,
|
---|
4180 | key,
|
---|
4181 | castValues[key],
|
---|
4182 | instance,
|
---|
4183 | !shared.hasOwn(castValues, key)
|
---|
4184 | );
|
---|
4185 | }
|
---|
4186 | }
|
---|
4187 | return hasAttrsChanged;
|
---|
4188 | }
|
---|
4189 | function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
---|
4190 | const opt = options[key];
|
---|
4191 | if (opt != null) {
|
---|
4192 | const hasDefault = shared.hasOwn(opt, "default");
|
---|
4193 | if (hasDefault && value === void 0) {
|
---|
4194 | const defaultValue = opt.default;
|
---|
4195 | if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
|
---|
4196 | const { propsDefaults } = instance;
|
---|
4197 | if (key in propsDefaults) {
|
---|
4198 | value = propsDefaults[key];
|
---|
4199 | } else {
|
---|
4200 | const reset = setCurrentInstance(instance);
|
---|
4201 | value = propsDefaults[key] = defaultValue.call(
|
---|
4202 | null,
|
---|
4203 | props
|
---|
4204 | );
|
---|
4205 | reset();
|
---|
4206 | }
|
---|
4207 | } else {
|
---|
4208 | value = defaultValue;
|
---|
4209 | }
|
---|
4210 | if (instance.ce) {
|
---|
4211 | instance.ce._setProp(key, value);
|
---|
4212 | }
|
---|
4213 | }
|
---|
4214 | if (opt[0 /* shouldCast */]) {
|
---|
4215 | if (isAbsent && !hasDefault) {
|
---|
4216 | value = false;
|
---|
4217 | } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
|
---|
4218 | value = true;
|
---|
4219 | }
|
---|
4220 | }
|
---|
4221 | }
|
---|
4222 | return value;
|
---|
4223 | }
|
---|
4224 | const mixinPropsCache = /* @__PURE__ */ new WeakMap();
|
---|
4225 | function normalizePropsOptions(comp, appContext, asMixin = false) {
|
---|
4226 | const cache = asMixin ? mixinPropsCache : appContext.propsCache;
|
---|
4227 | const cached = cache.get(comp);
|
---|
4228 | if (cached) {
|
---|
4229 | return cached;
|
---|
4230 | }
|
---|
4231 | const raw = comp.props;
|
---|
4232 | const normalized = {};
|
---|
4233 | const needCastKeys = [];
|
---|
4234 | let hasExtends = false;
|
---|
4235 | if (!shared.isFunction(comp)) {
|
---|
4236 | const extendProps = (raw2) => {
|
---|
4237 | hasExtends = true;
|
---|
4238 | const [props, keys] = normalizePropsOptions(raw2, appContext, true);
|
---|
4239 | shared.extend(normalized, props);
|
---|
4240 | if (keys) needCastKeys.push(...keys);
|
---|
4241 | };
|
---|
4242 | if (!asMixin && appContext.mixins.length) {
|
---|
4243 | appContext.mixins.forEach(extendProps);
|
---|
4244 | }
|
---|
4245 | if (comp.extends) {
|
---|
4246 | extendProps(comp.extends);
|
---|
4247 | }
|
---|
4248 | if (comp.mixins) {
|
---|
4249 | comp.mixins.forEach(extendProps);
|
---|
4250 | }
|
---|
4251 | }
|
---|
4252 | if (!raw && !hasExtends) {
|
---|
4253 | if (shared.isObject(comp)) {
|
---|
4254 | cache.set(comp, shared.EMPTY_ARR);
|
---|
4255 | }
|
---|
4256 | return shared.EMPTY_ARR;
|
---|
4257 | }
|
---|
4258 | if (shared.isArray(raw)) {
|
---|
4259 | for (let i = 0; i < raw.length; i++) {
|
---|
4260 | if (!shared.isString(raw[i])) {
|
---|
4261 | warn$1(`props must be strings when using array syntax.`, raw[i]);
|
---|
4262 | }
|
---|
4263 | const normalizedKey = shared.camelize(raw[i]);
|
---|
4264 | if (validatePropName(normalizedKey)) {
|
---|
4265 | normalized[normalizedKey] = shared.EMPTY_OBJ;
|
---|
4266 | }
|
---|
4267 | }
|
---|
4268 | } else if (raw) {
|
---|
4269 | if (!shared.isObject(raw)) {
|
---|
4270 | warn$1(`invalid props options`, raw);
|
---|
4271 | }
|
---|
4272 | for (const key in raw) {
|
---|
4273 | const normalizedKey = shared.camelize(key);
|
---|
4274 | if (validatePropName(normalizedKey)) {
|
---|
4275 | const opt = raw[key];
|
---|
4276 | const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
|
---|
4277 | const propType = prop.type;
|
---|
4278 | let shouldCast = false;
|
---|
4279 | let shouldCastTrue = true;
|
---|
4280 | if (shared.isArray(propType)) {
|
---|
4281 | for (let index = 0; index < propType.length; ++index) {
|
---|
4282 | const type = propType[index];
|
---|
4283 | const typeName = shared.isFunction(type) && type.name;
|
---|
4284 | if (typeName === "Boolean") {
|
---|
4285 | shouldCast = true;
|
---|
4286 | break;
|
---|
4287 | } else if (typeName === "String") {
|
---|
4288 | shouldCastTrue = false;
|
---|
4289 | }
|
---|
4290 | }
|
---|
4291 | } else {
|
---|
4292 | shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
|
---|
4293 | }
|
---|
4294 | prop[0 /* shouldCast */] = shouldCast;
|
---|
4295 | prop[1 /* shouldCastTrue */] = shouldCastTrue;
|
---|
4296 | if (shouldCast || shared.hasOwn(prop, "default")) {
|
---|
4297 | needCastKeys.push(normalizedKey);
|
---|
4298 | }
|
---|
4299 | }
|
---|
4300 | }
|
---|
4301 | }
|
---|
4302 | const res = [normalized, needCastKeys];
|
---|
4303 | if (shared.isObject(comp)) {
|
---|
4304 | cache.set(comp, res);
|
---|
4305 | }
|
---|
4306 | return res;
|
---|
4307 | }
|
---|
4308 | function validatePropName(key) {
|
---|
4309 | if (key[0] !== "$" && !shared.isReservedProp(key)) {
|
---|
4310 | return true;
|
---|
4311 | } else {
|
---|
4312 | warn$1(`Invalid prop name: "${key}" is a reserved property.`);
|
---|
4313 | }
|
---|
4314 | return false;
|
---|
4315 | }
|
---|
4316 | function getType(ctor) {
|
---|
4317 | if (ctor === null) {
|
---|
4318 | return "null";
|
---|
4319 | }
|
---|
4320 | if (typeof ctor === "function") {
|
---|
4321 | return ctor.name || "";
|
---|
4322 | } else if (typeof ctor === "object") {
|
---|
4323 | const name = ctor.constructor && ctor.constructor.name;
|
---|
4324 | return name || "";
|
---|
4325 | }
|
---|
4326 | return "";
|
---|
4327 | }
|
---|
4328 | function validateProps(rawProps, props, instance) {
|
---|
4329 | const resolvedValues = reactivity.toRaw(props);
|
---|
4330 | const options = instance.propsOptions[0];
|
---|
4331 | const camelizePropsKey = Object.keys(rawProps).map((key) => shared.camelize(key));
|
---|
4332 | for (const key in options) {
|
---|
4333 | let opt = options[key];
|
---|
4334 | if (opt == null) continue;
|
---|
4335 | validateProp(
|
---|
4336 | key,
|
---|
4337 | resolvedValues[key],
|
---|
4338 | opt,
|
---|
4339 | reactivity.shallowReadonly(resolvedValues) ,
|
---|
4340 | !camelizePropsKey.includes(key)
|
---|
4341 | );
|
---|
4342 | }
|
---|
4343 | }
|
---|
4344 | function validateProp(name, value, prop, props, isAbsent) {
|
---|
4345 | const { type, required, validator, skipCheck } = prop;
|
---|
4346 | if (required && isAbsent) {
|
---|
4347 | warn$1('Missing required prop: "' + name + '"');
|
---|
4348 | return;
|
---|
4349 | }
|
---|
4350 | if (value == null && !required) {
|
---|
4351 | return;
|
---|
4352 | }
|
---|
4353 | if (type != null && type !== true && !skipCheck) {
|
---|
4354 | let isValid = false;
|
---|
4355 | const types = shared.isArray(type) ? type : [type];
|
---|
4356 | const expectedTypes = [];
|
---|
4357 | for (let i = 0; i < types.length && !isValid; i++) {
|
---|
4358 | const { valid, expectedType } = assertType(value, types[i]);
|
---|
4359 | expectedTypes.push(expectedType || "");
|
---|
4360 | isValid = valid;
|
---|
4361 | }
|
---|
4362 | if (!isValid) {
|
---|
4363 | warn$1(getInvalidTypeMessage(name, value, expectedTypes));
|
---|
4364 | return;
|
---|
4365 | }
|
---|
4366 | }
|
---|
4367 | if (validator && !validator(value, props)) {
|
---|
4368 | warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
|
---|
4369 | }
|
---|
4370 | }
|
---|
4371 | const isSimpleType = /* @__PURE__ */ shared.makeMap(
|
---|
4372 | "String,Number,Boolean,Function,Symbol,BigInt"
|
---|
4373 | );
|
---|
4374 | function assertType(value, type) {
|
---|
4375 | let valid;
|
---|
4376 | const expectedType = getType(type);
|
---|
4377 | if (expectedType === "null") {
|
---|
4378 | valid = value === null;
|
---|
4379 | } else if (isSimpleType(expectedType)) {
|
---|
4380 | const t = typeof value;
|
---|
4381 | valid = t === expectedType.toLowerCase();
|
---|
4382 | if (!valid && t === "object") {
|
---|
4383 | valid = value instanceof type;
|
---|
4384 | }
|
---|
4385 | } else if (expectedType === "Object") {
|
---|
4386 | valid = shared.isObject(value);
|
---|
4387 | } else if (expectedType === "Array") {
|
---|
4388 | valid = shared.isArray(value);
|
---|
4389 | } else {
|
---|
4390 | valid = value instanceof type;
|
---|
4391 | }
|
---|
4392 | return {
|
---|
4393 | valid,
|
---|
4394 | expectedType
|
---|
4395 | };
|
---|
4396 | }
|
---|
4397 | function getInvalidTypeMessage(name, value, expectedTypes) {
|
---|
4398 | if (expectedTypes.length === 0) {
|
---|
4399 | return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
|
---|
4400 | }
|
---|
4401 | let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(shared.capitalize).join(" | ")}`;
|
---|
4402 | const expectedType = expectedTypes[0];
|
---|
4403 | const receivedType = shared.toRawType(value);
|
---|
4404 | const expectedValue = styleValue(value, expectedType);
|
---|
4405 | const receivedValue = styleValue(value, receivedType);
|
---|
4406 | if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
|
---|
4407 | message += ` with value ${expectedValue}`;
|
---|
4408 | }
|
---|
4409 | message += `, got ${receivedType} `;
|
---|
4410 | if (isExplicable(receivedType)) {
|
---|
4411 | message += `with value ${receivedValue}.`;
|
---|
4412 | }
|
---|
4413 | return message;
|
---|
4414 | }
|
---|
4415 | function styleValue(value, type) {
|
---|
4416 | if (type === "String") {
|
---|
4417 | return `"${value}"`;
|
---|
4418 | } else if (type === "Number") {
|
---|
4419 | return `${Number(value)}`;
|
---|
4420 | } else {
|
---|
4421 | return `${value}`;
|
---|
4422 | }
|
---|
4423 | }
|
---|
4424 | function isExplicable(type) {
|
---|
4425 | const explicitTypes = ["string", "number", "boolean"];
|
---|
4426 | return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
---|
4427 | }
|
---|
4428 | function isBoolean(...args) {
|
---|
4429 | return args.some((elem) => elem.toLowerCase() === "boolean");
|
---|
4430 | }
|
---|
4431 |
|
---|
4432 | const isInternalKey = (key) => key[0] === "_" || key === "$stable";
|
---|
4433 | const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
|
---|
4434 | const normalizeSlot = (key, rawSlot, ctx) => {
|
---|
4435 | if (rawSlot._n) {
|
---|
4436 | return rawSlot;
|
---|
4437 | }
|
---|
4438 | const normalized = withCtx((...args) => {
|
---|
4439 | if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
|
---|
4440 | warn$1(
|
---|
4441 | `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
|
---|
4442 | );
|
---|
4443 | }
|
---|
4444 | return normalizeSlotValue(rawSlot(...args));
|
---|
4445 | }, ctx);
|
---|
4446 | normalized._c = false;
|
---|
4447 | return normalized;
|
---|
4448 | };
|
---|
4449 | const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
---|
4450 | const ctx = rawSlots._ctx;
|
---|
4451 | for (const key in rawSlots) {
|
---|
4452 | if (isInternalKey(key)) continue;
|
---|
4453 | const value = rawSlots[key];
|
---|
4454 | if (shared.isFunction(value)) {
|
---|
4455 | slots[key] = normalizeSlot(key, value, ctx);
|
---|
4456 | } else if (value != null) {
|
---|
4457 | {
|
---|
4458 | warn$1(
|
---|
4459 | `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
|
---|
4460 | );
|
---|
4461 | }
|
---|
4462 | const normalized = normalizeSlotValue(value);
|
---|
4463 | slots[key] = () => normalized;
|
---|
4464 | }
|
---|
4465 | }
|
---|
4466 | };
|
---|
4467 | const normalizeVNodeSlots = (instance, children) => {
|
---|
4468 | if (!isKeepAlive(instance.vnode) && true) {
|
---|
4469 | warn$1(
|
---|
4470 | `Non-function value encountered for default slot. Prefer function slots for better performance.`
|
---|
4471 | );
|
---|
4472 | }
|
---|
4473 | const normalized = normalizeSlotValue(children);
|
---|
4474 | instance.slots.default = () => normalized;
|
---|
4475 | };
|
---|
4476 | const assignSlots = (slots, children, optimized) => {
|
---|
4477 | for (const key in children) {
|
---|
4478 | if (optimized || key !== "_") {
|
---|
4479 | slots[key] = children[key];
|
---|
4480 | }
|
---|
4481 | }
|
---|
4482 | };
|
---|
4483 | const initSlots = (instance, children, optimized) => {
|
---|
4484 | const slots = instance.slots = createInternalObject();
|
---|
4485 | if (instance.vnode.shapeFlag & 32) {
|
---|
4486 | const type = children._;
|
---|
4487 | if (type) {
|
---|
4488 | assignSlots(slots, children, optimized);
|
---|
4489 | if (optimized) {
|
---|
4490 | shared.def(slots, "_", type, true);
|
---|
4491 | }
|
---|
4492 | } else {
|
---|
4493 | normalizeObjectSlots(children, slots);
|
---|
4494 | }
|
---|
4495 | } else if (children) {
|
---|
4496 | normalizeVNodeSlots(instance, children);
|
---|
4497 | }
|
---|
4498 | };
|
---|
4499 | const updateSlots = (instance, children, optimized) => {
|
---|
4500 | const { vnode, slots } = instance;
|
---|
4501 | let needDeletionCheck = true;
|
---|
4502 | let deletionComparisonTarget = shared.EMPTY_OBJ;
|
---|
4503 | if (vnode.shapeFlag & 32) {
|
---|
4504 | const type = children._;
|
---|
4505 | if (type) {
|
---|
4506 | if (isHmrUpdating) {
|
---|
4507 | assignSlots(slots, children, optimized);
|
---|
4508 | reactivity.trigger(instance, "set", "$slots");
|
---|
4509 | } else if (optimized && type === 1) {
|
---|
4510 | needDeletionCheck = false;
|
---|
4511 | } else {
|
---|
4512 | assignSlots(slots, children, optimized);
|
---|
4513 | }
|
---|
4514 | } else {
|
---|
4515 | needDeletionCheck = !children.$stable;
|
---|
4516 | normalizeObjectSlots(children, slots);
|
---|
4517 | }
|
---|
4518 | deletionComparisonTarget = children;
|
---|
4519 | } else if (children) {
|
---|
4520 | normalizeVNodeSlots(instance, children);
|
---|
4521 | deletionComparisonTarget = { default: 1 };
|
---|
4522 | }
|
---|
4523 | if (needDeletionCheck) {
|
---|
4524 | for (const key in slots) {
|
---|
4525 | if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
|
---|
4526 | delete slots[key];
|
---|
4527 | }
|
---|
4528 | }
|
---|
4529 | }
|
---|
4530 | };
|
---|
4531 |
|
---|
4532 | let supported;
|
---|
4533 | let perf;
|
---|
4534 | function startMeasure(instance, type) {
|
---|
4535 | if (instance.appContext.config.performance && isSupported()) {
|
---|
4536 | perf.mark(`vue-${type}-${instance.uid}`);
|
---|
4537 | }
|
---|
4538 | {
|
---|
4539 | devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
|
---|
4540 | }
|
---|
4541 | }
|
---|
4542 | function endMeasure(instance, type) {
|
---|
4543 | if (instance.appContext.config.performance && isSupported()) {
|
---|
4544 | const startTag = `vue-${type}-${instance.uid}`;
|
---|
4545 | const endTag = startTag + `:end`;
|
---|
4546 | perf.mark(endTag);
|
---|
4547 | perf.measure(
|
---|
4548 | `<${formatComponentName(instance, instance.type)}> ${type}`,
|
---|
4549 | startTag,
|
---|
4550 | endTag
|
---|
4551 | );
|
---|
4552 | perf.clearMarks(startTag);
|
---|
4553 | perf.clearMarks(endTag);
|
---|
4554 | }
|
---|
4555 | {
|
---|
4556 | devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
|
---|
4557 | }
|
---|
4558 | }
|
---|
4559 | function isSupported() {
|
---|
4560 | if (supported !== void 0) {
|
---|
4561 | return supported;
|
---|
4562 | }
|
---|
4563 | if (typeof window !== "undefined" && window.performance) {
|
---|
4564 | supported = true;
|
---|
4565 | perf = window.performance;
|
---|
4566 | } else {
|
---|
4567 | supported = false;
|
---|
4568 | }
|
---|
4569 | return supported;
|
---|
4570 | }
|
---|
4571 |
|
---|
4572 | const queuePostRenderEffect = queueEffectWithSuspense ;
|
---|
4573 | function createRenderer(options) {
|
---|
4574 | return baseCreateRenderer(options);
|
---|
4575 | }
|
---|
4576 | function createHydrationRenderer(options) {
|
---|
4577 | return baseCreateRenderer(options, createHydrationFunctions);
|
---|
4578 | }
|
---|
4579 | function baseCreateRenderer(options, createHydrationFns) {
|
---|
4580 | const target = shared.getGlobalThis();
|
---|
4581 | target.__VUE__ = true;
|
---|
4582 | {
|
---|
4583 | setDevtoolsHook$1(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
---|
4584 | }
|
---|
4585 | const {
|
---|
4586 | insert: hostInsert,
|
---|
4587 | remove: hostRemove,
|
---|
4588 | patchProp: hostPatchProp,
|
---|
4589 | createElement: hostCreateElement,
|
---|
4590 | createText: hostCreateText,
|
---|
4591 | createComment: hostCreateComment,
|
---|
4592 | setText: hostSetText,
|
---|
4593 | setElementText: hostSetElementText,
|
---|
4594 | parentNode: hostParentNode,
|
---|
4595 | nextSibling: hostNextSibling,
|
---|
4596 | setScopeId: hostSetScopeId = shared.NOOP,
|
---|
4597 | insertStaticContent: hostInsertStaticContent
|
---|
4598 | } = options;
|
---|
4599 | const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
|
---|
4600 | if (n1 === n2) {
|
---|
4601 | return;
|
---|
4602 | }
|
---|
4603 | if (n1 && !isSameVNodeType(n1, n2)) {
|
---|
4604 | anchor = getNextHostNode(n1);
|
---|
4605 | unmount(n1, parentComponent, parentSuspense, true);
|
---|
4606 | n1 = null;
|
---|
4607 | }
|
---|
4608 | if (n2.patchFlag === -2) {
|
---|
4609 | optimized = false;
|
---|
4610 | n2.dynamicChildren = null;
|
---|
4611 | }
|
---|
4612 | const { type, ref, shapeFlag } = n2;
|
---|
4613 | switch (type) {
|
---|
4614 | case Text:
|
---|
4615 | processText(n1, n2, container, anchor);
|
---|
4616 | break;
|
---|
4617 | case Comment:
|
---|
4618 | processCommentNode(n1, n2, container, anchor);
|
---|
4619 | break;
|
---|
4620 | case Static:
|
---|
4621 | if (n1 == null) {
|
---|
4622 | mountStaticNode(n2, container, anchor, namespace);
|
---|
4623 | } else {
|
---|
4624 | patchStaticNode(n1, n2, container, namespace);
|
---|
4625 | }
|
---|
4626 | break;
|
---|
4627 | case Fragment:
|
---|
4628 | processFragment(
|
---|
4629 | n1,
|
---|
4630 | n2,
|
---|
4631 | container,
|
---|
4632 | anchor,
|
---|
4633 | parentComponent,
|
---|
4634 | parentSuspense,
|
---|
4635 | namespace,
|
---|
4636 | slotScopeIds,
|
---|
4637 | optimized
|
---|
4638 | );
|
---|
4639 | break;
|
---|
4640 | default:
|
---|
4641 | if (shapeFlag & 1) {
|
---|
4642 | processElement(
|
---|
4643 | n1,
|
---|
4644 | n2,
|
---|
4645 | container,
|
---|
4646 | anchor,
|
---|
4647 | parentComponent,
|
---|
4648 | parentSuspense,
|
---|
4649 | namespace,
|
---|
4650 | slotScopeIds,
|
---|
4651 | optimized
|
---|
4652 | );
|
---|
4653 | } else if (shapeFlag & 6) {
|
---|
4654 | processComponent(
|
---|
4655 | n1,
|
---|
4656 | n2,
|
---|
4657 | container,
|
---|
4658 | anchor,
|
---|
4659 | parentComponent,
|
---|
4660 | parentSuspense,
|
---|
4661 | namespace,
|
---|
4662 | slotScopeIds,
|
---|
4663 | optimized
|
---|
4664 | );
|
---|
4665 | } else if (shapeFlag & 64) {
|
---|
4666 | type.process(
|
---|
4667 | n1,
|
---|
4668 | n2,
|
---|
4669 | container,
|
---|
4670 | anchor,
|
---|
4671 | parentComponent,
|
---|
4672 | parentSuspense,
|
---|
4673 | namespace,
|
---|
4674 | slotScopeIds,
|
---|
4675 | optimized,
|
---|
4676 | internals
|
---|
4677 | );
|
---|
4678 | } else if (shapeFlag & 128) {
|
---|
4679 | type.process(
|
---|
4680 | n1,
|
---|
4681 | n2,
|
---|
4682 | container,
|
---|
4683 | anchor,
|
---|
4684 | parentComponent,
|
---|
4685 | parentSuspense,
|
---|
4686 | namespace,
|
---|
4687 | slotScopeIds,
|
---|
4688 | optimized,
|
---|
4689 | internals
|
---|
4690 | );
|
---|
4691 | } else {
|
---|
4692 | warn$1("Invalid VNode type:", type, `(${typeof type})`);
|
---|
4693 | }
|
---|
4694 | }
|
---|
4695 | if (ref != null && parentComponent) {
|
---|
4696 | setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
---|
4697 | }
|
---|
4698 | };
|
---|
4699 | const processText = (n1, n2, container, anchor) => {
|
---|
4700 | if (n1 == null) {
|
---|
4701 | hostInsert(
|
---|
4702 | n2.el = hostCreateText(n2.children),
|
---|
4703 | container,
|
---|
4704 | anchor
|
---|
4705 | );
|
---|
4706 | } else {
|
---|
4707 | const el = n2.el = n1.el;
|
---|
4708 | if (n2.children !== n1.children) {
|
---|
4709 | hostSetText(el, n2.children);
|
---|
4710 | }
|
---|
4711 | }
|
---|
4712 | };
|
---|
4713 | const processCommentNode = (n1, n2, container, anchor) => {
|
---|
4714 | if (n1 == null) {
|
---|
4715 | hostInsert(
|
---|
4716 | n2.el = hostCreateComment(n2.children || ""),
|
---|
4717 | container,
|
---|
4718 | anchor
|
---|
4719 | );
|
---|
4720 | } else {
|
---|
4721 | n2.el = n1.el;
|
---|
4722 | }
|
---|
4723 | };
|
---|
4724 | const mountStaticNode = (n2, container, anchor, namespace) => {
|
---|
4725 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
---|
4726 | n2.children,
|
---|
4727 | container,
|
---|
4728 | anchor,
|
---|
4729 | namespace,
|
---|
4730 | n2.el,
|
---|
4731 | n2.anchor
|
---|
4732 | );
|
---|
4733 | };
|
---|
4734 | const patchStaticNode = (n1, n2, container, namespace) => {
|
---|
4735 | if (n2.children !== n1.children) {
|
---|
4736 | const anchor = hostNextSibling(n1.anchor);
|
---|
4737 | removeStaticNode(n1);
|
---|
4738 | [n2.el, n2.anchor] = hostInsertStaticContent(
|
---|
4739 | n2.children,
|
---|
4740 | container,
|
---|
4741 | anchor,
|
---|
4742 | namespace
|
---|
4743 | );
|
---|
4744 | } else {
|
---|
4745 | n2.el = n1.el;
|
---|
4746 | n2.anchor = n1.anchor;
|
---|
4747 | }
|
---|
4748 | };
|
---|
4749 | const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
---|
4750 | let next;
|
---|
4751 | while (el && el !== anchor) {
|
---|
4752 | next = hostNextSibling(el);
|
---|
4753 | hostInsert(el, container, nextSibling);
|
---|
4754 | el = next;
|
---|
4755 | }
|
---|
4756 | hostInsert(anchor, container, nextSibling);
|
---|
4757 | };
|
---|
4758 | const removeStaticNode = ({ el, anchor }) => {
|
---|
4759 | let next;
|
---|
4760 | while (el && el !== anchor) {
|
---|
4761 | next = hostNextSibling(el);
|
---|
4762 | hostRemove(el);
|
---|
4763 | el = next;
|
---|
4764 | }
|
---|
4765 | hostRemove(anchor);
|
---|
4766 | };
|
---|
4767 | const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4768 | if (n2.type === "svg") {
|
---|
4769 | namespace = "svg";
|
---|
4770 | } else if (n2.type === "math") {
|
---|
4771 | namespace = "mathml";
|
---|
4772 | }
|
---|
4773 | if (n1 == null) {
|
---|
4774 | mountElement(
|
---|
4775 | n2,
|
---|
4776 | container,
|
---|
4777 | anchor,
|
---|
4778 | parentComponent,
|
---|
4779 | parentSuspense,
|
---|
4780 | namespace,
|
---|
4781 | slotScopeIds,
|
---|
4782 | optimized
|
---|
4783 | );
|
---|
4784 | } else {
|
---|
4785 | patchElement(
|
---|
4786 | n1,
|
---|
4787 | n2,
|
---|
4788 | parentComponent,
|
---|
4789 | parentSuspense,
|
---|
4790 | namespace,
|
---|
4791 | slotScopeIds,
|
---|
4792 | optimized
|
---|
4793 | );
|
---|
4794 | }
|
---|
4795 | };
|
---|
4796 | const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4797 | let el;
|
---|
4798 | let vnodeHook;
|
---|
4799 | const { props, shapeFlag, transition, dirs } = vnode;
|
---|
4800 | el = vnode.el = hostCreateElement(
|
---|
4801 | vnode.type,
|
---|
4802 | namespace,
|
---|
4803 | props && props.is,
|
---|
4804 | props
|
---|
4805 | );
|
---|
4806 | if (shapeFlag & 8) {
|
---|
4807 | hostSetElementText(el, vnode.children);
|
---|
4808 | } else if (shapeFlag & 16) {
|
---|
4809 | mountChildren(
|
---|
4810 | vnode.children,
|
---|
4811 | el,
|
---|
4812 | null,
|
---|
4813 | parentComponent,
|
---|
4814 | parentSuspense,
|
---|
4815 | resolveChildrenNamespace(vnode, namespace),
|
---|
4816 | slotScopeIds,
|
---|
4817 | optimized
|
---|
4818 | );
|
---|
4819 | }
|
---|
4820 | if (dirs) {
|
---|
4821 | invokeDirectiveHook(vnode, null, parentComponent, "created");
|
---|
4822 | }
|
---|
4823 | setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
---|
4824 | if (props) {
|
---|
4825 | for (const key in props) {
|
---|
4826 | if (key !== "value" && !shared.isReservedProp(key)) {
|
---|
4827 | hostPatchProp(el, key, null, props[key], namespace, parentComponent);
|
---|
4828 | }
|
---|
4829 | }
|
---|
4830 | if ("value" in props) {
|
---|
4831 | hostPatchProp(el, "value", null, props.value, namespace);
|
---|
4832 | }
|
---|
4833 | if (vnodeHook = props.onVnodeBeforeMount) {
|
---|
4834 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
4835 | }
|
---|
4836 | }
|
---|
4837 | {
|
---|
4838 | shared.def(el, "__vnode", vnode, true);
|
---|
4839 | shared.def(el, "__vueParentComponent", parentComponent, true);
|
---|
4840 | }
|
---|
4841 | if (dirs) {
|
---|
4842 | invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
---|
4843 | }
|
---|
4844 | const needCallTransitionHooks = needTransition(parentSuspense, transition);
|
---|
4845 | if (needCallTransitionHooks) {
|
---|
4846 | transition.beforeEnter(el);
|
---|
4847 | }
|
---|
4848 | hostInsert(el, container, anchor);
|
---|
4849 | if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
|
---|
4850 | queuePostRenderEffect(() => {
|
---|
4851 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
4852 | needCallTransitionHooks && transition.enter(el);
|
---|
4853 | dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
---|
4854 | }, parentSuspense);
|
---|
4855 | }
|
---|
4856 | };
|
---|
4857 | const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
---|
4858 | if (scopeId) {
|
---|
4859 | hostSetScopeId(el, scopeId);
|
---|
4860 | }
|
---|
4861 | if (slotScopeIds) {
|
---|
4862 | for (let i = 0; i < slotScopeIds.length; i++) {
|
---|
4863 | hostSetScopeId(el, slotScopeIds[i]);
|
---|
4864 | }
|
---|
4865 | }
|
---|
4866 | if (parentComponent) {
|
---|
4867 | let subTree = parentComponent.subTree;
|
---|
4868 | if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
|
---|
4869 | subTree = filterSingleRoot(subTree.children) || subTree;
|
---|
4870 | }
|
---|
4871 | if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
|
---|
4872 | const parentVNode = parentComponent.vnode;
|
---|
4873 | setScopeId(
|
---|
4874 | el,
|
---|
4875 | parentVNode,
|
---|
4876 | parentVNode.scopeId,
|
---|
4877 | parentVNode.slotScopeIds,
|
---|
4878 | parentComponent.parent
|
---|
4879 | );
|
---|
4880 | }
|
---|
4881 | }
|
---|
4882 | };
|
---|
4883 | const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
|
---|
4884 | for (let i = start; i < children.length; i++) {
|
---|
4885 | const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
|
---|
4886 | patch(
|
---|
4887 | null,
|
---|
4888 | child,
|
---|
4889 | container,
|
---|
4890 | anchor,
|
---|
4891 | parentComponent,
|
---|
4892 | parentSuspense,
|
---|
4893 | namespace,
|
---|
4894 | slotScopeIds,
|
---|
4895 | optimized
|
---|
4896 | );
|
---|
4897 | }
|
---|
4898 | };
|
---|
4899 | const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
4900 | const el = n2.el = n1.el;
|
---|
4901 | {
|
---|
4902 | el.__vnode = n2;
|
---|
4903 | }
|
---|
4904 | let { patchFlag, dynamicChildren, dirs } = n2;
|
---|
4905 | patchFlag |= n1.patchFlag & 16;
|
---|
4906 | const oldProps = n1.props || shared.EMPTY_OBJ;
|
---|
4907 | const newProps = n2.props || shared.EMPTY_OBJ;
|
---|
4908 | let vnodeHook;
|
---|
4909 | parentComponent && toggleRecurse(parentComponent, false);
|
---|
4910 | if (vnodeHook = newProps.onVnodeBeforeUpdate) {
|
---|
4911 | invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
---|
4912 | }
|
---|
4913 | if (dirs) {
|
---|
4914 | invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
|
---|
4915 | }
|
---|
4916 | parentComponent && toggleRecurse(parentComponent, true);
|
---|
4917 | if (isHmrUpdating) {
|
---|
4918 | patchFlag = 0;
|
---|
4919 | optimized = false;
|
---|
4920 | dynamicChildren = null;
|
---|
4921 | }
|
---|
4922 | if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
|
---|
4923 | hostSetElementText(el, "");
|
---|
4924 | }
|
---|
4925 | if (dynamicChildren) {
|
---|
4926 | patchBlockChildren(
|
---|
4927 | n1.dynamicChildren,
|
---|
4928 | dynamicChildren,
|
---|
4929 | el,
|
---|
4930 | parentComponent,
|
---|
4931 | parentSuspense,
|
---|
4932 | resolveChildrenNamespace(n2, namespace),
|
---|
4933 | slotScopeIds
|
---|
4934 | );
|
---|
4935 | {
|
---|
4936 | traverseStaticChildren(n1, n2);
|
---|
4937 | }
|
---|
4938 | } else if (!optimized) {
|
---|
4939 | patchChildren(
|
---|
4940 | n1,
|
---|
4941 | n2,
|
---|
4942 | el,
|
---|
4943 | null,
|
---|
4944 | parentComponent,
|
---|
4945 | parentSuspense,
|
---|
4946 | resolveChildrenNamespace(n2, namespace),
|
---|
4947 | slotScopeIds,
|
---|
4948 | false
|
---|
4949 | );
|
---|
4950 | }
|
---|
4951 | if (patchFlag > 0) {
|
---|
4952 | if (patchFlag & 16) {
|
---|
4953 | patchProps(el, oldProps, newProps, parentComponent, namespace);
|
---|
4954 | } else {
|
---|
4955 | if (patchFlag & 2) {
|
---|
4956 | if (oldProps.class !== newProps.class) {
|
---|
4957 | hostPatchProp(el, "class", null, newProps.class, namespace);
|
---|
4958 | }
|
---|
4959 | }
|
---|
4960 | if (patchFlag & 4) {
|
---|
4961 | hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
|
---|
4962 | }
|
---|
4963 | if (patchFlag & 8) {
|
---|
4964 | const propsToUpdate = n2.dynamicProps;
|
---|
4965 | for (let i = 0; i < propsToUpdate.length; i++) {
|
---|
4966 | const key = propsToUpdate[i];
|
---|
4967 | const prev = oldProps[key];
|
---|
4968 | const next = newProps[key];
|
---|
4969 | if (next !== prev || key === "value") {
|
---|
4970 | hostPatchProp(el, key, prev, next, namespace, parentComponent);
|
---|
4971 | }
|
---|
4972 | }
|
---|
4973 | }
|
---|
4974 | }
|
---|
4975 | if (patchFlag & 1) {
|
---|
4976 | if (n1.children !== n2.children) {
|
---|
4977 | hostSetElementText(el, n2.children);
|
---|
4978 | }
|
---|
4979 | }
|
---|
4980 | } else if (!optimized && dynamicChildren == null) {
|
---|
4981 | patchProps(el, oldProps, newProps, parentComponent, namespace);
|
---|
4982 | }
|
---|
4983 | if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
---|
4984 | queuePostRenderEffect(() => {
|
---|
4985 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
---|
4986 | dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
|
---|
4987 | }, parentSuspense);
|
---|
4988 | }
|
---|
4989 | };
|
---|
4990 | const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
|
---|
4991 | for (let i = 0; i < newChildren.length; i++) {
|
---|
4992 | const oldVNode = oldChildren[i];
|
---|
4993 | const newVNode = newChildren[i];
|
---|
4994 | const container = (
|
---|
4995 | // oldVNode may be an errored async setup() component inside Suspense
|
---|
4996 | // which will not have a mounted element
|
---|
4997 | oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
|
---|
4998 | // of the Fragment itself so it can move its children.
|
---|
4999 | (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
|
---|
5000 | // which also requires the correct parent container
|
---|
5001 | !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
|
---|
5002 | oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
|
---|
5003 | // In other cases, the parent container is not actually used so we
|
---|
5004 | // just pass the block element here to avoid a DOM parentNode call.
|
---|
5005 | fallbackContainer
|
---|
5006 | )
|
---|
5007 | );
|
---|
5008 | patch(
|
---|
5009 | oldVNode,
|
---|
5010 | newVNode,
|
---|
5011 | container,
|
---|
5012 | null,
|
---|
5013 | parentComponent,
|
---|
5014 | parentSuspense,
|
---|
5015 | namespace,
|
---|
5016 | slotScopeIds,
|
---|
5017 | true
|
---|
5018 | );
|
---|
5019 | }
|
---|
5020 | };
|
---|
5021 | const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
|
---|
5022 | if (oldProps !== newProps) {
|
---|
5023 | if (oldProps !== shared.EMPTY_OBJ) {
|
---|
5024 | for (const key in oldProps) {
|
---|
5025 | if (!shared.isReservedProp(key) && !(key in newProps)) {
|
---|
5026 | hostPatchProp(
|
---|
5027 | el,
|
---|
5028 | key,
|
---|
5029 | oldProps[key],
|
---|
5030 | null,
|
---|
5031 | namespace,
|
---|
5032 | parentComponent
|
---|
5033 | );
|
---|
5034 | }
|
---|
5035 | }
|
---|
5036 | }
|
---|
5037 | for (const key in newProps) {
|
---|
5038 | if (shared.isReservedProp(key)) continue;
|
---|
5039 | const next = newProps[key];
|
---|
5040 | const prev = oldProps[key];
|
---|
5041 | if (next !== prev && key !== "value") {
|
---|
5042 | hostPatchProp(el, key, prev, next, namespace, parentComponent);
|
---|
5043 | }
|
---|
5044 | }
|
---|
5045 | if ("value" in newProps) {
|
---|
5046 | hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
|
---|
5047 | }
|
---|
5048 | }
|
---|
5049 | };
|
---|
5050 | const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
5051 | const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
|
---|
5052 | const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
|
---|
5053 | let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
---|
5054 | if (
|
---|
5055 | // #5523 dev root fragment may inherit directives
|
---|
5056 | isHmrUpdating || patchFlag & 2048
|
---|
5057 | ) {
|
---|
5058 | patchFlag = 0;
|
---|
5059 | optimized = false;
|
---|
5060 | dynamicChildren = null;
|
---|
5061 | }
|
---|
5062 | if (fragmentSlotScopeIds) {
|
---|
5063 | slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
---|
5064 | }
|
---|
5065 | if (n1 == null) {
|
---|
5066 | hostInsert(fragmentStartAnchor, container, anchor);
|
---|
5067 | hostInsert(fragmentEndAnchor, container, anchor);
|
---|
5068 | mountChildren(
|
---|
5069 | // #10007
|
---|
5070 | // such fragment like `<></>` will be compiled into
|
---|
5071 | // a fragment which doesn't have a children.
|
---|
5072 | // In this case fallback to an empty array
|
---|
5073 | n2.children || [],
|
---|
5074 | container,
|
---|
5075 | fragmentEndAnchor,
|
---|
5076 | parentComponent,
|
---|
5077 | parentSuspense,
|
---|
5078 | namespace,
|
---|
5079 | slotScopeIds,
|
---|
5080 | optimized
|
---|
5081 | );
|
---|
5082 | } else {
|
---|
5083 | if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
|
---|
5084 | // of renderSlot() with no valid children
|
---|
5085 | n1.dynamicChildren) {
|
---|
5086 | patchBlockChildren(
|
---|
5087 | n1.dynamicChildren,
|
---|
5088 | dynamicChildren,
|
---|
5089 | container,
|
---|
5090 | parentComponent,
|
---|
5091 | parentSuspense,
|
---|
5092 | namespace,
|
---|
5093 | slotScopeIds
|
---|
5094 | );
|
---|
5095 | {
|
---|
5096 | traverseStaticChildren(n1, n2);
|
---|
5097 | }
|
---|
5098 | } else {
|
---|
5099 | patchChildren(
|
---|
5100 | n1,
|
---|
5101 | n2,
|
---|
5102 | container,
|
---|
5103 | fragmentEndAnchor,
|
---|
5104 | parentComponent,
|
---|
5105 | parentSuspense,
|
---|
5106 | namespace,
|
---|
5107 | slotScopeIds,
|
---|
5108 | optimized
|
---|
5109 | );
|
---|
5110 | }
|
---|
5111 | }
|
---|
5112 | };
|
---|
5113 | const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
5114 | n2.slotScopeIds = slotScopeIds;
|
---|
5115 | if (n1 == null) {
|
---|
5116 | if (n2.shapeFlag & 512) {
|
---|
5117 | parentComponent.ctx.activate(
|
---|
5118 | n2,
|
---|
5119 | container,
|
---|
5120 | anchor,
|
---|
5121 | namespace,
|
---|
5122 | optimized
|
---|
5123 | );
|
---|
5124 | } else {
|
---|
5125 | mountComponent(
|
---|
5126 | n2,
|
---|
5127 | container,
|
---|
5128 | anchor,
|
---|
5129 | parentComponent,
|
---|
5130 | parentSuspense,
|
---|
5131 | namespace,
|
---|
5132 | optimized
|
---|
5133 | );
|
---|
5134 | }
|
---|
5135 | } else {
|
---|
5136 | updateComponent(n1, n2, optimized);
|
---|
5137 | }
|
---|
5138 | };
|
---|
5139 | const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
|
---|
5140 | const instance = (initialVNode.component = createComponentInstance(
|
---|
5141 | initialVNode,
|
---|
5142 | parentComponent,
|
---|
5143 | parentSuspense
|
---|
5144 | ));
|
---|
5145 | if (instance.type.__hmrId) {
|
---|
5146 | registerHMR(instance);
|
---|
5147 | }
|
---|
5148 | {
|
---|
5149 | pushWarningContext(initialVNode);
|
---|
5150 | startMeasure(instance, `mount`);
|
---|
5151 | }
|
---|
5152 | if (isKeepAlive(initialVNode)) {
|
---|
5153 | instance.ctx.renderer = internals;
|
---|
5154 | }
|
---|
5155 | {
|
---|
5156 | {
|
---|
5157 | startMeasure(instance, `init`);
|
---|
5158 | }
|
---|
5159 | setupComponent(instance, false, optimized);
|
---|
5160 | {
|
---|
5161 | endMeasure(instance, `init`);
|
---|
5162 | }
|
---|
5163 | }
|
---|
5164 | if (instance.asyncDep) {
|
---|
5165 | if (isHmrUpdating) initialVNode.el = null;
|
---|
5166 | parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
|
---|
5167 | if (!initialVNode.el) {
|
---|
5168 | const placeholder = instance.subTree = createVNode(Comment);
|
---|
5169 | processCommentNode(null, placeholder, container, anchor);
|
---|
5170 | }
|
---|
5171 | } else {
|
---|
5172 | setupRenderEffect(
|
---|
5173 | instance,
|
---|
5174 | initialVNode,
|
---|
5175 | container,
|
---|
5176 | anchor,
|
---|
5177 | parentSuspense,
|
---|
5178 | namespace,
|
---|
5179 | optimized
|
---|
5180 | );
|
---|
5181 | }
|
---|
5182 | {
|
---|
5183 | popWarningContext();
|
---|
5184 | endMeasure(instance, `mount`);
|
---|
5185 | }
|
---|
5186 | };
|
---|
5187 | const updateComponent = (n1, n2, optimized) => {
|
---|
5188 | const instance = n2.component = n1.component;
|
---|
5189 | if (shouldUpdateComponent(n1, n2, optimized)) {
|
---|
5190 | if (instance.asyncDep && !instance.asyncResolved) {
|
---|
5191 | {
|
---|
5192 | pushWarningContext(n2);
|
---|
5193 | }
|
---|
5194 | updateComponentPreRender(instance, n2, optimized);
|
---|
5195 | {
|
---|
5196 | popWarningContext();
|
---|
5197 | }
|
---|
5198 | return;
|
---|
5199 | } else {
|
---|
5200 | instance.next = n2;
|
---|
5201 | instance.update();
|
---|
5202 | }
|
---|
5203 | } else {
|
---|
5204 | n2.el = n1.el;
|
---|
5205 | instance.vnode = n2;
|
---|
5206 | }
|
---|
5207 | };
|
---|
5208 | const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
|
---|
5209 | const componentUpdateFn = () => {
|
---|
5210 | if (!instance.isMounted) {
|
---|
5211 | let vnodeHook;
|
---|
5212 | const { el, props } = initialVNode;
|
---|
5213 | const { bm, m, parent, root, type } = instance;
|
---|
5214 | const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
---|
5215 | toggleRecurse(instance, false);
|
---|
5216 | if (bm) {
|
---|
5217 | shared.invokeArrayFns(bm);
|
---|
5218 | }
|
---|
5219 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
|
---|
5220 | invokeVNodeHook(vnodeHook, parent, initialVNode);
|
---|
5221 | }
|
---|
5222 | toggleRecurse(instance, true);
|
---|
5223 | if (el && hydrateNode) {
|
---|
5224 | const hydrateSubTree = () => {
|
---|
5225 | {
|
---|
5226 | startMeasure(instance, `render`);
|
---|
5227 | }
|
---|
5228 | instance.subTree = renderComponentRoot(instance);
|
---|
5229 | {
|
---|
5230 | endMeasure(instance, `render`);
|
---|
5231 | }
|
---|
5232 | {
|
---|
5233 | startMeasure(instance, `hydrate`);
|
---|
5234 | }
|
---|
5235 | hydrateNode(
|
---|
5236 | el,
|
---|
5237 | instance.subTree,
|
---|
5238 | instance,
|
---|
5239 | parentSuspense,
|
---|
5240 | null
|
---|
5241 | );
|
---|
5242 | {
|
---|
5243 | endMeasure(instance, `hydrate`);
|
---|
5244 | }
|
---|
5245 | };
|
---|
5246 | if (isAsyncWrapperVNode && type.__asyncHydrate) {
|
---|
5247 | type.__asyncHydrate(
|
---|
5248 | el,
|
---|
5249 | instance,
|
---|
5250 | hydrateSubTree
|
---|
5251 | );
|
---|
5252 | } else {
|
---|
5253 | hydrateSubTree();
|
---|
5254 | }
|
---|
5255 | } else {
|
---|
5256 | if (root.ce) {
|
---|
5257 | root.ce._injectChildStyle(type);
|
---|
5258 | }
|
---|
5259 | {
|
---|
5260 | startMeasure(instance, `render`);
|
---|
5261 | }
|
---|
5262 | const subTree = instance.subTree = renderComponentRoot(instance);
|
---|
5263 | {
|
---|
5264 | endMeasure(instance, `render`);
|
---|
5265 | }
|
---|
5266 | {
|
---|
5267 | startMeasure(instance, `patch`);
|
---|
5268 | }
|
---|
5269 | patch(
|
---|
5270 | null,
|
---|
5271 | subTree,
|
---|
5272 | container,
|
---|
5273 | anchor,
|
---|
5274 | instance,
|
---|
5275 | parentSuspense,
|
---|
5276 | namespace
|
---|
5277 | );
|
---|
5278 | {
|
---|
5279 | endMeasure(instance, `patch`);
|
---|
5280 | }
|
---|
5281 | initialVNode.el = subTree.el;
|
---|
5282 | }
|
---|
5283 | if (m) {
|
---|
5284 | queuePostRenderEffect(m, parentSuspense);
|
---|
5285 | }
|
---|
5286 | if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
|
---|
5287 | const scopedInitialVNode = initialVNode;
|
---|
5288 | queuePostRenderEffect(
|
---|
5289 | () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
|
---|
5290 | parentSuspense
|
---|
5291 | );
|
---|
5292 | }
|
---|
5293 | if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
|
---|
5294 | instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
---|
5295 | }
|
---|
5296 | instance.isMounted = true;
|
---|
5297 | {
|
---|
5298 | devtoolsComponentAdded(instance);
|
---|
5299 | }
|
---|
5300 | initialVNode = container = anchor = null;
|
---|
5301 | } else {
|
---|
5302 | let { next, bu, u, parent, vnode } = instance;
|
---|
5303 | {
|
---|
5304 | const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
|
---|
5305 | if (nonHydratedAsyncRoot) {
|
---|
5306 | if (next) {
|
---|
5307 | next.el = vnode.el;
|
---|
5308 | updateComponentPreRender(instance, next, optimized);
|
---|
5309 | }
|
---|
5310 | nonHydratedAsyncRoot.asyncDep.then(() => {
|
---|
5311 | if (!instance.isUnmounted) {
|
---|
5312 | componentUpdateFn();
|
---|
5313 | }
|
---|
5314 | });
|
---|
5315 | return;
|
---|
5316 | }
|
---|
5317 | }
|
---|
5318 | let originNext = next;
|
---|
5319 | let vnodeHook;
|
---|
5320 | {
|
---|
5321 | pushWarningContext(next || instance.vnode);
|
---|
5322 | }
|
---|
5323 | toggleRecurse(instance, false);
|
---|
5324 | if (next) {
|
---|
5325 | next.el = vnode.el;
|
---|
5326 | updateComponentPreRender(instance, next, optimized);
|
---|
5327 | } else {
|
---|
5328 | next = vnode;
|
---|
5329 | }
|
---|
5330 | if (bu) {
|
---|
5331 | shared.invokeArrayFns(bu);
|
---|
5332 | }
|
---|
5333 | if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
|
---|
5334 | invokeVNodeHook(vnodeHook, parent, next, vnode);
|
---|
5335 | }
|
---|
5336 | toggleRecurse(instance, true);
|
---|
5337 | {
|
---|
5338 | startMeasure(instance, `render`);
|
---|
5339 | }
|
---|
5340 | const nextTree = renderComponentRoot(instance);
|
---|
5341 | {
|
---|
5342 | endMeasure(instance, `render`);
|
---|
5343 | }
|
---|
5344 | const prevTree = instance.subTree;
|
---|
5345 | instance.subTree = nextTree;
|
---|
5346 | {
|
---|
5347 | startMeasure(instance, `patch`);
|
---|
5348 | }
|
---|
5349 | patch(
|
---|
5350 | prevTree,
|
---|
5351 | nextTree,
|
---|
5352 | // parent may have changed if it's in a teleport
|
---|
5353 | hostParentNode(prevTree.el),
|
---|
5354 | // anchor may have changed if it's in a fragment
|
---|
5355 | getNextHostNode(prevTree),
|
---|
5356 | instance,
|
---|
5357 | parentSuspense,
|
---|
5358 | namespace
|
---|
5359 | );
|
---|
5360 | {
|
---|
5361 | endMeasure(instance, `patch`);
|
---|
5362 | }
|
---|
5363 | next.el = nextTree.el;
|
---|
5364 | if (originNext === null) {
|
---|
5365 | updateHOCHostEl(instance, nextTree.el);
|
---|
5366 | }
|
---|
5367 | if (u) {
|
---|
5368 | queuePostRenderEffect(u, parentSuspense);
|
---|
5369 | }
|
---|
5370 | if (vnodeHook = next.props && next.props.onVnodeUpdated) {
|
---|
5371 | queuePostRenderEffect(
|
---|
5372 | () => invokeVNodeHook(vnodeHook, parent, next, vnode),
|
---|
5373 | parentSuspense
|
---|
5374 | );
|
---|
5375 | }
|
---|
5376 | {
|
---|
5377 | devtoolsComponentUpdated(instance);
|
---|
5378 | }
|
---|
5379 | {
|
---|
5380 | popWarningContext();
|
---|
5381 | }
|
---|
5382 | }
|
---|
5383 | };
|
---|
5384 | instance.scope.on();
|
---|
5385 | const effect = instance.effect = new reactivity.ReactiveEffect(componentUpdateFn);
|
---|
5386 | instance.scope.off();
|
---|
5387 | const update = instance.update = effect.run.bind(effect);
|
---|
5388 | const job = instance.job = effect.runIfDirty.bind(effect);
|
---|
5389 | job.i = instance;
|
---|
5390 | job.id = instance.uid;
|
---|
5391 | effect.scheduler = () => queueJob(job);
|
---|
5392 | toggleRecurse(instance, true);
|
---|
5393 | {
|
---|
5394 | effect.onTrack = instance.rtc ? (e) => shared.invokeArrayFns(instance.rtc, e) : void 0;
|
---|
5395 | effect.onTrigger = instance.rtg ? (e) => shared.invokeArrayFns(instance.rtg, e) : void 0;
|
---|
5396 | }
|
---|
5397 | update();
|
---|
5398 | };
|
---|
5399 | const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
---|
5400 | nextVNode.component = instance;
|
---|
5401 | const prevProps = instance.vnode.props;
|
---|
5402 | instance.vnode = nextVNode;
|
---|
5403 | instance.next = null;
|
---|
5404 | updateProps(instance, nextVNode.props, prevProps, optimized);
|
---|
5405 | updateSlots(instance, nextVNode.children, optimized);
|
---|
5406 | reactivity.pauseTracking();
|
---|
5407 | flushPreFlushCbs(instance);
|
---|
5408 | reactivity.resetTracking();
|
---|
5409 | };
|
---|
5410 | const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
|
---|
5411 | const c1 = n1 && n1.children;
|
---|
5412 | const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
---|
5413 | const c2 = n2.children;
|
---|
5414 | const { patchFlag, shapeFlag } = n2;
|
---|
5415 | if (patchFlag > 0) {
|
---|
5416 | if (patchFlag & 128) {
|
---|
5417 | patchKeyedChildren(
|
---|
5418 | c1,
|
---|
5419 | c2,
|
---|
5420 | container,
|
---|
5421 | anchor,
|
---|
5422 | parentComponent,
|
---|
5423 | parentSuspense,
|
---|
5424 | namespace,
|
---|
5425 | slotScopeIds,
|
---|
5426 | optimized
|
---|
5427 | );
|
---|
5428 | return;
|
---|
5429 | } else if (patchFlag & 256) {
|
---|
5430 | patchUnkeyedChildren(
|
---|
5431 | c1,
|
---|
5432 | c2,
|
---|
5433 | container,
|
---|
5434 | anchor,
|
---|
5435 | parentComponent,
|
---|
5436 | parentSuspense,
|
---|
5437 | namespace,
|
---|
5438 | slotScopeIds,
|
---|
5439 | optimized
|
---|
5440 | );
|
---|
5441 | return;
|
---|
5442 | }
|
---|
5443 | }
|
---|
5444 | if (shapeFlag & 8) {
|
---|
5445 | if (prevShapeFlag & 16) {
|
---|
5446 | unmountChildren(c1, parentComponent, parentSuspense);
|
---|
5447 | }
|
---|
5448 | if (c2 !== c1) {
|
---|
5449 | hostSetElementText(container, c2);
|
---|
5450 | }
|
---|
5451 | } else {
|
---|
5452 | if (prevShapeFlag & 16) {
|
---|
5453 | if (shapeFlag & 16) {
|
---|
5454 | patchKeyedChildren(
|
---|
5455 | c1,
|
---|
5456 | c2,
|
---|
5457 | container,
|
---|
5458 | anchor,
|
---|
5459 | parentComponent,
|
---|
5460 | parentSuspense,
|
---|
5461 | namespace,
|
---|
5462 | slotScopeIds,
|
---|
5463 | optimized
|
---|
5464 | );
|
---|
5465 | } else {
|
---|
5466 | unmountChildren(c1, parentComponent, parentSuspense, true);
|
---|
5467 | }
|
---|
5468 | } else {
|
---|
5469 | if (prevShapeFlag & 8) {
|
---|
5470 | hostSetElementText(container, "");
|
---|
5471 | }
|
---|
5472 | if (shapeFlag & 16) {
|
---|
5473 | mountChildren(
|
---|
5474 | c2,
|
---|
5475 | container,
|
---|
5476 | anchor,
|
---|
5477 | parentComponent,
|
---|
5478 | parentSuspense,
|
---|
5479 | namespace,
|
---|
5480 | slotScopeIds,
|
---|
5481 | optimized
|
---|
5482 | );
|
---|
5483 | }
|
---|
5484 | }
|
---|
5485 | }
|
---|
5486 | };
|
---|
5487 | const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
5488 | c1 = c1 || shared.EMPTY_ARR;
|
---|
5489 | c2 = c2 || shared.EMPTY_ARR;
|
---|
5490 | const oldLength = c1.length;
|
---|
5491 | const newLength = c2.length;
|
---|
5492 | const commonLength = Math.min(oldLength, newLength);
|
---|
5493 | let i;
|
---|
5494 | for (i = 0; i < commonLength; i++) {
|
---|
5495 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
---|
5496 | patch(
|
---|
5497 | c1[i],
|
---|
5498 | nextChild,
|
---|
5499 | container,
|
---|
5500 | null,
|
---|
5501 | parentComponent,
|
---|
5502 | parentSuspense,
|
---|
5503 | namespace,
|
---|
5504 | slotScopeIds,
|
---|
5505 | optimized
|
---|
5506 | );
|
---|
5507 | }
|
---|
5508 | if (oldLength > newLength) {
|
---|
5509 | unmountChildren(
|
---|
5510 | c1,
|
---|
5511 | parentComponent,
|
---|
5512 | parentSuspense,
|
---|
5513 | true,
|
---|
5514 | false,
|
---|
5515 | commonLength
|
---|
5516 | );
|
---|
5517 | } else {
|
---|
5518 | mountChildren(
|
---|
5519 | c2,
|
---|
5520 | container,
|
---|
5521 | anchor,
|
---|
5522 | parentComponent,
|
---|
5523 | parentSuspense,
|
---|
5524 | namespace,
|
---|
5525 | slotScopeIds,
|
---|
5526 | optimized,
|
---|
5527 | commonLength
|
---|
5528 | );
|
---|
5529 | }
|
---|
5530 | };
|
---|
5531 | const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
|
---|
5532 | let i = 0;
|
---|
5533 | const l2 = c2.length;
|
---|
5534 | let e1 = c1.length - 1;
|
---|
5535 | let e2 = l2 - 1;
|
---|
5536 | while (i <= e1 && i <= e2) {
|
---|
5537 | const n1 = c1[i];
|
---|
5538 | const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
---|
5539 | if (isSameVNodeType(n1, n2)) {
|
---|
5540 | patch(
|
---|
5541 | n1,
|
---|
5542 | n2,
|
---|
5543 | container,
|
---|
5544 | null,
|
---|
5545 | parentComponent,
|
---|
5546 | parentSuspense,
|
---|
5547 | namespace,
|
---|
5548 | slotScopeIds,
|
---|
5549 | optimized
|
---|
5550 | );
|
---|
5551 | } else {
|
---|
5552 | break;
|
---|
5553 | }
|
---|
5554 | i++;
|
---|
5555 | }
|
---|
5556 | while (i <= e1 && i <= e2) {
|
---|
5557 | const n1 = c1[e1];
|
---|
5558 | const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
|
---|
5559 | if (isSameVNodeType(n1, n2)) {
|
---|
5560 | patch(
|
---|
5561 | n1,
|
---|
5562 | n2,
|
---|
5563 | container,
|
---|
5564 | null,
|
---|
5565 | parentComponent,
|
---|
5566 | parentSuspense,
|
---|
5567 | namespace,
|
---|
5568 | slotScopeIds,
|
---|
5569 | optimized
|
---|
5570 | );
|
---|
5571 | } else {
|
---|
5572 | break;
|
---|
5573 | }
|
---|
5574 | e1--;
|
---|
5575 | e2--;
|
---|
5576 | }
|
---|
5577 | if (i > e1) {
|
---|
5578 | if (i <= e2) {
|
---|
5579 | const nextPos = e2 + 1;
|
---|
5580 | const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
---|
5581 | while (i <= e2) {
|
---|
5582 | patch(
|
---|
5583 | null,
|
---|
5584 | c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
|
---|
5585 | container,
|
---|
5586 | anchor,
|
---|
5587 | parentComponent,
|
---|
5588 | parentSuspense,
|
---|
5589 | namespace,
|
---|
5590 | slotScopeIds,
|
---|
5591 | optimized
|
---|
5592 | );
|
---|
5593 | i++;
|
---|
5594 | }
|
---|
5595 | }
|
---|
5596 | } else if (i > e2) {
|
---|
5597 | while (i <= e1) {
|
---|
5598 | unmount(c1[i], parentComponent, parentSuspense, true);
|
---|
5599 | i++;
|
---|
5600 | }
|
---|
5601 | } else {
|
---|
5602 | const s1 = i;
|
---|
5603 | const s2 = i;
|
---|
5604 | const keyToNewIndexMap = /* @__PURE__ */ new Map();
|
---|
5605 | for (i = s2; i <= e2; i++) {
|
---|
5606 | const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
---|
5607 | if (nextChild.key != null) {
|
---|
5608 | if (keyToNewIndexMap.has(nextChild.key)) {
|
---|
5609 | warn$1(
|
---|
5610 | `Duplicate keys found during update:`,
|
---|
5611 | JSON.stringify(nextChild.key),
|
---|
5612 | `Make sure keys are unique.`
|
---|
5613 | );
|
---|
5614 | }
|
---|
5615 | keyToNewIndexMap.set(nextChild.key, i);
|
---|
5616 | }
|
---|
5617 | }
|
---|
5618 | let j;
|
---|
5619 | let patched = 0;
|
---|
5620 | const toBePatched = e2 - s2 + 1;
|
---|
5621 | let moved = false;
|
---|
5622 | let maxNewIndexSoFar = 0;
|
---|
5623 | const newIndexToOldIndexMap = new Array(toBePatched);
|
---|
5624 | for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
|
---|
5625 | for (i = s1; i <= e1; i++) {
|
---|
5626 | const prevChild = c1[i];
|
---|
5627 | if (patched >= toBePatched) {
|
---|
5628 | unmount(prevChild, parentComponent, parentSuspense, true);
|
---|
5629 | continue;
|
---|
5630 | }
|
---|
5631 | let newIndex;
|
---|
5632 | if (prevChild.key != null) {
|
---|
5633 | newIndex = keyToNewIndexMap.get(prevChild.key);
|
---|
5634 | } else {
|
---|
5635 | for (j = s2; j <= e2; j++) {
|
---|
5636 | if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
|
---|
5637 | newIndex = j;
|
---|
5638 | break;
|
---|
5639 | }
|
---|
5640 | }
|
---|
5641 | }
|
---|
5642 | if (newIndex === void 0) {
|
---|
5643 | unmount(prevChild, parentComponent, parentSuspense, true);
|
---|
5644 | } else {
|
---|
5645 | newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
---|
5646 | if (newIndex >= maxNewIndexSoFar) {
|
---|
5647 | maxNewIndexSoFar = newIndex;
|
---|
5648 | } else {
|
---|
5649 | moved = true;
|
---|
5650 | }
|
---|
5651 | patch(
|
---|
5652 | prevChild,
|
---|
5653 | c2[newIndex],
|
---|
5654 | container,
|
---|
5655 | null,
|
---|
5656 | parentComponent,
|
---|
5657 | parentSuspense,
|
---|
5658 | namespace,
|
---|
5659 | slotScopeIds,
|
---|
5660 | optimized
|
---|
5661 | );
|
---|
5662 | patched++;
|
---|
5663 | }
|
---|
5664 | }
|
---|
5665 | const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : shared.EMPTY_ARR;
|
---|
5666 | j = increasingNewIndexSequence.length - 1;
|
---|
5667 | for (i = toBePatched - 1; i >= 0; i--) {
|
---|
5668 | const nextIndex = s2 + i;
|
---|
5669 | const nextChild = c2[nextIndex];
|
---|
5670 | const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
---|
5671 | if (newIndexToOldIndexMap[i] === 0) {
|
---|
5672 | patch(
|
---|
5673 | null,
|
---|
5674 | nextChild,
|
---|
5675 | container,
|
---|
5676 | anchor,
|
---|
5677 | parentComponent,
|
---|
5678 | parentSuspense,
|
---|
5679 | namespace,
|
---|
5680 | slotScopeIds,
|
---|
5681 | optimized
|
---|
5682 | );
|
---|
5683 | } else if (moved) {
|
---|
5684 | if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
---|
5685 | move(nextChild, container, anchor, 2);
|
---|
5686 | } else {
|
---|
5687 | j--;
|
---|
5688 | }
|
---|
5689 | }
|
---|
5690 | }
|
---|
5691 | }
|
---|
5692 | };
|
---|
5693 | const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
---|
5694 | const { el, type, transition, children, shapeFlag } = vnode;
|
---|
5695 | if (shapeFlag & 6) {
|
---|
5696 | move(vnode.component.subTree, container, anchor, moveType);
|
---|
5697 | return;
|
---|
5698 | }
|
---|
5699 | if (shapeFlag & 128) {
|
---|
5700 | vnode.suspense.move(container, anchor, moveType);
|
---|
5701 | return;
|
---|
5702 | }
|
---|
5703 | if (shapeFlag & 64) {
|
---|
5704 | type.move(vnode, container, anchor, internals);
|
---|
5705 | return;
|
---|
5706 | }
|
---|
5707 | if (type === Fragment) {
|
---|
5708 | hostInsert(el, container, anchor);
|
---|
5709 | for (let i = 0; i < children.length; i++) {
|
---|
5710 | move(children[i], container, anchor, moveType);
|
---|
5711 | }
|
---|
5712 | hostInsert(vnode.anchor, container, anchor);
|
---|
5713 | return;
|
---|
5714 | }
|
---|
5715 | if (type === Static) {
|
---|
5716 | moveStaticNode(vnode, container, anchor);
|
---|
5717 | return;
|
---|
5718 | }
|
---|
5719 | const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
|
---|
5720 | if (needTransition2) {
|
---|
5721 | if (moveType === 0) {
|
---|
5722 | transition.beforeEnter(el);
|
---|
5723 | hostInsert(el, container, anchor);
|
---|
5724 | queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
---|
5725 | } else {
|
---|
5726 | const { leave, delayLeave, afterLeave } = transition;
|
---|
5727 | const remove2 = () => hostInsert(el, container, anchor);
|
---|
5728 | const performLeave = () => {
|
---|
5729 | leave(el, () => {
|
---|
5730 | remove2();
|
---|
5731 | afterLeave && afterLeave();
|
---|
5732 | });
|
---|
5733 | };
|
---|
5734 | if (delayLeave) {
|
---|
5735 | delayLeave(el, remove2, performLeave);
|
---|
5736 | } else {
|
---|
5737 | performLeave();
|
---|
5738 | }
|
---|
5739 | }
|
---|
5740 | } else {
|
---|
5741 | hostInsert(el, container, anchor);
|
---|
5742 | }
|
---|
5743 | };
|
---|
5744 | const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
---|
5745 | const {
|
---|
5746 | type,
|
---|
5747 | props,
|
---|
5748 | ref,
|
---|
5749 | children,
|
---|
5750 | dynamicChildren,
|
---|
5751 | shapeFlag,
|
---|
5752 | patchFlag,
|
---|
5753 | dirs,
|
---|
5754 | cacheIndex
|
---|
5755 | } = vnode;
|
---|
5756 | if (patchFlag === -2) {
|
---|
5757 | optimized = false;
|
---|
5758 | }
|
---|
5759 | if (ref != null) {
|
---|
5760 | setRef(ref, null, parentSuspense, vnode, true);
|
---|
5761 | }
|
---|
5762 | if (cacheIndex != null) {
|
---|
5763 | parentComponent.renderCache[cacheIndex] = void 0;
|
---|
5764 | }
|
---|
5765 | if (shapeFlag & 256) {
|
---|
5766 | parentComponent.ctx.deactivate(vnode);
|
---|
5767 | return;
|
---|
5768 | }
|
---|
5769 | const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
---|
5770 | const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
---|
5771 | let vnodeHook;
|
---|
5772 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
---|
5773 | invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
5774 | }
|
---|
5775 | if (shapeFlag & 6) {
|
---|
5776 | unmountComponent(vnode.component, parentSuspense, doRemove);
|
---|
5777 | } else {
|
---|
5778 | if (shapeFlag & 128) {
|
---|
5779 | vnode.suspense.unmount(parentSuspense, doRemove);
|
---|
5780 | return;
|
---|
5781 | }
|
---|
5782 | if (shouldInvokeDirs) {
|
---|
5783 | invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
|
---|
5784 | }
|
---|
5785 | if (shapeFlag & 64) {
|
---|
5786 | vnode.type.remove(
|
---|
5787 | vnode,
|
---|
5788 | parentComponent,
|
---|
5789 | parentSuspense,
|
---|
5790 | internals,
|
---|
5791 | doRemove
|
---|
5792 | );
|
---|
5793 | } else if (dynamicChildren && // #5154
|
---|
5794 | // when v-once is used inside a block, setBlockTracking(-1) marks the
|
---|
5795 | // parent block with hasOnce: true
|
---|
5796 | // so that it doesn't take the fast path during unmount - otherwise
|
---|
5797 | // components nested in v-once are never unmounted.
|
---|
5798 | !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
|
---|
5799 | (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
|
---|
5800 | unmountChildren(
|
---|
5801 | dynamicChildren,
|
---|
5802 | parentComponent,
|
---|
5803 | parentSuspense,
|
---|
5804 | false,
|
---|
5805 | true
|
---|
5806 | );
|
---|
5807 | } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
|
---|
5808 | unmountChildren(children, parentComponent, parentSuspense);
|
---|
5809 | }
|
---|
5810 | if (doRemove) {
|
---|
5811 | remove(vnode);
|
---|
5812 | }
|
---|
5813 | }
|
---|
5814 | if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
|
---|
5815 | queuePostRenderEffect(() => {
|
---|
5816 | vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
---|
5817 | shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
|
---|
5818 | }, parentSuspense);
|
---|
5819 | }
|
---|
5820 | };
|
---|
5821 | const remove = (vnode) => {
|
---|
5822 | const { type, el, anchor, transition } = vnode;
|
---|
5823 | if (type === Fragment) {
|
---|
5824 | if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
|
---|
5825 | vnode.children.forEach((child) => {
|
---|
5826 | if (child.type === Comment) {
|
---|
5827 | hostRemove(child.el);
|
---|
5828 | } else {
|
---|
5829 | remove(child);
|
---|
5830 | }
|
---|
5831 | });
|
---|
5832 | } else {
|
---|
5833 | removeFragment(el, anchor);
|
---|
5834 | }
|
---|
5835 | return;
|
---|
5836 | }
|
---|
5837 | if (type === Static) {
|
---|
5838 | removeStaticNode(vnode);
|
---|
5839 | return;
|
---|
5840 | }
|
---|
5841 | const performRemove = () => {
|
---|
5842 | hostRemove(el);
|
---|
5843 | if (transition && !transition.persisted && transition.afterLeave) {
|
---|
5844 | transition.afterLeave();
|
---|
5845 | }
|
---|
5846 | };
|
---|
5847 | if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
|
---|
5848 | const { leave, delayLeave } = transition;
|
---|
5849 | const performLeave = () => leave(el, performRemove);
|
---|
5850 | if (delayLeave) {
|
---|
5851 | delayLeave(vnode.el, performRemove, performLeave);
|
---|
5852 | } else {
|
---|
5853 | performLeave();
|
---|
5854 | }
|
---|
5855 | } else {
|
---|
5856 | performRemove();
|
---|
5857 | }
|
---|
5858 | };
|
---|
5859 | const removeFragment = (cur, end) => {
|
---|
5860 | let next;
|
---|
5861 | while (cur !== end) {
|
---|
5862 | next = hostNextSibling(cur);
|
---|
5863 | hostRemove(cur);
|
---|
5864 | cur = next;
|
---|
5865 | }
|
---|
5866 | hostRemove(end);
|
---|
5867 | };
|
---|
5868 | const unmountComponent = (instance, parentSuspense, doRemove) => {
|
---|
5869 | if (instance.type.__hmrId) {
|
---|
5870 | unregisterHMR(instance);
|
---|
5871 | }
|
---|
5872 | const { bum, scope, job, subTree, um, m, a } = instance;
|
---|
5873 | invalidateMount(m);
|
---|
5874 | invalidateMount(a);
|
---|
5875 | if (bum) {
|
---|
5876 | shared.invokeArrayFns(bum);
|
---|
5877 | }
|
---|
5878 | scope.stop();
|
---|
5879 | if (job) {
|
---|
5880 | job.flags |= 8;
|
---|
5881 | unmount(subTree, instance, parentSuspense, doRemove);
|
---|
5882 | }
|
---|
5883 | if (um) {
|
---|
5884 | queuePostRenderEffect(um, parentSuspense);
|
---|
5885 | }
|
---|
5886 | queuePostRenderEffect(() => {
|
---|
5887 | instance.isUnmounted = true;
|
---|
5888 | }, parentSuspense);
|
---|
5889 | if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
|
---|
5890 | parentSuspense.deps--;
|
---|
5891 | if (parentSuspense.deps === 0) {
|
---|
5892 | parentSuspense.resolve();
|
---|
5893 | }
|
---|
5894 | }
|
---|
5895 | {
|
---|
5896 | devtoolsComponentRemoved(instance);
|
---|
5897 | }
|
---|
5898 | };
|
---|
5899 | const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
---|
5900 | for (let i = start; i < children.length; i++) {
|
---|
5901 | unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
---|
5902 | }
|
---|
5903 | };
|
---|
5904 | const getNextHostNode = (vnode) => {
|
---|
5905 | if (vnode.shapeFlag & 6) {
|
---|
5906 | return getNextHostNode(vnode.component.subTree);
|
---|
5907 | }
|
---|
5908 | if (vnode.shapeFlag & 128) {
|
---|
5909 | return vnode.suspense.next();
|
---|
5910 | }
|
---|
5911 | const el = hostNextSibling(vnode.anchor || vnode.el);
|
---|
5912 | const teleportEnd = el && el[TeleportEndKey];
|
---|
5913 | return teleportEnd ? hostNextSibling(teleportEnd) : el;
|
---|
5914 | };
|
---|
5915 | let isFlushing = false;
|
---|
5916 | const render = (vnode, container, namespace) => {
|
---|
5917 | if (vnode == null) {
|
---|
5918 | if (container._vnode) {
|
---|
5919 | unmount(container._vnode, null, null, true);
|
---|
5920 | }
|
---|
5921 | } else {
|
---|
5922 | patch(
|
---|
5923 | container._vnode || null,
|
---|
5924 | vnode,
|
---|
5925 | container,
|
---|
5926 | null,
|
---|
5927 | null,
|
---|
5928 | null,
|
---|
5929 | namespace
|
---|
5930 | );
|
---|
5931 | }
|
---|
5932 | container._vnode = vnode;
|
---|
5933 | if (!isFlushing) {
|
---|
5934 | isFlushing = true;
|
---|
5935 | flushPreFlushCbs();
|
---|
5936 | flushPostFlushCbs();
|
---|
5937 | isFlushing = false;
|
---|
5938 | }
|
---|
5939 | };
|
---|
5940 | const internals = {
|
---|
5941 | p: patch,
|
---|
5942 | um: unmount,
|
---|
5943 | m: move,
|
---|
5944 | r: remove,
|
---|
5945 | mt: mountComponent,
|
---|
5946 | mc: mountChildren,
|
---|
5947 | pc: patchChildren,
|
---|
5948 | pbc: patchBlockChildren,
|
---|
5949 | n: getNextHostNode,
|
---|
5950 | o: options
|
---|
5951 | };
|
---|
5952 | let hydrate;
|
---|
5953 | let hydrateNode;
|
---|
5954 | if (createHydrationFns) {
|
---|
5955 | [hydrate, hydrateNode] = createHydrationFns(
|
---|
5956 | internals
|
---|
5957 | );
|
---|
5958 | }
|
---|
5959 | return {
|
---|
5960 | render,
|
---|
5961 | hydrate,
|
---|
5962 | createApp: createAppAPI(render, hydrate)
|
---|
5963 | };
|
---|
5964 | }
|
---|
5965 | function resolveChildrenNamespace({ type, props }, currentNamespace) {
|
---|
5966 | return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
|
---|
5967 | }
|
---|
5968 | function toggleRecurse({ effect, job }, allowed) {
|
---|
5969 | if (allowed) {
|
---|
5970 | effect.flags |= 32;
|
---|
5971 | job.flags |= 4;
|
---|
5972 | } else {
|
---|
5973 | effect.flags &= ~32;
|
---|
5974 | job.flags &= ~4;
|
---|
5975 | }
|
---|
5976 | }
|
---|
5977 | function needTransition(parentSuspense, transition) {
|
---|
5978 | return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
|
---|
5979 | }
|
---|
5980 | function traverseStaticChildren(n1, n2, shallow = false) {
|
---|
5981 | const ch1 = n1.children;
|
---|
5982 | const ch2 = n2.children;
|
---|
5983 | if (shared.isArray(ch1) && shared.isArray(ch2)) {
|
---|
5984 | for (let i = 0; i < ch1.length; i++) {
|
---|
5985 | const c1 = ch1[i];
|
---|
5986 | let c2 = ch2[i];
|
---|
5987 | if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
---|
5988 | if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
|
---|
5989 | c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
---|
5990 | c2.el = c1.el;
|
---|
5991 | }
|
---|
5992 | if (!shallow && c2.patchFlag !== -2)
|
---|
5993 | traverseStaticChildren(c1, c2);
|
---|
5994 | }
|
---|
5995 | if (c2.type === Text) {
|
---|
5996 | c2.el = c1.el;
|
---|
5997 | }
|
---|
5998 | if (c2.type === Comment && !c2.el) {
|
---|
5999 | c2.el = c1.el;
|
---|
6000 | }
|
---|
6001 | }
|
---|
6002 | }
|
---|
6003 | }
|
---|
6004 | function getSequence(arr) {
|
---|
6005 | const p = arr.slice();
|
---|
6006 | const result = [0];
|
---|
6007 | let i, j, u, v, c;
|
---|
6008 | const len = arr.length;
|
---|
6009 | for (i = 0; i < len; i++) {
|
---|
6010 | const arrI = arr[i];
|
---|
6011 | if (arrI !== 0) {
|
---|
6012 | j = result[result.length - 1];
|
---|
6013 | if (arr[j] < arrI) {
|
---|
6014 | p[i] = j;
|
---|
6015 | result.push(i);
|
---|
6016 | continue;
|
---|
6017 | }
|
---|
6018 | u = 0;
|
---|
6019 | v = result.length - 1;
|
---|
6020 | while (u < v) {
|
---|
6021 | c = u + v >> 1;
|
---|
6022 | if (arr[result[c]] < arrI) {
|
---|
6023 | u = c + 1;
|
---|
6024 | } else {
|
---|
6025 | v = c;
|
---|
6026 | }
|
---|
6027 | }
|
---|
6028 | if (arrI < arr[result[u]]) {
|
---|
6029 | if (u > 0) {
|
---|
6030 | p[i] = result[u - 1];
|
---|
6031 | }
|
---|
6032 | result[u] = i;
|
---|
6033 | }
|
---|
6034 | }
|
---|
6035 | }
|
---|
6036 | u = result.length;
|
---|
6037 | v = result[u - 1];
|
---|
6038 | while (u-- > 0) {
|
---|
6039 | result[u] = v;
|
---|
6040 | v = p[v];
|
---|
6041 | }
|
---|
6042 | return result;
|
---|
6043 | }
|
---|
6044 | function locateNonHydratedAsyncRoot(instance) {
|
---|
6045 | const subComponent = instance.subTree.component;
|
---|
6046 | if (subComponent) {
|
---|
6047 | if (subComponent.asyncDep && !subComponent.asyncResolved) {
|
---|
6048 | return subComponent;
|
---|
6049 | } else {
|
---|
6050 | return locateNonHydratedAsyncRoot(subComponent);
|
---|
6051 | }
|
---|
6052 | }
|
---|
6053 | }
|
---|
6054 | function invalidateMount(hooks) {
|
---|
6055 | if (hooks) {
|
---|
6056 | for (let i = 0; i < hooks.length; i++)
|
---|
6057 | hooks[i].flags |= 8;
|
---|
6058 | }
|
---|
6059 | }
|
---|
6060 |
|
---|
6061 | const ssrContextKey = Symbol.for("v-scx");
|
---|
6062 | const useSSRContext = () => {
|
---|
6063 | {
|
---|
6064 | const ctx = inject(ssrContextKey);
|
---|
6065 | if (!ctx) {
|
---|
6066 | warn$1(
|
---|
6067 | `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
|
---|
6068 | );
|
---|
6069 | }
|
---|
6070 | return ctx;
|
---|
6071 | }
|
---|
6072 | };
|
---|
6073 |
|
---|
6074 | function watchEffect(effect, options) {
|
---|
6075 | return doWatch(effect, null, options);
|
---|
6076 | }
|
---|
6077 | function watchPostEffect(effect, options) {
|
---|
6078 | return doWatch(
|
---|
6079 | effect,
|
---|
6080 | null,
|
---|
6081 | shared.extend({}, options, { flush: "post" })
|
---|
6082 | );
|
---|
6083 | }
|
---|
6084 | function watchSyncEffect(effect, options) {
|
---|
6085 | return doWatch(
|
---|
6086 | effect,
|
---|
6087 | null,
|
---|
6088 | shared.extend({}, options, { flush: "sync" })
|
---|
6089 | );
|
---|
6090 | }
|
---|
6091 | function watch(source, cb, options) {
|
---|
6092 | if (!shared.isFunction(cb)) {
|
---|
6093 | warn$1(
|
---|
6094 | `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
|
---|
6095 | );
|
---|
6096 | }
|
---|
6097 | return doWatch(source, cb, options);
|
---|
6098 | }
|
---|
6099 | function doWatch(source, cb, options = shared.EMPTY_OBJ) {
|
---|
6100 | const { immediate, deep, flush, once } = options;
|
---|
6101 | if (!cb) {
|
---|
6102 | if (immediate !== void 0) {
|
---|
6103 | warn$1(
|
---|
6104 | `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
|
---|
6105 | );
|
---|
6106 | }
|
---|
6107 | if (deep !== void 0) {
|
---|
6108 | warn$1(
|
---|
6109 | `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
|
---|
6110 | );
|
---|
6111 | }
|
---|
6112 | if (once !== void 0) {
|
---|
6113 | warn$1(
|
---|
6114 | `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
|
---|
6115 | );
|
---|
6116 | }
|
---|
6117 | }
|
---|
6118 | const baseWatchOptions = shared.extend({}, options);
|
---|
6119 | baseWatchOptions.onWarn = warn$1;
|
---|
6120 | const runsImmediately = cb && immediate || !cb && flush !== "post";
|
---|
6121 | let ssrCleanup;
|
---|
6122 | if (isInSSRComponentSetup) {
|
---|
6123 | if (flush === "sync") {
|
---|
6124 | const ctx = useSSRContext();
|
---|
6125 | ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
|
---|
6126 | } else if (!runsImmediately) {
|
---|
6127 | const watchStopHandle = () => {
|
---|
6128 | };
|
---|
6129 | watchStopHandle.stop = shared.NOOP;
|
---|
6130 | watchStopHandle.resume = shared.NOOP;
|
---|
6131 | watchStopHandle.pause = shared.NOOP;
|
---|
6132 | return watchStopHandle;
|
---|
6133 | }
|
---|
6134 | }
|
---|
6135 | const instance = currentInstance;
|
---|
6136 | baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
|
---|
6137 | let isPre = false;
|
---|
6138 | if (flush === "post") {
|
---|
6139 | baseWatchOptions.scheduler = (job) => {
|
---|
6140 | queuePostRenderEffect(job, instance && instance.suspense);
|
---|
6141 | };
|
---|
6142 | } else if (flush !== "sync") {
|
---|
6143 | isPre = true;
|
---|
6144 | baseWatchOptions.scheduler = (job, isFirstRun) => {
|
---|
6145 | if (isFirstRun) {
|
---|
6146 | job();
|
---|
6147 | } else {
|
---|
6148 | queueJob(job);
|
---|
6149 | }
|
---|
6150 | };
|
---|
6151 | }
|
---|
6152 | baseWatchOptions.augmentJob = (job) => {
|
---|
6153 | if (cb) {
|
---|
6154 | job.flags |= 4;
|
---|
6155 | }
|
---|
6156 | if (isPre) {
|
---|
6157 | job.flags |= 2;
|
---|
6158 | if (instance) {
|
---|
6159 | job.id = instance.uid;
|
---|
6160 | job.i = instance;
|
---|
6161 | }
|
---|
6162 | }
|
---|
6163 | };
|
---|
6164 | const watchHandle = reactivity.watch(source, cb, baseWatchOptions);
|
---|
6165 | if (isInSSRComponentSetup) {
|
---|
6166 | if (ssrCleanup) {
|
---|
6167 | ssrCleanup.push(watchHandle);
|
---|
6168 | } else if (runsImmediately) {
|
---|
6169 | watchHandle();
|
---|
6170 | }
|
---|
6171 | }
|
---|
6172 | return watchHandle;
|
---|
6173 | }
|
---|
6174 | function instanceWatch(source, value, options) {
|
---|
6175 | const publicThis = this.proxy;
|
---|
6176 | const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
---|
6177 | let cb;
|
---|
6178 | if (shared.isFunction(value)) {
|
---|
6179 | cb = value;
|
---|
6180 | } else {
|
---|
6181 | cb = value.handler;
|
---|
6182 | options = value;
|
---|
6183 | }
|
---|
6184 | const reset = setCurrentInstance(this);
|
---|
6185 | const res = doWatch(getter, cb.bind(publicThis), options);
|
---|
6186 | reset();
|
---|
6187 | return res;
|
---|
6188 | }
|
---|
6189 | function createPathGetter(ctx, path) {
|
---|
6190 | const segments = path.split(".");
|
---|
6191 | return () => {
|
---|
6192 | let cur = ctx;
|
---|
6193 | for (let i = 0; i < segments.length && cur; i++) {
|
---|
6194 | cur = cur[segments[i]];
|
---|
6195 | }
|
---|
6196 | return cur;
|
---|
6197 | };
|
---|
6198 | }
|
---|
6199 |
|
---|
6200 | function useModel(props, name, options = shared.EMPTY_OBJ) {
|
---|
6201 | const i = getCurrentInstance();
|
---|
6202 | if (!i) {
|
---|
6203 | warn$1(`useModel() called without active instance.`);
|
---|
6204 | return reactivity.ref();
|
---|
6205 | }
|
---|
6206 | const camelizedName = shared.camelize(name);
|
---|
6207 | if (!i.propsOptions[0][camelizedName]) {
|
---|
6208 | warn$1(`useModel() called with prop "${name}" which is not declared.`);
|
---|
6209 | return reactivity.ref();
|
---|
6210 | }
|
---|
6211 | const hyphenatedName = shared.hyphenate(name);
|
---|
6212 | const modifiers = getModelModifiers(props, camelizedName);
|
---|
6213 | const res = reactivity.customRef((track, trigger) => {
|
---|
6214 | let localValue;
|
---|
6215 | let prevSetValue = shared.EMPTY_OBJ;
|
---|
6216 | let prevEmittedValue;
|
---|
6217 | watchSyncEffect(() => {
|
---|
6218 | const propValue = props[camelizedName];
|
---|
6219 | if (shared.hasChanged(localValue, propValue)) {
|
---|
6220 | localValue = propValue;
|
---|
6221 | trigger();
|
---|
6222 | }
|
---|
6223 | });
|
---|
6224 | return {
|
---|
6225 | get() {
|
---|
6226 | track();
|
---|
6227 | return options.get ? options.get(localValue) : localValue;
|
---|
6228 | },
|
---|
6229 | set(value) {
|
---|
6230 | const emittedValue = options.set ? options.set(value) : value;
|
---|
6231 | if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
|
---|
6232 | return;
|
---|
6233 | }
|
---|
6234 | const rawProps = i.vnode.props;
|
---|
6235 | if (!(rawProps && // check if parent has passed v-model
|
---|
6236 | (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
|
---|
6237 | localValue = value;
|
---|
6238 | trigger();
|
---|
6239 | }
|
---|
6240 | i.emit(`update:${name}`, emittedValue);
|
---|
6241 | if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
|
---|
6242 | trigger();
|
---|
6243 | }
|
---|
6244 | prevSetValue = value;
|
---|
6245 | prevEmittedValue = emittedValue;
|
---|
6246 | }
|
---|
6247 | };
|
---|
6248 | });
|
---|
6249 | res[Symbol.iterator] = () => {
|
---|
6250 | let i2 = 0;
|
---|
6251 | return {
|
---|
6252 | next() {
|
---|
6253 | if (i2 < 2) {
|
---|
6254 | return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
|
---|
6255 | } else {
|
---|
6256 | return { done: true };
|
---|
6257 | }
|
---|
6258 | }
|
---|
6259 | };
|
---|
6260 | };
|
---|
6261 | return res;
|
---|
6262 | }
|
---|
6263 | const getModelModifiers = (props, modelName) => {
|
---|
6264 | return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${shared.camelize(modelName)}Modifiers`] || props[`${shared.hyphenate(modelName)}Modifiers`];
|
---|
6265 | };
|
---|
6266 |
|
---|
6267 | function emit(instance, event, ...rawArgs) {
|
---|
6268 | if (instance.isUnmounted) return;
|
---|
6269 | const props = instance.vnode.props || shared.EMPTY_OBJ;
|
---|
6270 | {
|
---|
6271 | const {
|
---|
6272 | emitsOptions,
|
---|
6273 | propsOptions: [propsOptions]
|
---|
6274 | } = instance;
|
---|
6275 | if (emitsOptions) {
|
---|
6276 | if (!(event in emitsOptions) && true) {
|
---|
6277 | if (!propsOptions || !(shared.toHandlerKey(shared.camelize(event)) in propsOptions)) {
|
---|
6278 | warn$1(
|
---|
6279 | `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${shared.toHandlerKey(shared.camelize(event))}" prop.`
|
---|
6280 | );
|
---|
6281 | }
|
---|
6282 | } else {
|
---|
6283 | const validator = emitsOptions[event];
|
---|
6284 | if (shared.isFunction(validator)) {
|
---|
6285 | const isValid = validator(...rawArgs);
|
---|
6286 | if (!isValid) {
|
---|
6287 | warn$1(
|
---|
6288 | `Invalid event arguments: event validation failed for event "${event}".`
|
---|
6289 | );
|
---|
6290 | }
|
---|
6291 | }
|
---|
6292 | }
|
---|
6293 | }
|
---|
6294 | }
|
---|
6295 | let args = rawArgs;
|
---|
6296 | const isModelListener = event.startsWith("update:");
|
---|
6297 | const modifiers = isModelListener && getModelModifiers(props, event.slice(7));
|
---|
6298 | if (modifiers) {
|
---|
6299 | if (modifiers.trim) {
|
---|
6300 | args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
|
---|
6301 | }
|
---|
6302 | if (modifiers.number) {
|
---|
6303 | args = rawArgs.map(shared.looseToNumber);
|
---|
6304 | }
|
---|
6305 | }
|
---|
6306 | {
|
---|
6307 | devtoolsComponentEmit(instance, event, args);
|
---|
6308 | }
|
---|
6309 | {
|
---|
6310 | const lowerCaseEvent = event.toLowerCase();
|
---|
6311 | if (lowerCaseEvent !== event && props[shared.toHandlerKey(lowerCaseEvent)]) {
|
---|
6312 | warn$1(
|
---|
6313 | `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
|
---|
6314 | instance,
|
---|
6315 | instance.type
|
---|
6316 | )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${shared.hyphenate(
|
---|
6317 | event
|
---|
6318 | )}" instead of "${event}".`
|
---|
6319 | );
|
---|
6320 | }
|
---|
6321 | }
|
---|
6322 | let handlerName;
|
---|
6323 | let handler = props[handlerName = shared.toHandlerKey(event)] || // also try camelCase event handler (#2249)
|
---|
6324 | props[handlerName = shared.toHandlerKey(shared.camelize(event))];
|
---|
6325 | if (!handler && isModelListener) {
|
---|
6326 | handler = props[handlerName = shared.toHandlerKey(shared.hyphenate(event))];
|
---|
6327 | }
|
---|
6328 | if (handler) {
|
---|
6329 | callWithAsyncErrorHandling(
|
---|
6330 | handler,
|
---|
6331 | instance,
|
---|
6332 | 6,
|
---|
6333 | args
|
---|
6334 | );
|
---|
6335 | }
|
---|
6336 | const onceHandler = props[handlerName + `Once`];
|
---|
6337 | if (onceHandler) {
|
---|
6338 | if (!instance.emitted) {
|
---|
6339 | instance.emitted = {};
|
---|
6340 | } else if (instance.emitted[handlerName]) {
|
---|
6341 | return;
|
---|
6342 | }
|
---|
6343 | instance.emitted[handlerName] = true;
|
---|
6344 | callWithAsyncErrorHandling(
|
---|
6345 | onceHandler,
|
---|
6346 | instance,
|
---|
6347 | 6,
|
---|
6348 | args
|
---|
6349 | );
|
---|
6350 | }
|
---|
6351 | }
|
---|
6352 | function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
---|
6353 | const cache = appContext.emitsCache;
|
---|
6354 | const cached = cache.get(comp);
|
---|
6355 | if (cached !== void 0) {
|
---|
6356 | return cached;
|
---|
6357 | }
|
---|
6358 | const raw = comp.emits;
|
---|
6359 | let normalized = {};
|
---|
6360 | let hasExtends = false;
|
---|
6361 | if (!shared.isFunction(comp)) {
|
---|
6362 | const extendEmits = (raw2) => {
|
---|
6363 | const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
|
---|
6364 | if (normalizedFromExtend) {
|
---|
6365 | hasExtends = true;
|
---|
6366 | shared.extend(normalized, normalizedFromExtend);
|
---|
6367 | }
|
---|
6368 | };
|
---|
6369 | if (!asMixin && appContext.mixins.length) {
|
---|
6370 | appContext.mixins.forEach(extendEmits);
|
---|
6371 | }
|
---|
6372 | if (comp.extends) {
|
---|
6373 | extendEmits(comp.extends);
|
---|
6374 | }
|
---|
6375 | if (comp.mixins) {
|
---|
6376 | comp.mixins.forEach(extendEmits);
|
---|
6377 | }
|
---|
6378 | }
|
---|
6379 | if (!raw && !hasExtends) {
|
---|
6380 | if (shared.isObject(comp)) {
|
---|
6381 | cache.set(comp, null);
|
---|
6382 | }
|
---|
6383 | return null;
|
---|
6384 | }
|
---|
6385 | if (shared.isArray(raw)) {
|
---|
6386 | raw.forEach((key) => normalized[key] = null);
|
---|
6387 | } else {
|
---|
6388 | shared.extend(normalized, raw);
|
---|
6389 | }
|
---|
6390 | if (shared.isObject(comp)) {
|
---|
6391 | cache.set(comp, normalized);
|
---|
6392 | }
|
---|
6393 | return normalized;
|
---|
6394 | }
|
---|
6395 | function isEmitListener(options, key) {
|
---|
6396 | if (!options || !shared.isOn(key)) {
|
---|
6397 | return false;
|
---|
6398 | }
|
---|
6399 | key = key.slice(2).replace(/Once$/, "");
|
---|
6400 | return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
|
---|
6401 | }
|
---|
6402 |
|
---|
6403 | let accessedAttrs = false;
|
---|
6404 | function markAttrsAccessed() {
|
---|
6405 | accessedAttrs = true;
|
---|
6406 | }
|
---|
6407 | function renderComponentRoot(instance) {
|
---|
6408 | const {
|
---|
6409 | type: Component,
|
---|
6410 | vnode,
|
---|
6411 | proxy,
|
---|
6412 | withProxy,
|
---|
6413 | propsOptions: [propsOptions],
|
---|
6414 | slots,
|
---|
6415 | attrs,
|
---|
6416 | emit,
|
---|
6417 | render,
|
---|
6418 | renderCache,
|
---|
6419 | props,
|
---|
6420 | data,
|
---|
6421 | setupState,
|
---|
6422 | ctx,
|
---|
6423 | inheritAttrs
|
---|
6424 | } = instance;
|
---|
6425 | const prev = setCurrentRenderingInstance(instance);
|
---|
6426 | let result;
|
---|
6427 | let fallthroughAttrs;
|
---|
6428 | {
|
---|
6429 | accessedAttrs = false;
|
---|
6430 | }
|
---|
6431 | try {
|
---|
6432 | if (vnode.shapeFlag & 4) {
|
---|
6433 | const proxyToUse = withProxy || proxy;
|
---|
6434 | const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
|
---|
6435 | get(target, key, receiver) {
|
---|
6436 | warn$1(
|
---|
6437 | `Property '${String(
|
---|
6438 | key
|
---|
6439 | )}' was accessed via 'this'. Avoid using 'this' in templates.`
|
---|
6440 | );
|
---|
6441 | return Reflect.get(target, key, receiver);
|
---|
6442 | }
|
---|
6443 | }) : proxyToUse;
|
---|
6444 | result = normalizeVNode(
|
---|
6445 | render.call(
|
---|
6446 | thisProxy,
|
---|
6447 | proxyToUse,
|
---|
6448 | renderCache,
|
---|
6449 | true ? reactivity.shallowReadonly(props) : props,
|
---|
6450 | setupState,
|
---|
6451 | data,
|
---|
6452 | ctx
|
---|
6453 | )
|
---|
6454 | );
|
---|
6455 | fallthroughAttrs = attrs;
|
---|
6456 | } else {
|
---|
6457 | const render2 = Component;
|
---|
6458 | if (attrs === props) {
|
---|
6459 | markAttrsAccessed();
|
---|
6460 | }
|
---|
6461 | result = normalizeVNode(
|
---|
6462 | render2.length > 1 ? render2(
|
---|
6463 | true ? reactivity.shallowReadonly(props) : props,
|
---|
6464 | true ? {
|
---|
6465 | get attrs() {
|
---|
6466 | markAttrsAccessed();
|
---|
6467 | return reactivity.shallowReadonly(attrs);
|
---|
6468 | },
|
---|
6469 | slots,
|
---|
6470 | emit
|
---|
6471 | } : { attrs, slots, emit }
|
---|
6472 | ) : render2(
|
---|
6473 | true ? reactivity.shallowReadonly(props) : props,
|
---|
6474 | null
|
---|
6475 | )
|
---|
6476 | );
|
---|
6477 | fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
|
---|
6478 | }
|
---|
6479 | } catch (err) {
|
---|
6480 | blockStack.length = 0;
|
---|
6481 | handleError(err, instance, 1);
|
---|
6482 | result = createVNode(Comment);
|
---|
6483 | }
|
---|
6484 | let root = result;
|
---|
6485 | let setRoot = void 0;
|
---|
6486 | if (result.patchFlag > 0 && result.patchFlag & 2048) {
|
---|
6487 | [root, setRoot] = getChildRoot(result);
|
---|
6488 | }
|
---|
6489 | if (fallthroughAttrs && inheritAttrs !== false) {
|
---|
6490 | const keys = Object.keys(fallthroughAttrs);
|
---|
6491 | const { shapeFlag } = root;
|
---|
6492 | if (keys.length) {
|
---|
6493 | if (shapeFlag & (1 | 6)) {
|
---|
6494 | if (propsOptions && keys.some(shared.isModelListener)) {
|
---|
6495 | fallthroughAttrs = filterModelListeners(
|
---|
6496 | fallthroughAttrs,
|
---|
6497 | propsOptions
|
---|
6498 | );
|
---|
6499 | }
|
---|
6500 | root = cloneVNode(root, fallthroughAttrs, false, true);
|
---|
6501 | } else if (!accessedAttrs && root.type !== Comment) {
|
---|
6502 | const allAttrs = Object.keys(attrs);
|
---|
6503 | const eventAttrs = [];
|
---|
6504 | const extraAttrs = [];
|
---|
6505 | for (let i = 0, l = allAttrs.length; i < l; i++) {
|
---|
6506 | const key = allAttrs[i];
|
---|
6507 | if (shared.isOn(key)) {
|
---|
6508 | if (!shared.isModelListener(key)) {
|
---|
6509 | eventAttrs.push(key[2].toLowerCase() + key.slice(3));
|
---|
6510 | }
|
---|
6511 | } else {
|
---|
6512 | extraAttrs.push(key);
|
---|
6513 | }
|
---|
6514 | }
|
---|
6515 | if (extraAttrs.length) {
|
---|
6516 | warn$1(
|
---|
6517 | `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text or teleport root nodes.`
|
---|
6518 | );
|
---|
6519 | }
|
---|
6520 | if (eventAttrs.length) {
|
---|
6521 | warn$1(
|
---|
6522 | `Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
|
---|
6523 | );
|
---|
6524 | }
|
---|
6525 | }
|
---|
6526 | }
|
---|
6527 | }
|
---|
6528 | if (vnode.dirs) {
|
---|
6529 | if (!isElementRoot(root)) {
|
---|
6530 | warn$1(
|
---|
6531 | `Runtime directive used on component with non-element root node. The directives will not function as intended.`
|
---|
6532 | );
|
---|
6533 | }
|
---|
6534 | root = cloneVNode(root, null, false, true);
|
---|
6535 | root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
|
---|
6536 | }
|
---|
6537 | if (vnode.transition) {
|
---|
6538 | if (!isElementRoot(root)) {
|
---|
6539 | warn$1(
|
---|
6540 | `Component inside <Transition> renders non-element root node that cannot be animated.`
|
---|
6541 | );
|
---|
6542 | }
|
---|
6543 | setTransitionHooks(root, vnode.transition);
|
---|
6544 | }
|
---|
6545 | if (setRoot) {
|
---|
6546 | setRoot(root);
|
---|
6547 | } else {
|
---|
6548 | result = root;
|
---|
6549 | }
|
---|
6550 | setCurrentRenderingInstance(prev);
|
---|
6551 | return result;
|
---|
6552 | }
|
---|
6553 | const getChildRoot = (vnode) => {
|
---|
6554 | const rawChildren = vnode.children;
|
---|
6555 | const dynamicChildren = vnode.dynamicChildren;
|
---|
6556 | const childRoot = filterSingleRoot(rawChildren, false);
|
---|
6557 | if (!childRoot) {
|
---|
6558 | return [vnode, void 0];
|
---|
6559 | } else if (childRoot.patchFlag > 0 && childRoot.patchFlag & 2048) {
|
---|
6560 | return getChildRoot(childRoot);
|
---|
6561 | }
|
---|
6562 | const index = rawChildren.indexOf(childRoot);
|
---|
6563 | const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
|
---|
6564 | const setRoot = (updatedRoot) => {
|
---|
6565 | rawChildren[index] = updatedRoot;
|
---|
6566 | if (dynamicChildren) {
|
---|
6567 | if (dynamicIndex > -1) {
|
---|
6568 | dynamicChildren[dynamicIndex] = updatedRoot;
|
---|
6569 | } else if (updatedRoot.patchFlag > 0) {
|
---|
6570 | vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
|
---|
6571 | }
|
---|
6572 | }
|
---|
6573 | };
|
---|
6574 | return [normalizeVNode(childRoot), setRoot];
|
---|
6575 | };
|
---|
6576 | function filterSingleRoot(children, recurse = true) {
|
---|
6577 | let singleRoot;
|
---|
6578 | for (let i = 0; i < children.length; i++) {
|
---|
6579 | const child = children[i];
|
---|
6580 | if (isVNode(child)) {
|
---|
6581 | if (child.type !== Comment || child.children === "v-if") {
|
---|
6582 | if (singleRoot) {
|
---|
6583 | return;
|
---|
6584 | } else {
|
---|
6585 | singleRoot = child;
|
---|
6586 | if (recurse && singleRoot.patchFlag > 0 && singleRoot.patchFlag & 2048) {
|
---|
6587 | return filterSingleRoot(singleRoot.children);
|
---|
6588 | }
|
---|
6589 | }
|
---|
6590 | }
|
---|
6591 | } else {
|
---|
6592 | return;
|
---|
6593 | }
|
---|
6594 | }
|
---|
6595 | return singleRoot;
|
---|
6596 | }
|
---|
6597 | const getFunctionalFallthrough = (attrs) => {
|
---|
6598 | let res;
|
---|
6599 | for (const key in attrs) {
|
---|
6600 | if (key === "class" || key === "style" || shared.isOn(key)) {
|
---|
6601 | (res || (res = {}))[key] = attrs[key];
|
---|
6602 | }
|
---|
6603 | }
|
---|
6604 | return res;
|
---|
6605 | };
|
---|
6606 | const filterModelListeners = (attrs, props) => {
|
---|
6607 | const res = {};
|
---|
6608 | for (const key in attrs) {
|
---|
6609 | if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
|
---|
6610 | res[key] = attrs[key];
|
---|
6611 | }
|
---|
6612 | }
|
---|
6613 | return res;
|
---|
6614 | };
|
---|
6615 | const isElementRoot = (vnode) => {
|
---|
6616 | return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
|
---|
6617 | };
|
---|
6618 | function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
---|
6619 | const { props: prevProps, children: prevChildren, component } = prevVNode;
|
---|
6620 | const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
---|
6621 | const emits = component.emitsOptions;
|
---|
6622 | if ((prevChildren || nextChildren) && isHmrUpdating) {
|
---|
6623 | return true;
|
---|
6624 | }
|
---|
6625 | if (nextVNode.dirs || nextVNode.transition) {
|
---|
6626 | return true;
|
---|
6627 | }
|
---|
6628 | if (optimized && patchFlag >= 0) {
|
---|
6629 | if (patchFlag & 1024) {
|
---|
6630 | return true;
|
---|
6631 | }
|
---|
6632 | if (patchFlag & 16) {
|
---|
6633 | if (!prevProps) {
|
---|
6634 | return !!nextProps;
|
---|
6635 | }
|
---|
6636 | return hasPropsChanged(prevProps, nextProps, emits);
|
---|
6637 | } else if (patchFlag & 8) {
|
---|
6638 | const dynamicProps = nextVNode.dynamicProps;
|
---|
6639 | for (let i = 0; i < dynamicProps.length; i++) {
|
---|
6640 | const key = dynamicProps[i];
|
---|
6641 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
|
---|
6642 | return true;
|
---|
6643 | }
|
---|
6644 | }
|
---|
6645 | }
|
---|
6646 | } else {
|
---|
6647 | if (prevChildren || nextChildren) {
|
---|
6648 | if (!nextChildren || !nextChildren.$stable) {
|
---|
6649 | return true;
|
---|
6650 | }
|
---|
6651 | }
|
---|
6652 | if (prevProps === nextProps) {
|
---|
6653 | return false;
|
---|
6654 | }
|
---|
6655 | if (!prevProps) {
|
---|
6656 | return !!nextProps;
|
---|
6657 | }
|
---|
6658 | if (!nextProps) {
|
---|
6659 | return true;
|
---|
6660 | }
|
---|
6661 | return hasPropsChanged(prevProps, nextProps, emits);
|
---|
6662 | }
|
---|
6663 | return false;
|
---|
6664 | }
|
---|
6665 | function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
---|
6666 | const nextKeys = Object.keys(nextProps);
|
---|
6667 | if (nextKeys.length !== Object.keys(prevProps).length) {
|
---|
6668 | return true;
|
---|
6669 | }
|
---|
6670 | for (let i = 0; i < nextKeys.length; i++) {
|
---|
6671 | const key = nextKeys[i];
|
---|
6672 | if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
|
---|
6673 | return true;
|
---|
6674 | }
|
---|
6675 | }
|
---|
6676 | return false;
|
---|
6677 | }
|
---|
6678 | function updateHOCHostEl({ vnode, parent }, el) {
|
---|
6679 | while (parent) {
|
---|
6680 | const root = parent.subTree;
|
---|
6681 | if (root.suspense && root.suspense.activeBranch === vnode) {
|
---|
6682 | root.el = vnode.el;
|
---|
6683 | }
|
---|
6684 | if (root === vnode) {
|
---|
6685 | (vnode = parent.vnode).el = el;
|
---|
6686 | parent = parent.parent;
|
---|
6687 | } else {
|
---|
6688 | break;
|
---|
6689 | }
|
---|
6690 | }
|
---|
6691 | }
|
---|
6692 |
|
---|
6693 | const isSuspense = (type) => type.__isSuspense;
|
---|
6694 | let suspenseId = 0;
|
---|
6695 | const SuspenseImpl = {
|
---|
6696 | name: "Suspense",
|
---|
6697 | // In order to make Suspense tree-shakable, we need to avoid importing it
|
---|
6698 | // directly in the renderer. The renderer checks for the __isSuspense flag
|
---|
6699 | // on a vnode's type and calls the `process` method, passing in renderer
|
---|
6700 | // internals.
|
---|
6701 | __isSuspense: true,
|
---|
6702 | process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
---|
6703 | if (n1 == null) {
|
---|
6704 | mountSuspense(
|
---|
6705 | n2,
|
---|
6706 | container,
|
---|
6707 | anchor,
|
---|
6708 | parentComponent,
|
---|
6709 | parentSuspense,
|
---|
6710 | namespace,
|
---|
6711 | slotScopeIds,
|
---|
6712 | optimized,
|
---|
6713 | rendererInternals
|
---|
6714 | );
|
---|
6715 | } else {
|
---|
6716 | if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
|
---|
6717 | n2.suspense = n1.suspense;
|
---|
6718 | n2.suspense.vnode = n2;
|
---|
6719 | n2.el = n1.el;
|
---|
6720 | return;
|
---|
6721 | }
|
---|
6722 | patchSuspense(
|
---|
6723 | n1,
|
---|
6724 | n2,
|
---|
6725 | container,
|
---|
6726 | anchor,
|
---|
6727 | parentComponent,
|
---|
6728 | namespace,
|
---|
6729 | slotScopeIds,
|
---|
6730 | optimized,
|
---|
6731 | rendererInternals
|
---|
6732 | );
|
---|
6733 | }
|
---|
6734 | },
|
---|
6735 | hydrate: hydrateSuspense,
|
---|
6736 | normalize: normalizeSuspenseChildren
|
---|
6737 | };
|
---|
6738 | const Suspense = SuspenseImpl ;
|
---|
6739 | function triggerEvent(vnode, name) {
|
---|
6740 | const eventListener = vnode.props && vnode.props[name];
|
---|
6741 | if (shared.isFunction(eventListener)) {
|
---|
6742 | eventListener();
|
---|
6743 | }
|
---|
6744 | }
|
---|
6745 | function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
|
---|
6746 | const {
|
---|
6747 | p: patch,
|
---|
6748 | o: { createElement }
|
---|
6749 | } = rendererInternals;
|
---|
6750 | const hiddenContainer = createElement("div");
|
---|
6751 | const suspense = vnode.suspense = createSuspenseBoundary(
|
---|
6752 | vnode,
|
---|
6753 | parentSuspense,
|
---|
6754 | parentComponent,
|
---|
6755 | container,
|
---|
6756 | hiddenContainer,
|
---|
6757 | anchor,
|
---|
6758 | namespace,
|
---|
6759 | slotScopeIds,
|
---|
6760 | optimized,
|
---|
6761 | rendererInternals
|
---|
6762 | );
|
---|
6763 | patch(
|
---|
6764 | null,
|
---|
6765 | suspense.pendingBranch = vnode.ssContent,
|
---|
6766 | hiddenContainer,
|
---|
6767 | null,
|
---|
6768 | parentComponent,
|
---|
6769 | suspense,
|
---|
6770 | namespace,
|
---|
6771 | slotScopeIds
|
---|
6772 | );
|
---|
6773 | if (suspense.deps > 0) {
|
---|
6774 | triggerEvent(vnode, "onPending");
|
---|
6775 | triggerEvent(vnode, "onFallback");
|
---|
6776 | patch(
|
---|
6777 | null,
|
---|
6778 | vnode.ssFallback,
|
---|
6779 | container,
|
---|
6780 | anchor,
|
---|
6781 | parentComponent,
|
---|
6782 | null,
|
---|
6783 | // fallback tree will not have suspense context
|
---|
6784 | namespace,
|
---|
6785 | slotScopeIds
|
---|
6786 | );
|
---|
6787 | setActiveBranch(suspense, vnode.ssFallback);
|
---|
6788 | } else {
|
---|
6789 | suspense.resolve(false, true);
|
---|
6790 | }
|
---|
6791 | }
|
---|
6792 | function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
|
---|
6793 | const suspense = n2.suspense = n1.suspense;
|
---|
6794 | suspense.vnode = n2;
|
---|
6795 | n2.el = n1.el;
|
---|
6796 | const newBranch = n2.ssContent;
|
---|
6797 | const newFallback = n2.ssFallback;
|
---|
6798 | const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
---|
6799 | if (pendingBranch) {
|
---|
6800 | suspense.pendingBranch = newBranch;
|
---|
6801 | if (isSameVNodeType(newBranch, pendingBranch)) {
|
---|
6802 | patch(
|
---|
6803 | pendingBranch,
|
---|
6804 | newBranch,
|
---|
6805 | suspense.hiddenContainer,
|
---|
6806 | null,
|
---|
6807 | parentComponent,
|
---|
6808 | suspense,
|
---|
6809 | namespace,
|
---|
6810 | slotScopeIds,
|
---|
6811 | optimized
|
---|
6812 | );
|
---|
6813 | if (suspense.deps <= 0) {
|
---|
6814 | suspense.resolve();
|
---|
6815 | } else if (isInFallback) {
|
---|
6816 | if (!isHydrating) {
|
---|
6817 | patch(
|
---|
6818 | activeBranch,
|
---|
6819 | newFallback,
|
---|
6820 | container,
|
---|
6821 | anchor,
|
---|
6822 | parentComponent,
|
---|
6823 | null,
|
---|
6824 | // fallback tree will not have suspense context
|
---|
6825 | namespace,
|
---|
6826 | slotScopeIds,
|
---|
6827 | optimized
|
---|
6828 | );
|
---|
6829 | setActiveBranch(suspense, newFallback);
|
---|
6830 | }
|
---|
6831 | }
|
---|
6832 | } else {
|
---|
6833 | suspense.pendingId = suspenseId++;
|
---|
6834 | if (isHydrating) {
|
---|
6835 | suspense.isHydrating = false;
|
---|
6836 | suspense.activeBranch = pendingBranch;
|
---|
6837 | } else {
|
---|
6838 | unmount(pendingBranch, parentComponent, suspense);
|
---|
6839 | }
|
---|
6840 | suspense.deps = 0;
|
---|
6841 | suspense.effects.length = 0;
|
---|
6842 | suspense.hiddenContainer = createElement("div");
|
---|
6843 | if (isInFallback) {
|
---|
6844 | patch(
|
---|
6845 | null,
|
---|
6846 | newBranch,
|
---|
6847 | suspense.hiddenContainer,
|
---|
6848 | null,
|
---|
6849 | parentComponent,
|
---|
6850 | suspense,
|
---|
6851 | namespace,
|
---|
6852 | slotScopeIds,
|
---|
6853 | optimized
|
---|
6854 | );
|
---|
6855 | if (suspense.deps <= 0) {
|
---|
6856 | suspense.resolve();
|
---|
6857 | } else {
|
---|
6858 | patch(
|
---|
6859 | activeBranch,
|
---|
6860 | newFallback,
|
---|
6861 | container,
|
---|
6862 | anchor,
|
---|
6863 | parentComponent,
|
---|
6864 | null,
|
---|
6865 | // fallback tree will not have suspense context
|
---|
6866 | namespace,
|
---|
6867 | slotScopeIds,
|
---|
6868 | optimized
|
---|
6869 | );
|
---|
6870 | setActiveBranch(suspense, newFallback);
|
---|
6871 | }
|
---|
6872 | } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
---|
6873 | patch(
|
---|
6874 | activeBranch,
|
---|
6875 | newBranch,
|
---|
6876 | container,
|
---|
6877 | anchor,
|
---|
6878 | parentComponent,
|
---|
6879 | suspense,
|
---|
6880 | namespace,
|
---|
6881 | slotScopeIds,
|
---|
6882 | optimized
|
---|
6883 | );
|
---|
6884 | suspense.resolve(true);
|
---|
6885 | } else {
|
---|
6886 | patch(
|
---|
6887 | null,
|
---|
6888 | newBranch,
|
---|
6889 | suspense.hiddenContainer,
|
---|
6890 | null,
|
---|
6891 | parentComponent,
|
---|
6892 | suspense,
|
---|
6893 | namespace,
|
---|
6894 | slotScopeIds,
|
---|
6895 | optimized
|
---|
6896 | );
|
---|
6897 | if (suspense.deps <= 0) {
|
---|
6898 | suspense.resolve();
|
---|
6899 | }
|
---|
6900 | }
|
---|
6901 | }
|
---|
6902 | } else {
|
---|
6903 | if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
---|
6904 | patch(
|
---|
6905 | activeBranch,
|
---|
6906 | newBranch,
|
---|
6907 | container,
|
---|
6908 | anchor,
|
---|
6909 | parentComponent,
|
---|
6910 | suspense,
|
---|
6911 | namespace,
|
---|
6912 | slotScopeIds,
|
---|
6913 | optimized
|
---|
6914 | );
|
---|
6915 | setActiveBranch(suspense, newBranch);
|
---|
6916 | } else {
|
---|
6917 | triggerEvent(n2, "onPending");
|
---|
6918 | suspense.pendingBranch = newBranch;
|
---|
6919 | if (newBranch.shapeFlag & 512) {
|
---|
6920 | suspense.pendingId = newBranch.component.suspenseId;
|
---|
6921 | } else {
|
---|
6922 | suspense.pendingId = suspenseId++;
|
---|
6923 | }
|
---|
6924 | patch(
|
---|
6925 | null,
|
---|
6926 | newBranch,
|
---|
6927 | suspense.hiddenContainer,
|
---|
6928 | null,
|
---|
6929 | parentComponent,
|
---|
6930 | suspense,
|
---|
6931 | namespace,
|
---|
6932 | slotScopeIds,
|
---|
6933 | optimized
|
---|
6934 | );
|
---|
6935 | if (suspense.deps <= 0) {
|
---|
6936 | suspense.resolve();
|
---|
6937 | } else {
|
---|
6938 | const { timeout, pendingId } = suspense;
|
---|
6939 | if (timeout > 0) {
|
---|
6940 | setTimeout(() => {
|
---|
6941 | if (suspense.pendingId === pendingId) {
|
---|
6942 | suspense.fallback(newFallback);
|
---|
6943 | }
|
---|
6944 | }, timeout);
|
---|
6945 | } else if (timeout === 0) {
|
---|
6946 | suspense.fallback(newFallback);
|
---|
6947 | }
|
---|
6948 | }
|
---|
6949 | }
|
---|
6950 | }
|
---|
6951 | }
|
---|
6952 | let hasWarned = false;
|
---|
6953 | function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
---|
6954 | if (!hasWarned) {
|
---|
6955 | hasWarned = true;
|
---|
6956 | console[console.info ? "info" : "log"](
|
---|
6957 | `<Suspense> is an experimental feature and its API will likely change.`
|
---|
6958 | );
|
---|
6959 | }
|
---|
6960 | const {
|
---|
6961 | p: patch,
|
---|
6962 | m: move,
|
---|
6963 | um: unmount,
|
---|
6964 | n: next,
|
---|
6965 | o: { parentNode, remove }
|
---|
6966 | } = rendererInternals;
|
---|
6967 | let parentSuspenseId;
|
---|
6968 | const isSuspensible = isVNodeSuspensible(vnode);
|
---|
6969 | if (isSuspensible) {
|
---|
6970 | if (parentSuspense && parentSuspense.pendingBranch) {
|
---|
6971 | parentSuspenseId = parentSuspense.pendingId;
|
---|
6972 | parentSuspense.deps++;
|
---|
6973 | }
|
---|
6974 | }
|
---|
6975 | const timeout = vnode.props ? shared.toNumber(vnode.props.timeout) : void 0;
|
---|
6976 | {
|
---|
6977 | assertNumber(timeout, `Suspense timeout`);
|
---|
6978 | }
|
---|
6979 | const initialAnchor = anchor;
|
---|
6980 | const suspense = {
|
---|
6981 | vnode,
|
---|
6982 | parent: parentSuspense,
|
---|
6983 | parentComponent,
|
---|
6984 | namespace,
|
---|
6985 | container,
|
---|
6986 | hiddenContainer,
|
---|
6987 | deps: 0,
|
---|
6988 | pendingId: suspenseId++,
|
---|
6989 | timeout: typeof timeout === "number" ? timeout : -1,
|
---|
6990 | activeBranch: null,
|
---|
6991 | pendingBranch: null,
|
---|
6992 | isInFallback: !isHydrating,
|
---|
6993 | isHydrating,
|
---|
6994 | isUnmounted: false,
|
---|
6995 | effects: [],
|
---|
6996 | resolve(resume = false, sync = false) {
|
---|
6997 | {
|
---|
6998 | if (!resume && !suspense.pendingBranch) {
|
---|
6999 | throw new Error(
|
---|
7000 | `suspense.resolve() is called without a pending branch.`
|
---|
7001 | );
|
---|
7002 | }
|
---|
7003 | if (suspense.isUnmounted) {
|
---|
7004 | throw new Error(
|
---|
7005 | `suspense.resolve() is called on an already unmounted suspense boundary.`
|
---|
7006 | );
|
---|
7007 | }
|
---|
7008 | }
|
---|
7009 | const {
|
---|
7010 | vnode: vnode2,
|
---|
7011 | activeBranch,
|
---|
7012 | pendingBranch,
|
---|
7013 | pendingId,
|
---|
7014 | effects,
|
---|
7015 | parentComponent: parentComponent2,
|
---|
7016 | container: container2
|
---|
7017 | } = suspense;
|
---|
7018 | let delayEnter = false;
|
---|
7019 | if (suspense.isHydrating) {
|
---|
7020 | suspense.isHydrating = false;
|
---|
7021 | } else if (!resume) {
|
---|
7022 | delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
|
---|
7023 | if (delayEnter) {
|
---|
7024 | activeBranch.transition.afterLeave = () => {
|
---|
7025 | if (pendingId === suspense.pendingId) {
|
---|
7026 | move(
|
---|
7027 | pendingBranch,
|
---|
7028 | container2,
|
---|
7029 | anchor === initialAnchor ? next(activeBranch) : anchor,
|
---|
7030 | 0
|
---|
7031 | );
|
---|
7032 | queuePostFlushCb(effects);
|
---|
7033 | }
|
---|
7034 | };
|
---|
7035 | }
|
---|
7036 | if (activeBranch) {
|
---|
7037 | if (parentNode(activeBranch.el) === container2) {
|
---|
7038 | anchor = next(activeBranch);
|
---|
7039 | }
|
---|
7040 | unmount(activeBranch, parentComponent2, suspense, true);
|
---|
7041 | }
|
---|
7042 | if (!delayEnter) {
|
---|
7043 | move(pendingBranch, container2, anchor, 0);
|
---|
7044 | }
|
---|
7045 | }
|
---|
7046 | setActiveBranch(suspense, pendingBranch);
|
---|
7047 | suspense.pendingBranch = null;
|
---|
7048 | suspense.isInFallback = false;
|
---|
7049 | let parent = suspense.parent;
|
---|
7050 | let hasUnresolvedAncestor = false;
|
---|
7051 | while (parent) {
|
---|
7052 | if (parent.pendingBranch) {
|
---|
7053 | parent.effects.push(...effects);
|
---|
7054 | hasUnresolvedAncestor = true;
|
---|
7055 | break;
|
---|
7056 | }
|
---|
7057 | parent = parent.parent;
|
---|
7058 | }
|
---|
7059 | if (!hasUnresolvedAncestor && !delayEnter) {
|
---|
7060 | queuePostFlushCb(effects);
|
---|
7061 | }
|
---|
7062 | suspense.effects = [];
|
---|
7063 | if (isSuspensible) {
|
---|
7064 | if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
|
---|
7065 | parentSuspense.deps--;
|
---|
7066 | if (parentSuspense.deps === 0 && !sync) {
|
---|
7067 | parentSuspense.resolve();
|
---|
7068 | }
|
---|
7069 | }
|
---|
7070 | }
|
---|
7071 | triggerEvent(vnode2, "onResolve");
|
---|
7072 | },
|
---|
7073 | fallback(fallbackVNode) {
|
---|
7074 | if (!suspense.pendingBranch) {
|
---|
7075 | return;
|
---|
7076 | }
|
---|
7077 | const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense;
|
---|
7078 | triggerEvent(vnode2, "onFallback");
|
---|
7079 | const anchor2 = next(activeBranch);
|
---|
7080 | const mountFallback = () => {
|
---|
7081 | if (!suspense.isInFallback) {
|
---|
7082 | return;
|
---|
7083 | }
|
---|
7084 | patch(
|
---|
7085 | null,
|
---|
7086 | fallbackVNode,
|
---|
7087 | container2,
|
---|
7088 | anchor2,
|
---|
7089 | parentComponent2,
|
---|
7090 | null,
|
---|
7091 | // fallback tree will not have suspense context
|
---|
7092 | namespace2,
|
---|
7093 | slotScopeIds,
|
---|
7094 | optimized
|
---|
7095 | );
|
---|
7096 | setActiveBranch(suspense, fallbackVNode);
|
---|
7097 | };
|
---|
7098 | const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
|
---|
7099 | if (delayEnter) {
|
---|
7100 | activeBranch.transition.afterLeave = mountFallback;
|
---|
7101 | }
|
---|
7102 | suspense.isInFallback = true;
|
---|
7103 | unmount(
|
---|
7104 | activeBranch,
|
---|
7105 | parentComponent2,
|
---|
7106 | null,
|
---|
7107 | // no suspense so unmount hooks fire now
|
---|
7108 | true
|
---|
7109 | // shouldRemove
|
---|
7110 | );
|
---|
7111 | if (!delayEnter) {
|
---|
7112 | mountFallback();
|
---|
7113 | }
|
---|
7114 | },
|
---|
7115 | move(container2, anchor2, type) {
|
---|
7116 | suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
|
---|
7117 | suspense.container = container2;
|
---|
7118 | },
|
---|
7119 | next() {
|
---|
7120 | return suspense.activeBranch && next(suspense.activeBranch);
|
---|
7121 | },
|
---|
7122 | registerDep(instance, setupRenderEffect, optimized2) {
|
---|
7123 | const isInPendingSuspense = !!suspense.pendingBranch;
|
---|
7124 | if (isInPendingSuspense) {
|
---|
7125 | suspense.deps++;
|
---|
7126 | }
|
---|
7127 | const hydratedEl = instance.vnode.el;
|
---|
7128 | instance.asyncDep.catch((err) => {
|
---|
7129 | handleError(err, instance, 0);
|
---|
7130 | }).then((asyncSetupResult) => {
|
---|
7131 | if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
|
---|
7132 | return;
|
---|
7133 | }
|
---|
7134 | instance.asyncResolved = true;
|
---|
7135 | const { vnode: vnode2 } = instance;
|
---|
7136 | {
|
---|
7137 | pushWarningContext(vnode2);
|
---|
7138 | }
|
---|
7139 | handleSetupResult(instance, asyncSetupResult, false);
|
---|
7140 | if (hydratedEl) {
|
---|
7141 | vnode2.el = hydratedEl;
|
---|
7142 | }
|
---|
7143 | const placeholder = !hydratedEl && instance.subTree.el;
|
---|
7144 | setupRenderEffect(
|
---|
7145 | instance,
|
---|
7146 | vnode2,
|
---|
7147 | // component may have been moved before resolve.
|
---|
7148 | // if this is not a hydration, instance.subTree will be the comment
|
---|
7149 | // placeholder.
|
---|
7150 | parentNode(hydratedEl || instance.subTree.el),
|
---|
7151 | // anchor will not be used if this is hydration, so only need to
|
---|
7152 | // consider the comment placeholder case.
|
---|
7153 | hydratedEl ? null : next(instance.subTree),
|
---|
7154 | suspense,
|
---|
7155 | namespace,
|
---|
7156 | optimized2
|
---|
7157 | );
|
---|
7158 | if (placeholder) {
|
---|
7159 | remove(placeholder);
|
---|
7160 | }
|
---|
7161 | updateHOCHostEl(instance, vnode2.el);
|
---|
7162 | {
|
---|
7163 | popWarningContext();
|
---|
7164 | }
|
---|
7165 | if (isInPendingSuspense && --suspense.deps === 0) {
|
---|
7166 | suspense.resolve();
|
---|
7167 | }
|
---|
7168 | });
|
---|
7169 | },
|
---|
7170 | unmount(parentSuspense2, doRemove) {
|
---|
7171 | suspense.isUnmounted = true;
|
---|
7172 | if (suspense.activeBranch) {
|
---|
7173 | unmount(
|
---|
7174 | suspense.activeBranch,
|
---|
7175 | parentComponent,
|
---|
7176 | parentSuspense2,
|
---|
7177 | doRemove
|
---|
7178 | );
|
---|
7179 | }
|
---|
7180 | if (suspense.pendingBranch) {
|
---|
7181 | unmount(
|
---|
7182 | suspense.pendingBranch,
|
---|
7183 | parentComponent,
|
---|
7184 | parentSuspense2,
|
---|
7185 | doRemove
|
---|
7186 | );
|
---|
7187 | }
|
---|
7188 | }
|
---|
7189 | };
|
---|
7190 | return suspense;
|
---|
7191 | }
|
---|
7192 | function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
---|
7193 | const suspense = vnode.suspense = createSuspenseBoundary(
|
---|
7194 | vnode,
|
---|
7195 | parentSuspense,
|
---|
7196 | parentComponent,
|
---|
7197 | node.parentNode,
|
---|
7198 | // eslint-disable-next-line no-restricted-globals
|
---|
7199 | document.createElement("div"),
|
---|
7200 | null,
|
---|
7201 | namespace,
|
---|
7202 | slotScopeIds,
|
---|
7203 | optimized,
|
---|
7204 | rendererInternals,
|
---|
7205 | true
|
---|
7206 | );
|
---|
7207 | const result = hydrateNode(
|
---|
7208 | node,
|
---|
7209 | suspense.pendingBranch = vnode.ssContent,
|
---|
7210 | parentComponent,
|
---|
7211 | suspense,
|
---|
7212 | slotScopeIds,
|
---|
7213 | optimized
|
---|
7214 | );
|
---|
7215 | if (suspense.deps === 0) {
|
---|
7216 | suspense.resolve(false, true);
|
---|
7217 | }
|
---|
7218 | return result;
|
---|
7219 | }
|
---|
7220 | function normalizeSuspenseChildren(vnode) {
|
---|
7221 | const { shapeFlag, children } = vnode;
|
---|
7222 | const isSlotChildren = shapeFlag & 32;
|
---|
7223 | vnode.ssContent = normalizeSuspenseSlot(
|
---|
7224 | isSlotChildren ? children.default : children
|
---|
7225 | );
|
---|
7226 | vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
|
---|
7227 | }
|
---|
7228 | function normalizeSuspenseSlot(s) {
|
---|
7229 | let block;
|
---|
7230 | if (shared.isFunction(s)) {
|
---|
7231 | const trackBlock = isBlockTreeEnabled && s._c;
|
---|
7232 | if (trackBlock) {
|
---|
7233 | s._d = false;
|
---|
7234 | openBlock();
|
---|
7235 | }
|
---|
7236 | s = s();
|
---|
7237 | if (trackBlock) {
|
---|
7238 | s._d = true;
|
---|
7239 | block = currentBlock;
|
---|
7240 | closeBlock();
|
---|
7241 | }
|
---|
7242 | }
|
---|
7243 | if (shared.isArray(s)) {
|
---|
7244 | const singleChild = filterSingleRoot(s);
|
---|
7245 | if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
|
---|
7246 | warn$1(`<Suspense> slots expect a single root node.`);
|
---|
7247 | }
|
---|
7248 | s = singleChild;
|
---|
7249 | }
|
---|
7250 | s = normalizeVNode(s);
|
---|
7251 | if (block && !s.dynamicChildren) {
|
---|
7252 | s.dynamicChildren = block.filter((c) => c !== s);
|
---|
7253 | }
|
---|
7254 | return s;
|
---|
7255 | }
|
---|
7256 | function queueEffectWithSuspense(fn, suspense) {
|
---|
7257 | if (suspense && suspense.pendingBranch) {
|
---|
7258 | if (shared.isArray(fn)) {
|
---|
7259 | suspense.effects.push(...fn);
|
---|
7260 | } else {
|
---|
7261 | suspense.effects.push(fn);
|
---|
7262 | }
|
---|
7263 | } else {
|
---|
7264 | queuePostFlushCb(fn);
|
---|
7265 | }
|
---|
7266 | }
|
---|
7267 | function setActiveBranch(suspense, branch) {
|
---|
7268 | suspense.activeBranch = branch;
|
---|
7269 | const { vnode, parentComponent } = suspense;
|
---|
7270 | let el = branch.el;
|
---|
7271 | while (!el && branch.component) {
|
---|
7272 | branch = branch.component.subTree;
|
---|
7273 | el = branch.el;
|
---|
7274 | }
|
---|
7275 | vnode.el = el;
|
---|
7276 | if (parentComponent && parentComponent.subTree === vnode) {
|
---|
7277 | parentComponent.vnode.el = el;
|
---|
7278 | updateHOCHostEl(parentComponent, el);
|
---|
7279 | }
|
---|
7280 | }
|
---|
7281 | function isVNodeSuspensible(vnode) {
|
---|
7282 | const suspensible = vnode.props && vnode.props.suspensible;
|
---|
7283 | return suspensible != null && suspensible !== false;
|
---|
7284 | }
|
---|
7285 |
|
---|
7286 | const Fragment = Symbol.for("v-fgt");
|
---|
7287 | const Text = Symbol.for("v-txt");
|
---|
7288 | const Comment = Symbol.for("v-cmt");
|
---|
7289 | const Static = Symbol.for("v-stc");
|
---|
7290 | const blockStack = [];
|
---|
7291 | let currentBlock = null;
|
---|
7292 | function openBlock(disableTracking = false) {
|
---|
7293 | blockStack.push(currentBlock = disableTracking ? null : []);
|
---|
7294 | }
|
---|
7295 | function closeBlock() {
|
---|
7296 | blockStack.pop();
|
---|
7297 | currentBlock = blockStack[blockStack.length - 1] || null;
|
---|
7298 | }
|
---|
7299 | let isBlockTreeEnabled = 1;
|
---|
7300 | function setBlockTracking(value, inVOnce = false) {
|
---|
7301 | isBlockTreeEnabled += value;
|
---|
7302 | if (value < 0 && currentBlock && inVOnce) {
|
---|
7303 | currentBlock.hasOnce = true;
|
---|
7304 | }
|
---|
7305 | }
|
---|
7306 | function setupBlock(vnode) {
|
---|
7307 | vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || shared.EMPTY_ARR : null;
|
---|
7308 | closeBlock();
|
---|
7309 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
---|
7310 | currentBlock.push(vnode);
|
---|
7311 | }
|
---|
7312 | return vnode;
|
---|
7313 | }
|
---|
7314 | function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
---|
7315 | return setupBlock(
|
---|
7316 | createBaseVNode(
|
---|
7317 | type,
|
---|
7318 | props,
|
---|
7319 | children,
|
---|
7320 | patchFlag,
|
---|
7321 | dynamicProps,
|
---|
7322 | shapeFlag,
|
---|
7323 | true
|
---|
7324 | )
|
---|
7325 | );
|
---|
7326 | }
|
---|
7327 | function createBlock(type, props, children, patchFlag, dynamicProps) {
|
---|
7328 | return setupBlock(
|
---|
7329 | createVNode(
|
---|
7330 | type,
|
---|
7331 | props,
|
---|
7332 | children,
|
---|
7333 | patchFlag,
|
---|
7334 | dynamicProps,
|
---|
7335 | true
|
---|
7336 | )
|
---|
7337 | );
|
---|
7338 | }
|
---|
7339 | function isVNode(value) {
|
---|
7340 | return value ? value.__v_isVNode === true : false;
|
---|
7341 | }
|
---|
7342 | function isSameVNodeType(n1, n2) {
|
---|
7343 | if (n2.shapeFlag & 6 && n1.component) {
|
---|
7344 | const dirtyInstances = hmrDirtyComponents.get(n2.type);
|
---|
7345 | if (dirtyInstances && dirtyInstances.has(n1.component)) {
|
---|
7346 | n1.shapeFlag &= ~256;
|
---|
7347 | n2.shapeFlag &= ~512;
|
---|
7348 | return false;
|
---|
7349 | }
|
---|
7350 | }
|
---|
7351 | return n1.type === n2.type && n1.key === n2.key;
|
---|
7352 | }
|
---|
7353 | let vnodeArgsTransformer;
|
---|
7354 | function transformVNodeArgs(transformer) {
|
---|
7355 | vnodeArgsTransformer = transformer;
|
---|
7356 | }
|
---|
7357 | const createVNodeWithArgsTransform = (...args) => {
|
---|
7358 | return _createVNode(
|
---|
7359 | ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
|
---|
7360 | );
|
---|
7361 | };
|
---|
7362 | const normalizeKey = ({ key }) => key != null ? key : null;
|
---|
7363 | const normalizeRef = ({
|
---|
7364 | ref,
|
---|
7365 | ref_key,
|
---|
7366 | ref_for
|
---|
7367 | }) => {
|
---|
7368 | if (typeof ref === "number") {
|
---|
7369 | ref = "" + ref;
|
---|
7370 | }
|
---|
7371 | return ref != null ? shared.isString(ref) || reactivity.isRef(ref) || shared.isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
|
---|
7372 | };
|
---|
7373 | function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
---|
7374 | const vnode = {
|
---|
7375 | __v_isVNode: true,
|
---|
7376 | __v_skip: true,
|
---|
7377 | type,
|
---|
7378 | props,
|
---|
7379 | key: props && normalizeKey(props),
|
---|
7380 | ref: props && normalizeRef(props),
|
---|
7381 | scopeId: currentScopeId,
|
---|
7382 | slotScopeIds: null,
|
---|
7383 | children,
|
---|
7384 | component: null,
|
---|
7385 | suspense: null,
|
---|
7386 | ssContent: null,
|
---|
7387 | ssFallback: null,
|
---|
7388 | dirs: null,
|
---|
7389 | transition: null,
|
---|
7390 | el: null,
|
---|
7391 | anchor: null,
|
---|
7392 | target: null,
|
---|
7393 | targetStart: null,
|
---|
7394 | targetAnchor: null,
|
---|
7395 | staticCount: 0,
|
---|
7396 | shapeFlag,
|
---|
7397 | patchFlag,
|
---|
7398 | dynamicProps,
|
---|
7399 | dynamicChildren: null,
|
---|
7400 | appContext: null,
|
---|
7401 | ctx: currentRenderingInstance
|
---|
7402 | };
|
---|
7403 | if (needFullChildrenNormalization) {
|
---|
7404 | normalizeChildren(vnode, children);
|
---|
7405 | if (shapeFlag & 128) {
|
---|
7406 | type.normalize(vnode);
|
---|
7407 | }
|
---|
7408 | } else if (children) {
|
---|
7409 | vnode.shapeFlag |= shared.isString(children) ? 8 : 16;
|
---|
7410 | }
|
---|
7411 | if (vnode.key !== vnode.key) {
|
---|
7412 | warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
---|
7413 | }
|
---|
7414 | if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
|
---|
7415 | !isBlockNode && // has current parent block
|
---|
7416 | currentBlock && // presence of a patch flag indicates this node needs patching on updates.
|
---|
7417 | // component nodes also should always be patched, because even if the
|
---|
7418 | // component doesn't need to update, it needs to persist the instance on to
|
---|
7419 | // the next vnode so that it can be properly unmounted later.
|
---|
7420 | (vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
|
---|
7421 | // vnode should not be considered dynamic due to handler caching.
|
---|
7422 | vnode.patchFlag !== 32) {
|
---|
7423 | currentBlock.push(vnode);
|
---|
7424 | }
|
---|
7425 | return vnode;
|
---|
7426 | }
|
---|
7427 | const createVNode = createVNodeWithArgsTransform ;
|
---|
7428 | function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
---|
7429 | if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
---|
7430 | if (!type) {
|
---|
7431 | warn$1(`Invalid vnode type when creating vnode: ${type}.`);
|
---|
7432 | }
|
---|
7433 | type = Comment;
|
---|
7434 | }
|
---|
7435 | if (isVNode(type)) {
|
---|
7436 | const cloned = cloneVNode(
|
---|
7437 | type,
|
---|
7438 | props,
|
---|
7439 | true
|
---|
7440 | /* mergeRef: true */
|
---|
7441 | );
|
---|
7442 | if (children) {
|
---|
7443 | normalizeChildren(cloned, children);
|
---|
7444 | }
|
---|
7445 | if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
|
---|
7446 | if (cloned.shapeFlag & 6) {
|
---|
7447 | currentBlock[currentBlock.indexOf(type)] = cloned;
|
---|
7448 | } else {
|
---|
7449 | currentBlock.push(cloned);
|
---|
7450 | }
|
---|
7451 | }
|
---|
7452 | cloned.patchFlag = -2;
|
---|
7453 | return cloned;
|
---|
7454 | }
|
---|
7455 | if (isClassComponent(type)) {
|
---|
7456 | type = type.__vccOpts;
|
---|
7457 | }
|
---|
7458 | if (props) {
|
---|
7459 | props = guardReactiveProps(props);
|
---|
7460 | let { class: klass, style } = props;
|
---|
7461 | if (klass && !shared.isString(klass)) {
|
---|
7462 | props.class = shared.normalizeClass(klass);
|
---|
7463 | }
|
---|
7464 | if (shared.isObject(style)) {
|
---|
7465 | if (reactivity.isProxy(style) && !shared.isArray(style)) {
|
---|
7466 | style = shared.extend({}, style);
|
---|
7467 | }
|
---|
7468 | props.style = shared.normalizeStyle(style);
|
---|
7469 | }
|
---|
7470 | }
|
---|
7471 | const shapeFlag = shared.isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : shared.isObject(type) ? 4 : shared.isFunction(type) ? 2 : 0;
|
---|
7472 | if (shapeFlag & 4 && reactivity.isProxy(type)) {
|
---|
7473 | type = reactivity.toRaw(type);
|
---|
7474 | warn$1(
|
---|
7475 | `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
|
---|
7476 | `
|
---|
7477 | Component that was made reactive: `,
|
---|
7478 | type
|
---|
7479 | );
|
---|
7480 | }
|
---|
7481 | return createBaseVNode(
|
---|
7482 | type,
|
---|
7483 | props,
|
---|
7484 | children,
|
---|
7485 | patchFlag,
|
---|
7486 | dynamicProps,
|
---|
7487 | shapeFlag,
|
---|
7488 | isBlockNode,
|
---|
7489 | true
|
---|
7490 | );
|
---|
7491 | }
|
---|
7492 | function guardReactiveProps(props) {
|
---|
7493 | if (!props) return null;
|
---|
7494 | return reactivity.isProxy(props) || isInternalObject(props) ? shared.extend({}, props) : props;
|
---|
7495 | }
|
---|
7496 | function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
|
---|
7497 | const { props, ref, patchFlag, children, transition } = vnode;
|
---|
7498 | const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
---|
7499 | const cloned = {
|
---|
7500 | __v_isVNode: true,
|
---|
7501 | __v_skip: true,
|
---|
7502 | type: vnode.type,
|
---|
7503 | props: mergedProps,
|
---|
7504 | key: mergedProps && normalizeKey(mergedProps),
|
---|
7505 | ref: extraProps && extraProps.ref ? (
|
---|
7506 | // #2078 in the case of <component :is="vnode" ref="extra"/>
|
---|
7507 | // if the vnode itself already has a ref, cloneVNode will need to merge
|
---|
7508 | // the refs so the single vnode can be set on multiple refs
|
---|
7509 | mergeRef && ref ? shared.isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
|
---|
7510 | ) : ref,
|
---|
7511 | scopeId: vnode.scopeId,
|
---|
7512 | slotScopeIds: vnode.slotScopeIds,
|
---|
7513 | children: patchFlag === -1 && shared.isArray(children) ? children.map(deepCloneVNode) : children,
|
---|
7514 | target: vnode.target,
|
---|
7515 | targetStart: vnode.targetStart,
|
---|
7516 | targetAnchor: vnode.targetAnchor,
|
---|
7517 | staticCount: vnode.staticCount,
|
---|
7518 | shapeFlag: vnode.shapeFlag,
|
---|
7519 | // if the vnode is cloned with extra props, we can no longer assume its
|
---|
7520 | // existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
---|
7521 | // note: preserve flag for fragments since they use the flag for children
|
---|
7522 | // fast paths only.
|
---|
7523 | patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
---|
7524 | dynamicProps: vnode.dynamicProps,
|
---|
7525 | dynamicChildren: vnode.dynamicChildren,
|
---|
7526 | appContext: vnode.appContext,
|
---|
7527 | dirs: vnode.dirs,
|
---|
7528 | transition,
|
---|
7529 | // These should technically only be non-null on mounted VNodes. However,
|
---|
7530 | // they *should* be copied for kept-alive vnodes. So we just always copy
|
---|
7531 | // them since them being non-null during a mount doesn't affect the logic as
|
---|
7532 | // they will simply be overwritten.
|
---|
7533 | component: vnode.component,
|
---|
7534 | suspense: vnode.suspense,
|
---|
7535 | ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
---|
7536 | ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
---|
7537 | el: vnode.el,
|
---|
7538 | anchor: vnode.anchor,
|
---|
7539 | ctx: vnode.ctx,
|
---|
7540 | ce: vnode.ce
|
---|
7541 | };
|
---|
7542 | if (transition && cloneTransition) {
|
---|
7543 | setTransitionHooks(
|
---|
7544 | cloned,
|
---|
7545 | transition.clone(cloned)
|
---|
7546 | );
|
---|
7547 | }
|
---|
7548 | return cloned;
|
---|
7549 | }
|
---|
7550 | function deepCloneVNode(vnode) {
|
---|
7551 | const cloned = cloneVNode(vnode);
|
---|
7552 | if (shared.isArray(vnode.children)) {
|
---|
7553 | cloned.children = vnode.children.map(deepCloneVNode);
|
---|
7554 | }
|
---|
7555 | return cloned;
|
---|
7556 | }
|
---|
7557 | function createTextVNode(text = " ", flag = 0) {
|
---|
7558 | return createVNode(Text, null, text, flag);
|
---|
7559 | }
|
---|
7560 | function createStaticVNode(content, numberOfNodes) {
|
---|
7561 | const vnode = createVNode(Static, null, content);
|
---|
7562 | vnode.staticCount = numberOfNodes;
|
---|
7563 | return vnode;
|
---|
7564 | }
|
---|
7565 | function createCommentVNode(text = "", asBlock = false) {
|
---|
7566 | return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
|
---|
7567 | }
|
---|
7568 | function normalizeVNode(child) {
|
---|
7569 | if (child == null || typeof child === "boolean") {
|
---|
7570 | return createVNode(Comment);
|
---|
7571 | } else if (shared.isArray(child)) {
|
---|
7572 | return createVNode(
|
---|
7573 | Fragment,
|
---|
7574 | null,
|
---|
7575 | // #3666, avoid reference pollution when reusing vnode
|
---|
7576 | child.slice()
|
---|
7577 | );
|
---|
7578 | } else if (isVNode(child)) {
|
---|
7579 | return cloneIfMounted(child);
|
---|
7580 | } else {
|
---|
7581 | return createVNode(Text, null, String(child));
|
---|
7582 | }
|
---|
7583 | }
|
---|
7584 | function cloneIfMounted(child) {
|
---|
7585 | return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
|
---|
7586 | }
|
---|
7587 | function normalizeChildren(vnode, children) {
|
---|
7588 | let type = 0;
|
---|
7589 | const { shapeFlag } = vnode;
|
---|
7590 | if (children == null) {
|
---|
7591 | children = null;
|
---|
7592 | } else if (shared.isArray(children)) {
|
---|
7593 | type = 16;
|
---|
7594 | } else if (typeof children === "object") {
|
---|
7595 | if (shapeFlag & (1 | 64)) {
|
---|
7596 | const slot = children.default;
|
---|
7597 | if (slot) {
|
---|
7598 | slot._c && (slot._d = false);
|
---|
7599 | normalizeChildren(vnode, slot());
|
---|
7600 | slot._c && (slot._d = true);
|
---|
7601 | }
|
---|
7602 | return;
|
---|
7603 | } else {
|
---|
7604 | type = 32;
|
---|
7605 | const slotFlag = children._;
|
---|
7606 | if (!slotFlag && !isInternalObject(children)) {
|
---|
7607 | children._ctx = currentRenderingInstance;
|
---|
7608 | } else if (slotFlag === 3 && currentRenderingInstance) {
|
---|
7609 | if (currentRenderingInstance.slots._ === 1) {
|
---|
7610 | children._ = 1;
|
---|
7611 | } else {
|
---|
7612 | children._ = 2;
|
---|
7613 | vnode.patchFlag |= 1024;
|
---|
7614 | }
|
---|
7615 | }
|
---|
7616 | }
|
---|
7617 | } else if (shared.isFunction(children)) {
|
---|
7618 | children = { default: children, _ctx: currentRenderingInstance };
|
---|
7619 | type = 32;
|
---|
7620 | } else {
|
---|
7621 | children = String(children);
|
---|
7622 | if (shapeFlag & 64) {
|
---|
7623 | type = 16;
|
---|
7624 | children = [createTextVNode(children)];
|
---|
7625 | } else {
|
---|
7626 | type = 8;
|
---|
7627 | }
|
---|
7628 | }
|
---|
7629 | vnode.children = children;
|
---|
7630 | vnode.shapeFlag |= type;
|
---|
7631 | }
|
---|
7632 | function mergeProps(...args) {
|
---|
7633 | const ret = {};
|
---|
7634 | for (let i = 0; i < args.length; i++) {
|
---|
7635 | const toMerge = args[i];
|
---|
7636 | for (const key in toMerge) {
|
---|
7637 | if (key === "class") {
|
---|
7638 | if (ret.class !== toMerge.class) {
|
---|
7639 | ret.class = shared.normalizeClass([ret.class, toMerge.class]);
|
---|
7640 | }
|
---|
7641 | } else if (key === "style") {
|
---|
7642 | ret.style = shared.normalizeStyle([ret.style, toMerge.style]);
|
---|
7643 | } else if (shared.isOn(key)) {
|
---|
7644 | const existing = ret[key];
|
---|
7645 | const incoming = toMerge[key];
|
---|
7646 | if (incoming && existing !== incoming && !(shared.isArray(existing) && existing.includes(incoming))) {
|
---|
7647 | ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
---|
7648 | }
|
---|
7649 | } else if (key !== "") {
|
---|
7650 | ret[key] = toMerge[key];
|
---|
7651 | }
|
---|
7652 | }
|
---|
7653 | }
|
---|
7654 | return ret;
|
---|
7655 | }
|
---|
7656 | function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
---|
7657 | callWithAsyncErrorHandling(hook, instance, 7, [
|
---|
7658 | vnode,
|
---|
7659 | prevVNode
|
---|
7660 | ]);
|
---|
7661 | }
|
---|
7662 |
|
---|
7663 | const emptyAppContext = createAppContext();
|
---|
7664 | let uid = 0;
|
---|
7665 | function createComponentInstance(vnode, parent, suspense) {
|
---|
7666 | const type = vnode.type;
|
---|
7667 | const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
---|
7668 | const instance = {
|
---|
7669 | uid: uid++,
|
---|
7670 | vnode,
|
---|
7671 | type,
|
---|
7672 | parent,
|
---|
7673 | appContext,
|
---|
7674 | root: null,
|
---|
7675 | // to be immediately set
|
---|
7676 | next: null,
|
---|
7677 | subTree: null,
|
---|
7678 | // will be set synchronously right after creation
|
---|
7679 | effect: null,
|
---|
7680 | update: null,
|
---|
7681 | // will be set synchronously right after creation
|
---|
7682 | job: null,
|
---|
7683 | scope: new reactivity.EffectScope(
|
---|
7684 | true
|
---|
7685 | /* detached */
|
---|
7686 | ),
|
---|
7687 | render: null,
|
---|
7688 | proxy: null,
|
---|
7689 | exposed: null,
|
---|
7690 | exposeProxy: null,
|
---|
7691 | withProxy: null,
|
---|
7692 | provides: parent ? parent.provides : Object.create(appContext.provides),
|
---|
7693 | ids: parent ? parent.ids : ["", 0, 0],
|
---|
7694 | accessCache: null,
|
---|
7695 | renderCache: [],
|
---|
7696 | // local resolved assets
|
---|
7697 | components: null,
|
---|
7698 | directives: null,
|
---|
7699 | // resolved props and emits options
|
---|
7700 | propsOptions: normalizePropsOptions(type, appContext),
|
---|
7701 | emitsOptions: normalizeEmitsOptions(type, appContext),
|
---|
7702 | // emit
|
---|
7703 | emit: null,
|
---|
7704 | // to be set immediately
|
---|
7705 | emitted: null,
|
---|
7706 | // props default value
|
---|
7707 | propsDefaults: shared.EMPTY_OBJ,
|
---|
7708 | // inheritAttrs
|
---|
7709 | inheritAttrs: type.inheritAttrs,
|
---|
7710 | // state
|
---|
7711 | ctx: shared.EMPTY_OBJ,
|
---|
7712 | data: shared.EMPTY_OBJ,
|
---|
7713 | props: shared.EMPTY_OBJ,
|
---|
7714 | attrs: shared.EMPTY_OBJ,
|
---|
7715 | slots: shared.EMPTY_OBJ,
|
---|
7716 | refs: shared.EMPTY_OBJ,
|
---|
7717 | setupState: shared.EMPTY_OBJ,
|
---|
7718 | setupContext: null,
|
---|
7719 | // suspense related
|
---|
7720 | suspense,
|
---|
7721 | suspenseId: suspense ? suspense.pendingId : 0,
|
---|
7722 | asyncDep: null,
|
---|
7723 | asyncResolved: false,
|
---|
7724 | // lifecycle hooks
|
---|
7725 | // not using enums here because it results in computed properties
|
---|
7726 | isMounted: false,
|
---|
7727 | isUnmounted: false,
|
---|
7728 | isDeactivated: false,
|
---|
7729 | bc: null,
|
---|
7730 | c: null,
|
---|
7731 | bm: null,
|
---|
7732 | m: null,
|
---|
7733 | bu: null,
|
---|
7734 | u: null,
|
---|
7735 | um: null,
|
---|
7736 | bum: null,
|
---|
7737 | da: null,
|
---|
7738 | a: null,
|
---|
7739 | rtg: null,
|
---|
7740 | rtc: null,
|
---|
7741 | ec: null,
|
---|
7742 | sp: null
|
---|
7743 | };
|
---|
7744 | {
|
---|
7745 | instance.ctx = createDevRenderContext(instance);
|
---|
7746 | }
|
---|
7747 | instance.root = parent ? parent.root : instance;
|
---|
7748 | instance.emit = emit.bind(null, instance);
|
---|
7749 | if (vnode.ce) {
|
---|
7750 | vnode.ce(instance);
|
---|
7751 | }
|
---|
7752 | return instance;
|
---|
7753 | }
|
---|
7754 | let currentInstance = null;
|
---|
7755 | const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
---|
7756 | let internalSetCurrentInstance;
|
---|
7757 | let setInSSRSetupState;
|
---|
7758 | {
|
---|
7759 | const g = shared.getGlobalThis();
|
---|
7760 | const registerGlobalSetter = (key, setter) => {
|
---|
7761 | let setters;
|
---|
7762 | if (!(setters = g[key])) setters = g[key] = [];
|
---|
7763 | setters.push(setter);
|
---|
7764 | return (v) => {
|
---|
7765 | if (setters.length > 1) setters.forEach((set) => set(v));
|
---|
7766 | else setters[0](v);
|
---|
7767 | };
|
---|
7768 | };
|
---|
7769 | internalSetCurrentInstance = registerGlobalSetter(
|
---|
7770 | `__VUE_INSTANCE_SETTERS__`,
|
---|
7771 | (v) => currentInstance = v
|
---|
7772 | );
|
---|
7773 | setInSSRSetupState = registerGlobalSetter(
|
---|
7774 | `__VUE_SSR_SETTERS__`,
|
---|
7775 | (v) => isInSSRComponentSetup = v
|
---|
7776 | );
|
---|
7777 | }
|
---|
7778 | const setCurrentInstance = (instance) => {
|
---|
7779 | const prev = currentInstance;
|
---|
7780 | internalSetCurrentInstance(instance);
|
---|
7781 | instance.scope.on();
|
---|
7782 | return () => {
|
---|
7783 | instance.scope.off();
|
---|
7784 | internalSetCurrentInstance(prev);
|
---|
7785 | };
|
---|
7786 | };
|
---|
7787 | const unsetCurrentInstance = () => {
|
---|
7788 | currentInstance && currentInstance.scope.off();
|
---|
7789 | internalSetCurrentInstance(null);
|
---|
7790 | };
|
---|
7791 | const isBuiltInTag = /* @__PURE__ */ shared.makeMap("slot,component");
|
---|
7792 | function validateComponentName(name, { isNativeTag }) {
|
---|
7793 | if (isBuiltInTag(name) || isNativeTag(name)) {
|
---|
7794 | warn$1(
|
---|
7795 | "Do not use built-in or reserved HTML elements as component id: " + name
|
---|
7796 | );
|
---|
7797 | }
|
---|
7798 | }
|
---|
7799 | function isStatefulComponent(instance) {
|
---|
7800 | return instance.vnode.shapeFlag & 4;
|
---|
7801 | }
|
---|
7802 | let isInSSRComponentSetup = false;
|
---|
7803 | function setupComponent(instance, isSSR = false, optimized = false) {
|
---|
7804 | isSSR && setInSSRSetupState(isSSR);
|
---|
7805 | const { props, children } = instance.vnode;
|
---|
7806 | const isStateful = isStatefulComponent(instance);
|
---|
7807 | initProps(instance, props, isStateful, isSSR);
|
---|
7808 | initSlots(instance, children, optimized);
|
---|
7809 | const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
|
---|
7810 | isSSR && setInSSRSetupState(false);
|
---|
7811 | return setupResult;
|
---|
7812 | }
|
---|
7813 | function setupStatefulComponent(instance, isSSR) {
|
---|
7814 | var _a;
|
---|
7815 | const Component = instance.type;
|
---|
7816 | {
|
---|
7817 | if (Component.name) {
|
---|
7818 | validateComponentName(Component.name, instance.appContext.config);
|
---|
7819 | }
|
---|
7820 | if (Component.components) {
|
---|
7821 | const names = Object.keys(Component.components);
|
---|
7822 | for (let i = 0; i < names.length; i++) {
|
---|
7823 | validateComponentName(names[i], instance.appContext.config);
|
---|
7824 | }
|
---|
7825 | }
|
---|
7826 | if (Component.directives) {
|
---|
7827 | const names = Object.keys(Component.directives);
|
---|
7828 | for (let i = 0; i < names.length; i++) {
|
---|
7829 | validateDirectiveName(names[i]);
|
---|
7830 | }
|
---|
7831 | }
|
---|
7832 | if (Component.compilerOptions && isRuntimeOnly()) {
|
---|
7833 | warn$1(
|
---|
7834 | `"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`
|
---|
7835 | );
|
---|
7836 | }
|
---|
7837 | }
|
---|
7838 | instance.accessCache = /* @__PURE__ */ Object.create(null);
|
---|
7839 | instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
|
---|
7840 | {
|
---|
7841 | exposePropsOnRenderContext(instance);
|
---|
7842 | }
|
---|
7843 | const { setup } = Component;
|
---|
7844 | if (setup) {
|
---|
7845 | reactivity.pauseTracking();
|
---|
7846 | const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
---|
7847 | const reset = setCurrentInstance(instance);
|
---|
7848 | const setupResult = callWithErrorHandling(
|
---|
7849 | setup,
|
---|
7850 | instance,
|
---|
7851 | 0,
|
---|
7852 | [
|
---|
7853 | reactivity.shallowReadonly(instance.props) ,
|
---|
7854 | setupContext
|
---|
7855 | ]
|
---|
7856 | );
|
---|
7857 | const isAsyncSetup = shared.isPromise(setupResult);
|
---|
7858 | reactivity.resetTracking();
|
---|
7859 | reset();
|
---|
7860 | if ((isAsyncSetup || instance.sp) && !isAsyncWrapper(instance)) {
|
---|
7861 | markAsyncBoundary(instance);
|
---|
7862 | }
|
---|
7863 | if (isAsyncSetup) {
|
---|
7864 | setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
---|
7865 | if (isSSR) {
|
---|
7866 | return setupResult.then((resolvedResult) => {
|
---|
7867 | handleSetupResult(instance, resolvedResult, isSSR);
|
---|
7868 | }).catch((e) => {
|
---|
7869 | handleError(e, instance, 0);
|
---|
7870 | });
|
---|
7871 | } else {
|
---|
7872 | instance.asyncDep = setupResult;
|
---|
7873 | if (!instance.suspense) {
|
---|
7874 | const name = (_a = Component.name) != null ? _a : "Anonymous";
|
---|
7875 | warn$1(
|
---|
7876 | `Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`
|
---|
7877 | );
|
---|
7878 | }
|
---|
7879 | }
|
---|
7880 | } else {
|
---|
7881 | handleSetupResult(instance, setupResult, isSSR);
|
---|
7882 | }
|
---|
7883 | } else {
|
---|
7884 | finishComponentSetup(instance, isSSR);
|
---|
7885 | }
|
---|
7886 | }
|
---|
7887 | function handleSetupResult(instance, setupResult, isSSR) {
|
---|
7888 | if (shared.isFunction(setupResult)) {
|
---|
7889 | if (instance.type.__ssrInlineRender) {
|
---|
7890 | instance.ssrRender = setupResult;
|
---|
7891 | } else {
|
---|
7892 | instance.render = setupResult;
|
---|
7893 | }
|
---|
7894 | } else if (shared.isObject(setupResult)) {
|
---|
7895 | if (isVNode(setupResult)) {
|
---|
7896 | warn$1(
|
---|
7897 | `setup() should not return VNodes directly - return a render function instead.`
|
---|
7898 | );
|
---|
7899 | }
|
---|
7900 | {
|
---|
7901 | instance.devtoolsRawSetupState = setupResult;
|
---|
7902 | }
|
---|
7903 | instance.setupState = reactivity.proxyRefs(setupResult);
|
---|
7904 | {
|
---|
7905 | exposeSetupStateOnRenderContext(instance);
|
---|
7906 | }
|
---|
7907 | } else if (setupResult !== void 0) {
|
---|
7908 | warn$1(
|
---|
7909 | `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
|
---|
7910 | );
|
---|
7911 | }
|
---|
7912 | finishComponentSetup(instance, isSSR);
|
---|
7913 | }
|
---|
7914 | let compile;
|
---|
7915 | let installWithProxy;
|
---|
7916 | function registerRuntimeCompiler(_compile) {
|
---|
7917 | compile = _compile;
|
---|
7918 | installWithProxy = (i) => {
|
---|
7919 | if (i.render._rc) {
|
---|
7920 | i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
---|
7921 | }
|
---|
7922 | };
|
---|
7923 | }
|
---|
7924 | const isRuntimeOnly = () => !compile;
|
---|
7925 | function finishComponentSetup(instance, isSSR, skipOptions) {
|
---|
7926 | const Component = instance.type;
|
---|
7927 | if (!instance.render) {
|
---|
7928 | if (!isSSR && compile && !Component.render) {
|
---|
7929 | const template = Component.template || resolveMergedOptions(instance).template;
|
---|
7930 | if (template) {
|
---|
7931 | {
|
---|
7932 | startMeasure(instance, `compile`);
|
---|
7933 | }
|
---|
7934 | const { isCustomElement, compilerOptions } = instance.appContext.config;
|
---|
7935 | const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
---|
7936 | const finalCompilerOptions = shared.extend(
|
---|
7937 | shared.extend(
|
---|
7938 | {
|
---|
7939 | isCustomElement,
|
---|
7940 | delimiters
|
---|
7941 | },
|
---|
7942 | compilerOptions
|
---|
7943 | ),
|
---|
7944 | componentCompilerOptions
|
---|
7945 | );
|
---|
7946 | Component.render = compile(template, finalCompilerOptions);
|
---|
7947 | {
|
---|
7948 | endMeasure(instance, `compile`);
|
---|
7949 | }
|
---|
7950 | }
|
---|
7951 | }
|
---|
7952 | instance.render = Component.render || shared.NOOP;
|
---|
7953 | if (installWithProxy) {
|
---|
7954 | installWithProxy(instance);
|
---|
7955 | }
|
---|
7956 | }
|
---|
7957 | {
|
---|
7958 | const reset = setCurrentInstance(instance);
|
---|
7959 | reactivity.pauseTracking();
|
---|
7960 | try {
|
---|
7961 | applyOptions(instance);
|
---|
7962 | } finally {
|
---|
7963 | reactivity.resetTracking();
|
---|
7964 | reset();
|
---|
7965 | }
|
---|
7966 | }
|
---|
7967 | if (!Component.render && instance.render === shared.NOOP && !isSSR) {
|
---|
7968 | if (!compile && Component.template) {
|
---|
7969 | warn$1(
|
---|
7970 | `Component provided template option but runtime compilation is not supported in this build of Vue.` + (``)
|
---|
7971 | );
|
---|
7972 | } else {
|
---|
7973 | warn$1(`Component is missing template or render function: `, Component);
|
---|
7974 | }
|
---|
7975 | }
|
---|
7976 | }
|
---|
7977 | const attrsProxyHandlers = {
|
---|
7978 | get(target, key) {
|
---|
7979 | markAttrsAccessed();
|
---|
7980 | reactivity.track(target, "get", "");
|
---|
7981 | return target[key];
|
---|
7982 | },
|
---|
7983 | set() {
|
---|
7984 | warn$1(`setupContext.attrs is readonly.`);
|
---|
7985 | return false;
|
---|
7986 | },
|
---|
7987 | deleteProperty() {
|
---|
7988 | warn$1(`setupContext.attrs is readonly.`);
|
---|
7989 | return false;
|
---|
7990 | }
|
---|
7991 | } ;
|
---|
7992 | function getSlotsProxy(instance) {
|
---|
7993 | return new Proxy(instance.slots, {
|
---|
7994 | get(target, key) {
|
---|
7995 | reactivity.track(instance, "get", "$slots");
|
---|
7996 | return target[key];
|
---|
7997 | }
|
---|
7998 | });
|
---|
7999 | }
|
---|
8000 | function createSetupContext(instance) {
|
---|
8001 | const expose = (exposed) => {
|
---|
8002 | {
|
---|
8003 | if (instance.exposed) {
|
---|
8004 | warn$1(`expose() should be called only once per setup().`);
|
---|
8005 | }
|
---|
8006 | if (exposed != null) {
|
---|
8007 | let exposedType = typeof exposed;
|
---|
8008 | if (exposedType === "object") {
|
---|
8009 | if (shared.isArray(exposed)) {
|
---|
8010 | exposedType = "array";
|
---|
8011 | } else if (reactivity.isRef(exposed)) {
|
---|
8012 | exposedType = "ref";
|
---|
8013 | }
|
---|
8014 | }
|
---|
8015 | if (exposedType !== "object") {
|
---|
8016 | warn$1(
|
---|
8017 | `expose() should be passed a plain object, received ${exposedType}.`
|
---|
8018 | );
|
---|
8019 | }
|
---|
8020 | }
|
---|
8021 | }
|
---|
8022 | instance.exposed = exposed || {};
|
---|
8023 | };
|
---|
8024 | {
|
---|
8025 | let attrsProxy;
|
---|
8026 | let slotsProxy;
|
---|
8027 | return Object.freeze({
|
---|
8028 | get attrs() {
|
---|
8029 | return attrsProxy || (attrsProxy = new Proxy(instance.attrs, attrsProxyHandlers));
|
---|
8030 | },
|
---|
8031 | get slots() {
|
---|
8032 | return slotsProxy || (slotsProxy = getSlotsProxy(instance));
|
---|
8033 | },
|
---|
8034 | get emit() {
|
---|
8035 | return (event, ...args) => instance.emit(event, ...args);
|
---|
8036 | },
|
---|
8037 | expose
|
---|
8038 | });
|
---|
8039 | }
|
---|
8040 | }
|
---|
8041 | function getComponentPublicInstance(instance) {
|
---|
8042 | if (instance.exposed) {
|
---|
8043 | return instance.exposeProxy || (instance.exposeProxy = new Proxy(reactivity.proxyRefs(reactivity.markRaw(instance.exposed)), {
|
---|
8044 | get(target, key) {
|
---|
8045 | if (key in target) {
|
---|
8046 | return target[key];
|
---|
8047 | } else if (key in publicPropertiesMap) {
|
---|
8048 | return publicPropertiesMap[key](instance);
|
---|
8049 | }
|
---|
8050 | },
|
---|
8051 | has(target, key) {
|
---|
8052 | return key in target || key in publicPropertiesMap;
|
---|
8053 | }
|
---|
8054 | }));
|
---|
8055 | } else {
|
---|
8056 | return instance.proxy;
|
---|
8057 | }
|
---|
8058 | }
|
---|
8059 | const classifyRE = /(?:^|[-_])(\w)/g;
|
---|
8060 | const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
---|
8061 | function getComponentName(Component, includeInferred = true) {
|
---|
8062 | return shared.isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
---|
8063 | }
|
---|
8064 | function formatComponentName(instance, Component, isRoot = false) {
|
---|
8065 | let name = getComponentName(Component);
|
---|
8066 | if (!name && Component.__file) {
|
---|
8067 | const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
---|
8068 | if (match) {
|
---|
8069 | name = match[1];
|
---|
8070 | }
|
---|
8071 | }
|
---|
8072 | if (!name && instance && instance.parent) {
|
---|
8073 | const inferFromRegistry = (registry) => {
|
---|
8074 | for (const key in registry) {
|
---|
8075 | if (registry[key] === Component) {
|
---|
8076 | return key;
|
---|
8077 | }
|
---|
8078 | }
|
---|
8079 | };
|
---|
8080 | name = inferFromRegistry(
|
---|
8081 | instance.components || instance.parent.type.components
|
---|
8082 | ) || inferFromRegistry(instance.appContext.components);
|
---|
8083 | }
|
---|
8084 | return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
---|
8085 | }
|
---|
8086 | function isClassComponent(value) {
|
---|
8087 | return shared.isFunction(value) && "__vccOpts" in value;
|
---|
8088 | }
|
---|
8089 |
|
---|
8090 | const computed = (getterOrOptions, debugOptions) => {
|
---|
8091 | const c = reactivity.computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
---|
8092 | {
|
---|
8093 | const i = getCurrentInstance();
|
---|
8094 | if (i && i.appContext.config.warnRecursiveComputed) {
|
---|
8095 | c._warnRecursive = true;
|
---|
8096 | }
|
---|
8097 | }
|
---|
8098 | return c;
|
---|
8099 | };
|
---|
8100 |
|
---|
8101 | function h(type, propsOrChildren, children) {
|
---|
8102 | const l = arguments.length;
|
---|
8103 | if (l === 2) {
|
---|
8104 | if (shared.isObject(propsOrChildren) && !shared.isArray(propsOrChildren)) {
|
---|
8105 | if (isVNode(propsOrChildren)) {
|
---|
8106 | return createVNode(type, null, [propsOrChildren]);
|
---|
8107 | }
|
---|
8108 | return createVNode(type, propsOrChildren);
|
---|
8109 | } else {
|
---|
8110 | return createVNode(type, null, propsOrChildren);
|
---|
8111 | }
|
---|
8112 | } else {
|
---|
8113 | if (l > 3) {
|
---|
8114 | children = Array.prototype.slice.call(arguments, 2);
|
---|
8115 | } else if (l === 3 && isVNode(children)) {
|
---|
8116 | children = [children];
|
---|
8117 | }
|
---|
8118 | return createVNode(type, propsOrChildren, children);
|
---|
8119 | }
|
---|
8120 | }
|
---|
8121 |
|
---|
8122 | function initCustomFormatter() {
|
---|
8123 | if (typeof window === "undefined") {
|
---|
8124 | return;
|
---|
8125 | }
|
---|
8126 | const vueStyle = { style: "color:#3ba776" };
|
---|
8127 | const numberStyle = { style: "color:#1677ff" };
|
---|
8128 | const stringStyle = { style: "color:#f5222d" };
|
---|
8129 | const keywordStyle = { style: "color:#eb2f96" };
|
---|
8130 | const formatter = {
|
---|
8131 | __vue_custom_formatter: true,
|
---|
8132 | header(obj) {
|
---|
8133 | if (!shared.isObject(obj)) {
|
---|
8134 | return null;
|
---|
8135 | }
|
---|
8136 | if (obj.__isVue) {
|
---|
8137 | return ["div", vueStyle, `VueInstance`];
|
---|
8138 | } else if (reactivity.isRef(obj)) {
|
---|
8139 | return [
|
---|
8140 | "div",
|
---|
8141 | {},
|
---|
8142 | ["span", vueStyle, genRefFlag(obj)],
|
---|
8143 | "<",
|
---|
8144 | // avoid debugger accessing value affecting behavior
|
---|
8145 | formatValue("_value" in obj ? obj._value : obj),
|
---|
8146 | `>`
|
---|
8147 | ];
|
---|
8148 | } else if (reactivity.isReactive(obj)) {
|
---|
8149 | return [
|
---|
8150 | "div",
|
---|
8151 | {},
|
---|
8152 | ["span", vueStyle, reactivity.isShallow(obj) ? "ShallowReactive" : "Reactive"],
|
---|
8153 | "<",
|
---|
8154 | formatValue(obj),
|
---|
8155 | `>${reactivity.isReadonly(obj) ? ` (readonly)` : ``}`
|
---|
8156 | ];
|
---|
8157 | } else if (reactivity.isReadonly(obj)) {
|
---|
8158 | return [
|
---|
8159 | "div",
|
---|
8160 | {},
|
---|
8161 | ["span", vueStyle, reactivity.isShallow(obj) ? "ShallowReadonly" : "Readonly"],
|
---|
8162 | "<",
|
---|
8163 | formatValue(obj),
|
---|
8164 | ">"
|
---|
8165 | ];
|
---|
8166 | }
|
---|
8167 | return null;
|
---|
8168 | },
|
---|
8169 | hasBody(obj) {
|
---|
8170 | return obj && obj.__isVue;
|
---|
8171 | },
|
---|
8172 | body(obj) {
|
---|
8173 | if (obj && obj.__isVue) {
|
---|
8174 | return [
|
---|
8175 | "div",
|
---|
8176 | {},
|
---|
8177 | ...formatInstance(obj.$)
|
---|
8178 | ];
|
---|
8179 | }
|
---|
8180 | }
|
---|
8181 | };
|
---|
8182 | function formatInstance(instance) {
|
---|
8183 | const blocks = [];
|
---|
8184 | if (instance.type.props && instance.props) {
|
---|
8185 | blocks.push(createInstanceBlock("props", reactivity.toRaw(instance.props)));
|
---|
8186 | }
|
---|
8187 | if (instance.setupState !== shared.EMPTY_OBJ) {
|
---|
8188 | blocks.push(createInstanceBlock("setup", instance.setupState));
|
---|
8189 | }
|
---|
8190 | if (instance.data !== shared.EMPTY_OBJ) {
|
---|
8191 | blocks.push(createInstanceBlock("data", reactivity.toRaw(instance.data)));
|
---|
8192 | }
|
---|
8193 | const computed = extractKeys(instance, "computed");
|
---|
8194 | if (computed) {
|
---|
8195 | blocks.push(createInstanceBlock("computed", computed));
|
---|
8196 | }
|
---|
8197 | const injected = extractKeys(instance, "inject");
|
---|
8198 | if (injected) {
|
---|
8199 | blocks.push(createInstanceBlock("injected", injected));
|
---|
8200 | }
|
---|
8201 | blocks.push([
|
---|
8202 | "div",
|
---|
8203 | {},
|
---|
8204 | [
|
---|
8205 | "span",
|
---|
8206 | {
|
---|
8207 | style: keywordStyle.style + ";opacity:0.66"
|
---|
8208 | },
|
---|
8209 | "$ (internal): "
|
---|
8210 | ],
|
---|
8211 | ["object", { object: instance }]
|
---|
8212 | ]);
|
---|
8213 | return blocks;
|
---|
8214 | }
|
---|
8215 | function createInstanceBlock(type, target) {
|
---|
8216 | target = shared.extend({}, target);
|
---|
8217 | if (!Object.keys(target).length) {
|
---|
8218 | return ["span", {}];
|
---|
8219 | }
|
---|
8220 | return [
|
---|
8221 | "div",
|
---|
8222 | { style: "line-height:1.25em;margin-bottom:0.6em" },
|
---|
8223 | [
|
---|
8224 | "div",
|
---|
8225 | {
|
---|
8226 | style: "color:#476582"
|
---|
8227 | },
|
---|
8228 | type
|
---|
8229 | ],
|
---|
8230 | [
|
---|
8231 | "div",
|
---|
8232 | {
|
---|
8233 | style: "padding-left:1.25em"
|
---|
8234 | },
|
---|
8235 | ...Object.keys(target).map((key) => {
|
---|
8236 | return [
|
---|
8237 | "div",
|
---|
8238 | {},
|
---|
8239 | ["span", keywordStyle, key + ": "],
|
---|
8240 | formatValue(target[key], false)
|
---|
8241 | ];
|
---|
8242 | })
|
---|
8243 | ]
|
---|
8244 | ];
|
---|
8245 | }
|
---|
8246 | function formatValue(v, asRaw = true) {
|
---|
8247 | if (typeof v === "number") {
|
---|
8248 | return ["span", numberStyle, v];
|
---|
8249 | } else if (typeof v === "string") {
|
---|
8250 | return ["span", stringStyle, JSON.stringify(v)];
|
---|
8251 | } else if (typeof v === "boolean") {
|
---|
8252 | return ["span", keywordStyle, v];
|
---|
8253 | } else if (shared.isObject(v)) {
|
---|
8254 | return ["object", { object: asRaw ? reactivity.toRaw(v) : v }];
|
---|
8255 | } else {
|
---|
8256 | return ["span", stringStyle, String(v)];
|
---|
8257 | }
|
---|
8258 | }
|
---|
8259 | function extractKeys(instance, type) {
|
---|
8260 | const Comp = instance.type;
|
---|
8261 | if (shared.isFunction(Comp)) {
|
---|
8262 | return;
|
---|
8263 | }
|
---|
8264 | const extracted = {};
|
---|
8265 | for (const key in instance.ctx) {
|
---|
8266 | if (isKeyOfType(Comp, key, type)) {
|
---|
8267 | extracted[key] = instance.ctx[key];
|
---|
8268 | }
|
---|
8269 | }
|
---|
8270 | return extracted;
|
---|
8271 | }
|
---|
8272 | function isKeyOfType(Comp, key, type) {
|
---|
8273 | const opts = Comp[type];
|
---|
8274 | if (shared.isArray(opts) && opts.includes(key) || shared.isObject(opts) && key in opts) {
|
---|
8275 | return true;
|
---|
8276 | }
|
---|
8277 | if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
|
---|
8278 | return true;
|
---|
8279 | }
|
---|
8280 | if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
|
---|
8281 | return true;
|
---|
8282 | }
|
---|
8283 | }
|
---|
8284 | function genRefFlag(v) {
|
---|
8285 | if (reactivity.isShallow(v)) {
|
---|
8286 | return `ShallowRef`;
|
---|
8287 | }
|
---|
8288 | if (v.effect) {
|
---|
8289 | return `ComputedRef`;
|
---|
8290 | }
|
---|
8291 | return `Ref`;
|
---|
8292 | }
|
---|
8293 | if (window.devtoolsFormatters) {
|
---|
8294 | window.devtoolsFormatters.push(formatter);
|
---|
8295 | } else {
|
---|
8296 | window.devtoolsFormatters = [formatter];
|
---|
8297 | }
|
---|
8298 | }
|
---|
8299 |
|
---|
8300 | function withMemo(memo, render, cache, index) {
|
---|
8301 | const cached = cache[index];
|
---|
8302 | if (cached && isMemoSame(cached, memo)) {
|
---|
8303 | return cached;
|
---|
8304 | }
|
---|
8305 | const ret = render();
|
---|
8306 | ret.memo = memo.slice();
|
---|
8307 | ret.cacheIndex = index;
|
---|
8308 | return cache[index] = ret;
|
---|
8309 | }
|
---|
8310 | function isMemoSame(cached, memo) {
|
---|
8311 | const prev = cached.memo;
|
---|
8312 | if (prev.length != memo.length) {
|
---|
8313 | return false;
|
---|
8314 | }
|
---|
8315 | for (let i = 0; i < prev.length; i++) {
|
---|
8316 | if (shared.hasChanged(prev[i], memo[i])) {
|
---|
8317 | return false;
|
---|
8318 | }
|
---|
8319 | }
|
---|
8320 | if (isBlockTreeEnabled > 0 && currentBlock) {
|
---|
8321 | currentBlock.push(cached);
|
---|
8322 | }
|
---|
8323 | return true;
|
---|
8324 | }
|
---|
8325 |
|
---|
8326 | const version = "3.5.13";
|
---|
8327 | const warn = warn$1 ;
|
---|
8328 | const ErrorTypeStrings = ErrorTypeStrings$1 ;
|
---|
8329 | const devtools = devtools$1 ;
|
---|
8330 | const setDevtoolsHook = setDevtoolsHook$1 ;
|
---|
8331 | const _ssrUtils = {
|
---|
8332 | createComponentInstance,
|
---|
8333 | setupComponent,
|
---|
8334 | renderComponentRoot,
|
---|
8335 | setCurrentRenderingInstance,
|
---|
8336 | isVNode: isVNode,
|
---|
8337 | normalizeVNode,
|
---|
8338 | getComponentPublicInstance,
|
---|
8339 | ensureValidVNode,
|
---|
8340 | pushWarningContext,
|
---|
8341 | popWarningContext
|
---|
8342 | };
|
---|
8343 | const ssrUtils = _ssrUtils ;
|
---|
8344 | const resolveFilter = null;
|
---|
8345 | const compatUtils = null;
|
---|
8346 | const DeprecationTypes = null;
|
---|
8347 |
|
---|
8348 | exports.EffectScope = reactivity.EffectScope;
|
---|
8349 | exports.ReactiveEffect = reactivity.ReactiveEffect;
|
---|
8350 | exports.TrackOpTypes = reactivity.TrackOpTypes;
|
---|
8351 | exports.TriggerOpTypes = reactivity.TriggerOpTypes;
|
---|
8352 | exports.customRef = reactivity.customRef;
|
---|
8353 | exports.effect = reactivity.effect;
|
---|
8354 | exports.effectScope = reactivity.effectScope;
|
---|
8355 | exports.getCurrentScope = reactivity.getCurrentScope;
|
---|
8356 | exports.getCurrentWatcher = reactivity.getCurrentWatcher;
|
---|
8357 | exports.isProxy = reactivity.isProxy;
|
---|
8358 | exports.isReactive = reactivity.isReactive;
|
---|
8359 | exports.isReadonly = reactivity.isReadonly;
|
---|
8360 | exports.isRef = reactivity.isRef;
|
---|
8361 | exports.isShallow = reactivity.isShallow;
|
---|
8362 | exports.markRaw = reactivity.markRaw;
|
---|
8363 | exports.onScopeDispose = reactivity.onScopeDispose;
|
---|
8364 | exports.onWatcherCleanup = reactivity.onWatcherCleanup;
|
---|
8365 | exports.proxyRefs = reactivity.proxyRefs;
|
---|
8366 | exports.reactive = reactivity.reactive;
|
---|
8367 | exports.readonly = reactivity.readonly;
|
---|
8368 | exports.ref = reactivity.ref;
|
---|
8369 | exports.shallowReactive = reactivity.shallowReactive;
|
---|
8370 | exports.shallowReadonly = reactivity.shallowReadonly;
|
---|
8371 | exports.shallowRef = reactivity.shallowRef;
|
---|
8372 | exports.stop = reactivity.stop;
|
---|
8373 | exports.toRaw = reactivity.toRaw;
|
---|
8374 | exports.toRef = reactivity.toRef;
|
---|
8375 | exports.toRefs = reactivity.toRefs;
|
---|
8376 | exports.toValue = reactivity.toValue;
|
---|
8377 | exports.triggerRef = reactivity.triggerRef;
|
---|
8378 | exports.unref = reactivity.unref;
|
---|
8379 | exports.camelize = shared.camelize;
|
---|
8380 | exports.capitalize = shared.capitalize;
|
---|
8381 | exports.normalizeClass = shared.normalizeClass;
|
---|
8382 | exports.normalizeProps = shared.normalizeProps;
|
---|
8383 | exports.normalizeStyle = shared.normalizeStyle;
|
---|
8384 | exports.toDisplayString = shared.toDisplayString;
|
---|
8385 | exports.toHandlerKey = shared.toHandlerKey;
|
---|
8386 | exports.BaseTransition = BaseTransition;
|
---|
8387 | exports.BaseTransitionPropsValidators = BaseTransitionPropsValidators;
|
---|
8388 | exports.Comment = Comment;
|
---|
8389 | exports.DeprecationTypes = DeprecationTypes;
|
---|
8390 | exports.ErrorCodes = ErrorCodes;
|
---|
8391 | exports.ErrorTypeStrings = ErrorTypeStrings;
|
---|
8392 | exports.Fragment = Fragment;
|
---|
8393 | exports.KeepAlive = KeepAlive;
|
---|
8394 | exports.Static = Static;
|
---|
8395 | exports.Suspense = Suspense;
|
---|
8396 | exports.Teleport = Teleport;
|
---|
8397 | exports.Text = Text;
|
---|
8398 | exports.assertNumber = assertNumber;
|
---|
8399 | exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
|
---|
8400 | exports.callWithErrorHandling = callWithErrorHandling;
|
---|
8401 | exports.cloneVNode = cloneVNode;
|
---|
8402 | exports.compatUtils = compatUtils;
|
---|
8403 | exports.computed = computed;
|
---|
8404 | exports.createBlock = createBlock;
|
---|
8405 | exports.createCommentVNode = createCommentVNode;
|
---|
8406 | exports.createElementBlock = createElementBlock;
|
---|
8407 | exports.createElementVNode = createBaseVNode;
|
---|
8408 | exports.createHydrationRenderer = createHydrationRenderer;
|
---|
8409 | exports.createPropsRestProxy = createPropsRestProxy;
|
---|
8410 | exports.createRenderer = createRenderer;
|
---|
8411 | exports.createSlots = createSlots;
|
---|
8412 | exports.createStaticVNode = createStaticVNode;
|
---|
8413 | exports.createTextVNode = createTextVNode;
|
---|
8414 | exports.createVNode = createVNode;
|
---|
8415 | exports.defineAsyncComponent = defineAsyncComponent;
|
---|
8416 | exports.defineComponent = defineComponent;
|
---|
8417 | exports.defineEmits = defineEmits;
|
---|
8418 | exports.defineExpose = defineExpose;
|
---|
8419 | exports.defineModel = defineModel;
|
---|
8420 | exports.defineOptions = defineOptions;
|
---|
8421 | exports.defineProps = defineProps;
|
---|
8422 | exports.defineSlots = defineSlots;
|
---|
8423 | exports.devtools = devtools;
|
---|
8424 | exports.getCurrentInstance = getCurrentInstance;
|
---|
8425 | exports.getTransitionRawChildren = getTransitionRawChildren;
|
---|
8426 | exports.guardReactiveProps = guardReactiveProps;
|
---|
8427 | exports.h = h;
|
---|
8428 | exports.handleError = handleError;
|
---|
8429 | exports.hasInjectionContext = hasInjectionContext;
|
---|
8430 | exports.hydrateOnIdle = hydrateOnIdle;
|
---|
8431 | exports.hydrateOnInteraction = hydrateOnInteraction;
|
---|
8432 | exports.hydrateOnMediaQuery = hydrateOnMediaQuery;
|
---|
8433 | exports.hydrateOnVisible = hydrateOnVisible;
|
---|
8434 | exports.initCustomFormatter = initCustomFormatter;
|
---|
8435 | exports.inject = inject;
|
---|
8436 | exports.isMemoSame = isMemoSame;
|
---|
8437 | exports.isRuntimeOnly = isRuntimeOnly;
|
---|
8438 | exports.isVNode = isVNode;
|
---|
8439 | exports.mergeDefaults = mergeDefaults;
|
---|
8440 | exports.mergeModels = mergeModels;
|
---|
8441 | exports.mergeProps = mergeProps;
|
---|
8442 | exports.nextTick = nextTick;
|
---|
8443 | exports.onActivated = onActivated;
|
---|
8444 | exports.onBeforeMount = onBeforeMount;
|
---|
8445 | exports.onBeforeUnmount = onBeforeUnmount;
|
---|
8446 | exports.onBeforeUpdate = onBeforeUpdate;
|
---|
8447 | exports.onDeactivated = onDeactivated;
|
---|
8448 | exports.onErrorCaptured = onErrorCaptured;
|
---|
8449 | exports.onMounted = onMounted;
|
---|
8450 | exports.onRenderTracked = onRenderTracked;
|
---|
8451 | exports.onRenderTriggered = onRenderTriggered;
|
---|
8452 | exports.onServerPrefetch = onServerPrefetch;
|
---|
8453 | exports.onUnmounted = onUnmounted;
|
---|
8454 | exports.onUpdated = onUpdated;
|
---|
8455 | exports.openBlock = openBlock;
|
---|
8456 | exports.popScopeId = popScopeId;
|
---|
8457 | exports.provide = provide;
|
---|
8458 | exports.pushScopeId = pushScopeId;
|
---|
8459 | exports.queuePostFlushCb = queuePostFlushCb;
|
---|
8460 | exports.registerRuntimeCompiler = registerRuntimeCompiler;
|
---|
8461 | exports.renderList = renderList;
|
---|
8462 | exports.renderSlot = renderSlot;
|
---|
8463 | exports.resolveComponent = resolveComponent;
|
---|
8464 | exports.resolveDirective = resolveDirective;
|
---|
8465 | exports.resolveDynamicComponent = resolveDynamicComponent;
|
---|
8466 | exports.resolveFilter = resolveFilter;
|
---|
8467 | exports.resolveTransitionHooks = resolveTransitionHooks;
|
---|
8468 | exports.setBlockTracking = setBlockTracking;
|
---|
8469 | exports.setDevtoolsHook = setDevtoolsHook;
|
---|
8470 | exports.setTransitionHooks = setTransitionHooks;
|
---|
8471 | exports.ssrContextKey = ssrContextKey;
|
---|
8472 | exports.ssrUtils = ssrUtils;
|
---|
8473 | exports.toHandlers = toHandlers;
|
---|
8474 | exports.transformVNodeArgs = transformVNodeArgs;
|
---|
8475 | exports.useAttrs = useAttrs;
|
---|
8476 | exports.useId = useId;
|
---|
8477 | exports.useModel = useModel;
|
---|
8478 | exports.useSSRContext = useSSRContext;
|
---|
8479 | exports.useSlots = useSlots;
|
---|
8480 | exports.useTemplateRef = useTemplateRef;
|
---|
8481 | exports.useTransitionState = useTransitionState;
|
---|
8482 | exports.version = version;
|
---|
8483 | exports.warn = warn;
|
---|
8484 | exports.watch = watch;
|
---|
8485 | exports.watchEffect = watchEffect;
|
---|
8486 | exports.watchPostEffect = watchPostEffect;
|
---|
8487 | exports.watchSyncEffect = watchSyncEffect;
|
---|
8488 | exports.withAsyncContext = withAsyncContext;
|
---|
8489 | exports.withCtx = withCtx;
|
---|
8490 | exports.withDefaults = withDefaults;
|
---|
8491 | exports.withDirectives = withDirectives;
|
---|
8492 | exports.withMemo = withMemo;
|
---|
8493 | exports.withScopeId = withScopeId;
|
---|