@vue/runtime-core 3.5.0-alpha.5 → 3.5.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.1
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);
@@ -1842,6 +1839,7 @@ Server rendered element contains more child nodes than client vdom.`
1842
1839
  }
1843
1840
  if (props) {
1844
1841
  {
1842
+ const isCustomElement = el.tagName.includes("-");
1845
1843
  for (const key in props) {
1846
1844
  if (// #11189 skip if this node has directives that have created hooks
1847
1845
  // as it could have mutated the DOM in any possible way
@@ -1849,7 +1847,7 @@ Server rendered element contains more child nodes than client vdom.`
1849
1847
  logMismatchError();
1850
1848
  }
1851
1849
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
1852
- key[0] === ".") {
1850
+ key[0] === "." || isCustomElement) {
1853
1851
  patchProp(el, key, null, props[key], void 0, parentComponent);
1854
1852
  }
1855
1853
  }
@@ -2174,24 +2172,19 @@ function isMismatchAllowed(el, allowedType) {
2174
2172
  }
2175
2173
  }
2176
2174
 
2177
- const hydrateOnIdle = () => (hydrate) => {
2178
- const id = requestIdleCallback(hydrate);
2175
+ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
2176
+ const id = requestIdleCallback(hydrate, { timeout });
2179
2177
  return () => cancelIdleCallback(id);
2180
2178
  };
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"
2179
+ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
2180
+ const ob = new IntersectionObserver((entries) => {
2181
+ for (const e of entries) {
2182
+ if (!e.isIntersecting) continue;
2183
+ ob.disconnect();
2184
+ hydrate();
2185
+ break;
2193
2186
  }
2194
- );
2187
+ }, opts);
2195
2188
  forEach((el) => ob.observe(el));
2196
2189
  return () => ob.disconnect();
2197
2190
  };
@@ -2506,7 +2499,7 @@ const KeepAliveImpl = {
2506
2499
  }
