@vue/runtime-core 3.6.0-alpha.4 → 3.6.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-core v3.6.0-alpha.4
2
+ * @vue/runtime-core v3.6.0-alpha.6
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -10,9 +10,119 @@ Object.defineProperty(exports, '__esModule', { value: true });
10
10
  var reactivity = require('@vue/reactivity');
11
11
  var shared = require('@vue/shared');
12
12
 
13
+ const stack = [];
13
14
  function pushWarningContext(ctx) {
15
+ stack.push(ctx);
14
16
  }
15
17
  function popWarningContext() {
18
+ stack.pop();
19
+ }
20
+ let isWarning = false;
21
+ function warn$2(msg, ...args) {
22
+ if (isWarning) return;
23
+ isWarning = true;
24
+ const prevSub = reactivity.setActiveSub();
25
+ const entry = stack.length ? stack[stack.length - 1] : null;
26
+ const instance = isVNode(entry) ? entry.component : entry;
27
+ const appWarnHandler = instance && instance.appContext.config.warnHandler;
28
+ const trace = getComponentTrace();
29
+ if (appWarnHandler) {
30
+ callWithErrorHandling(
31
+ appWarnHandler,
32
+ instance,
33
+ 11,
34
+ [
35
+ // eslint-disable-next-line no-restricted-syntax
36
+ msg + args.map((a) => {
37
+ var _a, _b;
38
+ return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
39
+ }).join(""),
40
+ instance && instance.proxy || instance,
41
+ trace.map(
42
+ ({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`
43
+ ).join("\n"),
44
+ trace
45
+ ]
46
+ );
47
+ } else {
48
+ const warnArgs = [`[Vue warn]: ${msg}`, ...args];
49
+ if (trace.length && // avoid spamming console during tests
50
+ true) {
51
+ warnArgs.push(`
52
+ `, ...formatTrace(trace));
53
+ }
54
+ console.warn(...warnArgs);
55
+ }
56
+ reactivity.setActiveSub(prevSub);
57
+ isWarning = false;
58
+ }
59
+ function getComponentTrace() {
60
+ let currentCtx = stack[stack.length - 1];
61
+ if (!currentCtx) {
62
+ return [];
63
+ }
64
+ const normalizedStack = [];
65
+ while (currentCtx) {
66
+ const last = normalizedStack[0];
67
+ if (last && last.ctx === currentCtx) {
68
+ last.recurseCount++;
69
+ } else {
70
+ normalizedStack.push({
71
+ ctx: currentCtx,
72
+ recurseCount: 0
73
+ });
74
+ }
75
+ if (isVNode(currentCtx)) {
76
+ const parent = currentCtx.component && currentCtx.component.parent;
77
+ currentCtx = parent && parent.vnode || parent;
78
+ } else {
79
+ currentCtx = currentCtx.parent;
80
+ }
81
+ }
82
+ return normalizedStack;
83
+ }
84
+ function formatTrace(trace) {
85
+ const logs = [];
86
+ trace.forEach((entry, i) => {
87
+ logs.push(...i === 0 ? [] : [`
88
+ `], ...formatTraceEntry(entry));
89
+ });
90
+ return logs;
91
+ }
92
+ function formatTraceEntry({ ctx, recurseCount }) {
93
+ const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
94
+ const instance = isVNode(ctx) ? ctx.component : ctx;
95
+ const isRoot = instance ? instance.parent == null : false;
96
+ const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`;
97
+ const close = `>` + postfix;
98
+ return ctx.props ? [open, ...formatProps(ctx.props), close] : [open + close];
99
+ }
100
+ function formatProps(props) {
101
+ const res = [];
102
+ const keys = Object.keys(props);
103
+ keys.slice(0, 3).forEach((key) => {
104
+ res.push(...formatProp(key, props[key]));
105
+ });
106
+ if (keys.length > 3) {
107
+ res.push(` ...`);
108
+ }
109
+ return res;
110
+ }
111
+ function formatProp(key, value, raw) {
112
+ if (shared.isString(value)) {
113
+ value = JSON.stringify(value);
114
+ return raw ? value : [`${key}=${value}`];
115
+ } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
116
+ return raw ? value : [`${key}=${value}`];
117
+ } else if (reactivity.isRef(value)) {
118
+ value = formatProp(key, reactivity.toRaw(value.value), true);
119
+ return raw ? value : [`${key}=Ref<`, value, `>`];
120
+ } else if (shared.isFunction(value)) {
121
+ return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
122
+ } else {
123
+ value = reactivity.toRaw(value);
124
+ return raw ? value : [`${key}=`, value];
125
+ }
16
126
  }
17
127
  function assertNumber(val, type) {
18
128
  return;
@@ -1444,7 +1554,8 @@ function createHydrationFunctions(rendererInternals) {
1444
1554
  node,
1445
1555
  container,
1446
1556
  null,
1447
- parentComponent
1557
+ parentComponent,
1558
+ parentSuspense
1448
1559
  );
1449
1560
  } else {
1450
1561
  mountComponent(
@@ -2616,7 +2727,6 @@ const PublicInstanceProxyHandlers = {
2616
2727
  return true;
2617
2728
  }
2618
2729
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
2619
- let normalizedProps;
2620
2730
  if (key[0] !== "$") {
2621
2731
  const n = accessCache[key];
2622
2732
  if (n !== void 0) {
@@ -2636,11 +2746,7 @@ const PublicInstanceProxyHandlers = {
2636
2746
  } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
2637
2747
  accessCache[key] = 2 /* DATA */;
2638
2748
  return data[key];
2639
- } else if (
2640
- // only cache other properties when instance has declared (thus stable)
2641
- // props
2642
- (normalizedProps = instance.propsOptions[0]) && shared.hasOwn(normalizedProps, key)
2643
- ) {
2749
+ } else if (shared.hasOwn(props, key)) {
2644
2750
  accessCache[key] = 3 /* PROPS */;
2645
2751
  return props[key];
2646
2752
  } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
@@ -2695,10 +2801,10 @@ const PublicInstanceProxyHandlers = {
2695
2801
  return true;
2696
2802
  },
2697
2803
  has({
2698
- _: { data, setupState, accessCache, ctx, appContext, propsOptions, type }
2804
+ _: { data, setupState, accessCache, ctx, appContext, props, type }
2699
2805
  }, key) {
2700
- let normalizedProps, cssModules;
2701
- return !!(accessCache[key] || data !== shared.EMPTY_OBJ && key[0] !== "$" && 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) || (cssModules = type.__cssModules) && cssModules[key]);
2806
+ let cssModules;
2807
+ return !!(accessCache[key] || data !== shared.EMPTY_OBJ && key[0] !== "$" && shared.hasOwn(data, key) || hasSetupBinding(setupState, key) || shared.hasOwn(props, key) || shared.hasOwn(ctx, key) || shared.hasOwn(publicPropertiesMap, key) || shared.hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]);
2702
2808
  },
2703
2809
  defineProperty(target, key, descriptor) {
2704
2810
  if (descriptor.get != null) {
@@ -3271,8 +3377,7 @@ function createAppAPI(mount, unmount, getPublicInstance, render) {
3271
3377
  let currentApp = null;
3272
3378
 
3273
3379
  function provide(key, value) {
3274
- const currentInstance = getCurrentGenericInstance();
3275
- if (!currentInstance) ; else {
3380
+ if (currentInstance) {
3276
3381
  let provides = currentInstance.provides;
3277
3382
  const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3278
3383
  if (parentProvides === provides) {
@@ -3296,2438 +3401,2468 @@ function hasInjectionContext() {
3296
3401
  return !!(getCurrentGenericInstance() || currentApp);
3297
3402
  }
3298
3403
 
3299
- const internalObjectProto = {};
3300
- const createInternalObject = () => Object.create(internalObjectProto);
3301
- const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
3302
-
3303
- function initProps(instance, rawProps, isStateful, isSSR = false) {
3304
- const props = instance.props = {};
3305
- const attrs = createInternalObject();
3306
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3307
- setFullProps(instance, rawProps, props, attrs);
3308
- for (const key in instance.propsOptions[0]) {
3309
- if (!(key in props)) {
3310
- props[key] = void 0;
3311
- }
3312
- }
3313
- if (isStateful) {
3314
- instance.props = isSSR ? props : reactivity.shallowReactive(props);
3315
- } else {
3316
- if (!instance.type.props) {
3317
- instance.props = attrs;
3318
- } else {
3319
- instance.props = props;
3320
- }
3404
+ const ssrContextKey = Symbol.for("v-scx");
3405
+ const useSSRContext = () => {
3406
+ {
3407
+ const ctx = inject(ssrContextKey);
3408
+ return ctx;
3321
3409
  }
3322
- instance.attrs = attrs;
3410
+ };
3411
+
3412
+ function watchEffect(effect, options) {
3413
+ return doWatch(effect, null, options);
3323
3414
  }
3324
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
3325
- const {
3326
- props,
3327
- attrs,
3328
- vnode: { patchFlag }
3329
- } = instance;
3330
- const rawCurrentProps = reactivity.toRaw(props);
3331
- const [options] = instance.propsOptions;
3332
- let hasAttrsChanged = false;
3333
- if (
3334
- // always force full diff in dev
3335
- // - #1942 if hmr is enabled with sfc component
3336
- // - vite#872 non-sfc component used by sfc component
3337
- (optimized || patchFlag > 0) && !(patchFlag & 16)
3338
- ) {
3339
- if (patchFlag & 8) {
3340
- const propsToUpdate = instance.vnode.dynamicProps;
3341
- for (let i = 0; i < propsToUpdate.length; i++) {
3342
- let key = propsToUpdate[i];
3343
- if (isEmitListener(instance.emitsOptions, key)) {
3344
- continue;
3345
- }
3346
- const value = rawProps[key];
3347
- if (options) {
3348
- if (shared.hasOwn(attrs, key)) {
3349
- if (value !== attrs[key]) {
3350
- attrs[key] = value;
3351
- hasAttrsChanged = true;
3352
- }
3353
- } else {
3354
- const camelizedKey = shared.camelize(key);
3355
- props[camelizedKey] = resolvePropValue(
3356
- options,
3357
- camelizedKey,
3358
- value,
3359
- instance,
3360
- baseResolveDefault
3361
- );
3362
- }
3363
- } else {
3364
- if (value !== attrs[key]) {
3365
- attrs[key] = value;
3366
- hasAttrsChanged = true;
3367
- }
3368
- }
3415
+ function watchPostEffect(effect, options) {
3416
+ return doWatch(
3417
+ effect,
3418
+ null,
3419
+ { flush: "post" }
3420
+ );
3421
+ }
3422
+ function watchSyncEffect(effect, options) {
3423
+ return doWatch(
3424
+ effect,
3425
+ null,
3426
+ { flush: "sync" }
3427
+ );
3428
+ }
3429
+ function watch(source, cb, options) {
3430
+ return doWatch(source, cb, options);
3431
+ }
3432
+ class RenderWatcherEffect extends reactivity.WatcherEffect {
3433
+ constructor(instance, source, cb, options, flush) {
3434
+ super(source, cb, options);
3435
+ this.flush = flush;
3436
+ const job = () => {
3437
+ if (this.dirty) {
3438
+ this.run();
3369
3439
  }
3440
+ };
3441
+ if (cb) {
3442
+ this.flags |= 128;
3443
+ job.flags |= 2;
3370
3444
  }
3371
- } else {
3372
- if (setFullProps(instance, rawProps, props, attrs)) {
3373
- hasAttrsChanged = true;
3374
- }
3375
- let kebabKey;
3376
- for (const key in rawCurrentProps) {
3377
- if (!rawProps || // for camelCase
3378
- !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
3379
- // and converted to camelCase (#955)
3380
- ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
3381
- if (options) {
3382
- if (rawPrevProps && // for camelCase
3383
- (rawPrevProps[key] !== void 0 || // for kebab-case
3384
- rawPrevProps[kebabKey] !== void 0)) {
3385
- props[key] = resolvePropValue(
3386
- options,
3387
- key,
3388
- void 0,
3389
- instance,
3390
- baseResolveDefault,
3391
- true
3392
- );
3393
- }
3394
- } else {
3395
- delete props[key];
3396
- }
3397
- }
3445
+ if (instance) {
3446
+ job.i = instance;
3398
3447
  }
3399
- if (attrs !== rawCurrentProps) {
3400
- for (const key in attrs) {
3401
- if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
3402
- delete attrs[key];
3403
- hasAttrsChanged = true;
3404
- }
3448
+ this.job = job;
3449
+ }
3450
+ notify() {
3451
+ const flags = this.flags;
3452
+ if (!(flags & 256)) {
3453
+ const flush = this.flush;
3454
+ const job = this.job;
3455
+ if (flush === "post") {
3456
+ queuePostRenderEffect(job, void 0, job.i ? job.i.suspense : null);
3457
+ } else if (flush === "pre") {
3458
+ queueJob(job, job.i ? job.i.uid : void 0, true);
3459
+ } else {
3460
+ job();
3405
3461
  }
3406
3462
  }
3407
3463
  }
3408
- if (hasAttrsChanged) {
3409
- reactivity.trigger(instance.attrs, "set", "");
3410
- }
3411
3464
  }
3412
- function setFullProps(instance, rawProps, props, attrs) {
3413
- const [options, needCastKeys] = instance.propsOptions;
3414
- let hasAttrsChanged = false;
3415
- let rawCastValues;
3416
- if (rawProps) {
3417
- for (let key in rawProps) {
3418
- if (shared.isReservedProp(key)) {
3419
- continue;
3420
- }
3421
- const value = rawProps[key];
3422
- let camelKey;
3423
- if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
3424
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
3425
- props[camelKey] = value;
3426
- } else {
3427
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
3428
- }
3429
- } else if (!isEmitListener(instance.emitsOptions, key)) {
3430
- if (!(key in attrs) || value !== attrs[key]) {
3431
- attrs[key] = value;
3432
- hasAttrsChanged = true;
3433
- }
3434
- }
3465
+ function doWatch(source, cb, options = shared.EMPTY_OBJ) {
3466
+ const { immediate, deep, flush = "pre", once } = options;
3467
+ const baseWatchOptions = shared.extend({}, options);
3468
+ const runsImmediately = cb && immediate || !cb && flush !== "post";
3469
+ let ssrCleanup;
3470
+ if (isInSSRComponentSetup) {
3471
+ if (flush === "sync") {
3472
+ const ctx = useSSRContext();
3473
+ ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
3474
+ } else if (!runsImmediately) {
3475
+ const watchStopHandle = () => {
3476
+ };
3477
+ watchStopHandle.stop = shared.NOOP;
3478
+ watchStopHandle.resume = shared.NOOP;
3479
+ watchStopHandle.pause = shared.NOOP;
3480
+ return watchStopHandle;
3435
3481
  }
3436
3482
  }
3437
- if (needCastKeys) {
3438
- const castValues = rawCastValues || shared.EMPTY_OBJ;
3439
- for (let i = 0; i < needCastKeys.length; i++) {
3440
- const key = needCastKeys[i];
3441
- props[key] = resolvePropValue(
3442
- options,
3443
- key,
3444
- castValues[key],
3445
- instance,
3446
- baseResolveDefault,
3447
- !shared.hasOwn(castValues, key)
3448
- );
3483
+ const instance = currentInstance;
3484
+ baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
3485
+ const effect = new RenderWatcherEffect(
3486
+ instance,
3487
+ source,
3488
+ cb,
3489
+ baseWatchOptions,
3490
+ flush
3491
+ );
3492
+ if (cb) {
3493
+ effect.run(true);
3494
+ } else if (flush === "post") {
3495
+ queuePostRenderEffect(effect.job, void 0, instance && instance.suspense);
3496
+ } else {
3497
+ effect.run(true);
3498
+ }
3499
+ const stop = effect.stop.bind(effect);
3500
+ stop.pause = effect.pause.bind(effect);
3501
+ stop.resume = effect.resume.bind(effect);
3502
+ stop.stop = stop;
3503
+ if (isInSSRComponentSetup) {
3504
+ if (ssrCleanup) {
3505
+ ssrCleanup.push(stop);
3506
+ } else if (runsImmediately) {
3507
+ stop();
3449
3508
  }
3450
3509
  }
3451
- return hasAttrsChanged;
3510
+ return stop;
3452
3511
  }
3453
- function resolvePropValue(options, key, value, instance, resolveDefault, isAbsent = false) {
3454
- const opt = options[key];
3455
- if (opt != null) {
3456
- const hasDefault = shared.hasOwn(opt, "default");
3457
- if (hasDefault && value === void 0) {
3458
- const defaultValue = opt.default;
3459
- if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
3460
- const cachedDefaults = instance.propsDefaults || (instance.propsDefaults = {});
3461
- if (shared.hasOwn(cachedDefaults, key)) {
3462
- value = cachedDefaults[key];
3512
+ function instanceWatch(source, value, options) {
3513
+ const publicThis = this.proxy;
3514
+ const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
3515
+ let cb;
3516
+ if (shared.isFunction(value)) {
3517
+ cb = value;
3518
+ } else {
3519
+ cb = value.handler;
3520
+ options = value;
3521
+ }
3522
+ const prev = setCurrentInstance(this);
3523
+ const res = doWatch(getter, cb.bind(publicThis), options);
3524
+ setCurrentInstance(...prev);
3525
+ return res;
3526
+ }
3527
+ function createPathGetter(ctx, path) {
3528
+ const segments = path.split(".");
3529
+ return () => {
3530
+ let cur = ctx;
3531
+ for (let i = 0; i < segments.length && cur; i++) {
3532
+ cur = cur[segments[i]];
3533
+ }
3534
+ return cur;
3535
+ };
3536
+ }
3537
+
3538
+ function useModel(props, name, options = shared.EMPTY_OBJ) {
3539
+ const i = getCurrentGenericInstance();
3540
+ const camelizedName = shared.camelize(name);
3541
+ const hyphenatedName = shared.hyphenate(name);
3542
+ const modifiers = getModelModifiers(props, camelizedName, defaultPropGetter);
3543
+ const res = reactivity.customRef((track, trigger) => {
3544
+ let localValue;
3545
+ let prevSetValue = shared.EMPTY_OBJ;
3546
+ let prevEmittedValue;
3547
+ watchSyncEffect(() => {
3548
+ const propValue = props[camelizedName];
3549
+ if (shared.hasChanged(localValue, propValue)) {
3550
+ localValue = propValue;
3551
+ trigger();
3552
+ }
3553
+ });
3554
+ return {
3555
+ get() {
3556
+ track();
3557
+ return options.get ? options.get(localValue) : localValue;
3558
+ },
3559
+ set(value) {
3560
+ const emittedValue = options.set ? options.set(value) : value;
3561
+ if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
3562
+ return;
3563
+ }
3564
+ let rawPropKeys;
3565
+ let parentPassedModelValue = false;
3566
+ let parentPassedModelUpdater = false;
3567
+ if (i.rawKeys) {
3568
+ rawPropKeys = i.rawKeys();
3463
3569
  } else {
3464
- value = cachedDefaults[key] = resolveDefault(
3465
- defaultValue,
3466
- instance,
3467
- key
3468
- );
3570
+ const rawProps = i.vnode.props;
3571
+ rawPropKeys = rawProps && Object.keys(rawProps);
3469
3572
  }
3470
- } else {
3471
- value = defaultValue;
3573
+ if (rawPropKeys) {
3574
+ for (const key of rawPropKeys) {
3575
+ if (key === name || key === camelizedName || key === hyphenatedName) {
3576
+ parentPassedModelValue = true;
3577
+ } else if (key === `onUpdate:${name}` || key === `onUpdate:${camelizedName}` || key === `onUpdate:${hyphenatedName}`) {
3578
+ parentPassedModelUpdater = true;
3579
+ }
3580
+ }
3581
+ }
3582
+ if (!parentPassedModelValue || !parentPassedModelUpdater) {
3583
+ localValue = value;
3584
+ trigger();
3585
+ }
3586
+ i.emit(`update:${name}`, emittedValue);
3587
+ if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
3588
+ trigger();
3589
+ }
3590
+ prevSetValue = value;
3591
+ prevEmittedValue = emittedValue;
3472
3592
  }
3473
- if (instance.ce) {
3474
- instance.ce._setProp(key, value);
3593
+ };
3594
+ });
3595
+ res[Symbol.iterator] = () => {
3596
+ let i2 = 0;
3597
+ return {
3598
+ next() {
3599
+ if (i2 < 2) {
3600
+ return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
3601
+ } else {
3602
+ return { done: true };
3603
+ }
3475
3604
  }
3605
+ };
3606
+ };
3607
+ return res;
3608
+ }
3609
+ const getModelModifiers = (props, modelName, getter) => {
3610
+ return getter(props, shared.getModifierPropName(modelName)) || getter(props, `${shared.camelize(modelName)}Modifiers`) || getter(props, `${shared.hyphenate(modelName)}Modifiers`);
3611
+ };
3612
+
3613
+ function emit(instance, event, ...rawArgs) {
3614
+ return baseEmit(
3615
+ instance,
3616
+ instance.vnode.props || shared.EMPTY_OBJ,
3617
+ defaultPropGetter,
3618
+ event,
3619
+ ...rawArgs
3620
+ );
3621
+ }
3622
+ function baseEmit(instance, props, getter, event, ...rawArgs) {
3623
+ if (instance.isUnmounted) return;
3624
+ let args = rawArgs;
3625
+ const isModelListener = event.startsWith("update:");
3626
+ const modifiers = isModelListener && getModelModifiers(props, event.slice(7), getter);
3627
+ if (modifiers) {
3628
+ if (modifiers.trim) {
3629
+ args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
3476
3630
  }
3477
- if (opt[0 /* shouldCast */]) {
3478
- if (isAbsent && !hasDefault) {
3479
- value = false;
3480
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
3481
- value = true;
3482
- }
3631
+ if (modifiers.number) {
3632
+ args = rawArgs.map(shared.looseToNumber);
3483
3633
  }
3484
3634
  }
3485
- return value;
3635
+ let handlerName;
3636
+ let handler = getter(props, handlerName = shared.toHandlerKey(event)) || // also try camelCase event handler (#2249)
3637
+ getter(props, handlerName = shared.toHandlerKey(shared.camelize(event)));
3638
+ if (!handler && isModelListener) {
3639
+ handler = getter(props, handlerName = shared.toHandlerKey(shared.hyphenate(event)));
3640
+ }
3641
+ if (handler) {
3642
+ callWithAsyncErrorHandling(
3643
+ handler,
3644
+ instance,
3645
+ 6,
3646
+ args
3647
+ );
3648
+ }
3649
+ const onceHandler = getter(props, handlerName + `Once`);
3650
+ if (onceHandler) {
3651
+ if (!instance.emitted) {
3652
+ instance.emitted = {};
3653
+ } else if (instance.emitted[handlerName]) {
3654
+ return;
3655
+ }
3656
+ instance.emitted[handlerName] = true;
3657
+ callWithAsyncErrorHandling(
3658
+ onceHandler,
3659
+ instance,
3660
+ 6,
3661
+ args
3662
+ );
3663
+ }
3486
3664
  }
3487
- function baseResolveDefault(factory, instance, key) {
3488
- let value;
3489
- const prev = setCurrentInstance(instance);
3490
- const props = reactivity.toRaw(instance.props);
3491
- value = factory.call(
3492
- null,
3493
- props
3494
- );
3495
- setCurrentInstance(...prev);
3496
- return value;
3665
+ function defaultPropGetter(props, key) {
3666
+ return props[key];
3497
3667
  }
3498
- const mixinPropsCache = /* @__PURE__ */ new WeakMap();
3499
- function normalizePropsOptions(comp, appContext, asMixin = false) {
3500
- const cache = asMixin ? mixinPropsCache : appContext.propsCache;
3668
+ const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
3669
+ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
3670
+ const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
3501
3671
  const cached = cache.get(comp);
3502
- if (cached) {
3672
+ if (cached !== void 0) {
3503
3673
  return cached;
3504
3674
  }
3505
- const raw = comp.props;
3506
- const normalized = {};
3507
- const needCastKeys = [];
3675
+ const raw = comp.emits;
3676
+ let normalized = {};
3508
3677
  let hasExtends = false;
3509
3678
  if (!shared.isFunction(comp)) {
3510
- const extendProps = (raw2) => {
3511
- hasExtends = true;
3512
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
3513
- shared.extend(normalized, props);
3514
- if (keys) needCastKeys.push(...keys);
3679
+ const extendEmits = (raw2) => {
3680
+ const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
3681
+ if (normalizedFromExtend) {
3682
+ hasExtends = true;
3683
+ shared.extend(normalized, normalizedFromExtend);
3684
+ }
3515
3685
  };
3516
3686
  if (!asMixin && appContext.mixins.length) {
3517
- appContext.mixins.forEach(extendProps);
3687
+ appContext.mixins.forEach(extendEmits);
3518
3688
  }
3519
3689
  if (comp.extends) {
3520
- extendProps(comp.extends);
3690
+ extendEmits(comp.extends);
3521
3691
  }
3522
3692
  if (comp.mixins) {
3523
- comp.mixins.forEach(extendProps);
3693
+ comp.mixins.forEach(extendEmits);
3524
3694
  }
3525
3695
  }
3526
3696
  if (!raw && !hasExtends) {
3527
3697
  if (shared.isObject(comp)) {
3528
- cache.set(comp, shared.EMPTY_ARR);
3698
+ cache.set(comp, null);
3529
3699
  }
3530
- return shared.EMPTY_ARR;
3700
+ return null;
3701
+ }
3702
+ if (shared.isArray(raw)) {
3703
+ raw.forEach((key) => normalized[key] = null);
3704
+ } else {
3705
+ shared.extend(normalized, raw);
3531
3706
  }
3532
- baseNormalizePropsOptions(raw, normalized, needCastKeys);
3533
- const res = [normalized, needCastKeys];
3534
3707
  if (shared.isObject(comp)) {
3535
- cache.set(comp, res);
3708
+ cache.set(comp, normalized);
3536
3709
  }
3537
- return res;
3710
+ return normalized;
3538
3711
  }
3539
- function baseNormalizePropsOptions(raw, normalized, needCastKeys) {
3540
- if (shared.isArray(raw)) {
3541
- for (let i = 0; i < raw.length; i++) {
3542
- const normalizedKey = shared.camelize(raw[i]);
3543
- if (validatePropName(normalizedKey)) {
3544
- normalized[normalizedKey] = shared.EMPTY_OBJ;
3545
- }
3546
- }
3547
- } else if (raw) {
3548
- for (const key in raw) {
3549
- const normalizedKey = shared.camelize(key);
3550
- if (validatePropName(normalizedKey)) {
3551
- const opt = raw[key];
3552
- const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
3553
- const propType = prop.type;
3554
- let shouldCast = false;
3555
- let shouldCastTrue = true;
3556
- if (shared.isArray(propType)) {
3557
- for (let index = 0; index < propType.length; ++index) {
3558
- const type = propType[index];
3559
- const typeName = shared.isFunction(type) && type.name;
3560
- if (typeName === "Boolean") {
3561
- shouldCast = true;
3562
- break;
3563
- } else if (typeName === "String") {
3564
- shouldCastTrue = false;
3565
- }
3566
- }
3567
- } else {
3568
- shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
3712
+ function isEmitListener(options, key) {
3713
+ if (!options || !shared.isOn(key)) {
3714
+ return false;
3715
+ }
3716
+ key = key.slice(2).replace(/Once$/, "");
3717
+ return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
3718
+ }
3719
+
3720
+ function markAttrsAccessed() {
3721
+ }
3722
+ function renderComponentRoot(instance) {
3723
+ const {
3724
+ type: Component,
3725
+ vnode,
3726
+ proxy,
3727
+ withProxy,
3728
+ propsOptions: [propsOptions],
3729
+ slots,
3730
+ attrs,
3731
+ emit,
3732
+ render,
3733
+ renderCache,
3734
+ props,
3735
+ data,
3736
+ setupState,
3737
+ ctx,
3738
+ inheritAttrs
3739
+ } = instance;
3740
+ const prev = setCurrentRenderingInstance(instance);
3741
+ let result;
3742
+ let fallthroughAttrs;
3743
+ try {
3744
+ if (vnode.shapeFlag & 4) {
3745
+ const proxyToUse = withProxy || proxy;
3746
+ const thisProxy = false ? new Proxy(proxyToUse, {
3747
+ get(target, key, receiver) {
3748
+ warn$2(
3749
+ `Property '${String(
3750
+ key
3751
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
3752
+ );
3753
+ return Reflect.get(target, key, receiver);
3569
3754
  }
3570
- prop[0 /* shouldCast */] = shouldCast;
3571
- prop[1 /* shouldCastTrue */] = shouldCastTrue;
3572
- if (shouldCast || shared.hasOwn(prop, "default")) {
3573
- needCastKeys.push(normalizedKey);
3755
+ }) : proxyToUse;
3756
+ result = normalizeVNode(
3757
+ render.call(
3758
+ thisProxy,
3759
+ proxyToUse,
3760
+ renderCache,
3761
+ false ? shallowReadonly(props) : props,
3762
+ setupState,
3763
+ data,
3764
+ ctx
3765
+ )
3766
+ );
3767
+ fallthroughAttrs = attrs;
3768
+ } else {
3769
+ const render2 = Component;
3770
+ if (false) ;
3771
+ result = normalizeVNode(
3772
+ render2.length > 1 ? render2(
3773
+ false ? shallowReadonly(props) : props,
3774
+ false ? {
3775
+ get attrs() {
3776
+ markAttrsAccessed();
3777
+ return shallowReadonly(attrs);
3778
+ },
3779
+ slots,
3780
+ emit
3781
+ } : { attrs, slots, emit }
3782
+ ) : render2(
3783
+ false ? shallowReadonly(props) : props,
3784
+ null
3785
+ )
3786
+ );
3787
+ fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
3788
+ }
3789
+ } catch (err) {
3790
+ blockStack.length = 0;
3791
+ handleError(err, instance, 1);
3792
+ result = createVNode(Comment);
3793
+ }
3794
+ let root = result;
3795
+ if (fallthroughAttrs && inheritAttrs !== false) {
3796
+ const keys = Object.keys(fallthroughAttrs);
3797
+ const { shapeFlag } = root;
3798
+ if (keys.length) {
3799
+ if (shapeFlag & (1 | 6)) {
3800
+ if (propsOptions && keys.some(shared.isModelListener)) {
3801
+ fallthroughAttrs = filterModelListeners(
3802
+ fallthroughAttrs,
3803
+ propsOptions
3804
+ );
3574
3805
  }
3806
+ root = cloneVNode(root, fallthroughAttrs, false, true);
3575
3807
  }
3576
3808
  }
3577
3809
  }
3578
- }
3579
- function validatePropName(key) {
3580
- if (key[0] !== "$" && !shared.isReservedProp(key)) {
3581
- return true;
3810
+ if (vnode.dirs) {
3811
+ root = cloneVNode(root, null, false, true);
3812
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
3582
3813
  }
3583
- return false;
3584
- }
3585
-
3586
- const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
3587
- const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
3588
- const normalizeSlot = (key, rawSlot, ctx) => {
3589
- if (rawSlot._n) {
3590
- return rawSlot;
3814
+ if (vnode.transition) {
3815
+ setTransitionHooks(root, vnode.transition);
3591
3816
  }
3592
- const normalized = withCtx((...args) => {
3593
- if (false) ;
3594
- return normalizeSlotValue(rawSlot(...args));
3595
- }, ctx);
3596
- normalized._c = false;
3597
- return normalized;
3598
- };
3599
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
3600
- const ctx = rawSlots._ctx;
3601
- for (const key in rawSlots) {
3602
- if (isInternalKey(key)) continue;
3603
- const value = rawSlots[key];
3604
- if (shared.isFunction(value)) {
3605
- slots[key] = normalizeSlot(key, value, ctx);
3606
- } else if (value != null) {
3607
- const normalized = normalizeSlotValue(value);
3608
- slots[key] = () => normalized;
3817
+ {
3818
+ result = root;
3819
+ }
3820
+ setCurrentRenderingInstance(prev);
3821
+ return result;
3822
+ }
3823
+ function filterSingleRoot(children, recurse = true) {
3824
+ let singleRoot;
3825
+ for (let i = 0; i < children.length; i++) {
3826
+ const child = children[i];
3827
+ if (isVNode(child)) {
3828
+ if (child.type !== Comment || child.children === "v-if") {
3829
+ if (singleRoot) {
3830
+ return;
3831
+ } else {
3832
+ singleRoot = child;
3833
+ }
3834
+ }
3835
+ } else {
3836
+ return;
3609
3837
  }
3610
3838
  }
3611
- };
3612
- const normalizeVNodeSlots = (instance, children) => {
3613
- const normalized = normalizeSlotValue(children);
3614
- instance.slots.default = () => normalized;
3615
- };
3616
- const assignSlots = (slots, children, optimized) => {
3617
- for (const key in children) {
3618
- if (optimized || !isInternalKey(key)) {
3619
- slots[key] = children[key];
3839
+ return singleRoot;
3840
+ }
3841
+ const getFunctionalFallthrough = (attrs) => {
3842
+ let res;
3843
+ for (const key in attrs) {
3844
+ if (key === "class" || key === "style" || shared.isOn(key)) {
3845
+ (res || (res = {}))[key] = attrs[key];
3620
3846
  }
3621
3847
  }
3848
+ return res;
3622
3849
  };
3623
- const initSlots = (instance, children, optimized) => {
3624
- const slots = instance.slots = createInternalObject();
3625
- if (instance.vnode.shapeFlag & 32) {
3626
- const type = children._;
3627
- if (type) {
3628
- assignSlots(slots, children, optimized);
3629
- if (optimized) {
3630
- shared.def(slots, "_", type, true);
3631
- }
3632
- } else {
3633
- normalizeObjectSlots(children, slots);
3850
+ const filterModelListeners = (attrs, props) => {
3851
+ const res = {};
3852
+ for (const key in attrs) {
3853
+ if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
3854
+ res[key] = attrs[key];
3634
3855
  }
3635
- } else if (children) {
3636
- normalizeVNodeSlots(instance, children);
3637
3856
  }
3857
+ return res;
3638
3858
  };
3639
- const updateSlots = (instance, children, optimized) => {
3640
- const { vnode, slots } = instance;
3641
- let needDeletionCheck = true;
3642
- let deletionComparisonTarget = shared.EMPTY_OBJ;
3643
- if (vnode.shapeFlag & 32) {
3644
- const type = children._;
3645
- if (type) {
3646
- if (optimized && type === 1) {
3647
- needDeletionCheck = false;
3648
- } else {
3649
- assignSlots(slots, children, optimized);
3859
+ function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
3860
+ const { props: prevProps, children: prevChildren, component } = prevVNode;
3861
+ const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
3862
+ const emits = component.emitsOptions;
3863
+ if (nextVNode.dirs || nextVNode.transition) {
3864
+ return true;
3865
+ }
3866
+ if (optimized && patchFlag >= 0) {
3867
+ if (patchFlag & 1024) {
3868
+ return true;
3869
+ }
3870
+ if (patchFlag & 16) {
3871
+ if (!prevProps) {
3872
+ return !!nextProps;
3873
+ }
3874
+ return hasPropsChanged(prevProps, nextProps, emits);
3875
+ } else if (patchFlag & 8) {
3876
+ const dynamicProps = nextVNode.dynamicProps;
3877
+ for (let i = 0; i < dynamicProps.length; i++) {
3878
+ const key = dynamicProps[i];
3879
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
3880
+ return true;
3881
+ }
3650
3882
  }
3651
- } else {
3652
- needDeletionCheck = !children.$stable;
3653
- normalizeObjectSlots(children, slots);
3654
3883
  }
3655
- deletionComparisonTarget = children;
3656
- } else if (children) {
3657
- normalizeVNodeSlots(instance, children);
3658
- deletionComparisonTarget = { default: 1 };
3659
- }
3660
- if (needDeletionCheck) {
3661
- for (const key in slots) {
3662
- if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
3663
- delete slots[key];
3884
+ } else {
3885
+ if (prevChildren || nextChildren) {
3886
+ if (!nextChildren || !nextChildren.$stable) {
3887
+ return true;
3664
3888
  }
3665
3889
  }
3890
+ if (prevProps === nextProps) {
3891
+ return false;
3892
+ }
3893
+ if (!prevProps) {
3894
+ return !!nextProps;
3895
+ }
3896
+ if (!nextProps) {
3897
+ return true;
3898
+ }
3899
+ return hasPropsChanged(prevProps, nextProps, emits);
3666
3900
  }
3667
- };
3668
-
3669
- const queuePostRenderEffect = queueEffectWithSuspense ;
3670
- function createRenderer(options) {
3671
- return baseCreateRenderer(options);
3672
- }
3673
- function createHydrationRenderer(options) {
3674
- return baseCreateRenderer(options, createHydrationFunctions);
3901
+ return false;
3675
3902
  }
3676
- function baseCreateRenderer(options, createHydrationFns) {
3677
- const target = shared.getGlobalThis();
3678
- target.__VUE__ = true;
3679
- const {
3680
- insert: hostInsert,
3681
- remove: hostRemove,
3682
- patchProp: hostPatchProp,
3683
- createElement: hostCreateElement,
3684
- createText: hostCreateText,
3685
- createComment: hostCreateComment,
3686
- setText: hostSetText,
3687
- setElementText: hostSetElementText,
3688
- parentNode: hostParentNode,
3689
- nextSibling: hostNextSibling,
3690
- setScopeId: hostSetScopeId = shared.NOOP,
3691
- insertStaticContent: hostInsertStaticContent
3692
- } = options;
3693
- const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
3694
- if (n1 === n2) {
3695
- return;
3696
- }
3697
- if (n1 && !isSameVNodeType(n1, n2)) {
3698
- anchor = getNextHostNode(n1);
3699
- unmount(n1, parentComponent, parentSuspense, true);
3700
- n1 = null;
3701
- }
3702
- if (n2.patchFlag === -2) {
3703
- optimized = false;
3704
- n2.dynamicChildren = null;
3705
- }
3706
- const { type, ref, shapeFlag } = n2;
3707
- switch (type) {
3708
- case Text:
3709
- processText(n1, n2, container, anchor);
3710
- break;
3711
- case Comment:
3712
- processCommentNode(n1, n2, container, anchor);
3713
- break;
3714
- case Static:
3715
- if (n1 == null) {
3716
- mountStaticNode(n2, container, anchor, namespace);
3717
- }
3718
- break;
3719
- case Fragment:
3720
- processFragment(
3721
- n1,
3722
- n2,
3723
- container,
3724
- anchor,
3725
- parentComponent,
3726
- parentSuspense,
3727
- namespace,
3728
- slotScopeIds,
3729
- optimized
3730
- );
3731
- break;
3732
- case VaporSlot:
3733
- getVaporInterface(parentComponent, n2).slot(n1, n2, container, anchor);
3734
- break;
3735
- default:
3736
- if (shapeFlag & 1) {
3737
- processElement(
3738
- n1,
3739
- n2,
3740
- container,
3741
- anchor,
3742
- parentComponent,
3743
- parentSuspense,
3744
- namespace,
3745
- slotScopeIds,
3746
- optimized
3747
- );
3748
- } else if (shapeFlag & 6) {
3749
- processComponent(
3750
- n1,
3751
- n2,
3752
- container,
3753
- anchor,
3754
- parentComponent,
3755
- parentSuspense,
3756
- namespace,
3757
- slotScopeIds,
3758
- optimized
3759
- );
3760
- } else if (shapeFlag & 64) {
3761
- type.process(
3762
- n1,
3763
- n2,
3764
- container,
3765
- anchor,
3766
- parentComponent,
3767
- parentSuspense,
3768
- namespace,
3769
- slotScopeIds,
3770
- optimized,
3771
- internals
3772
- );
3773
- } else if (shapeFlag & 128) {
3774
- type.process(
3775
- n1,
3776
- n2,
3777
- container,
3778
- anchor,
3779
- parentComponent,
3780
- parentSuspense,
3781
- namespace,
3782
- slotScopeIds,
3783
- optimized,
3784
- internals
3785
- );
3786
- } else ;
3787
- }
3788
- if (ref != null && parentComponent) {
3789
- setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
3790
- } else if (ref == null && n1 && n1.ref != null) {
3791
- setRef(n1.ref, null, parentSuspense, n1, true);
3792
- }
3793
- };
3794
- const processText = (n1, n2, container, anchor) => {
3795
- if (n1 == null) {
3796
- hostInsert(
3797
- n2.el = hostCreateText(n2.children),
3798
- container,
3799
- anchor
3800
- );
3801
- } else {
3802
- const el = n2.el = n1.el;
3803
- if (n2.children !== n1.children) {
3804
- hostSetText(el, n2.children);
3805
- }
3806
- }
3807
- };
3808
- const processCommentNode = (n1, n2, container, anchor) => {
3809
- if (n1 == null) {
3810
- hostInsert(
3811
- n2.el = hostCreateComment(n2.children || ""),
3812
- container,
3813
- anchor
3814
- );
3815
- } else {
3816
- n2.el = n1.el;
3817
- }
3818
- };
3819
- const mountStaticNode = (n2, container, anchor, namespace) => {
3820
- [n2.el, n2.anchor] = hostInsertStaticContent(
3821
- n2.children,
3822
- container,
3823
- anchor,
3824
- namespace,
3825
- n2.el,
3826
- n2.anchor
3827
- );
3828
- };
3829
- const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
3830
- let next;
3831
- while (el && el !== anchor) {
3832
- next = hostNextSibling(el);
3833
- hostInsert(el, container, nextSibling);
3834
- el = next;
3835
- }
3836
- hostInsert(anchor, container, nextSibling);
3837
- };
3838
- const removeStaticNode = ({ el, anchor }) => {
3839
- let next;
3840
- while (el && el !== anchor) {
3841
- next = hostNextSibling(el);
3842
- hostRemove(el);
3843
- el = next;
3903
+ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
3904
+ const nextKeys = Object.keys(nextProps);
3905
+ if (nextKeys.length !== Object.keys(prevProps).length) {
3906
+ return true;
3907
+ }
3908
+ for (let i = 0; i < nextKeys.length; i++) {
3909
+ const key = nextKeys[i];
3910
+ if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
3911
+ return true;
3844
3912
  }
3845
- hostRemove(anchor);
3846
- };
3847
- const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3848
- if (n2.type === "svg") {
3849
- namespace = "svg";
3850
- } else if (n2.type === "math") {
3851
- namespace = "mathml";
3913
+ }
3914
+ return false;
3915
+ }
3916
+ function updateHOCHostEl({ vnode, parent }, el) {
3917
+ while (parent && !parent.vapor) {
3918
+ const root = parent.subTree;
3919
+ if (root.suspense && root.suspense.activeBranch === vnode) {
3920
+ root.el = vnode.el;
3852
3921
  }
3853
- if (n1 == null) {
3854
- mountElement(
3855
- n2,
3856
- container,
3857
- anchor,
3858
- parentComponent,
3859
- parentSuspense,
3860
- namespace,
3861
- slotScopeIds,
3862
- optimized
3863
- );
3922
+ if (root === vnode) {
3923
+ (vnode = parent.vnode).el = el;
3924
+ parent = parent.parent;
3864
3925
  } else {
3865
- const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
3866
- try {
3867
- if (customElement) {
3868
- customElement._beginPatch();
3869
- }
3870
- patchElement(
3871
- n1,
3872
- n2,
3873
- parentComponent,
3874
- parentSuspense,
3875
- namespace,
3876
- slotScopeIds,
3877
- optimized
3878
- );
3879
- } finally {
3880
- if (customElement) {
3881
- customElement._endPatch();
3882
- }
3883
- }
3884
- }
3885
- };
3886
- const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3887
- let el;
3888
- let vnodeHook;
3889
- const { props, shapeFlag, transition, dirs } = vnode;
3890
- el = vnode.el = hostCreateElement(
3891
- vnode.type,
3892
- namespace,
3893
- props && props.is,
3894
- props
3895
- );
3896
- if (shapeFlag & 8) {
3897
- hostSetElementText(el, vnode.children);
3898
- } else if (shapeFlag & 16) {
3899
- mountChildren(
3900
- vnode.children,
3901
- el,
3902
- null,
3903
- parentComponent,
3904
- parentSuspense,
3905
- resolveChildrenNamespace(vnode, namespace),
3906
- slotScopeIds,
3907
- optimized
3908
- );
3909
- }
3910
- if (dirs) {
3911
- invokeDirectiveHook(vnode, null, parentComponent, "created");
3912
- }
3913
- setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
3914
- if (props) {
3915
- for (const key in props) {
3916
- if (key !== "value" && !shared.isReservedProp(key)) {
3917
- hostPatchProp(el, key, null, props[key], namespace, parentComponent);
3918
- }
3919
- }
3920
- if ("value" in props) {
3921
- hostPatchProp(el, "value", null, props.value, namespace);
3922
- }
3923
- if (vnodeHook = props.onVnodeBeforeMount) {
3924
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
3925
- }
3926
+ break;
3926
3927
  }
3927
- if (dirs) {
3928
- invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
3928
+ }
3929
+ }
3930
+
3931
+ const internalObjectProto = {};
3932
+ const createInternalObject = () => Object.create(internalObjectProto);
3933
+ const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
3934
+
3935
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
3936
+ const props = instance.props = {};
3937
+ const attrs = createInternalObject();
3938
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3939
+ setFullProps(instance, rawProps, props, attrs);
3940
+ for (const key in instance.propsOptions[0]) {
3941
+ if (!(key in props)) {
3942
+ props[key] = void 0;
3929
3943
  }
3930
- if (transition) {
3931
- performTransitionEnter(
3932
- el,
3933
- transition,
3934
- () => hostInsert(el, container, anchor),
3935
- parentSuspense
3936
- );
3944
+ }
3945
+ if (isStateful) {
3946
+ instance.props = isSSR ? props : reactivity.shallowReactive(props);
3947
+ } else {
3948
+ if (!instance.type.props) {
3949
+ instance.props = attrs;
3937
3950
  } else {
3938
- hostInsert(el, container, anchor);
3939
- }
3940
- if ((vnodeHook = props && props.onVnodeMounted) || dirs) {
3941
- queuePostRenderEffect(
3942
- () => {
3943
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
3944
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
3945
- },
3946
- void 0,
3947
- parentSuspense
3948
- );
3949
- }
3950
- };
3951
- const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
3952
- if (scopeId) {
3953
- hostSetScopeId(el, scopeId);
3954
- }
3955
- if (slotScopeIds) {
3956
- for (let i = 0; i < slotScopeIds.length; i++) {
3957
- hostSetScopeId(el, slotScopeIds[i]);
3958
- }
3959
- }
3960
- const inheritedScopeIds = getInheritedScopeIds(vnode, parentComponent);
3961
- for (let i = 0; i < inheritedScopeIds.length; i++) {
3962
- hostSetScopeId(el, inheritedScopeIds[i]);
3963
- }
3964
- };
3965
- const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
3966
- for (let i = start; i < children.length; i++) {
3967
- const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
3968
- patch(
3969
- null,
3970
- child,
3971
- container,
3972
- anchor,
3973
- parentComponent,
3974
- parentSuspense,
3975
- namespace,
3976
- slotScopeIds,
3977
- optimized
3978
- );
3979
- }
3980
- };
3981
- const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
3982
- const el = n2.el = n1.el;
3983
- let { patchFlag, dynamicChildren, dirs } = n2;
3984
- patchFlag |= n1.patchFlag & 16;
3985
- const oldProps = n1.props || shared.EMPTY_OBJ;
3986
- const newProps = n2.props || shared.EMPTY_OBJ;
3987
- let vnodeHook;
3988
- parentComponent && toggleRecurse(parentComponent, false);
3989
- if (vnodeHook = newProps.onVnodeBeforeUpdate) {
3990
- invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
3991
- }
3992
- if (dirs) {
3993
- invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
3994
- }
3995
- parentComponent && toggleRecurse(parentComponent, true);
3996
- if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
3997
- hostSetElementText(el, "");
3998
- }
3999
- if (dynamicChildren) {
4000
- patchBlockChildren(
4001
- n1.dynamicChildren,
4002
- dynamicChildren,
4003
- el,
4004
- parentComponent,
4005
- parentSuspense,
4006
- resolveChildrenNamespace(n2, namespace),
4007
- slotScopeIds
4008
- );
4009
- } else if (!optimized) {
4010
- patchChildren(
4011
- n1,
4012
- n2,
4013
- el,
4014
- null,
4015
- parentComponent,
4016
- parentSuspense,
4017
- resolveChildrenNamespace(n2, namespace),
4018
- slotScopeIds,
4019
- false
4020
- );
3951
+ instance.props = props;
4021
3952
  }
4022
- if (patchFlag > 0) {
4023
- if (patchFlag & 16) {
4024
- patchProps(el, oldProps, newProps, parentComponent, namespace);
4025
- } else {
4026
- if (patchFlag & 2) {
4027
- if (oldProps.class !== newProps.class) {
4028
- hostPatchProp(el, "class", null, newProps.class, namespace);
4029
- }
4030
- }
4031
- if (patchFlag & 4) {
4032
- hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
3953
+ }
3954
+ instance.attrs = attrs;
3955
+ }
3956
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
3957
+ const {
3958
+ props,
3959
+ attrs,
3960
+ vnode: { patchFlag }
3961
+ } = instance;
3962
+ const rawCurrentProps = reactivity.toRaw(props);
3963
+ const [options] = instance.propsOptions;
3964
+ let hasAttrsChanged = false;
3965
+ if (
3966
+ // always force full diff in dev
3967
+ // - #1942 if hmr is enabled with sfc component
3968
+ // - vite#872 non-sfc component used by sfc component
3969
+ (optimized || patchFlag > 0) && !(patchFlag & 16)
3970
+ ) {
3971
+ if (patchFlag & 8) {
3972
+ const propsToUpdate = instance.vnode.dynamicProps;
3973
+ for (let i = 0; i < propsToUpdate.length; i++) {
3974
+ let key = propsToUpdate[i];
3975
+ if (isEmitListener(instance.emitsOptions, key)) {
3976
+ continue;
4033
3977
  }
4034
- if (patchFlag & 8) {
4035
- const propsToUpdate = n2.dynamicProps;
4036
- for (let i = 0; i < propsToUpdate.length; i++) {
4037
- const key = propsToUpdate[i];
4038
- const prev = oldProps[key];
4039
- const next = newProps[key];
4040
- if (next !== prev || key === "value") {
4041
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
3978
+ const value = rawProps[key];
3979
+ if (options) {
3980
+ if (shared.hasOwn(attrs, key)) {
3981
+ if (value !== attrs[key]) {
3982
+ attrs[key] = value;
3983
+ hasAttrsChanged = true;
4042
3984
  }
3985
+ } else {
3986
+ const camelizedKey = shared.camelize(key);
3987
+ props[camelizedKey] = resolvePropValue(
3988
+ options,
3989
+ camelizedKey,
3990
+ value,
3991
+ instance,
3992
+ baseResolveDefault
3993
+ );
3994
+ }
3995
+ } else {
3996
+ if (value !== attrs[key]) {
3997
+ attrs[key] = value;
3998
+ hasAttrsChanged = true;
4043
3999
  }
4044
4000
  }
4045
4001
  }
4046
- if (patchFlag & 1) {
4047
- if (n1.children !== n2.children) {
4048
- hostSetElementText(el, n2.children);
4049
- }
4050
- }
4051
- } else if (!optimized && dynamicChildren == null) {
4052
- patchProps(el, oldProps, newProps, parentComponent, namespace);
4053
- }
4054
- if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
4055
- queuePostRenderEffect(
4056
- () => {
4057
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4058
- dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
4059
- },
4060
- void 0,
4061
- parentSuspense
4062
- );
4063
4002
  }
4064
- };
4065
- const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
4066
- for (let i = 0; i < newChildren.length; i++) {
4067
- const oldVNode = oldChildren[i];
4068
- const newVNode = newChildren[i];
4069
- const container = (
4070
- // oldVNode may be an errored async setup() component inside Suspense
4071
- // which will not have a mounted element
4072
- oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
4073
- // of the Fragment itself so it can move its children.
4074
- (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
4075
- // which also requires the correct parent container
4076
- !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
4077
- oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
4078
- // In other cases, the parent container is not actually used so we
4079
- // just pass the block element here to avoid a DOM parentNode call.
4080
- fallbackContainer
4081
- )
4082
- );
4083
- patch(
4084
- oldVNode,
4085
- newVNode,
4086
- container,
4087
- null,
4088
- parentComponent,
4089
- parentSuspense,
4090
- namespace,
4091
- slotScopeIds,
4092
- true
4093
- );
4003
+ } else {
4004
+ if (setFullProps(instance, rawProps, props, attrs)) {
4005
+ hasAttrsChanged = true;
4094
4006
  }
4095
- };
4096
- const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
4097
- if (oldProps !== newProps) {
4098
- if (oldProps !== shared.EMPTY_OBJ) {
4099
- for (const key in oldProps) {
4100
- if (!shared.isReservedProp(key) && !(key in newProps)) {
4101
- hostPatchProp(
4102
- el,
4007
+ let kebabKey;
4008
+ for (const key in rawCurrentProps) {
4009
+ if (!rawProps || // for camelCase
4010
+ !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
4011
+ // and converted to camelCase (#955)
4012
+ ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
4013
+ if (options) {
4014
+ if (rawPrevProps && // for camelCase
4015
+ (rawPrevProps[key] !== void 0 || // for kebab-case
4016
+ rawPrevProps[kebabKey] !== void 0)) {
4017
+ props[key] = resolvePropValue(
4018
+ options,
4103
4019
  key,
4104
- oldProps[key],
4105
- null,
4106
- namespace,
4107
- parentComponent
4020
+ void 0,
4021
+ instance,
4022
+ baseResolveDefault,
4023
+ true
4108
4024
  );
4109
4025
  }
4026
+ } else {
4027
+ delete props[key];
4110
4028
  }
4111
4029
  }
4112
- for (const key in newProps) {
4113
- if (shared.isReservedProp(key)) continue;
4114
- const next = newProps[key];
4115
- const prev = oldProps[key];
4116
- if (next !== prev && key !== "value") {
4117
- hostPatchProp(el, key, prev, next, namespace, parentComponent);
4030
+ }
4031
+ if (attrs !== rawCurrentProps) {
4032
+ for (const key in attrs) {
4033
+ if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
4034
+ delete attrs[key];
4035
+ hasAttrsChanged = true;
4118
4036
  }
4119
4037
  }
4120
- if ("value" in newProps) {
4121
- hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
4122
- }
4123
4038
  }
4124
- };
4125
- const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4126
- const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
4127
- const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
4128
- let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
4129
- if (fragmentSlotScopeIds) {
4130
- slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
4039
+ }
4040
+ if (hasAttrsChanged) {
4041
+ reactivity.trigger(instance.attrs, "set", "");
4042
+ }
4043
+ }
4044
+ function setFullProps(instance, rawProps, props, attrs) {
4045
+ const [options, needCastKeys] = instance.propsOptions;
4046
+ let hasAttrsChanged = false;
4047
+ let rawCastValues;
4048
+ if (rawProps) {
4049
+ for (let key in rawProps) {
4050
+ if (shared.isReservedProp(key)) {
4051
+ continue;
4052
+ }
4053
+ const value = rawProps[key];
4054
+ let camelKey;
4055
+ if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
4056
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4057
+ props[camelKey] = value;
4058
+ } else {
4059
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4060
+ }
4061
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
4062
+ if (!(key in attrs) || value !== attrs[key]) {
4063
+ attrs[key] = value;
4064
+ hasAttrsChanged = true;
4065
+ }
4066
+ }
4131
4067
  }
4132
- if (n1 == null) {
4133
- hostInsert(fragmentStartAnchor, container, anchor);
4134
- hostInsert(fragmentEndAnchor, container, anchor);
4135
- mountChildren(
4136
- // #10007
4137
- // such fragment like `<></>` will be compiled into
4138
- // a fragment which doesn't have a children.
4139
- // In this case fallback to an empty array
4140
- n2.children || [],
4141
- container,
4142
- fragmentEndAnchor,
4143
- parentComponent,
4144
- parentSuspense,
4145
- namespace,
4146
- slotScopeIds,
4147
- optimized
4068
+ }
4069
+ if (needCastKeys) {
4070
+ const castValues = rawCastValues || shared.EMPTY_OBJ;
4071
+ for (let i = 0; i < needCastKeys.length; i++) {
4072
+ const key = needCastKeys[i];
4073
+ props[key] = resolvePropValue(
4074
+ options,
4075
+ key,
4076
+ castValues[key],
4077
+ instance,
4078
+ baseResolveDefault,
4079
+ !shared.hasOwn(castValues, key)
4148
4080
  );
4149
- } else {
4150
- if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
4151
- // of renderSlot() with no valid children
4152
- n1.dynamicChildren) {
4153
- patchBlockChildren(
4154
- n1.dynamicChildren,
4155
- dynamicChildren,
4156
- container,
4157
- parentComponent,
4158
- parentSuspense,
4159
- namespace,
4160
- slotScopeIds
4161
- );
4162
- if (
4163
- // #2080 if the stable fragment has a key, it's a <template v-for> that may
4164
- // get moved around. Make sure all root level vnodes inherit el.
4165
- // #2134 or if it's a component root, it may also get moved around
4166
- // as the component is being moved.
4167
- n2.key != null || parentComponent && n2 === parentComponent.subTree
4168
- ) {
4169
- traverseStaticChildren(
4170
- n1,
4171
- n2,
4172
- true
4173
- /* shallow */
4081
+ }
4082
+ }
4083
+ return hasAttrsChanged;
4084
+ }
4085
+ function resolvePropValue(options, key, value, instance, resolveDefault, isAbsent = false) {
4086
+ const opt = options[key];
4087
+ if (opt != null) {
4088
+ const hasDefault = shared.hasOwn(opt, "default");
4089
+ if (hasDefault && value === void 0) {
4090
+ const defaultValue = opt.default;
4091
+ if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
4092
+ const cachedDefaults = instance.propsDefaults || (instance.propsDefaults = {});
4093
+ if (shared.hasOwn(cachedDefaults, key)) {
4094
+ value = cachedDefaults[key];
4095
+ } else {
4096
+ value = cachedDefaults[key] = resolveDefault(
4097
+ defaultValue,
4098
+ instance,
4099
+ key
4174
4100
  );
4175
4101
  }
4176
4102
  } else {
4177
- patchChildren(
4178
- n1,
4179
- n2,
4180
- container,
4181
- fragmentEndAnchor,
4182
- parentComponent,
4183
- parentSuspense,
4184
- namespace,
4185
- slotScopeIds,
4186
- optimized
4187
- );
4103
+ value = defaultValue;
4104
+ }
4105
+ if (instance.ce) {
4106
+ instance.ce._setProp(key, value);
4188
4107
  }
4189
4108
  }
4190
- };
4191
- const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4192
- n2.slotScopeIds = slotScopeIds;
4193
- if (n2.type.__vapor) {
4194
- if (n1 == null) {
4195
- if (n2.shapeFlag & 512) {
4196
- getVaporInterface(parentComponent, n2).activate(
4197
- n2,
4198
- container,
4199
- anchor,
4200
- parentComponent
4201
- );
4202
- } else {
4203
- getVaporInterface(parentComponent, n2).mount(
4204
- n2,
4205
- container,
4206
- anchor,
4207
- parentComponent
4208
- );
4109
+ if (opt[0 /* shouldCast */]) {
4110
+ if (isAbsent && !hasDefault) {
4111
+ value = false;
4112
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
4113
+ value = true;
4114
+ }
4115
+ }
4116
+ }
4117
+ return value;
4118
+ }
4119
+ function baseResolveDefault(factory, instance, key) {
4120
+ let value;
4121
+ const prev = setCurrentInstance(instance);
4122
+ const props = reactivity.toRaw(instance.props);
4123
+ value = factory.call(
4124
+ null,
4125
+ props
4126
+ );
4127
+ setCurrentInstance(...prev);
4128
+ return value;
4129
+ }
4130
+ const mixinPropsCache = /* @__PURE__ */ new WeakMap();
4131
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
4132
+ const cache = asMixin ? mixinPropsCache : appContext.propsCache;
4133
+ const cached = cache.get(comp);
4134
+ if (cached) {
4135
+ return cached;
4136
+ }
4137
+ const raw = comp.props;
4138
+ const normalized = {};
4139
+ const needCastKeys = [];
4140
+ let hasExtends = false;
4141
+ if (!shared.isFunction(comp)) {
4142
+ const extendProps = (raw2) => {
4143
+ hasExtends = true;
4144
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
4145
+ shared.extend(normalized, props);
4146
+ if (keys) needCastKeys.push(...keys);
4147
+ };
4148
+ if (!asMixin && appContext.mixins.length) {
4149
+ appContext.mixins.forEach(extendProps);
4150
+ }
4151
+ if (comp.extends) {
4152
+ extendProps(comp.extends);
4153
+ }
4154
+ if (comp.mixins) {
4155
+ comp.mixins.forEach(extendProps);
4156
+ }
4157
+ }
4158
+ if (!raw && !hasExtends) {
4159
+ if (shared.isObject(comp)) {
4160
+ cache.set(comp, shared.EMPTY_ARR);
4161
+ }
4162
+ return shared.EMPTY_ARR;
4163
+ }
4164
+ baseNormalizePropsOptions(raw, normalized, needCastKeys);
4165
+ const res = [normalized, needCastKeys];
4166
+ if (shared.isObject(comp)) {
4167
+ cache.set(comp, res);
4168
+ }
4169
+ return res;
4170
+ }
4171
+ function baseNormalizePropsOptions(raw, normalized, needCastKeys) {
4172
+ if (shared.isArray(raw)) {
4173
+ for (let i = 0; i < raw.length; i++) {
4174
+ const normalizedKey = shared.camelize(raw[i]);
4175
+ if (validatePropName(normalizedKey)) {
4176
+ normalized[normalizedKey] = shared.EMPTY_OBJ;
4177
+ }
4178
+ }
4179
+ } else if (raw) {
4180
+ for (const key in raw) {
4181
+ const normalizedKey = shared.camelize(key);
4182
+ if (validatePropName(normalizedKey)) {
4183
+ const opt = raw[key];
4184
+ const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
4185
+ const propType = prop.type;
4186
+ let shouldCast = false;
4187
+ let shouldCastTrue = true;
4188
+ if (shared.isArray(propType)) {
4189
+ for (let index = 0; index < propType.length; ++index) {
4190
+ const type = propType[index];
4191
+ const typeName = shared.isFunction(type) && type.name;
4192
+ if (typeName === "Boolean") {
4193
+ shouldCast = true;
4194
+ break;
4195
+ } else if (typeName === "String") {
4196
+ shouldCastTrue = false;
4197
+ }
4198
+ }
4199
+ } else {
4200
+ shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
4201
+ }
4202
+ prop[0 /* shouldCast */] = shouldCast;
4203
+ prop[1 /* shouldCastTrue */] = shouldCastTrue;
4204
+ if (shouldCast || shared.hasOwn(prop, "default")) {
4205
+ needCastKeys.push(normalizedKey);
4209
4206
  }
4210
- } else {
4211
- getVaporInterface(parentComponent, n2).update(
4212
- n1,
4213
- n2,
4214
- shouldUpdateComponent(n1, n2, optimized)
4215
- );
4216
- }
4217
- } else if (n1 == null) {
4218
- if (n2.shapeFlag & 512) {
4219
- parentComponent.ctx.activate(
4220
- n2,
4221
- container,
4222
- anchor,
4223
- namespace,
4224
- optimized
4225
- );
4226
- } else {
4227
- mountComponent(
4228
- n2,
4229
- container,
4230
- anchor,
4231
- parentComponent,
4232
- parentSuspense,
4233
- namespace,
4234
- optimized
4235
- );
4236
4207
  }
4237
- } else {
4238
- updateComponent(n1, n2, optimized);
4239
4208
  }
4240
- };
4241
- const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
4242
- const instance = (initialVNode.component = createComponentInstance(
4243
- initialVNode,
4244
- parentComponent,
4245
- parentSuspense
4246
- ));
4247
- if (isKeepAlive(initialVNode)) {
4248
- instance.ctx.renderer = internals;
4209
+ }
4210
+ }
4211
+ function validatePropName(key) {
4212
+ if (key[0] !== "$" && !shared.isReservedProp(key)) {
4213
+ return true;
4214
+ }
4215
+ return false;
4216
+ }
4217
+
4218
+ const isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
4219
+ const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
4220
+ const normalizeSlot = (key, rawSlot, ctx) => {
4221
+ if (rawSlot._n) {
4222
+ return rawSlot;
4223
+ }
4224
+ const normalized = withCtx((...args) => {
4225
+ if (false) ;
4226
+ return normalizeSlotValue(rawSlot(...args));
4227
+ }, ctx);
4228
+ normalized._c = false;
4229
+ return normalized;
4230
+ };
4231
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
4232
+ const ctx = rawSlots._ctx;
4233
+ for (const key in rawSlots) {
4234
+ if (isInternalKey(key)) continue;
4235
+ const value = rawSlots[key];
4236
+ if (shared.isFunction(value)) {
4237
+ slots[key] = normalizeSlot(key, value, ctx);
4238
+ } else if (value != null) {
4239
+ const normalized = normalizeSlotValue(value);
4240
+ slots[key] = () => normalized;
4249
4241
  }
4250
- {
4251
- setupComponent(instance, false, optimized);
4242
+ }
4243
+ };
4244
+ const normalizeVNodeSlots = (instance, children) => {
4245
+ const normalized = normalizeSlotValue(children);
4246
+ instance.slots.default = () => normalized;
4247
+ };
4248
+ const assignSlots = (slots, children, optimized) => {
4249
+ for (const key in children) {
4250
+ if (optimized || !isInternalKey(key)) {
4251
+ slots[key] = children[key];
4252
4252
  }
4253
- if (instance.asyncDep) {
4254
- parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
4255
- if (!initialVNode.el) {
4256
- const placeholder = instance.subTree = createVNode(Comment);
4257
- processCommentNode(null, placeholder, container, anchor);
4258
- initialVNode.placeholder = placeholder.el;
4253
+ }
4254
+ };
4255
+ const initSlots = (instance, children, optimized) => {
4256
+ const slots = instance.slots = createInternalObject();
4257
+ if (instance.vnode.shapeFlag & 32) {
4258
+ const type = children._;
4259
+ if (type) {
4260
+ assignSlots(slots, children, optimized);
4261
+ if (optimized) {
4262
+ shared.def(slots, "_", type, true);
4259
4263
  }
4260
4264
  } else {
4261
- setupRenderEffect(
4262
- instance,
4263
- initialVNode,
4264
- container,
4265
- anchor,
4266
- parentSuspense,
4267
- namespace,
4268
- optimized
4269
- );
4265
+ normalizeObjectSlots(children, slots);
4270
4266
  }
4271
- };
4272
- const updateComponent = (n1, n2, optimized) => {
4273
- const instance = n2.component = n1.component;
4274
- if (shouldUpdateComponent(n1, n2, optimized)) {
4275
- if (instance.asyncDep && !instance.asyncResolved) {
4276
- updateComponentPreRender(instance, n2, optimized);
4277
- return;
4267
+ } else if (children) {
4268
+ normalizeVNodeSlots(instance, children);
4269
+ }
4270
+ };
4271
+ const updateSlots = (instance, children, optimized) => {
4272
+ const { vnode, slots } = instance;
4273
+ let needDeletionCheck = true;
4274
+ let deletionComparisonTarget = shared.EMPTY_OBJ;
4275
+ if (vnode.shapeFlag & 32) {
4276
+ const type = children._;
4277
+ if (type) {
4278
+ if (optimized && type === 1) {
4279
+ needDeletionCheck = false;
4278
4280
  } else {
4279
- instance.next = n2;
4280
- instance.effect.run();
4281
+ assignSlots(slots, children, optimized);
4281
4282
  }
4282
4283
  } else {
4283
- n2.el = n1.el;
4284
- instance.vnode = n2;
4285
- }
4286
- };
4287
- class SetupRenderEffect extends reactivity.ReactiveEffect {
4288
- constructor(instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) {
4289
- const prevScope = reactivity.setCurrentScope(instance.scope);
4290
- super();
4291
- this.instance = instance;
4292
- this.initialVNode = initialVNode;
4293
- this.container = container;
4294
- this.anchor = anchor;
4295
- this.parentSuspense = parentSuspense;
4296
- this.namespace = namespace;
4297
- this.optimized = optimized;
4298
- reactivity.setCurrentScope(prevScope);
4299
- this.job = instance.job = () => {
4300
- if (this.dirty) {
4301
- this.run();
4302
- }
4303
- };
4304
- this.job.i = instance;
4284
+ needDeletionCheck = !children.$stable;
4285
+ normalizeObjectSlots(children, slots);
4305
4286
  }
4306
- notify() {
4307
- if (!(this.flags & 256)) {
4308
- const job = this.job;
4309
- queueJob(job, job.i.uid);
4287
+ deletionComparisonTarget = children;
4288
+ } else if (children) {
4289
+ normalizeVNodeSlots(instance, children);
4290
+ deletionComparisonTarget = { default: 1 };
4291
+ }
4292
+ if (needDeletionCheck) {
4293
+ for (const key in slots) {
4294
+ if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
4295
+ delete slots[key];
4310
4296
  }
4311
4297
  }
4312
- fn() {
4313
- const {
4314
- instance,
4315
- initialVNode,
4316
- container,
4317
- anchor,
4318
- parentSuspense,
4319
- namespace,
4320
- optimized
4321
- } = this;
4322
- if (!instance.isMounted) {
4323
- let vnodeHook;
4324
- const { el, props } = initialVNode;
4325
- const { bm, m, parent, root, type } = instance;
4326
- const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4327
- toggleRecurse(instance, false);
4328
- if (bm) {
4329
- shared.invokeArrayFns(bm);
4330
- }
4331
- if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
4332
- invokeVNodeHook(vnodeHook, parent, initialVNode);
4333
- }
4334
- toggleRecurse(instance, true);
4335
- if (el && hydrateNode) {
4336
- const hydrateSubTree = () => {
4337
- instance.subTree = renderComponentRoot(instance);
4338
- hydrateNode(
4339
- el,
4340
- instance.subTree,
4341
- instance,
4342
- parentSuspense,
4343
- null
4344
- );
4345
- };
4346
- if (isAsyncWrapperVNode && type.__asyncHydrate) {
4347
- type.__asyncHydrate(
4348
- el,
4349
- instance,
4350
- hydrateSubTree
4351
- );
4352
- } else {
4353
- hydrateSubTree();
4354
- }
4355
- } else {
4356
- if (root.ce && // @ts-expect-error _def is private
4357
- root.ce._def.shadowRoot !== false) {
4358
- root.ce._injectChildStyle(type);
4359
- }
4360
- const subTree = instance.subTree = renderComponentRoot(instance);
4361
- patch(
4362
- null,
4363
- subTree,
4298
+ }
4299
+ };
4300
+
4301
+ const queuePostRenderEffect = queueEffectWithSuspense ;
4302
+ function createRenderer(options) {
4303
+ return baseCreateRenderer(options);
4304
+ }
4305
+ function createHydrationRenderer(options) {
4306
+ return baseCreateRenderer(options, createHydrationFunctions);
4307
+ }
4308
+ function baseCreateRenderer(options, createHydrationFns) {
4309
+ const target = shared.getGlobalThis();
4310
+ target.__VUE__ = true;
4311
+ const {
4312
+ insert: hostInsert,
4313
+ remove: hostRemove,
4314
+ patchProp: hostPatchProp,
4315
+ createElement: hostCreateElement,
4316
+ createText: hostCreateText,
4317
+ createComment: hostCreateComment,
4318
+ setText: hostSetText,
4319
+ setElementText: hostSetElementText,
4320
+ parentNode: hostParentNode,
4321
+ nextSibling: hostNextSibling,
4322
+ setScopeId: hostSetScopeId = shared.NOOP,
4323
+ insertStaticContent: hostInsertStaticContent
4324
+ } = options;
4325
+ const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
4326
+ if (n1 === n2) {
4327
+ return;
4328
+ }
4329
+ if (n1 && !isSameVNodeType(n1, n2)) {
4330
+ anchor = getNextHostNode(n1);
4331
+ unmount(n1, parentComponent, parentSuspense, true);
4332
+ n1 = null;
4333
+ }
4334
+ if (n2.patchFlag === -2) {
4335
+ optimized = false;
4336
+ n2.dynamicChildren = null;
4337
+ }
4338
+ const { type, ref, shapeFlag } = n2;
4339
+ switch (type) {
4340
+ case Text:
4341
+ processText(n1, n2, container, anchor);
4342
+ break;
4343
+ case Comment:
4344
+ processCommentNode(n1, n2, container, anchor);
4345
+ break;
4346
+ case Static:
4347
+ if (n1 == null) {
4348
+ mountStaticNode(n2, container, anchor, namespace);
4349
+ }
4350
+ break;
4351
+ case Fragment:
4352
+ processFragment(
4353
+ n1,
4354
+ n2,
4355
+ container,
4356
+ anchor,
4357
+ parentComponent,
4358
+ parentSuspense,
4359
+ namespace,
4360
+ slotScopeIds,
4361
+ optimized
4362
+ );
4363
+ break;
4364
+ case VaporSlot:
4365
+ getVaporInterface(parentComponent, n2).slot(n1, n2, container, anchor);
4366
+ break;
4367
+ default:
4368
+ if (shapeFlag & 1) {
4369
+ processElement(
4370
+ n1,
4371
+ n2,
4364
4372
  container,
4365
4373
  anchor,
4366
- instance,
4374
+ parentComponent,
4367
4375
  parentSuspense,
4368
- namespace
4376
+ namespace,
4377
+ slotScopeIds,
4378
+ optimized
4369
4379
  );
4370
- initialVNode.el = subTree.el;
4371
- }
4372
- if (m) {
4373
- queuePostRenderEffect(m, void 0, parentSuspense);
4374
- }
4375
- if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
4376
- const scopedInitialVNode = initialVNode;
4377
- queuePostRenderEffect(
4378
- () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
4379
- void 0,
4380
- parentSuspense
4380
+ } else if (shapeFlag & 6) {
4381
+ processComponent(
4382
+ n1,
4383
+ n2,
4384
+ container,
4385
+ anchor,
4386
+ parentComponent,
4387
+ parentSuspense,
4388
+ namespace,
4389
+ slotScopeIds,
4390
+ optimized
4381
4391
  );
4382
- }
4383
- if (initialVNode.shapeFlag & 256 || parent && parent.vnode && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
4384
- instance.a && queuePostRenderEffect(instance.a, void 0, parentSuspense);
4385
- }
4386
- instance.isMounted = true;
4387
- this.initialVNode = this.container = this.anchor = null;
4388
- } else {
4389
- let { next, bu, u, parent, vnode } = instance;
4390
- {
4391
- const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
4392
- if (nonHydratedAsyncRoot) {
4393
- if (next) {
4394
- next.el = vnode.el;
4395
- updateComponentPreRender(instance, next, optimized);
4396
- }
4397
- nonHydratedAsyncRoot.asyncDep.then(() => {
4398
- if (!instance.isUnmounted) {
4399
- this.fn();
4400
- }
4401
- });
4402
- return;
4403
- }
4404
- }
4405
- let originNext = next;
4406
- let vnodeHook;
4407
- toggleRecurse(instance, false);
4408
- if (next) {
4409
- next.el = vnode.el;
4410
- updateComponentPreRender(instance, next, optimized);
4411
- } else {
4412
- next = vnode;
4413
- }
4414
- if (bu) {
4415
- shared.invokeArrayFns(bu);
4416
- }
4417
- if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
4418
- invokeVNodeHook(vnodeHook, parent, next, vnode);
4419
- }
4420
- toggleRecurse(instance, true);
4421
- const nextTree = renderComponentRoot(instance);
4422
- const prevTree = instance.subTree;
4423
- instance.subTree = nextTree;
4424
- patch(
4425
- prevTree,
4426
- nextTree,
4427
- // parent may have changed if it's in a teleport
4428
- hostParentNode(prevTree.el),
4429
- // anchor may have changed if it's in a fragment
4430
- getNextHostNode(prevTree),
4431
- instance,
4432
- parentSuspense,
4433
- namespace
4434
- );
4435
- next.el = nextTree.el;
4436
- if (originNext === null) {
4437
- updateHOCHostEl(instance, nextTree.el);
4438
- }
4439
- if (u) {
4440
- queuePostRenderEffect(u, void 0, parentSuspense);
4441
- }
4442
- if (vnodeHook = next.props && next.props.onVnodeUpdated) {
4443
- queuePostRenderEffect(
4444
- () => invokeVNodeHook(vnodeHook, parent, next, vnode),
4445
- void 0,
4446
- parentSuspense
4392
+ } else if (shapeFlag & 64) {
4393
+ type.process(
4394
+ n1,
4395
+ n2,
4396
+ container,
4397
+ anchor,
4398
+ parentComponent,
4399
+ parentSuspense,
4400
+ namespace,
4401
+ slotScopeIds,
4402
+ optimized,
4403
+ internals
4447
4404
  );
4448
- }
4405
+ } else if (shapeFlag & 128) {
4406
+ type.process(
4407
+ n1,
4408
+ n2,
4409
+ container,
4410
+ anchor,
4411
+ parentComponent,
4412
+ parentSuspense,
4413
+ namespace,
4414
+ slotScopeIds,
4415
+ optimized,
4416
+ internals
4417
+ );
4418
+ } else ;
4419
+ }
4420
+ if (ref != null && parentComponent) {
4421
+ setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
4422
+ } else if (ref == null && n1 && n1.ref != null) {
4423
+ setRef(n1.ref, null, parentSuspense, n1, true);
4424
+ }
4425
+ };
4426
+ const processText = (n1, n2, container, anchor) => {
4427
+ if (n1 == null) {
4428
+ hostInsert(
4429
+ n2.el = hostCreateText(n2.children),
4430
+ container,
4431
+ anchor
4432
+ );
4433
+ } else {
4434
+ const el = n2.el = n1.el;
4435
+ if (n2.children !== n1.children) {
4436
+ hostSetText(el, n2.children);
4449
4437
  }
4450
4438
  }
4451
- }
4452
- const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
4453
- const effect = instance.effect = new SetupRenderEffect(
4454
- instance,
4455
- initialVNode,
4439
+ };
4440
+ const processCommentNode = (n1, n2, container, anchor) => {
4441
+ if (n1 == null) {
4442
+ hostInsert(
4443
+ n2.el = hostCreateComment(n2.children || ""),
4444
+ container,
4445
+ anchor
4446
+ );
4447
+ } else {
4448
+ n2.el = n1.el;
4449
+ }
4450
+ };
4451
+ const mountStaticNode = (n2, container, anchor, namespace) => {
4452
+ [n2.el, n2.anchor] = hostInsertStaticContent(
4453
+ n2.children,
4456
4454
  container,
4457
4455
  anchor,
4458
- parentSuspense,
4459
4456
  namespace,
4460
- optimized
4457
+ n2.el,
4458
+ n2.anchor
4461
4459
  );
4462
- instance.update = effect.run.bind(effect);
4463
- toggleRecurse(instance, true);
4464
- effect.run();
4465
4460
  };
4466
- const updateComponentPreRender = (instance, nextVNode, optimized) => {
4467
- nextVNode.component = instance;
4468
- const prevProps = instance.vnode.props;
4469
- instance.vnode = nextVNode;
4470
- instance.next = null;
4471
- updateProps(instance, nextVNode.props, prevProps, optimized);
4472
- updateSlots(instance, nextVNode.children, optimized);
4473
- const prevSub = reactivity.setActiveSub();
4474
- flushPreFlushCbs(instance);
4475
- reactivity.setActiveSub(prevSub);
4461
+ const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
4462
+ let next;
4463
+ while (el && el !== anchor) {
4464
+ next = hostNextSibling(el);
4465
+ hostInsert(el, container, nextSibling);
4466
+ el = next;
4467
+ }
4468
+ hostInsert(anchor, container, nextSibling);
4476
4469
  };
4477
- const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
4478
- const c1 = n1 && n1.children;
4479
- const prevShapeFlag = n1 ? n1.shapeFlag : 0;
4480
- const c2 = n2.children;
4481
- const { patchFlag, shapeFlag } = n2;
4482
- if (patchFlag > 0) {
4483
- if (patchFlag & 128) {
4484
- patchKeyedChildren(
4485
- c1,
4486
- c2,
4487
- container,
4488
- anchor,
4489
- parentComponent,
4490
- parentSuspense,
4491
- namespace,
4492
- slotScopeIds,
4493
- optimized
4494
- );
4495
- return;
4496
- } else if (patchFlag & 256) {
4497
- patchUnkeyedChildren(
4498
- c1,
4499
- c2,
4500
- container,
4501
- anchor,
4470
+ const removeStaticNode = ({ el, anchor }) => {
4471
+ let next;
4472
+ while (el && el !== anchor) {
4473
+ next = hostNextSibling(el);
4474
+ hostRemove(el);
4475
+ el = next;
4476
+ }
4477
+ hostRemove(anchor);
4478
+ };
4479
+ const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4480
+ if (n2.type === "svg") {
4481
+ namespace = "svg";
4482
+ } else if (n2.type === "math") {
4483
+ namespace = "mathml";
4484
+ }
4485
+ if (n1 == null) {
4486
+ mountElement(
4487
+ n2,
4488
+ container,
4489
+ anchor,
4490
+ parentComponent,
4491
+ parentSuspense,
4492
+ namespace,
4493
+ slotScopeIds,
4494
+ optimized
4495
+ );
4496
+ } else {
4497
+ const customElement = !!(n1.el && n1.el._isVueCE) ? n1.el : null;
4498
+ try {
4499
+ if (customElement) {
4500
+ customElement._beginPatch();
4501
+ }
4502
+ patchElement(
4503
+ n1,
4504
+ n2,
4502
4505
  parentComponent,
4503
4506
  parentSuspense,
4504
4507
  namespace,
4505
4508
  slotScopeIds,
4506
4509
  optimized
4507
4510
  );
4508
- return;
4511
+ } finally {
4512
+ if (customElement) {
4513
+ customElement._endPatch();
4514
+ }
4509
4515
  }
4510
4516
  }
4517
+ };
4518
+ const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4519
+ let el;
4520
+ let vnodeHook;
4521
+ const { props, shapeFlag, transition, dirs } = vnode;
4522
+ el = vnode.el = hostCreateElement(
4523
+ vnode.type,
4524
+ namespace,
4525
+ props && props.is,
4526
+ props
4527
+ );
4511
4528
  if (shapeFlag & 8) {
4512
- if (prevShapeFlag & 16) {
4513
- unmountChildren(c1, parentComponent, parentSuspense);
4529
+ hostSetElementText(el, vnode.children);
4530
+ } else if (shapeFlag & 16) {
4531
+ mountChildren(
4532
+ vnode.children,
4533
+ el,
4534
+ null,
4535
+ parentComponent,
4536
+ parentSuspense,
4537
+ resolveChildrenNamespace(vnode, namespace),
4538
+ slotScopeIds,
4539
+ optimized
4540
+ );
4541
+ }
4542
+ if (dirs) {
4543
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
4544
+ }
4545
+ setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
4546
+ if (props) {
4547
+ for (const key in props) {
4548
+ if (key !== "value" && !shared.isReservedProp(key)) {
4549
+ hostPatchProp(el, key, null, props[key], namespace, parentComponent);
4550
+ }
4514
4551
  }
4515
- if (c2 !== c1) {
4516
- hostSetElementText(container, c2);
4552
+ if ("value" in props) {
4553
+ hostPatchProp(el, "value", null, props.value, namespace);
4554
+ }
4555
+ if (vnodeHook = props.onVnodeBeforeMount) {
4556
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
4517
4557
  }
4558
+ }
4559
+ if (dirs) {
4560
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
4561
+ }
4562
+ if (transition) {
4563
+ performTransitionEnter(
4564
+ el,
4565
+ transition,
4566
+ () => hostInsert(el, container, anchor),
4567
+ parentSuspense
4568
+ );
4518
4569
  } else {
4519
- if (prevShapeFlag & 16) {
4520
- if (shapeFlag & 16) {
4521
- patchKeyedChildren(
4522
- c1,
4523
- c2,
4524
- container,
4525
- anchor,
4526
- parentComponent,
4527
- parentSuspense,
4528
- namespace,
4529
- slotScopeIds,
4530
- optimized
4531
- );
4532
- } else {
4533
- unmountChildren(c1, parentComponent, parentSuspense, true);
4534
- }
4570
+ hostInsert(el, container, anchor);
4571
+ }
4572
+ if ((vnodeHook = props && props.onVnodeMounted) || dirs) {
4573
+ queuePostRenderEffect(
4574
+ () => {
4575
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4576
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
4577
+ },
4578
+ void 0,
4579
+ parentSuspense
4580
+ );
4581
+ }
4582
+ };
4583
+ const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
4584
+ if (scopeId) {
4585
+ hostSetScopeId(el, scopeId);
4586
+ }
4587
+ if (slotScopeIds) {
4588
+ for (let i = 0; i < slotScopeIds.length; i++) {
4589
+ hostSetScopeId(el, slotScopeIds[i]);
4590
+ }
4591
+ }
4592
+ const inheritedScopeIds = getInheritedScopeIds(vnode, parentComponent);
4593
+ for (let i = 0; i < inheritedScopeIds.length; i++) {
4594
+ hostSetScopeId(el, inheritedScopeIds[i]);
4595
+ }
4596
+ };
4597
+ const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => {
4598
+ for (let i = start; i < children.length; i++) {
4599
+ const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
4600
+ patch(
4601
+ null,
4602
+ child,
4603
+ container,
4604
+ anchor,
4605
+ parentComponent,
4606
+ parentSuspense,
4607
+ namespace,
4608
+ slotScopeIds,
4609
+ optimized
4610
+ );
4611
+ }
4612
+ };
4613
+ const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4614
+ const el = n2.el = n1.el;
4615
+ let { patchFlag, dynamicChildren, dirs } = n2;
4616
+ patchFlag |= n1.patchFlag & 16;
4617
+ const oldProps = n1.props || shared.EMPTY_OBJ;
4618
+ const newProps = n2.props || shared.EMPTY_OBJ;
4619
+ let vnodeHook;
4620
+ parentComponent && toggleRecurse(parentComponent, false);
4621
+ if (vnodeHook = newProps.onVnodeBeforeUpdate) {
4622
+ invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4623
+ }
4624
+ if (dirs) {
4625
+ invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
4626
+ }
4627
+ parentComponent && toggleRecurse(parentComponent, true);
4628
+ if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
4629
+ hostSetElementText(el, "");
4630
+ }
4631
+ if (dynamicChildren) {
4632
+ patchBlockChildren(
4633
+ n1.dynamicChildren,
4634
+ dynamicChildren,
4635
+ el,
4636
+ parentComponent,
4637
+ parentSuspense,
4638
+ resolveChildrenNamespace(n2, namespace),
4639
+ slotScopeIds
4640
+ );
4641
+ } else if (!optimized) {
4642
+ patchChildren(
4643
+ n1,
4644
+ n2,
4645
+ el,
4646
+ null,
4647
+ parentComponent,
4648
+ parentSuspense,
4649
+ resolveChildrenNamespace(n2, namespace),
4650
+ slotScopeIds,
4651
+ false
4652
+ );
4653
+ }
4654
+ if (patchFlag > 0) {
4655
+ if (patchFlag & 16) {
4656
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4535
4657
  } else {
4536
- if (prevShapeFlag & 8) {
4537
- hostSetElementText(container, "");
4658
+ if (patchFlag & 2) {
4659
+ if (oldProps.class !== newProps.class) {
4660
+ hostPatchProp(el, "class", null, newProps.class, namespace);
4661
+ }
4538
4662
  }
4539
- if (shapeFlag & 16) {
4540
- mountChildren(
4541
- c2,
4542
- container,
4543
- anchor,
4544
- parentComponent,
4545
- parentSuspense,
4546
- namespace,
4547
- slotScopeIds,
4548
- optimized
4549
- );
4663
+ if (patchFlag & 4) {
4664
+ hostPatchProp(el, "style", oldProps.style, newProps.style, namespace);
4665
+ }
4666
+ if (patchFlag & 8) {
4667
+ const propsToUpdate = n2.dynamicProps;
4668
+ for (let i = 0; i < propsToUpdate.length; i++) {
4669
+ const key = propsToUpdate[i];
4670
+ const prev = oldProps[key];
4671
+ const next = newProps[key];
4672
+ if (next !== prev || key === "value") {
4673
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4674
+ }
4675
+ }
4676
+ }
4677
+ }
4678
+ if (patchFlag & 1) {
4679
+ if (n1.children !== n2.children) {
4680
+ hostSetElementText(el, n2.children);
4550
4681
  }
4551
4682
  }
4683
+ } else if (!optimized && dynamicChildren == null) {
4684
+ patchProps(el, oldProps, newProps, parentComponent, namespace);
4685
+ }
4686
+ if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
4687
+ queuePostRenderEffect(
4688
+ () => {
4689
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4690
+ dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
4691
+ },
4692
+ void 0,
4693
+ parentSuspense
4694
+ );
4552
4695
  }
4553
4696
  };
4554
- const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4555
- c1 = c1 || shared.EMPTY_ARR;
4556
- c2 = c2 || shared.EMPTY_ARR;
4557
- const oldLength = c1.length;
4558
- const newLength = c2.length;
4559
- const commonLength = Math.min(oldLength, newLength);
4560
- let i;
4561
- for (i = 0; i < commonLength; i++) {
4562
- const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4697
+ const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => {
4698
+ for (let i = 0; i < newChildren.length; i++) {
4699
+ const oldVNode = oldChildren[i];
4700
+ const newVNode = newChildren[i];
4701
+ const container = (
4702
+ // oldVNode may be an errored async setup() component inside Suspense
4703
+ // which will not have a mounted element
4704
+ oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
4705
+ // of the Fragment itself so it can move its children.
4706
+ (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
4707
+ // which also requires the correct parent container
4708
+ !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
4709
+ oldVNode.shapeFlag & (6 | 64 | 128)) ? hostParentNode(oldVNode.el) : (
4710
+ // In other cases, the parent container is not actually used so we
4711
+ // just pass the block element here to avoid a DOM parentNode call.
4712
+ fallbackContainer
4713
+ )
4714
+ );
4563
4715
  patch(
4564
- c1[i],
4565
- nextChild,
4716
+ oldVNode,
4717
+ newVNode,
4566
4718
  container,
4567
4719
  null,
4568
4720
  parentComponent,
4569
4721
  parentSuspense,
4570
4722
  namespace,
4571
4723
  slotScopeIds,
4572
- optimized
4724
+ true
4573
4725
  );
4574
4726
  }
4575
- if (oldLength > newLength) {
4576
- unmountChildren(
4577
- c1,
4578
- parentComponent,
4579
- parentSuspense,
4580
- true,
4581
- false,
4582
- commonLength
4583
- );
4584
- } else {
4727
+ };
4728
+ const patchProps = (el, oldProps, newProps, parentComponent, namespace) => {
4729
+ if (oldProps !== newProps) {
4730
+ if (oldProps !== shared.EMPTY_OBJ) {
4731
+ for (const key in oldProps) {
4732
+ if (!shared.isReservedProp(key) && !(key in newProps)) {
4733
+ hostPatchProp(
4734
+ el,
4735
+ key,
4736
+ oldProps[key],
4737
+ null,
4738
+ namespace,
4739
+ parentComponent
4740
+ );
4741
+ }
4742
+ }
4743
+ }
4744
+ for (const key in newProps) {
4745
+ if (shared.isReservedProp(key)) continue;
4746
+ const next = newProps[key];
4747
+ const prev = oldProps[key];
4748
+ if (next !== prev && key !== "value") {
4749
+ hostPatchProp(el, key, prev, next, namespace, parentComponent);
4750
+ }
4751
+ }
4752
+ if ("value" in newProps) {
4753
+ hostPatchProp(el, "value", oldProps.value, newProps.value, namespace);
4754
+ }
4755
+ }
4756
+ };
4757
+ const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4758
+ const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
4759
+ const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
4760
+ let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
4761
+ if (fragmentSlotScopeIds) {
4762
+ slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
4763
+ }
4764
+ if (n1 == null) {
4765
+ hostInsert(fragmentStartAnchor, container, anchor);
4766
+ hostInsert(fragmentEndAnchor, container, anchor);
4585
4767
  mountChildren(
4586
- c2,
4768
+ // #10007
4769
+ // such fragment like `<></>` will be compiled into
4770
+ // a fragment which doesn't have a children.
4771
+ // In this case fallback to an empty array
4772
+ n2.children || [],
4587
4773
  container,
4588
- anchor,
4774
+ fragmentEndAnchor,
4589
4775
  parentComponent,
4590
4776
  parentSuspense,
4591
4777
  namespace,
4592
4778
  slotScopeIds,
4593
- optimized,
4594
- commonLength
4779
+ optimized
4595
4780
  );
4596
- }
4597
- };
4598
- const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4599
- let i = 0;
4600
- const l2 = c2.length;
4601
- let e1 = c1.length - 1;
4602
- let e2 = l2 - 1;
4603
- while (i <= e1 && i <= e2) {
4604
- const n1 = c1[i];
4605
- const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4606
- if (isSameVNodeType(n1, n2)) {
4607
- patch(
4608
- n1,
4609
- n2,
4781
+ } else {
4782
+ if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
4783
+ // of renderSlot() with no valid children
4784
+ n1.dynamicChildren) {
4785
+ patchBlockChildren(
4786
+ n1.dynamicChildren,
4787
+ dynamicChildren,
4610
4788
  container,
4611
- null,
4612
4789
  parentComponent,
4613
4790
  parentSuspense,
4614
4791
  namespace,
4615
- slotScopeIds,
4616
- optimized
4792
+ slotScopeIds
4617
4793
  );
4794
+ if (
4795
+ // #2080 if the stable fragment has a key, it's a <template v-for> that may
4796
+ // get moved around. Make sure all root level vnodes inherit el.
4797
+ // #2134 or if it's a component root, it may also get moved around
4798
+ // as the component is being moved.
4799
+ n2.key != null || parentComponent && n2 === parentComponent.subTree
4800
+ ) {
4801
+ traverseStaticChildren(
4802
+ n1,
4803
+ n2,
4804
+ true
4805
+ /* shallow */
4806
+ );
4807
+ }
4618
4808
  } else {
4619
- break;
4620
- }
4621
- i++;
4622
- }
4623
- while (i <= e1 && i <= e2) {
4624
- const n1 = c1[e1];
4625
- const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
4626
- if (isSameVNodeType(n1, n2)) {
4627
- patch(
4809
+ patchChildren(
4628
4810
  n1,
4629
4811
  n2,
4630
4812
  container,
4631
- null,
4813
+ fragmentEndAnchor,
4632
4814
  parentComponent,
4633
4815
  parentSuspense,
4634
4816
  namespace,
4635
4817
  slotScopeIds,
4636
4818
  optimized
4637
4819
  );
4638
- } else {
4639
- break;
4640
4820
  }
4641
- e1--;
4642
- e2--;
4643
4821
  }
4644
- if (i > e1) {
4645
- if (i <= e2) {
4646
- const nextPos = e2 + 1;
4647
- const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
4648
- while (i <= e2) {
4649
- patch(
4650
- null,
4651
- c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
4822
+ };
4823
+ const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
4824
+ n2.slotScopeIds = slotScopeIds;
4825
+ if (n2.type.__vapor) {
4826
+ if (n1 == null) {
4827
+ if (n2.shapeFlag & 512) {
4828
+ getVaporInterface(parentComponent, n2).activate(
4829
+ n2,
4652
4830
  container,
4653
4831
  anchor,
4654
- parentComponent,
4655
- parentSuspense,
4656
- namespace,
4657
- slotScopeIds,
4658
- optimized
4832
+ parentComponent
4659
4833
  );
4660
- i++;
4661
- }
4662
- }
4663
- } else if (i > e2) {
4664
- while (i <= e1) {
4665
- unmount(c1[i], parentComponent, parentSuspense, true);
4666
- i++;
4667
- }
4668
- } else {
4669
- const s1 = i;
4670
- const s2 = i;
4671
- const keyToNewIndexMap = /* @__PURE__ */ new Map();
4672
- for (i = s2; i <= e2; i++) {
4673
- const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
4674
- if (nextChild.key != null) {
4675
- keyToNewIndexMap.set(nextChild.key, i);
4676
- }
4677
- }
4678
- let j;
4679
- let patched = 0;
4680
- const toBePatched = e2 - s2 + 1;
4681
- let moved = false;
4682
- let maxNewIndexSoFar = 0;
4683
- const newIndexToOldIndexMap = new Array(toBePatched);
4684
- for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
4685
- for (i = s1; i <= e1; i++) {
4686
- const prevChild = c1[i];
4687
- if (patched >= toBePatched) {
4688
- unmount(prevChild, parentComponent, parentSuspense, true);
4689
- continue;
4690
- }
4691
- let newIndex;
4692
- if (prevChild.key != null) {
4693
- newIndex = keyToNewIndexMap.get(prevChild.key);
4694
- } else {
4695
- for (j = s2; j <= e2; j++) {
4696
- if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
4697
- newIndex = j;
4698
- break;
4699
- }
4700
- }
4701
- }
4702
- if (newIndex === void 0) {
4703
- unmount(prevChild, parentComponent, parentSuspense, true);
4704
4834
  } else {
4705
- newIndexToOldIndexMap[newIndex - s2] = i + 1;
4706
- if (newIndex >= maxNewIndexSoFar) {
4707
- maxNewIndexSoFar = newIndex;
4708
- } else {
4709
- moved = true;
4710
- }
4711
- patch(
4712
- prevChild,
4713
- c2[newIndex],
4714
- container,
4715
- null,
4716
- parentComponent,
4717
- parentSuspense,
4718
- namespace,
4719
- slotScopeIds,
4720
- optimized
4721
- );
4722
- patched++;
4723
- }
4724
- }
4725
- const increasingNewIndexSequence = moved ? shared.getSequence(newIndexToOldIndexMap) : shared.EMPTY_ARR;
4726
- j = increasingNewIndexSequence.length - 1;
4727
- for (i = toBePatched - 1; i >= 0; i--) {
4728
- const nextIndex = s2 + i;
4729
- const nextChild = c2[nextIndex];
4730
- const anchorVNode = c2[nextIndex + 1];
4731
- const anchor = nextIndex + 1 < l2 ? (
4732
- // #13559, fallback to el placeholder for unresolved async component
4733
- anchorVNode.el || anchorVNode.placeholder
4734
- ) : parentAnchor;
4735
- if (newIndexToOldIndexMap[i] === 0) {
4736
- patch(
4737
- null,
4738
- nextChild,
4835
+ getVaporInterface(parentComponent, n2).mount(
4836
+ n2,
4739
4837
  container,
4740
4838
  anchor,
4741
4839
  parentComponent,
4742
- parentSuspense,
4743
- namespace,
4744
- slotScopeIds,
4745
- optimized
4840
+ parentSuspense
4746
4841
  );
4747
- } else if (moved) {
4748
- if (j < 0 || i !== increasingNewIndexSequence[j]) {
4749
- move(
4750
- nextChild,
4751
- container,
4752
- anchor,
4753
- 2,
4754
- parentComponent
4755
- );
4756
- } else {
4757
- j--;
4758
- }
4759
4842
  }
4843
+ } else {
4844
+ getVaporInterface(parentComponent, n2).update(
4845
+ n1,
4846
+ n2,
4847
+ shouldUpdateComponent(n1, n2, optimized)
4848
+ );
4760
4849
  }
4761
- }
4762
- };
4763
- const move = (vnode, container, anchor, moveType, parentComponent, parentSuspense = null) => {
4764
- const { el, type, transition, children, shapeFlag } = vnode;
4765
- if (shapeFlag & 6) {
4766
- if (type.__vapor) {
4767
- getVaporInterface(parentComponent, vnode).move(vnode, container, anchor);
4850
+ } else if (n1 == null) {
4851
+ if (n2.shapeFlag & 512) {
4852
+ parentComponent.ctx.activate(
4853
+ n2,
4854
+ container,
4855
+ anchor,
4856
+ namespace,
4857
+ optimized
4858
+ );
4768
4859
  } else {
4769
- move(
4770
- vnode.component.subTree,
4860
+ mountComponent(
4861
+ n2,
4771
4862
  container,
4772
4863
  anchor,
4773
- moveType,
4774
- parentComponent
4864
+ parentComponent,
4865
+ parentSuspense,
4866
+ namespace,
4867
+ optimized
4775
4868
  );
4776
4869
  }
4777
- return;
4870
+ } else {
4871
+ updateComponent(n1, n2, optimized);
4778
4872
  }
4779
- if (shapeFlag & 128) {
4780
- vnode.suspense.move(container, anchor, moveType);
4781
- return;
4873
+ };
4874
+ const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => {
4875
+ const instance = (initialVNode.component = createComponentInstance(
4876
+ initialVNode,
4877
+ parentComponent,
4878
+ parentSuspense
4879
+ ));
4880
+ if (isKeepAlive(initialVNode)) {
4881
+ instance.ctx.renderer = internals;
4782
4882
  }
4783
- if (shapeFlag & 64) {
4784
- type.move(
4785
- vnode,
4883
+ {
4884
+ setupComponent(instance, false, optimized);
4885
+ }
4886
+ if (instance.asyncDep) {
4887
+ if (parentSuspense) {
4888
+ const hydratedEl = instance.vnode.el;
4889
+ parentSuspense.registerDep(instance, (setupResult) => {
4890
+ const { vnode } = instance;
4891
+ handleSetupResult(instance, setupResult, false);
4892
+ if (hydratedEl) {
4893
+ vnode.el = hydratedEl;
4894
+ }
4895
+ const placeholder = !hydratedEl && instance.subTree.el;
4896
+ setupRenderEffect(
4897
+ instance,
4898
+ vnode,
4899
+ // component may have been moved before resolve.
4900
+ // if this is not a hydration, instance.subTree will be the comment
4901
+ // placeholder.
4902
+ hostParentNode(hydratedEl || instance.subTree.el),
4903
+ // anchor will not be used if this is hydration, so only need to
4904
+ // consider the comment placeholder case.
4905
+ hydratedEl ? null : getNextHostNode(instance.subTree),
4906
+ parentSuspense,
4907
+ namespace,
4908
+ optimized
4909
+ );
4910
+ if (placeholder) {
4911
+ vnode.placeholder = null;
4912
+ hostRemove(placeholder);
4913
+ }
4914
+ updateHOCHostEl(instance, vnode.el);
4915
+ });
4916
+ }
4917
+ if (!initialVNode.el) {
4918
+ const placeholder = instance.subTree = createVNode(Comment);
4919
+ processCommentNode(null, placeholder, container, anchor);
4920
+ initialVNode.placeholder = placeholder.el;
4921
+ }
4922
+ } else {
4923
+ setupRenderEffect(
4924
+ instance,
4925
+ initialVNode,
4786
4926
  container,
4787
4927
  anchor,
4788
- internals,
4789
- parentComponent
4928
+ parentSuspense,
4929
+ namespace,
4930
+ optimized
4790
4931
  );
4791
- return;
4792
4932
  }
4793
- if (type === Fragment) {
4794
- hostInsert(el, container, anchor);
4795
- for (let i = 0; i < children.length; i++) {
4796
- move(
4797
- children[i],
4798
- container,
4799
- anchor,
4800
- moveType,
4801
- parentComponent
4802
- );
4933
+ };
4934
+ const updateComponent = (n1, n2, optimized) => {
4935
+ const instance = n2.component = n1.component;
4936
+ if (shouldUpdateComponent(n1, n2, optimized)) {
4937
+ if (instance.asyncDep && !instance.asyncResolved) {
4938
+ updateComponentPreRender(instance, n2, optimized);
4939
+ return;
4940
+ } else {
4941
+ instance.next = n2;
4942
+ instance.effect.run();
4803
4943
  }
4804
- hostInsert(vnode.anchor, container, anchor);
4805
- return;
4944
+ } else {
4945
+ n2.el = n1.el;
4946
+ instance.vnode = n2;
4806
4947
  }
4807
- if (type === Static) {
4808
- moveStaticNode(vnode, container, anchor);
4809
- return;
4948
+ };
4949
+ class SetupRenderEffect extends reactivity.ReactiveEffect {
4950
+ constructor(instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) {
4951
+ const prevScope = reactivity.setCurrentScope(instance.scope);
4952
+ super();
4953
+ this.instance = instance;
4954
+ this.initialVNode = initialVNode;
4955
+ this.container = container;
4956
+ this.anchor = anchor;
4957
+ this.parentSuspense = parentSuspense;
4958
+ this.namespace = namespace;
4959
+ this.optimized = optimized;
4960
+ reactivity.setCurrentScope(prevScope);
4961
+ this.job = instance.job = () => {
4962
+ if (this.dirty) {
4963
+ this.run();
4964
+ }
4965
+ };
4966
+ this.job.i = instance;
4810
4967
  }
4811
- const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
4812
- if (needTransition2) {
4813
- if (moveType === 0) {
4814
- performTransitionEnter(
4815
- el,
4816
- transition,
4817
- () => hostInsert(el, container, anchor),
4968
+ notify() {
4969
+ if (!(this.flags & 256)) {
4970
+ const job = this.job;
4971
+ queueJob(job, job.i.uid);
4972
+ }
4973
+ }
4974
+ fn() {
4975
+ const {
4976
+ instance,
4977
+ initialVNode,
4978
+ container,
4979
+ anchor,
4980
+ parentSuspense,
4981
+ namespace,
4982
+ optimized
4983
+ } = this;
4984
+ if (!instance.isMounted) {
4985
+ let vnodeHook;
4986
+ const { el, props } = initialVNode;
4987
+ const { bm, m, parent, root, type } = instance;
4988
+ const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4989
+ toggleRecurse(instance, false);
4990
+ if (bm) {
4991
+ shared.invokeArrayFns(bm);
4992
+ }
4993
+ if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
4994
+ invokeVNodeHook(vnodeHook, parent, initialVNode);
4995
+ }
4996
+ toggleRecurse(instance, true);
4997
+ if (el && hydrateNode) {
4998
+ const hydrateSubTree = () => {
4999
+ instance.subTree = renderComponentRoot(instance);
5000
+ hydrateNode(
5001
+ el,
5002
+ instance.subTree,
5003
+ instance,
5004
+ parentSuspense,
5005
+ null
5006
+ );
5007
+ };
5008
+ if (isAsyncWrapperVNode && type.__asyncHydrate) {
5009
+ type.__asyncHydrate(
5010
+ el,
5011
+ instance,
5012
+ hydrateSubTree
5013
+ );
5014
+ } else {
5015
+ hydrateSubTree();
5016
+ }
5017
+ } else {
5018
+ if (root.ce && // @ts-expect-error _def is private
5019
+ root.ce._def.shadowRoot !== false) {
5020
+ root.ce._injectChildStyle(type);
5021
+ }
5022
+ const subTree = instance.subTree = renderComponentRoot(instance);
5023
+ patch(
5024
+ null,
5025
+ subTree,
5026
+ container,
5027
+ anchor,
5028
+ instance,
5029
+ parentSuspense,
5030
+ namespace
5031
+ );
5032
+ initialVNode.el = subTree.el;
5033
+ }
5034
+ if (m) {
5035
+ queuePostRenderEffect(m, void 0, parentSuspense);
5036
+ }
5037
+ if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
5038
+ const scopedInitialVNode = initialVNode;
5039
+ queuePostRenderEffect(
5040
+ () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
5041
+ void 0,
5042
+ parentSuspense
5043
+ );
5044
+ }
5045
+ if (initialVNode.shapeFlag & 256 || parent && parent.vnode && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
5046
+ instance.a && queuePostRenderEffect(instance.a, void 0, parentSuspense);
5047
+ }
5048
+ instance.isMounted = true;
5049
+ this.initialVNode = this.container = this.anchor = null;
5050
+ } else {
5051
+ let { next, bu, u, parent, vnode } = instance;
5052
+ {
5053
+ const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
5054
+ if (nonHydratedAsyncRoot) {
5055
+ if (next) {
5056
+ next.el = vnode.el;
5057
+ updateComponentPreRender(instance, next, optimized);
5058
+ }
5059
+ nonHydratedAsyncRoot.asyncDep.then(() => {
5060
+ if (!instance.isUnmounted) {
5061
+ this.fn();
5062
+ }
5063
+ });
5064
+ return;
5065
+ }
5066
+ }
5067
+ let originNext = next;
5068
+ let vnodeHook;
5069
+ toggleRecurse(instance, false);
5070
+ if (next) {
5071
+ next.el = vnode.el;
5072
+ updateComponentPreRender(instance, next, optimized);
5073
+ } else {
5074
+ next = vnode;
5075
+ }
5076
+ if (bu) {
5077
+ shared.invokeArrayFns(bu);
5078
+ }
5079
+ if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
5080
+ invokeVNodeHook(vnodeHook, parent, next, vnode);
5081
+ }
5082
+ toggleRecurse(instance, true);
5083
+ const nextTree = renderComponentRoot(instance);
5084
+ const prevTree = instance.subTree;
5085
+ instance.subTree = nextTree;
5086
+ patch(
5087
+ prevTree,
5088
+ nextTree,
5089
+ // parent may have changed if it's in a teleport
5090
+ hostParentNode(prevTree.el),
5091
+ // anchor may have changed if it's in a fragment
5092
+ getNextHostNode(prevTree),
5093
+ instance,
4818
5094
  parentSuspense,
4819
- true
5095
+ namespace
4820
5096
  );
4821
- } else {
4822
- const { leave, delayLeave, afterLeave } = transition;
4823
- const remove2 = () => {
4824
- if (vnode.ctx.isUnmounted) {
4825
- hostRemove(el);
4826
- } else {
4827
- hostInsert(el, container, anchor);
4828
- }
4829
- };
4830
- const performLeave = () => {
4831
- if (el._isLeaving) {
4832
- el[leaveCbKey](
4833
- true
4834
- /* cancelled */
4835
- );
4836
- }
4837
- leave(el, () => {
4838
- remove2();
4839
- afterLeave && afterLeave();
4840
- });
4841
- };
4842
- if (delayLeave) {
4843
- delayLeave(el, remove2, performLeave);
4844
- } else {
4845
- performLeave();
5097
+ next.el = nextTree.el;
5098
+ if (originNext === null) {
5099
+ updateHOCHostEl(instance, nextTree.el);
5100
+ }
5101
+ if (u) {
5102
+ queuePostRenderEffect(u, void 0, parentSuspense);
5103
+ }
5104
+ if (vnodeHook = next.props && next.props.onVnodeUpdated) {
5105
+ queuePostRenderEffect(
5106
+ () => invokeVNodeHook(vnodeHook, parent, next, vnode),
5107
+ void 0,
5108
+ parentSuspense
5109
+ );
4846
5110
  }
4847
5111
  }
4848
- } else {
4849
- hostInsert(el, container, anchor);
4850
5112
  }
5113
+ }
5114
+ const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => {
5115
+ const effect = instance.effect = new SetupRenderEffect(
5116
+ instance,
5117
+ initialVNode,
5118
+ container,
5119
+ anchor,
5120
+ parentSuspense,
5121
+ namespace,
5122
+ optimized
5123
+ );
5124
+ instance.update = effect.run.bind(effect);
5125
+ toggleRecurse(instance, true);
5126
+ effect.run();
4851
5127
  };
4852
- const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
4853
- const {
4854
- type,
4855
- props,
4856
- ref,
4857
- children,
4858
- dynamicChildren,
4859
- shapeFlag,
4860
- patchFlag,
4861
- dirs,
4862
- cacheIndex
4863
- } = vnode;
4864
- if (patchFlag === -2) {
4865
- optimized = false;
4866
- }
4867
- if (ref != null) {
4868
- const prevSub = reactivity.setActiveSub();
4869
- setRef(ref, null, parentSuspense, vnode, true);
4870
- reactivity.setActiveSub(prevSub);
4871
- }
4872
- if (cacheIndex != null) {
4873
- parentComponent.renderCache[cacheIndex] = void 0;
4874
- }
4875
- if (shapeFlag & 256) {
4876
- if (vnode.type.__vapor) {
4877
- getVaporInterface(parentComponent, vnode).deactivate(
4878
- vnode,
4879
- parentComponent.ctx.getStorageContainer()
4880
- );
4881
- } else {
4882
- parentComponent.ctx.deactivate(vnode);
4883
- }
4884
- return;
4885
- }
4886
- const shouldInvokeDirs = shapeFlag & 1 && dirs;
4887
- const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
4888
- let vnodeHook;
4889
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
4890
- invokeVNodeHook(vnodeHook, parentComponent, vnode);
4891
- }
4892
- if (shapeFlag & 6) {
4893
- if (type.__vapor) {
4894
- getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
4895
- return;
4896
- } else {
4897
- unmountComponent(vnode.component, parentSuspense, doRemove);
4898
- }
4899
- } else {
4900
- if (shapeFlag & 128) {
4901
- vnode.suspense.unmount(parentSuspense, doRemove);
4902
- return;
4903
- }
4904
- if (shouldInvokeDirs) {
4905
- invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
4906
- }
4907
- if (shapeFlag & 64) {
4908
- vnode.type.remove(
4909
- vnode,
5128
+ const updateComponentPreRender = (instance, nextVNode, optimized) => {
5129
+ nextVNode.component = instance;
5130
+ const prevProps = instance.vnode.props;
5131
+ instance.vnode = nextVNode;
5132
+ instance.next = null;
5133
+ updateProps(instance, nextVNode.props, prevProps, optimized);
5134
+ updateSlots(instance, nextVNode.children, optimized);
5135
+ const prevSub = reactivity.setActiveSub();
5136
+ flushPreFlushCbs(instance);
5137
+ reactivity.setActiveSub(prevSub);
5138
+ };
5139
+ const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => {
5140
+ const c1 = n1 && n1.children;
5141
+ const prevShapeFlag = n1 ? n1.shapeFlag : 0;
5142
+ const c2 = n2.children;
5143
+ const { patchFlag, shapeFlag } = n2;
5144
+ if (patchFlag > 0) {
5145
+ if (patchFlag & 128) {
5146
+ patchKeyedChildren(
5147
+ c1,
5148
+ c2,
5149
+ container,
5150
+ anchor,
4910
5151
  parentComponent,
4911
5152
  parentSuspense,
4912
- internals,
4913
- doRemove
5153
+ namespace,
5154
+ slotScopeIds,
5155
+ optimized
4914
5156
  );
4915
- } else if (dynamicChildren && // #5154
4916
- // when v-once is used inside a block, setBlockTracking(-1) marks the
4917
- // parent block with hasOnce: true
4918
- // so that it doesn't take the fast path during unmount - otherwise
4919
- // components nested in v-once are never unmounted.
4920
- !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
4921
- (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
4922
- unmountChildren(
4923
- dynamicChildren,
5157
+ return;
5158
+ } else if (patchFlag & 256) {
5159
+ patchUnkeyedChildren(
5160
+ c1,
5161
+ c2,
5162
+ container,
5163
+ anchor,
4924
5164
  parentComponent,
4925
5165
  parentSuspense,
4926
- false,
4927
- true
5166
+ namespace,
5167
+ slotScopeIds,
5168
+ optimized
4928
5169
  );
4929
- } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
4930
- unmountChildren(children, parentComponent, parentSuspense);
4931
- }
4932
- if (type === VaporSlot) {
4933
- getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
4934
5170
  return;
4935
5171
  }
4936
- if (doRemove) {
4937
- remove(vnode);
4938
- }
4939
- }
4940
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
4941
- queuePostRenderEffect(
4942
- () => {
4943
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4944
- shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
4945
- },
4946
- void 0,
4947
- parentSuspense
4948
- );
4949
5172
  }
4950
- };
4951
- const remove = (vnode) => {
4952
- const { type, el, anchor, transition } = vnode;
4953
- if (type === Fragment) {
4954
- {
4955
- removeFragment(el, anchor);
5173
+ if (shapeFlag & 8) {
5174
+ if (prevShapeFlag & 16) {
5175
+ unmountChildren(c1, parentComponent, parentSuspense);
5176
+ }
5177
+ if (c2 !== c1) {
5178
+ hostSetElementText(container, c2);
4956
5179
  }
4957
- return;
4958
- }
4959
- if (type === Static) {
4960
- removeStaticNode(vnode);
4961
- return;
4962
- }
4963
- if (transition) {
4964
- performTransitionLeave(
4965
- el,
4966
- transition,
4967
- () => hostRemove(el),
4968
- !!(vnode.shapeFlag & 1)
4969
- );
4970
5180
  } else {
4971
- hostRemove(el);
4972
- }
4973
- };
4974
- const removeFragment = (cur, end) => {
4975
- let next;
4976
- while (cur !== end) {
4977
- next = hostNextSibling(cur);
4978
- hostRemove(cur);
4979
- cur = next;
4980
- }
4981
- hostRemove(end);
4982
- };
4983
- const unmountComponent = (instance, parentSuspense, doRemove) => {
4984
- const { bum, scope, effect, subTree, um, m, a } = instance;
4985
- invalidateMount(m);
4986
- invalidateMount(a);
4987
- if (bum) {
4988
- shared.invokeArrayFns(bum);
4989
- }
4990
- scope.stop();
4991
- if (effect) {
4992
- effect.stop();
4993
- unmount(subTree, instance, parentSuspense, doRemove);
4994
- }
4995
- if (um) {
4996
- queuePostRenderEffect(um, void 0, parentSuspense);
4997
- }
4998
- queuePostRenderEffect(
4999
- () => instance.isUnmounted = true,
5000
- void 0,
5001
- parentSuspense
5002
- );
5003
- };
5004
- const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
5005
- for (let i = start; i < children.length; i++) {
5006
- unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
5007
- }
5008
- };
5009
- const getNextHostNode = (vnode) => {
5010
- if (vnode.shapeFlag & 6) {
5011
- if (vnode.type.__vapor) {
5012
- return hostNextSibling(vnode.anchor);
5181
+ if (prevShapeFlag & 16) {
5182
+ if (shapeFlag & 16) {
5183
+ patchKeyedChildren(
5184
+ c1,
5185
+ c2,
5186
+ container,
5187
+ anchor,
5188
+ parentComponent,
5189
+ parentSuspense,
5190
+ namespace,
5191
+ slotScopeIds,
5192
+ optimized
5193
+ );
5194
+ } else {
5195
+ unmountChildren(c1, parentComponent, parentSuspense, true);
5196
+ }
5197
+ } else {
5198
+ if (prevShapeFlag & 8) {
5199
+ hostSetElementText(container, "");
5200
+ }
5201
+ if (shapeFlag & 16) {
5202
+ mountChildren(
5203
+ c2,
5204
+ container,
5205
+ anchor,
5206
+ parentComponent,
5207
+ parentSuspense,
5208
+ namespace,
5209
+ slotScopeIds,
5210
+ optimized
5211
+ );
5212
+ }
5013
5213
  }
5014
- return getNextHostNode(vnode.component.subTree);
5015
- }
5016
- if (vnode.shapeFlag & 128) {
5017
- return vnode.suspense.next();
5018
5214
  }
5019
- const el = hostNextSibling(vnode.anchor || vnode.el);
5020
- const teleportEnd = el && el[TeleportEndKey];
5021
- return teleportEnd ? hostNextSibling(teleportEnd) : el;
5022
5215
  };
5023
- const render = (vnode, container, namespace) => {
5024
- if (vnode == null) {
5025
- if (container._vnode) {
5026
- unmount(container._vnode, null, null, true);
5027
- }
5028
- } else {
5216
+ const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
5217
+ c1 = c1 || shared.EMPTY_ARR;
5218
+ c2 = c2 || shared.EMPTY_ARR;
5219
+ const oldLength = c1.length;
5220
+ const newLength = c2.length;
5221
+ const commonLength = Math.min(oldLength, newLength);
5222
+ let i;
5223
+ for (i = 0; i < commonLength; i++) {
5224
+ const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
5029
5225
  patch(
5030
- container._vnode || null,
5031
- vnode,
5226
+ c1[i],
5227
+ nextChild,
5032
5228
  container,
5033
5229
  null,
5034
- null,
5035
- null,
5036
- namespace
5230
+ parentComponent,
5231
+ parentSuspense,
5232
+ namespace,
5233
+ slotScopeIds,
5234
+ optimized
5037
5235
  );
5038
5236
  }
5039
- container._vnode = vnode;
5040
- flushOnAppMount();
5041
- };
5042
- const internals = {
5043
- p: patch,
5044
- um: unmount,
5045
- m: move,
5046
- r: remove,
5047
- mt: mountComponent,
5048
- umt: unmountComponent,
5049
- mc: mountChildren,
5050
- pc: patchChildren,
5051
- pbc: patchBlockChildren,
5052
- n: getNextHostNode,
5053
- o: options
5054
- };
5055
- let hydrate;
5056
- let hydrateNode;
5057
- if (createHydrationFns) {
5058
- [hydrate, hydrateNode] = createHydrationFns(
5059
- internals
5060
- );
5061
- }
5062
- const mountApp = (app, container, isHydrate, namespace) => {
5063
- const vnode = app._ceVNode || createVNode(app._component, app._props);
5064
- vnode.appContext = app._context;
5065
- if (namespace === true) {
5066
- namespace = "svg";
5067
- } else if (namespace === false) {
5068
- namespace = void 0;
5069
- }
5070
- if (isHydrate && hydrate) {
5071
- hydrate(vnode, container);
5237
+ if (oldLength > newLength) {
5238
+ unmountChildren(
5239
+ c1,
5240
+ parentComponent,
5241
+ parentSuspense,
5242
+ true,
5243
+ false,
5244
+ commonLength
5245
+ );
5072
5246
  } else {
5073
- render(vnode, container, namespace);
5247
+ mountChildren(
5248
+ c2,
5249
+ container,
5250
+ anchor,
5251
+ parentComponent,
5252
+ parentSuspense,
5253
+ namespace,
5254
+ slotScopeIds,
5255
+ optimized,
5256
+ commonLength
5257
+ );
5074
5258
  }
5075
- return vnode.component;
5076
- };
5077
- const unmountApp = (app) => {
5078
- render(null, app._container);
5079
- };
5080
- return {
5081
- render,
5082
- hydrate,
5083
- hydrateNode,
5084
- internals,
5085
- createApp: createAppAPI(
5086
- mountApp,
5087
- unmountApp,
5088
- getComponentPublicInstance)
5089
5259
  };
5090
- }
5091
- function resolveChildrenNamespace({ type, props }, currentNamespace) {
5092
- return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
5093
- }
5094
- function toggleRecurse({ effect, job, vapor }, allowed) {
5095
- if (!vapor) {
5096
- if (allowed) {
5097
- effect.flags |= 128;
5098
- job.flags |= 2;
5099
- } else {
5100
- effect.flags &= -129;
5101
- job.flags &= -3;
5260
+ const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => {
5261
+ let i = 0;
5262
+ const l2 = c2.length;
5263
+ let e1 = c1.length - 1;
5264
+ let e2 = l2 - 1;
5265
+ while (i <= e1 && i <= e2) {
5266
+ const n1 = c1[i];
5267
+ const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
5268
+ if (isSameVNodeType(n1, n2)) {
5269
+ patch(
5270
+ n1,
5271
+ n2,
5272
+ container,
5273
+ null,
5274
+ parentComponent,
5275
+ parentSuspense,
5276
+ namespace,
5277
+ slotScopeIds,
5278
+ optimized
5279
+ );
5280
+ } else {
5281
+ break;
5282
+ }
5283
+ i++;
5102
5284
  }
5103
- }
5104
- }
5105
- function needTransition(parentSuspense, transition) {
5106
- return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5107
- }
5108
- function traverseStaticChildren(n1, n2, shallow = false) {
5109
- const ch1 = n1.children;
5110
- const ch2 = n2.children;
5111
- if (shared.isArray(ch1) && shared.isArray(ch2)) {
5112
- for (let i = 0; i < ch1.length; i++) {
5113
- const c1 = ch1[i];
5114
- let c2 = ch2[i];
5115
- if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
5116
- if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
5117
- c2 = ch2[i] = cloneIfMounted(ch2[i]);
5118
- c2.el = c1.el;
5285
+ while (i <= e1 && i <= e2) {
5286
+ const n1 = c1[e1];
5287
+ const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
5288
+ if (isSameVNodeType(n1, n2)) {
5289
+ patch(
5290
+ n1,
5291
+ n2,
5292
+ container,
5293
+ null,
5294
+ parentComponent,
5295
+ parentSuspense,
5296
+ namespace,
5297
+ slotScopeIds,
5298
+ optimized
5299
+ );
5300
+ } else {
5301
+ break;
5302
+ }
5303
+ e1--;
5304
+ e2--;
5305
+ }
5306
+ if (i > e1) {
5307
+ if (i <= e2) {
5308
+ const nextPos = e2 + 1;
5309
+ const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
5310
+ while (i <= e2) {
5311
+ patch(
5312
+ null,
5313
+ c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
5314
+ container,
5315
+ anchor,
5316
+ parentComponent,
5317
+ parentSuspense,
5318
+ namespace,
5319
+ slotScopeIds,
5320
+ optimized
5321
+ );
5322
+ i++;
5323
+ }
5324
+ }
5325
+ } else if (i > e2) {
5326
+ while (i <= e1) {
5327
+ unmount(c1[i], parentComponent, parentSuspense, true);
5328
+ i++;
5329
+ }
5330
+ } else {
5331
+ const s1 = i;
5332
+ const s2 = i;
5333
+ const keyToNewIndexMap = /* @__PURE__ */ new Map();
5334
+ for (i = s2; i <= e2; i++) {
5335
+ const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
5336
+ if (nextChild.key != null) {
5337
+ keyToNewIndexMap.set(nextChild.key, i);
5338
+ }
5339
+ }
5340
+ let j;
5341
+ let patched = 0;
5342
+ const toBePatched = e2 - s2 + 1;
5343
+ let moved = false;
5344
+ let maxNewIndexSoFar = 0;
5345
+ const newIndexToOldIndexMap = new Array(toBePatched);
5346
+ for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
5347
+ for (i = s1; i <= e1; i++) {
5348
+ const prevChild = c1[i];
5349
+ if (patched >= toBePatched) {
5350
+ unmount(prevChild, parentComponent, parentSuspense, true);
5351
+ continue;
5352
+ }
5353
+ let newIndex;
5354
+ if (prevChild.key != null) {
5355
+ newIndex = keyToNewIndexMap.get(prevChild.key);
5356
+ } else {
5357
+ for (j = s2; j <= e2; j++) {
5358
+ if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
5359
+ newIndex = j;
5360
+ break;
5361
+ }
5362
+ }
5363
+ }
5364
+ if (newIndex === void 0) {
5365
+ unmount(prevChild, parentComponent, parentSuspense, true);
5366
+ } else {
5367
+ newIndexToOldIndexMap[newIndex - s2] = i + 1;
5368
+ if (newIndex >= maxNewIndexSoFar) {
5369
+ maxNewIndexSoFar = newIndex;
5370
+ } else {
5371
+ moved = true;
5372
+ }
5373
+ patch(
5374
+ prevChild,
5375
+ c2[newIndex],
5376
+ container,
5377
+ null,
5378
+ parentComponent,
5379
+ parentSuspense,
5380
+ namespace,
5381
+ slotScopeIds,
5382
+ optimized
5383
+ );
5384
+ patched++;
5119
5385
  }
5120
- if (!shallow && c2.patchFlag !== -2)
5121
- traverseStaticChildren(c1, c2);
5122
- }
5123
- if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
5124
- c2.patchFlag !== -1) {
5125
- c2.el = c1.el;
5126
5386
  }
5127
- if (c2.type === Comment && !c2.el) {
5128
- c2.el = c1.el;
5387
+ const increasingNewIndexSequence = moved ? shared.getSequence(newIndexToOldIndexMap) : shared.EMPTY_ARR;
5388
+ j = increasingNewIndexSequence.length - 1;
5389
+ for (i = toBePatched - 1; i >= 0; i--) {
5390
+ const nextIndex = s2 + i;
5391
+ const nextChild = c2[nextIndex];
5392
+ const anchorVNode = c2[nextIndex + 1];
5393
+ const anchor = nextIndex + 1 < l2 ? (
5394
+ // #13559, fallback to el placeholder for unresolved async component
5395
+ anchorVNode.el || anchorVNode.placeholder
5396
+ ) : parentAnchor;
5397
+ if (newIndexToOldIndexMap[i] === 0) {
5398
+ patch(
5399
+ null,
5400
+ nextChild,
5401
+ container,
5402
+ anchor,
5403
+ parentComponent,
5404
+ parentSuspense,
5405
+ namespace,
5406
+ slotScopeIds,
5407
+ optimized
5408
+ );
5409
+ } else if (moved) {
5410
+ if (j < 0 || i !== increasingNewIndexSequence[j]) {
5411
+ move(
5412
+ nextChild,
5413
+ container,
5414
+ anchor,
5415
+ 2,
5416
+ parentComponent
5417
+ );
5418
+ } else {
5419
+ j--;
5420
+ }
5421
+ }
5129
5422
  }
5130
5423
  }
5131
- }
5132
- }
5133
- function locateNonHydratedAsyncRoot(instance) {
5134
- const subComponent = instance.subTree && instance.subTree.component;
5135
- if (subComponent) {
5136
- if (subComponent.asyncDep && !subComponent.asyncResolved) {
5137
- return subComponent;
5138
- } else {
5139
- return locateNonHydratedAsyncRoot(subComponent);
5424
+ };
5425
+ const move = (vnode, container, anchor, moveType, parentComponent, parentSuspense = null) => {
5426
+ const { el, type, transition, children, shapeFlag } = vnode;
5427
+ if (shapeFlag & 6) {
5428
+ if (type.__vapor) {
5429
+ getVaporInterface(parentComponent, vnode).move(vnode, container, anchor);
5430
+ } else {
5431
+ move(
5432
+ vnode.component.subTree,
5433
+ container,
5434
+ anchor,
5435
+ moveType,
5436
+ parentComponent
5437
+ );
5438
+ }
5439
+ return;
5140
5440
  }
5141
- }
5142
- }
5143
- function invalidateMount(hooks) {
5144
- if (hooks) {
5145
- for (let i = 0; i < hooks.length; i++)
5146
- hooks[i].flags |= 4;
5147
- }
5148
- }
5149
- function performTransitionEnter(el, transition, insert, parentSuspense, force = false) {
5150
- if (force || needTransition(parentSuspense, transition)) {
5151
- transition.beforeEnter(el);
5152
- insert();
5153
- queuePostRenderEffect(() => transition.enter(el), void 0, parentSuspense);
5154
- } else {
5155
- insert();
5156
- }
5157
- }
5158
- function performTransitionLeave(el, transition, remove, isElement = true) {
5159
- const performRemove = () => {
5160
- remove();
5161
- if (transition && !transition.persisted && transition.afterLeave) {
5162
- transition.afterLeave();
5441
+ if (shapeFlag & 128) {
5442
+ vnode.suspense.move(container, anchor, moveType);
5443
+ return;
5163
5444
  }
5164
- };
5165
- if (isElement && transition && !transition.persisted) {
5166
- const { leave, delayLeave } = transition;
5167
- const performLeave = () => leave(el, performRemove);
5168
- if (delayLeave) {
5169
- delayLeave(el, performRemove, performLeave);
5170
- } else {
5171
- performLeave();
5445
+ if (shapeFlag & 64) {
5446
+ type.move(
5447
+ vnode,
5448
+ container,
5449
+ anchor,
5450
+ internals,
5451
+ parentComponent
5452
+ );
5453
+ return;
5172
5454
  }
5173
- } else {
5174
- performRemove();
5175
- }
5176
- }
5177
- function getVaporInterface(instance, vnode) {
5178
- const ctx = instance ? instance.appContext : vnode.appContext;
5179
- const res = ctx && ctx.vapor;
5180
- return res;
5181
- }
5182
- function getInheritedScopeIds(vnode, parentComponent) {
5183
- const inheritedScopeIds = [];
5184
- let currentParent = parentComponent;
5185
- let currentVNode = vnode;
5186
- while (currentParent) {
5187
- let subTree = currentParent.subTree;
5188
- if (!subTree) break;
5189
- if (currentVNode === subTree || isSuspense(subTree.type) && (subTree.ssContent === currentVNode || subTree.ssFallback === currentVNode)) {
5190
- const parentVNode = currentParent.vnode;
5191
- if (parentVNode.scopeId) {
5192
- inheritedScopeIds.push(parentVNode.scopeId);
5193
- }
5194
- if (parentVNode.slotScopeIds) {
5195
- inheritedScopeIds.push(...parentVNode.slotScopeIds);
5455
+ if (type === Fragment) {
5456
+ hostInsert(el, container, anchor);
5457
+ for (let i = 0; i < children.length; i++) {
5458
+ move(
5459
+ children[i],
5460
+ container,
5461
+ anchor,
5462
+ moveType,
5463
+ parentComponent
5464
+ );
5196
5465
  }
5197
- currentVNode = parentVNode;
5198
- currentParent = currentParent.parent;
5199
- } else {
5200
- break;
5466
+ hostInsert(vnode.anchor, container, anchor);
5467
+ return;
5201
5468
  }
5202
- }
5203
- return inheritedScopeIds;
5204
- }
5205
-
5206
- const ssrContextKey = Symbol.for("v-scx");
5207
- const useSSRContext = () => {
5208
- {
5209
- const ctx = inject(ssrContextKey);
5210
- return ctx;
5211
- }
5212
- };
5213
-
5214
- function watchEffect(effect, options) {
5215
- return doWatch(effect, null, options);
5216
- }
5217
- function watchPostEffect(effect, options) {
5218
- return doWatch(
5219
- effect,
5220
- null,
5221
- { flush: "post" }
5222
- );
5223
- }
5224
- function watchSyncEffect(effect, options) {
5225
- return doWatch(
5226
- effect,
5227
- null,
5228
- { flush: "sync" }
5229
- );
5230
- }
5231
- function watch(source, cb, options) {
5232
- return doWatch(source, cb, options);
5233
- }
5234
- class RenderWatcherEffect extends reactivity.WatcherEffect {
5235
- constructor(instance, source, cb, options, flush) {
5236
- super(source, cb, options);
5237
- this.flush = flush;
5238
- const job = () => {
5239
- if (this.dirty) {
5240
- this.run();
5241
- }
5242
- };
5243
- if (cb) {
5244
- this.flags |= 128;
5245
- job.flags |= 2;
5469
+ if (type === Static) {
5470
+ moveStaticNode(vnode, container, anchor);
5471
+ return;
5472
+ }
5473
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
5474
+ if (needTransition2) {
5475
+ if (moveType === 0) {
5476
+ performTransitionEnter(
5477
+ el,
5478
+ transition,
5479
+ () => hostInsert(el, container, anchor),
5480
+ parentSuspense,
5481
+ true
5482
+ );
5483
+ } else {
5484
+ const { leave, delayLeave, afterLeave } = transition;
5485
+ const remove2 = () => {
5486
+ if (vnode.ctx.isUnmounted) {
5487
+ hostRemove(el);
5488
+ } else {
5489
+ hostInsert(el, container, anchor);
5490
+ }
5491
+ };
5492
+ const performLeave = () => {
5493
+ if (el._isLeaving) {
5494
+ el[leaveCbKey](
5495
+ true
5496
+ /* cancelled */
5497
+ );
5498
+ }
5499
+ leave(el, () => {
5500
+ remove2();
5501
+ afterLeave && afterLeave();
5502
+ });
5503
+ };
5504
+ if (delayLeave) {
5505
+ delayLeave(el, remove2, performLeave);
5506
+ } else {
5507
+ performLeave();
5508
+ }
5509
+ }
5510
+ } else {
5511
+ hostInsert(el, container, anchor);
5246
5512
  }
5247
- if (instance) {
5248
- job.i = instance;
5513
+ };
5514
+ const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
5515
+ const {
5516
+ type,
5517
+ props,
5518
+ ref,
5519
+ children,
5520
+ dynamicChildren,
5521
+ shapeFlag,
5522
+ patchFlag,
5523
+ dirs,
5524
+ cacheIndex
5525
+ } = vnode;
5526
+ if (patchFlag === -2) {
5527
+ optimized = false;
5249
5528
  }
5250
- this.job = job;
5251
- }
5252
- notify() {
5253
- const flags = this.flags;
5254
- if (!(flags & 256)) {
5255
- const flush = this.flush;
5256
- const job = this.job;
5257
- if (flush === "post") {
5258
- queuePostRenderEffect(job, void 0, job.i ? job.i.suspense : null);
5259
- } else if (flush === "pre") {
5260
- queueJob(job, job.i ? job.i.uid : void 0, true);
5261
- } else {
5262
- job();
5263
- }
5529
+ if (ref != null) {
5530
+ const prevSub = reactivity.setActiveSub();
5531
+ setRef(ref, null, parentSuspense, vnode, true);
5532
+ reactivity.setActiveSub(prevSub);
5264
5533
  }
5265
- }
5266
- }
5267
- function doWatch(source, cb, options = shared.EMPTY_OBJ) {
5268
- const { immediate, deep, flush = "pre", once } = options;
5269
- const baseWatchOptions = shared.extend({}, options);
5270
- const runsImmediately = cb && immediate || !cb && flush !== "post";
5271
- let ssrCleanup;
5272
- if (isInSSRComponentSetup) {
5273
- if (flush === "sync") {
5274
- const ctx = useSSRContext();
5275
- ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
5276
- } else if (!runsImmediately) {
5277
- const watchStopHandle = () => {
5278
- };
5279
- watchStopHandle.stop = shared.NOOP;
5280
- watchStopHandle.resume = shared.NOOP;
5281
- watchStopHandle.pause = shared.NOOP;
5282
- return watchStopHandle;
5534
+ if (cacheIndex != null) {
5535
+ parentComponent.renderCache[cacheIndex] = void 0;
5283
5536
  }
5284
- }
5285
- const instance = currentInstance;
5286
- baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
5287
- const effect = new RenderWatcherEffect(
5288
- instance,
5289
- source,
5290
- cb,
5291
- baseWatchOptions,
5292
- flush
5293
- );
5294
- if (cb) {
5295
- effect.run(true);
5296
- } else if (flush === "post") {
5297
- queuePostRenderEffect(effect.job, void 0, instance && instance.suspense);
5298
- } else {
5299
- effect.run(true);
5300
- }
5301
- const stop = effect.stop.bind(effect);
5302
- stop.pause = effect.pause.bind(effect);
5303
- stop.resume = effect.resume.bind(effect);
5304
- stop.stop = stop;
5305
- if (isInSSRComponentSetup) {
5306
- if (ssrCleanup) {
5307
- ssrCleanup.push(stop);
5308
- } else if (runsImmediately) {
5309
- stop();
5537
+ if (shapeFlag & 256) {
5538
+ if (vnode.type.__vapor) {
5539
+ getVaporInterface(parentComponent, vnode).deactivate(
5540
+ vnode,
5541
+ parentComponent.ctx.getStorageContainer()
5542
+ );
5543
+ } else {
5544
+ parentComponent.ctx.deactivate(vnode);
5545
+ }
5546
+ return;
5310
5547
  }
5311
- }
5312
- return stop;
5313
- }
5314
- function instanceWatch(source, value, options) {
5315
- const publicThis = this.proxy;
5316
- const getter = shared.isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
5317
- let cb;
5318
- if (shared.isFunction(value)) {
5319
- cb = value;
5320
- } else {
5321
- cb = value.handler;
5322
- options = value;
5323
- }
5324
- const prev = setCurrentInstance(this);
5325
- const res = doWatch(getter, cb.bind(publicThis), options);
5326
- setCurrentInstance(...prev);
5327
- return res;
5328
- }
5329
- function createPathGetter(ctx, path) {
5330
- const segments = path.split(".");
5331
- return () => {
5332
- let cur = ctx;
5333
- for (let i = 0; i < segments.length && cur; i++) {
5334
- cur = cur[segments[i]];
5548
+ const shouldInvokeDirs = shapeFlag & 1 && dirs;
5549
+ const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
5550
+ let vnodeHook;
5551
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
5552
+ invokeVNodeHook(vnodeHook, parentComponent, vnode);
5335
5553
  }
5336
- return cur;
5337
- };
5338
- }
5339
-
5340
- function useModel(props, name, options = shared.EMPTY_OBJ) {
5341
- const i = getCurrentGenericInstance();
5342
- const camelizedName = shared.camelize(name);
5343
- const hyphenatedName = shared.hyphenate(name);
5344
- const modifiers = getModelModifiers(props, camelizedName, defaultPropGetter);
5345
- const res = reactivity.customRef((track, trigger) => {
5346
- let localValue;
5347
- let prevSetValue = shared.EMPTY_OBJ;
5348
- let prevEmittedValue;
5349
- watchSyncEffect(() => {
5350
- const propValue = props[camelizedName];
5351
- if (shared.hasChanged(localValue, propValue)) {
5352
- localValue = propValue;
5353
- trigger();
5554
+ if (shapeFlag & 6) {
5555
+ if (type.__vapor) {
5556
+ getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
5557
+ return;
5558
+ } else {
5559
+ unmountComponent(vnode.component, parentSuspense, doRemove);
5354
5560
  }
5355
- });
5356
- return {
5357
- get() {
5358
- track();
5359
- return options.get ? options.get(localValue) : localValue;
5360
- },
5361
- set(value) {
5362
- const emittedValue = options.set ? options.set(value) : value;
5363
- if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
5364
- return;
5365
- }
5366
- let rawPropKeys;
5367
- let parentPassedModelValue = false;
5368
- let parentPassedModelUpdater = false;
5369
- if (i.rawKeys) {
5370
- rawPropKeys = i.rawKeys();
5371
- } else {
5372
- const rawProps = i.vnode.props;
5373
- rawPropKeys = rawProps && Object.keys(rawProps);
5374
- }
5375
- if (rawPropKeys) {
5376
- for (const key of rawPropKeys) {
5377
- if (key === name || key === camelizedName || key === hyphenatedName) {
5378
- parentPassedModelValue = true;
5379
- } else if (key === `onUpdate:${name}` || key === `onUpdate:${camelizedName}` || key === `onUpdate:${hyphenatedName}`) {
5380
- parentPassedModelUpdater = true;
5381
- }
5382
- }
5383
- }
5384
- if (!parentPassedModelValue || !parentPassedModelUpdater) {
5385
- localValue = value;
5386
- trigger();
5387
- }
5388
- i.emit(`update:${name}`, emittedValue);
5389
- if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
5390
- trigger();
5391
- }
5392
- prevSetValue = value;
5393
- prevEmittedValue = emittedValue;
5561
+ } else {
5562
+ if (shapeFlag & 128) {
5563
+ vnode.suspense.unmount(parentSuspense, doRemove);
5564
+ return;
5394
5565
  }
5395
- };
5396
- });
5397
- res[Symbol.iterator] = () => {
5398
- let i2 = 0;
5399
- return {
5400
- next() {
5401
- if (i2 < 2) {
5402
- return { value: i2++ ? modifiers || shared.EMPTY_OBJ : res, done: false };
5403
- } else {
5404
- return { done: true };
5405
- }
5566
+ if (shouldInvokeDirs) {
5567
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
5568
+ }
5569
+ if (shapeFlag & 64) {
5570
+ vnode.type.remove(
5571
+ vnode,
5572
+ parentComponent,
5573
+ parentSuspense,
5574
+ internals,
5575
+ doRemove
5576
+ );
5577
+ } else if (dynamicChildren && // #5154
5578
+ // when v-once is used inside a block, setBlockTracking(-1) marks the
5579
+ // parent block with hasOnce: true
5580
+ // so that it doesn't take the fast path during unmount - otherwise
5581
+ // components nested in v-once are never unmounted.
5582
+ !dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
5583
+ (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
5584
+ unmountChildren(
5585
+ dynamicChildren,
5586
+ parentComponent,
5587
+ parentSuspense,
5588
+ false,
5589
+ true
5590
+ );
5591
+ } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
5592
+ unmountChildren(children, parentComponent, parentSuspense);
5593
+ }
5594
+ if (type === VaporSlot) {
5595
+ getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
5596
+ return;
5597
+ }
5598
+ if (doRemove) {
5599
+ remove(vnode);
5406
5600
  }
5407
- };
5408
- };
5409
- return res;
5410
- }
5411
- const getModelModifiers = (props, modelName, getter) => {
5412
- return getter(props, shared.getModifierPropName(modelName)) || getter(props, `${shared.camelize(modelName)}Modifiers`) || getter(props, `${shared.hyphenate(modelName)}Modifiers`);
5413
- };
5414
-
5415
- function emit(instance, event, ...rawArgs) {
5416
- return baseEmit(
5417
- instance,
5418
- instance.vnode.props || shared.EMPTY_OBJ,
5419
- defaultPropGetter,
5420
- event,
5421
- ...rawArgs
5422
- );
5423
- }
5424
- function baseEmit(instance, props, getter, event, ...rawArgs) {
5425
- if (instance.isUnmounted) return;
5426
- let args = rawArgs;
5427
- const isModelListener = event.startsWith("update:");
5428
- const modifiers = isModelListener && getModelModifiers(props, event.slice(7), getter);
5429
- if (modifiers) {
5430
- if (modifiers.trim) {
5431
- args = rawArgs.map((a) => shared.isString(a) ? a.trim() : a);
5432
5601
  }
5433
- if (modifiers.number) {
5434
- args = rawArgs.map(shared.looseToNumber);
5602
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
5603
+ queuePostRenderEffect(
5604
+ () => {
5605
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
5606
+ shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
5607
+ },
5608
+ void 0,
5609
+ parentSuspense
5610
+ );
5435
5611
  }
5436
- }
5437
- let handlerName;
5438
- let handler = getter(props, handlerName = shared.toHandlerKey(event)) || // also try camelCase event handler (#2249)
5439
- getter(props, handlerName = shared.toHandlerKey(shared.camelize(event)));
5440
- if (!handler && isModelListener) {
5441
- handler = getter(props, handlerName = shared.toHandlerKey(shared.hyphenate(event)));
5442
- }
5443
- if (handler) {
5444
- callWithAsyncErrorHandling(
5445
- handler,
5446
- instance,
5447
- 6,
5448
- args
5449
- );
5450
- }
5451
- const onceHandler = getter(props, handlerName + `Once`);
5452
- if (onceHandler) {
5453
- if (!instance.emitted) {
5454
- instance.emitted = {};
5455
- } else if (instance.emitted[handlerName]) {
5612
+ };
5613
+ const remove = (vnode) => {
5614
+ const { type, el, anchor, transition } = vnode;
5615
+ if (type === Fragment) {
5616
+ {
5617
+ removeFragment(el, anchor);
5618
+ }
5456
5619
  return;
5457
5620
  }
5458
- instance.emitted[handlerName] = true;
5459
- callWithAsyncErrorHandling(
5460
- onceHandler,
5461
- instance,
5462
- 6,
5463
- args
5621
+ if (type === Static) {
5622
+ removeStaticNode(vnode);
5623
+ return;
5624
+ }
5625
+ if (transition) {
5626
+ performTransitionLeave(
5627
+ el,
5628
+ transition,
5629
+ () => hostRemove(el),
5630
+ !!(vnode.shapeFlag & 1)
5631
+ );
5632
+ } else {
5633
+ hostRemove(el);
5634
+ }
5635
+ };
5636
+ const removeFragment = (cur, end) => {
5637
+ let next;
5638
+ while (cur !== end) {
5639
+ next = hostNextSibling(cur);
5640
+ hostRemove(cur);
5641
+ cur = next;
5642
+ }
5643
+ hostRemove(end);
5644
+ };
5645
+ const unmountComponent = (instance, parentSuspense, doRemove) => {
5646
+ const { bum, scope, effect, subTree, um, m, a } = instance;
5647
+ invalidateMount(m);
5648
+ invalidateMount(a);
5649
+ if (bum) {
5650
+ shared.invokeArrayFns(bum);
5651
+ }
5652
+ scope.stop();
5653
+ if (effect) {
5654
+ effect.stop();
5655
+ unmount(subTree, instance, parentSuspense, doRemove);
5656
+ }
5657
+ if (um) {
5658
+ queuePostRenderEffect(um, void 0, parentSuspense);
5659
+ }
5660
+ queuePostRenderEffect(
5661
+ () => instance.isUnmounted = true,
5662
+ void 0,
5663
+ parentSuspense
5464
5664
  );
5465
- }
5466
- }
5467
- function defaultPropGetter(props, key) {
5468
- return props[key];
5469
- }
5470
- const mixinEmitsCache = /* @__PURE__ */ new WeakMap();
5471
- function normalizeEmitsOptions(comp, appContext, asMixin = false) {
5472
- const cache = asMixin ? mixinEmitsCache : appContext.emitsCache;
5473
- const cached = cache.get(comp);
5474
- if (cached !== void 0) {
5475
- return cached;
5476
- }
5477
- const raw = comp.emits;
5478
- let normalized = {};
5479
- let hasExtends = false;
5480
- if (!shared.isFunction(comp)) {
5481
- const extendEmits = (raw2) => {
5482
- const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
5483
- if (normalizedFromExtend) {
5484
- hasExtends = true;
5485
- shared.extend(normalized, normalizedFromExtend);
5665
+ };
5666
+ const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
5667
+ for (let i = start; i < children.length; i++) {
5668
+ unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
5669
+ }
5670
+ };
5671
+ const getNextHostNode = (vnode) => {
5672
+ if (vnode.shapeFlag & 6) {
5673
+ if (vnode.type.__vapor) {
5674
+ return hostNextSibling(vnode.anchor);
5486
5675
  }
5487
- };
5488
- if (!asMixin && appContext.mixins.length) {
5489
- appContext.mixins.forEach(extendEmits);
5676
+ return getNextHostNode(vnode.component.subTree);
5490
5677
  }
5491
- if (comp.extends) {
5492
- extendEmits(comp.extends);
5678
+ if (vnode.shapeFlag & 128) {
5679
+ return vnode.suspense.next();
5493
5680
  }
5494
- if (comp.mixins) {
5495
- comp.mixins.forEach(extendEmits);
5681
+ const el = hostNextSibling(vnode.anchor || vnode.el);
5682
+ const teleportEnd = el && el[TeleportEndKey];
5683
+ return teleportEnd ? hostNextSibling(teleportEnd) : el;
5684
+ };
5685
+ const render = (vnode, container, namespace) => {
5686
+ if (vnode == null) {
5687
+ if (container._vnode) {
5688
+ unmount(container._vnode, null, null, true);
5689
+ }
5690
+ } else {
5691
+ patch(
5692
+ container._vnode || null,
5693
+ vnode,
5694
+ container,
5695
+ null,
5696
+ null,
5697
+ null,
5698
+ namespace
5699
+ );
5496
5700
  }
5701
+ container._vnode = vnode;
5702
+ flushOnAppMount();
5703
+ };
5704
+ const internals = {
5705
+ p: patch,
5706
+ um: unmount,
5707
+ m: move,
5708
+ r: remove,
5709
+ mt: mountComponent,
5710
+ umt: unmountComponent,
5711
+ mc: mountChildren,
5712
+ pc: patchChildren,
5713
+ pbc: patchBlockChildren,
5714
+ n: getNextHostNode,
5715
+ o: options
5716
+ };
5717
+ let hydrate;
5718
+ let hydrateNode;
5719
+ if (createHydrationFns) {
5720
+ [hydrate, hydrateNode] = createHydrationFns(
5721
+ internals
5722
+ );
5497
5723
  }
5498
- if (!raw && !hasExtends) {
5499
- if (shared.isObject(comp)) {
5500
- cache.set(comp, null);
5724
+ const mountApp = (app, container, isHydrate, namespace) => {
5725
+ const vnode = app._ceVNode || createVNode(app._component, app._props);
5726
+ vnode.appContext = app._context;
5727
+ if (namespace === true) {
5728
+ namespace = "svg";
5729
+ } else if (namespace === false) {
5730
+ namespace = void 0;
5501
5731
  }
5502
- return null;
5503
- }
5504
- if (shared.isArray(raw)) {
5505
- raw.forEach((key) => normalized[key] = null);
5506
- } else {
5507
- shared.extend(normalized, raw);
5508
- }
5509
- if (shared.isObject(comp)) {
5510
- cache.set(comp, normalized);
5511
- }
5512
- return normalized;
5513
- }
5514
- function isEmitListener(options, key) {
5515
- if (!options || !shared.isOn(key)) {
5516
- return false;
5517
- }
5518
- key = key.slice(2).replace(/Once$/, "");
5519
- return shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) || shared.hasOwn(options, shared.hyphenate(key)) || shared.hasOwn(options, key);
5520
- }
5521
-
5522
- function markAttrsAccessed() {
5523
- }
5524
- function renderComponentRoot(instance) {
5525
- const {
5526
- type: Component,
5527
- vnode,
5528
- proxy,
5529
- withProxy,
5530
- propsOptions: [propsOptions],
5531
- slots,
5532
- attrs,
5533
- emit,
5534
- render,
5535
- renderCache,
5536
- props,
5537
- data,
5538
- setupState,
5539
- ctx,
5540
- inheritAttrs
5541
- } = instance;
5542
- const prev = setCurrentRenderingInstance(instance);
5543
- let result;
5544
- let fallthroughAttrs;
5545
- try {
5546
- if (vnode.shapeFlag & 4) {
5547
- const proxyToUse = withProxy || proxy;
5548
- const thisProxy = false ? new Proxy(proxyToUse, {
5549
- get(target, key, receiver) {
5550
- warn(
5551
- `Property '${String(
5552
- key
5553
- )}' was accessed via 'this'. Avoid using 'this' in templates.`
5554
- );
5555
- return Reflect.get(target, key, receiver);
5556
- }
5557
- }) : proxyToUse;
5558
- result = normalizeVNode(
5559
- render.call(
5560
- thisProxy,
5561
- proxyToUse,
5562
- renderCache,
5563
- false ? shallowReadonly(props) : props,
5564
- setupState,
5565
- data,
5566
- ctx
5567
- )
5568
- );
5569
- fallthroughAttrs = attrs;
5732
+ if (isHydrate && hydrate) {
5733
+ hydrate(vnode, container);
5734
+ } else {
5735
+ render(vnode, container, namespace);
5736
+ }
5737
+ return vnode.component;
5738
+ };
5739
+ const unmountApp = (app) => {
5740
+ render(null, app._container);
5741
+ };
5742
+ return {
5743
+ render,
5744
+ hydrate,
5745
+ hydrateNode,
5746
+ internals,
5747
+ createApp: createAppAPI(
5748
+ mountApp,
5749
+ unmountApp,
5750
+ getComponentPublicInstance)
5751
+ };
5752
+ }
5753
+ function resolveChildrenNamespace({ type, props }, currentNamespace) {
5754
+ return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
5755
+ }
5756
+ function toggleRecurse({ effect, job, vapor }, allowed) {
5757
+ if (!vapor) {
5758
+ if (allowed) {
5759
+ effect.flags |= 128;
5760
+ job.flags |= 2;
5570
5761
  } else {
5571
- const render2 = Component;
5572
- if (false) ;
5573
- result = normalizeVNode(
5574
- render2.length > 1 ? render2(
5575
- false ? shallowReadonly(props) : props,
5576
- false ? {
5577
- get attrs() {
5578
- markAttrsAccessed();
5579
- return shallowReadonly(attrs);
5580
- },
5581
- slots,
5582
- emit
5583
- } : { attrs, slots, emit }
5584
- ) : render2(
5585
- false ? shallowReadonly(props) : props,
5586
- null
5587
- )
5588
- );
5589
- fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
5762
+ effect.flags &= -129;
5763
+ job.flags &= -3;
5590
5764
  }
5591
- } catch (err) {
5592
- blockStack.length = 0;
5593
- handleError(err, instance, 1);
5594
- result = createVNode(Comment);
5595
5765
  }
5596
- let root = result;
5597
- if (fallthroughAttrs && inheritAttrs !== false) {
5598
- const keys = Object.keys(fallthroughAttrs);
5599
- const { shapeFlag } = root;
5600
- if (keys.length) {
5601
- if (shapeFlag & (1 | 6)) {
5602
- if (propsOptions && keys.some(shared.isModelListener)) {
5603
- fallthroughAttrs = filterModelListeners(
5604
- fallthroughAttrs,
5605
- propsOptions
5606
- );
5766
+ }
5767
+ function needTransition(parentSuspense, transition) {
5768
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
5769
+ }
5770
+ function traverseStaticChildren(n1, n2, shallow = false) {
5771
+ const ch1 = n1.children;
5772
+ const ch2 = n2.children;
5773
+ if (shared.isArray(ch1) && shared.isArray(ch2)) {
5774
+ for (let i = 0; i < ch1.length; i++) {
5775
+ const c1 = ch1[i];
5776
+ let c2 = ch2[i];
5777
+ if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
5778
+ if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
5779
+ c2 = ch2[i] = cloneIfMounted(ch2[i]);
5780
+ c2.el = c1.el;
5607
5781
  }
5608
- root = cloneVNode(root, fallthroughAttrs, false, true);
5782
+ if (!shallow && c2.patchFlag !== -2)
5783
+ traverseStaticChildren(c1, c2);
5784
+ }
5785
+ if (c2.type === Text && // avoid cached text nodes retaining detached dom nodes
5786
+ c2.patchFlag !== -1) {
5787
+ c2.el = c1.el;
5788
+ }
5789
+ if (c2.type === Comment && !c2.el) {
5790
+ c2.el = c1.el;
5609
5791
  }
5610
5792
  }
5611
5793
  }
5612
- if (vnode.dirs) {
5613
- root = cloneVNode(root, null, false, true);
5614
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
5615
- }
5616
- if (vnode.transition) {
5617
- setTransitionHooks(root, vnode.transition);
5618
- }
5619
- {
5620
- result = root;
5621
- }
5622
- setCurrentRenderingInstance(prev);
5623
- return result;
5624
5794
  }
5625
- function filterSingleRoot(children, recurse = true) {
5626
- let singleRoot;
5627
- for (let i = 0; i < children.length; i++) {
5628
- const child = children[i];
5629
- if (isVNode(child)) {
5630
- if (child.type !== Comment || child.children === "v-if") {
5631
- if (singleRoot) {
5632
- return;
5633
- } else {
5634
- singleRoot = child;
5635
- }
5636
- }
5795
+ function locateNonHydratedAsyncRoot(instance) {
5796
+ const subComponent = instance.subTree && instance.subTree.component;
5797
+ if (subComponent) {
5798
+ if (subComponent.asyncDep && !subComponent.asyncResolved) {
5799
+ return subComponent;
5637
5800
  } else {
5638
- return;
5801
+ return locateNonHydratedAsyncRoot(subComponent);
5639
5802
  }
5640
5803
  }
5641
- return singleRoot;
5642
5804
  }
5643
- const getFunctionalFallthrough = (attrs) => {
5644
- let res;
5645
- for (const key in attrs) {
5646
- if (key === "class" || key === "style" || shared.isOn(key)) {
5647
- (res || (res = {}))[key] = attrs[key];
5648
- }
5649
- }
5650
- return res;
5651
- };
5652
- const filterModelListeners = (attrs, props) => {
5653
- const res = {};
5654
- for (const key in attrs) {
5655
- if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
5656
- res[key] = attrs[key];
5657
- }
5805
+ function invalidateMount(hooks) {
5806
+ if (hooks) {
5807
+ for (let i = 0; i < hooks.length; i++)
5808
+ hooks[i].flags |= 4;
5658
5809
  }
5659
- return res;
5660
- };
5661
- function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
5662
- const { props: prevProps, children: prevChildren, component } = prevVNode;
5663
- const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
5664
- const emits = component.emitsOptions;
5665
- if (nextVNode.dirs || nextVNode.transition) {
5666
- return true;
5810
+ }
5811
+ function performTransitionEnter(el, transition, insert, parentSuspense, force = false) {
5812
+ if (force || needTransition(parentSuspense, transition)) {
5813
+ transition.beforeEnter(el);
5814
+ insert();
5815
+ queuePostRenderEffect(() => transition.enter(el), void 0, parentSuspense);
5816
+ } else {
5817
+ insert();
5667
5818
  }
5668
- if (optimized && patchFlag >= 0) {
5669
- if (patchFlag & 1024) {
5670
- return true;
5819
+ }
5820
+ function performTransitionLeave(el, transition, remove, isElement = true) {
5821
+ const performRemove = () => {
5822
+ remove();
5823
+ if (transition && !transition.persisted && transition.afterLeave) {
5824
+ transition.afterLeave();
5671
5825
  }
5672
- if (patchFlag & 16) {
5673
- if (!prevProps) {
5674
- return !!nextProps;
5675
- }
5676
- return hasPropsChanged(prevProps, nextProps, emits);
5677
- } else if (patchFlag & 8) {
5678
- const dynamicProps = nextVNode.dynamicProps;
5679
- for (let i = 0; i < dynamicProps.length; i++) {
5680
- const key = dynamicProps[i];
5681
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
5682
- return true;
5683
- }
5684
- }
5826
+ };
5827
+ if (isElement && transition && !transition.persisted) {
5828
+ const { leave, delayLeave } = transition;
5829
+ const performLeave = () => leave(el, performRemove);
5830
+ if (delayLeave) {
5831
+ delayLeave(el, performRemove, performLeave);
5832
+ } else {
5833
+ performLeave();
5685
5834
  }
5686
5835
  } else {
5687
- if (prevChildren || nextChildren) {
5688
- if (!nextChildren || !nextChildren.$stable) {
5689
- return true;
5690
- }
5691
- }
5692
- if (prevProps === nextProps) {
5693
- return false;
5694
- }
5695
- if (!prevProps) {
5696
- return !!nextProps;
5697
- }
5698
- if (!nextProps) {
5699
- return true;
5700
- }
5701
- return hasPropsChanged(prevProps, nextProps, emits);
5836
+ performRemove();
5702
5837
  }
5703
- return false;
5704
5838
  }
5705
- function hasPropsChanged(prevProps, nextProps, emitsOptions) {
5706
- const nextKeys = Object.keys(nextProps);
5707
- if (nextKeys.length !== Object.keys(prevProps).length) {
5708
- return true;
5709
- }
5710
- for (let i = 0; i < nextKeys.length; i++) {
5711
- const key = nextKeys[i];
5712
- if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
5713
- return true;
5714
- }
5715
- }
5716
- return false;
5839
+ function getVaporInterface(instance, vnode) {
5840
+ const ctx = instance ? instance.appContext : vnode.appContext;
5841
+ const res = ctx && ctx.vapor;
5842
+ return res;
5717
5843
  }
5718
- function updateHOCHostEl({ vnode, parent }, el) {
5719
- while (parent && !parent.vapor) {
5720
- const root = parent.subTree;
5721
- if (root.suspense && root.suspense.activeBranch === vnode) {
5722
- root.el = vnode.el;
5723
- }
5724
- if (root === vnode) {
5725
- (vnode = parent.vnode).el = el;
5726
- parent = parent.parent;
5844
+ function getInheritedScopeIds(vnode, parentComponent) {
5845
+ const inheritedScopeIds = [];
5846
+ let currentParent = parentComponent;
5847
+ let currentVNode = vnode;
5848
+ while (currentParent) {
5849
+ let subTree = currentParent.subTree;
5850
+ if (!subTree) break;
5851
+ if (currentVNode === subTree || isSuspense(subTree.type) && (subTree.ssContent === currentVNode || subTree.ssFallback === currentVNode)) {
5852
+ const parentVNode = currentParent.vnode;
5853
+ if (parentVNode.scopeId) {
5854
+ inheritedScopeIds.push(parentVNode.scopeId);
5855
+ }
5856
+ if (parentVNode.slotScopeIds) {
5857
+ inheritedScopeIds.push(...parentVNode.slotScopeIds);
5858
+ }
5859
+ currentVNode = parentVNode;
5860
+ currentParent = currentParent.parent;
5727
5861
  } else {
5728
5862
  break;
5729
5863
  }
5730
5864
  }
5865
+ return inheritedScopeIds;
5731
5866
  }
5732
5867
 
5733
5868
  const isSuspense = (type) => type.__isSuspense;
@@ -5995,7 +6130,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
5995
6130
  m: move,
5996
6131
  um: unmount,
5997
6132
  n: next,
5998
- o: { parentNode, remove }
6133
+ o: { parentNode }
5999
6134
  } = rendererInternals;
6000
6135
  let parentSuspenseId;
6001
6136
  const isSuspensible = isVNodeSuspensible(vnode);
@@ -6062,7 +6197,11 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
6062
6197
  }
6063
6198
  unmount(activeBranch, parentComponent2, suspense, true);
6064
6199
  if (!delayEnter && isInFallback && vnode2.ssFallback) {
6065
- vnode2.ssFallback.el = null;
6200
+ queuePostRenderEffect(
6201
+ () => vnode2.ssFallback.el = null,
6202
+ void 0,
6203
+ suspense
6204
+ );
6066
6205
  }
6067
6206
  }
6068
6207
  if (!delayEnter) {
@@ -6151,12 +6290,11 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
6151
6290
  next() {
6152
6291
  return suspense.activeBranch && next(suspense.activeBranch);
6153
6292
  },
6154
- registerDep(instance, setupRenderEffect, optimized2) {
6293
+ registerDep(instance, onResolve) {
6155
6294
  const isInPendingSuspense = !!suspense.pendingBranch;
6156
6295
  if (isInPendingSuspense) {
6157
6296
  suspense.deps++;
6158
6297
  }
6159
- const hydratedEl = instance.vnode.el;
6160
6298
  instance.asyncDep.catch((err) => {
6161
6299
  handleError(err, instance, 0);
6162
6300
  }).then((asyncSetupResult) => {
@@ -6164,31 +6302,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
6164
6302
  return;
6165
6303
  }
6166
6304
  instance.asyncResolved = true;
6167
- const { vnode: vnode2 } = instance;
6168
- handleSetupResult(instance, asyncSetupResult, false);
6169
- if (hydratedEl) {
6170
- vnode2.el = hydratedEl;
6171
- }
6172
- const placeholder = !hydratedEl && instance.subTree.el;
6173
- setupRenderEffect(
6174
- instance,
6175
- vnode2,
6176
- // component may have been moved before resolve.
6177
- // if this is not a hydration, instance.subTree will be the comment
6178
- // placeholder.
6179
- parentNode(hydratedEl || instance.subTree.el),
6180
- // anchor will not be used if this is hydration, so only need to
6181
- // consider the comment placeholder case.
6182
- hydratedEl ? null : next(instance.subTree),
6183
- suspense,
6184
- namespace,
6185
- optimized2
6186
- );
6187
- if (placeholder) {
6188
- vnode2.placeholder = null;
6189
- remove(placeholder);
6190
- }
6191
- updateHOCHostEl(instance, vnode2.el);
6305
+ onResolve(asyncSetupResult);
6192
6306
  if (isInPendingSuspense && --suspense.deps === 0) {
6193
6307
  suspense.resolve();
6194
6308
  }
@@ -6942,9 +7056,33 @@ function getComponentPublicInstance(instance) {
6942
7056
  return instance.proxy;
6943
7057
  }
6944
7058
  }
7059
+ const classifyRE = /(?:^|[-_])\w/g;
7060
+ const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
6945
7061
  function getComponentName(Component, includeInferred = true) {
6946
7062
  return shared.isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
6947
7063
  }
7064
+ function formatComponentName(instance, Component, isRoot = false) {
7065
+ let name = getComponentName(Component);
7066
+ if (!name && Component.__file) {
7067
+ const match = Component.__file.match(/([^/\\]+)\.\w+$/);
7068
+ if (match) {
7069
+ name = match[1];
7070
+ }
7071
+ }
7072
+ if (!name && instance) {
7073
+ const inferFromRegistry = (registry) => {
7074
+ for (const key in registry) {
7075
+ if (registry[key] === Component) {
7076
+ return key;
7077
+ }
7078
+ }
7079
+ };
7080
+ name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(
7081
+ instance.parent.type.components
7082
+ ) || inferFromRegistry(instance.appContext.components);
7083
+ }
7084
+ return name ? classify(name) : isRoot ? `App` : `Anonymous`;
7085
+ }
6948
7086
  function isClassComponent(value) {
6949
7087
  return shared.isFunction(value) && "__vccOpts" in value;
6950
7088
  }
@@ -7011,7 +7149,7 @@ function isMemoSame(cached, memo) {
7011
7149
  return true;
7012
7150
  }
7013
7151
 
7014
- const version = "3.6.0-alpha.4";
7152
+ const version = "3.6.0-alpha.6";
7015
7153
  const warn$1 = shared.NOOP;
7016
7154
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
7017
7155
  const devtools = void 0;