@vue/runtime-dom 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.
@@ -97,7 +97,7 @@ const getGlobalThis = () => {
97
97
  return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
98
98
  };
99
99
 
100
- const GLOBALS_WHITE_LISTED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt";
100
+ const GLOBALS_WHITE_LISTED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console";
101
101
  const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
102
102
 
103
103
  function normalizeStyle(value) {
@@ -1856,6 +1856,8 @@ function reload(id, newComp) {
1856
1856
  }
1857
1857
  hmrDirtyComponents.add(oldComp);
1858
1858
  }
1859
+ instance.appContext.propsCache.delete(instance.type);
1860
+ instance.appContext.emitsCache.delete(instance.type);
1859
1861
  instance.appContext.optionsCache.delete(instance.type);
1860
1862
  if (instance.ceReload) {
1861
1863
  hmrDirtyComponents.add(oldComp);
@@ -2698,7 +2700,8 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotSc
2698
2700
  }
2699
2701
  }
2700
2702
  let hasWarned = false;
2701
- function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
2703
+ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
2704
+ var _a;
2702
2705
  if (!hasWarned) {
2703
2706
  hasWarned = true;
2704
2707
  console[console.info ? "info" : "log"](
@@ -2712,13 +2715,21 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
2712
2715
  n: next,
2713
2716
  o: { parentNode, remove }
2714
2717
  } = rendererInternals;
2718
+ let parentSuspenseId;
2719
+ const isSuspensible = ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
2720
+ if (isSuspensible) {
2721
+ if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
2722
+ parentSuspenseId = parentSuspense == null ? void 0 : parentSuspense.pendingId;
2723
+ parentSuspense.deps++;
2724
+ }
2725
+ }
2715
2726
  const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
2716
2727
  {
2717
2728
  assertNumber(timeout, `Suspense timeout`);
2718
2729
  }
2719
2730
  const suspense = {
2720
2731
  vnode,
2721
- parent,
2732
+ parent: parentSuspense,
2722
2733
  parentComponent,
2723
2734
  isSVG,
2724
2735
  container,
@@ -2778,20 +2789,28 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
2778
2789
  setActiveBranch(suspense, pendingBranch);
2779
2790
  suspense.pendingBranch = null;
2780
2791
  suspense.isInFallback = false;
2781
- let parent2 = suspense.parent;
2792
+ let parent = suspense.parent;
2782
2793
  let hasUnresolvedAncestor = false;
2783
- while (parent2) {
2784
- if (parent2.pendingBranch) {
2785
- parent2.effects.push(...effects);
2794
+ while (parent) {
2795
+ if (parent.pendingBranch) {
2796
+ parent.effects.push(...effects);
2786
2797
  hasUnresolvedAncestor = true;
2787
2798
  break;
2788
2799
  }
2789
- parent2 = parent2.parent;
2800
+ parent = parent.parent;
2790
2801
  }
2791
2802
  if (!hasUnresolvedAncestor) {
2792
2803
  queuePostFlushCb(effects);
2793
2804
  }
2794
2805
  suspense.effects = [];
2806
+ if (isSuspensible) {
2807
+ if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
2808
+ parentSuspense.deps--;
2809
+ if (parentSuspense.deps === 0) {
2810
+ parentSuspense.resolve();
2811
+ }
2812
+ }
2813
+ }
2795
2814
  triggerEvent(vnode2, "onResolve");
2796
2815
  },
2797
2816
  fallback(fallbackVNode) {
@@ -2891,13 +2910,13 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
2891
2910
  }
2892
2911
  });
2893
2912
  },
2894
- unmount(parentSuspense, doRemove) {
2913
+ unmount(parentSuspense2, doRemove) {
2895
2914
  suspense.isUnmounted = true;
2896
2915
  if (suspense.activeBranch) {
2897
2916
  unmount(
2898
2917
  suspense.activeBranch,
2899
2918
  parentComponent,
2900
- parentSuspense,
2919
+ parentSuspense2,
2901
2920
  doRemove
2902
2921
  );
2903
2922
  }
@@ -2905,7 +2924,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
2905
2924
  unmount(
2906
2925
  suspense.pendingBranch,
2907
2926
  parentComponent,
2908
- parentSuspense,
2927
+ parentSuspense2,
2909
2928
  doRemove
2910
2929
  );
2911
2930
  }
@@ -2998,36 +3017,6 @@ function setActiveBranch(suspense, branch) {
2998
3017
  }
2999
3018
  }
3000
3019
 
3001
- function provide(key, value) {
3002
- if (!currentInstance) {
3003
- {
3004
- warn(`provide() can only be used inside setup().`);
3005
- }
3006
- } else {
3007
- let provides = currentInstance.provides;
3008
- const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3009
- if (parentProvides === provides) {
3010
- provides = currentInstance.provides = Object.create(parentProvides);
3011
- }
3012
- provides[key] = value;
3013
- }
3014
- }
3015
- function inject(key, defaultValue, treatDefaultAsFactory = false) {
3016
- const instance = currentInstance || currentRenderingInstance;
3017
- if (instance) {
3018
- const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
3019
- if (provides && key in provides) {
3020
- return provides[key];
3021
- } else if (arguments.length > 1) {
3022
- return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
3023
- } else {
3024
- warn(`injection "${String(key)}" not found.`);
3025
- }
3026
- } else {
3027
- warn(`inject() can only be used inside setup() or functional components.`);
3028
- }
3029
- }
3030
-
3031
3020
  function watchEffect(effect, options) {
3032
3021
  return doWatch(effect, null, options);
3033
3022
  }
@@ -3253,6 +3242,65 @@ function traverse(value, seen) {
3253
3242
  return value;
3254
3243
  }
3255
3244
 
