@vue/runtime-core 3.1.1 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { pauseTracking, resetTracking, isRef, toRaw, isReactive, effect, stop, ref, reactive, proxyRefs, toRef, shallowReactive, trigger, isProxy, shallowReadonly, track, computed as computed$1, isReadonly } from '@vue/reactivity';
1
+ import { pauseTracking, resetTracking, isRef, toRaw, isReactive, effect, stop, ref, reactive, shallowReactive, trigger, isProxy, shallowReadonly, track, markRaw, proxyRefs, computed as computed$1, isReadonly } from '@vue/reactivity';
2
2
  export { customRef, isProxy, isReactive, isReadonly, isRef, markRaw, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref } from '@vue/reactivity';
3
- import { isString, isFunction, isPromise, isArray, extend, hasOwn, EMPTY_OBJ, toHandlerKey, toNumber, hyphenate, camelize, isOn, isModelListener, remove, NOOP, hasChanged, isObject, isSet, isMap, isPlainObject, invokeArrayFns, def, isReservedProp, EMPTY_ARR, capitalize, toRawType, makeMap, NO, getGlobalThis, normalizeClass, normalizeStyle, isGloballyWhitelisted } from '@vue/shared';
3
+ import { isString, isFunction as isFunction$1, isPromise as isPromise$1, isArray, extend, hasOwn, EMPTY_OBJ, toHandlerKey, toNumber, hyphenate, camelize, isOn, isModelListener, remove, NOOP, hasChanged, isObject as isObject$1, isSet, isMap, isPlainObject, invokeArrayFns, def, isReservedProp, EMPTY_ARR, capitalize, toRawType, makeMap, NO, getGlobalThis, normalizeClass, normalizeStyle, isGloballyWhitelisted } from '@vue/shared';
4
4
  export { camelize, capitalize, toDisplayString, toHandlerKey } from '@vue/shared';
5
5
 
6
6
  const stack = [];
@@ -108,7 +108,7 @@ function formatProp(key, value, raw) {
108
108
  value = formatProp(key, toRaw(value.value), true);
109
109
  return raw ? value : [`${key}=Ref<`, value, `>`];
110
110
  }
111
- else if (isFunction(value)) {
111
+ else if (isFunction$1(value)) {
112
112
  return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
113
113
  }
114
114
  else {
@@ -118,6 +118,7 @@ function formatProp(key, value, raw) {
118
118
  }
119
119
 
120
120
  const ErrorTypeStrings = {
121
+ ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
121
122
  ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
122
123
  ["c" /* CREATED */]: 'created hook',
123
124
  ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
@@ -159,9 +160,9 @@ function callWithErrorHandling(fn, instance, type, args) {
159
160
  return res;
160
161
  }
161
162
  function callWithAsyncErrorHandling(fn, instance, type, args) {
162
- if (isFunction(fn)) {
163
+ if (isFunction$1(fn)) {
163
164
  const res = callWithErrorHandling(fn, instance, type, args);
164
- if (res && isPromise(res)) {
165
+ if (res && isPromise$1(res)) {
165
166
  res.catch(err => {
166
167
  handleError(err, instance, type);
167
168
  });
@@ -832,9 +833,10 @@ const deprecationData = {
832
833
  message: (comp) => {
833
834
  const configMsg = `opt-in to ` +
834
835
  `Vue 3 behavior on a per-component basis with \`compatConfig: { ${"COMPONENT_V_MODEL" /* COMPONENT_V_MODEL */}: false }\`.`;
835
- if (comp.props && isArray(comp.props)
836
- ? comp.props.includes('modelValue')
837
- : hasOwn(comp.props, 'modelValue')) {
836
+ if (comp.props &&
837
+ (isArray(comp.props)
838
+ ? comp.props.includes('modelValue')
839
+ : hasOwn(comp.props, 'modelValue'))) {
838
840
  return (`Component delcares "modelValue" prop, which is Vue 3 usage, but ` +
839
841
  `is running under Vue 2 compat v-model behavior. You can ${configMsg}`);
840
842
  }
@@ -917,7 +919,7 @@ function isCompatEnabled(key, instance, enableForBuiltIn = false) {
917
919
  }
918
920
  const rawMode = getCompatConfigForKey('MODE', instance) || 2;
919
921
  const val = getCompatConfigForKey(key, instance);
920
- const mode = isFunction(rawMode)
922
+ const mode = isFunction$1(rawMode)
921
923
  ? rawMode(instance && instance.type)
922
924
  : rawMode;
923
925
  if (mode === 2) {
@@ -942,7 +944,7 @@ function emit(instance, event, ...rawArgs) {
942
944
  }
943
945
  else {
944
946
  const validator = emitsOptions[event];
945
- if (isFunction(validator)) {
947
+ if (isFunction$1(validator)) {
946
948
  const isValid = validator(...rawArgs);
947
949
  if (!isValid) {
948
950
  warn(`Invalid event arguments: event validation failed for event "${event}".`);
@@ -993,11 +995,12 @@ function emit(instance, event, ...rawArgs) {
993
995
  const onceHandler = props[handlerName + `Once`];
994
996
  if (onceHandler) {
995
997
  if (!instance.emitted) {
996
- (instance.emitted = {})[handlerName] = true;
998
+ instance.emitted = {};
997
999
  }
998
1000
  else if (instance.emitted[handlerName]) {
999
1001
  return;
1000
1002
  }
1003
+ instance.emitted[handlerName] = true;
1001
1004
  callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
1002
1005
  }
1003
1006
  }
@@ -1011,7 +1014,7 @@ function normalizeEmitsOptions(comp, appContext, asMixin = false) {
1011
1014
  let normalized = {};
1012
1015
  // apply mixin/extends props
1013
1016
  let hasExtends = false;
1014
- if (__VUE_OPTIONS_API__ && !isFunction(comp)) {
1017
+ if (__VUE_OPTIONS_API__ && !isFunction$1(comp)) {
1015
1018
  const extendEmits = (raw) => {
1016
1019
  const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
1017
1020
  if (normalizedFromExtend) {
@@ -1468,6 +1471,12 @@ const SuspenseImpl = {
1468
1471
  // Force-casted public typing for h and TSX props inference
1469
1472
  const Suspense = (SuspenseImpl
1470
1473
  );
1474
+ function triggerEvent(vnode, name) {
1475
+ const eventListener = vnode.props && vnode.props[name];
1476
+ if (isFunction$1(eventListener)) {
1477
+ eventListener();
1478
+ }
1479
+ }
1471
1480
  function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
1472
1481
  const { p: patch, o: { createElement } } = rendererInternals;
1473
1482
  const hiddenContainer = createElement('div');
@@ -1477,6 +1486,9 @@ function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense
1477
1486
  // now check if we have encountered any async deps
1478
1487
  if (suspense.deps > 0) {
1479
1488
  // has async
1489
+ // invoke @fallback event
1490
+ triggerEvent(vnode, 'onPending');
1491
+ triggerEvent(vnode, 'onFallback');
1480
1492
  // mount the fallback tree
1481
1493
  patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
1482
1494
  isSVG, slotScopeIds);
@@ -1564,10 +1576,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotSc
1564
1576
  else {
1565
1577
  // root node toggled
1566
1578
  // invoke @pending event
1567
- const onPending = n2.props && n2.props.onPending;
1568
- if (isFunction(onPending)) {
1569
- onPending();
1570
- }
1579
+ triggerEvent(n2, 'onPending');
1571
1580
  // mount pending branch in off-dom container
1572
1581
  suspense.pendingBranch = newBranch;
1573
1582
  suspense.pendingId++;
@@ -1680,10 +1689,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1680
1689
  }
1681
1690
  suspense.effects = [];
1682
1691
  // invoke @resolve event
1683
- const onResolve = vnode.props && vnode.props.onResolve;
1684
- if (isFunction(onResolve)) {
1685
- onResolve();
1686
- }
1692
+ triggerEvent(vnode, 'onResolve');
1687
1693
  },
1688
1694
  fallback(fallbackVNode) {
1689
1695
  if (!suspense.pendingBranch) {
@@ -1691,10 +1697,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1691
1697
  }
1692
1698
  const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
1693
1699
  // invoke @fallback event
1694
- const onFallback = vnode.props && vnode.props.onFallback;
1695
- if (isFunction(onFallback)) {
1696
- onFallback();
1697
- }
1700
+ triggerEvent(vnode, 'onFallback');
1698
1701
  const anchor = next(activeBranch);
1699
1702
  const mountFallback = () => {
1700
1703
  if (!suspense.isInFallback) {
@@ -1709,11 +1712,11 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1709
1712
  if (delayEnter) {
1710
1713
  activeBranch.transition.afterLeave = mountFallback;
1711
1714
  }
1715
+ suspense.isInFallback = true;
1712
1716
  // unmount current active branch
1713
1717
  unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
1714
1718
  true // shouldRemove
1715
1719
  );
1716
- suspense.isInFallback = true;
1717
1720
  if (!delayEnter) {
1718
1721
  mountFallback();
1719
1722
  }
@@ -1816,7 +1819,7 @@ function normalizeSuspenseChildren(vnode) {
1816
1819
  }
1817
1820
  function normalizeSuspenseSlot(s) {
1818
1821
  let block;
1819
- if (isFunction(s)) {
1822
+ if (isFunction$1(s)) {
1820
1823
  const isCompiledSlot = s._c;
1821
1824
  if (isCompiledSlot) {
1822
1825
  // disableTracking: false
@@ -1907,8 +1910,8 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
1907
1910
  return provides[key];
1908
1911
  }
1909
1912
  else if (arguments.length > 1) {
1910
- return treatDefaultAsFactory && isFunction(defaultValue)
1911
- ? defaultValue()
1913
+ return treatDefaultAsFactory && isFunction$1(defaultValue)
1914
+ ? defaultValue.call(instance.proxy)
1912
1915
  : defaultValue;
1913
1916
  }
1914
1917
  else if ((process.env.NODE_ENV !== 'production')) {
@@ -1928,7 +1931,7 @@ function watchEffect(effect, options) {
1928
1931
  const INITIAL_WATCHER_VALUE = {};
1929
1932
  // implementation
1930
1933
  function watch(source, cb, options) {
1931
- if ((process.env.NODE_ENV !== 'production') && !isFunction(cb)) {
1934
+ if ((process.env.NODE_ENV !== 'production') && !isFunction$1(cb)) {
1932
1935
  warn(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
1933
1936
  `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
1934
1937
  `supports \`watch(source, cb, options?) signature.`);
@@ -1971,7 +1974,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
1971
1974
  else if (isReactive(s)) {
1972
1975
  return traverse(s);
1973
1976
  }
1974
- else if (isFunction(s)) {
1977
+ else if (isFunction$1(s)) {
1975
1978
  return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
1976
1979
  }
1977
1980
  else {
@@ -1979,7 +1982,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
1979
1982
  }
1980
1983
  });
1981
1984
  }
1982
- else if (isFunction(source)) {
1985
+ else if (isFunction$1(source)) {
1983
1986
  if (cb) {
1984
1987
  // getter with cb
1985
1988
  getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
@@ -2104,7 +2107,7 @@ function instanceWatch(source, value, options) {
2104
2107
  : () => publicThis[source]
2105
2108
  : source.bind(publicThis, publicThis);
2106
2109
  let cb;
2107
- if (isFunction(value)) {
2110
+ if (isFunction$1(value)) {
2108
2111
  cb = value;
2109
2112
  }
2110
2113
  else {
@@ -2124,9 +2127,11 @@ function createPathGetter(ctx, path) {
2124
2127
  };
2125
2128
  }
2126
2129
  function traverse(value, seen = new Set()) {
2127
- if (!isObject(value) ||
2128
- seen.has(value) ||
2129
- value["__v_skip" /* SKIP */]) {
2130
+ if (!isObject$1(value) || value["__v_skip" /* SKIP */]) {
2131
+ return value;
2132
+ }
2133
+ seen = seen || new Set();
2134
+ if (seen.has(value)) {
2130
2135
  return value;
2131
2136
  }
2132
2137
  seen.add(value);
@@ -2465,12 +2470,12 @@ function getTransitionRawChildren(children, keepComment = false) {
2465
2470
 
2466
2471
  // implementation, close to no-op
2467
2472
  function defineComponent(options) {
2468
- return isFunction(options) ? { setup: options, name: options.name } : options;
2473
+ return isFunction$1(options) ? { setup: options, name: options.name } : options;
2469
2474
  }
2470
2475
 
2471
2476
  const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
2472
2477
  function defineAsyncComponent(source) {
2473
- if (isFunction(source)) {
2478
+ if (isFunction$1(source)) {
2474
2479
  source = { loader: source };
2475
2480
  }
2476
2481
  const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
@@ -2513,7 +2518,7 @@ function defineAsyncComponent(source) {
2513
2518
  (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
2514
2519
  comp = comp.default;
2515
2520
  }
2516
- if ((process.env.NODE_ENV !== 'production') && comp && !isObject(comp) && !isFunction(comp)) {
2521
+ if ((process.env.NODE_ENV !== 'production') && comp && !isObject$1(comp) && !isFunction$1(comp)) {
2517
2522
  throw new Error(`Invalid async component load result: ${comp}`);
2518
2523
  }
2519
2524
  resolvedComp = comp;
@@ -2999,7 +3004,7 @@ function applyOptions(instance) {
2999
3004
  if (methods) {
3000
3005
  for (const key in methods) {
3001
3006
  const methodHandler = methods[key];
3002
- if (isFunction(methodHandler)) {
3007
+ if (isFunction$1(methodHandler)) {
3003
3008
  // In dev mode, we use the `createRenderContext` function to define methods to the proxy target,
3004
3009
  // and those are read-only but reconfigurable, so it needs to be redefined here
3005
3010
  if ((process.env.NODE_ENV !== 'production')) {
@@ -3024,17 +3029,17 @@ function applyOptions(instance) {
3024
3029
  }
3025
3030
  }
3026
3031
  if (dataOptions) {
3027
- if ((process.env.NODE_ENV !== 'production') && !isFunction(dataOptions)) {
3032
+ if ((process.env.NODE_ENV !== 'production') && !isFunction$1(dataOptions)) {
3028
3033
  warn(`The data option must be a function. ` +
3029
3034
  `Plain object usage is no longer supported.`);
3030
3035
  }
3031
3036
  const data = dataOptions.call(publicThis, publicThis);
3032
- if ((process.env.NODE_ENV !== 'production') && isPromise(data)) {
3037
+ if ((process.env.NODE_ENV !== 'production') && isPromise$1(data)) {
3033
3038
  warn(`data() returned a Promise - note data() cannot be async; If you ` +
3034
3039
  `intend to perform data fetching before component renders, use ` +
3035
3040
  `async setup() + <Suspense>.`);
3036
3041
  }
3037
- if (!isObject(data)) {
3042
+ if (!isObject$1(data)) {
3038
3043
  (process.env.NODE_ENV !== 'production') && warn(`data() should return an object.`);
3039
3044
  }
3040
3045
  else {
@@ -3060,15 +3065,15 @@ function applyOptions(instance) {
3060
3065
  if (computedOptions) {
3061
3066
  for (const key in computedOptions) {
3062
3067
  const opt = computedOptions[key];
3063
- const get = isFunction(opt)
3068
+ const get = isFunction$1(opt)
3064
3069
  ? opt.bind(publicThis, publicThis)
3065
- : isFunction(opt.get)
3070
+ : isFunction$1(opt.get)
3066
3071
  ? opt.get.bind(publicThis, publicThis)
3067
3072
  : NOOP;
3068
3073
  if ((process.env.NODE_ENV !== 'production') && get === NOOP) {
3069
3074
  warn(`Computed property "${key}" has no getter.`);
3070
3075
  }
3071
- const set = !isFunction(opt) && isFunction(opt.set)
3076
+ const set = !isFunction$1(opt) && isFunction$1(opt.set)
3072
3077
  ? opt.set.bind(publicThis)
3073
3078
  : (process.env.NODE_ENV !== 'production')
3074
3079
  ? () => {
@@ -3096,7 +3101,7 @@ function applyOptions(instance) {
3096
3101
  }
3097
3102
  }
3098
3103
  if (provideOptions) {
3099
- const provides = isFunction(provideOptions)
3104
+ const provides = isFunction$1(provideOptions)
3100
3105
  ? provideOptions.call(publicThis)
3101
3106
  : provideOptions;
3102
3107
  Reflect.ownKeys(provides).forEach(key => {
@@ -3128,13 +3133,16 @@ function applyOptions(instance) {
3128
3133
  registerLifecycleHook(onServerPrefetch, serverPrefetch);
3129
3134
  if (isArray(expose)) {
3130
3135
  if (expose.length) {
3131
- const exposed = instance.exposed || (instance.exposed = proxyRefs({}));
3136
+ const exposed = instance.exposed || (instance.exposed = {});
3132
3137
  expose.forEach(key => {
3133
- exposed[key] = toRef(publicThis, key);
3138
+ Object.defineProperty(exposed, key, {
3139
+ get: () => publicThis[key],
3140
+ set: val => (publicThis[key] = val)
3141
+ });
3134
3142
  });
3135
3143
  }
3136
3144
  else if (!instance.exposed) {
3137
- instance.exposed = EMPTY_OBJ;
3145
+ instance.exposed = {};
3138
3146
  }
3139
3147
  }
3140
3148
  // options that are handled when creating the instance but also need to be
@@ -3157,7 +3165,7 @@ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP)
3157
3165
  }
3158
3166
  for (const key in injectOptions) {
3159
3167
  const opt = injectOptions[key];
3160
- if (isObject(opt)) {
3168
+ if (isObject$1(opt)) {
3161
3169
  if ('default' in opt) {
3162
3170
  ctx[key] = inject(opt.from || key, opt.default, true /* treat default function as factory */);
3163
3171
  }
@@ -3184,25 +3192,25 @@ function createWatcher(raw, ctx, publicThis, key) {
3184
3192
  : () => publicThis[key];
3185
3193
  if (isString(raw)) {
3186
3194
  const handler = ctx[raw];
3187
- if (isFunction(handler)) {
3195
+ if (isFunction$1(handler)) {
3188
3196
  watch(getter, handler);
3189
3197
  }
3190
3198
  else if ((process.env.NODE_ENV !== 'production')) {
3191
3199
  warn(`Invalid watch handler specified by key "${raw}"`, handler);
3192
3200
  }
3193
3201
  }
3194
- else if (isFunction(raw)) {
3202
+ else if (isFunction$1(raw)) {
3195
3203
  watch(getter, raw.bind(publicThis));
3196
3204
  }
3197
- else if (isObject(raw)) {
3205
+ else if (isObject$1(raw)) {
3198
3206
  if (isArray(raw)) {
3199
3207
  raw.forEach(r => createWatcher(r, ctx, publicThis, key));
3200
3208
  }
3201
3209
  else {
3202
- const handler = isFunction(raw.handler)
3210
+ const handler = isFunction$1(raw.handler)
3203
3211
  ? raw.handler.bind(publicThis)
3204
3212
  : ctx[raw.handler];
3205
- if (isFunction(handler)) {
3213
+ if (isFunction$1(handler)) {
3206
3214
  watch(getter, handler, raw);
3207
3215
  }
3208
3216
  else if ((process.env.NODE_ENV !== 'production')) {
@@ -3272,25 +3280,23 @@ const internalOptionMergeStrats = {
3272
3280
  methods: mergeObjectOptions,
3273
3281
  computed: mergeObjectOptions,
3274
3282
  // lifecycle
3275
- beforeCreate: mergeHook,
3276
- created: mergeHook,
3277
- beforeMount: mergeHook,
3278
- mounted: mergeHook,
3279
- beforeUpdate: mergeHook,
3280
- updated: mergeHook,
3281
- beforeDestroy: mergeHook,
3282
- destroyed: mergeHook,
3283
- activated: mergeHook,
3284
- deactivated: mergeHook,
3285
- errorCaptured: mergeHook,
3286
- serverPrefetch: mergeHook,
3283
+ beforeCreate: mergeAsArray,
3284
+ created: mergeAsArray,
3285
+ beforeMount: mergeAsArray,
3286
+ mounted: mergeAsArray,
3287
+ beforeUpdate: mergeAsArray,
3288
+ updated: mergeAsArray,
3289
+ beforeDestroy: mergeAsArray,
3290
+ destroyed: mergeAsArray,
3291
+ activated: mergeAsArray,
3292
+ deactivated: mergeAsArray,
3293
+ errorCaptured: mergeAsArray,
3294
+ serverPrefetch: mergeAsArray,
3287
3295
  // assets
3288
3296
  components: mergeObjectOptions,
3289
3297
  directives: mergeObjectOptions,
3290
- // watch has special merge behavior in v2, but isn't actually needed in v3.
3291
- // since we are only exposing these for compat and nobody should be relying
3292
- // on the watch-specific behavior, just expose the object merge strat.
3293
- watch: mergeObjectOptions,
3298
+ // watch
3299
+ watch: mergeWatchOptions,
3294
3300
  // provide / inject
3295
3301
  provide: mergeDataFn,
3296
3302
  inject: mergeInject
@@ -3303,7 +3309,7 @@ function mergeDataFn(to, from) {
3303
3309
  return from;
3304
3310
  }
3305
3311
  return function mergedDataFn() {
3306
- return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
3312
+ return (extend)(isFunction$1(to) ? to.call(this, this) : to, isFunction$1(from) ? from.call(this, this) : from);
3307
3313
  };
3308
3314
  }
3309
3315
  function mergeInject(to, from) {
@@ -3319,11 +3325,22 @@ function normalizeInject(raw) {
3319
3325
  }
3320
3326
  return raw;
3321
3327
  }
3322
- function mergeHook(to, from) {
3328
+ function mergeAsArray(to, from) {
3323
3329
  return to ? [...new Set([].concat(to, from))] : from;
3324
3330
  }
3325
3331
  function mergeObjectOptions(to, from) {
3326
3332
  return to ? extend(extend(Object.create(null), to), from) : from;
3333
+ }
3334
+ function mergeWatchOptions(to, from) {
3335
+ if (!to)
3336
+ return from;
3337
+ if (!from)
3338
+ return to;
3339
+ const merged = extend(Object.create(null), to);
3340
+ for (const key in from) {
3341
+ merged[key] = mergeAsArray(to[key], from[key]);
3342
+ }
3343
+ return merged;
3327
3344
  }
3328
3345
 
3329
3346
  function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
@@ -3499,7 +3516,7 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
3499
3516
  // default values
3500
3517
  if (hasDefault && value === undefined) {
3501
3518
  const defaultValue = opt.default;
3502
- if (opt.type !== Function && isFunction(defaultValue)) {
3519
+ if (opt.type !== Function && isFunction$1(defaultValue)) {
3503
3520
  const { propsDefaults } = instance;
3504
3521
  if (key in propsDefaults) {
3505
3522
  value = propsDefaults[key];
@@ -3538,7 +3555,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
3538
3555
  const needCastKeys = [];
3539
3556
  // apply mixin/extends props
3540
3557
  let hasExtends = false;
3541
- if (__VUE_OPTIONS_API__ && !isFunction(comp)) {
3558
+ if (__VUE_OPTIONS_API__ && !isFunction$1(comp)) {
3542
3559
  const extendProps = (raw) => {
3543
3560
  hasExtends = true;
3544
3561
  const [props, keys] = normalizePropsOptions(raw, appContext, true);
@@ -3572,7 +3589,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
3572
3589
  }
3573
3590
  }
3574
3591
  else if (raw) {
3575
- if ((process.env.NODE_ENV !== 'production') && !isObject(raw)) {
3592
+ if ((process.env.NODE_ENV !== 'production') && !isObject$1(raw)) {
3576
3593
  warn(`invalid props options`, raw);
3577
3594
  }
3578
3595
  for (const key in raw) {
@@ -3580,7 +3597,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
3580
3597
  if (validatePropName(normalizedKey)) {
3581
3598
  const opt = raw[key];
3582
3599
  const prop = (normalized[normalizedKey] =
3583
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
3600
+ isArray(opt) || isFunction$1(opt) ? { type: opt } : opt);
3584
3601
  if (prop) {
3585
3602
  const booleanIndex = getTypeIndex(Boolean, prop.type);
3586
3603
  const stringIndex = getTypeIndex(String, prop.type);
@@ -3621,7 +3638,7 @@ function getTypeIndex(type, expectedTypes) {
3621
3638
  if (isArray(expectedTypes)) {
3622
3639
  return expectedTypes.findIndex(t => isSameType(t, type));
3623
3640
  }
3624
- else if (isFunction(expectedTypes)) {
3641
+ else if (isFunction$1(expectedTypes)) {
3625
3642
  return isSameType(expectedTypes, type) ? 0 : -1;
3626
3643
  }
3627
3644
  return -1;
@@ -3690,7 +3707,7 @@ function assertType(value, type) {
3690
3707
  }
3691
3708
  }
3692
3709
  else if (expectedType === 'Object') {
3693
- valid = isObject(value);
3710
+ valid = isObject$1(value);
3694
3711
  }
3695
3712
  else if (expectedType === 'Array') {
3696
3713
  valid = isArray(value);
@@ -3776,7 +3793,7 @@ const normalizeObjectSlots = (rawSlots, slots, instance) => {
3776
3793
  if (isInternalKey(key))
3777
3794
  continue;
3778
3795
  const value = rawSlots[key];
3779
- if (isFunction(value)) {
3796
+ if (isFunction$1(value)) {
3780
3797
  slots[key] = normalizeSlot(key, value, ctx);
3781
3798
  }
3782
3799
  else if (value != null) {
@@ -3905,12 +3922,15 @@ function withDirectives(vnode, directives) {
3905
3922
  const bindings = vnode.dirs || (vnode.dirs = []);
3906
3923
  for (let i = 0; i < directives.length; i++) {
3907
3924
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
3908
- if (isFunction(dir)) {
3925
+ if (isFunction$1(dir)) {
3909
3926
  dir = {
3910
3927
  mounted: dir,
3911
3928
  updated: dir
3912
3929
  };
3913
3930
  }
3931
+ if (dir.deep) {
3932
+ traverse(value);
3933
+ }
3914
3934
  bindings.push({
3915
3935
  dir,
3916
3936
  instance,
@@ -3970,7 +3990,7 @@ function createAppContext() {
3970
3990
  let uid = 0;
3971
3991
  function createAppAPI(render, hydrate) {
3972
3992
  return function createApp(rootComponent, rootProps = null) {
3973
- if (rootProps != null && !isObject(rootProps)) {
3993
+ if (rootProps != null && !isObject$1(rootProps)) {
3974
3994
  (process.env.NODE_ENV !== 'production') && warn(`root props passed to app.mount() must be an object.`);
3975
3995
  rootProps = null;
3976
3996
  }
@@ -3983,6 +4003,7 @@ function createAppAPI(render, hydrate) {
3983
4003
  _props: rootProps,
3984
4004
  _container: null,
3985
4005
  _context: context,
4006
+ _instance: null,
3986
4007
  version,
3987
4008
  get config() {
3988
4009
  return context.config;
@@ -3996,11 +4017,11 @@ function createAppAPI(render, hydrate) {
3996
4017
  if (installedPlugins.has(plugin)) {
3997
4018
  (process.env.NODE_ENV !== 'production') && warn(`Plugin has already been applied to target app.`);
3998
4019
  }
3999
- else if (plugin && isFunction(plugin.install)) {
4020
+ else if (plugin && isFunction$1(plugin.install)) {
4000
4021
  installedPlugins.add(plugin);
4001
4022
  plugin.install(app, ...options);
4002
4023
  }
4003
- else if (isFunction(plugin)) {
4024
+ else if (isFunction$1(plugin)) {
4004
4025
  installedPlugins.add(plugin);
4005
4026
  plugin(app, ...options);
4006
4027
  }
@@ -4073,6 +4094,7 @@ function createAppAPI(render, hydrate) {
4073
4094
  app._container = rootContainer;
4074
4095
  rootContainer.__vue_app__ = app;
4075
4096
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
4097
+ app._instance = vnode.component;
4076
4098
  devtoolsInitApp(app, version);
4077
4099
  }
4078
4100
  return vnode.component.proxy;
@@ -4088,6 +4110,7 @@ function createAppAPI(render, hydrate) {
4088
4110
  if (isMounted) {
4089
4111
  render(null, app._container);
4090
4112
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
4113
+ app._instance = null;
4091
4114
  devtoolsUnmountApp(app);
4092
4115
  }
4093
4116
  delete app._container.__vue_app__;
@@ -4122,10 +4145,12 @@ const isComment = (node) => node.nodeType === 8 /* COMMENT */;
4122
4145
  function createHydrationFunctions(rendererInternals) {
4123
4146
  const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
4124
4147
  const hydrate = (vnode, container) => {
4125
- if ((process.env.NODE_ENV !== 'production') && !container.hasChildNodes()) {
4126
- warn(`Attempting to hydrate existing markup but container is empty. ` +
4127
- `Performing full mount instead.`);
4148
+ if (!container.hasChildNodes()) {
4149
+ (process.env.NODE_ENV !== 'production') &&
4150
+ warn(`Attempting to hydrate existing markup but container is empty. ` +
4151
+ `Performing full mount instead.`);
4128
4152
  patch(null, vnode, container);
4153
+ flushPostFlushCbs();
4129
4154
  return;
4130
4155
  }
4131
4156
  hasMismatch = false;
@@ -4263,19 +4288,24 @@ function createHydrationFunctions(rendererInternals) {
4263
4288
  };
4264
4289
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
4265
4290
  optimized = optimized || !!vnode.dynamicChildren;
4266
- const { props, patchFlag, shapeFlag, dirs } = vnode;
4291
+ const { type, props, patchFlag, shapeFlag, dirs } = vnode;
4292
+ // #4006 for form elements with non-string v-model value bindings
4293
+ // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
4294
+ const forcePatchValue = (type === 'input' && dirs) || type === 'option';
4267
4295
  // skip props & children if this is hoisted static nodes
4268
- if (patchFlag !== -1 /* HOISTED */) {
4296
+ if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
4269
4297
  if (dirs) {
4270
4298
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
4271
4299
  }
4272
4300
  // props
4273
4301
  if (props) {
4274
- if (!optimized ||
4302
+ if (forcePatchValue ||
4303
+ !optimized ||
4275
4304
  (patchFlag & 16 /* FULL_PROPS */ ||
4276
4305
  patchFlag & 32 /* HYDRATE_EVENTS */)) {
4277
4306
  for (const key in props) {
4278
- if (!isReservedProp(key) && isOn(key)) {
4307
+ if ((forcePatchValue && key.endsWith('value')) ||
4308
+ (isOn(key) && !isReservedProp(key))) {
4279
4309
  patchProp(el, key, null, props[key]);
4280
4310
  }
4281
4311
  }
@@ -4521,7 +4551,7 @@ const setRef = (rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) =>
4521
4551
  return;
4522
4552
  }
4523
4553
  const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
4524
- ? vnode.component.exposed || vnode.component.proxy
4554
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
4525
4555
  : vnode.el;
4526
4556
  const value = isUnmount ? null : refValue;
4527
4557
  const { i: owner, r: ref } = rawRef;
@@ -4577,7 +4607,7 @@ const setRef = (rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) =>
4577
4607
  doSet();
4578
4608
  }
4579
4609
  }
4580
- else if (isFunction(ref)) {
4610
+ else if (isFunction$1(ref)) {
4581
4611
  callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
4582
4612
  }
4583
4613
  else if ((process.env.NODE_ENV !== 'production')) {
@@ -4622,7 +4652,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4622
4652
  const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, forcePatchProp: hostForcePatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
4623
4653
  // Note: functions inside this closure should use `const xxx = () => {}`
4624
4654
  // style in order to prevent being inlined by minifiers.
4625
- const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = false) => {
4655
+ const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = (process.env.NODE_ENV !== 'production') && isHmrUpdating ? false : !!n2.dynamicChildren) => {
4626
4656
  // patching & not same type, unmount old tree
4627
4657
  if (n1 && !isSameVNodeType(n1, n2)) {
4628
4658
  anchor = getNextHostNode(n1);
@@ -4762,7 +4792,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4762
4792
  hostSetElementText(el, vnode.children);
4763
4793
  }
4764
4794
  else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
4765
- mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized || !!vnode.dynamicChildren);
4795
+ mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
4766
4796
  }
4767
4797
  if (dirs) {
4768
4798
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
@@ -6257,7 +6287,7 @@ const InternalObjectKey = `__vInternal`;
6257
6287
  const normalizeKey = ({ key }) => key != null ? key : null;
6258
6288
  const normalizeRef = ({ ref }) => {
6259
6289
  return (ref != null
6260
- ? isString(ref) || isRef(ref) || isFunction(ref)
6290
+ ? isString(ref) || isRef(ref) || isFunction$1(ref)
6261
6291
  ? { i: currentRenderingInstance, r: ref }
6262
6292
  : ref
6263
6293
  : null);
@@ -6296,7 +6326,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
6296
6326
  if (klass && !isString(klass)) {
6297
6327
  props.class = normalizeClass(klass);
6298
6328
  }
6299
- if (isObject(style)) {
6329
+ if (isObject$1(style)) {
6300
6330
  // reactive state objects need to be cloned since they are likely to be
6301
6331
  // mutated
6302
6332
  if (isProxy(style) && !isArray(style)) {
@@ -6312,9 +6342,9 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
6312
6342
  ? 128 /* SUSPENSE */
6313
6343
  : isTeleport(type)
6314
6344
  ? 64 /* TELEPORT */
6315
- : isObject(type)
6345
+ : isObject$1(type)
6316
6346
  ? 4 /* STATEFUL_COMPONENT */
6317
- : isFunction(type)
6347
+ : isFunction$1(type)
6318
6348
  ? 2 /* FUNCTIONAL_COMPONENT */
6319
6349
  : 0;
6320
6350
  if ((process.env.NODE_ENV !== 'production') && shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
@@ -6344,7 +6374,6 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
6344
6374
  anchor: null,
6345
6375
  target: null,
6346
6376
  targetAnchor: null,
6347
- staticCount: 0,
6348
6377
  shapeFlag,
6349
6378
  patchFlag,
6350
6379
  dynamicProps,
@@ -6537,7 +6566,7 @@ function normalizeChildren(vnode, children) {
6537
6566
  }
6538
6567
  }
6539
6568
  }
6540
- else if (isFunction(children)) {
6569
+ else if (isFunction$1(children)) {
6541
6570
  children = { default: children, _ctx: currentRenderingInstance };
6542
6571
  type = 32 /* SLOTS_CHILDREN */;
6543
6572
  }
@@ -6606,7 +6635,7 @@ function renderList(source, renderItem) {
6606
6635
  ret[i] = renderItem(i + 1, i);
6607
6636
  }
6608
6637
  }
6609
- else if (isObject(source)) {
6638
+ else if (isObject$1(source)) {
6610
6639
  if (source[Symbol.iterator]) {
6611
6640
  ret = Array.from(source, renderItem);
6612
6641
  }
@@ -6702,7 +6731,7 @@ function ensureValidVNode(vnodes) {
6702
6731
  */
6703
6732
  function toHandlers(obj) {
6704
6733
  const ret = {};
6705
- if ((process.env.NODE_ENV !== 'production') && !isObject(obj)) {
6734
+ if ((process.env.NODE_ENV !== 'production') && !isObject$1(obj)) {
6706
6735
  warn(`v-on with no argument expects an object value.`);
6707
6736
  return ret;
6708
6737
  }
@@ -6721,7 +6750,7 @@ const getPublicInstance = (i) => {
6721
6750
  if (!i)
6722
6751
  return null;
6723
6752
  if (isStatefulComponent(i))
6724
- return i.exposed ? i.exposed : i.proxy;
6753
+ return getExposeProxy(i) || i.proxy;
6725
6754
  return getPublicInstance(i.parent);
6726
6755
  };
6727
6756
  const publicPropertiesMap = extend(Object.create(null), {
@@ -6743,14 +6772,20 @@ const publicPropertiesMap = extend(Object.create(null), {
6743
6772
  const PublicInstanceProxyHandlers = {
6744
6773
  get({ _: instance }, key) {
6745
6774
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
6746
- // let @vue/reactivity know it should never observe Vue public instances.
6747
- if (key === "__v_skip" /* SKIP */) {
6748
- return true;
6749
- }
6750
6775
  // for internal formatters to know that this is a Vue instance
6751
6776
  if ((process.env.NODE_ENV !== 'production') && key === '__isVue') {
6752
6777
  return true;
6753
6778
  }
6779
+ // prioritize <script setup> bindings during dev.
6780
+ // this allows even properties that start with _ or $ to be used - so that
6781
+ // it aligns with the production behavior where the render fn is inlined and
6782
+ // indeed has access to all declared variables.
6783
+ if ((process.env.NODE_ENV !== 'production') &&
6784
+ setupState !== EMPTY_OBJ &&
6785
+ setupState.__isScriptSetup &&
6786
+ hasOwn(setupState, key)) {
6787
+ return setupState[key];
6788
+ }
6754
6789
  // data / props / ctx
6755
6790
  // This getter gets called for every property access on the render context
6756
6791
  // during render and is a major hotspot. The most expensive part of this
@@ -6953,7 +6988,7 @@ function exposePropsOnRenderContext(instance) {
6953
6988
  function exposeSetupStateOnRenderContext(instance) {
6954
6989
  const { ctx, setupState } = instance;
6955
6990
  Object.keys(toRaw(setupState)).forEach(key => {
6956
- if (key[0] === '$' || key[0] === '_') {
6991
+ if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
6957
6992
  warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
6958
6993
  `which are reserved prefixes for Vue internals.`);
6959
6994
  return;
@@ -6986,6 +7021,7 @@ function createComponentInstance(vnode, parent, suspense) {
6986
7021
  render: null,
6987
7022
  proxy: null,
6988
7023
  exposed: null,
7024
+ exposeProxy: null,
6989
7025
  withProxy: null,
6990
7026
  effects: null,
6991
7027
  provides: parent ? parent.provides : Object.create(appContext.provides),
@@ -7104,7 +7140,7 @@ function setupStatefulComponent(instance, isSSR) {
7104
7140
  instance.accessCache = Object.create(null);
7105
7141
  // 1. create public instance / render proxy
7106
7142
  // also mark it raw so it's never observed
7107
- instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
7143
+ instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
7108
7144
  if ((process.env.NODE_ENV !== 'production')) {
7109
7145
  exposePropsOnRenderContext(instance);
7110
7146
  }
@@ -7118,7 +7154,11 @@ function setupStatefulComponent(instance, isSSR) {
7118
7154
  const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [(process.env.NODE_ENV !== 'production') ? shallowReadonly(instance.props) : instance.props, setupContext]);
7119
7155
  resetTracking();
7120
7156
  currentInstance = null;
7121
- if (isPromise(setupResult)) {
7157
+ if (isPromise$1(setupResult)) {
7158
+ const unsetInstance = () => {
7159
+ currentInstance = null;
7160
+ };
7161
+ setupResult.then(unsetInstance, unsetInstance);
7122
7162
  if (isSSR) {
7123
7163
  // return the promise so server-renderer can wait on it
7124
7164
  return setupResult
@@ -7144,13 +7184,13 @@ function setupStatefulComponent(instance, isSSR) {
7144
7184
  }
7145
7185
  }
7146
7186
  function handleSetupResult(instance, setupResult, isSSR) {
7147
- if (isFunction(setupResult)) {
7187
+ if (isFunction$1(setupResult)) {
7148
7188
  // setup returned an inline render function
7149
7189
  {
7150
7190
  instance.render = setupResult;
7151
7191
  }
7152
7192
  }
7153
- else if (isObject(setupResult)) {
7193
+ else if (isObject$1(setupResult)) {
7154
7194
  if ((process.env.NODE_ENV !== 'production') && isVNode(setupResult)) {
7155
7195
  warn(`setup() should not return VNodes directly - ` +
7156
7196
  `return a render function instead.`);
@@ -7234,11 +7274,9 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
7234
7274
  }
7235
7275
  }
7236
7276
  }
7237
- const attrHandlers = {
7277
+ const attrDevProxyHandlers = {
7238
7278
  get: (target, key) => {
7239
- if ((process.env.NODE_ENV !== 'production')) {
7240
- markAttrsAccessed();
7241
- }
7279
+ markAttrsAccessed();
7242
7280
  return target[key];
7243
7281
  },
7244
7282
  set: () => {
@@ -7255,14 +7293,15 @@ function createSetupContext(instance) {
7255
7293
  if ((process.env.NODE_ENV !== 'production') && instance.exposed) {
7256
7294
  warn(`expose() should be called only once per setup().`);
7257
7295
  }
7258
- instance.exposed = proxyRefs(exposed);
7296
+ instance.exposed = exposed || {};
7259
7297
  };
7260
7298
  if ((process.env.NODE_ENV !== 'production')) {
7299
+ let attrs;
7261
7300
  // We use getters in dev in case libs like test-utils overwrite instance
7262
7301
  // properties (overwrites should not be done in prod)
7263
7302
  return Object.freeze({
7264
7303
  get attrs() {
7265
- return new Proxy(instance.attrs, attrHandlers);
7304
+ return (attrs || (attrs = new Proxy(instance.attrs, attrDevProxyHandlers)));
7266
7305
  },
7267
7306
  get slots() {
7268
7307
  return shallowReadonly(instance.slots);
@@ -7282,6 +7321,21 @@ function createSetupContext(instance) {
7282
7321
  };
7283
7322
  }
7284
7323
  }
7324
+ function getExposeProxy(instance) {
7325
+ if (instance.exposed) {
7326
+ return (instance.exposeProxy ||
7327
+ (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
7328
+ get(target, key) {
7329
+ if (key in target) {
7330
+ return target[key];
7331
+ }
7332
+ else if (key in publicPropertiesMap) {
7333
+ return publicPropertiesMap[key](instance);
7334
+ }
7335
+ }
7336
+ })));
7337
+ }
7338
+ }
7285
7339
  // record effects created during a component's setup() so that they can be
7286
7340
  // stopped when the component unmounts
7287
7341
  function recordInstanceBoundEffect(effect, instance = currentInstance) {
@@ -7292,7 +7346,7 @@ function recordInstanceBoundEffect(effect, instance = currentInstance) {
7292
7346
  const classifyRE = /(?:^|[-_])(\w)/g;
7293
7347
  const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
7294
7348
  function getComponentName(Component) {
7295
- return isFunction(Component)
7349
+ return isFunction$1(Component)
7296
7350
  ? Component.displayName || Component.name
7297
7351
  : Component.name;
7298
7352
  }
@@ -7321,7 +7375,7 @@ function formatComponentName(instance, Component, isRoot = false) {
7321
7375
  return name ? classify(name) : isRoot ? `App` : `Anonymous`;
7322
7376
  }
7323
7377
  function isClassComponent(value) {
7324
- return isFunction(value) && '__vccOpts' in value;
7378
+ return isFunction$1(value) && '__vccOpts' in value;
7325
7379
  }
7326
7380
 
7327
7381
  function computed(getterOrOptions) {
@@ -7330,37 +7384,160 @@ function computed(getterOrOptions) {
7330
7384
  return c;
7331
7385
  }
7332
7386
 
7387
+ (process.env.NODE_ENV !== 'production')
7388
+ ? Object.freeze({})
7389
+ : {};
7390
+ (process.env.NODE_ENV !== 'production') ? Object.freeze([]) : [];
7391
+ const isFunction = (val) => typeof val === 'function';
7392
+ const isObject = (val) => val !== null && typeof val === 'object';
7393
+ const isPromise = (val) => {
7394
+ return isObject(val) && isFunction(val.then) && isFunction(val.catch);
7395
+ };
7396
+
7397
+ // dev only
7398
+ const warnRuntimeUsage = (method) => warn(`${method}() is a compiler-hint helper that is only usable inside ` +
7399
+ `<script setup> of a single file component. Its arguments should be ` +
7400
+ `compiled away and passing it at runtime has no effect.`);
7333
7401
  // implementation
7334
7402
  function defineProps() {
7335
7403
  if ((process.env.NODE_ENV !== 'production')) {
7336
- warn(`defineProps() is a compiler-hint helper that is only usable inside ` +
7337
- `<script setup> of a single file component. Its arguments should be ` +
7338
- `compiled away and passing it at runtime has no effect.`);
7404
+ warnRuntimeUsage(`defineProps`);
7339
7405
  }
7340
7406
  return null;
7341
7407
  }
7342
7408
  // implementation
7343
- function defineEmit() {
7409
+ function defineEmits() {
7410
+ if ((process.env.NODE_ENV !== 'production')) {
7411
+ warnRuntimeUsage(`defineEmits`);
7412
+ }
7413
+ return null;
7414
+ }
7415
+ /**
7416
+ * @deprecated use `defineEmits` instead.
7417
+ */
7418
+ const defineEmit = defineEmits;
7419
+ /**
7420
+ * Vue `<script setup>` compiler macro for declaring a component's exposed
7421
+ * instance properties when it is accessed by a parent component via template
7422
+ * refs.
7423
+ *
7424
+ * `<script setup>` components are closed by default - i.e. varaibles inside
7425
+ * the `<script setup>` scope is not exposed to parent unless explicitly exposed
7426
+ * via `defineExpose`.
7427
+ *
7428
+ * This is only usable inside `<script setup>`, is compiled away in the
7429
+ * output and should **not** be actually called at runtime.
7430
+ */
7431
+ function defineExpose(exposed) {
7432
+ if ((process.env.NODE_ENV !== 'production')) {
7433
+ warnRuntimeUsage(`defineExpose`);
7434
+ }
7435
+ }
7436
+ /**
7437
+ * Vue `<script setup>` compiler macro for providing props default values when
7438
+ * using type-based `defineProps` decalration.
7439
+ *
7440
+ * Example usage:
7441
+ * ```ts
7442
+ * withDefaults(defineProps<{
7443
+ * size?: number
7444
+ * labels?: string[]
7445
+ * }>(), {
7446
+ * size: 3,
7447
+ * labels: () => ['default label']
7448
+ * })
7449
+ * ```
7450
+ *
7451
+ * This is only usable inside `<script setup>`, is compiled away in the output
7452
+ * and should **not** be actually called at runtime.
7453
+ */
7454
+ function withDefaults(props, defaults) {
7344
7455
  if ((process.env.NODE_ENV !== 'production')) {
7345
- warn(`defineEmit() is a compiler-hint helper that is only usable inside ` +
7346
- `<script setup> of a single file component. Its arguments should be ` +
7347
- `compiled away and passing it at runtime has no effect.`);
7456
+ warnRuntimeUsage(`withDefaults`);
7348
7457
  }
7349
7458
  return null;
7350
7459
  }
7460
+ /**
7461
+ * @deprecated use `useSlots` and `useAttrs` instead.
7462
+ */
7351
7463
  function useContext() {
7464
+ if ((process.env.NODE_ENV !== 'production')) {
7465
+ warn(`\`useContext()\` has been deprecated and will be removed in the ` +
7466
+ `next minor release. Use \`useSlots()\` and \`useAttrs()\` instead.`);
7467
+ }
7468
+ return getContext();
7469
+ }
7470
+ function useSlots() {
7471
+ return getContext().slots;
7472
+ }
7473
+ function useAttrs() {
7474
+ return getContext().attrs;
7475
+ }
7476
+ function getContext() {
7352
7477
  const i = getCurrentInstance();
7353
7478
  if ((process.env.NODE_ENV !== 'production') && !i) {
7354
7479
  warn(`useContext() called without active instance.`);
7355
7480
  }
7356
7481
  return i.setupContext || (i.setupContext = createSetupContext(i));
7482
+ }
7483
+ /**
7484
+ * Runtime helper for merging default declarations. Imported by compiled code
7485
+ * only.
7486
+ * @internal
7487
+ */
7488
+ function mergeDefaults(
7489
+ // the base props is compiler-generated and guaranteed to be in this shape.
7490
+ props, defaults) {
7491
+ for (const key in defaults) {
7492
+ const val = props[key];
7493
+ if (val) {
7494
+ val.default = defaults[key];
7495
+ }
7496
+ else if (val === null) {
7497
+ props[key] = { default: defaults[key] };
7498
+ }
7499
+ else if ((process.env.NODE_ENV !== 'production')) {
7500
+ warn(`props default key "${key}" has no corresponding declaration.`);
7501
+ }
7502
+ }
7503
+ return props;
7504
+ }
7505
+ /**
7506
+ * `<script setup>` helper for persisting the current instance context over
7507
+ * async/await flows.
7508
+ *
7509
+ * `@vue/compiler-sfc` converts the following:
7510
+ *
7511
+ * ```ts
7512
+ * const x = await foo()
7513
+ * ```
7514
+ *
7515
+ * into:
7516
+ *
7517
+ * ```ts
7518
+ * let __temp, __restore
7519
+ * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
7520
+ * ```
7521
+ * @internal
7522
+ */
7523
+ function withAsyncContext(getAwaitable) {
7524
+ const ctx = getCurrentInstance();
7525
+ let awaitable = getAwaitable();
7526
+ setCurrentInstance(null);
7527
+ if (isPromise(awaitable)) {
7528
+ awaitable = awaitable.catch(e => {
7529
+ setCurrentInstance(ctx);
7530
+ throw e;
7531
+ });
7532
+ }
7533
+ return [awaitable, () => setCurrentInstance(ctx)];
7357
7534
  }
7358
7535
 
7359
7536
  // Actual implementation
7360
7537
  function h(type, propsOrChildren, children) {
7361
7538
  const l = arguments.length;
7362
7539
  if (l === 2) {
7363
- if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
7540
+ if (isObject$1(propsOrChildren) && !isArray(propsOrChildren)) {
7364
7541
  // single vnode without props
7365
7542
  if (isVNode(propsOrChildren)) {
7366
7543
  return createVNode(type, null, [propsOrChildren]);
@@ -7410,7 +7587,7 @@ function initCustomFormatter() {
7410
7587
  const formatter = {
7411
7588
  header(obj) {
7412
7589
  // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
7413
- if (!isObject(obj)) {
7590
+ if (!isObject$1(obj)) {
7414
7591
  return null;
7415
7592
  }
7416
7593
  if (obj.__isVue) {
@@ -7535,7 +7712,7 @@ function initCustomFormatter() {
7535
7712
  else if (typeof v === 'boolean') {
7536
7713
  return ['span', keywordStyle, v];
7537
7714
  }
7538
- else if (isObject(v)) {
7715
+ else if (isObject$1(v)) {
7539
7716
  return ['object', { object: asRaw ? toRaw(v) : v }];
7540
7717
  }
7541
7718
  else {
@@ -7544,7 +7721,7 @@ function initCustomFormatter() {
7544
7721
  }
7545
7722
  function extractKeys(instance, type) {
7546
7723
  const Comp = instance.type;
7547
- if (isFunction(Comp)) {
7724
+ if (isFunction$1(Comp)) {
7548
7725
  return;
7549
7726
  }
7550
7727
  const extracted = {};
@@ -7558,7 +7735,7 @@ function initCustomFormatter() {
7558
7735
  function isKeyOfType(Comp, key, type) {
7559
7736
  const opts = Comp[type];
7560
7737
  if ((isArray(opts) && opts.includes(key)) ||
7561
- (isObject(opts) && key in opts)) {
7738
+ (isObject$1(opts) && key in opts)) {
7562
7739
  return true;
7563
7740
  }
7564
7741
  if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
@@ -7586,7 +7763,7 @@ function initCustomFormatter() {
7586
7763
  }
7587
7764
 
7588
7765
  // Core API ------------------------------------------------------------------
7589
- const version = "3.1.1";
7766
+ const version = "3.1.5";
7590
7767
  /**
7591
7768
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
7592
7769
  * @internal
@@ -7601,4 +7778,4 @@ const resolveFilter = null;
7601
7778
  */
7602
7779
  const compatUtils = (null);
7603
7780
 
7604
- export { BaseTransition, Comment$1 as Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createHydrationRenderer, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmit, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, initCustomFormatter, inject, isRuntimeOnly, isVNode, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, pushScopeId, queuePostFlushCb, registerRuntimeCompiler, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, ssrContextKey, ssrUtils, toHandlers, transformVNodeArgs, useContext, useSSRContext, useTransitionState, version, warn, watch, watchEffect, withCtx, withDirectives, withScopeId };
7781
+ export { BaseTransition, Comment$1 as Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createHydrationRenderer, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmit, defineEmits, defineExpose, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, initCustomFormatter, inject, isRuntimeOnly, isVNode, mergeDefaults, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, pushScopeId, queuePostFlushCb, registerRuntimeCompiler, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, ssrContextKey, ssrUtils, toHandlers, transformVNodeArgs, useAttrs, useContext, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withScopeId };