@vue/server-renderer 3.6.0-beta.8 → 3.6.0-rc.1

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/server-renderer v3.6.0-beta.8
2
+ * @vue/server-renderer v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -292,9 +292,14 @@ function escapeHtml(string) {
292
292
  }
293
293
  return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
294
294
  }
295
- const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
295
+ const commentStripRE = /^(?:-?>)+|<!--|-->|--!>|<!-$/g;
296
296
  function escapeHtmlComment(src) {
297
- return src.replace(commentStripRE, "");
297
+ let prev;
298
+ do {
299
+ prev = src;
300
+ src = src.replace(commentStripRE, "");
301
+ } while (src !== prev);
302
+ return src;
298
303
  }
299
304
  //#endregion
300
305
  //#region packages/shared/src/looseEqual.ts
@@ -457,6 +462,13 @@ function warn$2(msg, ...args) {
457
462
  const notifyBuffer = [];
458
463
  let batchDepth = 0;
459
464
  let activeSub = void 0;
465
+ let runDepth = 0;
466
+ function incRunDepth() {
467
+ ++runDepth;
468
+ }
469
+ function decRunDepth() {
470
+ --runDepth;
471
+ }
460
472
  let globalVersion = 0;
461
473
  let notifyIndex = 0;
462
474
  let notifyBufferLength = 0;
@@ -530,8 +542,10 @@ function propagate(link) {
530
542
  const sub = link.sub;
531
543
  let flags = sub.flags;
532
544
  if (flags & 3) {
533
- if (!(flags & 60)) sub.flags = flags | 32;
534
- else if (!(flags & 12)) flags = 0;
545
+ if (!(flags & 60)) {
546
+ sub.flags = flags | 32;
547
+ if (runDepth) sub.flags |= 8;
548
+ } else if (!(flags & 12)) flags = 0;
535
549
  else if (!(flags & 4)) sub.flags = flags & -9 | 32;
536
550
  else if (!(flags & 48) && isValidLink(link, sub)) {
537
551
  sub.flags = flags | 40;
@@ -600,13 +614,13 @@ function checkDirty(link, sub) {
600
614
  let dirty = false;
601
615
  if (sub.flags & 16) dirty = true;
602
616
  else if ((depFlags & 17) === 17) {
617
+ const subs = dep.subs;
603
618
  if (dep.update()) {
604
- const subs = dep.subs;
605
619
  if (subs.nextSub !== void 0) shallowPropagate(subs);
606
620
  dirty = true;
607
621
  }
608
622
  } else if ((depFlags & 33) === 33) {
609
- if (link.nextSub !== void 0 || link.prevSub !== void 0) stack = {
623
+ stack = {
610
624
  value: link,
611
625
  prev: stack
612
626
  };
@@ -621,15 +635,12 @@ function checkDirty(link, sub) {
621
635
  }
622
636
  while (checkDepth) {
623
637
  --checkDepth;
624
- const firstSub = sub.subs;
625
- const hasMultipleSubs = firstSub.nextSub !== void 0;
626
- if (hasMultipleSubs) {
627
- link = stack.value;
628
- stack = stack.prev;
629
- } else link = firstSub;
638
+ link = stack.value;
639
+ stack = stack.prev;
630
640
  if (dirty) {
641
+ const subs = sub.subs;
631
642
  if (sub.update()) {
632
- if (hasMultipleSubs) shallowPropagate(firstSub);
643
+ if (subs.nextSub !== void 0) shallowPropagate(subs);
633
644
  sub = link.sub;
634
645
  continue;
635
646
  }
@@ -641,7 +652,7 @@ function checkDirty(link, sub) {
641
652
  }
642
653
  dirty = false;
643
654
  }
644
- return dirty;
655
+ return dirty && !!sub.flags;
645
656
  } while (true);
646
657
  }
647
658
  function shallowPropagate(link) {
@@ -1020,7 +1031,7 @@ var MutableReactiveHandler = class extends BaseReactiveHandler {
1020
1031
  }
1021
1032
  const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
1022
1033
  const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver);
1023
- if (target === /* @__PURE__ */ toRaw(receiver)) {
1034
+ if (target === /* @__PURE__ */ toRaw(receiver) && result) {
1024
1035
  if (!hadKey) trigger(target, "add", key, value);
1025
1036
  else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue);
1026
1037
  }
@@ -1238,9 +1249,6 @@ function targetTypeMap(rawType) {
1238
1249
  default: return 0;
1239
1250
  }
1240
1251
  }
1241
- function getTargetType(value) {
1242
- return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
1243
- }
1244
1252
  /* @__NO_SIDE_EFFECTS__ */
1245
1253
  function reactive(target) {
1246
1254
  if (/* @__PURE__ */ isReadonly(target)) return target;
@@ -1353,10 +1361,11 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle
1353
1361
  return target;
1354
1362
  }
1355
1363
  if (target["__v_raw"] && !(isReadonly && target["__v_isReactive"])) return target;
1356
- const targetType = getTargetType(target);
1357
- if (targetType === 0) return target;
1364
+ if (target["__v_skip"] || !Object.isExtensible(target)) return target;
1358
1365
  const existingProxy = proxyMap.get(target);
1359
1366
  if (existingProxy) return existingProxy;
1367
+ const targetType = targetTypeMap(toRawType(target));
1368
+ if (targetType === 0) return target;
1360
1369
  const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
1361
1370
  proxyMap.set(target, proxy);
1362
1371
  return proxy;
@@ -1561,9 +1570,11 @@ var ReactiveEffect = class {
1561
1570
  if (!this.active) return this.fn();
1562
1571
  cleanup(this);
1563
1572
  const prevSub = startTracking(this);
1573
+ incRunDepth();
1564
1574
  try {
1565
1575
  return this.fn();
1566
1576
  } finally {
1577
+ decRunDepth();
1567
1578
  endTracking(this, prevSub);
1568
1579
  const flags = this.flags;
1569
1580
  if ((flags & 136) === 136) {
@@ -1855,8 +1866,9 @@ var WatcherEffect = class extends ReactiveEffect {
1855
1866
  if (once && cb) {
1856
1867
  const _cb = cb;
1857
1868
  cb = (...args) => {
1858
- _cb(...args);
1869
+ const res = _cb(...args);
1859
1870
  this.stop();
1871
+ return res;
1860
1872
  };
1861
1873
  }
1862
1874
  this.cb = cb;
@@ -1870,7 +1882,7 @@ var WatcherEffect = class extends ReactiveEffect {
1870
1882
  if (!this.cb) return;
1871
1883
  const { immediate, deep, call } = this.options;
1872
1884
  if (initialRun && !immediate) return;
1873
- if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1885
+ if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
1874
1886
  cleanup(this);
1875
1887
  const currentWatcher = activeWatcher;
1876
1888
  activeWatcher = this;
@@ -2139,8 +2151,8 @@ function findInsertionIndex(order, queue, start, end) {
2139
2151
  /**
2140
2152
  * @internal for runtime-vapor only
2141
2153
  */
2142
- function queueJob(job, id, isPre = false) {
2143
- if (queueJobWorker(job, id === void 0 ? isPre ? -2 : Infinity : isPre ? id * 2 : id * 2 + 1, jobs, jobsLength, flushIndex)) {
2154
+ function queueJob(job, id, isPre = false, order = 0) {
2155
+ if (queueJobWorker(job, id === void 0 ? isPre ? -2 : Infinity : isPre ? id * 2 : order ? id * 2 + 1 + order / (order + 1) : id * 2 + 1, jobs, jobsLength, flushIndex)) {
2144
2156
  jobsLength++;
2145
2157
  queueFlush();
2146
2158
  }
@@ -2249,6 +2261,7 @@ function flushJobs(seen) {
2249
2261
  }
2250
2262
  flushIndex = 0;
2251
2263
  jobsLength = 0;
2264
+ jobs.length = 0;
2252
2265
  flushPostFlushCbs(seen);
2253
2266
  currentFlushPromise = null;
2254
2267
  if (jobsLength || postJobs.length) flushJobs(seen);
@@ -2268,6 +2281,13 @@ function checkRecursiveUpdates(seen, fn) {
2268
2281
  //#endregion
2269
2282
  //#region packages/runtime-core/src/hmr.ts
2270
2283
  let isHmrUpdating = false;
2284
+ const setHmrUpdating = (v) => {
2285
+ try {
2286
+ return isHmrUpdating;
2287
+ } finally {
2288
+ isHmrUpdating = v;
2289
+ }
2290
+ };
2271
2291
  const hmrDirtyComponents = /* @__PURE__ */ new Map();
2272
2292
  const hmrDirtyComponentsMode = /* @__PURE__ */ new Map();
2273
2293
  getGlobalThis().__VUE_HMR_RUNTIME__ = {
@@ -2299,6 +2319,14 @@ function createRecord(id, initialDef) {
2299
2319
  function normalizeClassComponent(component) {
2300
2320
  return isClassComponent(component) ? component.__vccOpts : component;
2301
2321
  }
2322
+ function hasDirtyAncestor(instance, dirtyInstances) {
2323
+ let parent = instance.parent;
2324
+ while (parent) {
2325
+ if (dirtyInstances.has(parent)) return true;
2326
+ parent = parent.parent;
2327
+ }
2328
+ return false;
2329
+ }
2302
2330
  function rerender(id, newRender) {
2303
2331
  const record = map.get(id);
2304
2332
  if (!record) return;
@@ -2330,42 +2358,69 @@ function reload(id, newComp) {
2330
2358
  const isVapor = record.initialDef.__vapor;
2331
2359
  updateComponentDef(record.initialDef, newComp);
2332
2360
  const instances = [...record.instances];
2333
- if (isVapor && newComp.__vapor && !instances.some((i) => i.ceReload)) {
2361
+ if (isVapor && newComp.__vapor && !instances.some((instance) => instance.parent && !instance.parent.vapor) && !instances.some((i) => i.ceReload)) {
2334
2362
  for (const instance of instances) if (instance.root && instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(instance.type);
2335
- for (const instance of instances) instance.hmrReload(newComp);
2336
- } else for (const instance of instances) {
2337
- const oldComp = normalizeClassComponent(instance.type);
2338
- let dirtyInstances = hmrDirtyComponents.get(oldComp);
2339
- if (!dirtyInstances) {
2340
- if (oldComp !== record.initialDef) updateComponentDef(oldComp, newComp);
2341
- hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
2342
- }
2343
- dirtyInstances.add(instance);
2344
- hmrDirtyComponentsMode.set(oldComp, !!isVapor);
2345
- instance.appContext.propsCache.delete(instance.type);
2346
- instance.appContext.emitsCache.delete(instance.type);
2347
- instance.appContext.optionsCache.delete(instance.type);
2348
- if (instance.ceReload) {
2349
- dirtyInstances.add(instance);
2350
- instance.ceReload(newComp.styles);
2351
- dirtyInstances.delete(instance);
2352
- } else if (instance.parent) queueJob(() => {
2353
- isHmrUpdating = true;
2363
+ const dirtyInstances = new Set(instances);
2364
+ const rerenderedParents = /* @__PURE__ */ new Set();
2365
+ for (const instance of instances) {
2354
2366
  const parent = instance.parent;
2355
- if (parent.vapor) parent.hmrRerender();
2356
- else if (!(parent.effect.flags & 1024)) {
2357
- parent.renderCache = [];
2358
- parent.effect.run();
2367
+ if (parent) {
2368
+ if (!hasDirtyAncestor(instance, dirtyInstances) && !rerenderedParents.has(parent)) {
2369
+ rerenderedParents.add(parent);
2370
+ parent.hmrRerender();
2371
+ }
2372
+ } else instance.hmrReload(newComp);
2373
+ }
2374
+ } else {
2375
+ const parentUpdates = /* @__PURE__ */ new Map();
2376
+ const dirtyInstanceSet = new Set(instances);
2377
+ for (const instance of instances) {
2378
+ const oldComp = normalizeClassComponent(instance.type);
2379
+ let dirtyInstances = hmrDirtyComponents.get(oldComp);
2380
+ if (!dirtyInstances) {
2381
+ if (oldComp !== record.initialDef) updateComponentDef(oldComp, newComp);
2382
+ hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
2359
2383
  }
2360
- nextTick(() => {
2361
- isHmrUpdating = false;
2384
+ dirtyInstances.add(instance);
2385
+ hmrDirtyComponentsMode.set(oldComp, !!isVapor);
2386
+ instance.appContext.propsCache.delete(instance.type);
2387
+ instance.appContext.emitsCache.delete(instance.type);
2388
+ instance.appContext.optionsCache.delete(instance.type);
2389
+ if (instance.ceReload) {
2390
+ dirtyInstances.add(instance);
2391
+ instance.ceReload(newComp.styles);
2392
+ dirtyInstances.delete(instance);
2393
+ } else if (instance.parent) {
2394
+ const parent = instance.parent;
2395
+ if (!hasDirtyAncestor(instance, dirtyInstanceSet)) {
2396
+ let updates = parentUpdates.get(parent);
2397
+ if (!updates) parentUpdates.set(parent, updates = []);
2398
+ updates.push([instance, dirtyInstances]);
2399
+ }
2400
+ } else if (instance.appContext.reload) instance.appContext.reload();
2401
+ else if (typeof window !== "undefined") window.location.reload();
2402
+ else console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
2403
+ if (instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(oldComp);
2404
+ }
2405
+ parentUpdates.forEach((updates, parent) => {
2406
+ queueJob(() => {
2407
+ isHmrUpdating = true;
2408
+ if (parent.vapor) parent.hmrRerender();
2409
+ else {
2410
+ const i = parent;
2411
+ if (!(i.effect.flags & 1024)) {
2412
+ i.renderCache = [];
2413
+ i.effect.run();
2414
+ }
2415
+ }
2416
+ nextTick(() => {
2417
+ isHmrUpdating = false;
2418
+ });
2419
+ updates.forEach(([instance, dirtyInstances]) => {
2420
+ dirtyInstances.delete(instance);
2421
+ });
2362
2422
  });
2363
- dirtyInstances.delete(instance);
2364
2423
  });
2365
- else if (instance.appContext.reload) instance.appContext.reload();
2366
- else if (typeof window !== "undefined") window.location.reload();
2367
- else console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
2368
- if (instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(oldComp);
2369
2424
  }
2370
2425
  queuePostFlushCb(() => {
2371
2426
  hmrDirtyComponents.clear();
@@ -2488,10 +2543,12 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
2488
2543
  const renderFnWithContext = (...args) => {
2489
2544
  if (renderFnWithContext._d) setBlockTracking(-1);
2490
2545
  const prevInstance = setCurrentRenderingInstance$1(ctx);
2546
+ const prevStackSize = blockStack.length;
2491
2547
  let res;
2492
2548
  try {
2493
2549
  res = fn(...args);
2494
2550
  } finally {
2551
+ for (let i = blockStack.length; i > prevStackSize; i--) closeBlock();
2495
2552
  setCurrentRenderingInstance$1(prevInstance);
2496
2553
  if (renderFnWithContext._d) setBlockTracking(1);
2497
2554
  }
@@ -3513,7 +3570,8 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
3513
3570
  */
3514
3571
  function isEmitListener(options, key) {
3515
3572
  if (!options || !isOn(key)) return false;
3516
- key = key.slice(2).replace(/Once$/, "");
3573
+ key = key.slice(2);
3574
+ key = key === "Once" ? key : key.replace(/Once$/, "");
3517
3575
  return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
3518
3576
  }
3519
3577
  //#endregion
@@ -3697,15 +3755,19 @@ function hasPropValueChanged(nextProps, prevProps, key) {
3697
3755
  if (key === "style" && isObject(nextProp) && isObject(prevProp)) return !looseEqual(nextProp, prevProp);
3698
3756
  return nextProp !== prevProp;
3699
3757
  }
3700
- function updateHOCHostEl({ vnode, parent }, el) {
3758
+ function updateHOCHostEl({ vnode, parent, suspense }, el) {
3701
3759
  while (parent && !parent.vapor) {
3702
3760
  const root = parent.subTree;
3703
- if (root.suspense && root.suspense.activeBranch === vnode) root.el = vnode.el;
3761
+ if (root.suspense && root.suspense.activeBranch === vnode) {
3762
+ root.suspense.vnode.el = root.el = el;
3763
+ vnode = root;
3764
+ }
3704
3765
  if (root === vnode) {
3705
3766
  (vnode = parent.vnode).el = el;
3706
3767
  parent = parent.parent;
3707
3768
  } else break;
3708
3769
  }
3770
+ if (suspense && suspense.activeBranch === vnode) suspense.vnode.el = el;
3709
3771
  }
3710
3772
  //#endregion
3711
3773
  //#region packages/runtime-core/src/internalObject.ts
@@ -3984,7 +4046,7 @@ function getInvalidTypeMessage(name, value, expectedTypes) {
3984
4046
  const receivedType = toRawType(value);
3985
4047
  const expectedValue = styleValue(value, expectedType);
3986
4048
  const receivedValue = styleValue(value, receivedType);
3987
- if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) message += ` with value ${expectedValue}`;
4049
+ if (expectedTypes.length === 1 && isExplicable(expectedType) && isCoercible(expectedType, receivedType)) message += ` with value ${expectedValue}`;
3988
4050
  message += `, got ${receivedType} `;
3989
4051
  if (isExplicable(receivedType)) message += `with value ${receivedValue}.`;
3990
4052
  return message;
@@ -3993,7 +4055,8 @@ function getInvalidTypeMessage(name, value, expectedTypes) {
3993
4055
  * dev only
3994
4056
  */
3995
4057
  function styleValue(value, type) {
3996
- if (type === "String") return `"${value}"`;
4058
+ if (isSymbol(value)) return value.toString();
4059
+ else if (type === "String") return `"${value}"`;
3997
4060
  else if (type === "Number") return `${Number(value)}`;
3998
4061
  else return `${value}`;
3999
4062
  }
@@ -4010,8 +4073,11 @@ function isExplicable(type) {
4010
4073
  /**
4011
4074
  * dev only
4012
4075
  */
4013
- function isBoolean(...args) {
4014
- return args.some((elem) => elem.toLowerCase() === "boolean");
4076
+ function isCoercible(...args) {
4077
+ return args.every((elem) => {
4078
+ const value = elem.toLowerCase();
4079
+ return value !== "boolean" && value !== "symbol";
4080
+ });
4015
4081
  }
4016
4082
  //#endregion
4017
4083
  //#region packages/runtime-core/src/componentSlots.ts
@@ -4270,10 +4336,19 @@ function baseCreateRenderer(options, createHydrationFns) {
4270
4336
  if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
4271
4337
  if (transition) performTransitionEnter(el, transition, () => hostInsert(el, container, anchor), parentSuspense);
4272
4338
  else hostInsert(el, container, anchor);
4273
- if ((vnodeHook = props && props.onVnodeMounted) || dirs) queuePostRenderEffect(() => {
4274
- vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4275
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
4276
- }, void 0, parentSuspense);
4339
+ if ((vnodeHook = props && props.onVnodeMounted) || dirs) {
4340
+ const isHmr = isHmrUpdating;
4341
+ queuePostRenderEffect(() => {
4342
+ let prev;
4343
+ prev = setHmrUpdating(isHmr);
4344
+ try {
4345
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4346
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
4347
+ } finally {
4348
+ setHmrUpdating(prev);
4349
+ }
4350
+ }, void 0, parentSuspense);
4351
+ }
4277
4352
  };
4278
4353
  const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
4279
4354
  if (scopeId) hostSetScopeId(el, scopeId);
@@ -4296,7 +4371,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4296
4371
  if (vnodeHook = newProps.onVnodeBeforeUpdate) invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
4297
4372
  if (dirs) invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
4298
4373
  parentComponent && toggleRecurse(parentComponent, true);
4299
- if (isHmrUpdating) {
4374
+ if (isHmrUpdating || dynamicChildren && (!n1.dynamicChildren || n1.dynamicChildren.length !== dynamicChildren.length)) {
4300
4375
  patchFlag = 0;
4301
4376
  optimized = false;
4302
4377
  dynamicChildren = null;
@@ -4376,19 +4451,35 @@ function baseCreateRenderer(options, createHydrationFns) {
4376
4451
  n2.slotScopeIds = slotScopeIds;
4377
4452
  if (n2.type.__vapor) if (n1 == null) if (n2.shapeFlag & 512) getVaporInterface(parentComponent, n2).activate(n2, container, anchor, parentComponent);
4378
4453
  else {
4454
+ const vnodeBeforeMountHook = !isAsyncWrapper(n2) && n2.props && n2.props.onVnodeBeforeMount;
4379
4455
  getVaporInterface(parentComponent, n2).mount(n2, container, anchor, parentComponent, parentSuspense, () => {
4380
4456
  if (n2.dirs) {
4381
4457
  invokeDirectiveHook(n2, null, parentComponent, "created");
4382
4458
  invokeDirectiveHook(n2, null, parentComponent, "beforeMount");
4383
4459
  }
4460
+ }, () => {
4461
+ if (vnodeBeforeMountHook) invokeVNodeHook(vnodeBeforeMountHook, parentComponent, n2);
4384
4462
  });
4385
4463
  if (n2.dirs) queuePostRenderEffect(() => invokeDirectiveHook(n2, null, parentComponent, "mounted"), void 0, parentSuspense);
4464
+ const vnodeMountedHook = !isAsyncWrapper(n2) && n2.props && n2.props.onVnodeMounted;
4465
+ if (vnodeMountedHook) {
4466
+ const scopedVNode = n2;
4467
+ queuePostRenderEffect(() => invokeVNodeHook(vnodeMountedHook, parentComponent, scopedVNode), void 0, parentSuspense);
4468
+ }
4386
4469
  }
4387
4470
  else {
4388
- getVaporInterface(parentComponent, n2).update(n1, n2, shouldUpdateComponent(n1, n2, optimized), () => {
4471
+ const shouldUpdate = shouldUpdateComponent(n1, n2, optimized);
4472
+ getVaporInterface(parentComponent, n2).update(n1, n2, shouldUpdate, () => {
4389
4473
  if (n2.dirs) invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
4474
+ }, () => {
4475
+ const vnodeBeforeUpdateHook = n2.props && n2.props.onVnodeBeforeUpdate;
4476
+ if (vnodeBeforeUpdateHook) invokeVNodeHook(vnodeBeforeUpdateHook, parentComponent, n2, n1);
4390
4477
  });
4391
- if (n2.dirs) queuePostRenderEffect(() => invokeDirectiveHook(n2, n1, parentComponent, "updated"), void 0, parentSuspense);
4478
+ const vnodeUpdatedHook = n2.props && n2.props.onVnodeUpdated;
4479
+ if (shouldUpdate && (vnodeUpdatedHook || n2.dirs)) queuePostRenderEffect(() => {
4480
+ n2.dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
4481
+ vnodeUpdatedHook && invokeVNodeHook(vnodeUpdatedHook, parentComponent, n2, n1);
4482
+ }, void 0, parentSuspense);
4392
4483
  }
4393
4484
  else if (n1 == null) if (n2.shapeFlag & 512) parentComponent.ctx.activate(n2, container, anchor, namespace, optimized);
4394
4485
  else mountComponent(n2, container, anchor, parentComponent, parentSuspense, namespace, optimized);
@@ -4734,8 +4825,10 @@ function baseCreateRenderer(options, createHydrationFns) {
4734
4825
  else hostInsert(el, container, anchor);
4735
4826
  };
4736
4827
  const performLeave = () => {
4828
+ const wasLeaving = el._isLeaving || !!el[leaveCbKey];
4737
4829
  if (el._isLeaving) el[leaveCbKey](true);
4738
- leave(el, () => {
4830
+ if (transition.persisted && !wasLeaving) remove();
4831
+ else leave(el, () => {
4739
4832
  remove();
4740
4833
  afterLeave && afterLeave();
4741
4834
  });
@@ -4746,7 +4839,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4746
4839
  else hostInsert(el, container, anchor);
4747
4840
  };
4748
4841
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
4749
- const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex } = vnode;
4842
+ const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
4750
4843
  if (patchFlag === -2) optimized = false;
4751
4844
  if (ref != null) {
4752
4845
  const prevSub = setActiveSub();
@@ -4766,7 +4859,10 @@ function baseCreateRenderer(options, createHydrationFns) {
4766
4859
  if (shapeFlag & 6) if (isVaporComponent(type)) {
4767
4860
  if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
4768
4861
  getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
4769
- if (dirs) queuePostRenderEffect(() => invokeDirectiveHook(vnode, null, parentComponent, "unmounted"), void 0, parentSuspense);
4862
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || dirs) queuePostRenderEffect(() => {
4863
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
4864
+ vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4865
+ }, void 0, parentSuspense);
4770
4866
  return;
4771
4867
  } else unmountComponent(vnode.component, parentSuspense, doRemove);
4772
4868
  else {
@@ -4784,9 +4880,11 @@ function baseCreateRenderer(options, createHydrationFns) {
4784
4880
  }
4785
4881
  if (doRemove) remove(vnode);
4786
4882
  }
4787
- if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) queuePostRenderEffect(() => {
4883
+ const shouldInvalidateMemo = memo != null && cacheIndex == null;
4884
+ if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs || shouldInvalidateMemo) queuePostRenderEffect(() => {
4788
4885
  vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
4789
4886
  shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
4887
+ if (shouldInvalidateMemo) vnode.el = null;
4790
4888
  }, void 0, parentSuspense);
4791
4889
  };
4792
4890
  const remove = (vnode) => {
@@ -4825,7 +4923,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4825
4923
  if (effect) {
4826
4924
  effect.stop();
4827
4925
  unmount(subTree, instance, parentSuspense, doRemove);
4828
- }
4926
+ } else if (doRemove && subTree && instance.vnode.el) remove(subTree);
4829
4927
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
4830
4928
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
4831
4929
  devtoolsComponentRemoved(instance);
@@ -4951,6 +5049,10 @@ function invalidateMount(hooks) {
4951
5049
  if (hooks) for (let i = 0; i < hooks.length; i++) hooks[i].flags |= 4;
4952
5050
  }
4953
5051
  function performTransitionEnter(el, transition, insert, parentSuspense, force = false) {
5052
+ if (force && transition.persisted && !el[leaveCbKey]) {
5053
+ insert();
5054
+ return;
5055
+ }
4954
5056
  if (force || needTransition(parentSuspense, transition)) {
4955
5057
  transition.beforeEnter(el);
4956
5058
  insert();
@@ -5025,6 +5127,11 @@ const Comment = Symbol.for("v-cmt");
5025
5127
  const Static = Symbol.for("v-stc");
5026
5128
  const VaporSlot = Symbol.for("v-vps");
5027
5129
  const blockStack = [];
5130
+ let currentBlock = null;
5131
+ function closeBlock() {
5132
+ blockStack.pop();
5133
+ currentBlock = blockStack[blockStack.length - 1] || null;
5134
+ }
5028
5135
  let isBlockTreeEnabled = 1;
5029
5136
  /**
5030
5137
  * Block tracking sometimes needs to be disabled, for example during the
@@ -5044,6 +5151,7 @@ let isBlockTreeEnabled = 1;
5044
5151
  */
5045
5152
  function setBlockTracking(value, inVOnce = false) {
5046
5153
  isBlockTreeEnabled += value;
5154
+ if (value < 0 && currentBlock && inVOnce) currentBlock.hasOnce = true;
5047
5155
  }
5048
5156
  function isVNode$2(value) {
5049
5157
  return value ? value.__v_isVNode === true : false;
@@ -5107,6 +5215,7 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
5107
5215
  if (shapeFlag & 128) type.normalize(vnode);
5108
5216
  } else if (children) vnode.shapeFlag |= isString(children) ? 8 : 16;
5109
5217
  if (vnode.key !== vnode.key) warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
5218
+ if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock && (vnode.patchFlag > 0 || shapeFlag & 6) && vnode.patchFlag !== 32) currentBlock.push(vnode);
5110
5219
  return vnode;
5111
5220
  }
5112
5221
  const createVNode = createVNodeWithArgsTransform;
@@ -5118,6 +5227,8 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
5118
5227
  if (isVNode$2(type)) {
5119
5228
  const cloned = cloneVNode(type, props, true);
5120
5229
  if (children) normalizeChildren(cloned, children);
5230
+ if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) if (cloned.shapeFlag & 6) currentBlock[currentBlock.indexOf(type)] = cloned;
5231
+ else currentBlock.push(cloned);
5121
5232
  cloned.patchFlag = -2;
5122
5233
  return cloned;
5123
5234
  }
@@ -5174,11 +5285,29 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
5174
5285
  el: vnode.el,
5175
5286
  anchor: vnode.anchor,
5176
5287
  ctx: vnode.ctx,
5177
- ce: vnode.ce
5288
+ ce: vnode.ce,
5289
+ vi: vnode.vi,
5290
+ vs: cloneVaporSlotMeta(vnode),
5291
+ vb: vnode.vb
5178
5292
  };
5179
5293
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
5180
5294
  return cloned;
5181
5295
  }
5296
+ function cloneVaporSlotMeta(vnode) {
5297
+ const vaporSlot = vnode.vs;
5298
+ if (!vaporSlot) return vaporSlot;
5299
+ const cloned = {
5300
+ slot: vaporSlot.slot,
5301
+ fallback: vaporSlot.fallback,
5302
+ outletFallback: vaporSlot.outletFallback
5303
+ };
5304
+ if (vnode.el) {
5305
+ cloned.state = vaporSlot.state;
5306
+ cloned.ref = vaporSlot.ref;
5307
+ cloned.scope = vaporSlot.scope;
5308
+ }
5309
+ return cloned;
5310
+ }
5182
5311
  /**
5183
5312
  * Dev only, for HMR of hoisted vnodes reused in v-for
5184
5313
  * https://github.com/vitejs/vite/issues/2022
@@ -5227,6 +5356,10 @@ function normalizeChildren(vnode, children) {
5227
5356
  }
5228
5357
  }
5229
5358
  else if (isFunction(children)) {
5359
+ if (shapeFlag & 65) {
5360
+ normalizeChildren(vnode, { default: children });
5361
+ return;
5362
+ }
5230
5363
  children = {
5231
5364
  default: children,
5232
5365
  _ctx: currentRenderingInstance
@@ -5253,6 +5386,7 @@ function mergeProps(...args) {
5253
5386
  const existing = ret[key];
5254
5387
  const incoming = toMerge[key];
5255
5388
  if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) ret[key] = existing ? [].concat(existing, incoming) : incoming;
5389
+ else if (incoming == null && existing == null && !isModelListener(key)) ret[key] = incoming;
5256
5390
  } else if (key !== "") ret[key] = toMerge[key];
5257
5391
  }
5258
5392
  return ret;
@@ -5570,7 +5704,7 @@ const computed = (getterOrOptions, debugOptions) => {
5570
5704
  };
5571
5705
  //#endregion
5572
5706
  //#region packages/runtime-core/src/index.ts
5573
- const version = "3.6.0-beta.8";
5707
+ const version = "3.6.0-rc.1";
5574
5708
  const warn = warn$1;
5575
5709
  /**
5576
5710
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
@@ -5717,7 +5851,10 @@ function patchStyle(el, prev, next) {
5717
5851
  }
5718
5852
  for (const key in next) {
5719
5853
  if (key === "display") hasControlledDisplay = true;
5720
- setStyle(style, key, next[key]);
5854
+ const value = next[key];
5855
+ if (value != null) {
5856
+ if (!shouldPreserveTextareaResizeStyle(el, key, !isString(prev) && prev ? prev[key] : void 0, value)) setStyle(style, key, value);
5857
+ } else setStyle(style, key, "");
5721
5858
  }
5722
5859
  } else if (isCssString) {
5723
5860
  if (prev !== next) {
@@ -5765,6 +5902,14 @@ function autoPrefix(style, rawName) {
5765
5902
  }
5766
5903
  return rawName;
5767
5904
  }
5905
+ /**
5906
+ * Browsers update textarea width/height directly during native resize.
5907
+ * Only special-case this common textarea path for now; other resize scenarios
5908
+ * still follow normal vnode style patching.
5909
+ */
5910
+ function shouldPreserveTextareaResizeStyle(el, key, prev, next) {
5911
+ return el.tagName === "TEXTAREA" && (key === "width" || key === "height") && isString(next) && prev === next;
5912
+ }
5768
5913
  //#endregion
5769
5914
  //#region packages/runtime-dom/src/modules/attrs.ts
5770
5915
  const xlinkNS = "http://www.w3.org/1999/xlink";
@@ -5823,7 +5968,7 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
5823
5968
  const existingInvoker = invokers[rawName];
5824
5969
  if (nextValue && existingInvoker) existingInvoker.value = sanitizeEventValue(nextValue, rawName);
5825
5970
  else {
5826
- const [name, options] = parseName(rawName);
5971
+ const [name, options] = parseEventName(rawName);
5827
5972
  if (nextValue) addEventListener(el, name, invokers[rawName] = createInvoker(sanitizeEventValue(nextValue, rawName), instance), options);
5828
5973
  else if (existingInvoker) {
5829
5974
  removeEventListener(el, name, existingInvoker, options);
@@ -5831,16 +5976,15 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
5831
5976
  }
5832
5977
  }
5833
5978
  }
5834
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
5835
- function parseName(name) {
5979
+ const optionsModifierRE = /(Once|Passive|Capture)$/;
5980
+ const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
5981
+ function parseEventName(name) {
5836
5982
  let options;
5837
- if (optionsModifierRE.test(name)) {
5838
- options = {};
5839
- let m;
5840
- while (m = name.match(optionsModifierRE)) {
5841
- name = name.slice(0, name.length - m[0].length);
5842
- options[m[0].toLowerCase()] = true;
5843
- }
5983
+ let m;
5984
+ while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
5985
+ if (!options) options = {};
5986
+ name = name.slice(0, name.length - m[1].length);
5987
+ options[m[1].toLowerCase()] = true;
5844
5988
  }
5845
5989
  return [name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2)), options];
5846
5990
  }
@@ -5851,7 +5995,21 @@ function createInvoker(initialValue, instance) {
5851
5995
  const invoker = (e) => {
5852
5996
  if (!e._vts) e._vts = Date.now();
5853
5997
  else if (e._vts <= invoker.attached) return;
5854
- callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5, [e]);
5998
+ const value = invoker.value;
5999
+ if (isArray(value)) {
6000
+ const originalStop = e.stopImmediatePropagation;
6001
+ e.stopImmediatePropagation = () => {
6002
+ originalStop.call(e);
6003
+ e._stopped = true;
6004
+ };
6005
+ const handlers = value.slice();
6006
+ const args = [e];
6007
+ for (let i = 0; i < handlers.length; i++) {
6008
+ if (e._stopped) break;
6009
+ const handler = handlers[i];
6010
+ if (handler) callWithAsyncErrorHandling(handler, instance, 5, args);
6011
+ }
6012
+ } else callWithAsyncErrorHandling(value, instance, 5, [e]);
5855
6013
  };
5856
6014
  invoker.value = initialValue;
5857
6015
  invoker.attached = getNow();
@@ -5862,16 +6020,6 @@ function sanitizeEventValue(value, propName) {
5862
6020
  warn(`Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?\nExpected function or array of functions, received type ${typeof value}.`);
5863
6021
  return NOOP;
5864
6022
  }
5865
- function patchStopImmediatePropagation(e, value) {
5866
- if (isArray(value)) {
5867
- const originalStop = e.stopImmediatePropagation;
5868
- e.stopImmediatePropagation = () => {
5869
- originalStop.call(e);
5870
- e._stopped = true;
5871
- };
5872
- return value.map((fn) => (e) => !e._stopped && fn && fn(e));
5873
- } else return value;
5874
- }
5875
6023
  //#endregion
5876
6024
  //#region packages/runtime-dom/src/patchProp.ts
5877
6025
  const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
@@ -5966,7 +6114,8 @@ const vModelTextUpdate = (el, oldValue, value, trim, number, lazy) => {
5966
6114
  const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
5967
6115
  const newValue = value == null ? "" : value;
5968
6116
  if (elValue === newValue) return;
5969
- if (document.activeElement === el && el.type !== "range") {
6117
+ const rootNode = el.getRootNode();
6118
+ if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
5970
6119
  if (lazy && value === oldValue) return;
5971
6120
  if (trim && el.value.trim() === newValue) return;
5972
6121
  }
@@ -6048,7 +6197,8 @@ const vModelSelect = {
6048
6197
  mounted(el, { value }) {
6049
6198
  vModelSetSelected(el, value);
6050
6199
  },
6051
- beforeUpdate(el, _binding, vnode) {
6200
+ beforeUpdate(el, { value }, vnode) {
6201
+ el._modelValue = value;
6052
6202
  el[assignKey] = getModelAssigner(vnode);
6053
6203
  },
6054
6204
  updated(el, { value }) {
@@ -6059,10 +6209,10 @@ const vModelSelect = {
6059
6209
  * @internal
6060
6210
  */
6061
6211
  const vModelSelectInit = (el, value, number, set) => {
6062
- const isSetModel = isSet(value);
6212
+ el._modelValue = value;
6063
6213
  addEventListener(el, "change", () => {
6064
6214
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map((o) => number ? looseToNumber(getValue(o)) : getValue(o));
6065
- (set || el[assignKey])(el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]);
6215
+ (set || el[assignKey])(el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]);
6066
6216
  el._assigning = true;
6067
6217
  nextTick(() => {
6068
6218
  el._assigning = false;
@@ -6073,6 +6223,7 @@ const vModelSelectInit = (el, value, number, set) => {
6073
6223
  * @internal
6074
6224
  */
6075
6225
  const vModelSetSelected = (el, value) => {
6226
+ el._modelValue = value;
6076
6227
  if (el._assigning) return;
6077
6228
  const isMultiple = el.multiple;
6078
6229
  const isArrayValue = isArray(value);
@@ -6290,6 +6441,11 @@ function ssrResetCssVars(raw) {
6290
6441
  //#endregion
6291
6442
  //#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
6292
6443
  function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
6444
+ if (isString(comp)) {
6445
+ const { getBuffer, push } = createBuffer();
6446
+ renderVNode(push, createVNode(comp, props, children), parentComponent, slotScopeId);
6447
+ return getBuffer();
6448
+ }
6293
6449
  return renderComponentVNode(createVNode(comp, props, children), parentComponent, slotScopeId);
6294
6450
  }
6295
6451
  //#endregion
@@ -6363,6 +6519,7 @@ function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parent
6363
6519
  teleportContent = getBuffer();
6364
6520
  }
6365
6521
  targetBuffer.splice(bufferIndex, 0, teleportContent);
6522
+ if (isPromise(teleportContent) || isArray(teleportContent) && teleportContent.hasAsync) targetBuffer.hasAsync = true;
6366
6523
  parentPush("<!--teleport end-->");
6367
6524
  }
6368
6525
  //#endregion
@@ -6381,8 +6538,8 @@ function ssrRenderList(source, renderItem) {
6381
6538
  }
6382
6539
  for (let i = 0; i < source; i++) renderItem(i + 1, i);
6383
6540
  } else if (isObject(source)) if (source[Symbol.iterator]) {
6384
- const arr = Array.from(source);
6385
- for (let i = 0, l = arr.length; i < l; i++) renderItem(arr[i], i);
6541
+ let i = 0;
6542
+ for (const item of source) renderItem(item, i++);
6386
6543
  } else {
6387
6544
  const keys = Object.keys(source);
6388
6545
  for (let i = 0, l = keys.length; i < l; i++) {
@@ -6393,7 +6550,7 @@ function ssrRenderList(source, renderItem) {
6393
6550
  }
6394
6551
  //#endregion
6395
6552
  //#region packages/server-renderer/src/helpers/ssrRenderSuspense.ts
6396
- async function ssrRenderSuspense(push, { default: renderContent }) {
6553
+ function ssrRenderSuspense(push, { default: renderContent }) {
6397
6554
  if (renderContent) renderContent();
6398
6555
  else push(`<!---->`);
6399
6556
  }
@@ -6439,6 +6596,26 @@ function ssrCompile(template, instance) {
6439
6596
  //#endregion
6440
6597
  //#region packages/server-renderer/src/render.ts
6441
6598
  const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = ssrUtils;
6599
+ function cleanupContext(context) {
6600
+ let firstError;
6601
+ if (context.__watcherHandles) {
6602
+ for (const unwatch of context.__watcherHandles) try {
6603
+ unwatch();
6604
+ } catch (err) {
6605
+ if (firstError === void 0) firstError = err;
6606
+ }
6607
+ context.__watcherHandles.length = 0;
6608
+ }
6609
+ if (context.__instanceScopes) {
6610
+ for (const scope of context.__instanceScopes) try {
6611
+ scope.stop();
6612
+ } catch (err) {
6613
+ if (firstError === void 0) firstError = err;
6614
+ }
6615
+ context.__instanceScopes.length = 0;
6616
+ }
6617
+ if (firstError !== void 0) throw firstError;
6618
+ }
6442
6619
  function createBuffer() {
6443
6620
  let appendable = false;
6444
6621
  const buffer = [];
@@ -6460,6 +6637,8 @@ function createBuffer() {
6460
6637
  }
6461
6638
  function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
6462
6639
  const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
6640
+ const context = instance.appContext.provides[ssrContextKey];
6641
+ if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
6463
6642
  pushWarningContext(vnode);
6464
6643
  const res = setupComponent(instance, true);
6465
6644
  popWarningContext();
@@ -6469,7 +6648,11 @@ function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
6469
6648
  if (hasAsyncSetup) prefetches = instance.sp;
6470
6649
  if (prefetches) return Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)));
6471
6650
  }).catch(NOOP).then(() => renderComponentSubTree(instance, slotScopeId));
6472
- else return renderComponentSubTree(instance, slotScopeId);
6651
+ else try {
6652
+ return renderComponentSubTree(instance, slotScopeId);
6653
+ } catch (err) {
6654
+ return Promise.reject(err);
6655
+ }
6473
6656
  }
6474
6657
  function renderComponentSubTree(instance, slotScopeId) {
6475
6658
  pushWarningContext(instance.vnode);
@@ -6509,6 +6692,8 @@ function renderComponentSubTree(instance, slotScopeId) {
6509
6692
  const prev = setCurrentRenderingInstance(instance);
6510
6693
  try {
6511
6694
  ssrRender(instance.proxy, push, instance, attrs, instance.props, instance.setupState, instance.data, instance.ctx);
6695
+ } catch (err) {
6696
+ handleError(err, instance, 1);
6512
6697
  } finally {
6513
6698
  setCurrentRenderingInstance(prev);
6514
6699
  }
@@ -6555,15 +6740,25 @@ function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
6555
6740
  let { props, children, shapeFlag, scopeId } = vnode;
6556
6741
  let openTag = `<${tag}`;
6557
6742
  if (props) openTag += ssrRenderAttrs(props, tag);
6558
- if (scopeId) openTag += ` ${scopeId}`;
6743
+ const renderedScopeIds = [];
6744
+ const appendScopeId = (id) => {
6745
+ if (id && (!props || !hasOwn(props, id)) && !renderedScopeIds.includes(id)) {
6746
+ openTag += ` ${id}`;
6747
+ renderedScopeIds.push(id);
6748
+ }
6749
+ };
6750
+ if (scopeId) appendScopeId(scopeId);
6559
6751
  let curParent = parentComponent;
6560
6752
  let curVnode = vnode;
6561
6753
  while (curParent && curVnode === curParent.subTree) {
6562
6754
  curVnode = curParent.vnode;
6563
- if (curVnode.scopeId) openTag += ` ${curVnode.scopeId}`;
6755
+ if (curVnode.scopeId) appendScopeId(curVnode.scopeId);
6564
6756
  curParent = curParent.parent;
6565
6757
  }
6566
- if (slotScopeId) openTag += ` ${slotScopeId}`;
6758
+ if (slotScopeId) {
6759
+ const slotScopeIdList = slotScopeId.trim().split(" ");
6760
+ for (let i = 0; i < slotScopeIdList.length; i++) appendScopeId(slotScopeIdList[i]);
6761
+ }
6567
6762
  push(openTag + `>`);
6568
6763
  if (!isVoidTag(tag)) {
6569
6764
  let hasChildrenOverride = false;
@@ -6655,15 +6850,18 @@ async function renderToString(input, context = {}) {
6655
6850
  const vnode = createVNode(input._component, input._props);
6656
6851
  vnode.appContext = input._context;
6657
6852
  input.provide(ssrContextKey, context);
6658
- const result = await unrollBuffer$1(await renderComponentVNode(vnode));
6659
- await resolveTeleports(context);
6660
- if (context.__watcherHandles) for (const unwatch of context.__watcherHandles) unwatch();
6661
- return result;
6853
+ try {
6854
+ const result = await unrollBuffer$1(await renderComponentVNode(vnode));
6855
+ await resolveTeleports(context);
6856
+ return result;
6857
+ } finally {
6858
+ cleanupContext(context);
6859
+ }
6662
6860
  }
6663
6861
  async function resolveTeleports(context) {
6664
6862
  if (context.__teleportBuffers) {
6665
6863
  context.teleports = context.teleports || {};
6666
- for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(await Promise.all([context.__teleportBuffers[key]]));
6864
+ for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(context.__teleportBuffers[key]);
6667
6865
  }
6668
6866
  }
6669
6867
  //#endregion
@@ -6680,7 +6878,7 @@ async function unrollBuffer(buffer, stream) {
6680
6878
  }
6681
6879
  function unrollBufferSync(buffer, stream) {
6682
6880
  for (let i = 0; i < buffer.length; i++) {
6683
- let item = buffer[i];
6881
+ const item = buffer[i];
6684
6882
  if (isString(item)) stream.push(item);
6685
6883
  else unrollBufferSync(item, stream);
6686
6884
  }
@@ -6690,9 +6888,19 @@ function renderToSimpleStream(input, context, stream) {
6690
6888
  const vnode = createVNode(input._component, input._props);
6691
6889
  vnode.appContext = input._context;
6692
6890
  input.provide(ssrContextKey, context);
6693
- Promise.resolve(renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
6694
- if (context.__watcherHandles) for (const unwatch of context.__watcherHandles) unwatch();
6695
- }).then(() => stream.push(null)).catch((error) => {
6891
+ let cleaned = false;
6892
+ const finalize = () => {
6893
+ if (cleaned) return;
6894
+ cleaned = true;
6895
+ cleanupContext(context);
6896
+ };
6897
+ Promise.resolve().then(() => renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
6898
+ finalize();
6899
+ return stream.push(null);
6900
+ }).catch((error) => {
6901
+ try {
6902
+ finalize();
6903
+ } catch {}
6696
6904
  stream.destroy(error);
6697
6905
  });
6698
6906
  return stream;