@vue/compat 3.3.0-alpha.7 → 3.3.0-alpha.9

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.
@@ -2674,25 +2674,41 @@ function setActiveBranch(suspense, branch) {
2674
2674
  }
2675
2675
  }
2676
2676
 
2677
- function provide(key, value) {
2678
- if (!currentInstance) ; else {
2679
- let provides = currentInstance.provides;
2680
- const parentProvides = currentInstance.parent && currentInstance.parent.provides;
2681
- if (parentProvides === provides) {
2682
- provides = currentInstance.provides = Object.create(parentProvides);
2677
+ const legacyDirectiveHookMap = {
2678
+ beforeMount: "bind",
2679
+ mounted: "inserted",
2680
+ updated: ["update", "componentUpdated"],
2681
+ unmounted: "unbind"
2682
+ };
2683
+ function mapCompatDirectiveHook(name, dir, instance) {
2684
+ const mappedName = legacyDirectiveHookMap[name];
2685
+ if (mappedName) {
2686
+ if (isArray(mappedName)) {
2687
+ const hook = [];
2688
+ mappedName.forEach((mapped) => {
2689
+ const mappedHook = dir[mapped];
2690
+ if (mappedHook) {
2691
+ softAssertCompatEnabled(
2692
+ "CUSTOM_DIR",
2693
+ instance,
2694
+ mapped,
2695
+ name
2696
+ );
2697
+ hook.push(mappedHook);
2698
+ }
2699
+ });
2700
+ return hook.length ? hook : void 0;
2701
+ } else {
2702
+ if (dir[mappedName]) {
2703
+ softAssertCompatEnabled(
2704
+ "CUSTOM_DIR",
2705
+ instance,
2706
+ mappedName,
2707
+ name
2708
+ );
2709
+ }
2710
+ return dir[mappedName];
2683
2711
  }
2684
- provides[key] = value;
2685
- }
2686
- }
2687
- function inject(key, defaultValue, treatDefaultAsFactory = false) {
2688
- const instance = currentInstance || currentRenderingInstance;
2689
- if (instance) {
2690
- const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
2691
- if (provides && key in provides) {
2692
- return provides[key];
2693
- } else if (arguments.length > 1) {
2694
- return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
2695
- } else ;
2696
2712
  }
2697
2713
  }
2698
2714
 
@@ -2921,6 +2937,62 @@ function traverse(value, seen) {
2921
2937
  return value;
2922
2938
  }
2923
2939
 
2940
+ function withDirectives(vnode, directives) {
2941
+ const internalInstance = currentRenderingInstance;
2942
+ if (internalInstance === null) {
2943
+ return vnode;
2944
+ }
2945
+ const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
2946
+ const bindings = vnode.dirs || (vnode.dirs = []);
2947
+ for (let i = 0; i < directives.length; i++) {
2948
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
2949
+ if (dir) {
2950
+ if (isFunction(dir)) {
2951
+ dir = {
2952
+ mounted: dir,
2953
+ updated: dir
2954
+ };
2955
+ }
2956
+ if (dir.deep) {
2957
+ traverse(value);
2958
+ }
2959
+ bindings.push({
2960
+ dir,
2961
+ instance,
2962
+ value,
2963
+ oldValue: void 0,
2964
+ arg,
2965
+ modifiers
2966
+ });
2967
+ }
2968
+ }
2969
+ return vnode;
2970
+ }
2971
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
2972
+ const bindings = vnode.dirs;
2973
+ const oldBindings = prevVNode && prevVNode.dirs;
2974
+ for (let i = 0; i < bindings.length; i++) {
2975
+ const binding = bindings[i];
2976
+ if (oldBindings) {
2977
+ binding.oldValue = oldBindings[i].value;
2978
+ }
2979
+ let hook = binding.dir[name];
2980
+ if (!hook) {
2981
+ hook = mapCompatDirectiveHook(name, binding.dir, instance);
2982
+ }
2983
+ if (hook) {
2984
+ pauseTracking();
2985
+ callWithAsyncErrorHandling(hook, instance, 8, [
2986
+ vnode.el,
2987
+ binding,
2988
+ vnode,
2989
+ prevVNode
2990
+ ]);
2991
+ resetTracking();
2992
+ }
2993
+ }
2994
+ }
2995
+
2924
2996
  function useTransitionState() {
2925
2997
  const state = {
2926
2998
  isMounted: false,
@@ -3690,100 +3762,6 @@ function getCompatListeners(instance) {
3690
3762
  return listeners;
3691
3763
  }
3692
3764
 
3693
- const legacyDirectiveHookMap = {
3694
- beforeMount: "bind",
3695
- mounted: "inserted",
3696
- updated: ["update", "componentUpdated"],
3697
- unmounted: "unbind"
3698
- };
3699
- function mapCompatDirectiveHook(name, dir, instance) {
3700
- const mappedName = legacyDirectiveHookMap[name];
3701
- if (mappedName) {
3702
- if (isArray(mappedName)) {
3703
- const hook = [];
3704
- mappedName.forEach((mapped) => {
3705
- const mappedHook = dir[mapped];
3706
- if (mappedHook) {
3707
- softAssertCompatEnabled(
3708
- "CUSTOM_DIR",
3709
- instance,
3710
- mapped,
3711
- name
3712
- );
3713
- hook.push(mappedHook);
3714
- }
3715
- });
3716
- return hook.length ? hook : void 0;
3717
- } else {
3718
- if (dir[mappedName]) {
3719
- softAssertCompatEnabled(
3720
- "CUSTOM_DIR",
3721
- instance,
3722
- mappedName,
3723
- name
3724
- );
3725
- }
3726
- return dir[mappedName];
3727
- }
3728
- }
3729
- }
3730
-
3731
- function withDirectives(vnode, directives) {
3732
- const internalInstance = currentRenderingInstance;
3733
- if (internalInstance === null) {
3734
- return vnode;
3735
- }
3736
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
3737
- const bindings = vnode.dirs || (vnode.dirs = []);
3738
- for (let i = 0; i < directives.length; i++) {
3739
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
3740
- if (dir) {
3741
- if (isFunction(dir)) {
3742
- dir = {
3743
- mounted: dir,
3744
- updated: dir
3745
- };
3746
- }
3747
- if (dir.deep) {
3748
- traverse(value);
3749
- }
3750
- bindings.push({
3751
- dir,
3752
- instance,
3753
- value,
3754
- oldValue: void 0,
3755
- arg,
3756
- modifiers
3757
- });
3758
- }
3759
- }
3760
- return vnode;
3761
- }
3762
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
3763
- const bindings = vnode.dirs;
3764
- const oldBindings = prevVNode && prevVNode.dirs;
3765
- for (let i = 0; i < bindings.length; i++) {
3766
- const binding = bindings[i];
3767
- if (oldBindings) {
3768
- binding.oldValue = oldBindings[i].value;
3769
- }
3770
- let hook = binding.dir[name];
3771
- if (!hook) {
3772
- hook = mapCompatDirectiveHook(name, binding.dir, instance);
3773
- }
3774
- if (hook) {
3775
- pauseTracking();
3776
- callWithAsyncErrorHandling(hook, instance, 8, [
3777
- vnode.el,
3778
- binding,
3779
- vnode,
3780
- prevVNode
3781
- ]);
3782
- resetTracking();
3783
- }
3784
- }
3785
- }
3786
-
3787
3765
  const COMPONENTS = "components";
3788
3766
  const DIRECTIVES = "directives";
3789
3767
  const FILTERS = "filters";
@@ -4915,918 +4893,949 @@ function mergeWatchOptions(to, from) {
4915
4893
  return merged;
4916
4894
  }
4917
4895
 
4918
- function createPropsDefaultThis(instance, rawProps, propKey) {
4919
- return new Proxy(
4920
- {},
4921
- {
4922
- get(_, key) {
4923
- if (key === "$options") {
4924
- return resolveMergedOptions(instance);
4925
- }
4926
- if (key in rawProps) {
4927
- return rawProps[key];
4928
- }
4929
- const injections = instance.type.inject;
4930
- if (injections) {
4931
- if (isArray(injections)) {
4932
- if (injections.includes(key)) {
4933
- return inject(key);
4934
- }
4935
- } else if (key in injections) {
4936
- return inject(key);
4937
- }
4938
- }
4896
+ function installLegacyOptionMergeStrats(config) {
4897
+ config.optionMergeStrategies = new Proxy({}, {
4898
+ get(target, key) {
4899
+ if (key in target) {
4900
+ return target[key];
4901
+ }
4902
+ if (key in internalOptionMergeStrats && softAssertCompatEnabled(
4903
+ "CONFIG_OPTION_MERGE_STRATS",
4904
+ null
4905
+ )) {
4906
+ return internalOptionMergeStrats[key];
4939
4907
  }
4940
4908
  }
4941
- );
4942
- }
4943
-
4944
- function shouldSkipAttr(key, instance) {
4945
- if (key === "is") {
4946
- return true;
4947
- }
4948
- if ((key === "class" || key === "style") && isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
4949
- return true;
4950
- }
4951
- if (isOn(key) && isCompatEnabled$1("INSTANCE_LISTENERS", instance)) {
4952
- return true;
4953
- }
4954
- if (key.startsWith("routerView") || key === "registerRouteInstance") {
4955
- return true;
4956
- }
4957
- return false;
4909
+ });
4958
4910
  }
4959
4911
 
4960
- function initProps(instance, rawProps, isStateful, isSSR = false) {
4961
- const props = {};
4962
- const attrs = {};
4963
- def(attrs, InternalObjectKey, 1);
4964
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
4965
- setFullProps(instance, rawProps, props, attrs);
4966
- for (const key in instance.propsOptions[0]) {
4967
- if (!(key in props)) {
4968
- props[key] = void 0;
4912
+ let singletonApp;
4913
+ let singletonCtor;
4914
+ function createCompatVue$1(createApp, createSingletonApp) {
4915
+ singletonApp = createSingletonApp({});
4916
+ const Vue = singletonCtor = function Vue2(options = {}) {
4917
+ return createCompatApp(options, Vue2);
4918
+ };
4919
+ function createCompatApp(options = {}, Ctor) {
4920
+ assertCompatEnabled("GLOBAL_MOUNT", null);
4921
+ const { data } = options;
4922
+ if (data && !isFunction(data) && softAssertCompatEnabled("OPTIONS_DATA_FN", null)) {
4923
+ options.data = () => data;
4969
4924
  }
4970
- }
4971
- if (isStateful) {
4972
- instance.props = isSSR ? props : shallowReactive(props);
4973
- } else {
4974
- if (!instance.type.props) {
4975
- instance.props = attrs;
4925
+ const app = createApp(options);
4926
+ if (Ctor !== Vue) {
4927
+ applySingletonPrototype(app, Ctor);
4928
+ }
4929
+ const vm = app._createRoot(options);
4930
+ if (options.el) {
4931
+ return vm.$mount(options.el);
4976
4932
  } else {
4977
- instance.props = props;
4933
+ return vm;
4978
4934
  }
4979
4935
  }
4980
- instance.attrs = attrs;
4981
- }
4982
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
4983
- const {
4984
- props,
4985
- attrs,
4986
- vnode: { patchFlag }
4987
- } = instance;
4988
- const rawCurrentProps = toRaw(props);
4989
- const [options] = instance.propsOptions;
4990
- let hasAttrsChanged = false;
4991
- if (
4992
- // always force full diff in dev
4993
- // - #1942 if hmr is enabled with sfc component
4994
- // - vite#872 non-sfc component used by sfc component
4995
- (optimized || patchFlag > 0) && !(patchFlag & 16)
4996
- ) {
4997
- if (patchFlag & 8) {
4998
- const propsToUpdate = instance.vnode.dynamicProps;
4999
- for (let i = 0; i < propsToUpdate.length; i++) {
5000
- let key = propsToUpdate[i];
5001
- if (isEmitListener(instance.emitsOptions, key)) {
5002
- continue;
5003
- }
5004
- const value = rawProps[key];
5005
- if (options) {
5006
- if (hasOwn(attrs, key)) {
5007
- if (value !== attrs[key]) {
5008
- attrs[key] = value;
5009
- hasAttrsChanged = true;
5010
- }
5011
- } else {
5012
- const camelizedKey = camelize(key);
5013
- props[camelizedKey] = resolvePropValue(
5014
- options,
5015
- rawCurrentProps,
5016
- camelizedKey,
5017
- value,
5018
- instance,
5019
- false
5020
- /* isAbsent */
5021
- );
5022
- }
5023
- } else {
5024
- {
5025
- if (isOn(key) && key.endsWith("Native")) {
5026
- key = key.slice(0, -6);
5027
- } else if (shouldSkipAttr(key, instance)) {
5028
- continue;
5029
- }
5030
- }
5031
- if (value !== attrs[key]) {
5032
- attrs[key] = value;
5033
- hasAttrsChanged = true;
5034
- }
5035
- }
5036
- }
5037
- }
5038
- } else {
5039
- if (setFullProps(instance, rawProps, props, attrs)) {
5040
- hasAttrsChanged = true;
4936
+ Vue.version = `2.6.14-compat:${"3.3.0-alpha.9"}`;
4937
+ Vue.config = singletonApp.config;
4938
+ Vue.use = (p, ...options) => {
4939
+ if (p && isFunction(p.install)) {
4940
+ p.install(Vue, ...options);
4941
+ } else if (isFunction(p)) {
4942
+ p(Vue, ...options);
5041
4943
  }
5042
- let kebabKey;
5043
- for (const key in rawCurrentProps) {
5044
- if (!rawProps || // for camelCase
5045
- !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
5046
- // and converted to camelCase (#955)
5047
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
5048
- if (options) {
5049
- if (rawPrevProps && // for camelCase
5050
- (rawPrevProps[key] !== void 0 || // for kebab-case
5051
- rawPrevProps[kebabKey] !== void 0)) {
5052
- props[key] = resolvePropValue(
5053
- options,
5054
- rawCurrentProps,
5055
- key,
5056
- void 0,
5057
- instance,
5058
- true
5059
- /* isAbsent */
5060
- );
5061
- }
5062
- } else {
5063
- delete props[key];
5064
- }
5065
- }
4944
+ return Vue;
4945
+ };
4946
+ Vue.mixin = (m) => {
4947
+ singletonApp.mixin(m);
4948
+ return Vue;
4949
+ };
4950
+ Vue.component = (name, comp) => {
4951
+ if (comp) {
4952
+ singletonApp.component(name, comp);
4953
+ return Vue;
4954
+ } else {
4955
+ return singletonApp.component(name);
5066
4956
  }
5067
- if (attrs !== rawCurrentProps) {
5068
- for (const key in attrs) {
5069
- if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
5070
- delete attrs[key];
5071
- hasAttrsChanged = true;
5072
- }
5073
- }
4957
+ };
4958
+ Vue.directive = (name, dir) => {
4959
+ if (dir) {
4960
+ singletonApp.directive(name, dir);
4961
+ return Vue;
4962
+ } else {
4963
+ return singletonApp.directive(name);
5074
4964
  }
5075
- }
5076
- if (hasAttrsChanged) {
5077
- trigger(instance, "set", "$attrs");
5078
- }
5079
- }
5080
- function setFullProps(instance, rawProps, props, attrs) {
5081
- const [options, needCastKeys] = instance.propsOptions;
5082
- let hasAttrsChanged = false;
5083
- let rawCastValues;
5084
- if (rawProps) {
5085
- for (let key in rawProps) {
5086
- if (isReservedProp(key)) {
5087
- continue;
5088
- }
5089
- {
5090
- if (key.startsWith("onHook:")) {
5091
- softAssertCompatEnabled(
5092
- "INSTANCE_EVENT_HOOKS",
5093
- instance,
5094
- key.slice(2).toLowerCase()
5095
- );
5096
- }
5097
- if (key === "inline-template") {
5098
- continue;
5099
- }
5100
- }
5101
- const value = rawProps[key];
5102
- let camelKey;
5103
- if (options && hasOwn(options, camelKey = camelize(key))) {
5104
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
5105
- props[camelKey] = value;
5106
- } else {
5107
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
5108
- }
5109
- } else if (!isEmitListener(instance.emitsOptions, key)) {
5110
- {
5111
- if (isOn(key) && key.endsWith("Native")) {
5112
- key = key.slice(0, -6);
5113
- } else if (shouldSkipAttr(key, instance)) {
5114
- continue;
5115
- }
5116
- }
5117
- if (!(key in attrs) || value !== attrs[key]) {
5118
- attrs[key] = value;
5119
- hasAttrsChanged = true;
5120
- }
5121
- }
4965
+ };
4966
+ Vue.options = { _base: Vue };
4967
+ let cid = 1;
4968
+ Vue.cid = cid;
4969
+ Vue.nextTick = nextTick;
4970
+ const extendCache = /* @__PURE__ */ new WeakMap();
4971
+ function extendCtor(extendOptions = {}) {
4972
+ assertCompatEnabled("GLOBAL_EXTEND", null);
4973
+ if (isFunction(extendOptions)) {
4974
+ extendOptions = extendOptions.options;
5122
4975
  }
5123
- }
5124
- if (needCastKeys) {
5125
- const rawCurrentProps = toRaw(props);
5126
- const castValues = rawCastValues || EMPTY_OBJ;
5127
- for (let i = 0; i < needCastKeys.length; i++) {
5128
- const key = needCastKeys[i];
5129
- props[key] = resolvePropValue(
5130
- options,
5131
- rawCurrentProps,
5132
- key,
5133
- castValues[key],
5134
- instance,
5135
- !hasOwn(castValues, key)
5136
- );
4976
+ if (extendCache.has(extendOptions)) {
4977
+ return extendCache.get(extendOptions);
5137
4978
  }
5138
- }
5139
- return hasAttrsChanged;
5140
- }
5141
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
5142
- const opt = options[key];
5143
- if (opt != null) {
5144
- const hasDefault = hasOwn(opt, "default");
5145
- if (hasDefault && value === void 0) {
5146
- const defaultValue = opt.default;
5147
- if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
5148
- const { propsDefaults } = instance;
5149
- if (key in propsDefaults) {
5150
- value = propsDefaults[key];
5151
- } else {
5152
- setCurrentInstance(instance);
5153
- value = propsDefaults[key] = defaultValue.call(
5154
- isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props) : null,
5155
- props
5156
- );
5157
- unsetCurrentInstance();
5158
- }
4979
+ const Super = this;
4980
+ function SubVue(inlineOptions) {
4981
+ if (!inlineOptions) {
4982
+ return createCompatApp(SubVue.options, SubVue);
5159
4983
  } else {
5160
- value = defaultValue;
4984
+ return createCompatApp(
4985
+ mergeOptions(
4986
+ extend({}, SubVue.options),
4987
+ inlineOptions,
4988
+ internalOptionMergeStrats
4989
+ ),
4990
+ SubVue
4991
+ );
5161
4992
  }
5162
4993
  }
5163
- if (opt[0 /* shouldCast */]) {
5164
- if (isAbsent && !hasDefault) {
5165
- value = false;
5166
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
5167
- value = true;
5168
- }
4994
+ SubVue.super = Super;
4995
+ SubVue.prototype = Object.create(Vue.prototype);
4996
+ SubVue.prototype.constructor = SubVue;
4997
+ const mergeBase = {};
4998
+ for (const key in Super.options) {
4999
+ const superValue = Super.options[key];
5000
+ mergeBase[key] = isArray(superValue) ? superValue.slice() : isObject(superValue) ? extend(/* @__PURE__ */ Object.create(null), superValue) : superValue;
5169
5001
  }
5002
+ SubVue.options = mergeOptions(
5003
+ mergeBase,
5004
+ extendOptions,
5005
+ internalOptionMergeStrats
5006
+ );
5007
+ SubVue.options._base = SubVue;
5008
+ SubVue.extend = extendCtor.bind(SubVue);
5009
+ SubVue.mixin = Super.mixin;
5010
+ SubVue.use = Super.use;
5011
+ SubVue.cid = ++cid;
5012
+ extendCache.set(extendOptions, SubVue);
5013
+ return SubVue;
5170
5014
  }
5171
- return value;
5172
- }
5173
- function normalizePropsOptions(comp, appContext, asMixin = false) {
5174
- const cache = appContext.propsCache;
5175
- const cached = cache.get(comp);
5176
- if (cached) {
5177
- return cached;
5178
- }
5179
- const raw = comp.props;
5180
- const normalized = {};
5181
- const needCastKeys = [];
5182
- let hasExtends = false;
5183
- if (!isFunction(comp)) {
5184
- const extendProps = (raw2) => {
5185
- if (isFunction(raw2)) {
5186
- raw2 = raw2.options;
5187
- }
5188
- hasExtends = true;
5189
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
5190
- extend(normalized, props);
5191
- if (keys)
5192
- needCastKeys.push(...keys);
5193
- };
5194
- if (!asMixin && appContext.mixins.length) {
5195
- appContext.mixins.forEach(extendProps);
5196
- }
5197
- if (comp.extends) {
5198
- extendProps(comp.extends);
5015
+ Vue.extend = extendCtor.bind(Vue);
5016
+ Vue.set = (target, key, value) => {
5017
+ assertCompatEnabled("GLOBAL_SET", null);
5018
+ target[key] = value;
5019
+ };
5020
+ Vue.delete = (target, key) => {
5021
+ assertCompatEnabled("GLOBAL_DELETE", null);
5022
+ delete target[key];
5023
+ };
5024
+ Vue.observable = (target) => {
5025
+ assertCompatEnabled("GLOBAL_OBSERVABLE", null);
5026
+ return reactive(target);
5027
+ };
5028
+ Vue.filter = (name, filter) => {
5029
+ if (filter) {
5030
+ singletonApp.filter(name, filter);
5031
+ return Vue;
5032
+ } else {
5033
+ return singletonApp.filter(name);
5199
5034
  }
5200
- if (comp.mixins) {
5201
- comp.mixins.forEach(extendProps);
5035
+ };
5036
+ const util = {
5037
+ warn: NOOP,
5038
+ extend,
5039
+ mergeOptions: (parent, child, vm) => mergeOptions(
5040
+ parent,
5041
+ child,
5042
+ vm ? void 0 : internalOptionMergeStrats
5043
+ ),
5044
+ defineReactive
5045
+ };
5046
+ Object.defineProperty(Vue, "util", {
5047
+ get() {
5048
+ assertCompatEnabled("GLOBAL_PRIVATE_UTIL", null);
5049
+ return util;
5202
5050
  }
5051
+ });
5052
+ Vue.configureCompat = configureCompat;
5053
+ return Vue;
5054
+ }
5055
+ function installAppCompatProperties(app, context, render) {
5056
+ installFilterMethod(app, context);
5057
+ installLegacyOptionMergeStrats(app.config);
5058
+ if (!singletonApp) {
5059
+ return;
5203
5060
  }
5204
- if (!raw && !hasExtends) {
5205
- if (isObject(comp)) {
5206
- cache.set(comp, EMPTY_ARR);
5061
+ installCompatMount(app, context, render);
5062
+ installLegacyAPIs(app);
5063
+ applySingletonAppMutations(app);
5064
+ }
5065
+ function installFilterMethod(app, context) {
5066
+ context.filters = {};
5067
+ app.filter = (name, filter) => {
5068
+ assertCompatEnabled("FILTERS", null);
5069
+ if (!filter) {
5070
+ return context.filters[name];
5207
5071
  }
5208
- return EMPTY_ARR;
5209
- }
5210
- if (isArray(raw)) {
5211
- for (let i = 0; i < raw.length; i++) {
5212
- const normalizedKey = camelize(raw[i]);
5213
- if (validatePropName(normalizedKey)) {
5214
- normalized[normalizedKey] = EMPTY_OBJ;
5072
+ context.filters[name] = filter;
5073
+ return app;
5074
+ };
5075
+ }
5076
+ function installLegacyAPIs(app) {
5077
+ Object.defineProperties(app, {
5078
+ // so that app.use() can work with legacy plugins that extend prototypes
5079
+ prototype: {
5080
+ get() {
5081
+ return app.config.globalProperties;
5215
5082
  }
5216
- }
5217
- } else if (raw) {
5218
- for (const key in raw) {
5219
- const normalizedKey = camelize(key);
5220
- if (validatePropName(normalizedKey)) {
5221
- const opt = raw[key];
5222
- const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
5223
- if (prop) {
5224
- const booleanIndex = getTypeIndex(Boolean, prop.type);
5225
- const stringIndex = getTypeIndex(String, prop.type);
5226
- prop[0 /* shouldCast */] = booleanIndex > -1;
5227
- prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
5228
- if (booleanIndex > -1 || hasOwn(prop, "default")) {
5229
- needCastKeys.push(normalizedKey);
5230
- }
5231
- }
5083
+ },
5084
+ nextTick: { value: nextTick },
5085
+ extend: { value: singletonCtor.extend },
5086
+ set: { value: singletonCtor.set },
5087
+ delete: { value: singletonCtor.delete },
5088
+ observable: { value: singletonCtor.observable },
5089
+ util: {
5090
+ get() {
5091
+ return singletonCtor.util;
5232
5092
  }
5233
5093
  }
5234
- }
5235
- const res = [normalized, needCastKeys];
5236
- if (isObject(comp)) {
5237
- cache.set(comp, res);
5238
- }
5239
- return res;
5240
- }
5241
- function validatePropName(key) {
5242
- if (key[0] !== "$") {
5243
- return true;
5244
- }
5245
- return false;
5246
- }
5247
- function getType(ctor) {
5248
- const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
5249
- return match ? match[2] : ctor === null ? "null" : "";
5250
- }
5251
- function isSameType(a, b) {
5252
- return getType(a) === getType(b);
5253
- }
5254
- function getTypeIndex(type, expectedTypes) {
5255
- if (isArray(expectedTypes)) {
5256
- return expectedTypes.findIndex((t) => isSameType(t, type));
5257
- } else if (isFunction(expectedTypes)) {
5258
- return isSameType(expectedTypes, type) ? 0 : -1;
5259
- }
5260
- return -1;
5094
+ });
5261
5095
  }
5262
-
5263
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
5264
- const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
5265
- const normalizeSlot = (key, rawSlot, ctx) => {
5266
- if (rawSlot._n) {
5267
- return rawSlot;
5268
- }
5269
- const normalized = withCtx((...args) => {
5270
- if (false) ;
5271
- return normalizeSlotValue(rawSlot(...args));
5272
- }, ctx);
5273
- normalized._c = false;
5274
- return normalized;
5275
- };
5276
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
5277
- const ctx = rawSlots._ctx;
5278
- for (const key in rawSlots) {
5279
- if (isInternalKey(key))
5096
+ function applySingletonAppMutations(app) {
5097
+ app._context.mixins = [...singletonApp._context.mixins];
5098
+ ["components", "directives", "filters"].forEach((key) => {
5099
+ app._context[key] = Object.create(singletonApp._context[key]);
5100
+ });
5101
+ for (const key in singletonApp.config) {
5102
+ if (key === "isNativeTag")
5103
+ continue;
5104
+ if (isRuntimeOnly() && (key === "isCustomElement" || key === "compilerOptions")) {
5280
5105
  continue;
5281
- const value = rawSlots[key];
5282
- if (isFunction(value)) {
5283
- slots[key] = normalizeSlot(key, value, ctx);
5284
- } else if (value != null) {
5285
- const normalized = normalizeSlotValue(value);
5286
- slots[key] = () => normalized;
5287
5106
  }
5288
- }
5289
- };
5290
- const normalizeVNodeSlots = (instance, children) => {
5291
- const normalized = normalizeSlotValue(children);
5292
- instance.slots.default = () => normalized;
5293
- };
5294
- const initSlots = (instance, children) => {
5295
- if (instance.vnode.shapeFlag & 32) {
5296
- const type = children._;
5297
- if (type) {
5298
- instance.slots = toRaw(children);
5299
- def(children, "_", type);
5300
- } else {
5301
- normalizeObjectSlots(
5302
- children,
5303
- instance.slots = {});
5107
+ const val = singletonApp.config[key];
5108
+ app.config[key] = isObject(val) ? Object.create(val) : val;
5109
+ if (key === "ignoredElements" && isCompatEnabled$1("CONFIG_IGNORED_ELEMENTS", null) && !isRuntimeOnly() && isArray(val)) {
5110
+ app.config.compilerOptions.isCustomElement = (tag) => {
5111
+ return val.some((v) => isString(v) ? v === tag : v.test(tag));
5112
+ };
5304
5113
  }
5305
- } else {
5306
- instance.slots = {};
5307
- if (children) {
5308
- normalizeVNodeSlots(instance, children);
5114
+ }
5115
+ applySingletonPrototype(app, singletonCtor);
5116
+ }
5117
+ function applySingletonPrototype(app, Ctor) {
5118
+ const enabled = isCompatEnabled$1("GLOBAL_PROTOTYPE", null);
5119
+ if (enabled) {
5120
+ app.config.globalProperties = Object.create(Ctor.prototype);
5121
+ }
5122
+ const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
5123
+ for (const key in descriptors) {
5124
+ if (key !== "constructor") {
5125
+ if (enabled) {
5126
+ Object.defineProperty(
5127
+ app.config.globalProperties,
5128
+ key,
5129
+ descriptors[key]
5130
+ );
5131
+ }
5309
5132
  }
5310
5133
  }
5311
- def(instance.slots, InternalObjectKey, 1);
5312
- };
5313
- const updateSlots = (instance, children, optimized) => {
5314
- const { vnode, slots } = instance;
5315
- let needDeletionCheck = true;
5316
- let deletionComparisonTarget = EMPTY_OBJ;
5317
- if (vnode.shapeFlag & 32) {
5318
- const type = children._;
5319
- if (type) {
5320
- if (optimized && type === 1) {
5321
- needDeletionCheck = false;
5134
+ }
5135
+ function installCompatMount(app, context, render) {
5136
+ let isMounted = false;
5137
+ app._createRoot = (options) => {
5138
+ const component = app._component;
5139
+ const vnode = createVNode(component, options.propsData || null);
5140
+ vnode.appContext = context;
5141
+ const hasNoRender = !isFunction(component) && !component.render && !component.template;
5142
+ const emptyRender = () => {
5143
+ };
5144
+ const instance = createComponentInstance(vnode, null, null);
5145
+ if (hasNoRender) {
5146
+ instance.render = emptyRender;
5147
+ }
5148
+ setupComponent(instance);
5149
+ vnode.component = instance;
5150
+ vnode.isCompatRoot = true;
5151
+ instance.ctx._compat_mount = (selectorOrEl) => {
5152
+ if (isMounted) {
5153
+ return;
5154
+ }
5155
+ let container;
5156
+ if (typeof selectorOrEl === "string") {
5157
+ const result = document.querySelector(selectorOrEl);
5158
+ if (!result) {
5159
+ return;
5160
+ }
5161
+ container = result;
5322
5162
  } else {
5323
- extend(slots, children);
5324
- if (!optimized && type === 1) {
5325
- delete slots._;
5163
+ container = selectorOrEl || document.createElement("div");
5164
+ }
5165
+ const isSVG = container instanceof SVGElement;
5166
+ if (hasNoRender && instance.render === emptyRender) {
5167
+ instance.render = null;
5168
+ component.template = container.innerHTML;
5169
+ finishComponentSetup(
5170
+ instance,
5171
+ false,
5172
+ true
5173
+ /* skip options */
5174
+ );
5175
+ }
5176
+ container.innerHTML = "";
5177
+ render(vnode, container, isSVG);
5178
+ if (container instanceof Element) {
5179
+ container.removeAttribute("v-cloak");
5180
+ container.setAttribute("data-v-app", "");
5181
+ }
5182
+ isMounted = true;
5183
+ app._container = container;
5184
+ container.__vue_app__ = app;
5185
+ return instance.proxy;
5186
+ };
5187
+ instance.ctx._compat_destroy = () => {
5188
+ if (isMounted) {
5189
+ render(null, app._container);
5190
+ delete app._container.__vue_app__;
5191
+ } else {
5192
+ const { bum, scope, um } = instance;
5193
+ if (bum) {
5194
+ invokeArrayFns(bum);
5195
+ }
5196
+ if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
5197
+ instance.emit("hook:beforeDestroy");
5198
+ }
5199
+ if (scope) {
5200
+ scope.stop();
5201
+ }
5202
+ if (um) {
5203
+ invokeArrayFns(um);
5204
+ }
5205
+ if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
5206
+ instance.emit("hook:destroyed");
5326
5207
  }
5327
5208
  }
5209
+ };
5210
+ return instance.proxy;
5211
+ };
5212
+ }
5213
+ const methodsToPatch = [
5214
+ "push",
5215
+ "pop",
5216
+ "shift",
5217
+ "unshift",
5218
+ "splice",
5219
+ "sort",
5220
+ "reverse"
5221
+ ];
5222
+ const patched = /* @__PURE__ */ new WeakSet();
5223
+ function defineReactive(obj, key, val) {
5224
+ if (isObject(val) && !isReactive(val) && !patched.has(val)) {
5225
+ const reactiveVal = reactive(val);
5226
+ if (isArray(val)) {
5227
+ methodsToPatch.forEach((m) => {
5228
+ val[m] = (...args) => {
5229
+ Array.prototype[m].call(reactiveVal, ...args);
5230
+ };
5231
+ });
5328
5232
  } else {
5329
- needDeletionCheck = !children.$stable;
5330
- normalizeObjectSlots(children, slots);
5233
+ Object.keys(val).forEach((key2) => {
5234
+ try {
5235
+ defineReactiveSimple(val, key2, val[key2]);
5236
+ } catch (e) {
5237
+ }
5238
+ });
5331
5239
  }
5332
- deletionComparisonTarget = children;
5333
- } else if (children) {
5334
- normalizeVNodeSlots(instance, children);
5335
- deletionComparisonTarget = { default: 1 };
5336
5240
  }
5337
- if (needDeletionCheck) {
5338
- for (const key in slots) {
5339
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5340
- delete slots[key];
5341
- }
5342
- }
5241
+ const i = obj.$;
5242
+ if (i && obj === i.proxy) {
5243
+ defineReactiveSimple(i.ctx, key, val);
5244
+ i.accessCache = /* @__PURE__ */ Object.create(null);
5245
+ } else if (isReactive(obj)) {
5246
+ obj[key] = val;
5247
+ } else {
5248
+ defineReactiveSimple(obj, key, val);
5343
5249
  }
5344
- };
5345
-
5346
- function installLegacyOptionMergeStrats(config) {
5347
- config.optionMergeStrategies = new Proxy({}, {
5348
- get(target, key) {
5349
- if (key in target) {
5350
- return target[key];
5351
- }
5352
- if (key in internalOptionMergeStrats && softAssertCompatEnabled(
5353
- "CONFIG_OPTION_MERGE_STRATS",
5354
- null
5355
- )) {
5356
- return internalOptionMergeStrats[key];
5357
- }
5250
+ }
5251
+ function defineReactiveSimple(obj, key, val) {
5252
+ val = isObject(val) ? reactive(val) : val;
5253
+ Object.defineProperty(obj, key, {
5254
+ enumerable: true,
5255
+ configurable: true,
5256
+ get() {
5257
+ track(obj, "get", key);
5258
+ return val;
5259
+ },
5260
+ set(newVal) {
5261
+ val = isObject(newVal) ? reactive(newVal) : newVal;
5262
+ trigger(obj, "set", key, newVal);
5358
5263
  }
5359
5264
  });
5360
5265
  }
5361
5266
 
5362
- let singletonApp;
5363
- let singletonCtor;
5364
- function createCompatVue$1(createApp, createSingletonApp) {
5365
- singletonApp = createSingletonApp({});
5366
- const Vue = singletonCtor = function Vue2(options = {}) {
5367
- return createCompatApp(options, Vue2);
5368
- };
5369
- function createCompatApp(options = {}, Ctor) {
5370
- assertCompatEnabled("GLOBAL_MOUNT", null);
5371
- const { data } = options;
5372
- if (data && !isFunction(data) && softAssertCompatEnabled("OPTIONS_DATA_FN", null)) {
5373
- options.data = () => data;
5374
- }
5375
- const app = createApp(options);
5376
- if (Ctor !== Vue) {
5377
- applySingletonPrototype(app, Ctor);
5378
- }
5379
- const vm = app._createRoot(options);
5380
- if (options.el) {
5381
- return vm.$mount(options.el);
5382
- } else {
5383
- return vm;
5384
- }
5385
- }
5386
- Vue.version = `2.6.14-compat:${"3.3.0-alpha.7"}`;
5387
- Vue.config = singletonApp.config;
5388
- Vue.use = (p, ...options) => {
5389
- if (p && isFunction(p.install)) {
5390
- p.install(Vue, ...options);
5391
- } else if (isFunction(p)) {
5392
- p(Vue, ...options);
5393
- }
5394
- return Vue;
5395
- };
5396
- Vue.mixin = (m) => {
5397
- singletonApp.mixin(m);
5398
- return Vue;
5399
- };
5400
- Vue.component = (name, comp) => {
5401
- if (comp) {
5402
- singletonApp.component(name, comp);
5403
- return Vue;
5404
- } else {
5405
- return singletonApp.component(name);
5406
- }
5407
- };
5408
- Vue.directive = (name, dir) => {
5409
- if (dir) {
5410
- singletonApp.directive(name, dir);
5411
- return Vue;
5412
- } else {
5413
- return singletonApp.directive(name);
5414
- }
5267
+ function createAppContext() {
5268
+ return {
5269
+ app: null,
5270
+ config: {
5271
+ isNativeTag: NO,
5272
+ performance: false,
5273
+ globalProperties: {},
5274
+ optionMergeStrategies: {},
5275
+ errorHandler: void 0,
5276
+ warnHandler: void 0,
5277
+ compilerOptions: {}
5278
+ },
5279
+ mixins: [],
5280
+ components: {},
5281
+ directives: {},
5282
+ provides: /* @__PURE__ */ Object.create(null),
5283
+ optionsCache: /* @__PURE__ */ new WeakMap(),
5284
+ propsCache: /* @__PURE__ */ new WeakMap(),
5285
+ emitsCache: /* @__PURE__ */ new WeakMap()
5415
5286
  };
5416
- Vue.options = { _base: Vue };
5417
- let cid = 1;
5418
- Vue.cid = cid;
5419
- Vue.nextTick = nextTick;
5420
- const extendCache = /* @__PURE__ */ new WeakMap();
5421
- function extendCtor(extendOptions = {}) {
5422
- assertCompatEnabled("GLOBAL_EXTEND", null);
5423
- if (isFunction(extendOptions)) {
5424
- extendOptions = extendOptions.options;
5287
+ }
5288
+ let uid$1 = 0;
5289
+ function createAppAPI(render, hydrate) {
5290
+ return function createApp(rootComponent, rootProps = null) {
5291
+ if (!isFunction(rootComponent)) {
5292
+ rootComponent = extend({}, rootComponent);
5425
5293
  }
5426
- if (extendCache.has(extendOptions)) {
5427
- return extendCache.get(extendOptions);
5294
+ if (rootProps != null && !isObject(rootProps)) {
5295
+ rootProps = null;
5428
5296
  }
5429
- const Super = this;
5430
- function SubVue(inlineOptions) {
5431
- if (!inlineOptions) {
5432
- return createCompatApp(SubVue.options, SubVue);
5433
- } else {
5434
- return createCompatApp(
5435
- mergeOptions(
5436
- extend({}, SubVue.options),
5437
- inlineOptions,
5438
- internalOptionMergeStrats
5439
- ),
5440
- SubVue
5441
- );
5297
+ const context = createAppContext();
5298
+ const installedPlugins = /* @__PURE__ */ new Set();
5299
+ let isMounted = false;
5300
+ const app = context.app = {
5301
+ _uid: uid$1++,
5302
+ _component: rootComponent,
5303
+ _props: rootProps,
5304
+ _container: null,
5305
+ _context: context,
5306
+ _instance: null,
5307
+ version,
5308
+ get config() {
5309
+ return context.config;
5310
+ },
5311
+ set config(v) {
5312
+ },
5313
+ use(plugin, ...options) {
5314
+ if (installedPlugins.has(plugin)) ; else if (plugin && isFunction(plugin.install)) {
5315
+ installedPlugins.add(plugin);
5316
+ plugin.install(app, ...options);
5317
+ } else if (isFunction(plugin)) {
5318
+ installedPlugins.add(plugin);
5319
+ plugin(app, ...options);
5320
+ } else ;
5321
+ return app;
5322
+ },
5323
+ mixin(mixin) {
5324
+ {
5325
+ if (!context.mixins.includes(mixin)) {
5326
+ context.mixins.push(mixin);
5327
+ }
5328
+ }
5329
+ return app;
5330
+ },
5331
+ component(name, component) {
5332
+ if (!component) {
5333
+ return context.components[name];
5334
+ }
5335
+ context.components[name] = component;
5336
+ return app;
5337
+ },
5338
+ directive(name, directive) {
5339
+ if (!directive) {
5340
+ return context.directives[name];
5341
+ }
5342
+ context.directives[name] = directive;
5343
+ return app;
5344
+ },
5345
+ mount(rootContainer, isHydrate, isSVG) {
5346
+ if (!isMounted) {
5347
+ const vnode = createVNode(
5348
+ rootComponent,
5349
+ rootProps
5350
+ );
5351
+ vnode.appContext = context;
5352
+ if (isHydrate && hydrate) {
5353
+ hydrate(vnode, rootContainer);
5354
+ } else {
5355
+ render(vnode, rootContainer, isSVG);
5356
+ }
5357
+ isMounted = true;
5358
+ app._container = rootContainer;
5359
+ rootContainer.__vue_app__ = app;
5360
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
5361
+ }
5362
+ },
5363
+ unmount() {
5364
+ if (isMounted) {
5365
+ render(null, app._container);
5366
+ delete app._container.__vue_app__;
5367
+ }
5368
+ },
5369
+ provide(key, value) {
5370
+ context.provides[key] = value;
5371
+ return app;
5372
+ },
5373
+ runWithContext(fn) {
5374
+ currentApp = app;
5375
+ try {
5376
+ return fn();
5377
+ } finally {
5378
+ currentApp = null;
5379
+ }
5442
5380
  }
5381
+ };
5382
+ {
5383
+ installAppCompatProperties(app, context, render);
5443
5384
  }
5444
- SubVue.super = Super;
5445
- SubVue.prototype = Object.create(Vue.prototype);
5446
- SubVue.prototype.constructor = SubVue;
5447
- const mergeBase = {};
5448
- for (const key in Super.options) {
5449
- const superValue = Super.options[key];
5450
- mergeBase[key] = isArray(superValue) ? superValue.slice() : isObject(superValue) ? extend(/* @__PURE__ */ Object.create(null), superValue) : superValue;
5451
- }
5452
- SubVue.options = mergeOptions(
5453
- mergeBase,
5454
- extendOptions,
5455
- internalOptionMergeStrats
5456
- );
5457
- SubVue.options._base = SubVue;
5458
- SubVue.extend = extendCtor.bind(SubVue);
5459
- SubVue.mixin = Super.mixin;
5460
- SubVue.use = Super.use;
5461
- SubVue.cid = ++cid;
5462
- extendCache.set(extendOptions, SubVue);
5463
- return SubVue;
5464
- }
5465
- Vue.extend = extendCtor.bind(Vue);
5466
- Vue.set = (target, key, value) => {
5467
- assertCompatEnabled("GLOBAL_SET", null);
5468
- target[key] = value;
5469
- };
5470
- Vue.delete = (target, key) => {
5471
- assertCompatEnabled("GLOBAL_DELETE", null);
5472
- delete target[key];
5473
- };
5474
- Vue.observable = (target) => {
5475
- assertCompatEnabled("GLOBAL_OBSERVABLE", null);
5476
- return reactive(target);
5385
+ return app;
5477
5386
  };
5478
- Vue.filter = (name, filter) => {
5479
- if (filter) {
5480
- singletonApp.filter(name, filter);
5481
- return Vue;
5482
- } else {
5483
- return singletonApp.filter(name);
5387
+ }
5388
+ let currentApp = null;
5389
+
5390
+ function provide(key, value) {
5391
+ if (!currentInstance) ; else {
5392
+ let provides = currentInstance.provides;
5393
+ const parentProvides = currentInstance.parent && currentInstance.parent.provides;
5394
+ if (parentProvides === provides) {
5395
+ provides = currentInstance.provides = Object.create(parentProvides);
5484
5396
  }
5485
- };
5486
- const util = {
5487
- warn: NOOP,
5488
- extend,
5489
- mergeOptions: (parent, child, vm) => mergeOptions(
5490
- parent,
5491
- child,
5492
- vm ? void 0 : internalOptionMergeStrats
5493
- ),
5494
- defineReactive
5495
- };
5496
- Object.defineProperty(Vue, "util", {
5497
- get() {
5498
- assertCompatEnabled("GLOBAL_PRIVATE_UTIL", null);
5499
- return util;
5397
+ provides[key] = value;
5398
+ }
5399
+ }
5400
+ function inject(key, defaultValue, treatDefaultAsFactory = false) {
5401
+ const instance = currentInstance || currentRenderingInstance;
5402
+ if (instance || currentApp) {
5403
+ const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
5404
+ if (provides && key in provides) {
5405
+ return provides[key];
5406
+ } else if (arguments.length > 1) {
5407
+ return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
5408
+ } else ;
5409
+ }
5410
+ }
5411
+
5412
+ function createPropsDefaultThis(instance, rawProps, propKey) {
5413
+ return new Proxy(
5414
+ {},
5415
+ {
5416
+ get(_, key) {
5417
+ if (key === "$options") {
5418
+ return resolveMergedOptions(instance);
5419
+ }
5420
+ if (key in rawProps) {
5421
+ return rawProps[key];
5422
+ }
5423
+ const injections = instance.type.inject;
5424
+ if (injections) {
5425
+ if (isArray(injections)) {
5426
+ if (injections.includes(key)) {
5427
+ return inject(key);
5428
+ }
5429
+ } else if (key in injections) {
5430
+ return inject(key);
5431
+ }
5432
+ }
5433
+ }
5500
5434
  }
5501
- });
5502
- Vue.configureCompat = configureCompat;
5503
- return Vue;
5435
+ );
5504
5436
  }
5505
- function installAppCompatProperties(app, context, render) {
5506
- installFilterMethod(app, context);
5507
- installLegacyOptionMergeStrats(app.config);
5508
- if (!singletonApp) {
5509
- return;
5437
+
5438
+ function shouldSkipAttr(key, instance) {
5439
+ if (key === "is") {
5440
+ return true;
5510
5441
  }
5511
- installCompatMount(app, context, render);
5512
- installLegacyAPIs(app);
5513
- applySingletonAppMutations(app);
5442
+ if ((key === "class" || key === "style") && isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
5443
+ return true;
5444
+ }
5445
+ if (isOn(key) && isCompatEnabled$1("INSTANCE_LISTENERS", instance)) {
5446
+ return true;
5447
+ }
5448
+ if (key.startsWith("routerView") || key === "registerRouteInstance") {
5449
+ return true;
5450
+ }
5451
+ return false;
5514
5452
  }
5515
- function installFilterMethod(app, context) {
5516
- context.filters = {};
5517
- app.filter = (name, filter) => {
5518
- assertCompatEnabled("FILTERS", null);
5519
- if (!filter) {
5520
- return context.filters[name];
5453
+
5454
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
5455
+ const props = {};
5456
+ const attrs = {};
5457
+ def(attrs, InternalObjectKey, 1);
5458
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
5459
+ setFullProps(instance, rawProps, props, attrs);
5460
+ for (const key in instance.propsOptions[0]) {
5461
+ if (!(key in props)) {
5462
+ props[key] = void 0;
5521
5463
  }
5522
- context.filters[name] = filter;
5523
- return app;
5524
- };
5464
+ }
5465
+ if (isStateful) {
5466
+ instance.props = isSSR ? props : shallowReactive(props);
5467
+ } else {
5468
+ if (!instance.type.props) {
5469
+ instance.props = attrs;
5470
+ } else {
5471
+ instance.props = props;
5472
+ }
5473
+ }
5474
+ instance.attrs = attrs;
5525
5475
  }
5526
- function installLegacyAPIs(app) {
5527
- Object.defineProperties(app, {
5528
- // so that app.use() can work with legacy plugins that extend prototypes
5529
- prototype: {
5530
- get() {
5531
- return app.config.globalProperties;
5532
- }
5533
- },
5534
- nextTick: { value: nextTick },
5535
- extend: { value: singletonCtor.extend },
5536
- set: { value: singletonCtor.set },
5537
- delete: { value: singletonCtor.delete },
5538
- observable: { value: singletonCtor.observable },
5539
- util: {
5540
- get() {
5541
- return singletonCtor.util;
5476
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
5477
+ const {
5478
+ props,
5479
+ attrs,
5480
+ vnode: { patchFlag }
5481
+ } = instance;
5482
+ const rawCurrentProps = toRaw(props);
5483
+ const [options] = instance.propsOptions;
5484
+ let hasAttrsChanged = false;
5485
+ if (
5486
+ // always force full diff in dev
5487
+ // - #1942 if hmr is enabled with sfc component
5488
+ // - vite#872 non-sfc component used by sfc component
5489
+ (optimized || patchFlag > 0) && !(patchFlag & 16)
5490
+ ) {
5491
+ if (patchFlag & 8) {
5492
+ const propsToUpdate = instance.vnode.dynamicProps;
5493
+ for (let i = 0; i < propsToUpdate.length; i++) {
5494
+ let key = propsToUpdate[i];
5495
+ if (isEmitListener(instance.emitsOptions, key)) {
5496
+ continue;
5497
+ }
5498
+ const value = rawProps[key];
5499
+ if (options) {
5500
+ if (hasOwn(attrs, key)) {
5501
+ if (value !== attrs[key]) {
5502
+ attrs[key] = value;
5503
+ hasAttrsChanged = true;
5504
+ }
5505
+ } else {
5506
+ const camelizedKey = camelize(key);
5507
+ props[camelizedKey] = resolvePropValue(
5508
+ options,
5509
+ rawCurrentProps,
5510
+ camelizedKey,
5511
+ value,
5512
+ instance,
5513
+ false
5514
+ /* isAbsent */
5515
+ );
5516
+ }
5517
+ } else {
5518
+ {
5519
+ if (isOn(key) && key.endsWith("Native")) {
5520
+ key = key.slice(0, -6);
5521
+ } else if (shouldSkipAttr(key, instance)) {
5522
+ continue;
5523
+ }
5524
+ }
5525
+ if (value !== attrs[key]) {
5526
+ attrs[key] = value;
5527
+ hasAttrsChanged = true;
5528
+ }
5529
+ }
5542
5530
  }
5543
5531
  }
5544
- });
5545
- }
5546
- function applySingletonAppMutations(app) {
5547
- app._context.mixins = [...singletonApp._context.mixins];
5548
- ["components", "directives", "filters"].forEach((key) => {
5549
- app._context[key] = Object.create(singletonApp._context[key]);
5550
- });
5551
- for (const key in singletonApp.config) {
5552
- if (key === "isNativeTag")
5553
- continue;
5554
- if (isRuntimeOnly() && (key === "isCustomElement" || key === "compilerOptions")) {
5555
- continue;
5532
+ } else {
5533
+ if (setFullProps(instance, rawProps, props, attrs)) {
5534
+ hasAttrsChanged = true;
5556
5535
  }
5557
- const val = singletonApp.config[key];
5558
- app.config[key] = isObject(val) ? Object.create(val) : val;
5559
- if (key === "ignoredElements" && isCompatEnabled$1("CONFIG_IGNORED_ELEMENTS", null) && !isRuntimeOnly() && isArray(val)) {
5560
- app.config.compilerOptions.isCustomElement = (tag) => {
5561
- return val.some((v) => isString(v) ? v === tag : v.test(tag));
5562
- };
5536
+ let kebabKey;
5537
+ for (const key in rawCurrentProps) {
5538
+ if (!rawProps || // for camelCase
5539
+ !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
5540
+ // and converted to camelCase (#955)
5541
+ ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
5542
+ if (options) {
5543
+ if (rawPrevProps && // for camelCase
5544
+ (rawPrevProps[key] !== void 0 || // for kebab-case
5545
+ rawPrevProps[kebabKey] !== void 0)) {
5546
+ props[key] = resolvePropValue(
5547
+ options,
5548
+ rawCurrentProps,
5549
+ key,
5550
+ void 0,
5551
+ instance,
5552
+ true
5553
+ /* isAbsent */
5554
+ );
5555
+ }
5556
+ } else {
5557
+ delete props[key];
5558
+ }
5559
+ }
5560
+ }
5561
+ if (attrs !== rawCurrentProps) {
5562
+ for (const key in attrs) {
5563
+ if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
5564
+ delete attrs[key];
5565
+ hasAttrsChanged = true;
5566
+ }
5567
+ }
5563
5568
  }
5564
5569
  }
5565
- applySingletonPrototype(app, singletonCtor);
5566
- }
5567
- function applySingletonPrototype(app, Ctor) {
5568
- const enabled = isCompatEnabled$1("GLOBAL_PROTOTYPE", null);
5569
- if (enabled) {
5570
- app.config.globalProperties = Object.create(Ctor.prototype);
5570
+ if (hasAttrsChanged) {
5571
+ trigger(instance, "set", "$attrs");
5571
5572
  }
5572
- const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
5573
- for (const key in descriptors) {
5574
- if (key !== "constructor") {
5575
- if (enabled) {
5576
- Object.defineProperty(
5577
- app.config.globalProperties,
5578
- key,
5579
- descriptors[key]
5580
- );
5573
+ }
5574
+ function setFullProps(instance, rawProps, props, attrs) {
5575
+ const [options, needCastKeys] = instance.propsOptions;
5576
+ let hasAttrsChanged = false;
5577
+ let rawCastValues;
5578
+ if (rawProps) {
5579
+ for (let key in rawProps) {
5580
+ if (isReservedProp(key)) {
5581
+ continue;
5582
+ }
5583
+ {
5584
+ if (key.startsWith("onHook:")) {
5585
+ softAssertCompatEnabled(
5586
+ "INSTANCE_EVENT_HOOKS",
5587
+ instance,
5588
+ key.slice(2).toLowerCase()
5589
+ );
5590
+ }
5591
+ if (key === "inline-template") {
5592
+ continue;
5593
+ }
5594
+ }
5595
+ const value = rawProps[key];
5596
+ let camelKey;
5597
+ if (options && hasOwn(options, camelKey = camelize(key))) {
5598
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
5599
+ props[camelKey] = value;
5600
+ } else {
5601
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
5602
+ }
5603
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
5604
+ {
5605
+ if (isOn(key) && key.endsWith("Native")) {
5606
+ key = key.slice(0, -6);
5607
+ } else if (shouldSkipAttr(key, instance)) {
5608
+ continue;
5609
+ }
5610
+ }
5611
+ if (!(key in attrs) || value !== attrs[key]) {
5612
+ attrs[key] = value;
5613
+ hasAttrsChanged = true;
5614
+ }
5581
5615
  }
5582
5616
  }
5583
5617
  }
5584
- }
5585
- function installCompatMount(app, context, render) {
5586
- let isMounted = false;
5587
- app._createRoot = (options) => {
5588
- const component = app._component;
5589
- const vnode = createVNode(component, options.propsData || null);
5590
- vnode.appContext = context;
5591
- const hasNoRender = !isFunction(component) && !component.render && !component.template;
5592
- const emptyRender = () => {
5593
- };
5594
- const instance = createComponentInstance(vnode, null, null);
5595
- if (hasNoRender) {
5596
- instance.render = emptyRender;
5618
+ if (needCastKeys) {
5619
+ const rawCurrentProps = toRaw(props);
5620
+ const castValues = rawCastValues || EMPTY_OBJ;
5621
+ for (let i = 0; i < needCastKeys.length; i++) {
5622
+ const key = needCastKeys[i];
5623
+ props[key] = resolvePropValue(
5624
+ options,
5625
+ rawCurrentProps,
5626
+ key,
5627
+ castValues[key],
5628
+ instance,
5629
+ !hasOwn(castValues, key)
5630
+ );
5597
5631
  }
5598
- setupComponent(instance);
5599
- vnode.component = instance;
5600
- vnode.isCompatRoot = true;
5601
- instance.ctx._compat_mount = (selectorOrEl) => {
5602
- if (isMounted) {
5603
- return;
5604
- }
5605
- let container;
5606
- if (typeof selectorOrEl === "string") {
5607
- const result = document.querySelector(selectorOrEl);
5608
- if (!result) {
5609
- return;
5632
+ }
5633
+ return hasAttrsChanged;
5634
+ }
5635
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
5636
+ const opt = options[key];
5637
+ if (opt != null) {
5638
+ const hasDefault = hasOwn(opt, "default");
5639
+ if (hasDefault && value === void 0) {
5640
+ const defaultValue = opt.default;
5641
+ if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
5642
+ const { propsDefaults } = instance;
5643
+ if (key in propsDefaults) {
5644
+ value = propsDefaults[key];
5645
+ } else {
5646
+ setCurrentInstance(instance);
5647
+ value = propsDefaults[key] = defaultValue.call(
5648
+ isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props) : null,
5649
+ props
5650
+ );
5651
+ unsetCurrentInstance();
5610
5652
  }
5611
- container = result;
5612
5653
  } else {
5613
- container = selectorOrEl || document.createElement("div");
5654
+ value = defaultValue;
5614
5655
  }
5615
- const isSVG = container instanceof SVGElement;
5616
- if (hasNoRender && instance.render === emptyRender) {
5617
- instance.render = null;
5618
- component.template = container.innerHTML;
5619
- finishComponentSetup(
5620
- instance,
5621
- false,
5622
- true
5623
- /* skip options */
5624
- );
5656
+ }
5657
+ if (opt[0 /* shouldCast */]) {
5658
+ if (isAbsent && !hasDefault) {
5659
+ value = false;
5660
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
5661
+ value = true;
5625
5662
  }
5626
- container.innerHTML = "";
5627
- render(vnode, container, isSVG);
5628
- if (container instanceof Element) {
5629
- container.removeAttribute("v-cloak");
5630
- container.setAttribute("data-v-app", "");
5663
+ }
5664
+ }
5665
+ return value;
5666
+ }
5667
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
5668
+ const cache = appContext.propsCache;
5669
+ const cached = cache.get(comp);
5670
+ if (cached) {
5671
+ return cached;
5672
+ }
5673
+ const raw = comp.props;
5674
+ const normalized = {};
5675
+ const needCastKeys = [];
5676
+ let hasExtends = false;
5677
+ if (!isFunction(comp)) {
5678
+ const extendProps = (raw2) => {
5679
+ if (isFunction(raw2)) {
5680
+ raw2 = raw2.options;
5631
5681
  }
5632
- isMounted = true;
5633
- app._container = container;
5634
- container.__vue_app__ = app;
5635
- return instance.proxy;
5682
+ hasExtends = true;
5683
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
5684
+ extend(normalized, props);
5685
+ if (keys)
5686
+ needCastKeys.push(...keys);
5636
5687
  };
5637
- instance.ctx._compat_destroy = () => {
5638
- if (isMounted) {
5639
- render(null, app._container);
5640
- delete app._container.__vue_app__;
5641
- } else {
5642
- const { bum, scope, um } = instance;
5643
- if (bum) {
5644
- invokeArrayFns(bum);
5645
- }
5646
- if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
5647
- instance.emit("hook:beforeDestroy");
5648
- }
5649
- if (scope) {
5650
- scope.stop();
5651
- }
5652
- if (um) {
5653
- invokeArrayFns(um);
5654
- }
5655
- if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
5656
- instance.emit("hook:destroyed");
5657
- }
5688
+ if (!asMixin && appContext.mixins.length) {
5689
+ appContext.mixins.forEach(extendProps);
5690
+ }
5691
+ if (comp.extends) {
5692
+ extendProps(comp.extends);
5693
+ }
5694
+ if (comp.mixins) {
5695
+ comp.mixins.forEach(extendProps);
5696
+ }
5697
+ }
5698
+ if (!raw && !hasExtends) {
5699
+ if (isObject(comp)) {
5700
+ cache.set(comp, EMPTY_ARR);
5701
+ }
5702
+ return EMPTY_ARR;
5703
+ }
5704
+ if (isArray(raw)) {
5705
+ for (let i = 0; i < raw.length; i++) {
5706
+ const normalizedKey = camelize(raw[i]);
5707
+ if (validatePropName(normalizedKey)) {
5708
+ normalized[normalizedKey] = EMPTY_OBJ;
5658
5709
  }
5659
- };
5660
- return instance.proxy;
5661
- };
5662
- }
5663
- const methodsToPatch = [
5664
- "push",
5665
- "pop",
5666
- "shift",
5667
- "unshift",
5668
- "splice",
5669
- "sort",
5670
- "reverse"
5671
- ];
5672
- const patched = /* @__PURE__ */ new WeakSet();
5673
- function defineReactive(obj, key, val) {
5674
- if (isObject(val) && !isReactive(val) && !patched.has(val)) {
5675
- const reactiveVal = reactive(val);
5676
- if (isArray(val)) {
5677
- methodsToPatch.forEach((m) => {
5678
- val[m] = (...args) => {
5679
- Array.prototype[m].call(reactiveVal, ...args);
5680
- };
5681
- });
5682
- } else {
5683
- Object.keys(val).forEach((key2) => {
5684
- try {
5685
- defineReactiveSimple(val, key2, val[key2]);
5686
- } catch (e) {
5710
+ }
5711
+ } else if (raw) {
5712
+ for (const key in raw) {
5713
+ const normalizedKey = camelize(key);
5714
+ if (validatePropName(normalizedKey)) {
5715
+ const opt = raw[key];
5716
+ const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
5717
+ if (prop) {
5718
+ const booleanIndex = getTypeIndex(Boolean, prop.type);
5719
+ const stringIndex = getTypeIndex(String, prop.type);
5720
+ prop[0 /* shouldCast */] = booleanIndex > -1;
5721
+ prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
5722
+ if (booleanIndex > -1 || hasOwn(prop, "default")) {
5723
+ needCastKeys.push(normalizedKey);
5724
+ }
5687
5725
  }
5688
- });
5726
+ }
5689
5727
  }
5690
5728
  }
5691
- const i = obj.$;
5692
- if (i && obj === i.proxy) {
5693
- defineReactiveSimple(i.ctx, key, val);
5694
- i.accessCache = /* @__PURE__ */ Object.create(null);
5695
- } else if (isReactive(obj)) {
5696
- obj[key] = val;
5697
- } else {
5698
- defineReactiveSimple(obj, key, val);
5729
+ const res = [normalized, needCastKeys];
5730
+ if (isObject(comp)) {
5731
+ cache.set(comp, res);
5699
5732
  }
5733
+ return res;
5700
5734
  }
5701
- function defineReactiveSimple(obj, key, val) {
5702
- val = isObject(val) ? reactive(val) : val;
5703
- Object.defineProperty(obj, key, {
5704
- enumerable: true,
5705
- configurable: true,
5706
- get() {
5707
- track(obj, "get", key);
5708
- return val;
5709
- },
5710
- set(newVal) {
5711
- val = isObject(newVal) ? reactive(newVal) : newVal;
5712
- trigger(obj, "set", key, newVal);
5713
- }
5714
- });
5735
+ function validatePropName(key) {
5736
+ if (key[0] !== "$") {
5737
+ return true;
5738
+ }
5739
+ return false;
5715
5740
  }
5716
-
5717
- function createAppContext() {
5718
- return {
5719
- app: null,
5720
- config: {
5721
- isNativeTag: NO,
5722
- performance: false,
5723
- globalProperties: {},
5724
- optionMergeStrategies: {},
5725
- errorHandler: void 0,
5726
- warnHandler: void 0,
5727
- compilerOptions: {}
5728
- },
5729
- mixins: [],
5730
- components: {},
5731
- directives: {},
5732
- provides: /* @__PURE__ */ Object.create(null),
5733
- optionsCache: /* @__PURE__ */ new WeakMap(),
5734
- propsCache: /* @__PURE__ */ new WeakMap(),
5735
- emitsCache: /* @__PURE__ */ new WeakMap()
5736
- };
5741
+ function getType(ctor) {
5742
+ const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
5743
+ return match ? match[2] : ctor === null ? "null" : "";
5737
5744
  }
5738
- let uid$1 = 0;
5739
- function createAppAPI(render, hydrate) {
5740
- return function createApp(rootComponent, rootProps = null) {
5741
- if (!isFunction(rootComponent)) {
5742
- rootComponent = extend({}, rootComponent);
5745
+ function isSameType(a, b) {
5746
+ return getType(a) === getType(b);
5747
+ }
5748
+ function getTypeIndex(type, expectedTypes) {
5749
+ if (isArray(expectedTypes)) {
5750
+ return expectedTypes.findIndex((t) => isSameType(t, type));
5751
+ } else if (isFunction(expectedTypes)) {
5752
+ return isSameType(expectedTypes, type) ? 0 : -1;
5753
+ }
5754
+ return -1;
5755
+ }
5756
+
5757
+ const isInternalKey = (key) => key[0] === "_" || key === "$stable";
5758
+ const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
5759
+ const normalizeSlot = (key, rawSlot, ctx) => {
5760
+ if (rawSlot._n) {
5761
+ return rawSlot;
5762
+ }
5763
+ const normalized = withCtx((...args) => {
5764
+ if (false) ;
5765
+ return normalizeSlotValue(rawSlot(...args));
5766
+ }, ctx);
5767
+ normalized._c = false;
5768
+ return normalized;
5769
+ };
5770
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
5771
+ const ctx = rawSlots._ctx;
5772
+ for (const key in rawSlots) {
5773
+ if (isInternalKey(key))
5774
+ continue;
5775
+ const value = rawSlots[key];
5776
+ if (isFunction(value)) {
5777
+ slots[key] = normalizeSlot(key, value, ctx);
5778
+ } else if (value != null) {
5779
+ const normalized = normalizeSlotValue(value);
5780
+ slots[key] = () => normalized;
5743
5781
  }
5744
- if (rootProps != null && !isObject(rootProps)) {
5745
- rootProps = null;
5782
+ }
5783
+ };
5784
+ const normalizeVNodeSlots = (instance, children) => {
5785
+ const normalized = normalizeSlotValue(children);
5786
+ instance.slots.default = () => normalized;
5787
+ };
5788
+ const initSlots = (instance, children) => {
5789
+ if (instance.vnode.shapeFlag & 32) {
5790
+ const type = children._;
5791
+ if (type) {
5792
+ instance.slots = toRaw(children);
5793
+ def(children, "_", type);
5794
+ } else {
5795
+ normalizeObjectSlots(
5796
+ children,
5797
+ instance.slots = {});
5746
5798
  }
5747
- const context = createAppContext();
5748
- const installedPlugins = /* @__PURE__ */ new Set();
5749
- let isMounted = false;
5750
- const app = context.app = {
5751
- _uid: uid$1++,
5752
- _component: rootComponent,
5753
- _props: rootProps,
5754
- _container: null,
5755
- _context: context,
5756
- _instance: null,
5757
- version,
5758
- get config() {
5759
- return context.config;
5760
- },
5761
- set config(v) {
5762
- },
5763
- use(plugin, ...options) {
5764
- if (installedPlugins.has(plugin)) ; else if (plugin && isFunction(plugin.install)) {
5765
- installedPlugins.add(plugin);
5766
- plugin.install(app, ...options);
5767
- } else if (isFunction(plugin)) {
5768
- installedPlugins.add(plugin);
5769
- plugin(app, ...options);
5770
- } else ;
5771
- return app;
5772
- },
5773
- mixin(mixin) {
5774
- {
5775
- if (!context.mixins.includes(mixin)) {
5776
- context.mixins.push(mixin);
5777
- }
5778
- }
5779
- return app;
5780
- },
5781
- component(name, component) {
5782
- if (!component) {
5783
- return context.components[name];
5784
- }
5785
- context.components[name] = component;
5786
- return app;
5787
- },
5788
- directive(name, directive) {
5789
- if (!directive) {
5790
- return context.directives[name];
5791
- }
5792
- context.directives[name] = directive;
5793
- return app;
5794
- },
5795
- mount(rootContainer, isHydrate, isSVG) {
5796
- if (!isMounted) {
5797
- const vnode = createVNode(
5798
- rootComponent,
5799
- rootProps
5800
- );
5801
- vnode.appContext = context;
5802
- if (isHydrate && hydrate) {
5803
- hydrate(vnode, rootContainer);
5804
- } else {
5805
- render(vnode, rootContainer, isSVG);
5806
- }
5807
- isMounted = true;
5808
- app._container = rootContainer;
5809
- rootContainer.__vue_app__ = app;
5810
- return getExposeProxy(vnode.component) || vnode.component.proxy;
5811
- }
5812
- },
5813
- unmount() {
5814
- if (isMounted) {
5815
- render(null, app._container);
5816
- delete app._container.__vue_app__;
5799
+ } else {
5800
+ instance.slots = {};
5801
+ if (children) {
5802
+ normalizeVNodeSlots(instance, children);
5803
+ }
5804
+ }
5805
+ def(instance.slots, InternalObjectKey, 1);
5806
+ };
5807
+ const updateSlots = (instance, children, optimized) => {
5808
+ const { vnode, slots } = instance;
5809
+ let needDeletionCheck = true;
5810
+ let deletionComparisonTarget = EMPTY_OBJ;
5811
+ if (vnode.shapeFlag & 32) {
5812
+ const type = children._;
5813
+ if (type) {
5814
+ if (optimized && type === 1) {
5815
+ needDeletionCheck = false;
5816
+ } else {
5817
+ extend(slots, children);
5818
+ if (!optimized && type === 1) {
5819
+ delete slots._;
5817
5820
  }
5818
- },
5819
- provide(key, value) {
5820
- context.provides[key] = value;
5821
- return app;
5822
5821
  }
5823
- };
5824
- {
5825
- installAppCompatProperties(app, context, render);
5822
+ } else {
5823
+ needDeletionCheck = !children.$stable;
5824
+ normalizeObjectSlots(children, slots);
5826
5825
  }
5827
- return app;
5828
- };
5829
- }
5826
+ deletionComparisonTarget = children;
5827
+ } else if (children) {
5828
+ normalizeVNodeSlots(instance, children);
5829
+ deletionComparisonTarget = { default: 1 };
5830
+ }
5831
+ if (needDeletionCheck) {
5832
+ for (const key in slots) {
5833
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5834
+ delete slots[key];
5835
+ }
5836
+ }
5837
+ }
5838
+ };
5830
5839
 
5831
5840
  function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5832
5841
  if (isArray(rawRef)) {
@@ -8552,6 +8561,9 @@ function defineExpose(exposed) {
8552
8561
  function defineOptions(options) {
8553
8562
  }
8554
8563
  function defineSlots() {
8564
+ return null;
8565
+ }
8566
+ function defineModel() {
8555
8567
  }
8556
8568
  function withDefaults(props, defaults) {
8557
8569
  return null;
@@ -8562,15 +8574,44 @@ function useSlots() {
8562
8574
  function useAttrs() {
8563
8575
  return getContext().attrs;
8564
8576
  }
8577
+ function useModel(props, name, options) {
8578
+ const i = getCurrentInstance();
8579
+ if (options && options.local) {
8580
+ const proxy = ref(props[name]);
8581
+ watch(
8582
+ () => props[name],
8583
+ (v) => proxy.value = v
8584
+ );
8585
+ watch(proxy, (value) => {
8586
+ if (value !== props[name]) {
8587
+ i.emit(`update:${name}`, value);
8588
+ }
8589
+ });
8590
+ return proxy;
8591
+ } else {
8592
+ return {
8593
+ __v_isRef: true,
8594
+ get value() {
8595
+ return props[name];
8596
+ },
8597
+ set value(value) {
8598
+ i.emit(`update:${name}`, value);
8599
+ }
8600
+ };
8601
+ }
8602
+ }
8565
8603
  function getContext() {
8566
8604
  const i = getCurrentInstance();
8567
8605
  return i.setupContext || (i.setupContext = createSetupContext(i));
8568
8606
  }
8569
- function mergeDefaults(raw, defaults) {
8570
- const props = isArray(raw) ? raw.reduce(
8607
+ function normalizePropsOrEmits(props) {
8608
+ return isArray(props) ? props.reduce(
8571
8609
  (normalized, p) => (normalized[p] = {}, normalized),
8572
8610
  {}
8573
- ) : raw;
8611
+ ) : props;
8612
+ }
8613
+ function mergeDefaults(raw, defaults) {
8614
+ const props = normalizePropsOrEmits(raw);
8574
8615
  for (const key in defaults) {
8575
8616
  if (key.startsWith("__skip"))
8576
8617
  continue;
@@ -8590,6 +8631,13 @@ function mergeDefaults(raw, defaults) {
8590
8631
  }
8591
8632
  return props;
8592
8633
  }
8634
+ function mergeModels(a, b) {
8635
+ if (!a || !b)
8636
+ return a || b;
8637
+ if (isArray(a) && isArray(b))
8638
+ return a.concat(b);
8639
+ return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
8640
+ }
8593
8641
  function createPropsRestProxy(props, excludedKeys) {
8594
8642
  const ret = {};
8595
8643
  for (const key in props) {
@@ -8675,7 +8723,7 @@ function isMemoSame(cached, memo) {
8675
8723
  return true;
8676
8724
  }
8677
8725
 
8678
- const version = "3.3.0-alpha.7";
8726
+ const version = "3.3.0-alpha.9";
8679
8727
  const _ssrUtils = {
8680
8728
  createComponentInstance,
8681
8729
  setupComponent,
@@ -10212,6 +10260,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10212
10260
  defineCustomElement: defineCustomElement,
10213
10261
  defineEmits: defineEmits,
10214
10262
  defineExpose: defineExpose,
10263
+ defineModel: defineModel,
10215
10264
  defineOptions: defineOptions,
10216
10265
  defineProps: defineProps,
10217
10266
  defineSSRCustomElement: defineSSRCustomElement,
@@ -10239,6 +10288,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10239
10288
  isVNode: isVNode,
10240
10289
  markRaw: markRaw,
10241
10290
  mergeDefaults: mergeDefaults,
10291
+ mergeModels: mergeModels,
10242
10292
  mergeProps: mergeProps,
10243
10293
  nextTick: nextTick,
10244
10294
  normalizeClass: normalizeClass,
@@ -10297,6 +10347,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10297
10347
  useAttrs: useAttrs,
10298
10348
  useCssModule: useCssModule,
10299
10349
  useCssVars: useCssVars,
10350
+ useModel: useModel,
10300
10351
  useSSRContext: useSSRContext,
10301
10352
  useSlots: useSlots,
10302
10353
  useTransitionState: useTransitionState,
@@ -15044,7 +15095,7 @@ const transformText = (node, context) => {
15044
15095
  const seen$1 = /* @__PURE__ */ new WeakSet();
15045
15096
  const transformOnce = (node, context) => {
15046
15097
  if (node.type === 1 && findDir(node, "once", true)) {
15047
- if (seen$1.has(node) || context.inVOnce) {
15098
+ if (seen$1.has(node) || context.inVOnce || context.inSSR) {
15048
15099
  return;
15049
15100
  }
15050
15101
  seen$1.add(node);