@vue/runtime-core 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/README.md CHANGED
@@ -13,7 +13,7 @@ const { render, createApp } = createRenderer({
13
13
  patchProp,
14
14
  insert,
15
15
  remove,
16
- createElement
16
+ createElement,
17
17
  // ...
18
18
  })
19
19
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-core v3.5.0-alpha.5
2
+ * @vue/runtime-core v3.5.0-beta.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -554,6 +554,9 @@ function reload(id, newComp) {
554
554
  "[HMR] Root or manually mounted instance modified. Full reload required."
555
555
  );
556
556
  }
557
+ if (instance.root.ce && instance !== instance.root) {
558
+ instance.root.ce._removeChildStyle(oldComp);
559
+ }
557
560
  }
558
561
  queuePostFlushCb(() => {
559
562
  hmrDirtyComponents.clear();
@@ -633,9 +636,7 @@ function devtoolsInitApp(app, version) {
633
636
  function devtoolsUnmountApp(app) {
634
637
  emit$1("app:unmount" /* APP_UNMOUNT */, app);
635
638
  }
636
- const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
637
- "component:added" /* COMPONENT_ADDED */
638
- );
639
+ const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
639
640
  const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
640
641
  const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
641
642
  "component:removed" /* COMPONENT_REMOVED */
@@ -659,12 +660,8 @@ function createDevtoolsComponentHook(hook) {
659
660
  );
660
661
  };
661
662
  }
662
- const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
663
- "perf:start" /* PERFORMANCE_START */
664
- );
665
- const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
666
- "perf:end" /* PERFORMANCE_END */
667
- );
663
+ const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
664
+ const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
668
665
  function createDevtoolsPerformanceHook(hook) {
669
666
  return (component, type, time) => {
670
667
  emit$1(hook, component.appContext.app, component.uid, component, type, time);
@@ -1567,6 +1564,7 @@ const logMismatchError = () => {
1567
1564
  const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
1568
1565
  const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
1569
1566
  const getContainerType = (container) => {
1567
+ if (container.nodeType !== 1) return void 0;
1570
1568
  if (isSVGContainer(container)) return "svg";
1571
1569
  if (isMathMLContainer(container)) return "mathml";
1572
1570
  return void 0;
@@ -1842,6 +1840,7 @@ Server rendered element contains more child nodes than client vdom.`
1842
1840
  }
1843
1841
  if (props) {
1844
1842
  {
1843
+ const isCustomElement = el.tagName.includes("-");
1845
1844
  for (const key in props) {
1846
1845
  if (// #11189 skip if this node has directives that have created hooks
1847
1846
  // as it could have mutated the DOM in any possible way
@@ -1849,7 +1848,7 @@ Server rendered element contains more child nodes than client vdom.`
1849
1848
  logMismatchError();
1850
1849
  }
1851
1850
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
1852
- key[0] === ".") {
1851
+ key[0] === "." || isCustomElement) {
1853
1852
  patchProp(el, key, null, props[key], void 0, parentComponent);
1854
1853
  }
1855
1854
  }
@@ -2174,24 +2173,19 @@ function isMismatchAllowed(el, allowedType) {
2174
2173
  }
2175
2174
  }
2176
2175
 
2177
- const hydrateOnIdle = () => (hydrate) => {
2178
- const id = requestIdleCallback(hydrate);
2176
+ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
2177
+ const id = requestIdleCallback(hydrate, { timeout });
2179
2178
  return () => cancelIdleCallback(id);
2180
2179
  };
2181
- const hydrateOnVisible = (margin = 0) => (hydrate, forEach) => {
2182
- const ob = new IntersectionObserver(
2183
- (entries) => {
2184
- for (const e of entries) {
2185
- if (!e.isIntersecting) continue;
2186
- ob.disconnect();
2187
- hydrate();
2188
- break;
2189
- }
2190
- },
2191
- {
2192
- rootMargin: shared.isString(margin) ? margin : margin + "px"
2180
+ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
2181
+ const ob = new IntersectionObserver((entries) => {
2182
+ for (const e of entries) {
2183
+ if (!e.isIntersecting) continue;
2184
+ ob.disconnect();
2185
+ hydrate();
2186
+ break;
2193
2187
  }
2194
- );
2188
+ }, opts);
2195
2189
  forEach((el) => ob.observe(el));
2196
2190
  return () => ob.disconnect();
2197
2191
  };
@@ -2499,14 +2493,14 @@ const KeepAliveImpl = {
2499
2493
  function pruneCache(filter) {
2500
2494
  cache.forEach((vnode, key) => {
2501
2495
  const name = getComponentName(vnode.type);
2502
- if (name && (!filter || !filter(name))) {
2496
+ if (name && !filter(name)) {
2503
2497
  pruneCacheEntry(key);
2504
2498
  }
2505
2499
  });
2506
2500
  }
2507
2501
  function pruneCacheEntry(key) {
2508
2502
  const cached = cache.get(key);
2509
- if (!current || !isSameVNodeType(cached, current)) {
2503
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
2510
2504
  unmount(cached);
2511
2505
  } else if (current) {
2512
2506
  resetShapeFlag(current);
@@ -2568,6 +2562,10 @@ const KeepAliveImpl = {
2568
2562
  return rawVNode;
2569
2563
  }
2570
2564
  let vnode = getInnerChild(rawVNode);
2565
+ if (vnode.type === Comment) {
2566
+ current = null;
2567
+ return vnode;
2568
+ }
2571
2569
  const comp = vnode.type;
2572
2570
  const name = getComponentName(
2573
2571
  isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
@@ -2614,6 +2612,7 @@ function matches(pattern, name) {
2614
2612
  } else if (shared.isString(pattern)) {
2615
2613
  return pattern.split(",").includes(name);
2616
2614
  } else if (shared.isRegExp(pattern)) {
2615
+ pattern.lastIndex = 0;
2617
2616
  return pattern.test(name);
2618
2617
  }
2619
2618
  return false;
@@ -2697,17 +2696,19 @@ const createHook = (lifecycle) => (hook, target = currentInstance) => {
2697
2696
  };
2698
2697
  const onBeforeMount = createHook("bm");
2699
2698
  const onMounted = createHook("m");
2700
- const onBeforeUpdate = createHook("bu");
2699
+ const onBeforeUpdate = createHook(
2700
+ "bu"
2701
+ );
2701
2702
  const onUpdated = createHook("u");
2702
- const onBeforeUnmount = createHook("bum");
2703
- const onUnmounted = createHook("um");
2704
- const onServerPrefetch = createHook("sp");
2705
- const onRenderTriggered = createHook(
2706
- "rtg"
2703
+ const onBeforeUnmount = createHook(
2704
+ "bum"
2707
2705
  );
2708
- const onRenderTracked = createHook(
2709
- "rtc"
2706
+ const onUnmounted = createHook("um");
2707
+ const onServerPrefetch = createHook(
2708
+ "sp"
2710
2709
  );
2710
+ const onRenderTriggered = createHook("rtg");
2711
+ const onRenderTracked = createHook("rtc");
2711
2712
  function onErrorCaptured(hook, target = currentInstance) {
2712
2713
  injectHook("ec", hook, target);
2713
2714
  }
@@ -2834,9 +2835,14 @@ function createSlots(slots, dynamicSlots) {
2834
2835
  }
2835
2836
 
2836
2837
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
2837
- if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
2838
+ if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
2838
2839
  if (name !== "default") props.name = name;
2839
- return createVNode("slot", props, fallback && fallback());
2840
+ return openBlock(), createBlock(
2841
+ Fragment,
2842
+ null,
2843
+ [createVNode("slot", props, fallback && fallback())],
2844
+ 64
2845
+ );
2840
2846
  }
2841
2847
  let slot = slots[name];
2842
2848
  if (slot && slot.length > 1) {
@@ -2909,6 +2915,7 @@ const publicPropertiesMap = (
2909
2915
  $refs: (i) => reactivity.shallowReadonly(i.refs) ,
2910
2916
  $parent: (i) => getPublicInstance(i.parent),
2911
2917
  $root: (i) => getPublicInstance(i.root),
2918
+ $host: (i) => i.ce,
2912
2919
  $emit: (i) => i.emit,
2913
2920
  $options: (i) => resolveMergedOptions(i) ,
2914
2921
  $forceUpdate: (i) => i.f || (i.f = () => {
@@ -3060,29 +3067,25 @@ const PublicInstanceProxyHandlers = {
3060
3067
  return Reflect.ownKeys(target);
3061
3068
  };
3062
3069
  }
3063
- const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ shared.extend(
3064
- {},
3065
- PublicInstanceProxyHandlers,
3066
- {
3067
- get(target, key) {
3068
- if (key === Symbol.unscopables) {
3069
- return;
3070
- }
3071
- return PublicInstanceProxyHandlers.get(target, key, target);
3072
- },
3073
- has(_, key) {
3074
- const has = key[0] !== "_" && !shared.isGloballyAllowed(key);
3075
- if (!has && PublicInstanceProxyHandlers.has(_, key)) {
3076
- warn$1(
3077
- `Property ${JSON.stringify(
3078
- key
3079
- )} should not start with _ which is a reserved prefix for Vue internals.`
3080
- );
3081
- }
3082
- return has;
3070
+ const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ shared.extend({}, PublicInstanceProxyHandlers, {
3071
+ get(target, key) {
3072
+ if (key === Symbol.unscopables) {
3073
+ return;
3083
3074
  }
3075
+ return PublicInstanceProxyHandlers.get(target, key, target);
3076
+ },
3077
+ has(_, key) {
3078
+ const has = key[0] !== "_" && !shared.isGloballyAllowed(key);
3079
+ if (!has && PublicInstanceProxyHandlers.has(_, key)) {
3080
+ warn$1(
3081
+ `Property ${JSON.stringify(
3082
+ key
3083
+ )} should not start with _ which is a reserved prefix for Vue internals.`
3084
+ );
3085
+ }
3086
+ return has;
3084
3087
  }
3085
- );
3088
+ });
3086
3089
  function createDevRenderContext(instance) {
3087
3090
  const target = {};
3088
3091
  Object.defineProperty(target, `_`, {
@@ -3784,7 +3787,7 @@ function createAppAPI(render, hydrate) {
3784
3787
  If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
3785
3788
  );
3786
3789
  }
3787
- const vnode = createVNode(rootComponent, rootProps);
3790
+ const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
3788
3791
  vnode.appContext = context;
3789
3792
  if (namespace === true) {
3790
3793
  namespace = "svg";
@@ -3886,7 +3889,7 @@ function provide(key, value) {
3886
3889
  function inject(key, defaultValue, treatDefaultAsFactory = false) {
3887
3890
  const instance = currentInstance || currentRenderingInstance;
3888
3891
  if (instance || currentApp) {
3889
- const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
3892
+ const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
3890
3893
  if (provides && key in provides) {
3891
3894
  return provides[key];
3892
3895
  } else if (arguments.length > 1) {
@@ -4091,6 +4094,9 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
4091
4094
  } else {
4092
4095
  value = defaultValue;
4093
4096
  }
4097
+ if (instance.ce) {
4098
+ instance.ce._setProp(key, value);
4099
+ }
4094
4100
  }
4095
4101
  if (opt[0 /* shouldCast */]) {
4096
4102
  if (isAbsent && !hasDefault) {
@@ -5089,8 +5095,8 @@ function baseCreateRenderer(options, createHydrationFns) {
5089
5095
  const componentUpdateFn = () => {
5090
5096
  if (!instance.isMounted) {
5091
5097
  let vnodeHook;
5092
- const { el, props, type } = initialVNode;
5093
- const { bm, m, parent } = instance;
5098
+ const { el, props } = initialVNode;
5099
+ const { bm, m, parent, root, type } = instance;
5094
5100
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
5095
5101
  toggleRecurse(instance, false);
5096
5102
  if (bm) {
@@ -5133,6 +5139,9 @@ function baseCreateRenderer(options, createHydrationFns) {
5133
5139
  hydrateSubTree();
5134
5140
  }
5135
5141
  } else {
5142
+ if (root.ce) {
5143
+ root.ce._injectChildStyle(type);
5144
+ }
5136
5145
  {
5137
5146
  startMeasure(instance, `render`);
5138
5147
  }
@@ -5806,13 +5815,13 @@ function baseCreateRenderer(options, createHydrationFns) {
5806
5815
  namespace
5807
5816
  );
5808
5817
  }
5818
+ container._vnode = vnode;
5809
5819
  if (!isFlushing) {
5810
5820
  isFlushing = true;
5811
5821
  flushPreFlushCbs();
5812
5822
  flushPostFlushCbs();
5813
5823
  isFlushing = false;
5814
5824
  }
5815
- container._vnode = vnode;
5816
5825
  };
5817
5826
  const internals = {
5818
5827
  p: patch,
@@ -5986,14 +5995,9 @@ function doWatch(source, cb, {
5986
5995
  const _cb = cb;
5987
5996
  cb = (...args) => {
5988
5997
  _cb(...args);
5989
- unwatch();
5998
+ watchHandle();
5990
5999
  };
5991
6000
  }
5992
- if (deep !== void 0 && typeof deep === "number") {
5993
- warn$1(
5994
- `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.`
5995
- );
5996
- }
5997
6001
  if (!cb) {
5998
6002
  if (immediate !== void 0) {
5999
6003
  warn$1(
@@ -6019,10 +6023,12 @@ function doWatch(source, cb, {
6019
6023
  );
6020
6024
  };
6021
6025
  const instance = currentInstance;
6022
- const reactiveGetter = (source2) => deep === true ? source2 : (
6023
- // for deep: false, only traverse root-level properties
6024
- traverse(source2, deep === false ? 1 : void 0)
6025
- );
6026
+ const reactiveGetter = (source2) => {
6027
+ if (deep) return source2;
6028
+ if (reactivity.isShallow(source2) || deep === false || deep === 0)
6029
+ return traverse(source2, 1);
6030
+ return traverse(source2);
6031
+ };
6026
6032
  let getter;
6027
6033
  let forceTrigger = false;
6028
6034
  let isMultiSource = false;
@@ -6068,7 +6074,8 @@ function doWatch(source, cb, {
6068
6074
  }
6069
6075
  if (cb && deep) {
6070
6076
  const baseGetter = getter;
6071
- getter = () => traverse(baseGetter());
6077
+ const depth = deep === true ? Infinity : deep;
6078
+ getter = () => traverse(baseGetter(), depth);
6072
6079
  }
6073
6080
  let cleanup;
6074
6081
  let onCleanup = (fn) => {
@@ -6093,7 +6100,12 @@ function doWatch(source, cb, {
6093
6100
  const ctx = useSSRContext();
6094
6101
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
6095
6102
  } else {
6096
- return shared.NOOP;
6103
+ const watchHandle2 = () => {
6104
+ };
6105
+ watchHandle2.stop = shared.NOOP;
6106
+ watchHandle2.resume = shared.NOOP;
6107
+ watchHandle2.pause = shared.NOOP;
6108
+ return watchHandle2;
6097
6109
  }
6098
6110
  }
6099
6111
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -6123,7 +6135,6 @@ function doWatch(source, cb, {
6123
6135
  const effect = new reactivity.ReactiveEffect(getter);
6124
6136
  let scheduler;
6125
6137
  if (flush === "sync") {
6126
- effect.flags |= 64;
6127
6138
  scheduler = job;
6128
6139
  } else if (flush === "post") {
6129
6140
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
@@ -6134,12 +6145,15 @@ function doWatch(source, cb, {
6134
6145
  }
6135
6146
  effect.scheduler = scheduler;
6136
6147
  const scope = reactivity.getCurrentScope();
6137
- const unwatch = () => {
6148
+ const watchHandle = () => {
6138
6149
  effect.stop();
6139
6150
  if (scope) {
6140
6151
  shared.remove(scope.effects, effect);
6141
6152
  }
6142
6153
  };
6154
+ watchHandle.pause = effect.pause.bind(effect);
6155
+ watchHandle.resume = effect.resume.bind(effect);
6156
+ watchHandle.stop = watchHandle;
6143
6157
  {
6144
6158
  effect.onTrack = onTrack;
6145
6159
  effect.onTrigger = onTrigger;
@@ -6158,8 +6172,8 @@ function doWatch(source, cb, {
6158
6172
  } else {
6159
6173
  effect.run();
6160
6174
  }
6161
- if (ssrCleanup) ssrCleanup.push(unwatch);
6162
- return unwatch;
6175
+ if (ssrCleanup) ssrCleanup.push(watchHandle);
6176
+ return watchHandle;
6163
6177
  }
6164
6178
  function instanceWatch(source, value, options) {
6165
6179
  const publicThis = this.proxy;
@@ -6249,7 +6263,8 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
6249
6263
  return options.get ? options.get(localValue) : localValue;
6250
6264
  },
6251
6265
  set(value) {
6252
- if (!shared.hasChanged(value, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
6266
+ const emittedValue = options.set ? options.set(value) : value;
6267
+ if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
6253
6268
  return;
6254
6269
  }
6255
6270
  const rawProps = i.vnode.props;
@@ -6258,7 +6273,6 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
6258
6273
  localValue = value;
6259
6274
  trigger();
6260
6275
  }
6261
- const emittedValue = options.set ? options.set(value) : value;
6262
6276
  i.emit(`update:${name}`, emittedValue);
6263
6277
  if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
6264
6278
  trigger();
@@ -6296,9 +6310,9 @@ function emit(instance, event, ...rawArgs) {
6296
6310
  } = instance;
6297
6311
  if (emitsOptions) {
6298
6312
  if (!(event in emitsOptions) && true) {
6299
- if (!propsOptions || !(shared.toHandlerKey(event) in propsOptions)) {
6313
+ if (!propsOptions || !(shared.toHandlerKey(shared.camelize(event)) in propsOptions)) {
6300
6314
  warn$1(
6301
- `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${shared.toHandlerKey(event)}" prop.`
6315
+ `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${shared.toHandlerKey(shared.camelize(event))}" prop.`
6302
6316
  );
6303
6317
  }
6304
6318
  } else {
@@ -8122,11 +8136,16 @@ function useTemplateRef(key) {
8122
8136
  const r = reactivity.shallowRef(null);
8123
8137
  if (i) {
8124
8138
  const refs = i.refs === shared.EMPTY_OBJ ? i.refs = {} : i.refs;
8125
- Object.defineProperty(refs, key, {
8126
- enumerable: true,
8127
- get: () => r.value,
8128
- set: (val) => r.value = val
8129
- });
8139
+ let desc;
8140
+ if ((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable) {
8141
+ warn$1(`useTemplateRef('${key}') already exists.`);
8142
+ } else {
8143
+ Object.defineProperty(refs, key, {
8144
+ enumerable: true,
8145
+ get: () => r.value,
8146
+ set: (val) => r.value = val
8147
+ });
8148
+ }
8130
8149
  } else {
8131
8150
  warn$1(
8132
8151
  `useTemplateRef() is called when there is no active component instance to be associated with.`
@@ -8360,7 +8379,7 @@ function isMemoSame(cached, memo) {
8360
8379
  return true;
8361
8380
  }
8362
8381
 
8363
- const version = "3.5.0-alpha.5";
8382
+ const version = "3.5.0-beta.2";
8364
8383
  const warn = warn$1 ;
8365
8384
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8366
8385
  const devtools = devtools$1 ;
@@ -8372,7 +8391,8 @@ const _ssrUtils = {
8372
8391
  setCurrentRenderingInstance,
8373
8392
  isVNode: isVNode,
8374
8393
  normalizeVNode,
8375
- getComponentPublicInstance
8394
+ getComponentPublicInstance,
8395
+ ensureValidVNode
8376
8396
  };
8377
8397
  const ssrUtils = _ssrUtils ;
8378
8398
  const resolveFilter = null;