3245
+ function validateDirectiveName(name) {
3246
+ if (isBuiltInDirective(name)) {
3247
+ warn("Do not use built-in directive ids as custom directive id: " + name);
3248
+ }
3249
+ }
3250
+ function withDirectives(vnode, directives) {
3251
+ const internalInstance = currentRenderingInstance;
3252
+ if (internalInstance === null) {
3253
+ warn(`withDirectives can only be used inside render functions.`);
3254
+ return vnode;
3255
+ }
3256
+ const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
3257
+ const bindings = vnode.dirs || (vnode.dirs = []);
3258
+ for (let i = 0; i < directives.length; i++) {
3259
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
3260
+ if (dir) {
3261
+ if (isFunction(dir)) {
3262
+ dir = {
3263
+ mounted: dir,
3264
+ updated: dir
3265
+ };
3266
+ }
3267
+ if (dir.deep) {
3268
+ traverse(value);
3269
+ }
3270
+ bindings.push({
3271
+ dir,
3272
+ instance,
3273
+ value,
3274
+ oldValue: void 0,
3275
+ arg,
3276
+ modifiers
3277
+ });
3278
+ }
3279
+ }
3280
+ return vnode;
3281
+ }
3282
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
3283
+ const bindings = vnode.dirs;
3284
+ const oldBindings = prevVNode && prevVNode.dirs;
3285
+ for (let i = 0; i < bindings.length; i++) {
3286
+ const binding = bindings[i];
3287
+ if (oldBindings) {
3288
+ binding.oldValue = oldBindings[i].value;
3289
+ }
3290
+ let hook = binding.dir[name];
3291
+ if (hook) {
3292
+ pauseTracking();
3293
+ callWithAsyncErrorHandling(hook, instance, 8, [
3294
+ vnode.el,
3295
+ binding,
3296
+ vnode,
3297
+ prevVNode
3298
+ ]);
3299
+ resetTracking();
3300
+ }
3301
+ }
3302
+ }
3303
+
3256
3304
  function useTransitionState() {
3257
3305
  const state = {
3258
3306
  isMounted: false,
@@ -4010,65 +4058,6 @@ function onErrorCaptured(hook, target = currentInstance) {
4010
4058
  injectHook("ec", hook, target);
4011
4059
  }
4012
4060
 
4013
- function validateDirectiveName(name) {
4014
- if (isBuiltInDirective(name)) {
4015
- warn("Do not use built-in directive ids as custom directive id: " + name);
4016
- }
4017
- }
4018
- function withDirectives(vnode, directives) {
4019
- const internalInstance = currentRenderingInstance;
4020
- if (internalInstance === null) {
4021
- warn(`withDirectives can only be used inside render functions.`);
4022
- return vnode;
4023
- }
4024
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
4025
- const bindings = vnode.dirs || (vnode.dirs = []);
4026
- for (let i = 0; i < directives.length; i++) {
4027
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4028
- if (dir) {
4029
- if (isFunction(dir)) {
4030
- dir = {
4031
- mounted: dir,
4032
- updated: dir
4033
- };
4034
- }
4035
- if (dir.deep) {
4036
- traverse(value);
4037
- }
4038
- bindings.push({
4039
- dir,
4040
- instance,
4041
- value,
4042
- oldValue: void 0,
4043
- arg,
4044
- modifiers
4045
- });
4046
- }
4047
- }
4048
- return vnode;
4049
- }
4050
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4051
- const bindings = vnode.dirs;
4052
- const oldBindings = prevVNode && prevVNode.dirs;
4053
- for (let i = 0; i < bindings.length; i++) {
4054
- const binding = bindings[i];
4055
- if (oldBindings) {
4056
- binding.oldValue = oldBindings[i].value;
4057
- }
4058
- let hook = binding.dir[name];
4059
- if (hook) {
4060
- pauseTracking();
4061
- callWithAsyncErrorHandling(hook, instance, 8, [
4062
- vnode.el,
4063
- binding,
4064
- vnode,
4065
- prevVNode
4066
- ]);
4067
- resetTracking();
4068
- }
4069
- }
4070
- }
4071
-
4072
4061
  const COMPONENTS = "components";
4073
4062
  const DIRECTIVES = "directives";
4074
4063
  function resolveComponent(name, maybeSelfReference) {
@@ -4317,6 +4306,8 @@ const PublicInstanceProxyHandlers = {
4317
4306
  if (key === "$attrs") {
4318
4307
  track(instance, "get", key);
4319
4308
  markAttrsAccessed();
4309
+ } else if (key === "$slots") {
4310
+ track(instance, "get", key);
4320
4311
  }
4321
4312
  return publicGetter(instance);
4322
4313
  } else if (
@@ -4486,96 +4477,246 @@ function exposeSetupStateOnRenderContext(instance) {
4486
4477
  });
4487
4478
  }
4488
4479
 
4489
- function createDuplicateChecker() {
4490
- const cache = /* @__PURE__ */ Object.create(null);
4491
- return (type, key) => {
4492
- if (cache[key]) {
4493
- warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
4494
- } else {
4495
- cache[key] = type;
4496
- }
4497
- };
4498
- }
4499
- let shouldCacheAccess = true;
4500
- function applyOptions(instance) {
4501
- const options = resolveMergedOptions(instance);
4502
- const publicThis = instance.proxy;
4503
- const ctx = instance.ctx;
4504
- shouldCacheAccess = false;
4505
- if (options.beforeCreate) {
4506
- callHook$1(options.beforeCreate, instance, "bc");
4480
+ const warnRuntimeUsage = (method) => warn(
4481
+ `${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.`
4482
+ );
4483
+ function defineProps() {
4484
+ {
4485
+ warnRuntimeUsage(`defineProps`);
4507
4486
  }
4508
- const {
4509
- // state
4510
- data: dataOptions,
4511
- computed: computedOptions,
4512
- methods,
4513
- watch: watchOptions,
4514
- provide: provideOptions,
4515
- inject: injectOptions,
4516
- // lifecycle
4517
- created,
4518
- beforeMount,
4519
- mounted,
4520
- beforeUpdate,
4521
- updated,
4522
- activated,
4523
- deactivated,
4524
- beforeDestroy,
4525
- beforeUnmount,
4526
- destroyed,
4527
- unmounted,
4528
- render,
4529
- renderTracked,
4530
- renderTriggered,
4531
- errorCaptured,
4532
- serverPrefetch,
4533
- // public API
4534
- expose,
4535
- inheritAttrs,
4536
- // assets
4537
- components,
4538
- directives,
4539
- filters
4540
- } = options;
4541
- const checkDuplicateProperties = createDuplicateChecker() ;
4487
+ return null;
4488
+ }
4489
+ function defineEmits() {
4542
4490
  {
4543
- const [propsOptions] = instance.propsOptions;
4544
- if (propsOptions) {
4545
- for (const key in propsOptions) {
4546
- checkDuplicateProperties("Props" /* PROPS */, key);
4547
- }
4548
- }
4491
+ warnRuntimeUsage(`defineEmits`);
4549
4492
  }
4550
- if (injectOptions) {
4551
- resolveInjections(
4552
- injectOptions,
4553
- ctx,
4554
- checkDuplicateProperties,
4555
- instance.appContext.config.unwrapInjectedRef
4556
- );
4493
+ return null;
4494
+ }
4495
+ function defineExpose(exposed) {
4496
+ {
4497
+ warnRuntimeUsage(`defineExpose`);
4557
4498
  }
4558
- if (methods) {
4559
- for (const key in methods) {
4560
- const methodHandler = methods[key];
4561
- if (isFunction(methodHandler)) {
4562
- {
4563
- Object.defineProperty(ctx, key, {
4564
- value: methodHandler.bind(publicThis),
4565
- configurable: true,
4566
- enumerable: true,
4567
- writable: true
4568
- });
4569
- }
4570
- {
4571
- checkDuplicateProperties("Methods" /* METHODS */, key);
4572
- }
4573
- } else {
4574
- warn(
4575
- `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
4576
- );
4577
- }
4578
- }
4499
+ }
4500
+ function defineOptions(options) {
4501
+ {
4502
+ warnRuntimeUsage(`defineOptions`);
4503
+ }
4504
+ }
4505
+ function defineSlots() {
4506
+ {
4507
+ warnRuntimeUsage(`defineSlots`);
4508
+ }
4509
+ return null;
4510
+ }
4511
+ function defineModel() {
4512
+ {
4513
+ warnRuntimeUsage("defineModel");
4514
+ }
4515
+ }
4516
+ function withDefaults(props, defaults) {
4517
+ {
4518
+ warnRuntimeUsage(`withDefaults`);
4519
+ }
4520
+ return null;
4521
+ }
4522
+ function useSlots() {
4523
+ return getContext().slots;
4524
+ }
4525
+ function useAttrs() {
4526
+ return getContext().attrs;
4527
+ }
4528
+ function useModel(props, name, options) {
4529
+ const i = getCurrentInstance();
4530
+ if (!i) {
4531
+ warn(`useModel() called without active instance.`);
4532
+ return ref();
4533
+ }
4534
+ if (!i.propsOptions[0][name]) {
4535
+ warn(`useModel() called with prop "${name}" which is not declared.`);
4536
+ return ref();
4537
+ }
4538
+ if (options && options.local) {
4539
+ const proxy = ref(props[name]);
4540
+ watch(
4541
+ () => props[name],
4542
+ (v) => proxy.value = v
4543
+ );
4544
+ watch(proxy, (value) => {
4545
+ if (value !== props[name]) {
4546
+ i.emit(`update:${name}`, value);
4547
+ }
4548
+ });
4549
+ return proxy;
4550
+ } else {
4551
+ return {
4552
+ __v_isRef: true,
4553
+ get value() {
4554
+ return props[name];
4555
+ },
4556
+ set value(value) {
4557
+ i.emit(`update:${name}`, value);
4558
+ }
4559
+ };
4560
+ }
4561
+ }
4562
+ function getContext() {
4563
+ const i = getCurrentInstance();
4564
+ if (!i) {
4565
+ warn(`useContext() called without active instance.`);
4566
+ }
4567
+ return i.setupContext || (i.setupContext = createSetupContext(i));
4568
+ }
4569
+ function normalizePropsOrEmits(props) {
4570
+ return isArray(props) ? props.reduce(
4571
+ (normalized, p) => (normalized[p] = null, normalized),
4572
+ {}
4573
+ ) : props;
4574
+ }
4575
+ function mergeDefaults(raw, defaults) {
4576
+ const props = normalizePropsOrEmits(raw);
4577
+ for (const key in defaults) {
4578
+ if (key.startsWith("__skip"))
4579
+ continue;
4580
+ let opt = props[key];
4581
+ if (opt) {
4582
+ if (isArray(opt) || isFunction(opt)) {
4583
+ opt = props[key] = { type: opt, default: defaults[key] };
4584
+ } else {
4585
+ opt.default = defaults[key];
4586
+ }
4587
+ } else if (opt === null) {
4588
+ opt = props[key] = { default: defaults[key] };
4589
+ } else {
4590
+ warn(`props default key "${key}" has no corresponding declaration.`);
4591
+ }
4592
+ if (opt && defaults[`__skip_${key}`]) {
4593
+ opt.skipFactory = true;
4594
+ }
4595
+ }
4596
+ return props;
4597
+ }
4598
+ function mergeModels(a, b) {
4599
+ if (!a || !b)
4600
+ return a || b;
4601
+ if (isArray(a) && isArray(b))
4602
+ return a.concat(b);
4603
+ return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
4604
+ }
4605
+ function createPropsRestProxy(props, excludedKeys) {
4606
+ const ret = {};
4607
+ for (const key in props) {
4608
+ if (!excludedKeys.includes(key)) {
4609
+ Object.defineProperty(ret, key, {
4610
+ enumerable: true,
4611
+ get: () => props[key]
4612
+ });
4613
+ }
4614
+ }
4615
+ return ret;
4616
+ }
4617
+ function withAsyncContext(getAwaitable) {
4618
+ const ctx = getCurrentInstance();
4619
+ if (!ctx) {
4620
+ warn(
4621
+ `withAsyncContext called without active current instance. This is likely a bug.`
4622
+ );
4623
+ }
4624
+ let awaitable = getAwaitable();
4625
+ unsetCurrentInstance();
4626
+ if (isPromise(awaitable)) {
4627
+ awaitable = awaitable.catch((e) => {
4628
+ setCurrentInstance(ctx);
4629
+ throw e;
4630
+ });
4631
+ }
4632
+ return [awaitable, () => setCurrentInstance(ctx)];
4633
+ }
4634
+
4635
+ function createDuplicateChecker() {
4636
+ const cache = /* @__PURE__ */ Object.create(null);
4637
+ return (type, key) => {
4638
+ if (cache[key]) {
4639
+ warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
4640
+ } else {
4641
+ cache[key] = type;
4642
+ }
4643
+ };
4644
+ }
4645
+ let shouldCacheAccess = true;
4646
+ function applyOptions(instance) {
4647
+ const options = resolveMergedOptions(instance);
4648
+ const publicThis = instance.proxy;
4649
+ const ctx = instance.ctx;
4650
+ shouldCacheAccess = false;
4651
+ if (options.beforeCreate) {
4652
+ callHook$1(options.beforeCreate, instance, "bc");
4653
+ }
4654
+ const {
4655
+ // state
4656
+ data: dataOptions,
4657
+ computed: computedOptions,
4658
+ methods,
4659
+ watch: watchOptions,
4660
+ provide: provideOptions,
4661
+ inject: injectOptions,
4662
+ // lifecycle
4663
+ created,
4664
+ beforeMount,
4665
+ mounted,
4666
+ beforeUpdate,
4667
+ updated,
4668
+ activated,
4669
+ deactivated,
4670
+ beforeDestroy,
4671
+ beforeUnmount,
4672
+ destroyed,
4673
+ unmounted,
4674
+ render,
4675
+ renderTracked,
4676
+ renderTriggered,
4677
+ errorCaptured,
4678
+ serverPrefetch,
4679
+ // public API
4680
+ expose,
4681
+ inheritAttrs,
4682
+ // assets
4683
+ components,
4684
+ directives,
4685
+ filters
4686
+ } = options;
4687
+ const checkDuplicateProperties = createDuplicateChecker() ;
4688
+ {
4689
+ const [propsOptions] = instance.propsOptions;
4690
+ if (propsOptions) {
4691
+ for (const key in propsOptions) {
4692
+ checkDuplicateProperties("Props" /* PROPS */, key);
4693
+ }
4694
+ }
4695
+ }
4696
+ if (injectOptions) {
4697
+ resolveInjections(injectOptions, ctx, checkDuplicateProperties);
4698
+ }
4699
+ if (methods) {
4700
+ for (const key in methods) {
4701
+ const methodHandler = methods[key];
4702
+ if (isFunction(methodHandler)) {
4703
+ {
4704
+ Object.defineProperty(ctx, key, {
4705
+ value: methodHandler.bind(publicThis),
4706
+ configurable: true,
4707
+ enumerable: true,
4708
+ writable: true
4709
+ });
4710
+ }
4711
+ {
4712
+ checkDuplicateProperties("Methods" /* METHODS */, key);
4713
+ }
4714
+ } else {
4715
+ warn(
4716
+ `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
4717
+ );
4718
+ }
4719
+ }
4579
4720
  }
4580
4721
  if (dataOptions) {
4581
4722
  if (!isFunction(dataOptions)) {
@@ -4693,7 +4834,7 @@ function applyOptions(instance) {
4693
4834
  if (directives)
4694
4835
  instance.directives = directives;
4695
4836
  }
4696
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4837
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
4697
4838
  if (isArray(injectOptions)) {
4698
4839
  injectOptions = normalizeInject(injectOptions);
4699
4840
  }
@@ -4715,21 +4856,12 @@ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP,
4715
4856
  injected = inject(opt);
4716
4857
  }
4717
4858
  if (isRef(injected)) {
4718
- if (unwrapRef) {
4719
- Object.defineProperty(ctx, key, {
4720
- enumerable: true,
4721
- configurable: true,
4722
- get: () => injected.value,
4723
- set: (v) => injected.value = v
4724
- });
4725
- } else {
4726
- {
4727
- warn(
4728
- `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.)`
4729
- );
4730
- }
4731
- ctx[key] = injected;
4732
- }
4859
+ Object.defineProperty(ctx, key, {
4860
+ enumerable: true,
4861
+ configurable: true,
4862
+ get: () => injected.value,
4863
+ set: (v) => injected.value = v
4864
+ });
4733
4865
  } else {
4734
4866
  ctx[key] = injected;
4735
4867
  }
@@ -4825,10 +4957,8 @@ function mergeOptions(to, from, strats, asMixin = false) {
4825
4957
  }
4826
4958
  const internalOptionMergeStrats = {
4827
4959
  data: mergeDataFn,
4828
- props: mergeObjectOptions,
4829
- // TODO
4830
- emits: mergeObjectOptions,
4831
- // TODO
4960
+ props: mergeEmitsOrPropsOptions,
4961
+ emits: mergeEmitsOrPropsOptions,
4832
4962
  // objects
4833
4963
  methods: mergeObjectOptions,
4834
4964
  computed: mergeObjectOptions,
@@ -4887,7 +5017,21 @@ function mergeAsArray(to, from) {
4887
5017
  return to ? [...new Set([].concat(to, from))] : from;
4888
5018
  }
4889
5019
  function mergeObjectOptions(to, from) {
4890
- return to ? extend(extend(/* @__PURE__ */ Object.create(null), to), from) : from;
5020
+ return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
5021
+ }
5022
+ function mergeEmitsOrPropsOptions(to, from) {
5023
+ if (to) {
5024
+ if (isArray(to) && isArray(from)) {
5025
+ return [.../* @__PURE__ */ new Set([...to, ...from])];
5026
+ }
5027
+ return extend(
5028
+ /* @__PURE__ */ Object.create(null),
5029
+ normalizePropsOrEmits(to),
5030
+ normalizePropsOrEmits(from != null ? from : {})
5031
+ );
5032
+ } else {
5033
+ return from;
5034
+ }
4891
5035
  }
4892
5036
  function mergeWatchOptions(to, from) {
4893
5037
  if (!to)
@@ -4901,30 +5045,254 @@ function mergeWatchOptions(to, from) {
4901
5045
  return merged;
4902
5046
  }
4903
5047
 
4904
- function initProps(instance, rawProps, isStateful, isSSR = false) {
4905
- const props = {};
4906
- const attrs = {};
4907
- def(attrs, InternalObjectKey, 1);
4908
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
4909
- setFullProps(instance, rawProps, props, attrs);
4910
- for (const key in instance.propsOptions[0]) {
4911
- if (!(key in props)) {
4912
- props[key] = void 0;
5048
+ function createAppContext() {
5049
+ return {
5050
+ app: null,
5051
+ config: {
5052
+ isNativeTag: NO,
5053
+ performance: false,
5054
+ globalProperties: {},
5055
+ optionMergeStrategies: {},
5056
+ errorHandler: void 0,
5057
+ warnHandler: void 0,
5058
+ compilerOptions: {}
5059
+ },
5060
+ mixins: [],
5061
+ components: {},
5062
+ directives: {},
5063
+ provides: /* @__PURE__ */ Object.create(null),
5064
+ optionsCache: /* @__PURE__ */ new WeakMap(),
5065
+ propsCache: /* @__PURE__ */ new WeakMap(),
5066
+ emitsCache: /* @__PURE__ */ new WeakMap()
5067
+ };
5068
+ }
5069
+ let uid$1 = 0;
5070
+ function createAppAPI(render, hydrate) {
5071
+ return function createApp(rootComponent, rootProps = null) {
5072
+ if (!isFunction(rootComponent)) {
5073
+ rootComponent = extend({}, rootComponent);
4913
5074
  }
4914
- }
4915
- {
4916
- validateProps(rawProps || {}, props, instance);
4917
- }
4918
- if (isStateful) {
4919
- instance.props = isSSR ? props : shallowReactive(props);
4920
- } else {
4921
- if (!instance.type.props) {
4922
- instance.props = attrs;
4923
- } else {
4924
- instance.props = props;
5075
+ if (rootProps != null && !isObject(rootProps)) {
5076
+ warn(`root props passed to app.mount() must be an object.`);
5077
+ rootProps = null;
4925
5078
  }
4926
- }
4927
- instance.attrs = attrs;
5079
+ const context = createAppContext();
5080
+ {
5081
+ Object.defineProperty(context.config, "unwrapInjectedRef", {
5082
+ get() {
5083
+ return true;
5084
+ },
5085
+ set() {
5086
+ warn(
5087
+ `app.config.unwrapInjectedRef has been deprecated. 3.3 now alawys unwraps injected refs in Options API.`
5088
+ );
5089
+ }
5090
+ });
5091
+ }
5092
+ const installedPlugins = /* @__PURE__ */ new Set();
5093
+ let isMounted = false;
5094
+ const app = context.app = {
5095
+ _uid: uid$1++,
5096
+ _component: rootComponent,
5097
+ _props: rootProps,
5098
+ _container: null,
5099
+ _context: context,
5100
+ _instance: null,
5101
+ version,
5102
+ get config() {
5103
+ return context.config;
5104
+ },
5105
+ set config(v) {
5106
+ {
5107
+ warn(
5108
+ `app.config cannot be replaced. Modify individual options instead.`
5109
+ );
5110
+ }
5111
+ },
5112
+ use(plugin, ...options) {
5113
+ if (installedPlugins.has(plugin)) {
5114
+ warn(`Plugin has already been applied to target app.`);
5115
+ } else if (plugin && isFunction(plugin.install)) {
5116
+ installedPlugins.add(plugin);
5117
+ plugin.install(app, ...options);
5118
+ } else if (isFunction(plugin)) {
5119
+ installedPlugins.add(plugin);
5120
+ plugin(app, ...options);
5121
+ } else {
5122
+ warn(
5123
+ `A plugin must either be a function or an object with an "install" function.`
5124
+ );
5125
+ }
5126
+ return app;
5127
+ },
5128
+ mixin(mixin) {
5129
+ {
5130
+ if (!context.mixins.includes(mixin)) {
5131
+ context.mixins.push(mixin);
5132
+ } else {
5133
+ warn(
5134
+ "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
5135
+ );
5136
+ }
5137
+ }
5138
+ return app;
5139
+ },
5140
+ component(name, component) {
5141
+ {
5142
+ validateComponentName(name, context.config);
5143
+ }
5144
+ if (!component) {
5145
+ return context.components[name];
5146
+ }
5147
+ if (context.components[name]) {
5148
+ warn(`Component "${name}" has already been registered in target app.`);
5149
+ }
5150
+ context.components[name] = component;
5151
+ return app;
5152
+ },
5153
+ directive(name, directive) {
5154
+ {
5155
+ validateDirectiveName(name);
5156
+ }
5157
+ if (!directive) {
5158
+ return context.directives[name];
5159
+ }
5160
+ if (context.directives[name]) {
5161
+ warn(`Directive "${name}" has already been registered in target app.`);
5162
+ }
5163
+ context.directives[name] = directive;
5164
+ return app;
5165
+ },
5166
+ mount(rootContainer, isHydrate, isSVG) {
5167
+ if (!isMounted) {
5168
+ if (rootContainer.__vue_app__) {
5169
+ warn(
5170
+ `There is already an app instance mounted on the host container.
5171
+ If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
5172
+ );
5173
+ }
5174
+ const vnode = createVNode(
5175
+ rootComponent,
5176
+ rootProps
5177
+ );
5178
+ vnode.appContext = context;
5179
+ {
5180
+ context.reload = () => {
5181
+ render(cloneVNode(vnode), rootContainer, isSVG);
5182
+ };
5183
+ }
5184
+ if (isHydrate && hydrate) {
5185
+ hydrate(vnode, rootContainer);
5186
+ } else {
5187
+ render(vnode, rootContainer, isSVG);
5188
+ }
5189
+ isMounted = true;
5190
+ app._container = rootContainer;
5191
+ rootContainer.__vue_app__ = app;
5192
+ {
5193
+ app._instance = vnode.component;
5194
+ devtoolsInitApp(app, version);
5195
+ }
5196
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
5197
+ } else {
5198
+ warn(
5199
+ `App has already been mounted.
5200
+ 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)\``
5201
+ );
5202
+ }
5203
+ },
5204
+ unmount() {
5205
+ if (isMounted) {
5206
+ render(null, app._container);
5207
+ {
5208
+ app._instance = null;
5209
+ devtoolsUnmountApp(app);
5210
+ }
5211
+ delete app._container.__vue_app__;
5212
+ } else {
5213
+ warn(`Cannot unmount an app that is not mounted.`);
5214
+ }
5215
+ },
5216
+ provide(key, value) {
5217
+ if (key in context.provides) {
5218
+ warn(
5219
+ `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
5220
+ );
5221
+ }
5222
+ context.provides[key] = value;
5223
+ return app;
5224
+ },
5225
+ runWithContext(fn) {
5226
+ currentApp = app;
5227
+ try {
5228
+ return fn();
5229
+ } finally {
5230
+ currentApp = null;
5231
+ }
5232
+ }
5233
+ };
5234
+ return app;
5235
+ };
5236
+ }
5237
+ let currentApp = null;
5238
+
5239
+ function provide(key, value) {
5240
+ if (!currentInstance) {
5241
+ {
5242
+ warn(`provide() can only be used inside setup().`);
5243
+ }
5244
+ } else {
5245
+ let provides = currentInstance.provides;
5246
+ const parentProvides = currentInstance.parent && currentInstance.parent.provides;
5247
+ if (parentProvides === provides) {
5248
+ provides = currentInstance.provides = Object.create(parentProvides);
5249
+ }
5250
+ provides[key] = value;
5251
+ }
5252
+ }
5253
+ function inject(key, defaultValue, treatDefaultAsFactory = false) {
5254
+ const instance = currentInstance || currentRenderingInstance;
5255
+ if (instance || currentApp) {
5256
+ const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
5257
+ if (provides && key in provides) {
5258
+ return provides[key];
5259
+ } else if (arguments.length > 1) {
5260
+ return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
5261
+ } else {
5262
+ warn(`injection "${String(key)}" not found.`);
5263
+ }
5264
+ } else {
5265
+ warn(`inject() can only be used inside setup() or functional components.`);
5266
+ }
5267
+ }
5268
+ function hasInjectionContext() {
5269
+ return !!(currentInstance || currentRenderingInstance || currentApp);
5270
+ }
5271
+
5272
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
5273
+ const props = {};
5274
+ const attrs = {};
5275
+ def(attrs, InternalObjectKey, 1);
5276
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
5277
+ setFullProps(instance, rawProps, props, attrs);
5278
+ for (const key in instance.propsOptions[0]) {
5279
+ if (!(key in props)) {
5280
+ props[key] = void 0;
5281
+ }
5282
+ }
5283
+ {
5284
+ validateProps(rawProps || {}, props, instance);
5285
+ }
5286
+ if (isStateful) {
5287
+ instance.props = isSSR ? props : shallowReactive(props);
5288
+ } else {
5289
+ if (!instance.type.props) {
5290
+ instance.props = attrs;
5291
+ } else {
5292
+ instance.props = props;
5293
+ }
5294
+ }
5295
+ instance.attrs = attrs;
4928
5296
  }
4929
5297
  function isInHmrContext(instance) {
4930
5298
  while (instance) {
@@ -5216,7 +5584,7 @@ function validateProp(name, value, prop, isAbsent) {
5216
5584
  warn('Missing required prop: "' + name + '"');
5217
5585
  return;
5218
5586
  }
5219
- if (value == null && !prop.required) {
5587
+ if (value == null && !required) {
5220
5588
  return;
5221
5589
  }
5222
5590
  if (type != null && type !== true && !skipCheck) {
@@ -5250,319 +5618,150 @@ function assertType(value, type) {
5250
5618
  valid = value instanceof type;
5251
5619
  }
5252
5620
  } else if (expectedType === "Object") {
5253
- valid = isObject(value);
5254
- } else if (expectedType === "Array") {
5255
- valid = isArray(value);
5256
- } else if (expectedType === "null") {
5257
- valid = value === null;
5258
- } else {
5259
- valid = value instanceof type;
5260
- }
5261
- return {
5262
- valid,
5263
- expectedType
5264
- };
5265
- }
5266
- function getInvalidTypeMessage(name, value, expectedTypes) {
5267
- let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5268
- const expectedType = expectedTypes[0];
5269
- const receivedType = toRawType(value);
5270
- const expectedValue = styleValue(value, expectedType);
5271
- const receivedValue = styleValue(value, receivedType);
5272
- if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
5273
- message += ` with value ${expectedValue}`;
5274
- }
5275
- message += `, got ${receivedType} `;
5276
- if (isExplicable(receivedType)) {
5277
- message += `with value ${receivedValue}.`;
5278
- }
5279
- return message;
5280
- }
5281
- function styleValue(value, type) {
5282
- if (type === "String") {
5283
- return `"${value}"`;
5284
- } else if (type === "Number") {
5285
- return `${Number(value)}`;
5286
- } else {
5287
- return `${value}`;
5288
- }
5289
- }
5290
- function isExplicable(type) {
5291
- const explicitTypes = ["string", "number", "boolean"];
5292
- return explicitTypes.some((elem) => type.toLowerCase() === elem);
5293
- }
5294
- function isBoolean(...args) {
5295
- return args.some((elem) => elem.toLowerCase() === "boolean");
5296
- }
5297
-
5298
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
5299
- const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
5300
- const normalizeSlot = (key, rawSlot, ctx) => {
5301
- if (rawSlot._n) {
5302
- return rawSlot;
5303
- }
5304
- const normalized = withCtx((...args) => {
5305
- if (currentInstance) {
5306
- warn(
5307
- `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.`
5308
- );
5309
- }
5310
- return normalizeSlotValue(rawSlot(...args));
5311
- }, ctx);
5312
- normalized._c = false;
5313
- return normalized;
5314
- };
5315
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
5316
- const ctx = rawSlots._ctx;
5317
- for (const key in rawSlots) {
5318
- if (isInternalKey(key))
5319
- continue;
5320
- const value = rawSlots[key];
5321
- if (isFunction(value)) {
5322
- slots[key] = normalizeSlot(key, value, ctx);
5323
- } else if (value != null) {
5324
- {
5325
- warn(
5326
- `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
5327
- );
5328
- }
5329
- const normalized = normalizeSlotValue(value);
5330
- slots[key] = () => normalized;
5331
- }
5332
- }
5333
- };
5334
- const normalizeVNodeSlots = (instance, children) => {
5335
- if (!isKeepAlive(instance.vnode) && true) {
5336
- warn(
5337
- `Non-function value encountered for default slot. Prefer function slots for better performance.`
5338
- );
5339
- }
5340
- const normalized = normalizeSlotValue(children);
5341
- instance.slots.default = () => normalized;
5342
- };
5343
- const initSlots = (instance, children) => {
5344
- if (instance.vnode.shapeFlag & 32) {
5345
- const type = children._;
5346
- if (type) {
5347
- instance.slots = toRaw(children);
5348
- def(children, "_", type);
5349
- } else {
5350
- normalizeObjectSlots(
5351
- children,
5352
- instance.slots = {});
5353
- }
5354
- } else {
5355
- instance.slots = {};
5356
- if (children) {
5357
- normalizeVNodeSlots(instance, children);
5358
- }
5359
- }
5360
- def(instance.slots, InternalObjectKey, 1);
5361
- };
5362
- const updateSlots = (instance, children, optimized) => {
5363
- const { vnode, slots } = instance;
5364
- let needDeletionCheck = true;
5365
- let deletionComparisonTarget = EMPTY_OBJ;
5366
- if (vnode.shapeFlag & 32) {
5367
- const type = children._;
5368
- if (type) {
5369
- if (isHmrUpdating) {
5370
- extend(slots, children);
5371
- } else if (optimized && type === 1) {
5372
- needDeletionCheck = false;
5373
- } else {
5374
- extend(slots, children);
5375
- if (!optimized && type === 1) {
5376
- delete slots._;
5377
- }
5378
- }
5379
- } else {
5380
- needDeletionCheck = !children.$stable;
5381
- normalizeObjectSlots(children, slots);
5382
- }
5383
- deletionComparisonTarget = children;
5384
- } else if (children) {
5385
- normalizeVNodeSlots(instance, children);
5386
- deletionComparisonTarget = { default: 1 };
5387
- }
5388
- if (needDeletionCheck) {
5389
- for (const key in slots) {
5390
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5391
- delete slots[key];
5392
- }
5393
- }
5394
- }
5395
- };
5396
-
5397
- function createAppContext() {
5398
- return {
5399
- app: null,
5400
- config: {
5401
- isNativeTag: NO,
5402
- performance: false,
5403
- globalProperties: {},
5404
- optionMergeStrategies: {},
5405
- errorHandler: void 0,
5406
- warnHandler: void 0,
5407
- compilerOptions: {}
5408
- },
5409
- mixins: [],
5410
- components: {},
5411
- directives: {},
5412
- provides: /* @__PURE__ */ Object.create(null),
5413
- optionsCache: /* @__PURE__ */ new WeakMap(),
5414
- propsCache: /* @__PURE__ */ new WeakMap(),
5415
- emitsCache: /* @__PURE__ */ new WeakMap()
5416
- };
5417
- }
5418
- let uid$1 = 0;
5419
- function createAppAPI(render, hydrate) {
5420
- return function createApp(rootComponent, rootProps = null) {
5421
- if (!isFunction(rootComponent)) {
5422
- rootComponent = extend({}, rootComponent);
5423
- }
5424
- if (rootProps != null && !isObject(rootProps)) {
5425
- warn(`root props passed to app.mount() must be an object.`);
5426
- rootProps = null;
5427
- }
5428
- const context = createAppContext();
5429
- const installedPlugins = /* @__PURE__ */ new Set();
5430
- let isMounted = false;
5431
- const app = context.app = {
5432
- _uid: uid$1++,
5433
- _component: rootComponent,
5434
- _props: rootProps,
5435
- _container: null,
5436
- _context: context,
5437
- _instance: null,
5438
- version,
5439
- get config() {
5440
- return context.config;
5441
- },
5442
- set config(v) {
5443
- {
5444
- warn(
5445
- `app.config cannot be replaced. Modify individual options instead.`
5446
- );
5447
- }
5448
- },
5449
- use(plugin, ...options) {
5450
- if (installedPlugins.has(plugin)) {
5451
- warn(`Plugin has already been applied to target app.`);
5452
- } else if (plugin && isFunction(plugin.install)) {
5453
- installedPlugins.add(plugin);
5454
- plugin.install(app, ...options);
5455
- } else if (isFunction(plugin)) {
5456
- installedPlugins.add(plugin);
5457
- plugin(app, ...options);
5458
- } else {
5459
- warn(
5460
- `A plugin must either be a function or an object with an "install" function.`
5461
- );
5462
- }
5463
- return app;
5464
- },
5465
- mixin(mixin) {
5466
- {
5467
- if (!context.mixins.includes(mixin)) {
5468
- context.mixins.push(mixin);
5469
- } else {
5470
- warn(
5471
- "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
5472
- );
5473
- }
5474
- }
5475
- return app;
5476
- },
5477
- component(name, component) {
5478
- {
5479
- validateComponentName(name, context.config);
5480
- }
5481
- if (!component) {
5482
- return context.components[name];
5483
- }
5484
- if (context.components[name]) {
5485
- warn(`Component "${name}" has already been registered in target app.`);
5486
- }
5487
- context.components[name] = component;
5488
- return app;
5489
- },
5490
- directive(name, directive) {
5491
- {
5492
- validateDirectiveName(name);
5493
- }
5494
- if (!directive) {
5495
- return context.directives[name];
5496
- }
5497
- if (context.directives[name]) {
5498
- warn(`Directive "${name}" has already been registered in target app.`);
5499
- }
5500
- context.directives[name] = directive;
5501
- return app;
5502
- },
5503
- mount(rootContainer, isHydrate, isSVG) {
5504
- if (!isMounted) {
5505
- if (rootContainer.__vue_app__) {
5506
- warn(
5507
- `There is already an app instance mounted on the host container.
5508
- If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
5509
- );
5510
- }
5511
- const vnode = createVNode(
5512
- rootComponent,
5513
- rootProps
5514
- );
5515
- vnode.appContext = context;
5516
- {
5517
- context.reload = () => {
5518
- render(cloneVNode(vnode), rootContainer, isSVG);
5519
- };
5520
- }
5521
- if (isHydrate && hydrate) {
5522
- hydrate(vnode, rootContainer);
5523
- } else {
5524
- render(vnode, rootContainer, isSVG);
5525
- }
5526
- isMounted = true;
5527
- app._container = rootContainer;
5528
- rootContainer.__vue_app__ = app;
5529
- {
5530
- app._instance = vnode.component;
5531
- devtoolsInitApp(app, version);
5532
- }
5533
- return getExposeProxy(vnode.component) || vnode.component.proxy;
5534
- } else {
5535
- warn(
5536
- `App has already been mounted.
5537
- 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)\``
5538
- );
5539
- }
5540
- },
5541
- unmount() {
5542
- if (isMounted) {
5543
- render(null, app._container);
5544
- {
5545
- app._instance = null;
5546
- devtoolsUnmountApp(app);
5547
- }
5548
- delete app._container.__vue_app__;
5549
- } else {
5550
- warn(`Cannot unmount an app that is not mounted.`);
5551
- }
5552
- },
5553
- provide(key, value) {
5554
- if (key in context.provides) {
5555
- warn(
5556
- `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
5557
- );
5558
- }
5559
- context.provides[key] = value;
5560
- return app;
5561
- }
5562
- };
5563
- return app;
5621
+ valid = isObject(value);
5622
+ } else if (expectedType === "Array") {
5623
+ valid = isArray(value);
5624
+ } else if (expectedType === "null") {
5625
+ valid = value === null;
5626
+ } else {
5627
+ valid = value instanceof type;
5628
+ }
5629
+ return {
5630
+ valid,
5631
+ expectedType
5564
5632
  };
5565
5633
  }
5634
+ function getInvalidTypeMessage(name, value, expectedTypes) {
5635
+ let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5636
+ const expectedType = expectedTypes[0];
5637
+ const receivedType = toRawType(value);
5638
+ const expectedValue = styleValue(value, expectedType);
5639
+ const receivedValue = styleValue(value, receivedType);
5640
+ if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
5641
+ message += ` with value ${expectedValue}`;
5642
+ }
5643
+ message += `, got ${receivedType} `;
5644
+ if (isExplicable(receivedType)) {
5645
+ message += `with value ${receivedValue}.`;
5646
+ }
5647
+ return message;
5648
+ }
5649
+ function styleValue(value, type) {
5650
+ if (type === "String") {
5651
+ return `"${value}"`;
5652
+ } else if (type === "Number") {
5653
+ return `${Number(value)}`;
5654
+ } else {
5655
+ return `${value}`;
5656
+ }
5657
+ }
5658
+ function isExplicable(type) {
5659
+ const explicitTypes = ["string", "number", "boolean"];
5660
+ return explicitTypes.some((elem) => type.toLowerCase() === elem);
5661
+ }
5662
+ function isBoolean(...args) {
5663
+ return args.some((elem) => elem.toLowerCase() === "boolean");
5664
+ }
5665
+
5666
+ const isInternalKey = (key) => key[0] === "_" || key === "$stable";
5667
+ const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
5668
+ const normalizeSlot = (key, rawSlot, ctx) => {
5669
+ if (rawSlot._n) {
5670
+ return rawSlot;
5671
+ }
5672
+ const normalized = withCtx((...args) => {
5673
+ if (currentInstance) {
5674
+ warn(
5675
+ `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.`
5676
+ );
5677
+ }
5678
+ return normalizeSlotValue(rawSlot(...args));
5679
+ }, ctx);
5680
+ normalized._c = false;
5681
+ return normalized;
5682
+ };
5683
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
5684
+ const ctx = rawSlots._ctx;
5685
+ for (const key in rawSlots) {
5686
+ if (isInternalKey(key))
5687
+ continue;
5688
+ const value = rawSlots[key];
5689
+ if (isFunction(value)) {
5690
+ slots[key] = normalizeSlot(key, value, ctx);
5691
+ } else if (value != null) {
5692
+ {
5693
+ warn(
5694
+ `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
5695
+ );
5696
+ }
5697
+ const normalized = normalizeSlotValue(value);
5698
+ slots[key] = () => normalized;
5699
+ }
5700
+ }
5701
+ };
5702
+ const normalizeVNodeSlots = (instance, children) => {
5703
+ if (!isKeepAlive(instance.vnode) && true) {
5704
+ warn(
5705
+ `Non-function value encountered for default slot. Prefer function slots for better performance.`
5706
+ );
5707
+ }
5708
+ const normalized = normalizeSlotValue(children);
5709
+ instance.slots.default = () => normalized;
5710
+ };
5711
+ const initSlots = (instance, children) => {
5712
+ if (instance.vnode.shapeFlag & 32) {
5713
+ const type = children._;
5714
+ if (type) {
5715
+ instance.slots = toRaw(children);
5716
+ def(children, "_", type);
5717
+ } else {
5718
+ normalizeObjectSlots(
5719
+ children,
5720
+ instance.slots = {});
5721
+ }
5722
+ } else {
5723
+ instance.slots = {};
5724
+ if (children) {
5725
+ normalizeVNodeSlots(instance, children);
5726
+ }
5727
+ }
5728
+ def(instance.slots, InternalObjectKey, 1);
5729
+ };
5730
+ const updateSlots = (instance, children, optimized) => {
5731
+ const { vnode, slots } = instance;
5732
+ let needDeletionCheck = true;
5733
+ let deletionComparisonTarget = EMPTY_OBJ;
5734
+ if (vnode.shapeFlag & 32) {
5735
+ const type = children._;
5736
+ if (type) {
5737
+ if (isHmrUpdating) {
5738
+ extend(slots, children);
5739
+ trigger(instance, "set", "$slots");
5740
+ } else if (optimized && type === 1) {
5741
+ needDeletionCheck = false;
5742
+ } else {
5743
+ extend(slots, children);
5744
+ if (!optimized && type === 1) {
5745
+ delete slots._;
5746
+ }
5747
+ }
5748
+ } else {
5749
+ needDeletionCheck = !children.$stable;
5750
+ normalizeObjectSlots(children, slots);
5751
+ }
5752
+ deletionComparisonTarget = children;
5753
+ } else if (children) {
5754
+ normalizeVNodeSlots(instance, children);
5755
+ deletionComparisonTarget = { default: 1 };
5756
+ }
5757
+ if (needDeletionCheck) {
5758
+ for (const key in slots) {
5759
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5760
+ delete slots[key];
5761
+ }
5762
+ }
5763
+ }
5764
+ };
5566
5765
 
5567
5766
  function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5568
5767
  if (isArray(rawRef)) {
@@ -6466,7 +6665,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6466
6665
  areChildrenSVG,
6467
6666
  slotScopeIds
6468
6667
  );
6469
- if (parentComponent && parentComponent.type.__hmrId) {
6668
+ {
6470
6669
  traverseStaticChildren(n1, n2);
6471
6670
  }
6472
6671
  } else if (!optimized) {
@@ -6662,21 +6861,8 @@ function baseCreateRenderer(options, createHydrationFns) {
6662
6861
  isSVG,
6663
6862
  slotScopeIds
6664
6863
  );
6665
- if (parentComponent && parentComponent.type.__hmrId) {
6864
+ {
6666
6865
  traverseStaticChildren(n1, n2);
6667
- } else if (
6668
- // #2080 if the stable fragment has a key, it's a <template v-for> that may
6669
- // get moved around. Make sure all root level vnodes inherit el.
6670
- // #2134 or if it's a component root, it may also get moved around
6671
- // as the component is being moved.
6672
- n2.key != null || parentComponent && n2 === parentComponent.subTree
6673
- ) {
6674
- traverseStaticChildren(
6675
- n1,
6676
- n2,
6677
- true
6678
- /* shallow */
6679
- );
6680
6866
  }
6681
6867
  } else {
6682
6868
  patchChildren(
@@ -8250,6 +8436,8 @@ function createComponentInstance(vnode, parent, suspense) {
8250
8436
  refs: EMPTY_OBJ,
8251
8437
  setupState: EMPTY_OBJ,
8252
8438
  setupContext: null,
8439
+ attrsProxy: null,
8440
+ slotsProxy: null,
8253
8441
  // suspense related
8254
8442
  suspense,
8255
8443
  suspenseId: suspense ? suspense.pendingId : 0,
@@ -8477,8 +8665,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
8477
8665
  }
8478
8666
  }
8479
8667
  }
8480
- function createAttrsProxy(instance) {
8481
- return new Proxy(
8668
+ function getAttrsProxy(instance) {
8669
+ return instance.attrsProxy || (instance.attrsProxy = new Proxy(
8482
8670
  instance.attrs,
8483
8671
  {
8484
8672
  get(target, key) {
@@ -8495,7 +8683,23 @@ function createAttrsProxy(instance) {
8495
8683
  return false;
8496
8684
  }
8497
8685
  }
8498
- );
8686
+ ));
8687
+ }
8688
+ function getSlotsProxy(instance) {
8689
+ return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
8690
+ get(target, key) {
8691
+ track(instance, "get", "$slots");
8692
+ return target[key];
8693
+ },
8694
+ set() {
8695
+ warn(`setupContext.slots is readonly.`);
8696
+ return false;
8697
+ },
8698
+ deleteProperty() {
8699
+ warn(`setupContext.slots is readonly.`);
8700
+ return false;
8701
+ }
8702
+ }));
8499
8703
  }
8500
8704
  function createSetupContext(instance) {
8501
8705
  const expose = (exposed) => {
@@ -8521,14 +8725,13 @@ function createSetupContext(instance) {
8521
8725
  }
8522
8726
  instance.exposed = exposed || {};
8523
8727
  };
8524
- let attrs;
8525
8728
  {
8526
8729
  return Object.freeze({
8527
8730
  get attrs() {
8528
- return attrs || (attrs = createAttrsProxy(instance));
8731
+ return getAttrsProxy(instance);
8529
8732
  },
8530
8733
  get slots() {
8531
- return shallowReadonly(instance.slots);
8734
+ return getSlotsProxy(instance);
8532
8735
  },
8533
8736
  get emit() {
8534
8737
  return (event, ...args) => instance.emit(event, ...args);
@@ -8588,111 +8791,6 @@ const computed = (getterOrOptions, debugOptions) => {
8588
8791
  return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
8589
8792
  };
8590
8793
 
8591
- const warnRuntimeUsage = (method) => warn(
8592
- `${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.`
8593
- );
8594
- function defineProps() {
8595
- {
8596
- warnRuntimeUsage(`defineProps`);
8597
- }
8598
- return null;
8599
- }
8600
- function defineEmits() {
8601
- {
8602
- warnRuntimeUsage(`defineEmits`);
8603
- }
8604
- return null;
8605
- }
8606
- function defineExpose(exposed) {
8607
- {
8608
- warnRuntimeUsage(`defineExpose`);
8609
- }
8610
- }
8611
- function defineOptions(options) {
8612
- {
8613
- warnRuntimeUsage(`defineOptions`);
8614
- }
8615
- }
8616
- function defineSlots() {
8617
- {
8618
- warnRuntimeUsage(`defineSlots`);
8619
- }
8620
- }
8621
- function withDefaults(props, defaults) {
8622
- {
8623
- warnRuntimeUsage(`withDefaults`);
8624
- }
8625
- return null;
8626
- }
8627
- function useSlots() {
8628
- return getContext().slots;
8629
- }
8630
- function useAttrs() {
8631
- return getContext().attrs;
8632
- }
8633
- function getContext() {
8634
- const i = getCurrentInstance();
8635
- if (!i) {
8636
- warn(`useContext() called without active instance.`);
8637
- }
8638
- return i.setupContext || (i.setupContext = createSetupContext(i));
8639
- }
8640
- function mergeDefaults(raw, defaults) {
8641
- const props = isArray(raw) ? raw.reduce(
8642
- (normalized, p) => (normalized[p] = {}, normalized),
8643
- {}
8644
- ) : raw;
8645
- for (const key in defaults) {
8646
- if (key.startsWith("__skip"))
8647
- continue;
8648
- let opt = props[key];
8649
- if (opt) {
8650
- if (isArray(opt) || isFunction(opt)) {
8651
- opt = props[key] = { type: opt, default: defaults[key] };
8652
- } else {
8653
- opt.default = defaults[key];
8654
- }
8655
- } else if (opt === null) {
8656
- opt = props[key] = { default: defaults[key] };
8657
- } else {
8658
- warn(`props default key "${key}" has no corresponding declaration.`);
8659
- }
8660
- if (opt && defaults[`__skip_${key}`]) {
8661
- opt.skipFactory = true;
8662
- }
8663
- }
8664
- return props;
8665
- }
8666
- function createPropsRestProxy(props, excludedKeys) {
8667
- const ret = {};
8668
- for (const key in props) {
8669
- if (!excludedKeys.includes(key)) {
8670
- Object.defineProperty(ret, key, {
8671
- enumerable: true,
8672
- get: () => props[key]
8673
- });
8674
- }
8675
- }
8676
- return ret;
8677
- }
8678
- function withAsyncContext(getAwaitable) {
8679
- const ctx = getCurrentInstance();
8680
- if (!ctx) {
8681
- warn(
8682
- `withAsyncContext called without active current instance. This is likely a bug.`
8683
- );
8684
- }
8685
- let awaitable = getAwaitable();
8686
- unsetCurrentInstance();
8687
- if (isPromise(awaitable)) {
8688
- awaitable = awaitable.catch((e) => {
8689
- setCurrentInstance(ctx);
8690
- throw e;
8691
- });
8692
- }
8693
- return [awaitable, () => setCurrentInstance(ctx)];
8694
- }
8695
-
8696
8794
  function h(type, propsOrChildren, children) {
8697
8795
  const l = arguments.length;
8698
8796
  if (l === 2) {
@@ -8928,7 +9026,7 @@ function isMemoSame(cached, memo) {
8928
9026
  return true;
8929
9027
  }
8930
9028
 
8931
- const version = "3.3.0-alpha.8";
9029
+ const version = "3.3.0-beta.1";
8932
9030
  const ssrUtils = null;
8933
9031
  const resolveFilter = null;
8934
9032
  const compatUtils = null;
@@ -10397,4 +10495,4 @@ function normalizeContainer(container) {
10397
10495
  }
10398
10496
  const initDirectivesForSSR = NOOP;
10399
10497
 
10400
- export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
10498
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useModel, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };