@vue/compat 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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.0-alpha.5
2
+ * @vue/compat v3.5.0-beta.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -68,9 +68,11 @@ const cacheStringFunction = (fn) => {
68
68
  };
69
69
  };
70
70
  const camelizeRE = /-(\w)/g;
71
- const camelize = cacheStringFunction((str) => {
72
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
73
- });
71
+ const camelize = cacheStringFunction(
72
+ (str) => {
73
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
74
+ }
75
+ );
74
76
  const hyphenateRE = /\B([A-Z])/g;
75
77
  const hyphenate = cacheStringFunction(
76
78
  (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
@@ -78,10 +80,12 @@ const hyphenate = cacheStringFunction(
78
80
  const capitalize = cacheStringFunction((str) => {
79
81
  return str.charAt(0).toUpperCase() + str.slice(1);
80
82
  });
81
- const toHandlerKey = cacheStringFunction((str) => {
82
- const s = str ? `on${capitalize(str)}` : ``;
83
- return s;
84
- });
83
+ const toHandlerKey = cacheStringFunction(
84
+ (str) => {
85
+ const s = str ? `on${capitalize(str)}` : ``;
86
+ return s;
87
+ }
88
+ );
85
89
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
86
90
  const invokeArrayFns = (fns, ...arg) => {
87
91
  for (let i = 0; i < fns.length; i++) {
@@ -437,6 +441,7 @@ class EffectScope {
437
441
  * @internal
438
442
  */
439
443
  this.cleanups = [];
444
+ this._isPaused = false;
440
445
  this.parent = activeEffectScope;
441
446
  if (!detached && activeEffectScope) {
442
447
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
@@ -447,6 +452,37 @@ class EffectScope {
447
452
  get active() {
448
453
  return this._active;
449
454
  }
455
+ pause() {
456
+ if (this._active) {
457
+ this._isPaused = true;
458
+ if (this.scopes) {
459
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
460
+ this.scopes[i].pause();
461
+ }
462
+ }
463
+ for (let i = 0, l = this.effects.length; i < l; i++) {
464
+ this.effects[i].pause();
465
+ }
466
+ }
467
+ }
468
+ /**
469
+ * Resumes the effect scope, including all child scopes and effects.
470
+ */
471
+ resume() {
472
+ if (this._active) {
473
+ if (this._isPaused) {
474
+ this._isPaused = false;
475
+ if (this.scopes) {
476
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
477
+ this.scopes[i].resume();
478
+ }
479
+ }
480
+ for (let i = 0, l = this.effects.length; i < l; i++) {
481
+ this.effects[i].resume();
482
+ }
483
+ }
484
+ }
485
+ }
450
486
  run(fn) {
451
487
  if (this._active) {
452
488
  const currentEffectScope = activeEffectScope;
@@ -517,6 +553,7 @@ function onScopeDispose(fn, failSilently = false) {
517
553
  }
518
554
 
519
555
  let activeSub;
556
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
520
557
  class ReactiveEffect {
521
558
  constructor(fn) {
522
559
  this.fn = fn;
@@ -545,6 +582,18 @@ class ReactiveEffect {
545
582
  activeEffectScope.effects.push(this);
546
583
  }
547
584
  }
585
+ pause() {
586
+ this.flags |= 64;
587
+ }
588
+ resume() {
589
+ if (this.flags & 64) {
590
+ this.flags &= ~64;
591
+ if (pausedQueueEffects.has(this)) {
592
+ pausedQueueEffects.delete(this);
593
+ this.trigger();
594
+ }
595
+ }
596
+ }
548
597
  /**
549
598
  * @internal
550
599
  */
@@ -552,9 +601,6 @@ class ReactiveEffect {
552
601
  if (this.flags & 2 && !(this.flags & 32)) {
553
602
  return;
554
603
  }
555
- if (this.flags & 64) {
556
- return this.trigger();
557
- }
558
604
  if (!(this.flags & 8)) {
559
605
  this.flags |= 8;
560
606
  this.nextEffect = batchedEffect;
@@ -598,7 +644,9 @@ class ReactiveEffect {
598
644
  }
599
645
  }
600
646
  trigger() {
601
- if (this.scheduler) {
647
+ if (this.flags & 64) {
648
+ pausedQueueEffects.add(this);
649
+ } else if (this.scheduler) {
602
650
  this.scheduler();
603
651
  } else {
604
652
  this.runIfDirty();
@@ -626,6 +674,7 @@ function endBatch() {
626
674
  batchDepth--;
627
675
  return;
628
676
  }
677
+ batchDepth--;
629
678
  let error;
630
679
  while (batchedEffect) {
631
680
  let e = batchedEffect;
@@ -644,7 +693,6 @@ function endBatch() {
644
693
  e = next;
645
694
  }
646
695
  }
647
- batchDepth--;
648
696
  if (error) throw error;
649
697
  }
650
698
  function prepareDeps(sub) {
@@ -918,9 +966,15 @@ function addSub(link) {
918
966
  link.dep.subs = link;
919
967
  }
920
968
  const targetMap = /* @__PURE__ */ new WeakMap();
921
- const ITERATE_KEY = Symbol("Object iterate" );
922
- const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
923
- const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
969
+ const ITERATE_KEY = Symbol(
970
+ "Object iterate"
971
+ );
972
+ const MAP_KEY_ITERATE_KEY = Symbol(
973
+ "Map keys iterate"
974
+ );
975
+ const ARRAY_ITERATE_KEY = Symbol(
976
+ "Array iterate"
977
+ );
924
978
  function track(target, type, key) {
925
979
  if (shouldTrack && activeSub) {
926
980
  let depsMap = targetMap.get(target);
@@ -1041,26 +1095,26 @@ const arrayInstrumentations = {
1041
1095
  });
1042
1096
  },
1043
1097
  every(fn, thisArg) {
1044
- return apply(this, "every", fn, thisArg);
1098
+ return apply(this, "every", fn, thisArg, void 0, arguments);
1045
1099
  },
1046
1100
  filter(fn, thisArg) {
1047
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
1101
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
1048
1102
  },
1049
1103
  find(fn, thisArg) {
1050
- return apply(this, "find", fn, thisArg, toReactive);
1104
+ return apply(this, "find", fn, thisArg, toReactive, arguments);
1051
1105
  },
1052
1106
  findIndex(fn, thisArg) {
1053
- return apply(this, "findIndex", fn, thisArg);
1107
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
1054
1108
  },
1055
1109
  findLast(fn, thisArg) {
1056
- return apply(this, "findLast", fn, thisArg, toReactive);
1110
+ return apply(this, "findLast", fn, thisArg, toReactive, arguments);
1057
1111
  },
1058
1112
  findLastIndex(fn, thisArg) {
1059
- return apply(this, "findLastIndex", fn, thisArg);
1113
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
1060
1114
  },
1061
1115
  // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
1062
1116
  forEach(fn, thisArg) {
1063
- return apply(this, "forEach", fn, thisArg);
1117
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
1064
1118
  },
1065
1119
  includes(...args) {
1066
1120
  return searchProxy(this, "includes", args);
@@ -1076,7 +1130,7 @@ const arrayInstrumentations = {
1076
1130
  return searchProxy(this, "lastIndexOf", args);
1077
1131
  },
1078
1132
  map(fn, thisArg) {
1079
- return apply(this, "map", fn, thisArg);
1133
+ return apply(this, "map", fn, thisArg, void 0, arguments);
1080
1134
  },
1081
1135
  pop() {
1082
1136
  return noTracking(this, "pop");
@@ -1095,7 +1149,7 @@ const arrayInstrumentations = {
1095
1149
  },
1096
1150
  // slice could use ARRAY_ITERATE but also seems to beg for range tracking
1097
1151
  some(fn, thisArg) {
1098
- return apply(this, "some", fn, thisArg);
1152
+ return apply(this, "some", fn, thisArg, void 0, arguments);
1099
1153
  },
1100
1154
  splice(...args) {
1101
1155
  return noTracking(this, "splice", args);
@@ -1131,8 +1185,13 @@ function iterator(self, method, wrapValue) {
1131
1185
  }
1132
1186
  return iter;
1133
1187
  }
1134
- function apply(self, method, fn, thisArg, wrappedRetFn) {
1188
+ const arrayProto = Array.prototype;
1189
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1135
1190
  const arr = shallowReadArray(self);
1191
+ let methodFn;
1192
+ if ((methodFn = arr[method]) !== arrayProto[method]) {
1193
+ return methodFn.apply(arr, args);
1194
+ }
1136
1195
  let needsWrap = false;
1137
1196
  let wrappedFn = fn;
1138
1197
  if (arr !== self) {
@@ -1147,7 +1206,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn) {
1147
1206
  };
1148
1207
  }
1149
1208
  }
1150
- const result = arr[method](wrappedFn, thisArg);
1209
+ const result = methodFn.call(arr, wrappedFn, thisArg);
1151
1210
  return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
1152
1211
  }
1153
1212
  function reduce(self, method, fn, args) {
@@ -1210,7 +1269,7 @@ class BaseReactiveHandler {
1210
1269
  return isShallow2;
1211
1270
  } else if (key === "__v_raw") {
1212
1271
  if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
1213
- // this means the reciever is a user proxy of the reactive proxy
1272
+ // this means the receiver is a user proxy of the reactive proxy
1214
1273
  Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
1215
1274
  return target;
1216
1275
  }
@@ -1334,9 +1393,7 @@ class ReadonlyReactiveHandler extends BaseReactiveHandler {
1334
1393
  }
1335
1394
  const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
1336
1395
  const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
1337
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
1338
- true
1339
- );
1396
+ const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
1340
1397
  const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
1341
1398
 
1342
1399
  const toShallow = (value) => value;
@@ -1831,13 +1888,14 @@ function proxyRefs(objectWithRefs) {
1831
1888
  class CustomRefImpl {
1832
1889
  constructor(factory) {
1833
1890
  this["__v_isRef"] = true;
1891
+ this._value = void 0;
1834
1892
  const dep = this.dep = new Dep();
1835
1893
  const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1836
1894
  this._get = get;
1837
1895
  this._set = set;
1838
1896
  }
1839
1897
  get value() {
1840
- return this._get();
1898
+ return this._value = this._get();
1841
1899
  }
1842
1900
  set value(newVal) {
1843
1901
  this._set(newVal);
@@ -1862,10 +1920,11 @@ class ObjectRefImpl {
1862
1920
  this._key = _key;
1863
1921
  this._defaultValue = _defaultValue;
1864
1922
  this["__v_isRef"] = true;
1923
+ this._value = void 0;
1865
1924
  }
1866
1925
  get value() {
1867
1926
  const val = this._object[this._key];
1868
- return val === void 0 ? this._defaultValue : val;
1927
+ return this._value = val === void 0 ? this._defaultValue : val;
1869
1928
  }
1870
1929
  set value(newVal) {
1871
1930
  this._object[this._key] = newVal;
@@ -1879,9 +1938,10 @@ class GetterRefImpl {
1879
1938
  this._getter = _getter;
1880
1939
  this["__v_isRef"] = true;
1881
1940
  this["__v_isReadonly"] = true;
1941
+ this._value = void 0;
1882
1942
  }
1883
1943
  get value() {
1884
- return this._getter();
1944
+ return this._value = this._getter();
1885
1945
  }
1886
1946
  }
1887
1947
  function toRef(source, key, defaultValue) {
@@ -1915,7 +1975,8 @@ class ComputedRefImpl {
1915
1975
  /**
1916
1976
  * @internal
1917
1977
  */
1918
- this["__v_isRef"] = true;
1978
+ this.__v_isRef = true;
1979
+ // TODO isolatedDeclarations "__v_isReadonly"
1919
1980
  // A computed is also a subscriber that tracks other deps
1920
1981
  /**
1921
1982
  * @internal
@@ -2540,6 +2601,9 @@ function reload(id, newComp) {
2540
2601
  "[HMR] Root or manually mounted instance modified. Full reload required."
2541
2602
  );
2542
2603
  }
2604
+ if (instance.root.ce && instance !== instance.root) {
2605
+ instance.root.ce._removeChildStyle(oldComp);
2606
+ }
2543
2607
  }
2544
2608
  queuePostFlushCb(() => {
2545
2609
  hmrDirtyComponents.clear();
@@ -2619,9 +2683,7 @@ function devtoolsInitApp(app, version) {
2619
2683
  function devtoolsUnmountApp(app) {
2620
2684
  emit$2("app:unmount" /* APP_UNMOUNT */, app);
2621
2685
  }
2622
- const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
2623
- "component:added" /* COMPONENT_ADDED */
2624
- );
2686
+ const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
2625
2687
  const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
2626
2688
  const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
2627
2689
  "component:removed" /* COMPONENT_REMOVED */
@@ -2645,12 +2707,8 @@ function createDevtoolsComponentHook(hook) {
2645
2707
  );
2646
2708
  };
2647
2709
  }
2648
- const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
2649
- "perf:start" /* PERFORMANCE_START */
2650
- );
2651
- const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
2652
- "perf:end" /* PERFORMANCE_END */
2653
- );
2710
+ const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
2711
+ const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
2654
2712
  function createDevtoolsPerformanceHook(hook) {
2655
2713
  return (component, type, time) => {
2656
2714
  emit$2(hook, component.appContext.app, component.uid, component, type, time);
@@ -4084,6 +4142,7 @@ const logMismatchError = () => {
4084
4142
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
4085
4143
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
4086
4144
  const getContainerType = (container) => {
4145
+ if (container.nodeType !== 1) return void 0;
4087
4146
  if (isSVGContainer(container)) return "svg";
4088
4147
  if (isMathMLContainer(container)) return "mathml";
4089
4148
  return void 0;
@@ -4359,6 +4418,7 @@ Server rendered element contains more child nodes than client vdom.`
4359
4418
  }
4360
4419
  if (props) {
4361
4420
  {
4421
+ const isCustomElement = el.tagName.includes("-");
4362
4422
  for (const key in props) {
4363
4423
  if (// #11189 skip if this node has directives that have created hooks
4364
4424
  // as it could have mutated the DOM in any possible way
@@ -4366,7 +4426,7 @@ Server rendered element contains more child nodes than client vdom.`
4366
4426
  logMismatchError();
4367
4427
  }
4368
4428
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
4369
- key[0] === ".") {
4429
+ key[0] === "." || isCustomElement) {
4370
4430
  patchProp(el, key, null, props[key], void 0, parentComponent);
4371
4431
  }
4372
4432
  }
@@ -4691,24 +4751,19 @@ function isMismatchAllowed(el, allowedType) {
4691
4751
  }
4692
4752
  }
4693
4753
 
4694
- const hydrateOnIdle = () => (hydrate) => {
4695
- const id = requestIdleCallback(hydrate);
4754
+ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
4755
+ const id = requestIdleCallback(hydrate, { timeout });
4696
4756
  return () => cancelIdleCallback(id);
4697
4757
  };
4698
- const hydrateOnVisible = (margin = 0) => (hydrate, forEach) => {
4699
- const ob = new IntersectionObserver(
4700
- (entries) => {
4701
- for (const e of entries) {
4702
- if (!e.isIntersecting) continue;
4703
- ob.disconnect();
4704
- hydrate();
4705
- break;
4706
- }
4707
- },
4708
- {
4709
- rootMargin: isString(margin) ? margin : margin + "px"
4758
+ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4759
+ const ob = new IntersectionObserver((entries) => {
4760
+ for (const e of entries) {
4761
+ if (!e.isIntersecting) continue;
4762
+ ob.disconnect();
4763
+ hydrate();
4764
+ break;
4710
4765
  }
4711
- );
4766
+ }, opts);
4712
4767
  forEach((el) => ob.observe(el));
4713
4768
  return () => ob.disconnect();
4714
4769
  };
@@ -5016,14 +5071,14 @@ const KeepAliveImpl = {
5016
5071
  function pruneCache(filter) {
5017
5072
  cache.forEach((vnode, key) => {
5018
5073
  const name = getComponentName(vnode.type);
5019
- if (name && (!filter || !filter(name))) {
5074
+ if (name && !filter(name)) {
5020
5075
  pruneCacheEntry(key);
5021
5076
  }
5022
5077
  });
5023
5078
  }
5024
5079
  function pruneCacheEntry(key) {
5025
5080
  const cached = cache.get(key);
5026
- if (!current || !isSameVNodeType(cached, current)) {
5081
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
5027
5082
  unmount(cached);
5028
5083
  } else if (current) {
5029
5084
  resetShapeFlag(current);
@@ -5085,6 +5140,10 @@ const KeepAliveImpl = {
5085
5140
  return rawVNode;
5086
5141
  }
5087
5142
  let vnode = getInnerChild(rawVNode);
5143
+ if (vnode.type === Comment) {
5144
+ current = null;
5145
+ return vnode;
5146
+ }
5088
5147
  const comp = vnode.type;
5089
5148
  const name = getComponentName(
5090
5149
  isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
@@ -5134,6 +5193,7 @@ function matches(pattern, name) {
5134
5193
  } else if (isString(pattern)) {
5135
5194
  return pattern.split(",").includes(name);
5136
5195
  } else if (isRegExp(pattern)) {
5196
+ pattern.lastIndex = 0;
5137
5197
  return pattern.test(name);
5138
5198
  }
5139
5199
  return false;
@@ -5217,17 +5277,19 @@ const createHook = (lifecycle) => (hook, target = currentInstance) => {
5217
5277
  };
5218
5278
  const onBeforeMount = createHook("bm");
5219
5279
  const onMounted = createHook("m");
5220
- const onBeforeUpdate = createHook("bu");
5280
+ const onBeforeUpdate = createHook(
5281
+ "bu"
5282
+ );
5221
5283
  const onUpdated = createHook("u");
5222
- const onBeforeUnmount = createHook("bum");
5223
- const onUnmounted = createHook("um");
5224
- const onServerPrefetch = createHook("sp");
5225
- const onRenderTriggered = createHook(
5226
- "rtg"
5284
+ const onBeforeUnmount = createHook(
5285
+ "bum"
5227
5286
  );
5228
- const onRenderTracked = createHook(
5229
- "rtc"
5287
+ const onUnmounted = createHook("um");
5288
+ const onServerPrefetch = createHook(
5289
+ "sp"
5230
5290
  );
5291
+ const onRenderTriggered = createHook("rtg");
5292
+ const onRenderTracked = createHook("rtc");
5231
5293
  function onErrorCaptured(hook, target = currentInstance) {
5232
5294
  injectHook("ec", hook, target);
5233
5295
  }
@@ -5641,9 +5703,14 @@ function createSlots(slots, dynamicSlots) {
5641
5703
  }
5642
5704
 
5643
5705
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
5644
- if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
5706
+ if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
5645
5707
  if (name !== "default") props.name = name;
5646
- return createVNode("slot", props, fallback && fallback());
5708
+ return openBlock(), createBlock(
5709
+ Fragment,
5710
+ null,
5711
+ [createVNode("slot", props, fallback && fallback())],
5712
+ 64
5713
+ );
5647
5714
  }
5648
5715
  let slot = slots[name];
5649
5716
  if (slot && slot.length > 1) {
@@ -5945,6 +6012,7 @@ const publicPropertiesMap = (
5945
6012
  $refs: (i) => shallowReadonly(i.refs) ,
5946
6013
  $parent: (i) => getPublicInstance(i.parent),
5947
6014
  $root: (i) => getPublicInstance(i.root),
6015
+ $host: (i) => i.ce,
5948
6016
  $emit: (i) => i.emit,
5949
6017
  $options: (i) => resolveMergedOptions(i) ,
5950
6018
  $forceUpdate: (i) => i.f || (i.f = () => {
@@ -6105,29 +6173,25 @@ const PublicInstanceProxyHandlers = {
6105
6173
  return Reflect.ownKeys(target);
6106
6174
  };
6107
6175
  }
6108
- const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend(
6109
- {},
6110
- PublicInstanceProxyHandlers,
6111
- {
6112
- get(target, key) {
6113
- if (key === Symbol.unscopables) {
6114
- return;
6115
- }
6116
- return PublicInstanceProxyHandlers.get(target, key, target);
6117
- },
6118
- has(_, key) {
6119
- const has = key[0] !== "_" && !isGloballyAllowed(key);
6120
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
6121
- warn$1(
6122
- `Property ${JSON.stringify(
6123
- key
6124
- )} should not start with _ which is a reserved prefix for Vue internals.`
6125
- );
6126
- }
6127
- return has;
6176
+ const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend({}, PublicInstanceProxyHandlers, {
6177
+ get(target, key) {
6178
+ if (key === Symbol.unscopables) {
6179
+ return;
6128
6180
  }
6181
+ return PublicInstanceProxyHandlers.get(target, key, target);
6182
+ },
6183
+ has(_, key) {
6184
+ const has = key[0] !== "_" && !isGloballyAllowed(key);
6185
+ if (!has && PublicInstanceProxyHandlers.has(_, key)) {
6186
+ warn$1(
6187
+ `Property ${JSON.stringify(
6188
+ key
6189
+ )} should not start with _ which is a reserved prefix for Vue internals.`
6190
+ );
6191
+ }
6192
+ return has;
6129
6193
  }
6130
- );
6194
+ });
6131
6195
  function createDevRenderContext(instance) {
6132
6196
  const target = {};
6133
6197
  Object.defineProperty(target, `_`, {
@@ -6814,7 +6878,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6814
6878
  return vm;
6815
6879
  }
6816
6880
  }
6817
- Vue.version = `2.6.14-compat:${"3.5.0-alpha.5"}`;
6881
+ Vue.version = `2.6.14-compat:${"3.5.0-beta.2"}`;
6818
6882
  Vue.config = singletonApp.config;
6819
6883
  Vue.use = (plugin, ...options) => {
6820
6884
  if (plugin && isFunction(plugin.install)) {
@@ -7087,7 +7151,7 @@ function installCompatMount(app, context, render) {
7087
7151
  /* skip options */
7088
7152
  );
7089
7153
  }
7090
- container.innerHTML = "";
7154
+ container.textContent = "";
7091
7155
  render(vnode, container, namespace);
7092
7156
  if (container instanceof Element) {
7093
7157
  container.removeAttribute("v-cloak");
@@ -7299,7 +7363,7 @@ function createAppAPI(render, hydrate) {
7299
7363
  If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
7300
7364
  );
7301
7365
  }
7302
- const vnode = createVNode(rootComponent, rootProps);
7366
+ const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
7303
7367
  vnode.appContext = context;
7304
7368
  if (namespace === true) {
7305
7369
  namespace = "svg";
@@ -7404,7 +7468,7 @@ function provide(key, value) {
7404
7468
  function inject(key, defaultValue, treatDefaultAsFactory = false) {
7405
7469
  const instance = currentInstance || currentRenderingInstance;
7406
7470
  if (instance || currentApp) {
7407
- const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
7471
+ const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
7408
7472
  if (provides && key in provides) {
7409
7473
  return provides[key];
7410
7474
  } else if (arguments.length > 1) {
@@ -7678,6 +7742,9 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
7678
7742
  } else {
7679
7743
  value = defaultValue;
7680
7744
  }
7745
+ if (instance.ce) {
7746
+ instance.ce._setProp(key, value);
7747
+ }
7681
7748
  }
7682
7749
  if (opt[0 /* shouldCast */]) {
7683
7750
  if (isAbsent && !hasDefault) {
@@ -8680,8 +8747,8 @@ function baseCreateRenderer(options, createHydrationFns) {
8680
8747
  const componentUpdateFn = () => {
8681
8748
  if (!instance.isMounted) {
8682
8749
  let vnodeHook;
8683
- const { el, props, type } = initialVNode;
8684
- const { bm, m, parent } = instance;
8750
+ const { el, props } = initialVNode;
8751
+ const { bm, m, parent, root, type } = instance;
8685
8752
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
8686
8753
  toggleRecurse(instance, false);
8687
8754
  if (bm) {
@@ -8727,6 +8794,9 @@ function baseCreateRenderer(options, createHydrationFns) {
8727
8794
  hydrateSubTree();
8728
8795
  }
8729
8796
  } else {
8797
+ if (root.ce) {
8798
+ root.ce._injectChildStyle(type);
8799
+ }
8730
8800
  {
8731
8801
  startMeasure(instance, `render`);
8732
8802
  }
@@ -9430,13 +9500,13 @@ function baseCreateRenderer(options, createHydrationFns) {
9430
9500
  namespace
9431
9501
  );
9432
9502
  }
9503
+ container._vnode = vnode;
9433
9504
  if (!isFlushing) {
9434
9505
  isFlushing = true;
9435
9506
  flushPreFlushCbs();
9436
9507
  flushPostFlushCbs();
9437
9508
  isFlushing = false;
9438
9509
  }
9439
- container._vnode = vnode;
9440
9510
  };
9441
9511
  const internals = {
9442
9512
  p: patch,
@@ -9610,14 +9680,9 @@ function doWatch(source, cb, {
9610
9680
  const _cb = cb;
9611
9681
  cb = (...args) => {
9612
9682
  _cb(...args);
9613
- unwatch();
9683
+ watchHandle();
9614
9684
  };
9615
9685
  }
9616
- if (deep !== void 0 && typeof deep === "number") {
9617
- warn$1(
9618
- `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
9619
- );
9620
- }
9621
9686
  if (!cb) {
9622
9687
  if (immediate !== void 0) {
9623
9688
  warn$1(
@@ -9643,10 +9708,12 @@ function doWatch(source, cb, {
9643
9708
  );
9644
9709
  };
9645
9710
  const instance = currentInstance;
9646
- const reactiveGetter = (source2) => deep === true ? source2 : (
9647
- // for deep: false, only traverse root-level properties
9648
- traverse(source2, deep === false ? 1 : void 0)
9649
- );
9711
+ const reactiveGetter = (source2) => {
9712
+ if (deep) return source2;
9713
+ if (isShallow(source2) || deep === false || deep === 0)
9714
+ return traverse(source2, 1);
9715
+ return traverse(source2);
9716
+ };
9650
9717
  let getter;
9651
9718
  let forceTrigger = false;
9652
9719
  let isMultiSource = false;
@@ -9702,7 +9769,8 @@ function doWatch(source, cb, {
9702
9769
  }
9703
9770
  if (cb && deep) {
9704
9771
  const baseGetter = getter;
9705
- getter = () => traverse(baseGetter());
9772
+ const depth = deep === true ? Infinity : deep;
9773
+ getter = () => traverse(baseGetter(), depth);
9706
9774
  }
9707
9775
  let cleanup;
9708
9776
  let onCleanup = (fn) => {
@@ -9727,7 +9795,12 @@ function doWatch(source, cb, {
9727
9795
  const ctx = useSSRContext();
9728
9796
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
9729
9797
  } else {
9730
- return NOOP;
9798
+ const watchHandle2 = () => {
9799
+ };
9800
+ watchHandle2.stop = NOOP;
9801
+ watchHandle2.resume = NOOP;
9802
+ watchHandle2.pause = NOOP;
9803
+ return watchHandle2;
9731
9804
  }
9732
9805
  }
9733
9806
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -9757,7 +9830,6 @@ function doWatch(source, cb, {
9757
9830
  const effect = new ReactiveEffect(getter);
9758
9831
  let scheduler;
9759
9832
  if (flush === "sync") {
9760
- effect.flags |= 64;
9761
9833
  scheduler = job;
9762
9834
  } else if (flush === "post") {
9763
9835
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
@@ -9768,12 +9840,15 @@ function doWatch(source, cb, {
9768
9840
  }
9769
9841
  effect.scheduler = scheduler;
9770
9842
  const scope = getCurrentScope();
9771
- const unwatch = () => {
9843
+ const watchHandle = () => {
9772
9844
  effect.stop();
9773
9845
  if (scope) {
9774
9846
  remove(scope.effects, effect);
9775
9847
  }
9776
9848
  };
9849
+ watchHandle.pause = effect.pause.bind(effect);
9850
+ watchHandle.resume = effect.resume.bind(effect);
9851
+ watchHandle.stop = watchHandle;
9777
9852
  {
9778
9853
  effect.onTrack = onTrack;
9779
9854
  effect.onTrigger = onTrigger;
@@ -9792,8 +9867,8 @@ function doWatch(source, cb, {
9792
9867
  } else {
9793
9868
  effect.run();
9794
9869
  }
9795
- if (ssrCleanup) ssrCleanup.push(unwatch);
9796
- return unwatch;
9870
+ if (ssrCleanup) ssrCleanup.push(watchHandle);
9871
+ return watchHandle;
9797
9872
  }
9798
9873
  function instanceWatch(source, value, options) {
9799
9874
  const publicThis = this.proxy;
@@ -9883,7 +9958,8 @@ function useModel(props, name, options = EMPTY_OBJ) {
9883
9958
  return options.get ? options.get(localValue) : localValue;
9884
9959
  },
9885
9960
  set(value) {
9886
- if (!hasChanged(value, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
9961
+ const emittedValue = options.set ? options.set(value) : value;
9962
+ if (!hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
9887
9963
  return;
9888
9964
  }
9889
9965
  const rawProps = i.vnode.props;
@@ -9892,7 +9968,6 @@ function useModel(props, name, options = EMPTY_OBJ) {
9892
9968
  localValue = value;
9893
9969
  trigger();
9894
9970
  }
9895
- const emittedValue = options.set ? options.set(value) : value;
9896
9971
  i.emit(`update:${name}`, emittedValue);
9897
9972
  if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) {
9898
9973
  trigger();
@@ -9930,9 +10005,9 @@ function emit(instance, event, ...rawArgs) {
9930
10005
  } = instance;
9931
10006
  if (emitsOptions) {
9932
10007
  if (!(event in emitsOptions) && !(event.startsWith("hook:") || event.startsWith(compatModelEventPrefix))) {
9933
- if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
10008
+ if (!propsOptions || !(toHandlerKey(camelize(event)) in propsOptions)) {
9934
10009
  warn$1(
9935
- `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
10010
+ `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(camelize(event))}" prop.`
9936
10011
  );
9937
10012
  }
9938
10013
  } else {
@@ -11863,11 +11938,16 @@ function useTemplateRef(key) {
11863
11938
  const r = shallowRef(null);
11864
11939
  if (i) {
11865
11940
  const refs = i.refs === EMPTY_OBJ ? i.refs = {} : i.refs;
11866
- Object.defineProperty(refs, key, {
11867
- enumerable: true,
11868
- get: () => r.value,
11869
- set: (val) => r.value = val
11870
- });
11941
+ let desc;
11942
+ if ((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable) {
11943
+ warn$1(`useTemplateRef('${key}') already exists.`);
11944
+ } else {
11945
+ Object.defineProperty(refs, key, {
11946
+ enumerable: true,
11947
+ get: () => r.value,
11948
+ set: (val) => r.value = val
11949
+ });
11950
+ }
11871
11951
  } else {
11872
11952
  warn$1(
11873
11953
  `useTemplateRef() is called when there is no active component instance to be associated with.`
@@ -12101,7 +12181,7 @@ function isMemoSame(cached, memo) {
12101
12181
  return true;
12102
12182
  }
12103
12183
 
12104
- const version = "3.5.0-alpha.5";
12184
+ const version = "3.5.0-beta.2";
12105
12185
  const warn = warn$1 ;
12106
12186
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12107
12187
  const devtools = devtools$1 ;
@@ -12113,7 +12193,8 @@ const _ssrUtils = {
12113
12193
  setCurrentRenderingInstance,
12114
12194
  isVNode: isVNode,
12115
12195
  normalizeVNode,
12116
- getComponentPublicInstance
12196
+ getComponentPublicInstance,
12197
+ ensureValidVNode
12117
12198
  };
12118
12199
  const ssrUtils = _ssrUtils ;
12119
12200
  const resolveFilter = resolveFilter$1 ;
@@ -12127,6 +12208,18 @@ const _compatUtils = {
12127
12208
  const compatUtils = _compatUtils ;
12128
12209
  const DeprecationTypes = DeprecationTypes$1 ;
12129
12210
 
12211
+ let policy = void 0;
12212
+ const tt = typeof window !== "undefined" && window.trustedTypes;
12213
+ if (tt) {
12214
+ try {
12215
+ policy = /* @__PURE__ */ tt.createPolicy("vue", {
12216
+ createHTML: (val) => val
12217
+ });
12218
+ } catch (e) {
12219
+ warn(`Error creating trusted types policy: ${e}`);
12220
+ }
12221
+ }
12222
+ const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
12130
12223
  const svgNS = "http://www.w3.org/2000/svg";
12131
12224
  const mathmlNS = "http://www.w3.org/1998/Math/MathML";
12132
12225
  const doc = typeof document !== "undefined" ? document : null;
@@ -12174,7 +12267,9 @@ const nodeOps = {
12174
12267
  if (start === end || !(start = start.nextSibling)) break;
12175
12268
  }
12176
12269
  } else {
12177
- templateContainer.innerHTML = namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content;
12270
+ templateContainer.innerHTML = unsafeToTrustedHTML(
12271
+ namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content
12272
+ );
12178
12273
  const template = templateContainer.content;
12179
12274
  if (namespace === "svg" || namespace === "mathml") {
12180
12275
  const wrapper = template.firstChild;
@@ -12922,16 +13017,24 @@ function shouldSetAsProp(el, key, value, isSVG) {
12922
13017
  if (isNativeOn(key) && isString(value)) {
12923
13018
  return false;
12924
13019
  }
12925
- return key in el;
13020
+ if (key in el) {
13021
+ return true;
13022
+ }
13023
+ if (el._isVueCE && (/[A-Z]/.test(key) || !isString(value))) {
13024
+ return true;
13025
+ }
13026
+ return false;
12926
13027
  }
12927
13028
 
13029
+ const REMOVAL = {};
12928
13030
  /*! #__NO_SIDE_EFFECTS__ */
12929
13031
  // @__NO_SIDE_EFFECTS__
12930
- function defineCustomElement(options, extraOptions, hydrate2) {
13032
+ function defineCustomElement(options, extraOptions, _createApp) {
12931
13033
  const Comp = defineComponent(options, extraOptions);
13034
+ if (isPlainObject(Comp)) extend(Comp, extraOptions);
12932
13035
  class VueCustomElement extends VueElement {
12933
13036
  constructor(initialProps) {
12934
- super(Comp, initialProps, hydrate2);
13037
+ super(Comp, initialProps, _createApp);
12935
13038
  }
12936
13039
  }
12937
13040
  VueCustomElement.def = Comp;
@@ -12939,47 +13042,87 @@ function defineCustomElement(options, extraOptions, hydrate2) {
12939
13042
  }
12940
13043
  /*! #__NO_SIDE_EFFECTS__ */
12941
13044
  const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
12942
- return /* @__PURE__ */ defineCustomElement(options, extraOptions, hydrate);
13045
+ return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
12943
13046
  };
12944
13047
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
12945
13048
  };
12946
13049
  class VueElement extends BaseClass {
12947
- constructor(_def, _props = {}, hydrate2) {
13050
+ constructor(_def, _props = {}, _createApp = createApp) {
12948
13051
  super();
12949
13052
  this._def = _def;
12950
13053
  this._props = _props;
13054
+ this._createApp = _createApp;
13055
+ this._isVueCE = true;
12951
13056
  /**
12952
13057
  * @internal
12953
13058
  */
12954
13059
  this._instance = null;
13060
+ /**
13061
+ * @internal
13062
+ */
13063
+ this._app = null;
13064
+ /**
13065
+ * @internal
13066
+ */
13067
+ this._nonce = this._def.nonce;
12955
13068
  this._connected = false;
12956
13069
  this._resolved = false;
12957
13070
  this._numberProps = null;
13071
+ this._styleChildren = /* @__PURE__ */ new WeakSet();
12958
13072
  this._ob = null;
12959
- if (this.shadowRoot && hydrate2) {
12960
- hydrate2(this._createVNode(), this.shadowRoot);
13073
+ if (this.shadowRoot && _createApp !== createApp) {
13074
+ this._root = this.shadowRoot;
12961
13075
  } else {
12962
13076
  if (this.shadowRoot) {
12963
13077
  warn(
12964
13078
  `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
12965
13079
  );
12966
13080
  }
12967
- this.attachShadow({ mode: "open" });
12968
- if (!this._def.__asyncLoader) {
12969
- this._resolveProps(this._def);
13081
+ if (_def.shadowRoot !== false) {
13082
+ this.attachShadow({ mode: "open" });
13083
+ this._root = this.shadowRoot;
13084
+ } else {
13085
+ this._root = this;
12970
13086
  }
12971
13087
  }
13088
+ if (!this._def.__asyncLoader) {
13089
+ this._resolveProps(this._def);
13090
+ }
12972
13091
  }
12973
13092
  connectedCallback() {
13093
+ if (!this.shadowRoot) {
13094
+ this._parseSlots();
13095
+ }
12974
13096
  this._connected = true;
13097
+ let parent = this;
13098
+ while (parent = parent && (parent.parentNode || parent.host)) {
13099
+ if (parent instanceof VueElement) {
13100
+ this._parent = parent;
13101
+ break;
13102
+ }
13103
+ }
12975
13104
  if (!this._instance) {
12976
13105
  if (this._resolved) {
13106
+ this._setParent();
12977
13107
  this._update();
12978
13108
  } else {
12979
- this._resolveDef();
13109
+ if (parent && parent._pendingResolve) {
13110
+ this._pendingResolve = parent._pendingResolve.then(() => {
13111
+ this._pendingResolve = void 0;
13112
+ this._resolveDef();
13113
+ });
13114
+ } else {
13115
+ this._resolveDef();
13116
+ }
12980
13117
  }
12981
13118
  }
12982
13119
  }
13120
+ _setParent(parent = this._parent) {
13121
+ if (parent) {
13122
+ this._instance.parent = parent._instance;
13123
+ this._instance.provides = parent._instance.provides;
13124
+ }
13125
+ }
12983
13126
  disconnectedCallback() {
12984
13127
  this._connected = false;
12985
13128
  nextTick(() => {
@@ -12988,8 +13131,9 @@ class VueElement extends BaseClass {
12988
13131
  this._ob.disconnect();
12989
13132
  this._ob = null;
12990
13133
  }
12991
- render(null, this.shadowRoot);
12992
- this._instance = null;
13134
+ this._app && this._app.unmount();
13135
+ this._instance.ce = void 0;
13136
+ this._app = this._instance = null;
12993
13137
  }
12994
13138
  });
12995
13139
  }
@@ -12997,7 +13141,9 @@ class VueElement extends BaseClass {
12997
13141
  * resolve inner component definition (handle possible async component)
12998
13142
  */
12999
13143
  _resolveDef() {
13000
- this._resolved = true;
13144
+ if (this._pendingResolve) {
13145
+ return;
13146
+ }
13001
13147
  for (let i = 0; i < this.attributes.length; i++) {
13002
13148
  this._setAttr(this.attributes[i].name);
13003
13149
  }
@@ -13008,6 +13154,8 @@ class VueElement extends BaseClass {
13008
13154
  });
13009
13155
  this._ob.observe(this, { attributes: true });
13010
13156
  const resolve = (def, isAsync = false) => {
13157
+ this._resolved = true;
13158
+ this._pendingResolve = void 0;
13011
13159
  const { props, styles } = def;
13012
13160
  let numberProps;
13013
13161
  if (props && !isArray(props)) {
@@ -13025,22 +13173,53 @@ class VueElement extends BaseClass {
13025
13173
  if (isAsync) {
13026
13174
  this._resolveProps(def);
13027
13175
  }
13028
- this._applyStyles(styles);
13029
- this._update();
13176
+ if (this.shadowRoot) {
13177
+ this._applyStyles(styles);
13178
+ } else if (styles) {
13179
+ warn(
13180
+ "Custom element style injection is not supported when using shadowRoot: false"
13181
+ );
13182
+ }
13183
+ this._mount(def);
13030
13184
  };
13031
13185
  const asyncDef = this._def.__asyncLoader;
13032
13186
  if (asyncDef) {
13033
- asyncDef().then((def) => resolve(def, true));
13187
+ this._pendingResolve = asyncDef().then(
13188
+ (def) => resolve(this._def = def, true)
13189
+ );
13034
13190
  } else {
13035
13191
  resolve(this._def);
13036
13192
  }
13037
13193
  }
13194
+ _mount(def) {
13195
+ if (!def.name) {
13196
+ def.name = "VueElement";
13197
+ }
13198
+ this._app = this._createApp(def);
13199
+ if (def.configureApp) {
13200
+ def.configureApp(this._app);
13201
+ }
13202
+ this._app._ceVNode = this._createVNode();
13203
+ this._app.mount(this._root);
13204
+ const exposed = this._instance && this._instance.exposed;
13205
+ if (!exposed) return;
13206
+ for (const key in exposed) {
13207
+ if (!hasOwn(this, key)) {
13208
+ Object.defineProperty(this, key, {
13209
+ // unwrap ref to be consistent with public instance behavior
13210
+ get: () => unref(exposed[key])
13211
+ });
13212
+ } else {
13213
+ warn(`Exposed property "${key}" already exists on custom element.`);
13214
+ }
13215
+ }
13216
+ }
13038
13217
  _resolveProps(def) {
13039
13218
  const { props } = def;
13040
13219
  const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
13041
13220
  for (const key of Object.keys(this)) {
13042
13221
  if (key[0] !== "_" && declaredPropKeys.includes(key)) {
13043
- this._setProp(key, this[key], true, false);
13222
+ this._setProp(key, this[key]);
13044
13223
  }
13045
13224
  }
13046
13225
  for (const key of declaredPropKeys.map(camelize)) {
@@ -13049,18 +13228,20 @@ class VueElement extends BaseClass {
13049
13228
  return this._getProp(key);
13050
13229
  },
13051
13230
  set(val) {
13052
- this._setProp(key, val);
13231
+ this._setProp(key, val, true, true);
13053
13232
  }
13054
13233
  });
13055
13234
  }
13056
13235
  }
13057
13236
  _setAttr(key) {
13058
- let value = this.hasAttribute(key) ? this.getAttribute(key) : void 0;
13237
+ if (key.startsWith("data-v-")) return;
13238
+ const has = this.hasAttribute(key);
13239
+ let value = has ? this.getAttribute(key) : REMOVAL;
13059
13240
  const camelKey = camelize(key);
13060
- if (this._numberProps && this._numberProps[camelKey]) {
13241
+ if (has && this._numberProps && this._numberProps[camelKey]) {
13061
13242
  value = toNumber(value);
13062
13243
  }
13063
- this._setProp(camelKey, value, false);
13244
+ this._setProp(camelKey, value, false, true);
13064
13245
  }
13065
13246
  /**
13066
13247
  * @internal
@@ -13071,9 +13252,13 @@ class VueElement extends BaseClass {
13071
13252
  /**
13072
13253
  * @internal
13073
13254
  */
13074
- _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
13255
+ _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
13075
13256
  if (val !== this._props[key]) {
13076
- this._props[key] = val;
13257
+ if (val === REMOVAL) {
13258
+ delete this._props[key];
13259
+ } else {
13260
+ this._props[key] = val;
13261
+ }
13077
13262
  if (shouldUpdate && this._instance) {
13078
13263
  this._update();
13079
13264
  }
@@ -13089,18 +13274,23 @@ class VueElement extends BaseClass {
13089
13274
  }
13090
13275
  }
13091
13276
  _update() {
13092
- render(this._createVNode(), this.shadowRoot);
13277
+ render(this._createVNode(), this._root);
13093
13278
  }
13094
13279
  _createVNode() {
13095
- const vnode = createVNode(this._def, extend({}, this._props));
13280
+ const baseProps = {};
13281
+ if (!this.shadowRoot) {
13282
+ baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
13283
+ }
13284
+ const vnode = createVNode(this._def, extend(baseProps, this._props));
13096
13285
  if (!this._instance) {
13097
13286
  vnode.ce = (instance) => {
13098
13287
  this._instance = instance;
13288
+ instance.ce = this;
13099
13289
  instance.isCE = true;
13100
13290
  {
13101
13291
  instance.ceReload = (newStyles) => {
13102
13292
  if (this._styles) {
13103
- this._styles.forEach((s) => this.shadowRoot.removeChild(s));
13293
+ this._styles.forEach((s) => this._root.removeChild(s));
13104
13294
  this._styles.length = 0;
13105
13295
  }
13106
13296
  this._applyStyles(newStyles);
@@ -13110,9 +13300,10 @@ class VueElement extends BaseClass {
13110
13300
  }
13111
13301
  const dispatch = (event, args) => {
13112
13302
  this.dispatchEvent(
13113
- new CustomEvent(event, {
13114
- detail: args
13115
- })
13303
+ new CustomEvent(
13304
+ event,
13305
+ isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
13306
+ )
13116
13307
  );
13117
13308
  };
13118
13309
  instance.emit = (event, ...args) => {
@@ -13121,30 +13312,126 @@ class VueElement extends BaseClass {
13121
13312
  dispatch(hyphenate(event), args);
13122
13313
  }
13123
13314
  };
13124
- let parent = this;
13125
- while (parent = parent && (parent.parentNode || parent.host)) {
13126
- if (parent instanceof VueElement) {
13127
- instance.parent = parent._instance;
13128
- instance.provides = parent._instance.provides;
13129
- break;
13130
- }
13131
- }
13315
+ this._setParent();
13132
13316
  };
13133
13317
  }
13134
13318
  return vnode;
13135
13319
  }
13136
- _applyStyles(styles) {
13137
- if (styles) {
13138
- styles.forEach((css) => {
13139
- const s = document.createElement("style");
13140
- s.textContent = css;
13141
- this.shadowRoot.appendChild(s);
13142
- {
13320
+ _applyStyles(styles, owner) {
13321
+ if (!styles) return;
13322
+ if (owner) {
13323
+ if (owner === this._def || this._styleChildren.has(owner)) {
13324
+ return;
13325
+ }
13326
+ this._styleChildren.add(owner);
13327
+ }
13328
+ const nonce = this._nonce;
13329
+ for (let i = styles.length - 1; i >= 0; i--) {
13330
+ const s = document.createElement("style");
13331
+ if (nonce) s.setAttribute("nonce", nonce);
13332
+ s.textContent = styles[i];
13333
+ this.shadowRoot.prepend(s);
13334
+ {
13335
+ if (owner) {
13336
+ if (owner.__hmrId) {
13337
+ if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
13338
+ let entry = this._childStyles.get(owner.__hmrId);
13339
+ if (!entry) {
13340
+ this._childStyles.set(owner.__hmrId, entry = []);
13341
+ }
13342
+ entry.push(s);
13343
+ }
13344
+ } else {
13143
13345
  (this._styles || (this._styles = [])).push(s);
13144
13346
  }
13145
- });
13347
+ }
13348
+ }
13349
+ }
13350
+ /**
13351
+ * Only called when shaddowRoot is false
13352
+ */
13353
+ _parseSlots() {
13354
+ const slots = this._slots = {};
13355
+ let n;
13356
+ while (n = this.firstChild) {
13357
+ const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
13358
+ (slots[slotName] || (slots[slotName] = [])).push(n);
13359
+ this.removeChild(n);
13360
+ }
13361
+ }
13362
+ /**
13363
+ * Only called when shaddowRoot is false
13364
+ */
13365
+ _renderSlots() {
13366
+ const outlets = this.querySelectorAll("slot");
13367
+ const scopeId = this._instance.type.__scopeId;
13368
+ for (let i = 0; i < outlets.length; i++) {
13369
+ const o = outlets[i];
13370
+ const slotName = o.getAttribute("name") || "default";
13371
+ const content = this._slots[slotName];
13372
+ const parent = o.parentNode;
13373
+ if (content) {
13374
+ for (const n of content) {
13375
+ if (scopeId && n.nodeType === 1) {
13376
+ const id = scopeId + "-s";
13377
+ const walker = document.createTreeWalker(n, 1);
13378
+ n.setAttribute(id, "");
13379
+ let child;
13380
+ while (child = walker.nextNode()) {
13381
+ child.setAttribute(id, "");
13382
+ }
13383
+ }
13384
+ parent.insertBefore(n, o);
13385
+ }
13386
+ } else {
13387
+ while (o.firstChild) parent.insertBefore(o.firstChild, o);
13388
+ }
13389
+ parent.removeChild(o);
13390
+ }
13391
+ }
13392
+ /**
13393
+ * @internal
13394
+ */
13395
+ _injectChildStyle(comp) {
13396
+ this._applyStyles(comp.styles, comp);
13397
+ }
13398
+ /**
13399
+ * @internal
13400
+ */
13401
+ _removeChildStyle(comp) {
13402
+ {
13403
+ this._styleChildren.delete(comp);
13404
+ if (this._childStyles && comp.__hmrId) {
13405
+ const oldStyles = this._childStyles.get(comp.__hmrId);
13406
+ if (oldStyles) {
13407
+ oldStyles.forEach((s) => this._root.removeChild(s));
13408
+ oldStyles.length = 0;
13409
+ }
13410
+ }
13411
+ }
13412
+ }
13413
+ }
13414
+ function useHost(caller) {
13415
+ const instance = getCurrentInstance();
13416
+ const el = instance && instance.ce;
13417
+ if (el) {
13418
+ return el;
13419
+ } else {
13420
+ if (!instance) {
13421
+ warn(
13422
+ `${caller || "useHost"} called without an active component instance.`
13423
+ );
13424
+ } else {
13425
+ warn(
13426
+ `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
13427
+ );
13146
13428
  }
13147
13429
  }
13430
+ return null;
13431
+ }
13432
+ function useShadowRoot() {
13433
+ const el = useHost("useShadowRoot") ;
13434
+ return el && el.shadowRoot;
13148
13435
  }
13149
13436
 
13150
13437
  function useCssModule(name = "$style") {
@@ -13703,7 +13990,7 @@ const createApp = (...args) => {
13703
13990
  const component = app._component;
13704
13991
  if (!isFunction(component) && !component.render && !component.template) {
13705
13992
  component.template = container.innerHTML;
13706
- {
13993
+ if (container.nodeType === 1) {
13707
13994
  for (let i = 0; i < container.attributes.length; i++) {
13708
13995
  const attr = container.attributes[i];
13709
13996
  if (attr.name !== "v-cloak" && /^(v-|:|@)/.test(attr.name)) {
@@ -13716,7 +14003,9 @@ const createApp = (...args) => {
13716
14003
  }
13717
14004
  }
13718
14005
  }
13719
- container.innerHTML = "";
14006
+ if (container.nodeType === 1) {
14007
+ container.textContent = "";
14008
+ }
13720
14009
  const proxy = mount(container, false, resolveRootNamespace(container));
13721
14010
  if (container instanceof Element) {
13722
14011
  container.removeAttribute("v-cloak");
@@ -13950,9 +14239,11 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
13950
14239
  useAttrs: useAttrs,
13951
14240
  useCssModule: useCssModule,
13952
14241
  useCssVars: useCssVars,
14242
+ useHost: useHost,
13953
14243
  useId: useId,
13954
14244
  useModel: useModel,
13955
14245
  useSSRContext: useSSRContext,
14246
+ useShadowRoot: useShadowRoot,
13956
14247
  useSlots: useSlots,
13957
14248
  useTemplateRef: useTemplateRef,
13958
14249
  useTransitionState: useTransitionState,
@@ -13999,36 +14290,70 @@ const FRAGMENT = Symbol(`Fragment` );
13999
14290
  const TELEPORT = Symbol(`Teleport` );
14000
14291
  const SUSPENSE = Symbol(`Suspense` );
14001
14292
  const KEEP_ALIVE = Symbol(`KeepAlive` );
14002
- const BASE_TRANSITION = Symbol(`BaseTransition` );
14293
+ const BASE_TRANSITION = Symbol(
14294
+ `BaseTransition`
14295
+ );
14003
14296
  const OPEN_BLOCK = Symbol(`openBlock` );
14004
14297
  const CREATE_BLOCK = Symbol(`createBlock` );
14005
- const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
14298
+ const CREATE_ELEMENT_BLOCK = Symbol(
14299
+ `createElementBlock`
14300
+ );
14006
14301
  const CREATE_VNODE = Symbol(`createVNode` );
14007
- const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
14008
- const CREATE_COMMENT = Symbol(`createCommentVNode` );
14009
- const CREATE_TEXT = Symbol(`createTextVNode` );
14010
- const CREATE_STATIC = Symbol(`createStaticVNode` );
14011
- const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
14302
+ const CREATE_ELEMENT_VNODE = Symbol(
14303
+ `createElementVNode`
14304
+ );
14305
+ const CREATE_COMMENT = Symbol(
14306
+ `createCommentVNode`
14307
+ );
14308
+ const CREATE_TEXT = Symbol(
14309
+ `createTextVNode`
14310
+ );
14311
+ const CREATE_STATIC = Symbol(
14312
+ `createStaticVNode`
14313
+ );
14314
+ const RESOLVE_COMPONENT = Symbol(
14315
+ `resolveComponent`
14316
+ );
14012
14317
  const RESOLVE_DYNAMIC_COMPONENT = Symbol(
14013
14318
  `resolveDynamicComponent`
14014
14319
  );
14015
- const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
14016
- const RESOLVE_FILTER = Symbol(`resolveFilter` );
14017
- const WITH_DIRECTIVES = Symbol(`withDirectives` );
14320
+ const RESOLVE_DIRECTIVE = Symbol(
14321
+ `resolveDirective`
14322
+ );
14323
+ const RESOLVE_FILTER = Symbol(
14324
+ `resolveFilter`
14325
+ );
14326
+ const WITH_DIRECTIVES = Symbol(
14327
+ `withDirectives`
14328
+ );
14018
14329
  const RENDER_LIST = Symbol(`renderList` );
14019
14330
  const RENDER_SLOT = Symbol(`renderSlot` );
14020
14331
  const CREATE_SLOTS = Symbol(`createSlots` );
14021
- const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
14332
+ const TO_DISPLAY_STRING = Symbol(
14333
+ `toDisplayString`
14334
+ );
14022
14335
  const MERGE_PROPS = Symbol(`mergeProps` );
14023
- const NORMALIZE_CLASS = Symbol(`normalizeClass` );
14024
- const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
14025
- const NORMALIZE_PROPS = Symbol(`normalizeProps` );
14026
- const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
14336
+ const NORMALIZE_CLASS = Symbol(
14337
+ `normalizeClass`
14338
+ );
14339
+ const NORMALIZE_STYLE = Symbol(
14340
+ `normalizeStyle`
14341
+ );
14342
+ const NORMALIZE_PROPS = Symbol(
14343
+ `normalizeProps`
14344
+ );
14345
+ const GUARD_REACTIVE_PROPS = Symbol(
14346
+ `guardReactiveProps`
14347
+ );
14027
14348
  const TO_HANDLERS = Symbol(`toHandlers` );
14028
14349
  const CAMELIZE = Symbol(`camelize` );
14029
14350
  const CAPITALIZE = Symbol(`capitalize` );
14030
- const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
14031
- const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
14351
+ const TO_HANDLER_KEY = Symbol(
14352
+ `toHandlerKey`
14353
+ );
14354
+ const SET_BLOCK_TRACKING = Symbol(
14355
+ `setBlockTracking`
14356
+ );
14032
14357
  const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
14033
14358
  const POP_SCOPE_ID = Symbol(`popScopeId` );
14034
14359
  const WITH_CTX = Symbol(`withCtx` );
@@ -15272,6 +15597,16 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
15272
15597
  (id) => markScopeIdentifier(node, id, knownIds)
15273
15598
  );
15274
15599
  }
15600
+ } else if (node.type === "CatchClause" && node.param) {
15601
+ for (const id of extractIdentifiers(node.param)) {
15602
+ markScopeIdentifier(node, id, knownIds);
15603
+ }
15604
+ } else if (isForStatement(node)) {
15605
+ walkForStatement(
15606
+ node,
15607
+ false,
15608
+ (id) => markScopeIdentifier(node, id, knownIds)
15609
+ );
15275
15610
  }
15276
15611
  },
15277
15612
  leave(node, parent) {
@@ -15352,14 +15687,20 @@ function walkBlockDeclarations(block, onIdent) {
15352
15687
  } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
15353
15688
  if (stmt.declare || !stmt.id) continue;
15354
15689
  onIdent(stmt.id);
15355
- } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
15356
- const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
15357
- if (variable && variable.type === "VariableDeclaration") {
15358
- for (const decl of variable.declarations) {
15359
- for (const id of extractIdentifiers(decl.id)) {
15360
- onIdent(id);
15361
- }
15362
- }
15690
+ } else if (isForStatement(stmt)) {
15691
+ walkForStatement(stmt, true, onIdent);
15692
+ }
15693
+ }
15694
+ }
15695
+ function isForStatement(stmt) {
15696
+ return stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement";
15697
+ }
15698
+ function walkForStatement(stmt, isVar, onIdent) {
15699
+ const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
15700
+ if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : !isVar)) {
15701
+ for (const decl of variable.declarations) {
15702
+ for (const id of extractIdentifiers(decl.id)) {
15703
+ onIdent(id);
15363
15704
  }
15364
15705
  }
15365
15706
  }
@@ -15542,10 +15883,11 @@ function isCoreComponent(tag) {
15542
15883
  }
15543
15884
  const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
15544
15885
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
15545
- const isMemberExpressionNode = (path, context) => {
15886
+ const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
15887
+ const isMemberExpressionNode = (exp, context) => {
15546
15888
  try {
15547
- let ret = parser.parseExpression(path, {
15548
- plugins: context.expressionPlugins
15889
+ let ret = exp.ast || parser.parseExpression(getExpSource(exp), {
15890
+ plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
15549
15891
  });
15550
15892
  ret = unwrapTSNode(ret);
15551
15893
  return ret.type === "MemberExpression" || ret.type === "OptionalMemberExpression" || ret.type === "Identifier" && ret.name !== "undefined";
@@ -15554,6 +15896,24 @@ const isMemberExpressionNode = (path, context) => {
15554
15896
  }
15555
15897
  };
15556
15898
  const isMemberExpression = isMemberExpressionNode;
15899
+ const isFnExpressionNode = (exp, context) => {
15900
+ try {
15901
+ let ret = exp.ast || parser.parseExpression(getExpSource(exp), {
15902
+ plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"]
15903
+ });
15904
+ if (ret.type === "Program") {
15905
+ ret = ret.body[0];
15906
+ if (ret.type === "ExpressionStatement") {
15907
+ ret = ret.expression;
15908
+ }
15909
+ }
15910
+ ret = unwrapTSNode(ret);
15911
+ return ret.type === "FunctionExpression" || ret.type === "ArrowFunctionExpression";
15912
+ } catch (e) {
15913
+ return false;
15914
+ }
15915
+ };
15916
+ const isFnExpression = isFnExpressionNode;
15557
15917
  function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
15558
15918
  return advancePositionWithMutation(
15559
15919
  {
@@ -19075,7 +19435,7 @@ function resolveComponentType(node, context, ssr = false) {
19075
19435
  } else {
19076
19436
  exp = isProp.exp;
19077
19437
  if (!exp) {
19078
- exp = createSimpleExpression(`is`, false, isProp.loc);
19438
+ exp = createSimpleExpression(`is`, false, isProp.arg.loc);
19079
19439
  {
19080
19440
  exp = isProp.exp = processExpression(exp, context);
19081
19441
  }
@@ -19655,7 +20015,6 @@ function processSlotOutlet(node, context) {
19655
20015
  };
19656
20016
  }
19657
20017
 
19658
- const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
19659
20018
  const transformOn$1 = (dir, node, context, augmentor) => {
19660
20019
  const { loc, modifiers, arg } = dir;
19661
20020
  if (!dir.exp && !modifiers.length) {
@@ -19699,8 +20058,8 @@ const transformOn$1 = (dir, node, context, augmentor) => {
19699
20058
  }
19700
20059
  let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
19701
20060
  if (exp) {
19702
- const isMemberExp = isMemberExpression(exp.content, context);
19703
- const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
20061
+ const isMemberExp = isMemberExpression(exp, context);
20062
+ const isInlineStatement = !(isMemberExp || isFnExpression(exp, context));
19704
20063
  const hasMultipleStatements = exp.content.includes(`;`);
19705
20064
  if (context.prefixIdentifiers) {
19706
20065
  isInlineStatement && context.addIdentifiers(`$event`);
@@ -19870,7 +20229,7 @@ const transformModel$1 = (dir, node, context) => {
19870
20229
  return createTransformProps();
19871
20230
  }
19872
20231
  const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
19873
- if (!expString.trim() || !isMemberExpression(expString, context) && !maybeRef) {
20232
+ if (!expString.trim() || !isMemberExpression(exp, context) && !maybeRef) {
19874
20233
  context.onError(
19875
20234
  createCompilerError(42, exp.loc)
19876
20235
  );
@@ -20173,15 +20532,27 @@ function baseCompile(source, options = {}) {
20173
20532
  const noopDirectiveTransform = () => ({ props: [] });
20174
20533
 
20175
20534
  const V_MODEL_RADIO = Symbol(`vModelRadio` );
20176
- const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
20535
+ const V_MODEL_CHECKBOX = Symbol(
20536
+ `vModelCheckbox`
20537
+ );
20177
20538
  const V_MODEL_TEXT = Symbol(`vModelText` );
20178
- const V_MODEL_SELECT = Symbol(`vModelSelect` );
20179
- const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
20180
- const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
20181
- const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
20539
+ const V_MODEL_SELECT = Symbol(
20540
+ `vModelSelect`
20541
+ );
20542
+ const V_MODEL_DYNAMIC = Symbol(
20543
+ `vModelDynamic`
20544
+ );
20545
+ const V_ON_WITH_MODIFIERS = Symbol(
20546
+ `vOnModifiersGuard`
20547
+ );
20548
+ const V_ON_WITH_KEYS = Symbol(
20549
+ `vOnKeysGuard`
20550
+ );
20182
20551
  const V_SHOW = Symbol(`vShow` );
20183
20552
  const TRANSITION = Symbol(`Transition` );
20184
- const TRANSITION_GROUP = Symbol(`TransitionGroup` );
20553
+ const TRANSITION_GROUP = Symbol(
20554
+ `TransitionGroup`
20555
+ );
20185
20556
  registerRuntimeHelpers({
20186
20557
  [V_MODEL_RADIO]: `vModelRadio`,
20187
20558
  [V_MODEL_CHECKBOX]: `vModelCheckbox`,