@vue/runtime-core 3.1.0 → 3.1.4

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.
@@ -120,6 +120,7 @@ function formatProp(key, value, raw) {
120
120
  }
121
121
 
122
122
  const ErrorTypeStrings = {
123
+ ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
123
124
  ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
124
125
  ["c" /* CREATED */]: 'created hook',
125
126
  ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
@@ -985,11 +986,12 @@ function emit(instance, event, ...rawArgs) {
985
986
  const onceHandler = props[handlerName + `Once`];
986
987
  if (onceHandler) {
987
988
  if (!instance.emitted) {
988
- (instance.emitted = {})[handlerName] = true;
989
+ instance.emitted = {};
989
990
  }
990
991
  else if (instance.emitted[handlerName]) {
991
992
  return;
992
993
  }
994
+ instance.emitted[handlerName] = true;
993
995
  callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
994
996
  }
995
997
  }
@@ -1460,6 +1462,12 @@ const SuspenseImpl = {
1460
1462
  // Force-casted public typing for h and TSX props inference
1461
1463
  const Suspense = (SuspenseImpl
1462
1464
  );
1465
+ function triggerEvent(vnode, name) {
1466
+ const eventListener = vnode.props && vnode.props[name];
1467
+ if (shared.isFunction(eventListener)) {
1468
+ eventListener();
1469
+ }
1470
+ }
1463
1471
  function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
1464
1472
  const { p: patch, o: { createElement } } = rendererInternals;
1465
1473
  const hiddenContainer = createElement('div');
@@ -1469,6 +1477,9 @@ function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense
1469
1477
  // now check if we have encountered any async deps
1470
1478
  if (suspense.deps > 0) {
1471
1479
  // has async
1480
+ // invoke @fallback event
1481
+ triggerEvent(vnode, 'onPending');
1482
+ triggerEvent(vnode, 'onFallback');
1472
1483
  // mount the fallback tree
1473
1484
  patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
1474
1485
  isSVG, slotScopeIds);
@@ -1556,10 +1567,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotSc
1556
1567
  else {
1557
1568
  // root node toggled
1558
1569
  // invoke @pending event
1559
- const onPending = n2.props && n2.props.onPending;
1560
- if (shared.isFunction(onPending)) {
1561
- onPending();
1562
- }
1570
+ triggerEvent(n2, 'onPending');
1563
1571
  // mount pending branch in off-dom container
1564
1572
  suspense.pendingBranch = newBranch;
1565
1573
  suspense.pendingId++;
@@ -1672,10 +1680,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1672
1680
  }
1673
1681
  suspense.effects = [];
1674
1682
  // invoke @resolve event
1675
- const onResolve = vnode.props && vnode.props.onResolve;
1676
- if (shared.isFunction(onResolve)) {
1677
- onResolve();
1678
- }
1683
+ triggerEvent(vnode, 'onResolve');
1679
1684
  },
1680
1685
  fallback(fallbackVNode) {
1681
1686
  if (!suspense.pendingBranch) {
@@ -1683,10 +1688,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1683
1688
  }
1684
1689
  const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
1685
1690
  // invoke @fallback event
1686
- const onFallback = vnode.props && vnode.props.onFallback;
1687
- if (shared.isFunction(onFallback)) {
1688
- onFallback();
1689
- }
1691
+ triggerEvent(vnode, 'onFallback');
1690
1692
  const anchor = next(activeBranch);
1691
1693
  const mountFallback = () => {
1692
1694
  if (!suspense.isInFallback) {
@@ -1701,11 +1703,11 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1701
1703
  if (delayEnter) {
1702
1704
  activeBranch.transition.afterLeave = mountFallback;
1703
1705
  }
1706
+ suspense.isInFallback = true;
1704
1707
  // unmount current active branch
1705
1708
  unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
1706
1709
  true // shouldRemove
1707
1710
  );
1708
- suspense.isInFallback = true;
1709
1711
  if (!delayEnter) {
1710
1712
  mountFallback();
1711
1713
  }
@@ -1900,7 +1902,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
1900
1902
  }
1901
1903
  else if (arguments.length > 1) {
1902
1904
  return treatDefaultAsFactory && shared.isFunction(defaultValue)
1903
- ? defaultValue()
1905
+ ? defaultValue.call(instance.proxy)
1904
1906
  : defaultValue;
1905
1907
  }
1906
1908
  else {
@@ -3133,13 +3135,16 @@ function applyOptions(instance) {
3133
3135
  registerLifecycleHook(onServerPrefetch, serverPrefetch);
3134
3136
  if (shared.isArray(expose)) {
3135
3137
  if (expose.length) {
3136
- const exposed = instance.exposed || (instance.exposed = reactivity.proxyRefs({}));
3138
+ const exposed = instance.exposed || (instance.exposed = {});
3137
3139
  expose.forEach(key => {
3138
- exposed[key] = reactivity.toRef(publicThis, key);
3140
+ Object.defineProperty(exposed, key, {
3141
+ get: () => publicThis[key],
3142
+ set: val => (publicThis[key] = val)
3143
+ });
3139
3144
  });
3140
3145
  }
3141
3146
  else if (!instance.exposed) {
3142
- instance.exposed = shared.EMPTY_OBJ;
3147
+ instance.exposed = {};
3143
3148
  }
3144
3149
  }
3145
3150
  // options that are handled when creating the instance but also need to be
@@ -3276,25 +3281,23 @@ const internalOptionMergeStrats = {
3276
3281
  methods: mergeObjectOptions,
3277
3282
  computed: mergeObjectOptions,
3278
3283
  // lifecycle
3279
- beforeCreate: mergeHook,
3280
- created: mergeHook,
3281
- beforeMount: mergeHook,
3282
- mounted: mergeHook,
3283
- beforeUpdate: mergeHook,
3284
- updated: mergeHook,
3285
- beforeDestroy: mergeHook,
3286
- destroyed: mergeHook,
3287
- activated: mergeHook,
3288
- deactivated: mergeHook,
3289
- errorCaptured: mergeHook,
3290
- serverPrefetch: mergeHook,
3284
+ beforeCreate: mergeAsArray,
3285
+ created: mergeAsArray,
3286
+ beforeMount: mergeAsArray,
3287
+ mounted: mergeAsArray,
3288
+ beforeUpdate: mergeAsArray,
3289
+ updated: mergeAsArray,
3290
+ beforeDestroy: mergeAsArray,
3291
+ destroyed: mergeAsArray,
3292
+ activated: mergeAsArray,
3293
+ deactivated: mergeAsArray,
3294
+ errorCaptured: mergeAsArray,
3295
+ serverPrefetch: mergeAsArray,
3291
3296
  // assets
3292
3297
  components: mergeObjectOptions,
3293
3298
  directives: mergeObjectOptions,
3294
- // watch has special merge behavior in v2, but isn't actually needed in v3.
3295
- // since we are only exposing these for compat and nobody should be relying
3296
- // on the watch-specific behavior, just expose the object merge strat.
3297
- watch: mergeObjectOptions,
3299
+ // watch
3300
+ watch: mergeWatchOptions,
3298
3301
  // provide / inject
3299
3302
  provide: mergeDataFn,
3300
3303
  inject: mergeInject
@@ -3323,11 +3326,22 @@ function normalizeInject(raw) {
3323
3326
  }
3324
3327
  return raw;
3325
3328
  }
3326
- function mergeHook(to, from) {
3329
+ function mergeAsArray(to, from) {
3327
3330
  return to ? [...new Set([].concat(to, from))] : from;
3328
3331
  }
3329
3332
  function mergeObjectOptions(to, from) {
3330
3333
  return to ? shared.extend(shared.extend(Object.create(null), to), from) : from;
3334
+ }
3335
+ function mergeWatchOptions(to, from) {
3336
+ if (!to)
3337
+ return from;
3338
+ if (!from)
3339
+ return to;
3340
+ const merged = shared.extend(Object.create(null), to);
3341
+ for (const key in from) {
3342
+ merged[key] = mergeAsArray(to[key], from[key]);
3343
+ }
3344
+ return merged;
3331
3345
  }
3332
3346
 
3333
3347
  function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
@@ -3984,6 +3998,7 @@ function createAppAPI(render, hydrate) {
3984
3998
  _props: rootProps,
3985
3999
  _container: null,
3986
4000
  _context: context,
4001
+ _instance: null,
3987
4002
  version,
3988
4003
  get config() {
3989
4004
  return context.config;
@@ -4071,6 +4086,7 @@ function createAppAPI(render, hydrate) {
4071
4086
  app._container = rootContainer;
4072
4087
  rootContainer.__vue_app__ = app;
4073
4088
  {
4089
+ app._instance = vnode.component;
4074
4090
  devtoolsInitApp(app, version);
4075
4091
  }
4076
4092
  return vnode.component.proxy;
@@ -4086,6 +4102,7 @@ function createAppAPI(render, hydrate) {
4086
4102
  if (isMounted) {
4087
4103
  render(null, app._container);
4088
4104
  {
4105
+ app._instance = null;
4089
4106
  devtoolsUnmountApp(app);
4090
4107
  }
4091
4108
  delete app._container.__vue_app__;
@@ -4122,8 +4139,9 @@ function createHydrationFunctions(rendererInternals) {
4122
4139
  const hydrate = (vnode, container) => {
4123
4140
  if (!container.hasChildNodes()) {
4124
4141
  warn(`Attempting to hydrate existing markup but container is empty. ` +
4125
- `Performing full mount instead.`);
4142
+ `Performing full mount instead.`);
4126
4143
  patch(null, vnode, container);
4144
+ flushPostFlushCbs();
4127
4145
  return;
4128
4146
  }
4129
4147
  hasMismatch = false;
@@ -4260,19 +4278,24 @@ function createHydrationFunctions(rendererInternals) {
4260
4278
  };
4261
4279
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4262
4280
  optimized = optimized || !!vnode.dynamicChildren;
4263
- const { props, patchFlag, shapeFlag, dirs } = vnode;
4281
+ const { type, props, patchFlag, shapeFlag, dirs } = vnode;
4282
+ // #4006 for form elements with non-string v-model value bindings
4283
+ // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
4284
+ const forcePatchValue = (type === 'input' && dirs) || type === 'option';
4264
4285
  // skip props & children if this is hoisted static nodes
4265
- if (patchFlag !== -1 /* HOISTED */) {
4286
+ if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
4266
4287
  if (dirs) {
4267
4288
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
4268
4289
  }
4269
4290
  // props
4270
4291
  if (props) {
4271
- if (!optimized ||
4292
+ if (forcePatchValue ||
4293
+ !optimized ||
4272
4294
  (patchFlag & 16 /* FULL_PROPS */ ||
4273
4295
  patchFlag & 32 /* HYDRATE_EVENTS */)) {
4274
4296
  for (const key in props) {
4275
- if (!shared.isReservedProp(key) && shared.isOn(key)) {
4297
+ if ((forcePatchValue && key.endsWith('value')) ||
4298
+ (shared.isOn(key) && !shared.isReservedProp(key))) {
4276
4299
  patchProp(el, key, null, props[key]);
4277
4300
  }
4278
4301
  }
@@ -4486,7 +4509,7 @@ const setRef = (rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) =>
4486
4509
  return;
4487
4510
  }
4488
4511
  const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
4489
- ? vnode.component.exposed || vnode.component.proxy
4512
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
4490
4513
  : vnode.el;
4491
4514
  const value = isUnmount ? null : refValue;
4492
4515
  const { i: owner, r: ref } = rawRef;
@@ -4656,7 +4679,19 @@ function baseCreateRenderer(options, createHydrationFns) {
4656
4679
  }
4657
4680
  };
4658
4681
  const mountStaticNode = (n2, container, anchor, isSVG) => {
4659
- [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
4682
+ // static nodes are only present when used with compiler-dom/runtime-dom
4683
+ // which guarantees presence of hostInsertStaticContent.
4684
+ const nodes = hostInsertStaticContent(n2.children, container, anchor, isSVG,
4685
+ // pass cached nodes if the static node is being mounted multiple times
4686
+ // so that runtime-dom can simply cloneNode() instead of inserting new
4687
+ // HTML
4688
+ n2.staticCache);
4689
+ // first mount - this is the orignal hoisted vnode. cache nodes.
4690
+ if (!n2.el) {
4691
+ n2.staticCache = nodes;
4692
+ }
4693
+ n2.el = nodes[0];
4694
+ n2.anchor = nodes[nodes.length - 1];
4660
4695
  };
4661
4696
  /**
4662
4697
  * Dev / HMR only
@@ -6288,7 +6323,6 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
6288
6323
  anchor: null,
6289
6324
  target: null,
6290
6325
  targetAnchor: null,
6291
- staticCount: 0,
6292
6326
  shapeFlag,
6293
6327
  patchFlag,
6294
6328
  dynamicProps,
@@ -6350,6 +6384,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
6350
6384
  target: vnode.target,
6351
6385
  targetAnchor: vnode.targetAnchor,
6352
6386
  staticCount: vnode.staticCount,
6387
+ staticCache: vnode.staticCache,
6353
6388
  shapeFlag: vnode.shapeFlag,
6354
6389
  // if the vnode is cloned with extra props, we can no longer assume its
6355
6390
  // existing patch flag to be reliable and need to add the FULL_PROPS flag.
@@ -6665,7 +6700,7 @@ const getPublicInstance = (i) => {
6665
6700
  if (!i)
6666
6701
  return null;
6667
6702
  if (isStatefulComponent(i))
6668
- return i.exposed ? i.exposed : i.proxy;
6703
+ return getExposeProxy(i) || i.proxy;
6669
6704
  return getPublicInstance(i.parent);
6670
6705
  };
6671
6706
  const publicPropertiesMap = shared.extend(Object.create(null), {
@@ -6687,14 +6722,19 @@ const publicPropertiesMap = shared.extend(Object.create(null), {
6687
6722
  const PublicInstanceProxyHandlers = {
6688
6723
  get({ _: instance }, key) {
6689
6724
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
6690
- // let @vue/reactivity know it should never observe Vue public instances.
6691
- if (key === "__v_skip" /* SKIP */) {
6692
- return true;
6693
- }
6694
6725
  // for internal formatters to know that this is a Vue instance
6695
6726
  if (key === '__isVue') {
6696
6727
  return true;
6697
6728
  }
6729
+ // prioritize <script setup> bindings during dev.
6730
+ // this allows even properties that start with _ or $ to be used - so that
6731
+ // it aligns with the production behavior where the render fn is inlined and
6732
+ // indeed has access to all declared variables.
6733
+ if (setupState !== shared.EMPTY_OBJ &&
6734
+ setupState.__isScriptSetup &&
6735
+ shared.hasOwn(setupState, key)) {
6736
+ return setupState[key];
6737
+ }
6698
6738
  // data / props / ctx
6699
6739
  // This getter gets called for every property access on the render context
6700
6740
  // during render and is a major hotspot. The most expensive part of this
@@ -6894,7 +6934,7 @@ function exposePropsOnRenderContext(instance) {
6894
6934
  function exposeSetupStateOnRenderContext(instance) {
6895
6935
  const { ctx, setupState } = instance;
6896
6936
  Object.keys(reactivity.toRaw(setupState)).forEach(key => {
6897
- if (key[0] === '$' || key[0] === '_') {
6937
+ if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
6898
6938
  warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
6899
6939
  `which are reserved prefixes for Vue internals.`);
6900
6940
  return;
@@ -6927,6 +6967,7 @@ function createComponentInstance(vnode, parent, suspense) {
6927
6967
  render: null,
6928
6968
  proxy: null,
6929
6969
  exposed: null,
6970
+ exposeProxy: null,
6930
6971
  withProxy: null,
6931
6972
  effects: null,
6932
6973
  provides: parent ? parent.provides : Object.create(appContext.provides),
@@ -7042,7 +7083,7 @@ function setupStatefulComponent(instance, isSSR) {
7042
7083
  instance.accessCache = Object.create(null);
7043
7084
  // 1. create public instance / render proxy
7044
7085
  // also mark it raw so it's never observed
7045
- instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
7086
+ instance.proxy = reactivity.markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
7046
7087
  {
7047
7088
  exposePropsOnRenderContext(instance);
7048
7089
  }
@@ -7057,6 +7098,10 @@ function setupStatefulComponent(instance, isSSR) {
7057
7098
  reactivity.resetTracking();
7058
7099
  currentInstance = null;
7059
7100
  if (shared.isPromise(setupResult)) {
7101
+ const unsetInstance = () => {
7102
+ currentInstance = null;
7103
+ };
7104
+ setupResult.then(unsetInstance, unsetInstance);
7060
7105
  if (isSSR) {
7061
7106
  // return the promise so server-renderer can wait on it
7062
7107
  return setupResult
@@ -7186,11 +7231,9 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
7186
7231
  }
7187
7232
  }
7188
7233
  }
7189
- const attrHandlers = {
7234
+ const attrDevProxyHandlers = {
7190
7235
  get: (target, key) => {
7191
- {
7192
- markAttrsAccessed();
7193
- }
7236
+ markAttrsAccessed();
7194
7237
  return target[key];
7195
7238
  },
7196
7239
  set: () => {
@@ -7207,14 +7250,15 @@ function createSetupContext(instance) {
7207
7250
  if (instance.exposed) {
7208
7251
  warn(`expose() should be called only once per setup().`);
7209
7252
  }
7210
- instance.exposed = reactivity.proxyRefs(exposed);
7253
+ instance.exposed = exposed || {};
7211
7254
  };
7212
7255
  {
7256
+ let attrs;
7213
7257
  // We use getters in dev in case libs like test-utils overwrite instance
7214
7258
  // properties (overwrites should not be done in prod)
7215
7259
  return Object.freeze({
7216
7260
  get attrs() {
7217
- return new Proxy(instance.attrs, attrHandlers);
7261
+ return (attrs || (attrs = new Proxy(instance.attrs, attrDevProxyHandlers)));
7218
7262
  },
7219
7263
  get slots() {
7220
7264
  return reactivity.shallowReadonly(instance.slots);
@@ -7226,6 +7270,21 @@ function createSetupContext(instance) {
7226
7270
  });
7227
7271
  }
7228
7272
  }
7273
+ function getExposeProxy(instance) {
7274
+ if (instance.exposed) {
7275
+ return (instance.exposeProxy ||
7276
+ (instance.exposeProxy = new Proxy(reactivity.proxyRefs(reactivity.markRaw(instance.exposed)), {
7277
+ get(target, key) {
7278
+ if (key in target) {
7279
+ return target[key];
7280
+ }
7281
+ else if (key in publicPropertiesMap) {
7282
+ return publicPropertiesMap[key](instance);
7283
+ }
7284
+ }
7285
+ })));
7286
+ }
7287
+ }
7229
7288
  // record effects created during a component's setup() so that they can be
7230
7289
  // stopped when the component unmounts
7231
7290
  function recordInstanceBoundEffect(effect, instance = currentInstance) {
@@ -7274,30 +7333,142 @@ function computed(getterOrOptions) {
7274
7333
  return c;
7275
7334
  }
7276
7335
 
7336
+ Object.freeze({})
7337
+ ;
7338
+ Object.freeze([]) ;
7339
+ const isFunction = (val) => typeof val === 'function';
7340
+ const isObject = (val) => val !== null && typeof val === 'object';
7341
+ const isPromise = (val) => {
7342
+ return isObject(val) && isFunction(val.then) && isFunction(val.catch);
7343
+ };
7344
+
7345
+ // dev only
7346
+ const warnRuntimeUsage = (method) => warn(`${method}() is a compiler-hint helper that is only usable inside ` +
7347
+ `<script setup> of a single file component. Its arguments should be ` +
7348
+ `compiled away and passing it at runtime has no effect.`);
7277
7349
  // implementation
7278
7350
  function defineProps() {
7279
7351
  {
7280
- warn(`defineProps() is a compiler-hint helper that is only usable inside ` +
7281
- `<script setup> of a single file component. Its arguments should be ` +
7282
- `compiled away and passing it at runtime has no effect.`);
7352
+ warnRuntimeUsage(`defineProps`);
7283
7353
  }
7284
7354
  return null;
7285
7355
  }
7286
7356
  // implementation
7287
- function defineEmit() {
7357
+ function defineEmits() {
7358
+ {
7359
+ warnRuntimeUsage(`defineEmits`);
7360
+ }
7361
+ return null;
7362
+ }
7363
+ /**
7364
+ * @deprecated use `defineEmits` instead.
7365
+ */
7366
+ const defineEmit = defineEmits;
7367
+ /**
7368
+ * Vue `<script setup>` compiler macro for declaring a component's exposed
7369
+ * instance properties when it is accessed by a parent component via template
7370
+ * refs.
7371
+ *
7372
+ * `<script setup>` components are closed by default - i.e. varaibles inside
7373
+ * the `<script setup>` scope is not exposed to parent unless explicitly exposed
7374
+ * via `defineExpose`.
7375
+ *
7376
+ * This is only usable inside `<script setup>`, is compiled away in the
7377
+ * output and should **not** be actually called at runtime.
7378
+ */
7379
+ function defineExpose(exposed) {
7288
7380
  {
7289
- warn(`defineEmit() is a compiler-hint helper that is only usable inside ` +
7290
- `<script setup> of a single file component. Its arguments should be ` +
7291
- `compiled away and passing it at runtime has no effect.`);
7381
+ warnRuntimeUsage(`defineExpose`);
7382
+ }
7383
+ }
7384
+ /**
7385
+ * Vue `<script setup>` compiler macro for providing props default values when
7386
+ * using type-based `defineProps` decalration.
7387
+ *
7388
+ * Example usage:
7389
+ * ```ts
7390
+ * withDefaults(defineProps<{
7391
+ * size?: number
7392
+ * labels?: string[]
7393
+ * }>(), {
7394
+ * size: 3,
7395
+ * labels: () => ['default label']
7396
+ * })
7397
+ * ```
7398
+ *
7399
+ * This is only usable inside `<script setup>`, is compiled away in the output
7400
+ * and should **not** be actually called at runtime.
7401
+ */
7402
+ function withDefaults(props, defaults) {
7403
+ {
7404
+ warnRuntimeUsage(`withDefaults`);
7292
7405
  }
7293
7406
  return null;
7294
7407
  }
7408
+ /**
7409
+ * @deprecated use `useSlots` and `useAttrs` instead.
7410
+ */
7295
7411
  function useContext() {
7412
+ {
7413
+ warn(`\`useContext()\` has been deprecated and will be removed in the ` +
7414
+ `next minor release. Use \`useSlots()\` and \`useAttrs()\` instead.`);
7415
+ }
7416
+ return getContext();
7417
+ }
7418
+ function useSlots() {
7419
+ return getContext().slots;
7420
+ }
7421
+ function useAttrs() {
7422
+ return getContext().attrs;
7423
+ }
7424
+ function getContext() {
7296
7425
  const i = getCurrentInstance();
7297
7426
  if (!i) {
7298
7427
  warn(`useContext() called without active instance.`);
7299
7428
  }
7300
7429
  return i.setupContext || (i.setupContext = createSetupContext(i));
7430
+ }
7431
+ /**
7432
+ * Runtime helper for merging default declarations. Imported by compiled code
7433
+ * only.
7434
+ * @internal
7435
+ */
7436
+ function mergeDefaults(
7437
+ // the base props is compiler-generated and guaranteed to be in this shape.
7438
+ props, defaults) {
7439
+ for (const key in defaults) {
7440
+ const val = props[key];
7441
+ if (val) {
7442
+ val.default = defaults[key];
7443
+ }
7444
+ else if (val === null) {
7445
+ props[key] = { default: defaults[key] };
7446
+ }
7447
+ else {
7448
+ warn(`props default key "${key}" has no corresponding declaration.`);
7449
+ }
7450
+ }
7451
+ return props;
7452
+ }
7453
+ /**
7454
+ * Runtime helper for storing and resuming current instance context in
7455
+ * async setup().
7456
+ */
7457
+ function withAsyncContext(awaitable) {
7458
+ const ctx = getCurrentInstance();
7459
+ setCurrentInstance(null); // unset after storing instance
7460
+ if (!ctx) {
7461
+ warn(`withAsyncContext() called when there is no active context instance.`);
7462
+ }
7463
+ return isPromise(awaitable)
7464
+ ? awaitable.then(res => {
7465
+ setCurrentInstance(ctx);
7466
+ return res;
7467
+ }, err => {
7468
+ setCurrentInstance(ctx);
7469
+ throw err;
7470
+ })
7471
+ : awaitable;
7301
7472
  }
7302
7473
 
7303
7474
  // Actual implementation
@@ -7530,7 +7701,7 @@ function initCustomFormatter() {
7530
7701
  }
7531
7702
 
7532
7703
  // Core API ------------------------------------------------------------------
7533
- const version = "3.1.0";
7704
+ const version = "3.1.4";
7534
7705
  const _ssrUtils = {
7535
7706
  createComponentInstance,
7536
7707
  setupComponent,
@@ -7599,6 +7770,8 @@ exports.createVNode = createVNode;
7599
7770
  exports.defineAsyncComponent = defineAsyncComponent;
7600
7771
  exports.defineComponent = defineComponent;
7601
7772
  exports.defineEmit = defineEmit;
7773
+ exports.defineEmits = defineEmits;
7774
+ exports.defineExpose = defineExpose;
7602
7775
  exports.defineProps = defineProps;
7603
7776
  exports.getCurrentInstance = getCurrentInstance;
7604
7777
  exports.getTransitionRawChildren = getTransitionRawChildren;
@@ -7608,6 +7781,7 @@ exports.initCustomFormatter = initCustomFormatter;
7608
7781
  exports.inject = inject;
7609
7782
  exports.isRuntimeOnly = isRuntimeOnly;
7610
7783
  exports.isVNode = isVNode;
7784
+ exports.mergeDefaults = mergeDefaults;
7611
7785
  exports.mergeProps = mergeProps;
7612
7786
  exports.nextTick = nextTick;
7613
7787
  exports.onActivated = onActivated;
@@ -7642,13 +7816,17 @@ exports.ssrContextKey = ssrContextKey;
7642
7816
  exports.ssrUtils = ssrUtils;
7643
7817
  exports.toHandlers = toHandlers;
7644
7818
  exports.transformVNodeArgs = transformVNodeArgs;
7819
+ exports.useAttrs = useAttrs;
7645
7820
  exports.useContext = useContext;
7646
7821
  exports.useSSRContext = useSSRContext;
7822
+ exports.useSlots = useSlots;
7647
7823
  exports.useTransitionState = useTransitionState;
7648
7824
  exports.version = version;
7649
7825
  exports.warn = warn;
7650
7826
  exports.watch = watch;
7651
7827
  exports.watchEffect = watchEffect;
7828
+ exports.withAsyncContext = withAsyncContext;
7652
7829
  exports.withCtx = withCtx;
7830
+ exports.withDefaults = withDefaults;
7653
7831
  exports.withDirectives = withDirectives;
7654
7832
  exports.withScopeId = withScopeId;