@vue/runtime-dom 3.5.0-alpha.5 → 3.5.0-beta.2

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-dom v3.5.0-alpha.5
2
+ * @vue/runtime-dom v3.5.0-beta.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -64,9 +64,11 @@ var VueRuntimeDOM = (function (exports) {
64
64
  };
65
65
  };
66
66
  const camelizeRE = /-(\w)/g;
67
- const camelize = cacheStringFunction((str) => {
68
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
69
- });
67
+ const camelize = cacheStringFunction(
68
+ (str) => {
69
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
70
+ }
71
+ );
70
72
  const hyphenateRE = /\B([A-Z])/g;
71
73
  const hyphenate = cacheStringFunction(
72
74
  (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
@@ -74,10 +76,12 @@ var VueRuntimeDOM = (function (exports) {
74
76
  const capitalize = cacheStringFunction((str) => {
75
77
  return str.charAt(0).toUpperCase() + str.slice(1);
76
78
  });
77
- const toHandlerKey = cacheStringFunction((str) => {
78
- const s = str ? `on${capitalize(str)}` : ``;
79
- return s;
80
- });
79
+ const toHandlerKey = cacheStringFunction(
80
+ (str) => {
81
+ const s = str ? `on${capitalize(str)}` : ``;
82
+ return s;
83
+ }
84
+ );
81
85
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
82
86
  const invokeArrayFns = (fns, ...arg) => {
83
87
  for (let i = 0; i < fns.length; i++) {
@@ -322,6 +326,7 @@ var VueRuntimeDOM = (function (exports) {
322
326
  * @internal
323
327
  */
324
328
  this.cleanups = [];
329
+ this._isPaused = false;
325
330
  this.parent = activeEffectScope;
326
331
  if (!detached && activeEffectScope) {
327
332
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
@@ -332,6 +337,37 @@ var VueRuntimeDOM = (function (exports) {
332
337
  get active() {
333
338
  return this._active;
334
339
  }
340
+ pause() {
341
+ if (this._active) {
342
+ this._isPaused = true;
343
+ if (this.scopes) {
344
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
345
+ this.scopes[i].pause();
346
+ }
347
+ }
348
+ for (let i = 0, l = this.effects.length; i < l; i++) {
349
+ this.effects[i].pause();
350
+ }
351
+ }
352
+ }
353
+ /**
354
+ * Resumes the effect scope, including all child scopes and effects.
355
+ */
356
+ resume() {
357
+ if (this._active) {
358
+ if (this._isPaused) {
359
+ this._isPaused = false;
360
+ if (this.scopes) {
361
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
362
+ this.scopes[i].resume();
363
+ }
364
+ }
365
+ for (let i = 0, l = this.effects.length; i < l; i++) {
366
+ this.effects[i].resume();
367
+ }
368
+ }
369
+ }
370
+ }
335
371
  run(fn) {
336
372
  if (this._active) {
337
373
  const currentEffectScope = activeEffectScope;
@@ -402,6 +438,7 @@ var VueRuntimeDOM = (function (exports) {
402
438
  }
403
439
 
404
440
  let activeSub;
441
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
405
442
  class ReactiveEffect {
406
443
  constructor(fn) {
407
444
  this.fn = fn;
@@ -430,6 +467,18 @@ var VueRuntimeDOM = (function (exports) {
430
467
  activeEffectScope.effects.push(this);
431
468
  }
432
469
  }
470
+ pause() {
471
+ this.flags |= 64;
472
+ }
473
+ resume() {
474
+ if (this.flags & 64) {
475
+ this.flags &= ~64;
476
+ if (pausedQueueEffects.has(this)) {
477
+ pausedQueueEffects.delete(this);
478
+ this.trigger();
479
+ }
480
+ }
481
+ }
433
482
  /**
434
483
  * @internal
435
484
  */
@@ -437,9 +486,6 @@ var VueRuntimeDOM = (function (exports) {
437
486
  if (this.flags & 2 && !(this.flags & 32)) {
438
487
  return;
439
488
  }
440
- if (this.flags & 64) {
441
- return this.trigger();
442
- }
443
489
  if (!(this.flags & 8)) {
444
490
  this.flags |= 8;
445
491
  this.nextEffect = batchedEffect;
@@ -483,7 +529,9 @@ var VueRuntimeDOM = (function (exports) {
483
529
  }
484
530
  }
485
531
  trigger() {
486
- if (this.scheduler) {
532
+ if (this.flags & 64) {
533
+ pausedQueueEffects.add(this);
534
+ } else if (this.scheduler) {
487
535
  this.scheduler();
488
536
  } else {
489
537
  this.runIfDirty();
@@ -511,6 +559,7 @@ var VueRuntimeDOM = (function (exports) {
511
559
  batchDepth--;
512
560
  return;
513
561
  }
562
+ batchDepth--;
514
563
  let error;
515
564
  while (batchedEffect) {
516
565
  let e = batchedEffect;
@@ -529,7 +578,6 @@ var VueRuntimeDOM = (function (exports) {
529
578
  e = next;
530
579
  }
531
580
  }
532
- batchDepth--;
533
581
  if (error) throw error;
534
582
  }
535
583
  function prepareDeps(sub) {
@@ -803,9 +851,15 @@ var VueRuntimeDOM = (function (exports) {
803
851
  link.dep.subs = link;
804
852
  }
805
853
  const targetMap = /* @__PURE__ */ new WeakMap();
806
- const ITERATE_KEY = Symbol("Object iterate" );
807
- const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
808
- const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
854
+ const ITERATE_KEY = Symbol(
855
+ "Object iterate"
856
+ );
857
+ const MAP_KEY_ITERATE_KEY = Symbol(
858
+ "Map keys iterate"
859
+ );
860
+ const ARRAY_ITERATE_KEY = Symbol(
861
+ "Array iterate"
862
+ );
809
863
  function track(target, type, key) {
810
864
  if (shouldTrack && activeSub) {
811
865
  let depsMap = targetMap.get(target);
@@ -926,26 +980,26 @@ var VueRuntimeDOM = (function (exports) {
926
980
  });
927
981
  },
928
982
  every(fn, thisArg) {
929
- return apply(this, "every", fn, thisArg);
983
+ return apply(this, "every", fn, thisArg, void 0, arguments);
930
984
  },
931
985
  filter(fn, thisArg) {
932
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
986
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
933
987
  },
934
988
  find(fn, thisArg) {
935
- return apply(this, "find", fn, thisArg, toReactive);
989
+ return apply(this, "find", fn, thisArg, toReactive, arguments);
936
990
  },
937
991
  findIndex(fn, thisArg) {
938
- return apply(this, "findIndex", fn, thisArg);
992
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
939
993
  },
940
994
  findLast(fn, thisArg) {
941
- return apply(this, "findLast", fn, thisArg, toReactive);
995
+ return apply(this, "findLast", fn, thisArg, toReactive, arguments);
942
996
  },
943
997
  findLastIndex(fn, thisArg) {
944
- return apply(this, "findLastIndex", fn, thisArg);
998
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
945
999
  },
946
1000
  // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
947
1001
  forEach(fn, thisArg) {
948
- return apply(this, "forEach", fn, thisArg);
1002
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
949
1003
  },
950
1004
  includes(...args) {
951
1005
  return searchProxy(this, "includes", args);
@@ -961,7 +1015,7 @@ var VueRuntimeDOM = (function (exports) {
961
1015
  return searchProxy(this, "lastIndexOf", args);
962
1016
  },
963
1017
  map(fn, thisArg) {
964
- return apply(this, "map", fn, thisArg);
1018
+ return apply(this, "map", fn, thisArg, void 0, arguments);
965
1019
  },
966
1020
  pop() {
967
1021
  return noTracking(this, "pop");
@@ -980,7 +1034,7 @@ var VueRuntimeDOM = (function (exports) {
980
1034
  },
981
1035
  // slice could use ARRAY_ITERATE but also seems to beg for range tracking
982
1036
  some(fn, thisArg) {
983
- return apply(this, "some", fn, thisArg);
1037
+ return apply(this, "some", fn, thisArg, void 0, arguments);
984
1038
  },
985
1039
  splice(...args) {
986
1040
  return noTracking(this, "splice", args);
@@ -1016,8 +1070,13 @@ var VueRuntimeDOM = (function (exports) {
1016
1070
  }
1017
1071
  return iter;
1018
1072
  }
1019
- function apply(self, method, fn, thisArg, wrappedRetFn) {
1073
+ const arrayProto = Array.prototype;
1074
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1020
1075
  const arr = shallowReadArray(self);
1076
+ let methodFn;
1077
+ if ((methodFn = arr[method]) !== arrayProto[method]) {
1078
+ return methodFn.apply(arr, args);
1079
+ }
1021
1080
  let needsWrap = false;
1022
1081
  let wrappedFn = fn;
1023
1082
  if (arr !== self) {
@@ -1032,7 +1091,7 @@ var VueRuntimeDOM = (function (exports) {
1032
1091
  };
1033
1092
  }
1034
1093
  }
1035
- const result = arr[method](wrappedFn, thisArg);
1094
+ const result = methodFn.call(arr, wrappedFn, thisArg);
1036
1095
  return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
1037
1096
  }
1038
1097
  function reduce(self, method, fn, args) {
@@ -1095,7 +1154,7 @@ var VueRuntimeDOM = (function (exports) {
1095
1154
  return isShallow2;
1096
1155
  } else if (key === "__v_raw") {
1097
1156
  if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
1098
- // this means the reciever is a user proxy of the reactive proxy
1157
+ // this means the receiver is a user proxy of the reactive proxy
1099
1158
  Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
1100
1159
  return target;
1101
1160
  }
@@ -1219,9 +1278,7 @@ var VueRuntimeDOM = (function (exports) {
1219
1278
  }
1220
1279
  const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
1221
1280
  const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
1222
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
1223
- true
1224
- );
1281
+ const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
1225
1282
  const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
1226
1283
 
1227
1284
  const toShallow = (value) => value;
@@ -1716,13 +1773,14 @@ var VueRuntimeDOM = (function (exports) {
1716
1773
  class CustomRefImpl {
1717
1774
  constructor(factory) {
1718
1775
  this["__v_isRef"] = true;
1776
+ this._value = void 0;
1719
1777
  const dep = this.dep = new Dep();
1720
1778
  const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1721
1779
  this._get = get;
1722
1780
  this._set = set;
1723
1781
  }
1724
1782
  get value() {
1725
- return this._get();
1783
+ return this._value = this._get();
1726
1784
  }
1727
1785
  set value(newVal) {
1728
1786
  this._set(newVal);
@@ -1747,10 +1805,11 @@ var VueRuntimeDOM = (function (exports) {
1747
1805
  this._key = _key;
1748
1806
  this._defaultValue = _defaultValue;
1749
1807
  this["__v_isRef"] = true;
1808
+ this._value = void 0;
1750
1809
  }
1751
1810
  get value() {
1752
1811
  const val = this._object[this._key];
1753
- return val === void 0 ? this._defaultValue : val;
1812
+ return this._value = val === void 0 ? this._defaultValue : val;
1754
1813
  }
1755
1814
  set value(newVal) {
1756
1815
  this._object[this._key] = newVal;
@@ -1764,9 +1823,10 @@ var VueRuntimeDOM = (function (exports) {
1764
1823
  this._getter = _getter;
1765
1824
  this["__v_isRef"] = true;
1766
1825
  this["__v_isReadonly"] = true;
1826
+ this._value = void 0;
1767
1827
  }
1768
1828
  get value() {
1769
- return this._getter();
1829
+ return this._value = this._getter();
1770
1830
  }
1771
1831
  }
1772
1832
  function toRef(source, key, defaultValue) {
@@ -1800,7 +1860,8 @@ var VueRuntimeDOM = (function (exports) {
1800
1860
  /**
1801
1861
  * @internal
1802
1862
  */
1803
- this["__v_isRef"] = true;
1863
+ this.__v_isRef = true;
1864
+ // TODO isolatedDeclarations "__v_isReadonly"
1804
1865
  // A computed is also a subscriber that tracks other deps
1805
1866
  /**
1806
1867
  * @internal
@@ -2425,6 +2486,9 @@ var VueRuntimeDOM = (function (exports) {
2425
2486
  "[HMR] Root or manually mounted instance modified. Full reload required."
2426
2487
  );
2427
2488
  }
2489
+ if (instance.root.ce && instance !== instance.root) {
2490
+ instance.root.ce._removeChildStyle(oldComp);
2491
+ }
2428
2492
  }
2429
2493
  queuePostFlushCb(() => {
2430
2494
  hmrDirtyComponents.clear();
@@ -2504,9 +2568,7 @@ var VueRuntimeDOM = (function (exports) {
2504
2568
  function devtoolsUnmountApp(app) {
2505
2569
  emit$1("app:unmount" /* APP_UNMOUNT */, app);
2506
2570
  }
2507
- const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
2508
- "component:added" /* COMPONENT_ADDED */
2509
- );
2571
+ const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
2510
2572
  const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
2511
2573
  const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
2512
2574
  "component:removed" /* COMPONENT_REMOVED */
@@ -2530,12 +2592,8 @@ var VueRuntimeDOM = (function (exports) {
2530
2592
  );
2531
2593
  };
2532
2594
  }
2533
- const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
2534
- "perf:start" /* PERFORMANCE_START */
2535
- );
2536
- const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
2537
- "perf:end" /* PERFORMANCE_END */
2538
- );
2595
+ const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
2596
+ const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
2539
2597
  function createDevtoolsPerformanceHook(hook) {
2540
2598
  return (component, type, time) => {
2541
2599
  emit$1(hook, component.appContext.app, component.uid, component, type, time);
@@ -3438,6 +3496,7 @@ var VueRuntimeDOM = (function (exports) {
3438
3496
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
3439
3497
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
3440
3498
  const getContainerType = (container) => {
3499
+ if (container.nodeType !== 1) return void 0;
3441
3500
  if (isSVGContainer(container)) return "svg";
3442
3501
  if (isMathMLContainer(container)) return "mathml";
3443
3502
  return void 0;
@@ -3713,6 +3772,7 @@ Server rendered element contains more child nodes than client vdom.`
3713
3772
  }
3714
3773
  if (props) {
3715
3774
  {
3775
+ const isCustomElement = el.tagName.includes("-");
3716
3776
  for (const key in props) {
3717
3777
  if (// #11189 skip if this node has directives that have created hooks
3718
3778
  // as it could have mutated the DOM in any possible way
@@ -3720,7 +3780,7 @@ Server rendered element contains more child nodes than client vdom.`
3720
3780
  logMismatchError();
3721
3781
  }
3722
3782
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
3723
- key[0] === ".") {
3783
+ key[0] === "." || isCustomElement) {
3724
3784
  patchProp(el, key, null, props[key], void 0, parentComponent);
3725
3785
  }
3726
3786
  }
@@ -4045,24 +4105,19 @@ Server rendered element contains fewer child nodes than client vdom.`
4045
4105
  }
4046
4106
  }
4047
4107
 
4048
- const hydrateOnIdle = () => (hydrate) => {
4049
- const id = requestIdleCallback(hydrate);
4108
+ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
4109
+ const id = requestIdleCallback(hydrate, { timeout });
4050
4110
  return () => cancelIdleCallback(id);
4051
4111
  };
4052
- const hydrateOnVisible = (margin = 0) => (hydrate, forEach) => {
4053
- const ob = new IntersectionObserver(
4054
- (entries) => {
4055
- for (const e of entries) {
4056
- if (!e.isIntersecting) continue;
4057
- ob.disconnect();
4058
- hydrate();
4059
- break;
4060
- }
4061
- },
4062
- {
4063
- rootMargin: isString(margin) ? margin : margin + "px"
4112
+ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4113
+ const ob = new IntersectionObserver((entries) => {
4114
+ for (const e of entries) {
4115
+ if (!e.isIntersecting) continue;
4116
+ ob.disconnect();
4117
+ hydrate();
4118
+ break;
4064
4119
  }
4065
- );
4120
+ }, opts);
4066
4121
  forEach((el) => ob.observe(el));
4067
4122
  return () => ob.disconnect();
4068
4123
  };
@@ -4364,14 +4419,14 @@ Server rendered element contains fewer child nodes than client vdom.`
4364
4419
  function pruneCache(filter) {
4365
4420
  cache.forEach((vnode, key) => {
4366
4421
  const name = getComponentName(vnode.type);
4367
- if (name && (!filter || !filter(name))) {
4422
+ if (name && !filter(name)) {
4368
4423
  pruneCacheEntry(key);
4369
4424
  }
4370
4425
  });
4371
4426
  }
4372
4427
  function pruneCacheEntry(key) {
4373
4428
  const cached = cache.get(key);
4374
- if (!current || !isSameVNodeType(cached, current)) {
4429
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
4375
4430
  unmount(cached);
4376
4431
  } else if (current) {
4377
4432
  resetShapeFlag(current);
@@ -4433,6 +4488,10 @@ Server rendered element contains fewer child nodes than client vdom.`
4433
4488
  return rawVNode;
4434
4489
  }
4435
4490
  let vnode = getInnerChild(rawVNode);
4491
+ if (vnode.type === Comment) {
4492
+ current = null;
4493
+ return vnode;
4494
+ }
4436
4495
  const comp = vnode.type;
4437
4496
  const name = getComponentName(
4438
4497
  isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
@@ -4479,6 +4538,7 @@ Server rendered element contains fewer child nodes than client vdom.`
4479
4538
  } else if (isString(pattern)) {
4480
4539
  return pattern.split(",").includes(name);
4481
4540
  } else if (isRegExp(pattern)) {
4541
+ pattern.lastIndex = 0;
4482
4542
  return pattern.test(name);
4483
4543
  }
4484
4544
  return false;
@@ -4562,17 +4622,19 @@ Server rendered element contains fewer child nodes than client vdom.`
4562
4622
  };
4563
4623
  const onBeforeMount = createHook("bm");
4564
4624
  const onMounted = createHook("m");
4565
- const onBeforeUpdate = createHook("bu");
4625
+ const onBeforeUpdate = createHook(
4626
+ "bu"
4627
+ );
4566
4628
  const onUpdated = createHook("u");
4567
- const onBeforeUnmount = createHook("bum");
4568
- const onUnmounted = createHook("um");
4569
- const onServerPrefetch = createHook("sp");
4570
- const onRenderTriggered = createHook(
4571
- "rtg"
4629
+ const onBeforeUnmount = createHook(
4630
+ "bum"
4572
4631
  );
4573
- const onRenderTracked = createHook(
4574
- "rtc"
4632
+ const onUnmounted = createHook("um");
4633
+ const onServerPrefetch = createHook(
4634
+ "sp"
4575
4635
  );
4636
+ const onRenderTriggered = createHook("rtg");
4637
+ const onRenderTracked = createHook("rtc");
4576
4638
  function onErrorCaptured(hook, target = currentInstance) {
4577
4639
  injectHook("ec", hook, target);
4578
4640
  }
@@ -4699,9 +4761,14 @@ If this is a native custom element, make sure to exclude it from component resol
4699
4761
  }
4700
4762
 
4701
4763
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
4702
- if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
4764
+ if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
4703
4765
  if (name !== "default") props.name = name;
4704
- return createVNode("slot", props, fallback && fallback());
4766
+ return openBlock(), createBlock(
4767
+ Fragment,
4768
+ null,
4769
+ [createVNode("slot", props, fallback && fallback())],
4770
+ 64
4771
+ );
4705
4772
  }
4706
4773
  let slot = slots[name];
4707
4774
  if (slot && slot.length > 1) {
@@ -4774,6 +4841,7 @@ If this is a native custom element, make sure to exclude it from component resol
4774
4841
  $refs: (i) => shallowReadonly(i.refs) ,
4775
4842
  $parent: (i) => getPublicInstance(i.parent),
4776
4843
  $root: (i) => getPublicInstance(i.root),
4844
+ $host: (i) => i.ce,
4777
4845
  $emit: (i) => i.emit,
4778
4846
  $options: (i) => resolveMergedOptions(i) ,
4779
4847
  $forceUpdate: (i) => i.f || (i.f = () => {
@@ -4925,29 +4993,25 @@ If this is a native custom element, make sure to exclude it from component resol
4925
4993
  return Reflect.ownKeys(target);
4926
4994
  };
4927
4995
  }
4928
- const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend(
4929
- {},
4930
- PublicInstanceProxyHandlers,
4931
- {
4932
- get(target, key) {
4933
- if (key === Symbol.unscopables) {
4934
- return;
4935
- }
4936
- return PublicInstanceProxyHandlers.get(target, key, target);
4937
- },
4938
- has(_, key) {
4939
- const has = key[0] !== "_" && !isGloballyAllowed(key);
4940
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
4941
- warn$1(
4942
- `Property ${JSON.stringify(
4943
- key
4944
- )} should not start with _ which is a reserved prefix for Vue internals.`
4945
- );
4946
- }
4947
- return has;
4996
+ const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend({}, PublicInstanceProxyHandlers, {
4997
+ get(target, key) {
4998
+ if (key === Symbol.unscopables) {
4999
+ return;
5000
+ }
5001
+ return PublicInstanceProxyHandlers.get(target, key, target);
5002
+ },
5003
+ has(_, key) {
5004
+ const has = key[0] !== "_" && !isGloballyAllowed(key);
5005
+ if (!has && PublicInstanceProxyHandlers.has(_, key)) {
5006
+ warn$1(
5007
+ `Property ${JSON.stringify(
5008
+ key
5009
+ )} should not start with _ which is a reserved prefix for Vue internals.`
5010
+ );
4948
5011
  }
5012
+ return has;
4949
5013
  }
4950
- );
5014
+ });
4951
5015
  function createDevRenderContext(instance) {
4952
5016
  const target = {};
4953
5017
  Object.defineProperty(target, `_`, {
@@ -5646,7 +5710,7 @@ If this is a native custom element, make sure to exclude it from component resol
5646
5710
  If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
5647
5711
  );
5648
5712
  }
5649
- const vnode = createVNode(rootComponent, rootProps);
5713
+ const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
5650
5714
  vnode.appContext = context;
5651
5715
  if (namespace === true) {
5652
5716
  namespace = "svg";
@@ -5748,7 +5812,7 @@ If you want to remount the same app, move your app creation logic into a factory
5748
5812
  function inject(key, defaultValue, treatDefaultAsFactory = false) {
5749
5813
  const instance = currentInstance || currentRenderingInstance;
5750
5814
  if (instance || currentApp) {
5751
- const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
5815
+ const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
5752
5816
  if (provides && key in provides) {
5753
5817
  return provides[key];
5754
5818
  } else if (arguments.length > 1) {
@@ -5953,6 +6017,9 @@ If you want to remount the same app, move your app creation logic into a factory
5953
6017
  } else {
5954
6018
  value = defaultValue;
5955
6019
  }
6020
+ if (instance.ce) {
6021
+ instance.ce._setProp(key, value);
6022
+ }
5956
6023
  }
5957
6024
  if (opt[0 /* shouldCast */]) {
5958
6025
  if (isAbsent && !hasDefault) {
@@ -6951,8 +7018,8 @@ If you want to remount the same app, move your app creation logic into a factory
6951
7018
  const componentUpdateFn = () => {
6952
7019
  if (!instance.isMounted) {
6953
7020
  let vnodeHook;
6954
- const { el, props, type } = initialVNode;
6955
- const { bm, m, parent } = instance;
7021
+ const { el, props } = initialVNode;
7022
+ const { bm, m, parent, root, type } = instance;
6956
7023
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
6957
7024
  toggleRecurse(instance, false);
6958
7025
  if (bm) {
@@ -6995,6 +7062,9 @@ If you want to remount the same app, move your app creation logic into a factory
6995
7062
  hydrateSubTree();
6996
7063
  }
6997
7064
  } else {
7065
+ if (root.ce) {
7066
+ root.ce._injectChildStyle(type);
7067
+ }
6998
7068
  {
6999
7069
  startMeasure(instance, `render`);
7000
7070
  }
@@ -7668,13 +7738,13 @@ If you want to remount the same app, move your app creation logic into a factory
7668
7738
  namespace
7669
7739
  );
7670
7740
  }
7741
+ container._vnode = vnode;
7671
7742
  if (!isFlushing) {
7672
7743
  isFlushing = true;
7673
7744
  flushPreFlushCbs();
7674
7745
  flushPostFlushCbs();
7675
7746
  isFlushing = false;
7676
7747
  }
7677
- container._vnode = vnode;
7678
7748
  };
7679
7749
  const internals = {
7680
7750
  p: patch,
@@ -7842,14 +7912,9 @@ If you want to remount the same app, move your app creation logic into a factory
7842
7912
  const _cb = cb;
7843
7913
  cb = (...args) => {
7844
7914
  _cb(...args);
7845
- unwatch();
7915
+ watchHandle();
7846
7916
  };
7847
7917
  }
7848
- if (deep !== void 0 && typeof deep === "number") {
7849
- warn$1(
7850
- `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
7851
- );
7852
- }
7853
7918
  if (!cb) {
7854
7919
  if (immediate !== void 0) {
7855
7920
  warn$1(
@@ -7875,10 +7940,12 @@ If you want to remount the same app, move your app creation logic into a factory
7875
7940
  );
7876
7941
  };
7877
7942
  const instance = currentInstance;
7878
- const reactiveGetter = (source2) => deep === true ? source2 : (
7879
- // for deep: false, only traverse root-level properties
7880
- traverse(source2, deep === false ? 1 : void 0)
7881
- );
7943
+ const reactiveGetter = (source2) => {
7944
+ if (deep) return source2;
7945
+ if (isShallow(source2) || deep === false || deep === 0)
7946
+ return traverse(source2, 1);
7947
+ return traverse(source2);
7948
+ };
7882
7949
  let getter;
7883
7950
  let forceTrigger = false;
7884
7951
  let isMultiSource = false;
@@ -7924,7 +7991,8 @@ If you want to remount the same app, move your app creation logic into a factory
7924
7991
  }
7925
7992
  if (cb && deep) {
7926
7993
  const baseGetter = getter;
7927
- getter = () => traverse(baseGetter());
7994
+ const depth = deep === true ? Infinity : deep;
7995
+ getter = () => traverse(baseGetter(), depth);
7928
7996
  }
7929
7997
  let cleanup;
7930
7998
  let onCleanup = (fn) => {
@@ -7960,7 +8028,6 @@ If you want to remount the same app, move your app creation logic into a factory
7960
8028
  const effect = new ReactiveEffect(getter);
7961
8029
  let scheduler;
7962
8030
  if (flush === "sync") {
7963
- effect.flags |= 64;
7964
8031
  scheduler = job;
7965
8032
  } else if (flush === "post") {
7966
8033
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
@@ -7971,12 +8038,15 @@ If you want to remount the same app, move your app creation logic into a factory
7971
8038
  }
7972
8039
  effect.scheduler = scheduler;
7973
8040
  const scope = getCurrentScope();
7974
- const unwatch = () => {
8041
+ const watchHandle = () => {
7975
8042
  effect.stop();
7976
8043
  if (scope) {
7977
8044
  remove(scope.effects, effect);
7978
8045
  }
7979
8046
  };
8047
+ watchHandle.pause = effect.pause.bind(effect);
8048
+ watchHandle.resume = effect.resume.bind(effect);
8049
+ watchHandle.stop = watchHandle;
7980
8050
  {
7981
8051
  effect.onTrack = onTrack;
7982
8052
  effect.onTrigger = onTrigger;
@@ -7995,7 +8065,7 @@ If you want to remount the same app, move your app creation logic into a factory
7995
8065
  } else {
7996
8066
  effect.run();
7997
8067
  }
7998
- return unwatch;
8068
+ return watchHandle;
7999
8069
  }
8000
8070
  function instanceWatch(source, value, options) {
8001
8071
  const publicThis = this.proxy;
@@ -8085,7 +8155,8 @@ If you want to remount the same app, move your app creation logic into a factory
8085
8155
  return options.get ? options.get(localValue) : localValue;
8086
8156
  },
8087
8157
  set(value) {
8088
- if (!hasChanged(value, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
8158
+ const emittedValue = options.set ? options.set(value) : value;
8159
+ if (!hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
8089
8160
  return;
8090
8161
  }
8091
8162
  const rawProps = i.vnode.props;
@@ -8094,7 +8165,6 @@ If you want to remount the same app, move your app creation logic into a factory
8094
8165
  localValue = value;
8095
8166
  trigger();
8096
8167
  }
8097
- const emittedValue = options.set ? options.set(value) : value;
8098
8168
  i.emit(`update:${name}`, emittedValue);
8099
8169
  if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) {
8100
8170
  trigger();
@@ -8132,9 +8202,9 @@ If you want to remount the same app, move your app creation logic into a factory
8132
8202
  } = instance;
8133
8203
  if (emitsOptions) {
8134
8204
  if (!(event in emitsOptions) && true) {
8135
- if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
8205
+ if (!propsOptions || !(toHandlerKey(camelize(event)) in propsOptions)) {
8136
8206
  warn$1(
8137
- `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
8207
+ `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(camelize(event))}" prop.`
8138
8208
  );
8139
8209
  }
8140
8210
  } else {
@@ -9944,11 +10014,16 @@ Component that was made reactive: `,
9944
10014
  const r = shallowRef(null);
9945
10015
  if (i) {
9946
10016
  const refs = i.refs === EMPTY_OBJ ? i.refs = {} : i.refs;
9947
- Object.defineProperty(refs, key, {
9948
- enumerable: true,
9949
- get: () => r.value,
9950
- set: (val) => r.value = val
9951
- });
10017
+ let desc;
10018
+ if ((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable) {
10019
+ warn$1(`useTemplateRef('${key}') already exists.`);
10020
+ } else {
10021
+ Object.defineProperty(refs, key, {
10022
+ enumerable: true,
10023
+ get: () => r.value,
10024
+ set: (val) => r.value = val
10025
+ });
10026
+ }
9952
10027
  } else {
9953
10028
  warn$1(
9954
10029
  `useTemplateRef() is called when there is no active component instance to be associated with.`
@@ -10182,7 +10257,7 @@ Component that was made reactive: `,
10182
10257
  return true;
10183
10258
  }
10184
10259
 
10185
- const version = "3.5.0-alpha.5";
10260
+ const version = "3.5.0-beta.2";
10186
10261
  const warn = warn$1 ;
10187
10262
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10188
10263
  const devtools = devtools$1 ;
@@ -10192,6 +10267,18 @@ Component that was made reactive: `,
10192
10267
  const compatUtils = null;
10193
10268
  const DeprecationTypes = null;
10194
10269
 
10270
+ let policy = void 0;
10271
+ const tt = typeof window !== "undefined" && window.trustedTypes;
10272
+ if (tt) {
10273
+ try {
10274
+ policy = /* @__PURE__ */ tt.createPolicy("vue", {
10275
+ createHTML: (val) => val
10276
+ });
10277
+ } catch (e) {
10278
+ warn(`Error creating trusted types policy: ${e}`);
10279
+ }
10280
+ }
10281
+ const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
10195
10282
  const svgNS = "http://www.w3.org/2000/svg";
10196
10283
  const mathmlNS = "http://www.w3.org/1998/Math/MathML";
10197
10284
  const doc = typeof document !== "undefined" ? document : null;
@@ -10239,7 +10326,9 @@ Component that was made reactive: `,
10239
10326
  if (start === end || !(start = start.nextSibling)) break;
10240
10327
  }
10241
10328
  } else {
10242
- templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
10329
+ templateContainer.innerHTML = unsafeToTrustedHTML(
10330
+ namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content
10331
+ );
10243
10332
  const template = templateContainer.content;
10244
10333
  if (namespace === "svg" || namespace === "mathml") {
10245
10334
  const wrapper = template.firstChild;
@@ -10602,11 +10691,17 @@ Component that was made reactive: `,
10602
10691
  }
10603
10692
  const setVars = () => {
10604
10693
  const vars = getter(instance.proxy);
10605
- setVarsOnVNode(instance.subTree, vars);
10694
+ if (instance.ce) {
10695
+ setVarsOnNode(instance.ce, vars);
10696
+ } else {
10697
+ setVarsOnVNode(instance.subTree, vars);
10698
+ }
10606
10699
  updateTeleports(vars);
10607
10700
  };
10608
- onMounted(() => {
10701
+ onBeforeMount(() => {
10609
10702
  watchPostEffect(setVars);
10703
+ });
10704
+ onMounted(() => {
10610
10705
  const ob = new MutationObserver(setVars);
10611
10706
  ob.observe(instance.subTree.el.parentNode, { childList: true });
10612
10707
  onUnmounted(() => ob.disconnect());
@@ -10959,16 +11054,24 @@ Expected function or array of functions, received type ${typeof value}.`
10959
11054
  if (isNativeOn(key) && isString(value)) {
10960
11055
  return false;
10961
11056
  }
10962
- return key in el;
11057
+ if (key in el) {
11058
+ return true;
11059
+ }
11060
+ if (el._isVueCE && (/[A-Z]/.test(key) || !isString(value))) {
11061
+ return true;
11062
+ }
11063
+ return false;
10963
11064
  }
10964
11065
 
11066
+ const REMOVAL = {};
10965
11067
  /*! #__NO_SIDE_EFFECTS__ */
10966
11068
  // @__NO_SIDE_EFFECTS__
10967
- function defineCustomElement(options, extraOptions, hydrate2) {
11069
+ function defineCustomElement(options, extraOptions, _createApp) {
10968
11070
  const Comp = defineComponent(options, extraOptions);
11071
+ if (isPlainObject(Comp)) extend(Comp, extraOptions);
10969
11072
  class VueCustomElement extends VueElement {
10970
11073
  constructor(initialProps) {
10971
- super(Comp, initialProps, hydrate2);
11074
+ super(Comp, initialProps, _createApp);
10972
11075
  }
10973
11076
  }
10974
11077
  VueCustomElement.def = Comp;
@@ -10976,47 +11079,87 @@ Expected function or array of functions, received type ${typeof value}.`
10976
11079
  }
10977
11080
  /*! #__NO_SIDE_EFFECTS__ */
10978
11081
  const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
10979
- return /* @__PURE__ */ defineCustomElement(options, extraOptions, hydrate);
11082
+ return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
10980
11083
  };
10981
11084
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
10982
11085
  };
10983
11086
  class VueElement extends BaseClass {
10984
- constructor(_def, _props = {}, hydrate2) {
11087
+ constructor(_def, _props = {}, _createApp = createApp) {
10985
11088
  super();
10986
11089
  this._def = _def;
10987
11090
  this._props = _props;
11091
+ this._createApp = _createApp;
11092
+ this._isVueCE = true;
10988
11093
  /**
10989
11094
  * @internal
10990
11095
  */
10991
11096
  this._instance = null;
11097
+ /**
11098
+ * @internal
11099
+ */
11100
+ this._app = null;
11101
+ /**
11102
+ * @internal
11103
+ */
11104
+ this._nonce = this._def.nonce;
10992
11105
  this._connected = false;
10993
11106
  this._resolved = false;
10994
11107
  this._numberProps = null;
11108
+ this._styleChildren = /* @__PURE__ */ new WeakSet();
10995
11109
  this._ob = null;
10996
- if (this.shadowRoot && hydrate2) {
10997
- hydrate2(this._createVNode(), this.shadowRoot);
11110
+ if (this.shadowRoot && _createApp !== createApp) {
11111
+ this._root = this.shadowRoot;
10998
11112
  } else {
10999
11113
  if (this.shadowRoot) {
11000
11114
  warn(
11001
11115
  `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
11002
11116
  );
11003
11117
  }
11004
- this.attachShadow({ mode: "open" });
11005
- if (!this._def.__asyncLoader) {
11006
- this._resolveProps(this._def);
11118
+ if (_def.shadowRoot !== false) {
11119
+ this.attachShadow({ mode: "open" });
11120
+ this._root = this.shadowRoot;
11121
+ } else {
11122
+ this._root = this;
11007
11123
  }
11008
11124
  }
11125
+ if (!this._def.__asyncLoader) {
11126
+ this._resolveProps(this._def);
11127
+ }
11009
11128
  }
11010
11129
  connectedCallback() {
11130
+ if (!this.shadowRoot) {
11131
+ this._parseSlots();
11132
+ }
11011
11133
  this._connected = true;
11134
+ let parent = this;
11135
+ while (parent = parent && (parent.parentNode || parent.host)) {
11136
+ if (parent instanceof VueElement) {
11137
+ this._parent = parent;
11138
+ break;
11139
+ }
11140
+ }
11012
11141
  if (!this._instance) {
11013
11142
  if (this._resolved) {
11143
+ this._setParent();
11014
11144
  this._update();
11015
11145
  } else {
11016
- this._resolveDef();
11146
+ if (parent && parent._pendingResolve) {
11147
+ this._pendingResolve = parent._pendingResolve.then(() => {
11148
+ this._pendingResolve = void 0;
11149
+ this._resolveDef();
11150
+ });
11151
+ } else {
11152
+ this._resolveDef();
11153
+ }
11017
11154
  }
11018
11155
  }
11019
11156
  }
11157
+ _setParent(parent = this._parent) {
11158
+ if (parent) {
11159
+ this._instance.parent = parent._instance;
11160
+ this._instance.provides = parent._instance.provides;
11161
+ }
11162
+ }
11020
11163
  disconnectedCallback() {
11021
11164
  this._connected = false;
11022
11165
  nextTick(() => {
@@ -11025,8 +11168,9 @@ Expected function or array of functions, received type ${typeof value}.`
11025
11168
  this._ob.disconnect();
11026
11169
  this._ob = null;
11027
11170
  }
11028
- render(null, this.shadowRoot);
11029
- this._instance = null;
11171
+ this._app && this._app.unmount();
11172
+ this._instance.ce = void 0;
11173
+ this._app = this._instance = null;
11030
11174
  }
11031
11175
  });
11032
11176
  }
@@ -11034,7 +11178,9 @@ Expected function or array of functions, received type ${typeof value}.`
11034
11178
  * resolve inner component definition (handle possible async component)
11035
11179
  */
11036
11180
  _resolveDef() {
11037
- this._resolved = true;
11181
+ if (this._pendingResolve) {
11182
+ return;
11183
+ }
11038
11184
  for (let i = 0; i < this.attributes.length; i++) {
11039
11185
  this._setAttr(this.attributes[i].name);
11040
11186
  }
@@ -11045,6 +11191,8 @@ Expected function or array of functions, received type ${typeof value}.`
11045
11191
  });
11046
11192
  this._ob.observe(this, { attributes: true });
11047
11193
  const resolve = (def, isAsync = false) => {
11194
+ this._resolved = true;
11195
+ this._pendingResolve = void 0;
11048
11196
  const { props, styles } = def;
11049
11197
  let numberProps;
11050
11198
  if (props && !isArray(props)) {
@@ -11062,22 +11210,53 @@ Expected function or array of functions, received type ${typeof value}.`
11062
11210
  if (isAsync) {
11063
11211
  this._resolveProps(def);
11064
11212
  }
11065
- this._applyStyles(styles);
11066
- this._update();
11213
+ if (this.shadowRoot) {
11214
+ this._applyStyles(styles);
11215
+ } else if (styles) {
11216
+ warn(
11217
+ "Custom element style injection is not supported when using shadowRoot: false"
11218
+ );
11219
+ }
11220
+ this._mount(def);
11067
11221
  };
11068
11222
  const asyncDef = this._def.__asyncLoader;
11069
11223
  if (asyncDef) {
11070
- asyncDef().then((def) => resolve(def, true));
11224
+ this._pendingResolve = asyncDef().then(
11225
+ (def) => resolve(this._def = def, true)
11226
+ );
11071
11227
  } else {
11072
11228
  resolve(this._def);
11073
11229
  }
11074
11230
  }
11231
+ _mount(def) {
11232
+ if (!def.name) {
11233
+ def.name = "VueElement";
11234
+ }
11235
+ this._app = this._createApp(def);
11236
+ if (def.configureApp) {
11237
+ def.configureApp(this._app);
11238
+ }
11239
+ this._app._ceVNode = this._createVNode();
11240
+ this._app.mount(this._root);
11241
+ const exposed = this._instance && this._instance.exposed;
11242
+ if (!exposed) return;
11243
+ for (const key in exposed) {
11244
+ if (!hasOwn(this, key)) {
11245
+ Object.defineProperty(this, key, {
11246
+ // unwrap ref to be consistent with public instance behavior
11247
+ get: () => unref(exposed[key])
11248
+ });
11249
+ } else {
11250
+ warn(`Exposed property "${key}" already exists on custom element.`);
11251
+ }
11252
+ }
11253
+ }
11075
11254
  _resolveProps(def) {
11076
11255
  const { props } = def;
11077
11256
  const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
11078
11257
  for (const key of Object.keys(this)) {
11079
11258
  if (key[0] !== "_" && declaredPropKeys.includes(key)) {
11080
- this._setProp(key, this[key], true, false);
11259
+ this._setProp(key, this[key]);
11081
11260
  }
11082
11261
  }
11083
11262
  for (const key of declaredPropKeys.map(camelize)) {
@@ -11086,18 +11265,20 @@ Expected function or array of functions, received type ${typeof value}.`
11086
11265
  return this._getProp(key);
11087
11266
  },
11088
11267
  set(val) {
11089
- this._setProp(key, val);
11268
+ this._setProp(key, val, true, true);
11090
11269
  }
11091
11270
  });
11092
11271
  }
11093
11272
  }
11094
11273
  _setAttr(key) {
11095
- let value = this.hasAttribute(key) ? this.getAttribute(key) : void 0;
11274
+ if (key.startsWith("data-v-")) return;
11275
+ const has = this.hasAttribute(key);
11276
+ let value = has ? this.getAttribute(key) : REMOVAL;
11096
11277
  const camelKey = camelize(key);
11097
- if (this._numberProps && this._numberProps[camelKey]) {
11278
+ if (has && this._numberProps && this._numberProps[camelKey]) {
11098
11279
  value = toNumber(value);
11099
11280
  }
11100
- this._setProp(camelKey, value, false);
11281
+ this._setProp(camelKey, value, false, true);
11101
11282
  }
11102
11283
  /**
11103
11284
  * @internal
@@ -11108,9 +11289,13 @@ Expected function or array of functions, received type ${typeof value}.`
11108
11289
  /**
11109
11290
  * @internal
11110
11291
  */
11111
- _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
11292
+ _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
11112
11293
  if (val !== this._props[key]) {
11113
- this._props[key] = val;
11294
+ if (val === REMOVAL) {
11295
+ delete this._props[key];
11296
+ } else {
11297
+ this._props[key] = val;
11298
+ }
11114
11299
  if (shouldUpdate && this._instance) {
11115
11300
  this._update();
11116
11301
  }
@@ -11126,18 +11311,23 @@ Expected function or array of functions, received type ${typeof value}.`
11126
11311
  }
11127
11312
  }
11128
11313
  _update() {
11129
- render(this._createVNode(), this.shadowRoot);
11314
+ render(this._createVNode(), this._root);
11130
11315
  }
11131
11316
  _createVNode() {
11132
- const vnode = createVNode(this._def, extend({}, this._props));
11317
+ const baseProps = {};
11318
+ if (!this.shadowRoot) {
11319
+ baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
11320
+ }
11321
+ const vnode = createVNode(this._def, extend(baseProps, this._props));
11133
11322
  if (!this._instance) {
11134
11323
  vnode.ce = (instance) => {
11135
11324
  this._instance = instance;
11325
+ instance.ce = this;
11136
11326
  instance.isCE = true;
11137
11327
  {
11138
11328
  instance.ceReload = (newStyles) => {
11139
11329
  if (this._styles) {
11140
- this._styles.forEach((s) => this.shadowRoot.removeChild(s));
11330
+ this._styles.forEach((s) => this._root.removeChild(s));
11141
11331
  this._styles.length = 0;
11142
11332
  }
11143
11333
  this._applyStyles(newStyles);
@@ -11147,9 +11337,10 @@ Expected function or array of functions, received type ${typeof value}.`
11147
11337
  }
11148
11338
  const dispatch = (event, args) => {
11149
11339
  this.dispatchEvent(
11150
- new CustomEvent(event, {
11151
- detail: args
11152
- })
11340
+ new CustomEvent(
11341
+ event,
11342
+ isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
11343
+ )
11153
11344
  );
11154
11345
  };
11155
11346
  instance.emit = (event, ...args) => {
@@ -11158,30 +11349,126 @@ Expected function or array of functions, received type ${typeof value}.`
11158
11349
  dispatch(hyphenate(event), args);
11159
11350
  }
11160
11351
  };
11161
- let parent = this;
11162
- while (parent = parent && (parent.parentNode || parent.host)) {
11163
- if (parent instanceof VueElement) {
11164
- instance.parent = parent._instance;
11165
- instance.provides = parent._instance.provides;
11166
- break;
11167
- }
11168
- }
11352
+ this._setParent();
11169
11353
  };
11170
11354
  }
11171
11355
  return vnode;
11172
11356
  }
11173
- _applyStyles(styles) {
11174
- if (styles) {
11175
- styles.forEach((css) => {
11176
- const s = document.createElement("style");
11177
- s.textContent = css;
11178
- this.shadowRoot.appendChild(s);
11179
- {
11357
+ _applyStyles(styles, owner) {
11358
+ if (!styles) return;
11359
+ if (owner) {
11360
+ if (owner === this._def || this._styleChildren.has(owner)) {
11361
+ return;
11362
+ }
11363
+ this._styleChildren.add(owner);
11364
+ }
11365
+ const nonce = this._nonce;
11366
+ for (let i = styles.length - 1; i >= 0; i--) {
11367
+ const s = document.createElement("style");
11368
+ if (nonce) s.setAttribute("nonce", nonce);
11369
+ s.textContent = styles[i];
11370
+ this.shadowRoot.prepend(s);
11371
+ {
11372
+ if (owner) {
11373
+ if (owner.__hmrId) {
11374
+ if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
11375
+ let entry = this._childStyles.get(owner.__hmrId);
11376
+ if (!entry) {
11377
+ this._childStyles.set(owner.__hmrId, entry = []);
11378
+ }
11379
+ entry.push(s);
11380
+ }
11381
+ } else {
11180
11382
  (this._styles || (this._styles = [])).push(s);
11181
11383
  }
11182
- });
11384
+ }
11183
11385
  }
11184
11386
  }
11387
+ /**
11388
+ * Only called when shaddowRoot is false
11389
+ */
11390
+ _parseSlots() {
11391
+ const slots = this._slots = {};
11392
+ let n;
11393
+ while (n = this.firstChild) {
11394
+ const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
11395
+ (slots[slotName] || (slots[slotName] = [])).push(n);
11396
+ this.removeChild(n);
11397
+ }
11398
+ }
11399
+ /**
11400
+ * Only called when shaddowRoot is false
11401
+ */
11402
+ _renderSlots() {
11403
+ const outlets = this.querySelectorAll("slot");
11404
+ const scopeId = this._instance.type.__scopeId;
11405
+ for (let i = 0; i < outlets.length; i++) {
11406
+ const o = outlets[i];
11407
+ const slotName = o.getAttribute("name") || "default";
11408
+ const content = this._slots[slotName];
11409
+ const parent = o.parentNode;
11410
+ if (content) {
11411
+ for (const n of content) {
11412
+ if (scopeId && n.nodeType === 1) {
11413
+ const id = scopeId + "-s";
11414
+ const walker = document.createTreeWalker(n, 1);
11415
+ n.setAttribute(id, "");
11416
+ let child;
11417
+ while (child = walker.nextNode()) {
11418
+ child.setAttribute(id, "");
11419
+ }
11420
+ }
11421
+ parent.insertBefore(n, o);
11422
+ }
11423
+ } else {
11424
+ while (o.firstChild) parent.insertBefore(o.firstChild, o);
11425
+ }
11426
+ parent.removeChild(o);
11427
+ }
11428
+ }
11429
+ /**
11430
+ * @internal
11431
+ */
11432
+ _injectChildStyle(comp) {
11433
+ this._applyStyles(comp.styles, comp);
11434
+ }
11435
+ /**
11436
+ * @internal
11437
+ */
11438
+ _removeChildStyle(comp) {
11439
+ {
11440
+ this._styleChildren.delete(comp);
11441
+ if (this._childStyles && comp.__hmrId) {
11442
+ const oldStyles = this._childStyles.get(comp.__hmrId);
11443
+ if (oldStyles) {
11444
+ oldStyles.forEach((s) => this._root.removeChild(s));
11445
+ oldStyles.length = 0;
11446
+ }
11447
+ }
11448
+ }
11449
+ }
11450
+ }
11451
+ function useHost(caller) {
11452
+ const instance = getCurrentInstance();
11453
+ const el = instance && instance.ce;
11454
+ if (el) {
11455
+ return el;
11456
+ } else {
11457
+ if (!instance) {
11458
+ warn(
11459
+ `${caller || "useHost"} called without an active component instance.`
11460
+ );
11461
+ } else {
11462
+ warn(
11463
+ `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
11464
+ );
11465
+ }
11466
+ }
11467
+ return null;
11468
+ }
11469
+ function useShadowRoot() {
11470
+ const el = useHost("useShadowRoot") ;
11471
+ return el && el.shadowRoot;
11185
11472
  }
11186
11473
 
11187
11474
  function useCssModule(name = "$style") {
@@ -11650,7 +11937,9 @@ Expected function or array of functions, received type ${typeof value}.`
11650
11937
  if (!isFunction(component) && !component.render && !component.template) {
11651
11938
  component.template = container.innerHTML;
11652
11939
  }
11653
- container.innerHTML = "";
11940
+ if (container.nodeType === 1) {
11941
+ container.textContent = "";
11942
+ }
11654
11943
  const proxy = mount(container, false, resolveRootNamespace(container));
11655
11944
  if (container instanceof Element) {
11656
11945
  container.removeAttribute("v-cloak");
@@ -11875,9 +12164,11 @@ Expected function or array of functions, received type ${typeof value}.`
11875
12164
  exports.useAttrs = useAttrs;
11876
12165
  exports.useCssModule = useCssModule;
11877
12166
  exports.useCssVars = useCssVars;
12167
+ exports.useHost = useHost;
11878
12168
  exports.useId = useId;
11879
12169
  exports.useModel = useModel;
11880
12170
  exports.useSSRContext = useSSRContext;
12171
+ exports.useShadowRoot = useShadowRoot;
11881
12172
  exports.useSlots = useSlots;
11882
12173
  exports.useTemplateRef = useTemplateRef;
11883
12174
  exports.useTransitionState = useTransitionState;