@vue/runtime-core 3.3.0-alpha.8 → 3.3.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.
@@ -1,6 +1,6 @@
1
1
  import { pauseTracking, resetTracking, isRef, toRaw, getCurrentScope, isShallow as isShallow$1, isReactive, ReactiveEffect, ref, shallowReadonly, track, reactive, shallowReactive, trigger, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, isReadonly } from '@vue/reactivity';
2
2
  export { EffectScope, ReactiveEffect, customRef, effect, effectScope, getCurrentScope, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, triggerRef, unref } from '@vue/reactivity';
3
- import { isString, isFunction, isPromise, isArray, NOOP, getGlobalThis, extend, EMPTY_OBJ, toHandlerKey, looseToNumber, hyphenate, camelize, isObject, isOn, hasOwn, isModelListener, toNumber, hasChanged, remove, isSet, isMap, isPlainObject, invokeArrayFns, isRegExp, isBuiltInDirective, capitalize, isGloballyWhitelisted, def, isReservedProp, EMPTY_ARR, toRawType, makeMap, NO, normalizeClass, normalizeStyle } from '@vue/shared';
3
+ import { isString, isFunction, isPromise, isArray, NOOP, getGlobalThis, extend, EMPTY_OBJ, toHandlerKey, looseToNumber, hyphenate, camelize, isObject, isOn, hasOwn, isModelListener, toNumber, hasChanged, remove, isSet, isMap, isPlainObject, isBuiltInDirective, invokeArrayFns, isRegExp, capitalize, isGloballyWhitelisted, NO, def, isReservedProp, EMPTY_ARR, toRawType, makeMap, normalizeClass, normalizeStyle } from '@vue/shared';
4
4
  export { camelize, capitalize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
5
5
 
6
6
  const stack = [];
@@ -453,6 +453,8 @@ function reload(id, newComp) {
453
453
  }
454
454
  hmrDirtyComponents.add(oldComp);
455
455
  }
456
+ instance.appContext.propsCache.delete(instance.type);
457
+ instance.appContext.emitsCache.delete(instance.type);
456
458
  instance.appContext.optionsCache.delete(instance.type);
457
459
  if (instance.ceReload) {
458
460
  hmrDirtyComponents.add(oldComp);
@@ -1295,7 +1297,8 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotSc
1295
1297
  }
1296
1298
  }
1297
1299
  let hasWarned = false;
1298
- function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
1300
+ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
1301
+ var _a;
1299
1302
  if (process.env.NODE_ENV !== "production" && true && !hasWarned) {
1300
1303
  hasWarned = true;
1301
1304
  console[console.info ? "info" : "log"](
@@ -1309,13 +1312,21 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1309
1312
  n: next,
1310
1313
  o: { parentNode, remove }
1311
1314
  } = rendererInternals;
1315
+ let parentSuspenseId;
1316
+ const isSuspensible = ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
1317
+ if (isSuspensible) {
1318
+ if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
1319
+ parentSuspenseId = parentSuspense == null ? void 0 : parentSuspense.pendingId;
1320
+ parentSuspense.deps++;
1321
+ }
1322
+ }
1312
1323
  const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
1313
1324
  if (process.env.NODE_ENV !== "production") {
1314
1325
  assertNumber(timeout, `Suspense timeout`);
1315
1326
  }
1316
1327
  const suspense = {
1317
1328
  vnode,
1318
- parent,
1329
+ parent: parentSuspense,
1319
1330
  parentComponent,
1320
1331
  isSVG,
1321
1332
  container,
@@ -1375,20 +1386,28 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1375
1386
  setActiveBranch(suspense, pendingBranch);
1376
1387
  suspense.pendingBranch = null;
1377
1388
  suspense.isInFallback = false;
1378
- let parent2 = suspense.parent;
1389
+ let parent = suspense.parent;
1379
1390
  let hasUnresolvedAncestor = false;
1380
- while (parent2) {
1381
- if (parent2.pendingBranch) {
1382
- parent2.effects.push(...effects);
1391
+ while (parent) {
1392
+ if (parent.pendingBranch) {
1393
+ parent.effects.push(...effects);
1383
1394
  hasUnresolvedAncestor = true;
1384
1395
  break;
1385
1396
  }
1386
- parent2 = parent2.parent;
1397
+ parent = parent.parent;
1387
1398
  }
1388
1399
  if (!hasUnresolvedAncestor) {
1389
1400
  queuePostFlushCb(effects);
1390
1401
  }
1391
1402
  suspense.effects = [];
1403
+ if (isSuspensible) {
1404
+ if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
1405
+ parentSuspense.deps--;
1406
+ if (parentSuspense.deps === 0) {
1407
+ parentSuspense.resolve();
1408
+ }
1409
+ }
1410
+ }
1392
1411
  triggerEvent(vnode2, "onResolve");
1393
1412
  },
1394
1413
  fallback(fallbackVNode) {
@@ -1488,13 +1507,13 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1488
1507
  }
1489
1508
  });
1490
1509
  },
1491
- unmount(parentSuspense, doRemove) {
1510
+ unmount(parentSuspense2, doRemove) {
1492
1511
  suspense.isUnmounted = true;
1493
1512
  if (suspense.activeBranch) {
1494
1513
  unmount(
1495
1514
  suspense.activeBranch,
1496
1515
  parentComponent,
1497
- parentSuspense,
1516
+ parentSuspense2,
1498
1517
  doRemove
1499
1518
  );
1500
1519
  }
@@ -1502,7 +1521,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
1502
1521
  unmount(
1503
1522
  suspense.pendingBranch,
1504
1523
  parentComponent,
1505
- parentSuspense,
1524
+ parentSuspense2,
1506
1525
  doRemove
1507
1526
  );
1508
1527
  }
@@ -1595,36 +1614,6 @@ function setActiveBranch(suspense, branch) {
1595
1614
  }
1596
1615
  }
1597
1616
 
1598
- function provide(key, value) {
1599
- if (!currentInstance) {
1600
- if (process.env.NODE_ENV !== "production") {
1601
- warn(`provide() can only be used inside setup().`);
1602
- }
1603
- } else {
1604
- let provides = currentInstance.provides;
1605
- const parentProvides = currentInstance.parent && currentInstance.parent.provides;
1606
- if (parentProvides === provides) {
1607
- provides = currentInstance.provides = Object.create(parentProvides);
1608
- }
1609
- provides[key] = value;
1610
- }
1611
- }
1612
- function inject(key, defaultValue, treatDefaultAsFactory = false) {
1613
- const instance = currentInstance || currentRenderingInstance;
1614
- if (instance) {
1615
- const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
1616
- if (provides && key in provides) {
1617
- return provides[key];
1618
- } else if (arguments.length > 1) {
1619
- return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
1620
- } else if (process.env.NODE_ENV !== "production") {
1621
- warn(`injection "${String(key)}" not found.`);
1622
- }
1623
- } else if (process.env.NODE_ENV !== "production") {
1624
- warn(`inject() can only be used inside setup() or functional components.`);
1625
- }
1626
- }
1627
-
1628
1617
  function watchEffect(effect, options) {
1629
1618
  return doWatch(effect, null, options);
1630
1619
  }
@@ -1871,6 +1860,65 @@ function traverse(value, seen) {
1871
1860
  return value;
1872
1861
  }
1873
1862
 
1863
+ function validateDirectiveName(name) {
1864
+ if (isBuiltInDirective(name)) {
1865
+ warn("Do not use built-in directive ids as custom directive id: " + name);
1866
+ }
1867
+ }
1868
+ function withDirectives(vnode, directives) {
1869
+ const internalInstance = currentRenderingInstance;
1870
+ if (internalInstance === null) {
1871
+ process.env.NODE_ENV !== "production" && warn(`withDirectives can only be used inside render functions.`);
1872
+ return vnode;
1873
+ }
1874
+ const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
1875
+ const bindings = vnode.dirs || (vnode.dirs = []);
1876
+ for (let i = 0; i < directives.length; i++) {
1877
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
1878
+ if (dir) {
1879
+ if (isFunction(dir)) {
1880
+ dir = {
1881
+ mounted: dir,
1882
+ updated: dir
1883
+ };
1884
+ }
1885
+ if (dir.deep) {
1886
+ traverse(value);
1887
+ }
1888
+ bindings.push({
1889
+ dir,
1890
+ instance,
1891
+ value,
1892
+ oldValue: void 0,
1893
+ arg,
1894
+ modifiers
1895
+ });
1896
+ }
1897
+ }
1898
+ return vnode;
1899
+ }
1900
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
1901
+ const bindings = vnode.dirs;
1902
+ const oldBindings = prevVNode && prevVNode.dirs;
1903
+ for (let i = 0; i < bindings.length; i++) {
1904
+ const binding = bindings[i];
1905
+ if (oldBindings) {
1906
+ binding.oldValue = oldBindings[i].value;
1907
+ }
1908
+ let hook = binding.dir[name];
1909
+ if (hook) {
1910
+ pauseTracking();
1911
+ callWithAsyncErrorHandling(hook, instance, 8, [
1912
+ vnode.el,
1913
+ binding,
1914
+ vnode,
1915
+ prevVNode
1916
+ ]);
1917
+ resetTracking();
1918
+ }
1919
+ }
1920
+ }
1921
+
1874
1922
  function useTransitionState() {
1875
1923
  const state = {
1876
1924
  isMounted: false,
@@ -2636,65 +2684,6 @@ function onErrorCaptured(hook, target = currentInstance) {
2636
2684
  injectHook("ec", hook, target);
2637
2685
  }
2638
2686
 
2639
- function validateDirectiveName(name) {
2640
- if (isBuiltInDirective(name)) {
2641
- warn("Do not use built-in directive ids as custom directive id: " + name);
2642
- }
2643
- }
2644
- function withDirectives(vnode, directives) {
2645
- const internalInstance = currentRenderingInstance;
2646
- if (internalInstance === null) {
2647
- process.env.NODE_ENV !== "production" && warn(`withDirectives can only be used inside render functions.`);
2648
- return vnode;
2649
- }
2650
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
2651
- const bindings = vnode.dirs || (vnode.dirs = []);
2652
- for (let i = 0; i < directives.length; i++) {
2653
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
2654
- if (dir) {
2655
- if (isFunction(dir)) {
2656
- dir = {
2657
- mounted: dir,
2658
- updated: dir
2659
- };
2660
- }
2661
- if (dir.deep) {
2662
- traverse(value);
2663
- }
2664
- bindings.push({
2665
- dir,
2666
- instance,
2667
- value,
2668
- oldValue: void 0,
2669
- arg,
2670
- modifiers
2671
- });
2672
- }
2673
- }
2674
- return vnode;
2675
- }
2676
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
2677
- const bindings = vnode.dirs;
2678
- const oldBindings = prevVNode && prevVNode.dirs;
2679
- for (let i = 0; i < bindings.length; i++) {
2680
- const binding = bindings[i];
2681
- if (oldBindings) {
2682
- binding.oldValue = oldBindings[i].value;
2683
- }
2684
- let hook = binding.dir[name];
2685
- if (hook) {
2686
- pauseTracking();
2687
- callWithAsyncErrorHandling(hook, instance, 8, [
2688
- vnode.el,
2689
- binding,
2690
- vnode,
2691
- prevVNode
2692
- ]);
2693
- resetTracking();
2694
- }
2695
- }
2696
- }
2697
-
2698
2687
  const COMPONENTS = "components";
2699
2688
  const DIRECTIVES = "directives";
2700
2689
  function resolveComponent(name, maybeSelfReference) {
@@ -2943,6 +2932,8 @@ const PublicInstanceProxyHandlers = {
2943
2932
  if (key === "$attrs") {
2944
2933
  track(instance, "get", key);
2945
2934
  process.env.NODE_ENV !== "production" && markAttrsAccessed();
2935
+ } else if (process.env.NODE_ENV !== "production" && key === "$slots") {
2936
+ track(instance, "get", key);
2946
2937
  }
2947
2938
  return publicGetter(instance);
2948
2939
  } else if (
@@ -3112,97 +3103,247 @@ function exposeSetupStateOnRenderContext(instance) {
3112
3103
  });
3113
3104
  }
3114
3105
 
3115
- function createDuplicateChecker() {
3116
- const cache = /* @__PURE__ */ Object.create(null);
3117
- return (type, key) => {
3118
- if (cache[key]) {
3119
- warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
3120
- } else {
3121
- cache[key] = type;
3122
- }
3123
- };
3106
+ const warnRuntimeUsage = (method) => warn(
3107
+ `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`
3108
+ );
3109
+ function defineProps() {
3110
+ if (process.env.NODE_ENV !== "production") {
3111
+ warnRuntimeUsage(`defineProps`);
3112
+ }
3113
+ return null;
3124
3114
  }
3125
- let shouldCacheAccess = true;
3126
- function applyOptions(instance) {
3127
- const options = resolveMergedOptions(instance);
3128
- const publicThis = instance.proxy;
3129
- const ctx = instance.ctx;
3130
- shouldCacheAccess = false;
3131
- if (options.beforeCreate) {
3132
- callHook(options.beforeCreate, instance, "bc");
3115
+ function defineEmits() {
3116
+ if (process.env.NODE_ENV !== "production") {
3117
+ warnRuntimeUsage(`defineEmits`);
3133
3118
  }
3134
- const {
3135
- // state
3136
- data: dataOptions,
3137
- computed: computedOptions,
3138
- methods,
3139
- watch: watchOptions,
3140
- provide: provideOptions,
3141
- inject: injectOptions,
3142
- // lifecycle
3143
- created,
3144
- beforeMount,
3145
- mounted,
3146
- beforeUpdate,
3147
- updated,
3148
- activated,
3149
- deactivated,
3150
- beforeDestroy,
3151
- beforeUnmount,
3152
- destroyed,
3153
- unmounted,
3154
- render,
3155
- renderTracked,
3156
- renderTriggered,
3157
- errorCaptured,
3158
- serverPrefetch,
3159
- // public API
3160
- expose,
3161
- inheritAttrs,
3162
- // assets
3163
- components,
3164
- directives,
3165
- filters
3166
- } = options;
3167
- const checkDuplicateProperties = process.env.NODE_ENV !== "production" ? createDuplicateChecker() : null;
3119
+ return null;
3120
+ }
3121
+ function defineExpose(exposed) {
3168
3122
  if (process.env.NODE_ENV !== "production") {
3169
- const [propsOptions] = instance.propsOptions;
3170
- if (propsOptions) {
3171
- for (const key in propsOptions) {
3172
- checkDuplicateProperties("Props" /* PROPS */, key);
3173
- }
3174
- }
3123
+ warnRuntimeUsage(`defineExpose`);
3175
3124
  }
3176
- if (injectOptions) {
3177
- resolveInjections(
3178
- injectOptions,
3179
- ctx,
3180
- checkDuplicateProperties,
3181
- instance.appContext.config.unwrapInjectedRef
3182
- );
3125
+ }
3126
+ function defineOptions(options) {
3127
+ if (process.env.NODE_ENV !== "production") {
3128
+ warnRuntimeUsage(`defineOptions`);
3183
3129
  }
3184
- if (methods) {
3185
- for (const key in methods) {
3186
- const methodHandler = methods[key];
3187
- if (isFunction(methodHandler)) {
3188
- if (process.env.NODE_ENV !== "production") {
3189
- Object.defineProperty(ctx, key, {
3190
- value: methodHandler.bind(publicThis),
3191
- configurable: true,
3192
- enumerable: true,
3193
- writable: true
3194
- });
3195
- } else {
3196
- ctx[key] = methodHandler.bind(publicThis);
3197
- }
3198
- if (process.env.NODE_ENV !== "production") {
3199
- checkDuplicateProperties("Methods" /* METHODS */, key);
3200
- }
3201
- } else if (process.env.NODE_ENV !== "production") {
3202
- warn(
3203
- `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
3204
- );
3205
- }
3130
+ }
3131
+ function defineSlots() {
3132
+ if (process.env.NODE_ENV !== "production") {
3133
+ warnRuntimeUsage(`defineSlots`);
3134
+ }
3135
+ return null;
3136
+ }
3137
+ function defineModel() {
3138
+ if (process.env.NODE_ENV !== "production") {
3139
+ warnRuntimeUsage("defineModel");
3140
+ }
3141
+ }
3142
+ function withDefaults(props, defaults) {
3143
+ if (process.env.NODE_ENV !== "production") {
3144
+ warnRuntimeUsage(`withDefaults`);
3145
+ }
3146
+ return null;
3147
+ }
3148
+ function useSlots() {
3149
+ return getContext().slots;
3150
+ }
3151
+ function useAttrs() {
3152
+ return getContext().attrs;
3153
+ }
3154
+ function useModel(props, name, options) {
3155
+ const i = getCurrentInstance();
3156
+ if (process.env.NODE_ENV !== "production" && !i) {
3157
+ warn(`useModel() called without active instance.`);
3158
+ return ref();
3159
+ }
3160
+ if (process.env.NODE_ENV !== "production" && !i.propsOptions[0][name]) {
3161
+ warn(`useModel() called with prop "${name}" which is not declared.`);
3162
+ return ref();
3163
+ }
3164
+ if (options && options.local) {
3165
+ const proxy = ref(props[name]);
3166
+ watch(
3167
+ () => props[name],
3168
+ (v) => proxy.value = v
3169
+ );
3170
+ watch(proxy, (value) => {
3171
+ if (value !== props[name]) {
3172
+ i.emit(`update:${name}`, value);
3173
+ }
3174
+ });
3175
+ return proxy;
3176
+ } else {
3177
+ return {
3178
+ __v_isRef: true,
3179
+ get value() {
3180
+ return props[name];
3181
+ },
3182
+ set value(value) {
3183
+ i.emit(`update:${name}`, value);
3184
+ }
3185
+ };
3186
+ }
3187
+ }
3188
+ function getContext() {
3189
+ const i = getCurrentInstance();
3190
+ if (process.env.NODE_ENV !== "production" && !i) {
3191
+ warn(`useContext() called without active instance.`);
3192
+ }
3193
+ return i.setupContext || (i.setupContext = createSetupContext(i));
3194
+ }
3195
+ function normalizePropsOrEmits(props) {
3196
+ return isArray(props) ? props.reduce(
3197
+ (normalized, p) => (normalized[p] = null, normalized),
3198
+ {}
3199
+ ) : props;
3200
+ }
3201
+ function mergeDefaults(raw, defaults) {
3202
+ const props = normalizePropsOrEmits(raw);
3203
+ for (const key in defaults) {
3204
+ if (key.startsWith("__skip"))
3205
+ continue;
3206
+ let opt = props[key];
3207
+ if (opt) {
3208
+ if (isArray(opt) || isFunction(opt)) {
3209
+ opt = props[key] = { type: opt, default: defaults[key] };
3210
+ } else {
3211
+ opt.default = defaults[key];
3212
+ }
3213
+ } else if (opt === null) {
3214
+ opt = props[key] = { default: defaults[key] };
3215
+ } else if (process.env.NODE_ENV !== "production") {
3216
+ warn(`props default key "${key}" has no corresponding declaration.`);
3217
+ }
3218
+ if (opt && defaults[`__skip_${key}`]) {
3219
+ opt.skipFactory = true;
3220
+ }
3221
+ }
3222
+ return props;
3223
+ }
3224
+ function mergeModels(a, b) {
3225
+ if (!a || !b)
3226
+ return a || b;
3227
+ if (isArray(a) && isArray(b))
3228
+ return a.concat(b);
3229
+ return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
3230
+ }
3231
+ function createPropsRestProxy(props, excludedKeys) {
3232
+ const ret = {};
3233
+ for (const key in props) {
3234
+ if (!excludedKeys.includes(key)) {
3235
+ Object.defineProperty(ret, key, {
3236
+ enumerable: true,
3237
+ get: () => props[key]
3238
+ });
3239
+ }
3240
+ }
3241
+ return ret;
3242
+ }
3243
+ function withAsyncContext(getAwaitable) {
3244
+ const ctx = getCurrentInstance();
3245
+ if (process.env.NODE_ENV !== "production" && !ctx) {
3246
+ warn(
3247
+ `withAsyncContext called without active current instance. This is likely a bug.`
3248
+ );
3249
+ }
3250
+ let awaitable = getAwaitable();
3251
+ unsetCurrentInstance();
3252
+ if (isPromise(awaitable)) {
3253
+ awaitable = awaitable.catch((e) => {
3254
+ setCurrentInstance(ctx);
3255
+ throw e;
3256
+ });
3257
+ }
3258
+ return [awaitable, () => setCurrentInstance(ctx)];
3259
+ }
3260
+
3261
+ function createDuplicateChecker() {
3262
+ const cache = /* @__PURE__ */ Object.create(null);
3263
+ return (type, key) => {
3264
+ if (cache[key]) {
3265
+ warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
3266
+ } else {
3267
+ cache[key] = type;
3268
+ }
3269
+ };
3270
+ }
3271
+ let shouldCacheAccess = true;
3272
+ function applyOptions(instance) {
3273
+ const options = resolveMergedOptions(instance);
3274
+ const publicThis = instance.proxy;
3275
+ const ctx = instance.ctx;
3276
+ shouldCacheAccess = false;
3277
+ if (options.beforeCreate) {
3278
+ callHook(options.beforeCreate, instance, "bc");
3279
+ }
3280
+ const {
3281
+ // state
3282
+ data: dataOptions,
3283
+ computed: computedOptions,
3284
+ methods,
3285
+ watch: watchOptions,
3286
+ provide: provideOptions,
3287
+ inject: injectOptions,
3288
+ // lifecycle
3289
+ created,
3290
+ beforeMount,
3291
+ mounted,
3292
+ beforeUpdate,
3293
+ updated,
3294
+ activated,
3295
+ deactivated,
3296
+ beforeDestroy,
3297
+ beforeUnmount,
3298
+ destroyed,
3299
+ unmounted,
3300
+ render,
3301
+ renderTracked,
3302
+ renderTriggered,
3303
+ errorCaptured,
3304
+ serverPrefetch,
3305
+ // public API
3306
+ expose,
3307
+ inheritAttrs,
3308
+ // assets
3309
+ components,
3310
+ directives,
3311
+ filters
3312
+ } = options;
3313
+ const checkDuplicateProperties = process.env.NODE_ENV !== "production" ? createDuplicateChecker() : null;
3314
+ if (process.env.NODE_ENV !== "production") {
3315
+ const [propsOptions] = instance.propsOptions;
3316
+ if (propsOptions) {
3317
+ for (const key in propsOptions) {
3318
+ checkDuplicateProperties("Props" /* PROPS */, key);
3319
+ }
3320
+ }
3321
+ }
3322
+ if (injectOptions) {
3323
+ resolveInjections(injectOptions, ctx, checkDuplicateProperties);
3324
+ }
3325
+ if (methods) {
3326
+ for (const key in methods) {
3327
+ const methodHandler = methods[key];
3328
+ if (isFunction(methodHandler)) {
3329
+ if (process.env.NODE_ENV !== "production") {
3330
+ Object.defineProperty(ctx, key, {
3331
+ value: methodHandler.bind(publicThis),
3332
+ configurable: true,
3333
+ enumerable: true,
3334
+ writable: true
3335
+ });
3336
+ } else {
3337
+ ctx[key] = methodHandler.bind(publicThis);
3338
+ }
3339
+ if (process.env.NODE_ENV !== "production") {
3340
+ checkDuplicateProperties("Methods" /* METHODS */, key);
3341
+ }
3342
+ } else if (process.env.NODE_ENV !== "production") {
3343
+ warn(
3344
+ `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
3345
+ );
3346
+ }
3206
3347
  }
3207
3348
  }
3208
3349
  if (dataOptions) {
@@ -3321,7 +3462,7 @@ function applyOptions(instance) {
3321
3462
  if (directives)
3322
3463
  instance.directives = directives;
3323
3464
  }
3324
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
3465
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
3325
3466
  if (isArray(injectOptions)) {
3326
3467
  injectOptions = normalizeInject(injectOptions);
3327
3468
  }
@@ -3343,21 +3484,12 @@ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP,
3343
3484
  injected = inject(opt);
3344
3485
  }
3345
3486
  if (isRef(injected)) {
3346
- if (unwrapRef) {
3347
- Object.defineProperty(ctx, key, {
3348
- enumerable: true,
3349
- configurable: true,
3350
- get: () => injected.value,
3351
- set: (v) => injected.value = v
3352
- });
3353
- } else {
3354
- if (process.env.NODE_ENV !== "production") {
3355
- warn(
3356
- `injected property "${key}" is a ref and will be auto-unwrapped and no longer needs \`.value\` in the next minor release. To opt-in to the new behavior now, set \`app.config.unwrapInjectedRef = true\` (this config is temporary and will not be needed in the future.)`
3357
- );
3358
- }
3359
- ctx[key] = injected;
3360
- }
3487
+ Object.defineProperty(ctx, key, {
3488
+ enumerable: true,
3489
+ configurable: true,
3490
+ get: () => injected.value,
3491
+ set: (v) => injected.value = v
3492
+ });
3361
3493
  } else {
3362
3494
  ctx[key] = injected;
3363
3495
  }
@@ -3453,10 +3585,8 @@ function mergeOptions(to, from, strats, asMixin = false) {
3453
3585
  }
3454
3586
  const internalOptionMergeStrats = {
3455
3587
  data: mergeDataFn,
3456
- props: mergeObjectOptions,
3457
- // TODO
3458
- emits: mergeObjectOptions,
3459
- // TODO
3588
+ props: mergeEmitsOrPropsOptions,
3589
+ emits: mergeEmitsOrPropsOptions,
3460
3590
  // objects
3461
3591
  methods: mergeObjectOptions,
3462
3592
  computed: mergeObjectOptions,
@@ -3515,7 +3645,21 @@ function mergeAsArray(to, from) {
3515
3645
  return to ? [...new Set([].concat(to, from))] : from;
3516
3646
  }
3517
3647
  function mergeObjectOptions(to, from) {
3518
- return to ? extend(extend(/* @__PURE__ */ Object.create(null), to), from) : from;
3648
+ return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
3649
+ }
3650
+ function mergeEmitsOrPropsOptions(to, from) {
3651
+ if (to) {
3652
+ if (isArray(to) && isArray(from)) {
3653
+ return [.../* @__PURE__ */ new Set([...to, ...from])];
3654
+ }
3655
+ return extend(
3656
+ /* @__PURE__ */ Object.create(null),
3657
+ normalizePropsOrEmits(to),
3658
+ normalizePropsOrEmits(from != null ? from : {})
3659
+ );
3660
+ } else {
3661
+ return from;
3662
+ }
3519
3663
  }
3520
3664
  function mergeWatchOptions(to, from) {
3521
3665
  if (!to)
@@ -3529,31 +3673,257 @@ function mergeWatchOptions(to, from) {
3529
3673
  return merged;
3530
3674
  }
3531
3675
 
3532
- function initProps(instance, rawProps, isStateful, isSSR = false) {
3533
- const props = {};
3534
- const attrs = {};
3535
- def(attrs, InternalObjectKey, 1);
3536
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3537
- setFullProps(instance, rawProps, props, attrs);
3538
- for (const key in instance.propsOptions[0]) {
3539
- if (!(key in props)) {
3540
- props[key] = void 0;
3676
+ function createAppContext() {
3677
+ return {
3678
+ app: null,
3679
+ config: {
3680
+ isNativeTag: NO,
3681
+ performance: false,
3682
+ globalProperties: {},
3683
+ optionMergeStrategies: {},
3684
+ errorHandler: void 0,
3685
+ warnHandler: void 0,
3686
+ compilerOptions: {}
3687
+ },
3688
+ mixins: [],
3689
+ components: {},
3690
+ directives: {},
3691
+ provides: /* @__PURE__ */ Object.create(null),
3692
+ optionsCache: /* @__PURE__ */ new WeakMap(),
3693
+ propsCache: /* @__PURE__ */ new WeakMap(),
3694
+ emitsCache: /* @__PURE__ */ new WeakMap()
3695
+ };
3696
+ }
3697
+ let uid$1 = 0;
3698
+ function createAppAPI(render, hydrate) {
3699
+ return function createApp(rootComponent, rootProps = null) {
3700
+ if (!isFunction(rootComponent)) {
3701
+ rootComponent = extend({}, rootComponent);
3541
3702
  }
3542
- }
3543
- if (process.env.NODE_ENV !== "production") {
3544
- validateProps(rawProps || {}, props, instance);
3545
- }
3546
- if (isStateful) {
3547
- instance.props = isSSR ? props : shallowReactive(props);
3548
- } else {
3549
- if (!instance.type.props) {
3550
- instance.props = attrs;
3551
- } else {
3552
- instance.props = props;
3703
+ if (rootProps != null && !isObject(rootProps)) {
3704
+ process.env.NODE_ENV !== "production" && warn(`root props passed to app.mount() must be an object.`);
3705
+ rootProps = null;
3553
3706
  }
3554
- }
3555
- instance.attrs = attrs;
3556
- }
3707
+ const context = createAppContext();
3708
+ if (process.env.NODE_ENV !== "production") {
3709
+ Object.defineProperty(context.config, "unwrapInjectedRef", {
3710
+ get() {
3711
+ return true;
3712
+ },
3713
+ set() {
3714
+ warn(
3715
+ `app.config.unwrapInjectedRef has been deprecated. 3.3 now alawys unwraps injected refs in Options API.`
3716
+ );
3717
+ }
3718
+ });
3719
+ }
3720
+ const installedPlugins = /* @__PURE__ */ new Set();
3721
+ let isMounted = false;
3722
+ const app = context.app = {
3723
+ _uid: uid$1++,
3724
+ _component: rootComponent,
3725
+ _props: rootProps,
3726
+ _container: null,
3727
+ _context: context,
3728
+ _instance: null,
3729
+ version,
3730
+ get config() {
3731
+ return context.config;
3732
+ },
3733
+ set config(v) {
3734
+ if (process.env.NODE_ENV !== "production") {
3735
+ warn(
3736
+ `app.config cannot be replaced. Modify individual options instead.`
3737
+ );
3738
+ }
3739
+ },
3740
+ use(plugin, ...options) {
3741
+ if (installedPlugins.has(plugin)) {
3742
+ process.env.NODE_ENV !== "production" && warn(`Plugin has already been applied to target app.`);
3743
+ } else if (plugin && isFunction(plugin.install)) {
3744
+ installedPlugins.add(plugin);
3745
+ plugin.install(app, ...options);
3746
+ } else if (isFunction(plugin)) {
3747
+ installedPlugins.add(plugin);
3748
+ plugin(app, ...options);
3749
+ } else if (process.env.NODE_ENV !== "production") {
3750
+ warn(
3751
+ `A plugin must either be a function or an object with an "install" function.`
3752
+ );
3753
+ }
3754
+ return app;
3755
+ },
3756
+ mixin(mixin) {
3757
+ if (__VUE_OPTIONS_API__) {
3758
+ if (!context.mixins.includes(mixin)) {
3759
+ context.mixins.push(mixin);
3760
+ } else if (process.env.NODE_ENV !== "production") {
3761
+ warn(
3762
+ "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
3763
+ );
3764
+ }
3765
+ } else if (process.env.NODE_ENV !== "production") {
3766
+ warn("Mixins are only available in builds supporting Options API");
3767
+ }
3768
+ return app;
3769
+ },
3770
+ component(name, component) {
3771
+ if (process.env.NODE_ENV !== "production") {
3772
+ validateComponentName(name, context.config);
3773
+ }
3774
+ if (!component) {
3775
+ return context.components[name];
3776
+ }
3777
+ if (process.env.NODE_ENV !== "production" && context.components[name]) {
3778
+ warn(`Component "${name}" has already been registered in target app.`);
3779
+ }
3780
+ context.components[name] = component;
3781
+ return app;
3782
+ },
3783
+ directive(name, directive) {
3784
+ if (process.env.NODE_ENV !== "production") {
3785
+ validateDirectiveName(name);
3786
+ }
3787
+ if (!directive) {
3788
+ return context.directives[name];
3789
+ }
3790
+ if (process.env.NODE_ENV !== "production" && context.directives[name]) {
3791
+ warn(`Directive "${name}" has already been registered in target app.`);
3792
+ }
3793
+ context.directives[name] = directive;
3794
+ return app;
3795
+ },
3796
+ mount(rootContainer, isHydrate, isSVG) {
3797
+ if (!isMounted) {
3798
+ if (process.env.NODE_ENV !== "production" && rootContainer.__vue_app__) {
3799
+ warn(
3800
+ `There is already an app instance mounted on the host container.
3801
+ If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
3802
+ );
3803
+ }
3804
+ const vnode = createVNode(
3805
+ rootComponent,
3806
+ rootProps
3807
+ );
3808
+ vnode.appContext = context;
3809
+ if (process.env.NODE_ENV !== "production") {
3810
+ context.reload = () => {
3811
+ render(cloneVNode(vnode), rootContainer, isSVG);
3812
+ };
3813
+ }
3814
+ if (isHydrate && hydrate) {
3815
+ hydrate(vnode, rootContainer);
3816
+ } else {
3817
+ render(vnode, rootContainer, isSVG);
3818
+ }
3819
+ isMounted = true;
3820
+ app._container = rootContainer;
3821
+ rootContainer.__vue_app__ = app;
3822
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
3823
+ app._instance = vnode.component;
3824
+ devtoolsInitApp(app, version);
3825
+ }
3826
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
3827
+ } else if (process.env.NODE_ENV !== "production") {
3828
+ warn(
3829
+ `App has already been mounted.
3830
+ If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
3831
+ );
3832
+ }
3833
+ },
3834
+ unmount() {
3835
+ if (isMounted) {
3836
+ render(null, app._container);
3837
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
3838
+ app._instance = null;
3839
+ devtoolsUnmountApp(app);
3840
+ }
3841
+ delete app._container.__vue_app__;
3842
+ } else if (process.env.NODE_ENV !== "production") {
3843
+ warn(`Cannot unmount an app that is not mounted.`);
3844
+ }
3845
+ },
3846
+ provide(key, value) {
3847
+ if (process.env.NODE_ENV !== "production" && key in context.provides) {
3848
+ warn(
3849
+ `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
3850
+ );
3851
+ }
3852
+ context.provides[key] = value;
3853
+ return app;
3854
+ },
3855
+ runWithContext(fn) {
3856
+ currentApp = app;
3857
+ try {
3858
+ return fn();
3859
+ } finally {
3860
+ currentApp = null;
3861
+ }
3862
+ }
3863
+ };
3864
+ return app;
3865
+ };
3866
+ }
3867
+ let currentApp = null;
3868
+
3869
+ function provide(key, value) {
3870
+ if (!currentInstance) {
3871
+ if (process.env.NODE_ENV !== "production") {
3872
+ warn(`provide() can only be used inside setup().`);
3873
+ }
3874
+ } else {
3875
+ let provides = currentInstance.provides;
3876
+ const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3877
+ if (parentProvides === provides) {
3878
+ provides = currentInstance.provides = Object.create(parentProvides);
3879
+ }
3880
+ provides[key] = value;
3881
+ }
3882
+ }
3883
+ function inject(key, defaultValue, treatDefaultAsFactory = false) {
3884
+ const instance = currentInstance || currentRenderingInstance;
3885
+ if (instance || currentApp) {
3886
+ const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
3887
+ if (provides && key in provides) {
3888
+ return provides[key];
3889
+ } else if (arguments.length > 1) {
3890
+ return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
3891
+ } else if (process.env.NODE_ENV !== "production") {
3892
+ warn(`injection "${String(key)}" not found.`);
3893
+ }
3894
+ } else if (process.env.NODE_ENV !== "production") {
3895
+ warn(`inject() can only be used inside setup() or functional components.`);
3896
+ }
3897
+ }
3898
+ function hasInjectionContext() {
3899
+ return !!(currentInstance || currentRenderingInstance || currentApp);
3900
+ }
3901
+
3902
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
3903
+ const props = {};
3904
+ const attrs = {};
3905
+ def(attrs, InternalObjectKey, 1);
3906
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
3907
+ setFullProps(instance, rawProps, props, attrs);
3908
+ for (const key in instance.propsOptions[0]) {
3909
+ if (!(key in props)) {
3910
+ props[key] = void 0;
3911
+ }
3912
+ }
3913
+ if (process.env.NODE_ENV !== "production") {
3914
+ validateProps(rawProps || {}, props, instance);
3915
+ }
3916
+ if (isStateful) {
3917
+ instance.props = isSSR ? props : shallowReactive(props);
3918
+ } else {
3919
+ if (!instance.type.props) {
3920
+ instance.props = attrs;
3921
+ } else {
3922
+ instance.props = props;
3923
+ }
3924
+ }
3925
+ instance.attrs = attrs;
3926
+ }
3557
3927
  function isInHmrContext(instance) {
3558
3928
  while (instance) {
3559
3929
  if (instance.type.__hmrId)
@@ -3844,7 +4214,7 @@ function validateProp(name, value, prop, isAbsent) {
3844
4214
  warn('Missing required prop: "' + name + '"');
3845
4215
  return;
3846
4216
  }
3847
- if (value == null && !prop.required) {
4217
+ if (value == null && !required) {
3848
4218
  return;
3849
4219
  }
3850
4220
  if (type != null && type !== true && !skipCheck) {
@@ -3875,324 +4245,153 @@ function assertType(value, type) {
3875
4245
  const t = typeof value;
3876
4246
  valid = t === expectedType.toLowerCase();
3877
4247
  if (!valid && t === "object") {
3878
- valid = value instanceof type;
3879
- }
3880
- } else if (expectedType === "Object") {
3881
- valid = isObject(value);
3882
- } else if (expectedType === "Array") {
3883
- valid = isArray(value);
3884
- } else if (expectedType === "null") {
3885
- valid = value === null;
3886
- } else {
3887
- valid = value instanceof type;
3888
- }
3889
- return {
3890
- valid,
3891
- expectedType
3892
- };
3893
- }
3894
- function getInvalidTypeMessage(name, value, expectedTypes) {
3895
- let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
3896
- const expectedType = expectedTypes[0];
3897
- const receivedType = toRawType(value);
3898
- const expectedValue = styleValue(value, expectedType);
3899
- const receivedValue = styleValue(value, receivedType);
3900
- if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
3901
- message += ` with value ${expectedValue}`;
3902
- }
3903
- message += `, got ${receivedType} `;
3904
- if (isExplicable(receivedType)) {
3905
- message += `with value ${receivedValue}.`;
3906
- }
3907
- return message;
3908
- }
3909
- function styleValue(value, type) {
3910
- if (type === "String") {
3911
- return `"${value}"`;
3912
- } else if (type === "Number") {
3913
- return `${Number(value)}`;
3914
- } else {
3915
- return `${value}`;
3916
- }
3917
- }
3918
- function isExplicable(type) {
3919
- const explicitTypes = ["string", "number", "boolean"];
3920
- return explicitTypes.some((elem) => type.toLowerCase() === elem);
3921
- }
3922
- function isBoolean(...args) {
3923
- return args.some((elem) => elem.toLowerCase() === "boolean");
3924
- }
3925
-
3926
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
3927
- const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
3928
- const normalizeSlot = (key, rawSlot, ctx) => {
3929
- if (rawSlot._n) {
3930
- return rawSlot;
3931
- }
3932
- const normalized = withCtx((...args) => {
3933
- if (process.env.NODE_ENV !== "production" && currentInstance) {
3934
- warn(
3935
- `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
3936
- );
3937
- }
3938
- return normalizeSlotValue(rawSlot(...args));
3939
- }, ctx);
3940
- normalized._c = false;
3941
- return normalized;
3942
- };
3943
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
3944
- const ctx = rawSlots._ctx;
3945
- for (const key in rawSlots) {
3946
- if (isInternalKey(key))
3947
- continue;
3948
- const value = rawSlots[key];
3949
- if (isFunction(value)) {
3950
- slots[key] = normalizeSlot(key, value, ctx);
3951
- } else if (value != null) {
3952
- if (process.env.NODE_ENV !== "production" && true) {
3953
- warn(
3954
- `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
3955
- );
3956
- }
3957
- const normalized = normalizeSlotValue(value);
3958
- slots[key] = () => normalized;
3959
- }
3960
- }
3961
- };
3962
- const normalizeVNodeSlots = (instance, children) => {
3963
- if (process.env.NODE_ENV !== "production" && !isKeepAlive(instance.vnode) && true) {
3964
- warn(
3965
- `Non-function value encountered for default slot. Prefer function slots for better performance.`
3966
- );
3967
- }
3968
- const normalized = normalizeSlotValue(children);
3969
- instance.slots.default = () => normalized;
3970
- };
3971
- const initSlots = (instance, children) => {
3972
- if (instance.vnode.shapeFlag & 32) {
3973
- const type = children._;
3974
- if (type) {
3975
- instance.slots = toRaw(children);
3976
- def(children, "_", type);
3977
- } else {
3978
- normalizeObjectSlots(
3979
- children,
3980
- instance.slots = {});
3981
- }
3982
- } else {
3983
- instance.slots = {};
3984
- if (children) {
3985
- normalizeVNodeSlots(instance, children);
3986
- }
3987
- }
3988
- def(instance.slots, InternalObjectKey, 1);
3989
- };
3990
- const updateSlots = (instance, children, optimized) => {
3991
- const { vnode, slots } = instance;
3992
- let needDeletionCheck = true;
3993
- let deletionComparisonTarget = EMPTY_OBJ;
3994
- if (vnode.shapeFlag & 32) {
3995
- const type = children._;
3996
- if (type) {
3997
- if (process.env.NODE_ENV !== "production" && isHmrUpdating) {
3998
- extend(slots, children);
3999
- } else if (optimized && type === 1) {
4000
- needDeletionCheck = false;
4001
- } else {
4002
- extend(slots, children);
4003
- if (!optimized && type === 1) {
4004
- delete slots._;
4005
- }
4006
- }
4007
- } else {
4008
- needDeletionCheck = !children.$stable;
4009
- normalizeObjectSlots(children, slots);
4010
- }
4011
- deletionComparisonTarget = children;
4012
- } else if (children) {
4013
- normalizeVNodeSlots(instance, children);
4014
- deletionComparisonTarget = { default: 1 };
4015
- }
4016
- if (needDeletionCheck) {
4017
- for (const key in slots) {
4018
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
4019
- delete slots[key];
4020
- }
4021
- }
4022
- }
4023
- };
4024
-
4025
- function createAppContext() {
4026
- return {
4027
- app: null,
4028
- config: {
4029
- isNativeTag: NO,
4030
- performance: false,
4031
- globalProperties: {},
4032
- optionMergeStrategies: {},
4033
- errorHandler: void 0,
4034
- warnHandler: void 0,
4035
- compilerOptions: {}
4036
- },
4037
- mixins: [],
4038
- components: {},
4039
- directives: {},
4040
- provides: /* @__PURE__ */ Object.create(null),
4041
- optionsCache: /* @__PURE__ */ new WeakMap(),
4042
- propsCache: /* @__PURE__ */ new WeakMap(),
4043
- emitsCache: /* @__PURE__ */ new WeakMap()
4044
- };
4045
- }
4046
- let uid$1 = 0;
4047
- function createAppAPI(render, hydrate) {
4048
- return function createApp(rootComponent, rootProps = null) {
4049
- if (!isFunction(rootComponent)) {
4050
- rootComponent = extend({}, rootComponent);
4051
- }
4052
- if (rootProps != null && !isObject(rootProps)) {
4053
- process.env.NODE_ENV !== "production" && warn(`root props passed to app.mount() must be an object.`);
4054
- rootProps = null;
4055
- }
4056
- const context = createAppContext();
4057
- const installedPlugins = /* @__PURE__ */ new Set();
4058
- let isMounted = false;
4059
- const app = context.app = {
4060
- _uid: uid$1++,
4061
- _component: rootComponent,
4062
- _props: rootProps,
4063
- _container: null,
4064
- _context: context,
4065
- _instance: null,
4066
- version,
4067
- get config() {
4068
- return context.config;
4069
- },
4070
- set config(v) {
4071
- if (process.env.NODE_ENV !== "production") {
4072
- warn(
4073
- `app.config cannot be replaced. Modify individual options instead.`
4074
- );
4075
- }
4076
- },
4077
- use(plugin, ...options) {
4078
- if (installedPlugins.has(plugin)) {
4079
- process.env.NODE_ENV !== "production" && warn(`Plugin has already been applied to target app.`);
4080
- } else if (plugin && isFunction(plugin.install)) {
4081
- installedPlugins.add(plugin);
4082
- plugin.install(app, ...options);
4083
- } else if (isFunction(plugin)) {
4084
- installedPlugins.add(plugin);
4085
- plugin(app, ...options);
4086
- } else if (process.env.NODE_ENV !== "production") {
4087
- warn(
4088
- `A plugin must either be a function or an object with an "install" function.`
4089
- );
4090
- }
4091
- return app;
4092
- },
4093
- mixin(mixin) {
4094
- if (__VUE_OPTIONS_API__) {
4095
- if (!context.mixins.includes(mixin)) {
4096
- context.mixins.push(mixin);
4097
- } else if (process.env.NODE_ENV !== "production") {
4098
- warn(
4099
- "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
4100
- );
4101
- }
4102
- } else if (process.env.NODE_ENV !== "production") {
4103
- warn("Mixins are only available in builds supporting Options API");
4104
- }
4105
- return app;
4106
- },
4107
- component(name, component) {
4108
- if (process.env.NODE_ENV !== "production") {
4109
- validateComponentName(name, context.config);
4110
- }
4111
- if (!component) {
4112
- return context.components[name];
4113
- }
4114
- if (process.env.NODE_ENV !== "production" && context.components[name]) {
4115
- warn(`Component "${name}" has already been registered in target app.`);
4116
- }
4117
- context.components[name] = component;
4118
- return app;
4119
- },
4120
- directive(name, directive) {
4121
- if (process.env.NODE_ENV !== "production") {
4122
- validateDirectiveName(name);
4123
- }
4124
- if (!directive) {
4125
- return context.directives[name];
4126
- }
4127
- if (process.env.NODE_ENV !== "production" && context.directives[name]) {
4128
- warn(`Directive "${name}" has already been registered in target app.`);
4129
- }
4130
- context.directives[name] = directive;
4131
- return app;
4132
- },
4133
- mount(rootContainer, isHydrate, isSVG) {
4134
- if (!isMounted) {
4135
- if (process.env.NODE_ENV !== "production" && rootContainer.__vue_app__) {
4136
- warn(
4137
- `There is already an app instance mounted on the host container.
4138
- If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
4139
- );
4140
- }
4141
- const vnode = createVNode(
4142
- rootComponent,
4143
- rootProps
4144
- );
4145
- vnode.appContext = context;
4146
- if (process.env.NODE_ENV !== "production") {
4147
- context.reload = () => {
4148
- render(cloneVNode(vnode), rootContainer, isSVG);
4149
- };
4150
- }
4151
- if (isHydrate && hydrate) {
4152
- hydrate(vnode, rootContainer);
4153
- } else {
4154
- render(vnode, rootContainer, isSVG);
4155
- }
4156
- isMounted = true;
4157
- app._container = rootContainer;
4158
- rootContainer.__vue_app__ = app;
4159
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
4160
- app._instance = vnode.component;
4161
- devtoolsInitApp(app, version);
4162
- }
4163
- return getExposeProxy(vnode.component) || vnode.component.proxy;
4164
- } else if (process.env.NODE_ENV !== "production") {
4165
- warn(
4166
- `App has already been mounted.
4167
- If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
4168
- );
4169
- }
4170
- },
4171
- unmount() {
4172
- if (isMounted) {
4173
- render(null, app._container);
4174
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
4175
- app._instance = null;
4176
- devtoolsUnmountApp(app);
4177
- }
4178
- delete app._container.__vue_app__;
4179
- } else if (process.env.NODE_ENV !== "production") {
4180
- warn(`Cannot unmount an app that is not mounted.`);
4181
- }
4182
- },
4183
- provide(key, value) {
4184
- if (process.env.NODE_ENV !== "production" && key in context.provides) {
4185
- warn(
4186
- `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
4187
- );
4188
- }
4189
- context.provides[key] = value;
4190
- return app;
4191
- }
4192
- };
4193
- return app;
4248
+ valid = value instanceof type;
4249
+ }
4250
+ } else if (expectedType === "Object") {
4251
+ valid = isObject(value);
4252
+ } else if (expectedType === "Array") {
4253
+ valid = isArray(value);
4254
+ } else if (expectedType === "null") {
4255
+ valid = value === null;
4256
+ } else {
4257
+ valid = value instanceof type;
4258
+ }
4259
+ return {
4260
+ valid,
4261
+ expectedType
4194
4262
  };
4195
4263
  }
4264
+ function getInvalidTypeMessage(name, value, expectedTypes) {
4265
+ let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
4266
+ const expectedType = expectedTypes[0];
4267
+ const receivedType = toRawType(value);
4268
+ const expectedValue = styleValue(value, expectedType);
4269
+ const receivedValue = styleValue(value, receivedType);
4270
+ if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
4271
+ message += ` with value ${expectedValue}`;
4272
+ }
4273
+ message += `, got ${receivedType} `;
4274
+ if (isExplicable(receivedType)) {
4275
+ message += `with value ${receivedValue}.`;
4276
+ }
4277
+ return message;
4278
+ }
4279
+ function styleValue(value, type) {
4280
+ if (type === "String") {
4281
+ return `"${value}"`;
4282
+ } else if (type === "Number") {
4283
+ return `${Number(value)}`;
4284
+ } else {
4285
+ return `${value}`;
4286
+ }
4287
+ }
4288
+ function isExplicable(type) {
4289
+ const explicitTypes = ["string", "number", "boolean"];
4290
+ return explicitTypes.some((elem) => type.toLowerCase() === elem);
4291
+ }
4292
+ function isBoolean(...args) {
4293
+ return args.some((elem) => elem.toLowerCase() === "boolean");
4294
+ }
4295
+
4296
+ const isInternalKey = (key) => key[0] === "_" || key === "$stable";
4297
+ const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
4298
+ const normalizeSlot = (key, rawSlot, ctx) => {
4299
+ if (rawSlot._n) {
4300
+ return rawSlot;
4301
+ }
4302
+ const normalized = withCtx((...args) => {
4303
+ if (process.env.NODE_ENV !== "production" && currentInstance) {
4304
+ warn(
4305
+ `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
4306
+ );
4307
+ }
4308
+ return normalizeSlotValue(rawSlot(...args));
4309
+ }, ctx);
4310
+ normalized._c = false;
4311
+ return normalized;
4312
+ };
4313
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
4314
+ const ctx = rawSlots._ctx;
4315
+ for (const key in rawSlots) {
4316
+ if (isInternalKey(key))
4317
+ continue;
4318
+ const value = rawSlots[key];
4319
+ if (isFunction(value)) {
4320
+ slots[key] = normalizeSlot(key, value, ctx);
4321
+ } else if (value != null) {
4322
+ if (process.env.NODE_ENV !== "production" && true) {
4323
+ warn(
4324
+ `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
4325
+ );
4326
+ }
4327
+ const normalized = normalizeSlotValue(value);
4328
+ slots[key] = () => normalized;
4329
+ }
4330
+ }
4331
+ };
4332
+ const normalizeVNodeSlots = (instance, children) => {
4333
+ if (process.env.NODE_ENV !== "production" && !isKeepAlive(instance.vnode) && true) {
4334
+ warn(
4335
+ `Non-function value encountered for default slot. Prefer function slots for better performance.`
4336
+ );
4337
+ }
4338
+ const normalized = normalizeSlotValue(children);
4339
+ instance.slots.default = () => normalized;
4340
+ };
4341
+ const initSlots = (instance, children) => {
4342
+ if (instance.vnode.shapeFlag & 32) {
4343
+ const type = children._;
4344
+ if (type) {
4345
+ instance.slots = toRaw(children);
4346
+ def(children, "_", type);
4347
+ } else {
4348
+ normalizeObjectSlots(
4349
+ children,
4350
+ instance.slots = {});
4351
+ }
4352
+ } else {
4353
+ instance.slots = {};
4354
+ if (children) {
4355
+ normalizeVNodeSlots(instance, children);
4356
+ }
4357
+ }
4358
+ def(instance.slots, InternalObjectKey, 1);
4359
+ };
4360
+ const updateSlots = (instance, children, optimized) => {
4361
+ const { vnode, slots } = instance;
4362
+ let needDeletionCheck = true;
4363
+ let deletionComparisonTarget = EMPTY_OBJ;
4364
+ if (vnode.shapeFlag & 32) {
4365
+ const type = children._;
4366
+ if (type) {
4367
+ if (process.env.NODE_ENV !== "production" && isHmrUpdating) {
4368
+ extend(slots, children);
4369
+ trigger(instance, "set", "$slots");
4370
+ } else if (optimized && type === 1) {
4371
+ needDeletionCheck = false;
4372
+ } else {
4373
+ extend(slots, children);
4374
+ if (!optimized && type === 1) {
4375
+ delete slots._;
4376
+ }
4377
+ }
4378
+ } else {
4379
+ needDeletionCheck = !children.$stable;
4380
+ normalizeObjectSlots(children, slots);
4381
+ }
4382
+ deletionComparisonTarget = children;
4383
+ } else if (children) {
4384
+ normalizeVNodeSlots(instance, children);
4385
+ deletionComparisonTarget = { default: 1 };
4386
+ }
4387
+ if (needDeletionCheck) {
4388
+ for (const key in slots) {
4389
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
4390
+ delete slots[key];
4391
+ }
4392
+ }
4393
+ }
4394
+ };
4196
4395
 
4197
4396
  function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
4198
4397
  if (isArray(rawRef)) {
@@ -5119,7 +5318,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5119
5318
  areChildrenSVG,
5120
5319
  slotScopeIds
5121
5320
  );
5122
- if (process.env.NODE_ENV !== "production" && parentComponent && parentComponent.type.__hmrId) {
5321
+ if (process.env.NODE_ENV !== "production") {
5123
5322
  traverseStaticChildren(n1, n2);
5124
5323
  }
5125
5324
  } else if (!optimized) {
@@ -5313,7 +5512,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5313
5512
  isSVG,
5314
5513
  slotScopeIds
5315
5514
  );
5316
- if (process.env.NODE_ENV !== "production" && parentComponent && parentComponent.type.__hmrId) {
5515
+ if (process.env.NODE_ENV !== "production") {
5317
5516
  traverseStaticChildren(n1, n2);
5318
5517
  } else if (
5319
5518
  // #2080 if the stable fragment has a key, it's a <template v-for> that may
@@ -6901,6 +7100,8 @@ function createComponentInstance(vnode, parent, suspense) {
6901
7100
  refs: EMPTY_OBJ,
6902
7101
  setupState: EMPTY_OBJ,
6903
7102
  setupContext: null,
7103
+ attrsProxy: null,
7104
+ slotsProxy: null,
6904
7105
  // suspense related
6905
7106
  suspense,
6906
7107
  suspenseId: suspense ? suspense.pendingId : 0,
@@ -7142,8 +7343,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
7142
7343
  }
7143
7344
  }
7144
7345
  }
7145
- function createAttrsProxy(instance) {
7146
- return new Proxy(
7346
+ function getAttrsProxy(instance) {
7347
+ return instance.attrsProxy || (instance.attrsProxy = new Proxy(
7147
7348
  instance.attrs,
7148
7349
  process.env.NODE_ENV !== "production" ? {
7149
7350
  get(target, key) {
@@ -7165,7 +7366,23 @@ function createAttrsProxy(instance) {
7165
7366
  return target[key];
7166
7367
  }
7167
7368
  }
7168
- );
7369
+ ));
7370
+ }
7371
+ function getSlotsProxy(instance) {
7372
+ return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
7373
+ get(target, key) {
7374
+ track(instance, "get", "$slots");
7375
+ return target[key];
7376
+ },
7377
+ set() {
7378
+ warn(`setupContext.slots is readonly.`);
7379
+ return false;
7380
+ },
7381
+ deleteProperty() {
7382
+ warn(`setupContext.slots is readonly.`);
7383
+ return false;
7384
+ }
7385
+ }));
7169
7386
  }
7170
7387
  function createSetupContext(instance) {
7171
7388
  const expose = (exposed) => {
@@ -7191,14 +7408,13 @@ function createSetupContext(instance) {
7191
7408
  }
7192
7409
  instance.exposed = exposed || {};
7193
7410
  };
7194
- let attrs;
7195
7411
  if (process.env.NODE_ENV !== "production") {
7196
7412
  return Object.freeze({
7197
7413
  get attrs() {
7198
- return attrs || (attrs = createAttrsProxy(instance));
7414
+ return getAttrsProxy(instance);
7199
7415
  },
7200
7416
  get slots() {
7201
- return shallowReadonly(instance.slots);
7417
+ return getSlotsProxy(instance);
7202
7418
  },
7203
7419
  get emit() {
7204
7420
  return (event, ...args) => instance.emit(event, ...args);
@@ -7208,7 +7424,7 @@ function createSetupContext(instance) {
7208
7424
  } else {
7209
7425
  return {
7210
7426
  get attrs() {
7211
- return attrs || (attrs = createAttrsProxy(instance));
7427
+ return getAttrsProxy(instance);
7212
7428
  },
7213
7429
  slots: instance.slots,
7214
7430
  emit: instance.emit,
@@ -7267,111 +7483,6 @@ const computed = (getterOrOptions, debugOptions) => {
7267
7483
  return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
7268
7484
  };
7269
7485
 
7270
- const warnRuntimeUsage = (method) => warn(
7271
- `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`
7272
- );
7273
- function defineProps() {
7274
- if (process.env.NODE_ENV !== "production") {
7275
- warnRuntimeUsage(`defineProps`);
7276
- }
7277
- return null;
7278
- }
7279
- function defineEmits() {
7280
- if (process.env.NODE_ENV !== "production") {
7281
- warnRuntimeUsage(`defineEmits`);
7282
- }
7283
- return null;
7284
- }
7285
- function defineExpose(exposed) {
7286
- if (process.env.NODE_ENV !== "production") {
7287
- warnRuntimeUsage(`defineExpose`);
7288
- }
7289
- }
7290
- function defineOptions(options) {
7291
- if (process.env.NODE_ENV !== "production") {
7292
- warnRuntimeUsage(`defineOptions`);
7293
- }
7294
- }
7295
- function defineSlots() {
7296
- if (process.env.NODE_ENV !== "production") {
7297
- warnRuntimeUsage(`defineSlots`);
7298
- }
7299
- }
7300
- function withDefaults(props, defaults) {
7301
- if (process.env.NODE_ENV !== "production") {
7302
- warnRuntimeUsage(`withDefaults`);
7303
- }
7304
- return null;
7305
- }
7306
- function useSlots() {
7307
- return getContext().slots;
7308
- }
7309
- function useAttrs() {
7310
- return getContext().attrs;
7311
- }
7312
- function getContext() {
7313
- const i = getCurrentInstance();
7314
- if (process.env.NODE_ENV !== "production" && !i) {
7315
- warn(`useContext() called without active instance.`);
7316
- }
7317
- return i.setupContext || (i.setupContext = createSetupContext(i));
7318
- }
7319
- function mergeDefaults(raw, defaults) {
7320
- const props = isArray(raw) ? raw.reduce(
7321
- (normalized, p) => (normalized[p] = {}, normalized),
7322
- {}
7323
- ) : raw;
7324
- for (const key in defaults) {
7325
- if (key.startsWith("__skip"))
7326
- continue;
7327
- let opt = props[key];
7328
- if (opt) {
7329
- if (isArray(opt) || isFunction(opt)) {
7330
- opt = props[key] = { type: opt, default: defaults[key] };
7331
- } else {
7332
- opt.default = defaults[key];
7333
- }
7334
- } else if (opt === null) {
7335
- opt = props[key] = { default: defaults[key] };
7336
- } else if (process.env.NODE_ENV !== "production") {
7337
- warn(`props default key "${key}" has no corresponding declaration.`);
7338
- }
7339
- if (opt && defaults[`__skip_${key}`]) {
7340
- opt.skipFactory = true;
7341
- }
7342
- }
7343
- return props;
7344
- }
7345
- function createPropsRestProxy(props, excludedKeys) {
7346
- const ret = {};
7347
- for (const key in props) {
7348
- if (!excludedKeys.includes(key)) {
7349
- Object.defineProperty(ret, key, {
7350
- enumerable: true,
7351
- get: () => props[key]
7352
- });
7353
- }
7354
- }
7355
- return ret;
7356
- }
7357
- function withAsyncContext(getAwaitable) {
7358
- const ctx = getCurrentInstance();
7359
- if (process.env.NODE_ENV !== "production" && !ctx) {
7360
- warn(
7361
- `withAsyncContext called without active current instance. This is likely a bug.`
7362
- );
7363
- }
7364
- let awaitable = getAwaitable();
7365
- unsetCurrentInstance();
7366
- if (isPromise(awaitable)) {
7367
- awaitable = awaitable.catch((e) => {
7368
- setCurrentInstance(ctx);
7369
- throw e;
7370
- });
7371
- }
7372
- return [awaitable, () => setCurrentInstance(ctx)];
7373
- }
7374
-
7375
7486
  function h(type, propsOrChildren, children) {
7376
7487
  const l = arguments.length;
7377
7488
  if (l === 2) {
@@ -7611,7 +7722,7 @@ function isMemoSame(cached, memo) {
7611
7722
  return true;
7612
7723
  }
7613
7724
 
7614
- const version = "3.3.0-alpha.8";
7725
+ const version = "3.3.0-beta.1";
7615
7726
  const _ssrUtils = {
7616
7727
  createComponentInstance,
7617
7728
  setupComponent,
@@ -7624,4 +7735,4 @@ const ssrUtils = _ssrUtils ;
7624
7735
  const resolveFilter = null;
7625
7736
  const compatUtils = null;
7626
7737
 
7627
- export { BaseTransition, BaseTransitionPropsValidators, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineOptions, defineProps, defineSlots, devtools, getCurrentInstance, getTransitionRawChildren, guardReactiveProps, h, handleError, initCustomFormatter, inject, isMemoSame, 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, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withMemo, withScopeId };
7738
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, devtools, getCurrentInstance, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, initCustomFormatter, inject, isMemoSame, isRuntimeOnly, isVNode, mergeDefaults, mergeModels, 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, useModel, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withMemo, withScopeId };