2507
2500
  function pruneCacheEntry(key) {
2508
2501
  const cached = cache.get(key);
2509
- if (!current || !isSameVNodeType(cached, current)) {
2502
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
2510
2503
  unmount(cached);
2511
2504
  } else if (current) {
2512
2505
  resetShapeFlag(current);
@@ -2568,6 +2561,10 @@ const KeepAliveImpl = {
2568
2561
  return rawVNode;
2569
2562
  }
2570
2563
  let vnode = getInnerChild(rawVNode);
2564
+ if (vnode.type === Comment) {
2565
+ current = null;
2566
+ return vnode;
2567
+ }
2571
2568
  const comp = vnode.type;
2572
2569
  const name = getComponentName(
2573
2570
  isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
@@ -2697,17 +2694,19 @@ const createHook = (lifecycle) => (hook, target = currentInstance) => {
2697
2694
  };
2698
2695
  const onBeforeMount = createHook("bm");
2699
2696
  const onMounted = createHook("m");
2700
- const onBeforeUpdate = createHook("bu");
2697
+ const onBeforeUpdate = createHook(
2698
+ "bu"
2699
+ );
2701
2700
  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"
2701
+ const onBeforeUnmount = createHook(
2702
+ "bum"
2707
2703
  );
2708
- const onRenderTracked = createHook(
2709
- "rtc"
2704
+ const onUnmounted = createHook("um");
2705
+ const onServerPrefetch = createHook(
2706
+ "sp"
2710
2707
  );
2708
+ const onRenderTriggered = createHook("rtg");
2709
+ const onRenderTracked = createHook("rtc");
2711
2710
  function onErrorCaptured(hook, target = currentInstance) {
2712
2711
  injectHook("ec", hook, target);
2713
2712
  }
@@ -2834,9 +2833,14 @@ function createSlots(slots, dynamicSlots) {
2834
2833
  }
2835
2834
 
2836
2835
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
2837
- if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
2836
+ if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
2838
2837
  if (name !== "default") props.name = name;
2839
- return createVNode("slot", props, fallback && fallback());
2838
+ return openBlock(), createBlock(
2839
+ Fragment,
2840
+ null,
2841
+ [createVNode("slot", props, fallback && fallback())],
2842
+ 64
2843
+ );
2840
2844
  }
2841
2845
  let slot = slots[name];
2842
2846
  if (slot && slot.length > 1) {
@@ -2909,6 +2913,7 @@ const publicPropertiesMap = (
2909
2913
  $refs: (i) => reactivity.shallowReadonly(i.refs) ,
2910
2914
  $parent: (i) => getPublicInstance(i.parent),
2911
2915
  $root: (i) => getPublicInstance(i.root),
2916
+ $host: (i) => i.ce,
2912
2917
  $emit: (i) => i.emit,
2913
2918
  $options: (i) => resolveMergedOptions(i) ,
2914
2919
  $forceUpdate: (i) => i.f || (i.f = () => {
@@ -3060,29 +3065,25 @@ const PublicInstanceProxyHandlers = {
3060
3065
  return Reflect.ownKeys(target);
3061
3066
  };
3062
3067
  }
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;
3068
+ const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ shared.extend({}, PublicInstanceProxyHandlers, {
3069
+ get(target, key) {
3070
+ if (key === Symbol.unscopables) {
3071
+ return;
3083
3072
  }
3073
+ return PublicInstanceProxyHandlers.get(target, key, target);
3074
+ },
3075
+ has(_, key) {
3076
+ const has = key[0] !== "_" && !shared.isGloballyAllowed(key);
3077
+ if (!has && PublicInstanceProxyHandlers.has(_, key)) {
3078
+ warn$1(
3079
+ `Property ${JSON.stringify(
3080
+ key
3081
+ )} should not start with _ which is a reserved prefix for Vue internals.`
3082
+ );
3083
+ }
3084
+ return has;
3084
3085
  }
3085
- );
3086
+ });
3086
3087
  function createDevRenderContext(instance) {
3087
3088
  const target = {};
3088
3089
  Object.defineProperty(target, `_`, {
@@ -3784,7 +3785,7 @@ function createAppAPI(render, hydrate) {
3784
3785
  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
3786
  );
3786
3787
  }
3787
- const vnode = createVNode(rootComponent, rootProps);
3788
+ const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
3788
3789
  vnode.appContext = context;
3789
3790
  if (namespace === true) {
3790
3791
  namespace = "svg";
@@ -3886,7 +3887,7 @@ function provide(key, value) {
3886
3887
  function inject(key, defaultValue, treatDefaultAsFactory = false) {
3887
3888
  const instance = currentInstance || currentRenderingInstance;
3888
3889
  if (instance || currentApp) {
3889
- const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
3890
+ const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
3890
3891
  if (provides && key in provides) {
3891
3892
  return provides[key];
3892
3893
  } else if (arguments.length > 1) {
@@ -4091,6 +4092,9 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
4091
4092
  } else {
4092
4093
  value = defaultValue;
4093
4094
  }
4095
+ if (instance.ce) {
4096
+ instance.ce._setProp(key, value);
4097
+ }
4094
4098
  }
4095
4099
  if (opt[0 /* shouldCast */]) {
4096
4100
  if (isAbsent && !hasDefault) {
@@ -5089,8 +5093,8 @@ function baseCreateRenderer(options, createHydrationFns) {
5089
5093
  const componentUpdateFn = () => {
5090
5094
  if (!instance.isMounted) {
5091
5095
  let vnodeHook;
5092
- const { el, props, type } = initialVNode;
5093
- const { bm, m, parent } = instance;
5096
+ const { el, props } = initialVNode;
5097
+ const { bm, m, parent, root, type } = instance;
5094
5098
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
5095
5099
  toggleRecurse(instance, false);
5096
5100
  if (bm) {
@@ -5133,6 +5137,9 @@ function baseCreateRenderer(options, createHydrationFns) {
5133
5137
  hydrateSubTree();
5134
5138
  }
5135
5139
  } else {
5140
+ if (root.ce) {
5141
+ root.ce._injectChildStyle(type);
5142
+ }
5136
5143
  {
5137
5144
  startMeasure(instance, `render`);
5138
5145
  }
@@ -5806,13 +5813,13 @@ function baseCreateRenderer(options, createHydrationFns) {
5806
5813
  namespace
5807
5814
  );
5808
5815
  }
5816
+ container._vnode = vnode;
5809
5817
  if (!isFlushing) {
5810
5818
  isFlushing = true;
5811
5819
  flushPreFlushCbs();
5812
5820
  flushPostFlushCbs();
5813
5821
  isFlushing = false;
5814
5822
  }
5815
- container._vnode = vnode;
5816
5823
  };
5817
5824
  const internals = {
5818
5825
  p: patch,
@@ -5986,14 +5993,9 @@ function doWatch(source, cb, {
5986
5993
  const _cb = cb;
5987
5994
  cb = (...args) => {
5988
5995
  _cb(...args);
5989
- unwatch();
5996
+ watchHandle();
5990
5997
  };
5991
5998
  }
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
5999
  if (!cb) {
5998
6000
  if (immediate !== void 0) {
5999
6001
  warn$1(
@@ -6019,10 +6021,12 @@ function doWatch(source, cb, {
6019
6021
  );
6020
6022
  };
6021
6023
  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
- );
6024
+ const reactiveGetter = (source2) => {
6025
+ if (deep) return source2;
6026
+ if (reactivity.isShallow(source2) || deep === false || deep === 0)
6027
+ return traverse(source2, 1);
6028
+ return traverse(source2);
6029
+ };
6026
6030
  let getter;
6027
6031
  let forceTrigger = false;
6028
6032
  let isMultiSource = false;
@@ -6068,7 +6072,8 @@ function doWatch(source, cb, {
6068
6072
  }
6069
6073
  if (cb && deep) {
6070
6074
  const baseGetter = getter;
6071
- getter = () => traverse(baseGetter());
6075
+ const depth = deep === true ? Infinity : deep;
6076
+ getter = () => traverse(baseGetter(), depth);
6072
6077
  }
6073
6078
  let cleanup;
6074
6079
  let onCleanup = (fn) => {
@@ -6093,7 +6098,12 @@ function doWatch(source, cb, {
6093
6098
  const ctx = useSSRContext();
6094
6099
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
6095
6100
  } else {
6096
- return shared.NOOP;
6101
+ const watchHandle2 = () => {
6102
+ };
6103
+ watchHandle2.stop = shared.NOOP;
6104
+ watchHandle2.resume = shared.NOOP;
6105
+ watchHandle2.pause = shared.NOOP;
6106
+ return watchHandle2;
6097
6107
  }
6098
6108
  }
6099
6109
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -6134,12 +6144,15 @@ function doWatch(source, cb, {
6134
6144
  }
6135
6145
  effect.scheduler = scheduler;
6136
6146
  const scope = reactivity.getCurrentScope();
6137
- const unwatch = () => {
6147
+ const watchHandle = () => {
6138
6148
  effect.stop();
6139
6149
  if (scope) {
6140
6150
  shared.remove(scope.effects, effect);
6141
6151
  }
6142
6152
  };
6153
+ watchHandle.pause = effect.pause.bind(effect);
6154
+ watchHandle.resume = effect.resume.bind(effect);
6155
+ watchHandle.stop = watchHandle;
6143
6156
  {
6144
6157
  effect.onTrack = onTrack;
6145
6158
  effect.onTrigger = onTrigger;
@@ -6158,8 +6171,8 @@ function doWatch(source, cb, {
6158
6171
  } else {
6159
6172
  effect.run();
6160
6173
  }
6161
- if (ssrCleanup) ssrCleanup.push(unwatch);
6162
- return unwatch;
6174
+ if (ssrCleanup) ssrCleanup.push(watchHandle);
6175
+ return watchHandle;
6163
6176
  }
6164
6177
  function instanceWatch(source, value, options) {
6165
6178
  const publicThis = this.proxy;
@@ -6249,7 +6262,8 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
6249
6262
  return options.get ? options.get(localValue) : localValue;
6250
6263
  },
6251
6264
  set(value) {
6252
- if (!shared.hasChanged(value, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
6265
+ const emittedValue = options.set ? options.set(value) : value;
6266
+ if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
6253
6267
  return;
6254
6268
  }
6255
6269
  const rawProps = i.vnode.props;
@@ -6258,7 +6272,6 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
6258
6272
  localValue = value;
6259
6273
  trigger();
6260
6274
  }
6261
- const emittedValue = options.set ? options.set(value) : value;
6262
6275
  i.emit(`update:${name}`, emittedValue);
6263
6276
  if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
6264
6277
  trigger();
@@ -6296,9 +6309,9 @@ function emit(instance, event, ...rawArgs) {
6296
6309
  } = instance;
6297
6310
  if (emitsOptions) {
6298
6311
  if (!(event in emitsOptions) && true) {
6299
- if (!propsOptions || !(shared.toHandlerKey(event) in propsOptions)) {
6312
+ if (!propsOptions || !(shared.toHandlerKey(shared.camelize(event)) in propsOptions)) {
6300
6313
  warn$1(
6301
- `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${shared.toHandlerKey(event)}" prop.`
6314
+ `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${shared.toHandlerKey(shared.camelize(event))}" prop.`
6302
6315
  );
6303
6316
  }
6304
6317
  } else {
@@ -8122,11 +8135,16 @@ function useTemplateRef(key) {
8122
8135
  const r = reactivity.shallowRef(null);
8123
8136
  if (i) {
8124
8137
  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
- });
8138
+ let desc;
8139
+ if ((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable) {
8140
+ warn$1(`useTemplateRef('${key}') already exists.`);
8141
+ } else {
8142
+ Object.defineProperty(refs, key, {
8143
+ enumerable: true,
8144
+ get: () => r.value,
8145
+ set: (val) => r.value = val
8146
+ });
8147
+ }
8130
8148
  } else {
8131
8149
  warn$1(
8132
8150
  `useTemplateRef() is called when there is no active component instance to be associated with.`
@@ -8360,7 +8378,7 @@ function isMemoSame(cached, memo) {
8360
8378
  return true;
8361
8379
  }
8362
8380
 
8363
- const version = "3.5.0-alpha.5";
8381
+ const version = "3.5.0-beta.1";
8364
8382
  const warn = warn$1 ;
8365
8383
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8366
8384
  const devtools = devtools$1 ;
@@ -8372,7 +8390,8 @@ const _ssrUtils = {
8372
8390
  setCurrentRenderingInstance,
8373
8391
  isVNode: isVNode,
8374
8392
  normalizeVNode,
8375
- getComponentPublicInstance
8393
+ getComponentPublicInstance,
8394
+ ensureValidVNode
8376
8395
  };
8377
8396
  const ssrUtils = _ssrUtils ;
8378
8397
  const resolveFilter = null;