@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.
@@ -3488,33 +3488,41 @@ function setActiveBranch(suspense, branch) {
3488
3488
  }
3489
3489
  }
3490
3490
 
3491
- function provide(key, value) {
3492
- if (!currentInstance) {
3493
- if (process.env.NODE_ENV !== "production") {
3494
- warn(`provide() can only be used inside setup().`);
3495
- }
3496
- } else {
3497
- let provides = currentInstance.provides;
3498
- const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3499
- if (parentProvides === provides) {
3500
- provides = currentInstance.provides = Object.create(parentProvides);
3501
- }
3502
- provides[key] = value;
3503
- }
3504
- }
3505
- function inject(key, defaultValue, treatDefaultAsFactory = false) {
3506
- const instance = currentInstance || currentRenderingInstance;
3507
- if (instance) {
3508
- const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
3509
- if (provides && key in provides) {
3510
- return provides[key];
3511
- } else if (arguments.length > 1) {
3512
- return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
3513
- } else if (process.env.NODE_ENV !== "production") {
3514
- warn(`injection "${String(key)}" not found.`);
3491
+ const legacyDirectiveHookMap = {
3492
+ beforeMount: "bind",
3493
+ mounted: "inserted",
3494
+ updated: ["update", "componentUpdated"],
3495
+ unmounted: "unbind"
3496
+ };
3497
+ function mapCompatDirectiveHook(name, dir, instance) {
3498
+ const mappedName = legacyDirectiveHookMap[name];
3499
+ if (mappedName) {
3500
+ if (isArray(mappedName)) {
3501
+ const hook = [];
3502
+ mappedName.forEach((mapped) => {
3503
+ const mappedHook = dir[mapped];
3504
+ if (mappedHook) {
3505
+ softAssertCompatEnabled(
3506
+ "CUSTOM_DIR",
3507
+ instance,
3508
+ mapped,
3509
+ name
3510
+ );
3511
+ hook.push(mappedHook);
3512
+ }
3513
+ });
3514
+ return hook.length ? hook : void 0;
3515
+ } else {
3516
+ if (dir[mappedName]) {
3517
+ softAssertCompatEnabled(
3518
+ "CUSTOM_DIR",
3519
+ instance,
3520
+ mappedName,
3521
+ name
3522
+ );
3523
+ }
3524
+ return dir[mappedName];
3515
3525
  }
3516
- } else if (process.env.NODE_ENV !== "production") {
3517
- warn(`inject() can only be used inside setup() or functional components.`);
3518
3526
  }
3519
3527
  }
3520
3528
 
@@ -3774,6 +3782,68 @@ function traverse(value, seen) {
3774
3782
  return value;
3775
3783
  }
3776
3784
 
3785
+ function validateDirectiveName(name) {
3786
+ if (isBuiltInDirective(name)) {
3787
+ warn("Do not use built-in directive ids as custom directive id: " + name);
3788
+ }
3789
+ }
3790
+ function withDirectives(vnode, directives) {
3791
+ const internalInstance = currentRenderingInstance;
3792
+ if (internalInstance === null) {
3793
+ process.env.NODE_ENV !== "production" && warn(`withDirectives can only be used inside render functions.`);
3794
+ return vnode;
3795
+ }
3796
+ const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
3797
+ const bindings = vnode.dirs || (vnode.dirs = []);
3798
+ for (let i = 0; i < directives.length; i++) {
3799
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
3800
+ if (dir) {
3801
+ if (isFunction(dir)) {
3802
+ dir = {
3803
+ mounted: dir,
3804
+ updated: dir
3805
+ };
3806
+ }
3807
+ if (dir.deep) {
3808
+ traverse(value);
3809
+ }
3810
+ bindings.push({
3811
+ dir,
3812
+ instance,
3813
+ value,
3814
+ oldValue: void 0,
3815
+ arg,
3816
+ modifiers
3817
+ });
3818
+ }
3819
+ }
3820
+ return vnode;
3821
+ }
3822
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
3823
+ const bindings = vnode.dirs;
3824
+ const oldBindings = prevVNode && prevVNode.dirs;
3825
+ for (let i = 0; i < bindings.length; i++) {
3826
+ const binding = bindings[i];
3827
+ if (oldBindings) {
3828
+ binding.oldValue = oldBindings[i].value;
3829
+ }
3830
+ let hook = binding.dir[name];
3831
+ if (!hook) {
3832
+ hook = mapCompatDirectiveHook(name, binding.dir, instance);
3833
+ }
3834
+ if (hook) {
3835
+ pauseTracking();
3836
+ callWithAsyncErrorHandling(hook, instance, 8, [
3837
+ vnode.el,
3838
+ binding,
3839
+ vnode,
3840
+ prevVNode
3841
+ ]);
3842
+ resetTracking();
3843
+ }
3844
+ }
3845
+ }
3846
+
3777
3847
  function useTransitionState() {
3778
3848
  const state = {
3779
3849
  isMounted: false,
@@ -4580,106 +4650,6 @@ function getCompatListeners(instance) {
4580
4650
  return listeners;
4581
4651
  }
4582
4652
 
4583
- const legacyDirectiveHookMap = {
4584
- beforeMount: "bind",
4585
- mounted: "inserted",
4586
- updated: ["update", "componentUpdated"],
4587
- unmounted: "unbind"
4588
- };
4589
- function mapCompatDirectiveHook(name, dir, instance) {
4590
- const mappedName = legacyDirectiveHookMap[name];
4591
- if (mappedName) {
4592
- if (isArray(mappedName)) {
4593
- const hook = [];
4594
- mappedName.forEach((mapped) => {
4595
- const mappedHook = dir[mapped];
4596
- if (mappedHook) {
4597
- softAssertCompatEnabled(
4598
- "CUSTOM_DIR",
4599
- instance,
4600
- mapped,
4601
- name
4602
- );
4603
- hook.push(mappedHook);
4604
- }
4605
- });
4606
- return hook.length ? hook : void 0;
4607
- } else {
4608
- if (dir[mappedName]) {
4609
- softAssertCompatEnabled(
4610
- "CUSTOM_DIR",
4611
- instance,
4612
- mappedName,
4613
- name
4614
- );
4615
- }
4616
- return dir[mappedName];
4617
- }
4618
- }
4619
- }
4620
-
4621
- function validateDirectiveName(name) {
4622
- if (isBuiltInDirective(name)) {
4623
- warn("Do not use built-in directive ids as custom directive id: " + name);
4624
- }
4625
- }
4626
- function withDirectives(vnode, directives) {
4627
- const internalInstance = currentRenderingInstance;
4628
- if (internalInstance === null) {
4629
- process.env.NODE_ENV !== "production" && warn(`withDirectives can only be used inside render functions.`);
4630
- return vnode;
4631
- }
4632
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
4633
- const bindings = vnode.dirs || (vnode.dirs = []);
4634
- for (let i = 0; i < directives.length; i++) {
4635
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4636
- if (dir) {
4637
- if (isFunction(dir)) {
4638
- dir = {
4639
- mounted: dir,
4640
- updated: dir
4641
- };
4642
- }
4643
- if (dir.deep) {
4644
- traverse(value);
4645
- }
4646
- bindings.push({
4647
- dir,
4648
- instance,
4649
- value,
4650
- oldValue: void 0,
4651
- arg,
4652
- modifiers
4653
- });
4654
- }
4655
- }
4656
- return vnode;
4657
- }
4658
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4659
- const bindings = vnode.dirs;
4660
- const oldBindings = prevVNode && prevVNode.dirs;
4661
- for (let i = 0; i < bindings.length; i++) {
4662
- const binding = bindings[i];
4663
- if (oldBindings) {
4664
- binding.oldValue = oldBindings[i].value;
4665
- }
4666
- let hook = binding.dir[name];
4667
- if (!hook) {
4668
- hook = mapCompatDirectiveHook(name, binding.dir, instance);
4669
- }
4670
- if (hook) {
4671
- pauseTracking();
4672
- callWithAsyncErrorHandling(hook, instance, 8, [
4673
- vnode.el,
4674
- binding,
4675
- vnode,
4676
- prevVNode
4677
- ]);
4678
- resetTracking();
4679
- }
4680
- }
4681
- }
4682
-
4683
4653
  const COMPONENTS = "components";
4684
4654
  const DIRECTIVES = "directives";
4685
4655
  const FILTERS = "filters";
@@ -6022,1182 +5992,1221 @@ function mergeWatchOptions(to, from) {
6022
5992
  return merged;
6023
5993
  }
6024
5994
 
6025
- function createPropsDefaultThis(instance, rawProps, propKey) {
6026
- return new Proxy(
6027
- {},
6028
- {
6029
- get(_, key) {
6030
- process.env.NODE_ENV !== "production" && warnDeprecation("PROPS_DEFAULT_THIS", null, propKey);
6031
- if (key === "$options") {
6032
- return resolveMergedOptions(instance);
6033
- }
6034
- if (key in rawProps) {
6035
- return rawProps[key];
6036
- }
6037
- const injections = instance.type.inject;
6038
- if (injections) {
6039
- if (isArray(injections)) {
6040
- if (injections.includes(key)) {
6041
- return inject(key);
6042
- }
6043
- } else if (key in injections) {
6044
- return inject(key);
6045
- }
5995
+ function installLegacyConfigWarnings(config) {
5996
+ const legacyConfigOptions = {
5997
+ silent: "CONFIG_SILENT",
5998
+ devtools: "CONFIG_DEVTOOLS",
5999
+ ignoredElements: "CONFIG_IGNORED_ELEMENTS",
6000
+ keyCodes: "CONFIG_KEY_CODES",
6001
+ productionTip: "CONFIG_PRODUCTION_TIP"
6002
+ };
6003
+ Object.keys(legacyConfigOptions).forEach((key) => {
6004
+ let val = config[key];
6005
+ Object.defineProperty(config, key, {
6006
+ enumerable: true,
6007
+ get() {
6008
+ return val;
6009
+ },
6010
+ set(newVal) {
6011
+ if (!isCopyingConfig) {
6012
+ warnDeprecation(legacyConfigOptions[key], null);
6046
6013
  }
6014
+ val = newVal;
6047
6015
  }
6048
- }
6049
- );
6016
+ });
6017
+ });
6050
6018
  }
6051
-
6052
- function shouldSkipAttr(key, instance) {
6053
- if (key === "is") {
6054
- return true;
6055
- }
6056
- if ((key === "class" || key === "style") && isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
6057
- return true;
6058
- }
6059
- if (isOn(key) && isCompatEnabled("INSTANCE_LISTENERS", instance)) {
6060
- return true;
6061
- }
6062
- if (key.startsWith("routerView") || key === "registerRouteInstance") {
6063
- return true;
6064
- }
6065
- return false;
6019
+ function installLegacyOptionMergeStrats(config) {
6020
+ config.optionMergeStrategies = new Proxy({}, {
6021
+ get(target, key) {
6022
+ if (key in target) {
6023
+ return target[key];
6024
+ }
6025
+ if (key in internalOptionMergeStrats && softAssertCompatEnabled(
6026
+ "CONFIG_OPTION_MERGE_STRATS",
6027
+ null
6028
+ )) {
6029
+ return internalOptionMergeStrats[key];
6030
+ }
6031
+ }
6032
+ });
6066
6033
  }
6067
6034
 
6068
- function initProps(instance, rawProps, isStateful, isSSR = false) {
6069
- const props = {};
6070
- const attrs = {};
6071
- def(attrs, InternalObjectKey, 1);
6072
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
6073
- setFullProps(instance, rawProps, props, attrs);
6074
- for (const key in instance.propsOptions[0]) {
6075
- if (!(key in props)) {
6076
- props[key] = void 0;
6035
+ let isCopyingConfig = false;
6036
+ let singletonApp;
6037
+ let singletonCtor;
6038
+ function createCompatVue$1(createApp, createSingletonApp) {
6039
+ singletonApp = createSingletonApp({});
6040
+ const Vue = singletonCtor = function Vue2(options = {}) {
6041
+ return createCompatApp(options, Vue2);
6042
+ };
6043
+ function createCompatApp(options = {}, Ctor) {
6044
+ assertCompatEnabled("GLOBAL_MOUNT", null);
6045
+ const { data } = options;
6046
+ if (data && !isFunction(data) && softAssertCompatEnabled("OPTIONS_DATA_FN", null)) {
6047
+ options.data = () => data;
6077
6048
  }
6078
- }
6079
- if (process.env.NODE_ENV !== "production") {
6080
- validateProps(rawProps || {}, props, instance);
6081
- }
6082
- if (isStateful) {
6083
- instance.props = isSSR ? props : shallowReactive(props);
6084
- } else {
6085
- if (!instance.type.props) {
6086
- instance.props = attrs;
6049
+ const app = createApp(options);
6050
+ if (Ctor !== Vue) {
6051
+ applySingletonPrototype(app, Ctor);
6052
+ }
6053
+ const vm = app._createRoot(options);
6054
+ if (options.el) {
6055
+ return vm.$mount(options.el);
6087
6056
  } else {
6088
- instance.props = props;
6057
+ return vm;
6089
6058
  }
6090
6059
  }
6091
- instance.attrs = attrs;
6092
- }
6093
- function isInHmrContext(instance) {
6094
- while (instance) {
6095
- if (instance.type.__hmrId)
6096
- return true;
6097
- instance = instance.parent;
6098
- }
6099
- }
6100
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
6101
- const {
6102
- props,
6103
- attrs,
6104
- vnode: { patchFlag }
6105
- } = instance;
6106
- const rawCurrentProps = toRaw(props);
6107
- const [options] = instance.propsOptions;
6108
- let hasAttrsChanged = false;
6109
- if (
6110
- // always force full diff in dev
6111
- // - #1942 if hmr is enabled with sfc component
6112
- // - vite#872 non-sfc component used by sfc component
6113
- !(process.env.NODE_ENV !== "production" && isInHmrContext(instance)) && (optimized || patchFlag > 0) && !(patchFlag & 16)
6114
- ) {
6115
- if (patchFlag & 8) {
6116
- const propsToUpdate = instance.vnode.dynamicProps;
6117
- for (let i = 0; i < propsToUpdate.length; i++) {
6118
- let key = propsToUpdate[i];
6119
- if (isEmitListener(instance.emitsOptions, key)) {
6120
- continue;
6121
- }
6122
- const value = rawProps[key];
6123
- if (options) {
6124
- if (hasOwn(attrs, key)) {
6125
- if (value !== attrs[key]) {
6126
- attrs[key] = value;
6127
- hasAttrsChanged = true;
6128
- }
6129
- } else {
6130
- const camelizedKey = camelize(key);
6131
- props[camelizedKey] = resolvePropValue(
6132
- options,
6133
- rawCurrentProps,
6134
- camelizedKey,
6135
- value,
6136
- instance,
6137
- false
6138
- /* isAbsent */
6139
- );
6140
- }
6141
- } else {
6142
- {
6143
- if (isOn(key) && key.endsWith("Native")) {
6144
- key = key.slice(0, -6);
6145
- } else if (shouldSkipAttr(key, instance)) {
6146
- continue;
6147
- }
6148
- }
6149
- if (value !== attrs[key]) {
6150
- attrs[key] = value;
6151
- hasAttrsChanged = true;
6152
- }
6153
- }
6154
- }
6060
+ Vue.version = `2.6.14-compat:${"3.3.0-alpha.9"}`;
6061
+ Vue.config = singletonApp.config;
6062
+ Vue.use = (p, ...options) => {
6063
+ if (p && isFunction(p.install)) {
6064
+ p.install(Vue, ...options);
6065
+ } else if (isFunction(p)) {
6066
+ p(Vue, ...options);
6155
6067
  }
6156
- } else {
6157
- if (setFullProps(instance, rawProps, props, attrs)) {
6158
- hasAttrsChanged = true;
6068
+ return Vue;
6069
+ };
6070
+ Vue.mixin = (m) => {
6071
+ singletonApp.mixin(m);
6072
+ return Vue;
6073
+ };
6074
+ Vue.component = (name, comp) => {
6075
+ if (comp) {
6076
+ singletonApp.component(name, comp);
6077
+ return Vue;
6078
+ } else {
6079
+ return singletonApp.component(name);
6159
6080
  }
6160
- let kebabKey;
6161
- for (const key in rawCurrentProps) {
6162
- if (!rawProps || // for camelCase
6163
- !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
6164
- // and converted to camelCase (#955)
6165
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
6166
- if (options) {
6167
- if (rawPrevProps && // for camelCase
6168
- (rawPrevProps[key] !== void 0 || // for kebab-case
6169
- rawPrevProps[kebabKey] !== void 0)) {
6170
- props[key] = resolvePropValue(
6171
- options,
6172
- rawCurrentProps,
6173
- key,
6174
- void 0,
6175
- instance,
6176
- true
6177
- /* isAbsent */
6178
- );
6179
- }
6180
- } else {
6181
- delete props[key];
6182
- }
6183
- }
6081
+ };
6082
+ Vue.directive = (name, dir) => {
6083
+ if (dir) {
6084
+ singletonApp.directive(name, dir);
6085
+ return Vue;
6086
+ } else {
6087
+ return singletonApp.directive(name);
6184
6088
  }
6185
- if (attrs !== rawCurrentProps) {
6186
- for (const key in attrs) {
6187
- if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
6188
- delete attrs[key];
6189
- hasAttrsChanged = true;
6190
- }
6089
+ };
6090
+ Vue.options = { _base: Vue };
6091
+ let cid = 1;
6092
+ Vue.cid = cid;
6093
+ Vue.nextTick = nextTick;
6094
+ const extendCache = /* @__PURE__ */ new WeakMap();
6095
+ function extendCtor(extendOptions = {}) {
6096
+ assertCompatEnabled("GLOBAL_EXTEND", null);
6097
+ if (isFunction(extendOptions)) {
6098
+ extendOptions = extendOptions.options;
6099
+ }
6100
+ if (extendCache.has(extendOptions)) {
6101
+ return extendCache.get(extendOptions);
6102
+ }
6103
+ const Super = this;
6104
+ function SubVue(inlineOptions) {
6105
+ if (!inlineOptions) {
6106
+ return createCompatApp(SubVue.options, SubVue);
6107
+ } else {
6108
+ return createCompatApp(
6109
+ mergeOptions(
6110
+ extend({}, SubVue.options),
6111
+ inlineOptions,
6112
+ internalOptionMergeStrats
6113
+ ),
6114
+ SubVue
6115
+ );
6191
6116
  }
6192
6117
  }
6118
+ SubVue.super = Super;
6119
+ SubVue.prototype = Object.create(Vue.prototype);
6120
+ SubVue.prototype.constructor = SubVue;
6121
+ const mergeBase = {};
6122
+ for (const key in Super.options) {
6123
+ const superValue = Super.options[key];
6124
+ mergeBase[key] = isArray(superValue) ? superValue.slice() : isObject(superValue) ? extend(/* @__PURE__ */ Object.create(null), superValue) : superValue;
6125
+ }
6126
+ SubVue.options = mergeOptions(
6127
+ mergeBase,
6128
+ extendOptions,
6129
+ internalOptionMergeStrats
6130
+ );
6131
+ SubVue.options._base = SubVue;
6132
+ SubVue.extend = extendCtor.bind(SubVue);
6133
+ SubVue.mixin = Super.mixin;
6134
+ SubVue.use = Super.use;
6135
+ SubVue.cid = ++cid;
6136
+ extendCache.set(extendOptions, SubVue);
6137
+ return SubVue;
6193
6138
  }
6194
- if (hasAttrsChanged) {
6195
- trigger(instance, "set", "$attrs");
6196
- }
6197
- if (process.env.NODE_ENV !== "production") {
6198
- validateProps(rawProps || {}, props, instance);
6199
- }
6200
- }
6201
- function setFullProps(instance, rawProps, props, attrs) {
6202
- const [options, needCastKeys] = instance.propsOptions;
6203
- let hasAttrsChanged = false;
6204
- let rawCastValues;
6205
- if (rawProps) {
6206
- for (let key in rawProps) {
6207
- if (isReservedProp(key)) {
6208
- continue;
6209
- }
6210
- {
6211
- if (key.startsWith("onHook:")) {
6212
- softAssertCompatEnabled(
6213
- "INSTANCE_EVENT_HOOKS",
6214
- instance,
6215
- key.slice(2).toLowerCase()
6216
- );
6217
- }
6218
- if (key === "inline-template") {
6219
- continue;
6220
- }
6221
- }
6222
- const value = rawProps[key];
6223
- let camelKey;
6224
- if (options && hasOwn(options, camelKey = camelize(key))) {
6225
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
6226
- props[camelKey] = value;
6227
- } else {
6228
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
6229
- }
6230
- } else if (!isEmitListener(instance.emitsOptions, key)) {
6231
- {
6232
- if (isOn(key) && key.endsWith("Native")) {
6233
- key = key.slice(0, -6);
6234
- } else if (shouldSkipAttr(key, instance)) {
6235
- continue;
6236
- }
6237
- }
6238
- if (!(key in attrs) || value !== attrs[key]) {
6239
- attrs[key] = value;
6240
- hasAttrsChanged = true;
6241
- }
6242
- }
6139
+ Vue.extend = extendCtor.bind(Vue);
6140
+ Vue.set = (target, key, value) => {
6141
+ assertCompatEnabled("GLOBAL_SET", null);
6142
+ target[key] = value;
6143
+ };
6144
+ Vue.delete = (target, key) => {
6145
+ assertCompatEnabled("GLOBAL_DELETE", null);
6146
+ delete target[key];
6147
+ };
6148
+ Vue.observable = (target) => {
6149
+ assertCompatEnabled("GLOBAL_OBSERVABLE", null);
6150
+ return reactive(target);
6151
+ };
6152
+ Vue.filter = (name, filter) => {
6153
+ if (filter) {
6154
+ singletonApp.filter(name, filter);
6155
+ return Vue;
6156
+ } else {
6157
+ return singletonApp.filter(name);
6243
6158
  }
6244
- }
6245
- if (needCastKeys) {
6246
- const rawCurrentProps = toRaw(props);
6247
- const castValues = rawCastValues || EMPTY_OBJ;
6248
- for (let i = 0; i < needCastKeys.length; i++) {
6249
- const key = needCastKeys[i];
6250
- props[key] = resolvePropValue(
6251
- options,
6252
- rawCurrentProps,
6253
- key,
6254
- castValues[key],
6255
- instance,
6256
- !hasOwn(castValues, key)
6257
- );
6159
+ };
6160
+ const util = {
6161
+ warn: process.env.NODE_ENV !== "production" ? warn : NOOP,
6162
+ extend,
6163
+ mergeOptions: (parent, child, vm) => mergeOptions(
6164
+ parent,
6165
+ child,
6166
+ vm ? void 0 : internalOptionMergeStrats
6167
+ ),
6168
+ defineReactive
6169
+ };
6170
+ Object.defineProperty(Vue, "util", {
6171
+ get() {
6172
+ assertCompatEnabled("GLOBAL_PRIVATE_UTIL", null);
6173
+ return util;
6258
6174
  }
6175
+ });
6176
+ Vue.configureCompat = configureCompat$1;
6177
+ return Vue;
6178
+ }
6179
+ function installAppCompatProperties(app, context, render) {
6180
+ installFilterMethod(app, context);
6181
+ installLegacyOptionMergeStrats(app.config);
6182
+ if (!singletonApp) {
6183
+ return;
6259
6184
  }
6260
- return hasAttrsChanged;
6185
+ installCompatMount(app, context, render);
6186
+ installLegacyAPIs(app);
6187
+ applySingletonAppMutations(app);
6188
+ if (process.env.NODE_ENV !== "production")
6189
+ installLegacyConfigWarnings(app.config);
6261
6190
  }
6262
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
6263
- const opt = options[key];
6264
- if (opt != null) {
6265
- const hasDefault = hasOwn(opt, "default");
6266
- if (hasDefault && value === void 0) {
6267
- const defaultValue = opt.default;
6268
- if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
6269
- const { propsDefaults } = instance;
6270
- if (key in propsDefaults) {
6271
- value = propsDefaults[key];
6272
- } else {
6273
- setCurrentInstance(instance);
6274
- value = propsDefaults[key] = defaultValue.call(
6275
- isCompatEnabled("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props, key) : null,
6276
- props
6277
- );
6278
- unsetCurrentInstance();
6279
- }
6280
- } else {
6281
- value = defaultValue;
6282
- }
6191
+ function installFilterMethod(app, context) {
6192
+ context.filters = {};
6193
+ app.filter = (name, filter) => {
6194
+ assertCompatEnabled("FILTERS", null);
6195
+ if (!filter) {
6196
+ return context.filters[name];
6283
6197
  }
6284
- if (opt[0 /* shouldCast */]) {
6285
- if (isAbsent && !hasDefault) {
6286
- value = false;
6287
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
6288
- value = true;
6289
- }
6198
+ if (process.env.NODE_ENV !== "production" && context.filters[name]) {
6199
+ warn(`Filter "${name}" has already been registered.`);
6290
6200
  }
6291
- }
6292
- return value;
6201
+ context.filters[name] = filter;
6202
+ return app;
6203
+ };
6293
6204
  }
6294
- function normalizePropsOptions(comp, appContext, asMixin = false) {
6295
- const cache = appContext.propsCache;
6296
- const cached = cache.get(comp);
6297
- if (cached) {
6298
- return cached;
6299
- }
6300
- const raw = comp.props;
6301
- const normalized = {};
6302
- const needCastKeys = [];
6303
- let hasExtends = false;
6304
- if (__VUE_OPTIONS_API__ && !isFunction(comp)) {
6305
- const extendProps = (raw2) => {
6306
- if (isFunction(raw2)) {
6307
- raw2 = raw2.options;
6205
+ function installLegacyAPIs(app) {
6206
+ Object.defineProperties(app, {
6207
+ // so that app.use() can work with legacy plugins that extend prototypes
6208
+ prototype: {
6209
+ get() {
6210
+ process.env.NODE_ENV !== "production" && warnDeprecation("GLOBAL_PROTOTYPE", null);
6211
+ return app.config.globalProperties;
6212
+ }
6213
+ },
6214
+ nextTick: { value: nextTick },
6215
+ extend: { value: singletonCtor.extend },
6216
+ set: { value: singletonCtor.set },
6217
+ delete: { value: singletonCtor.delete },
6218
+ observable: { value: singletonCtor.observable },
6219
+ util: {
6220
+ get() {
6221
+ return singletonCtor.util;
6308
6222
  }
6309
- hasExtends = true;
6310
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
6311
- extend(normalized, props);
6312
- if (keys)
6313
- needCastKeys.push(...keys);
6314
- };
6315
- if (!asMixin && appContext.mixins.length) {
6316
- appContext.mixins.forEach(extendProps);
6317
6223
  }
6318
- if (comp.extends) {
6319
- extendProps(comp.extends);
6224
+ });
6225
+ }
6226
+ function applySingletonAppMutations(app) {
6227
+ app._context.mixins = [...singletonApp._context.mixins];
6228
+ ["components", "directives", "filters"].forEach((key) => {
6229
+ app._context[key] = Object.create(singletonApp._context[key]);
6230
+ });
6231
+ isCopyingConfig = true;
6232
+ for (const key in singletonApp.config) {
6233
+ if (key === "isNativeTag")
6234
+ continue;
6235
+ if (isRuntimeOnly() && (key === "isCustomElement" || key === "compilerOptions")) {
6236
+ continue;
6320
6237
  }
6321
- if (comp.mixins) {
6322
- comp.mixins.forEach(extendProps);
6238
+ const val = singletonApp.config[key];
6239
+ app.config[key] = isObject(val) ? Object.create(val) : val;
6240
+ if (key === "ignoredElements" && isCompatEnabled("CONFIG_IGNORED_ELEMENTS", null) && !isRuntimeOnly() && isArray(val)) {
6241
+ app.config.compilerOptions.isCustomElement = (tag) => {
6242
+ return val.some((v) => isString(v) ? v === tag : v.test(tag));
6243
+ };
6323
6244
  }
6324
6245
  }
6325
- if (!raw && !hasExtends) {
6326
- if (isObject(comp)) {
6327
- cache.set(comp, EMPTY_ARR);
6328
- }
6329
- return EMPTY_ARR;
6246
+ isCopyingConfig = false;
6247
+ applySingletonPrototype(app, singletonCtor);
6248
+ }
6249
+ function applySingletonPrototype(app, Ctor) {
6250
+ const enabled = isCompatEnabled("GLOBAL_PROTOTYPE", null);
6251
+ if (enabled) {
6252
+ app.config.globalProperties = Object.create(Ctor.prototype);
6330
6253
  }
6331
- if (isArray(raw)) {
6332
- for (let i = 0; i < raw.length; i++) {
6333
- if (process.env.NODE_ENV !== "production" && !isString(raw[i])) {
6334
- warn(`props must be strings when using array syntax.`, raw[i]);
6335
- }
6336
- const normalizedKey = camelize(raw[i]);
6337
- if (validatePropName(normalizedKey)) {
6338
- normalized[normalizedKey] = EMPTY_OBJ;
6339
- }
6340
- }
6341
- } else if (raw) {
6342
- if (process.env.NODE_ENV !== "production" && !isObject(raw)) {
6343
- warn(`invalid props options`, raw);
6344
- }
6345
- for (const key in raw) {
6346
- const normalizedKey = camelize(key);
6347
- if (validatePropName(normalizedKey)) {
6348
- const opt = raw[key];
6349
- const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
6350
- if (prop) {
6351
- const booleanIndex = getTypeIndex(Boolean, prop.type);
6352
- const stringIndex = getTypeIndex(String, prop.type);
6353
- prop[0 /* shouldCast */] = booleanIndex > -1;
6354
- prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
6355
- if (booleanIndex > -1 || hasOwn(prop, "default")) {
6356
- needCastKeys.push(normalizedKey);
6357
- }
6358
- }
6254
+ let hasPrototypeAugmentations = false;
6255
+ const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
6256
+ for (const key in descriptors) {
6257
+ if (key !== "constructor") {
6258
+ hasPrototypeAugmentations = true;
6259
+ if (enabled) {
6260
+ Object.defineProperty(
6261
+ app.config.globalProperties,
6262
+ key,
6263
+ descriptors[key]
6264
+ );
6359
6265
  }
6360
6266
  }
6361
6267
  }
6362
- const res = [normalized, needCastKeys];
6363
- if (isObject(comp)) {
6364
- cache.set(comp, res);
6365
- }
6366
- return res;
6367
- }
6368
- function validatePropName(key) {
6369
- if (key[0] !== "$") {
6370
- return true;
6371
- } else if (process.env.NODE_ENV !== "production") {
6372
- warn(`Invalid prop name: "${key}" is a reserved property.`);
6373
- }
6374
- return false;
6375
- }
6376
- function getType(ctor) {
6377
- const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
6378
- return match ? match[2] : ctor === null ? "null" : "";
6379
- }
6380
- function isSameType(a, b) {
6381
- return getType(a) === getType(b);
6382
- }
6383
- function getTypeIndex(type, expectedTypes) {
6384
- if (isArray(expectedTypes)) {
6385
- return expectedTypes.findIndex((t) => isSameType(t, type));
6386
- } else if (isFunction(expectedTypes)) {
6387
- return isSameType(expectedTypes, type) ? 0 : -1;
6388
- }
6389
- return -1;
6390
- }
6391
- function validateProps(rawProps, props, instance) {
6392
- const resolvedValues = toRaw(props);
6393
- const options = instance.propsOptions[0];
6394
- for (const key in options) {
6395
- let opt = options[key];
6396
- if (opt == null)
6397
- continue;
6398
- validateProp(
6399
- key,
6400
- resolvedValues[key],
6401
- opt,
6402
- !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
6403
- );
6268
+ if (process.env.NODE_ENV !== "production" && hasPrototypeAugmentations) {
6269
+ warnDeprecation("GLOBAL_PROTOTYPE", null);
6404
6270
  }
6405
6271
  }
6406
- function validateProp(name, value, prop, isAbsent) {
6407
- const { type, required, validator, skipCheck } = prop;
6408
- if (required && isAbsent) {
6409
- warn('Missing required prop: "' + name + '"');
6410
- return;
6411
- }
6412
- if (value == null && !prop.required) {
6413
- return;
6414
- }
6415
- if (type != null && type !== true && !skipCheck) {
6416
- let isValid = false;
6417
- const types = isArray(type) ? type : [type];
6418
- const expectedTypes = [];
6419
- for (let i = 0; i < types.length && !isValid; i++) {
6420
- const { valid, expectedType } = assertType(value, types[i]);
6421
- expectedTypes.push(expectedType || "");
6422
- isValid = valid;
6272
+ function installCompatMount(app, context, render) {
6273
+ let isMounted = false;
6274
+ app._createRoot = (options) => {
6275
+ const component = app._component;
6276
+ const vnode = createVNode(component, options.propsData || null);
6277
+ vnode.appContext = context;
6278
+ const hasNoRender = !isFunction(component) && !component.render && !component.template;
6279
+ const emptyRender = () => {
6280
+ };
6281
+ const instance = createComponentInstance(vnode, null, null);
6282
+ if (hasNoRender) {
6283
+ instance.render = emptyRender;
6423
6284
  }
6424
- if (!isValid) {
6425
- warn(getInvalidTypeMessage(name, value, expectedTypes));
6426
- return;
6285
+ setupComponent(instance);
6286
+ vnode.component = instance;
6287
+ vnode.isCompatRoot = true;
6288
+ instance.ctx._compat_mount = (selectorOrEl) => {
6289
+ if (isMounted) {
6290
+ process.env.NODE_ENV !== "production" && warn(`Root instance is already mounted.`);
6291
+ return;
6292
+ }
6293
+ let container;
6294
+ if (typeof selectorOrEl === "string") {
6295
+ const result = document.querySelector(selectorOrEl);
6296
+ if (!result) {
6297
+ process.env.NODE_ENV !== "production" && warn(
6298
+ `Failed to mount root instance: selector "${selectorOrEl}" returned null.`
6299
+ );
6300
+ return;
6301
+ }
6302
+ container = result;
6303
+ } else {
6304
+ container = selectorOrEl || document.createElement("div");
6305
+ }
6306
+ const isSVG = container instanceof SVGElement;
6307
+ if (process.env.NODE_ENV !== "production") {
6308
+ context.reload = () => {
6309
+ const cloned = cloneVNode(vnode);
6310
+ cloned.component = null;
6311
+ render(cloned, container, isSVG);
6312
+ };
6313
+ }
6314
+ if (hasNoRender && instance.render === emptyRender) {
6315
+ if (process.env.NODE_ENV !== "production") {
6316
+ for (let i = 0; i < container.attributes.length; i++) {
6317
+ const attr = container.attributes[i];
6318
+ if (attr.name !== "v-cloak" && /^(v-|:|@)/.test(attr.name)) {
6319
+ warnDeprecation("GLOBAL_MOUNT_CONTAINER", null);
6320
+ break;
6321
+ }
6322
+ }
6323
+ }
6324
+ instance.render = null;
6325
+ component.template = container.innerHTML;
6326
+ finishComponentSetup(
6327
+ instance,
6328
+ false,
6329
+ true
6330
+ /* skip options */
6331
+ );
6332
+ }
6333
+ container.innerHTML = "";
6334
+ render(vnode, container, isSVG);
6335
+ if (container instanceof Element) {
6336
+ container.removeAttribute("v-cloak");
6337
+ container.setAttribute("data-v-app", "");
6338
+ }
6339
+ isMounted = true;
6340
+ app._container = container;
6341
+ container.__vue_app__ = app;
6342
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6343
+ devtoolsInitApp(app, version);
6344
+ }
6345
+ return instance.proxy;
6346
+ };
6347
+ instance.ctx._compat_destroy = () => {
6348
+ if (isMounted) {
6349
+ render(null, app._container);
6350
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6351
+ devtoolsUnmountApp(app);
6352
+ }
6353
+ delete app._container.__vue_app__;
6354
+ } else {
6355
+ const { bum, scope, um } = instance;
6356
+ if (bum) {
6357
+ invokeArrayFns(bum);
6358
+ }
6359
+ if (isCompatEnabled("INSTANCE_EVENT_HOOKS", instance)) {
6360
+ instance.emit("hook:beforeDestroy");
6361
+ }
6362
+ if (scope) {
6363
+ scope.stop();
6364
+ }
6365
+ if (um) {
6366
+ invokeArrayFns(um);
6367
+ }
6368
+ if (isCompatEnabled("INSTANCE_EVENT_HOOKS", instance)) {
6369
+ instance.emit("hook:destroyed");
6370
+ }
6371
+ }
6372
+ };
6373
+ return instance.proxy;
6374
+ };
6375
+ }
6376
+ const methodsToPatch = [
6377
+ "push",
6378
+ "pop",
6379
+ "shift",
6380
+ "unshift",
6381
+ "splice",
6382
+ "sort",
6383
+ "reverse"
6384
+ ];
6385
+ const patched = /* @__PURE__ */ new WeakSet();
6386
+ function defineReactive(obj, key, val) {
6387
+ if (isObject(val) && !isReactive(val) && !patched.has(val)) {
6388
+ const reactiveVal = reactive(val);
6389
+ if (isArray(val)) {
6390
+ methodsToPatch.forEach((m) => {
6391
+ val[m] = (...args) => {
6392
+ Array.prototype[m].call(reactiveVal, ...args);
6393
+ };
6394
+ });
6395
+ } else {
6396
+ Object.keys(val).forEach((key2) => {
6397
+ try {
6398
+ defineReactiveSimple(val, key2, val[key2]);
6399
+ } catch (e) {
6400
+ }
6401
+ });
6427
6402
  }
6428
6403
  }
6429
- if (validator && !validator(value)) {
6430
- warn('Invalid prop: custom validator check failed for prop "' + name + '".');
6404
+ const i = obj.$;
6405
+ if (i && obj === i.proxy) {
6406
+ defineReactiveSimple(i.ctx, key, val);
6407
+ i.accessCache = /* @__PURE__ */ Object.create(null);
6408
+ } else if (isReactive(obj)) {
6409
+ obj[key] = val;
6410
+ } else {
6411
+ defineReactiveSimple(obj, key, val);
6431
6412
  }
6432
6413
  }
6433
- const isSimpleType = /* @__PURE__ */ makeMap(
6434
- "String,Number,Boolean,Function,Symbol,BigInt"
6435
- );
6436
- function assertType(value, type) {
6437
- let valid;
6438
- const expectedType = getType(type);
6439
- if (isSimpleType(expectedType)) {
6440
- const t = typeof value;
6441
- valid = t === expectedType.toLowerCase();
6442
- if (!valid && t === "object") {
6443
- valid = value instanceof type;
6414
+ function defineReactiveSimple(obj, key, val) {
6415
+ val = isObject(val) ? reactive(val) : val;
6416
+ Object.defineProperty(obj, key, {
6417
+ enumerable: true,
6418
+ configurable: true,
6419
+ get() {
6420
+ track(obj, "get", key);
6421
+ return val;
6422
+ },
6423
+ set(newVal) {
6424
+ val = isObject(newVal) ? reactive(newVal) : newVal;
6425
+ trigger(obj, "set", key, newVal);
6444
6426
  }
6445
- } else if (expectedType === "Object") {
6446
- valid = isObject(value);
6447
- } else if (expectedType === "Array") {
6448
- valid = isArray(value);
6449
- } else if (expectedType === "null") {
6450
- valid = value === null;
6451
- } else {
6452
- valid = value instanceof type;
6453
- }
6427
+ });
6428
+ }
6429
+
6430
+ function createAppContext() {
6454
6431
  return {
6455
- valid,
6456
- expectedType
6432
+ app: null,
6433
+ config: {
6434
+ isNativeTag: NO,
6435
+ performance: false,
6436
+ globalProperties: {},
6437
+ optionMergeStrategies: {},
6438
+ errorHandler: void 0,
6439
+ warnHandler: void 0,
6440
+ compilerOptions: {}
6441
+ },
6442
+ mixins: [],
6443
+ components: {},
6444
+ directives: {},
6445
+ provides: /* @__PURE__ */ Object.create(null),
6446
+ optionsCache: /* @__PURE__ */ new WeakMap(),
6447
+ propsCache: /* @__PURE__ */ new WeakMap(),
6448
+ emitsCache: /* @__PURE__ */ new WeakMap()
6457
6449
  };
6458
6450
  }
6459
- function getInvalidTypeMessage(name, value, expectedTypes) {
6460
- let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
6461
- const expectedType = expectedTypes[0];
6462
- const receivedType = toRawType(value);
6463
- const expectedValue = styleValue(value, expectedType);
6464
- const receivedValue = styleValue(value, receivedType);
6465
- if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
6466
- message += ` with value ${expectedValue}`;
6467
- }
6468
- message += `, got ${receivedType} `;
6469
- if (isExplicable(receivedType)) {
6470
- message += `with value ${receivedValue}.`;
6471
- }
6472
- return message;
6473
- }
6474
- function styleValue(value, type) {
6475
- if (type === "String") {
6476
- return `"${value}"`;
6477
- } else if (type === "Number") {
6478
- return `${Number(value)}`;
6479
- } else {
6480
- return `${value}`;
6481
- }
6482
- }
6483
- function isExplicable(type) {
6484
- const explicitTypes = ["string", "number", "boolean"];
6485
- return explicitTypes.some((elem) => type.toLowerCase() === elem);
6486
- }
6487
- function isBoolean(...args) {
6488
- return args.some((elem) => elem.toLowerCase() === "boolean");
6489
- }
6490
-
6491
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
6492
- const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
6493
- const normalizeSlot = (key, rawSlot, ctx) => {
6494
- if (rawSlot._n) {
6495
- return rawSlot;
6496
- }
6497
- const normalized = withCtx((...args) => {
6498
- if (process.env.NODE_ENV !== "production" && currentInstance) {
6499
- warn(
6500
- `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.`
6501
- );
6502
- }
6503
- return normalizeSlotValue(rawSlot(...args));
6504
- }, ctx);
6505
- normalized._c = false;
6506
- return normalized;
6507
- };
6508
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
6509
- const ctx = rawSlots._ctx;
6510
- for (const key in rawSlots) {
6511
- if (isInternalKey(key))
6512
- continue;
6513
- const value = rawSlots[key];
6514
- if (isFunction(value)) {
6515
- slots[key] = normalizeSlot(key, value, ctx);
6516
- } else if (value != null) {
6517
- if (process.env.NODE_ENV !== "production" && !isCompatEnabled("RENDER_FUNCTION", instance)) {
6518
- warn(
6519
- `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
6520
- );
6521
- }
6522
- const normalized = normalizeSlotValue(value);
6523
- slots[key] = () => normalized;
6524
- }
6525
- }
6526
- };
6527
- const normalizeVNodeSlots = (instance, children) => {
6528
- if (process.env.NODE_ENV !== "production" && !isKeepAlive(instance.vnode) && !isCompatEnabled("RENDER_FUNCTION", instance)) {
6529
- warn(
6530
- `Non-function value encountered for default slot. Prefer function slots for better performance.`
6531
- );
6532
- }
6533
- const normalized = normalizeSlotValue(children);
6534
- instance.slots.default = () => normalized;
6535
- };
6536
- const initSlots = (instance, children) => {
6537
- if (instance.vnode.shapeFlag & 32) {
6538
- const type = children._;
6539
- if (type) {
6540
- instance.slots = toRaw(children);
6541
- def(children, "_", type);
6542
- } else {
6543
- normalizeObjectSlots(
6544
- children,
6545
- instance.slots = {},
6546
- instance
6547
- );
6451
+ let uid$1 = 0;
6452
+ function createAppAPI(render, hydrate) {
6453
+ return function createApp(rootComponent, rootProps = null) {
6454
+ if (!isFunction(rootComponent)) {
6455
+ rootComponent = extend({}, rootComponent);
6548
6456
  }
6549
- } else {
6550
- instance.slots = {};
6551
- if (children) {
6552
- normalizeVNodeSlots(instance, children);
6457
+ if (rootProps != null && !isObject(rootProps)) {
6458
+ process.env.NODE_ENV !== "production" && warn(`root props passed to app.mount() must be an object.`);
6459
+ rootProps = null;
6553
6460
  }
6554
- }
6555
- def(instance.slots, InternalObjectKey, 1);
6556
- };
6557
- const updateSlots = (instance, children, optimized) => {
6558
- const { vnode, slots } = instance;
6559
- let needDeletionCheck = true;
6560
- let deletionComparisonTarget = EMPTY_OBJ;
6561
- if (vnode.shapeFlag & 32) {
6562
- const type = children._;
6563
- if (type) {
6564
- if (process.env.NODE_ENV !== "production" && isHmrUpdating) {
6565
- extend(slots, children);
6566
- } else if (optimized && type === 1) {
6567
- needDeletionCheck = false;
6568
- } else {
6569
- extend(slots, children);
6570
- if (!optimized && type === 1) {
6571
- delete slots._;
6461
+ const context = createAppContext();
6462
+ const installedPlugins = /* @__PURE__ */ new Set();
6463
+ let isMounted = false;
6464
+ const app = context.app = {
6465
+ _uid: uid$1++,
6466
+ _component: rootComponent,
6467
+ _props: rootProps,
6468
+ _container: null,
6469
+ _context: context,
6470
+ _instance: null,
6471
+ version,
6472
+ get config() {
6473
+ return context.config;
6474
+ },
6475
+ set config(v) {
6476
+ if (process.env.NODE_ENV !== "production") {
6477
+ warn(
6478
+ `app.config cannot be replaced. Modify individual options instead.`
6479
+ );
6572
6480
  }
6573
- }
6574
- } else {
6575
- needDeletionCheck = !children.$stable;
6576
- normalizeObjectSlots(children, slots, instance);
6577
- }
6578
- deletionComparisonTarget = children;
6579
- } else if (children) {
6580
- normalizeVNodeSlots(instance, children);
6581
- deletionComparisonTarget = { default: 1 };
6582
- }
6583
- if (needDeletionCheck) {
6584
- for (const key in slots) {
6585
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
6586
- delete slots[key];
6587
- }
6588
- }
6589
- }
6590
- };
6591
-
6592
- function installLegacyConfigWarnings(config) {
6593
- const legacyConfigOptions = {
6594
- silent: "CONFIG_SILENT",
6595
- devtools: "CONFIG_DEVTOOLS",
6596
- ignoredElements: "CONFIG_IGNORED_ELEMENTS",
6597
- keyCodes: "CONFIG_KEY_CODES",
6598
- productionTip: "CONFIG_PRODUCTION_TIP"
6599
- };
6600
- Object.keys(legacyConfigOptions).forEach((key) => {
6601
- let val = config[key];
6602
- Object.defineProperty(config, key, {
6603
- enumerable: true,
6604
- get() {
6605
- return val;
6606
6481
  },
6607
- set(newVal) {
6608
- if (!isCopyingConfig) {
6609
- warnDeprecation(legacyConfigOptions[key], null);
6482
+ use(plugin, ...options) {
6483
+ if (installedPlugins.has(plugin)) {
6484
+ process.env.NODE_ENV !== "production" && warn(`Plugin has already been applied to target app.`);
6485
+ } else if (plugin && isFunction(plugin.install)) {
6486
+ installedPlugins.add(plugin);
6487
+ plugin.install(app, ...options);
6488
+ } else if (isFunction(plugin)) {
6489
+ installedPlugins.add(plugin);
6490
+ plugin(app, ...options);
6491
+ } else if (process.env.NODE_ENV !== "production") {
6492
+ warn(
6493
+ `A plugin must either be a function or an object with an "install" function.`
6494
+ );
6495
+ }
6496
+ return app;
6497
+ },
6498
+ mixin(mixin) {
6499
+ if (__VUE_OPTIONS_API__) {
6500
+ if (!context.mixins.includes(mixin)) {
6501
+ context.mixins.push(mixin);
6502
+ } else if (process.env.NODE_ENV !== "production") {
6503
+ warn(
6504
+ "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
6505
+ );
6506
+ }
6507
+ } else if (process.env.NODE_ENV !== "production") {
6508
+ warn("Mixins are only available in builds supporting Options API");
6509
+ }
6510
+ return app;
6511
+ },
6512
+ component(name, component) {
6513
+ if (process.env.NODE_ENV !== "production") {
6514
+ validateComponentName(name, context.config);
6515
+ }
6516
+ if (!component) {
6517
+ return context.components[name];
6518
+ }
6519
+ if (process.env.NODE_ENV !== "production" && context.components[name]) {
6520
+ warn(`Component "${name}" has already been registered in target app.`);
6521
+ }
6522
+ context.components[name] = component;
6523
+ return app;
6524
+ },
6525
+ directive(name, directive) {
6526
+ if (process.env.NODE_ENV !== "production") {
6527
+ validateDirectiveName(name);
6528
+ }
6529
+ if (!directive) {
6530
+ return context.directives[name];
6531
+ }
6532
+ if (process.env.NODE_ENV !== "production" && context.directives[name]) {
6533
+ warn(`Directive "${name}" has already been registered in target app.`);
6534
+ }
6535
+ context.directives[name] = directive;
6536
+ return app;
6537
+ },
6538
+ mount(rootContainer, isHydrate, isSVG) {
6539
+ if (!isMounted) {
6540
+ if (process.env.NODE_ENV !== "production" && rootContainer.__vue_app__) {
6541
+ warn(
6542
+ `There is already an app instance mounted on the host container.
6543
+ If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
6544
+ );
6545
+ }
6546
+ const vnode = createVNode(
6547
+ rootComponent,
6548
+ rootProps
6549
+ );
6550
+ vnode.appContext = context;
6551
+ if (process.env.NODE_ENV !== "production") {
6552
+ context.reload = () => {
6553
+ render(cloneVNode(vnode), rootContainer, isSVG);
6554
+ };
6555
+ }
6556
+ if (isHydrate && hydrate) {
6557
+ hydrate(vnode, rootContainer);
6558
+ } else {
6559
+ render(vnode, rootContainer, isSVG);
6560
+ }
6561
+ isMounted = true;
6562
+ app._container = rootContainer;
6563
+ rootContainer.__vue_app__ = app;
6564
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6565
+ app._instance = vnode.component;
6566
+ devtoolsInitApp(app, version);
6567
+ }
6568
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
6569
+ } else if (process.env.NODE_ENV !== "production") {
6570
+ warn(
6571
+ `App has already been mounted.
6572
+ 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)\``
6573
+ );
6574
+ }
6575
+ },
6576
+ unmount() {
6577
+ if (isMounted) {
6578
+ render(null, app._container);
6579
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6580
+ app._instance = null;
6581
+ devtoolsUnmountApp(app);
6582
+ }
6583
+ delete app._container.__vue_app__;
6584
+ } else if (process.env.NODE_ENV !== "production") {
6585
+ warn(`Cannot unmount an app that is not mounted.`);
6586
+ }
6587
+ },
6588
+ provide(key, value) {
6589
+ if (process.env.NODE_ENV !== "production" && key in context.provides) {
6590
+ warn(
6591
+ `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
6592
+ );
6593
+ }
6594
+ context.provides[key] = value;
6595
+ return app;
6596
+ },
6597
+ runWithContext(fn) {
6598
+ currentApp = app;
6599
+ try {
6600
+ return fn();
6601
+ } finally {
6602
+ currentApp = null;
6610
6603
  }
6611
- val = newVal;
6612
- }
6613
- });
6614
- });
6615
- }
6616
- function installLegacyOptionMergeStrats(config) {
6617
- config.optionMergeStrategies = new Proxy({}, {
6618
- get(target, key) {
6619
- if (key in target) {
6620
- return target[key];
6621
- }
6622
- if (key in internalOptionMergeStrats && softAssertCompatEnabled(
6623
- "CONFIG_OPTION_MERGE_STRATS",
6624
- null
6625
- )) {
6626
- return internalOptionMergeStrats[key];
6627
- }
6628
- }
6629
- });
6630
- }
6631
-
6632
- let isCopyingConfig = false;
6633
- let singletonApp;
6634
- let singletonCtor;
6635
- function createCompatVue$1(createApp, createSingletonApp) {
6636
- singletonApp = createSingletonApp({});
6637
- const Vue = singletonCtor = function Vue2(options = {}) {
6638
- return createCompatApp(options, Vue2);
6639
- };
6640
- function createCompatApp(options = {}, Ctor) {
6641
- assertCompatEnabled("GLOBAL_MOUNT", null);
6642
- const { data } = options;
6643
- if (data && !isFunction(data) && softAssertCompatEnabled("OPTIONS_DATA_FN", null)) {
6644
- options.data = () => data;
6645
- }
6646
- const app = createApp(options);
6647
- if (Ctor !== Vue) {
6648
- applySingletonPrototype(app, Ctor);
6649
- }
6650
- const vm = app._createRoot(options);
6651
- if (options.el) {
6652
- return vm.$mount(options.el);
6653
- } else {
6654
- return vm;
6655
- }
6656
- }
6657
- Vue.version = `2.6.14-compat:${"3.3.0-alpha.7"}`;
6658
- Vue.config = singletonApp.config;
6659
- Vue.use = (p, ...options) => {
6660
- if (p && isFunction(p.install)) {
6661
- p.install(Vue, ...options);
6662
- } else if (isFunction(p)) {
6663
- p(Vue, ...options);
6664
- }
6665
- return Vue;
6666
- };
6667
- Vue.mixin = (m) => {
6668
- singletonApp.mixin(m);
6669
- return Vue;
6670
- };
6671
- Vue.component = (name, comp) => {
6672
- if (comp) {
6673
- singletonApp.component(name, comp);
6674
- return Vue;
6675
- } else {
6676
- return singletonApp.component(name);
6677
- }
6678
- };
6679
- Vue.directive = (name, dir) => {
6680
- if (dir) {
6681
- singletonApp.directive(name, dir);
6682
- return Vue;
6683
- } else {
6684
- return singletonApp.directive(name);
6685
- }
6686
- };
6687
- Vue.options = { _base: Vue };
6688
- let cid = 1;
6689
- Vue.cid = cid;
6690
- Vue.nextTick = nextTick;
6691
- const extendCache = /* @__PURE__ */ new WeakMap();
6692
- function extendCtor(extendOptions = {}) {
6693
- assertCompatEnabled("GLOBAL_EXTEND", null);
6694
- if (isFunction(extendOptions)) {
6695
- extendOptions = extendOptions.options;
6696
- }
6697
- if (extendCache.has(extendOptions)) {
6698
- return extendCache.get(extendOptions);
6699
- }
6700
- const Super = this;
6701
- function SubVue(inlineOptions) {
6702
- if (!inlineOptions) {
6703
- return createCompatApp(SubVue.options, SubVue);
6704
- } else {
6705
- return createCompatApp(
6706
- mergeOptions(
6707
- extend({}, SubVue.options),
6708
- inlineOptions,
6709
- internalOptionMergeStrats
6710
- ),
6711
- SubVue
6712
- );
6713
6604
  }
6605
+ };
6606
+ {
6607
+ installAppCompatProperties(app, context, render);
6714
6608
  }
6715
- SubVue.super = Super;
6716
- SubVue.prototype = Object.create(Vue.prototype);
6717
- SubVue.prototype.constructor = SubVue;
6718
- const mergeBase = {};
6719
- for (const key in Super.options) {
6720
- const superValue = Super.options[key];
6721
- mergeBase[key] = isArray(superValue) ? superValue.slice() : isObject(superValue) ? extend(/* @__PURE__ */ Object.create(null), superValue) : superValue;
6609
+ return app;
6610
+ };
6611
+ }
6612
+ let currentApp = null;
6613
+
6614
+ function provide(key, value) {
6615
+ if (!currentInstance) {
6616
+ if (process.env.NODE_ENV !== "production") {
6617
+ warn(`provide() can only be used inside setup().`);
6722
6618
  }
6723
- SubVue.options = mergeOptions(
6724
- mergeBase,
6725
- extendOptions,
6726
- internalOptionMergeStrats
6727
- );
6728
- SubVue.options._base = SubVue;
6729
- SubVue.extend = extendCtor.bind(SubVue);
6730
- SubVue.mixin = Super.mixin;
6731
- SubVue.use = Super.use;
6732
- SubVue.cid = ++cid;
6733
- extendCache.set(extendOptions, SubVue);
6734
- return SubVue;
6619
+ } else {
6620
+ let provides = currentInstance.provides;
6621
+ const parentProvides = currentInstance.parent && currentInstance.parent.provides;
6622
+ if (parentProvides === provides) {
6623
+ provides = currentInstance.provides = Object.create(parentProvides);
6624
+ }
6625
+ provides[key] = value;
6735
6626
  }
6736
- Vue.extend = extendCtor.bind(Vue);
6737
- Vue.set = (target, key, value) => {
6738
- assertCompatEnabled("GLOBAL_SET", null);
6739
- target[key] = value;
6740
- };
6741
- Vue.delete = (target, key) => {
6742
- assertCompatEnabled("GLOBAL_DELETE", null);
6743
- delete target[key];
6744
- };
6745
- Vue.observable = (target) => {
6746
- assertCompatEnabled("GLOBAL_OBSERVABLE", null);
6747
- return reactive(target);
6748
- };
6749
- Vue.filter = (name, filter) => {
6750
- if (filter) {
6751
- singletonApp.filter(name, filter);
6752
- return Vue;
6753
- } else {
6754
- return singletonApp.filter(name);
6627
+ }
6628
+ function inject(key, defaultValue, treatDefaultAsFactory = false) {
6629
+ const instance = currentInstance || currentRenderingInstance;
6630
+ if (instance || currentApp) {
6631
+ const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
6632
+ if (provides && key in provides) {
6633
+ return provides[key];
6634
+ } else if (arguments.length > 1) {
6635
+ return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
6636
+ } else if (process.env.NODE_ENV !== "production") {
6637
+ warn(`injection "${String(key)}" not found.`);
6755
6638
  }
6756
- };
6757
- const util = {
6758
- warn: process.env.NODE_ENV !== "production" ? warn : NOOP,
6759
- extend,
6760
- mergeOptions: (parent, child, vm) => mergeOptions(
6761
- parent,
6762
- child,
6763
- vm ? void 0 : internalOptionMergeStrats
6764
- ),
6765
- defineReactive
6766
- };
6767
- Object.defineProperty(Vue, "util", {
6768
- get() {
6769
- assertCompatEnabled("GLOBAL_PRIVATE_UTIL", null);
6770
- return util;
6639
+ } else if (process.env.NODE_ENV !== "production") {
6640
+ warn(`inject() can only be used inside setup() or functional components.`);
6641
+ }
6642
+ }
6643
+
6644
+ function createPropsDefaultThis(instance, rawProps, propKey) {
6645
+ return new Proxy(
6646
+ {},
6647
+ {
6648
+ get(_, key) {
6649
+ process.env.NODE_ENV !== "production" && warnDeprecation("PROPS_DEFAULT_THIS", null, propKey);
6650
+ if (key === "$options") {
6651
+ return resolveMergedOptions(instance);
6652
+ }
6653
+ if (key in rawProps) {
6654
+ return rawProps[key];
6655
+ }
6656
+ const injections = instance.type.inject;
6657
+ if (injections) {
6658
+ if (isArray(injections)) {
6659
+ if (injections.includes(key)) {
6660
+ return inject(key);
6661
+ }
6662
+ } else if (key in injections) {
6663
+ return inject(key);
6664
+ }
6665
+ }
6666
+ }
6771
6667
  }
6772
- });
6773
- Vue.configureCompat = configureCompat$1;
6774
- return Vue;
6668
+ );
6775
6669
  }
6776
- function installAppCompatProperties(app, context, render) {
6777
- installFilterMethod(app, context);
6778
- installLegacyOptionMergeStrats(app.config);
6779
- if (!singletonApp) {
6780
- return;
6670
+
6671
+ function shouldSkipAttr(key, instance) {
6672
+ if (key === "is") {
6673
+ return true;
6781
6674
  }
6782
- installCompatMount(app, context, render);
6783
- installLegacyAPIs(app);
6784
- applySingletonAppMutations(app);
6785
- if (process.env.NODE_ENV !== "production")
6786
- installLegacyConfigWarnings(app.config);
6675
+ if ((key === "class" || key === "style") && isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
6676
+ return true;
6677
+ }
6678
+ if (isOn(key) && isCompatEnabled("INSTANCE_LISTENERS", instance)) {
6679
+ return true;
6680
+ }
6681
+ if (key.startsWith("routerView") || key === "registerRouteInstance") {
6682
+ return true;
6683
+ }
6684
+ return false;
6787
6685
  }
6788
- function installFilterMethod(app, context) {
6789
- context.filters = {};
6790
- app.filter = (name, filter) => {
6791
- assertCompatEnabled("FILTERS", null);
6792
- if (!filter) {
6793
- return context.filters[name];
6686
+
6687
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
6688
+ const props = {};
6689
+ const attrs = {};
6690
+ def(attrs, InternalObjectKey, 1);
6691
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
6692
+ setFullProps(instance, rawProps, props, attrs);
6693
+ for (const key in instance.propsOptions[0]) {
6694
+ if (!(key in props)) {
6695
+ props[key] = void 0;
6794
6696
  }
6795
- if (process.env.NODE_ENV !== "production" && context.filters[name]) {
6796
- warn(`Filter "${name}" has already been registered.`);
6697
+ }
6698
+ if (process.env.NODE_ENV !== "production") {
6699
+ validateProps(rawProps || {}, props, instance);
6700
+ }
6701
+ if (isStateful) {
6702
+ instance.props = isSSR ? props : shallowReactive(props);
6703
+ } else {
6704
+ if (!instance.type.props) {
6705
+ instance.props = attrs;
6706
+ } else {
6707
+ instance.props = props;
6797
6708
  }
6798
- context.filters[name] = filter;
6799
- return app;
6800
- };
6709
+ }
6710
+ instance.attrs = attrs;
6801
6711
  }
6802
- function installLegacyAPIs(app) {
6803
- Object.defineProperties(app, {
6804
- // so that app.use() can work with legacy plugins that extend prototypes
6805
- prototype: {
6806
- get() {
6807
- process.env.NODE_ENV !== "production" && warnDeprecation("GLOBAL_PROTOTYPE", null);
6808
- return app.config.globalProperties;
6809
- }
6810
- },
6811
- nextTick: { value: nextTick },
6812
- extend: { value: singletonCtor.extend },
6813
- set: { value: singletonCtor.set },
6814
- delete: { value: singletonCtor.delete },
6815
- observable: { value: singletonCtor.observable },
6816
- util: {
6817
- get() {
6818
- return singletonCtor.util;
6712
+ function isInHmrContext(instance) {
6713
+ while (instance) {
6714
+ if (instance.type.__hmrId)
6715
+ return true;
6716
+ instance = instance.parent;
6717
+ }
6718
+ }
6719
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
6720
+ const {
6721
+ props,
6722
+ attrs,
6723
+ vnode: { patchFlag }
6724
+ } = instance;
6725
+ const rawCurrentProps = toRaw(props);
6726
+ const [options] = instance.propsOptions;
6727
+ let hasAttrsChanged = false;
6728
+ if (
6729
+ // always force full diff in dev
6730
+ // - #1942 if hmr is enabled with sfc component
6731
+ // - vite#872 non-sfc component used by sfc component
6732
+ !(process.env.NODE_ENV !== "production" && isInHmrContext(instance)) && (optimized || patchFlag > 0) && !(patchFlag & 16)
6733
+ ) {
6734
+ if (patchFlag & 8) {
6735
+ const propsToUpdate = instance.vnode.dynamicProps;
6736
+ for (let i = 0; i < propsToUpdate.length; i++) {
6737
+ let key = propsToUpdate[i];
6738
+ if (isEmitListener(instance.emitsOptions, key)) {
6739
+ continue;
6740
+ }
6741
+ const value = rawProps[key];
6742
+ if (options) {
6743
+ if (hasOwn(attrs, key)) {
6744
+ if (value !== attrs[key]) {
6745
+ attrs[key] = value;
6746
+ hasAttrsChanged = true;
6747
+ }
6748
+ } else {
6749
+ const camelizedKey = camelize(key);
6750
+ props[camelizedKey] = resolvePropValue(
6751
+ options,
6752
+ rawCurrentProps,
6753
+ camelizedKey,
6754
+ value,
6755
+ instance,
6756
+ false
6757
+ /* isAbsent */
6758
+ );
6759
+ }
6760
+ } else {
6761
+ {
6762
+ if (isOn(key) && key.endsWith("Native")) {
6763
+ key = key.slice(0, -6);
6764
+ } else if (shouldSkipAttr(key, instance)) {
6765
+ continue;
6766
+ }
6767
+ }
6768
+ if (value !== attrs[key]) {
6769
+ attrs[key] = value;
6770
+ hasAttrsChanged = true;
6771
+ }
6772
+ }
6819
6773
  }
6820
6774
  }
6821
- });
6822
- }
6823
- function applySingletonAppMutations(app) {
6824
- app._context.mixins = [...singletonApp._context.mixins];
6825
- ["components", "directives", "filters"].forEach((key) => {
6826
- app._context[key] = Object.create(singletonApp._context[key]);
6827
- });
6828
- isCopyingConfig = true;
6829
- for (const key in singletonApp.config) {
6830
- if (key === "isNativeTag")
6831
- continue;
6832
- if (isRuntimeOnly() && (key === "isCustomElement" || key === "compilerOptions")) {
6833
- continue;
6775
+ } else {
6776
+ if (setFullProps(instance, rawProps, props, attrs)) {
6777
+ hasAttrsChanged = true;
6778
+ }
6779
+ let kebabKey;
6780
+ for (const key in rawCurrentProps) {
6781
+ if (!rawProps || // for camelCase
6782
+ !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
6783
+ // and converted to camelCase (#955)
6784
+ ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
6785
+ if (options) {
6786
+ if (rawPrevProps && // for camelCase
6787
+ (rawPrevProps[key] !== void 0 || // for kebab-case
6788
+ rawPrevProps[kebabKey] !== void 0)) {
6789
+ props[key] = resolvePropValue(
6790
+ options,
6791
+ rawCurrentProps,
6792
+ key,
6793
+ void 0,
6794
+ instance,
6795
+ true
6796
+ /* isAbsent */
6797
+ );
6798
+ }
6799
+ } else {
6800
+ delete props[key];
6801
+ }
6802
+ }
6834
6803
  }
6835
- const val = singletonApp.config[key];
6836
- app.config[key] = isObject(val) ? Object.create(val) : val;
6837
- if (key === "ignoredElements" && isCompatEnabled("CONFIG_IGNORED_ELEMENTS", null) && !isRuntimeOnly() && isArray(val)) {
6838
- app.config.compilerOptions.isCustomElement = (tag) => {
6839
- return val.some((v) => isString(v) ? v === tag : v.test(tag));
6840
- };
6804
+ if (attrs !== rawCurrentProps) {
6805
+ for (const key in attrs) {
6806
+ if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
6807
+ delete attrs[key];
6808
+ hasAttrsChanged = true;
6809
+ }
6810
+ }
6841
6811
  }
6842
6812
  }
6843
- isCopyingConfig = false;
6844
- applySingletonPrototype(app, singletonCtor);
6845
- }
6846
- function applySingletonPrototype(app, Ctor) {
6847
- const enabled = isCompatEnabled("GLOBAL_PROTOTYPE", null);
6848
- if (enabled) {
6849
- app.config.globalProperties = Object.create(Ctor.prototype);
6813
+ if (hasAttrsChanged) {
6814
+ trigger(instance, "set", "$attrs");
6850
6815
  }
6851
- let hasPrototypeAugmentations = false;
6852
- const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
6853
- for (const key in descriptors) {
6854
- if (key !== "constructor") {
6855
- hasPrototypeAugmentations = true;
6856
- if (enabled) {
6857
- Object.defineProperty(
6858
- app.config.globalProperties,
6859
- key,
6860
- descriptors[key]
6861
- );
6816
+ if (process.env.NODE_ENV !== "production") {
6817
+ validateProps(rawProps || {}, props, instance);
6818
+ }
6819
+ }
6820
+ function setFullProps(instance, rawProps, props, attrs) {
6821
+ const [options, needCastKeys] = instance.propsOptions;
6822
+ let hasAttrsChanged = false;
6823
+ let rawCastValues;
6824
+ if (rawProps) {
6825
+ for (let key in rawProps) {
6826
+ if (isReservedProp(key)) {
6827
+ continue;
6828
+ }
6829
+ {
6830
+ if (key.startsWith("onHook:")) {
6831
+ softAssertCompatEnabled(
6832
+ "INSTANCE_EVENT_HOOKS",
6833
+ instance,
6834
+ key.slice(2).toLowerCase()
6835
+ );
6836
+ }
6837
+ if (key === "inline-template") {
6838
+ continue;
6839
+ }
6840
+ }
6841
+ const value = rawProps[key];
6842
+ let camelKey;
6843
+ if (options && hasOwn(options, camelKey = camelize(key))) {
6844
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
6845
+ props[camelKey] = value;
6846
+ } else {
6847
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
6848
+ }
6849
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
6850
+ {
6851
+ if (isOn(key) && key.endsWith("Native")) {
6852
+ key = key.slice(0, -6);
6853
+ } else if (shouldSkipAttr(key, instance)) {
6854
+ continue;
6855
+ }
6856
+ }
6857
+ if (!(key in attrs) || value !== attrs[key]) {
6858
+ attrs[key] = value;
6859
+ hasAttrsChanged = true;
6860
+ }
6862
6861
  }
6863
6862
  }
6864
6863
  }
6865
- if (process.env.NODE_ENV !== "production" && hasPrototypeAugmentations) {
6866
- warnDeprecation("GLOBAL_PROTOTYPE", null);
6864
+ if (needCastKeys) {
6865
+ const rawCurrentProps = toRaw(props);
6866
+ const castValues = rawCastValues || EMPTY_OBJ;
6867
+ for (let i = 0; i < needCastKeys.length; i++) {
6868
+ const key = needCastKeys[i];
6869
+ props[key] = resolvePropValue(
6870
+ options,
6871
+ rawCurrentProps,
6872
+ key,
6873
+ castValues[key],
6874
+ instance,
6875
+ !hasOwn(castValues, key)
6876
+ );
6877
+ }
6867
6878
  }
6879
+ return hasAttrsChanged;
6868
6880
  }
6869
- function installCompatMount(app, context, render) {
6870
- let isMounted = false;
6871
- app._createRoot = (options) => {
6872
- const component = app._component;
6873
- const vnode = createVNode(component, options.propsData || null);
6874
- vnode.appContext = context;
6875
- const hasNoRender = !isFunction(component) && !component.render && !component.template;
6876
- const emptyRender = () => {
6877
- };
6878
- const instance = createComponentInstance(vnode, null, null);
6879
- if (hasNoRender) {
6880
- instance.render = emptyRender;
6881
- }
6882
- setupComponent(instance);
6883
- vnode.component = instance;
6884
- vnode.isCompatRoot = true;
6885
- instance.ctx._compat_mount = (selectorOrEl) => {
6886
- if (isMounted) {
6887
- process.env.NODE_ENV !== "production" && warn(`Root instance is already mounted.`);
6888
- return;
6889
- }
6890
- let container;
6891
- if (typeof selectorOrEl === "string") {
6892
- const result = document.querySelector(selectorOrEl);
6893
- if (!result) {
6894
- process.env.NODE_ENV !== "production" && warn(
6895
- `Failed to mount root instance: selector "${selectorOrEl}" returned null.`
6881
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
6882
+ const opt = options[key];
6883
+ if (opt != null) {
6884
+ const hasDefault = hasOwn(opt, "default");
6885
+ if (hasDefault && value === void 0) {
6886
+ const defaultValue = opt.default;
6887
+ if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
6888
+ const { propsDefaults } = instance;
6889
+ if (key in propsDefaults) {
6890
+ value = propsDefaults[key];
6891
+ } else {
6892
+ setCurrentInstance(instance);
6893
+ value = propsDefaults[key] = defaultValue.call(
6894
+ isCompatEnabled("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props, key) : null,
6895
+ props
6896
6896
  );
6897
- return;
6897
+ unsetCurrentInstance();
6898
6898
  }
6899
- container = result;
6900
6899
  } else {
6901
- container = selectorOrEl || document.createElement("div");
6900
+ value = defaultValue;
6902
6901
  }
6903
- const isSVG = container instanceof SVGElement;
6904
- if (process.env.NODE_ENV !== "production") {
6905
- context.reload = () => {
6906
- const cloned = cloneVNode(vnode);
6907
- cloned.component = null;
6908
- render(cloned, container, isSVG);
6909
- };
6902
+ }
6903
+ if (opt[0 /* shouldCast */]) {
6904
+ if (isAbsent && !hasDefault) {
6905
+ value = false;
6906
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
6907
+ value = true;
6910
6908
  }
6911
- if (hasNoRender && instance.render === emptyRender) {
6912
- if (process.env.NODE_ENV !== "production") {
6913
- for (let i = 0; i < container.attributes.length; i++) {
6914
- const attr = container.attributes[i];
6915
- if (attr.name !== "v-cloak" && /^(v-|:|@)/.test(attr.name)) {
6916
- warnDeprecation("GLOBAL_MOUNT_CONTAINER", null);
6917
- break;
6918
- }
6919
- }
6920
- }
6921
- instance.render = null;
6922
- component.template = container.innerHTML;
6923
- finishComponentSetup(
6924
- instance,
6925
- false,
6926
- true
6927
- /* skip options */
6928
- );
6909
+ }
6910
+ }
6911
+ return value;
6912
+ }
6913
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
6914
+ const cache = appContext.propsCache;
6915
+ const cached = cache.get(comp);
6916
+ if (cached) {
6917
+ return cached;
6918
+ }
6919
+ const raw = comp.props;
6920
+ const normalized = {};
6921
+ const needCastKeys = [];
6922
+ let hasExtends = false;
6923
+ if (__VUE_OPTIONS_API__ && !isFunction(comp)) {
6924
+ const extendProps = (raw2) => {
6925
+ if (isFunction(raw2)) {
6926
+ raw2 = raw2.options;
6929
6927
  }
6930
- container.innerHTML = "";
6931
- render(vnode, container, isSVG);
6932
- if (container instanceof Element) {
6933
- container.removeAttribute("v-cloak");
6934
- container.setAttribute("data-v-app", "");
6928
+ hasExtends = true;
6929
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
6930
+ extend(normalized, props);
6931
+ if (keys)
6932
+ needCastKeys.push(...keys);
6933
+ };
6934
+ if (!asMixin && appContext.mixins.length) {
6935
+ appContext.mixins.forEach(extendProps);
6936
+ }
6937
+ if (comp.extends) {
6938
+ extendProps(comp.extends);
6939
+ }
6940
+ if (comp.mixins) {
6941
+ comp.mixins.forEach(extendProps);
6942
+ }
6943
+ }
6944
+ if (!raw && !hasExtends) {
6945
+ if (isObject(comp)) {
6946
+ cache.set(comp, EMPTY_ARR);
6947
+ }
6948
+ return EMPTY_ARR;
6949
+ }
6950
+ if (isArray(raw)) {
6951
+ for (let i = 0; i < raw.length; i++) {
6952
+ if (process.env.NODE_ENV !== "production" && !isString(raw[i])) {
6953
+ warn(`props must be strings when using array syntax.`, raw[i]);
6935
6954
  }
6936
- isMounted = true;
6937
- app._container = container;
6938
- container.__vue_app__ = app;
6939
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6940
- devtoolsInitApp(app, version);
6955
+ const normalizedKey = camelize(raw[i]);
6956
+ if (validatePropName(normalizedKey)) {
6957
+ normalized[normalizedKey] = EMPTY_OBJ;
6941
6958
  }
6942
- return instance.proxy;
6943
- };
6944
- instance.ctx._compat_destroy = () => {
6945
- if (isMounted) {
6946
- render(null, app._container);
6947
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6948
- devtoolsUnmountApp(app);
6949
- }
6950
- delete app._container.__vue_app__;
6951
- } else {
6952
- const { bum, scope, um } = instance;
6953
- if (bum) {
6954
- invokeArrayFns(bum);
6955
- }
6956
- if (isCompatEnabled("INSTANCE_EVENT_HOOKS", instance)) {
6957
- instance.emit("hook:beforeDestroy");
6958
- }
6959
- if (scope) {
6960
- scope.stop();
6961
- }
6962
- if (um) {
6963
- invokeArrayFns(um);
6964
- }
6965
- if (isCompatEnabled("INSTANCE_EVENT_HOOKS", instance)) {
6966
- instance.emit("hook:destroyed");
6959
+ }
6960
+ } else if (raw) {
6961
+ if (process.env.NODE_ENV !== "production" && !isObject(raw)) {
6962
+ warn(`invalid props options`, raw);
6963
+ }
6964
+ for (const key in raw) {
6965
+ const normalizedKey = camelize(key);
6966
+ if (validatePropName(normalizedKey)) {
6967
+ const opt = raw[key];
6968
+ const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
6969
+ if (prop) {
6970
+ const booleanIndex = getTypeIndex(Boolean, prop.type);
6971
+ const stringIndex = getTypeIndex(String, prop.type);
6972
+ prop[0 /* shouldCast */] = booleanIndex > -1;
6973
+ prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
6974
+ if (booleanIndex > -1 || hasOwn(prop, "default")) {
6975
+ needCastKeys.push(normalizedKey);
6976
+ }
6967
6977
  }
6968
6978
  }
6969
- };
6970
- return instance.proxy;
6971
- };
6972
- }
6973
- const methodsToPatch = [
6974
- "push",
6975
- "pop",
6976
- "shift",
6977
- "unshift",
6978
- "splice",
6979
- "sort",
6980
- "reverse"
6981
- ];
6982
- const patched = /* @__PURE__ */ new WeakSet();
6983
- function defineReactive(obj, key, val) {
6984
- if (isObject(val) && !isReactive(val) && !patched.has(val)) {
6985
- const reactiveVal = reactive(val);
6986
- if (isArray(val)) {
6987
- methodsToPatch.forEach((m) => {
6988
- val[m] = (...args) => {
6989
- Array.prototype[m].call(reactiveVal, ...args);
6990
- };
6991
- });
6992
- } else {
6993
- Object.keys(val).forEach((key2) => {
6994
- try {
6995
- defineReactiveSimple(val, key2, val[key2]);
6996
- } catch (e) {
6997
- }
6998
- });
6999
6979
  }
7000
6980
  }
7001
- const i = obj.$;
7002
- if (i && obj === i.proxy) {
7003
- defineReactiveSimple(i.ctx, key, val);
7004
- i.accessCache = /* @__PURE__ */ Object.create(null);
7005
- } else if (isReactive(obj)) {
7006
- obj[key] = val;
7007
- } else {
7008
- defineReactiveSimple(obj, key, val);
6981
+ const res = [normalized, needCastKeys];
6982
+ if (isObject(comp)) {
6983
+ cache.set(comp, res);
6984
+ }
6985
+ return res;
6986
+ }
6987
+ function validatePropName(key) {
6988
+ if (key[0] !== "$") {
6989
+ return true;
6990
+ } else if (process.env.NODE_ENV !== "production") {
6991
+ warn(`Invalid prop name: "${key}" is a reserved property.`);
7009
6992
  }
6993
+ return false;
7010
6994
  }
7011
- function defineReactiveSimple(obj, key, val) {
7012
- val = isObject(val) ? reactive(val) : val;
7013
- Object.defineProperty(obj, key, {
7014
- enumerable: true,
7015
- configurable: true,
7016
- get() {
7017
- track(obj, "get", key);
7018
- return val;
7019
- },
7020
- set(newVal) {
7021
- val = isObject(newVal) ? reactive(newVal) : newVal;
7022
- trigger(obj, "set", key, newVal);
6995
+ function getType(ctor) {
6996
+ const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
6997
+ return match ? match[2] : ctor === null ? "null" : "";
6998
+ }
6999
+ function isSameType(a, b) {
7000
+ return getType(a) === getType(b);
7001
+ }
7002
+ function getTypeIndex(type, expectedTypes) {
7003
+ if (isArray(expectedTypes)) {
7004
+ return expectedTypes.findIndex((t) => isSameType(t, type));
7005
+ } else if (isFunction(expectedTypes)) {
7006
+ return isSameType(expectedTypes, type) ? 0 : -1;
7007
+ }
7008
+ return -1;
7009
+ }
7010
+ function validateProps(rawProps, props, instance) {
7011
+ const resolvedValues = toRaw(props);
7012
+ const options = instance.propsOptions[0];
7013
+ for (const key in options) {
7014
+ let opt = options[key];
7015
+ if (opt == null)
7016
+ continue;
7017
+ validateProp(
7018
+ key,
7019
+ resolvedValues[key],
7020
+ opt,
7021
+ !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
7022
+ );
7023
+ }
7024
+ }
7025
+ function validateProp(name, value, prop, isAbsent) {
7026
+ const { type, required, validator, skipCheck } = prop;
7027
+ if (required && isAbsent) {
7028
+ warn('Missing required prop: "' + name + '"');
7029
+ return;
7030
+ }
7031
+ if (value == null && !required) {
7032
+ return;
7033
+ }
7034
+ if (type != null && type !== true && !skipCheck) {
7035
+ let isValid = false;
7036
+ const types = isArray(type) ? type : [type];
7037
+ const expectedTypes = [];
7038
+ for (let i = 0; i < types.length && !isValid; i++) {
7039
+ const { valid, expectedType } = assertType(value, types[i]);
7040
+ expectedTypes.push(expectedType || "");
7041
+ isValid = valid;
7023
7042
  }
7024
- });
7043
+ if (!isValid) {
7044
+ warn(getInvalidTypeMessage(name, value, expectedTypes));
7045
+ return;
7046
+ }
7047
+ }
7048
+ if (validator && !validator(value)) {
7049
+ warn('Invalid prop: custom validator check failed for prop "' + name + '".');
7050
+ }
7025
7051
  }
7026
-
7027
- function createAppContext() {
7052
+ const isSimpleType = /* @__PURE__ */ makeMap(
7053
+ "String,Number,Boolean,Function,Symbol,BigInt"
7054
+ );
7055
+ function assertType(value, type) {
7056
+ let valid;
7057
+ const expectedType = getType(type);
7058
+ if (isSimpleType(expectedType)) {
7059
+ const t = typeof value;
7060
+ valid = t === expectedType.toLowerCase();
7061
+ if (!valid && t === "object") {
7062
+ valid = value instanceof type;
7063
+ }
7064
+ } else if (expectedType === "Object") {
7065
+ valid = isObject(value);
7066
+ } else if (expectedType === "Array") {
7067
+ valid = isArray(value);
7068
+ } else if (expectedType === "null") {
7069
+ valid = value === null;
7070
+ } else {
7071
+ valid = value instanceof type;
7072
+ }
7028
7073
  return {
7029
- app: null,
7030
- config: {
7031
- isNativeTag: NO,
7032
- performance: false,
7033
- globalProperties: {},
7034
- optionMergeStrategies: {},
7035
- errorHandler: void 0,
7036
- warnHandler: void 0,
7037
- compilerOptions: {}
7038
- },
7039
- mixins: [],
7040
- components: {},
7041
- directives: {},
7042
- provides: /* @__PURE__ */ Object.create(null),
7043
- optionsCache: /* @__PURE__ */ new WeakMap(),
7044
- propsCache: /* @__PURE__ */ new WeakMap(),
7045
- emitsCache: /* @__PURE__ */ new WeakMap()
7074
+ valid,
7075
+ expectedType
7046
7076
  };
7047
7077
  }
7048
- let uid$1 = 0;
7049
- function createAppAPI(render, hydrate) {
7050
- return function createApp(rootComponent, rootProps = null) {
7051
- if (!isFunction(rootComponent)) {
7052
- rootComponent = extend({}, rootComponent);
7078
+ function getInvalidTypeMessage(name, value, expectedTypes) {
7079
+ let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7080
+ const expectedType = expectedTypes[0];
7081
+ const receivedType = toRawType(value);
7082
+ const expectedValue = styleValue(value, expectedType);
7083
+ const receivedValue = styleValue(value, receivedType);
7084
+ if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
7085
+ message += ` with value ${expectedValue}`;
7086
+ }
7087
+ message += `, got ${receivedType} `;
7088
+ if (isExplicable(receivedType)) {
7089
+ message += `with value ${receivedValue}.`;
7090
+ }
7091
+ return message;
7092
+ }
7093
+ function styleValue(value, type) {
7094
+ if (type === "String") {
7095
+ return `"${value}"`;
7096
+ } else if (type === "Number") {
7097
+ return `${Number(value)}`;
7098
+ } else {
7099
+ return `${value}`;
7100
+ }
7101
+ }
7102
+ function isExplicable(type) {
7103
+ const explicitTypes = ["string", "number", "boolean"];
7104
+ return explicitTypes.some((elem) => type.toLowerCase() === elem);
7105
+ }
7106
+ function isBoolean(...args) {
7107
+ return args.some((elem) => elem.toLowerCase() === "boolean");
7108
+ }
7109
+
7110
+ const isInternalKey = (key) => key[0] === "_" || key === "$stable";
7111
+ const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
7112
+ const normalizeSlot = (key, rawSlot, ctx) => {
7113
+ if (rawSlot._n) {
7114
+ return rawSlot;
7115
+ }
7116
+ const normalized = withCtx((...args) => {
7117
+ if (process.env.NODE_ENV !== "production" && currentInstance) {
7118
+ warn(
7119
+ `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.`
7120
+ );
7053
7121
  }
7054
- if (rootProps != null && !isObject(rootProps)) {
7055
- process.env.NODE_ENV !== "production" && warn(`root props passed to app.mount() must be an object.`);
7056
- rootProps = null;
7122
+ return normalizeSlotValue(rawSlot(...args));
7123
+ }, ctx);
7124
+ normalized._c = false;
7125
+ return normalized;
7126
+ };
7127
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
7128
+ const ctx = rawSlots._ctx;
7129
+ for (const key in rawSlots) {
7130
+ if (isInternalKey(key))
7131
+ continue;
7132
+ const value = rawSlots[key];
7133
+ if (isFunction(value)) {
7134
+ slots[key] = normalizeSlot(key, value, ctx);
7135
+ } else if (value != null) {
7136
+ if (process.env.NODE_ENV !== "production" && !isCompatEnabled("RENDER_FUNCTION", instance)) {
7137
+ warn(
7138
+ `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
7139
+ );
7140
+ }
7141
+ const normalized = normalizeSlotValue(value);
7142
+ slots[key] = () => normalized;
7057
7143
  }
7058
- const context = createAppContext();
7059
- const installedPlugins = /* @__PURE__ */ new Set();
7060
- let isMounted = false;
7061
- const app = context.app = {
7062
- _uid: uid$1++,
7063
- _component: rootComponent,
7064
- _props: rootProps,
7065
- _container: null,
7066
- _context: context,
7067
- _instance: null,
7068
- version,
7069
- get config() {
7070
- return context.config;
7071
- },
7072
- set config(v) {
7073
- if (process.env.NODE_ENV !== "production") {
7074
- warn(
7075
- `app.config cannot be replaced. Modify individual options instead.`
7076
- );
7077
- }
7078
- },
7079
- use(plugin, ...options) {
7080
- if (installedPlugins.has(plugin)) {
7081
- process.env.NODE_ENV !== "production" && warn(`Plugin has already been applied to target app.`);
7082
- } else if (plugin && isFunction(plugin.install)) {
7083
- installedPlugins.add(plugin);
7084
- plugin.install(app, ...options);
7085
- } else if (isFunction(plugin)) {
7086
- installedPlugins.add(plugin);
7087
- plugin(app, ...options);
7088
- } else if (process.env.NODE_ENV !== "production") {
7089
- warn(
7090
- `A plugin must either be a function or an object with an "install" function.`
7091
- );
7092
- }
7093
- return app;
7094
- },
7095
- mixin(mixin) {
7096
- if (__VUE_OPTIONS_API__) {
7097
- if (!context.mixins.includes(mixin)) {
7098
- context.mixins.push(mixin);
7099
- } else if (process.env.NODE_ENV !== "production") {
7100
- warn(
7101
- "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
7102
- );
7103
- }
7104
- } else if (process.env.NODE_ENV !== "production") {
7105
- warn("Mixins are only available in builds supporting Options API");
7106
- }
7107
- return app;
7108
- },
7109
- component(name, component) {
7110
- if (process.env.NODE_ENV !== "production") {
7111
- validateComponentName(name, context.config);
7112
- }
7113
- if (!component) {
7114
- return context.components[name];
7115
- }
7116
- if (process.env.NODE_ENV !== "production" && context.components[name]) {
7117
- warn(`Component "${name}" has already been registered in target app.`);
7118
- }
7119
- context.components[name] = component;
7120
- return app;
7121
- },
7122
- directive(name, directive) {
7123
- if (process.env.NODE_ENV !== "production") {
7124
- validateDirectiveName(name);
7125
- }
7126
- if (!directive) {
7127
- return context.directives[name];
7128
- }
7129
- if (process.env.NODE_ENV !== "production" && context.directives[name]) {
7130
- warn(`Directive "${name}" has already been registered in target app.`);
7131
- }
7132
- context.directives[name] = directive;
7133
- return app;
7134
- },
7135
- mount(rootContainer, isHydrate, isSVG) {
7136
- if (!isMounted) {
7137
- if (process.env.NODE_ENV !== "production" && rootContainer.__vue_app__) {
7138
- warn(
7139
- `There is already an app instance mounted on the host container.
7140
- If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
7141
- );
7142
- }
7143
- const vnode = createVNode(
7144
- rootComponent,
7145
- rootProps
7146
- );
7147
- vnode.appContext = context;
7148
- if (process.env.NODE_ENV !== "production") {
7149
- context.reload = () => {
7150
- render(cloneVNode(vnode), rootContainer, isSVG);
7151
- };
7152
- }
7153
- if (isHydrate && hydrate) {
7154
- hydrate(vnode, rootContainer);
7155
- } else {
7156
- render(vnode, rootContainer, isSVG);
7157
- }
7158
- isMounted = true;
7159
- app._container = rootContainer;
7160
- rootContainer.__vue_app__ = app;
7161
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
7162
- app._instance = vnode.component;
7163
- devtoolsInitApp(app, version);
7164
- }
7165
- return getExposeProxy(vnode.component) || vnode.component.proxy;
7166
- } else if (process.env.NODE_ENV !== "production") {
7167
- warn(
7168
- `App has already been mounted.
7169
- 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)\``
7170
- );
7171
- }
7172
- },
7173
- unmount() {
7174
- if (isMounted) {
7175
- render(null, app._container);
7176
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
7177
- app._instance = null;
7178
- devtoolsUnmountApp(app);
7179
- }
7180
- delete app._container.__vue_app__;
7181
- } else if (process.env.NODE_ENV !== "production") {
7182
- warn(`Cannot unmount an app that is not mounted.`);
7183
- }
7184
- },
7185
- provide(key, value) {
7186
- if (process.env.NODE_ENV !== "production" && key in context.provides) {
7187
- warn(
7188
- `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
7189
- );
7144
+ }
7145
+ };
7146
+ const normalizeVNodeSlots = (instance, children) => {
7147
+ if (process.env.NODE_ENV !== "production" && !isKeepAlive(instance.vnode) && !isCompatEnabled("RENDER_FUNCTION", instance)) {
7148
+ warn(
7149
+ `Non-function value encountered for default slot. Prefer function slots for better performance.`
7150
+ );
7151
+ }
7152
+ const normalized = normalizeSlotValue(children);
7153
+ instance.slots.default = () => normalized;
7154
+ };
7155
+ const initSlots = (instance, children) => {
7156
+ if (instance.vnode.shapeFlag & 32) {
7157
+ const type = children._;
7158
+ if (type) {
7159
+ instance.slots = toRaw(children);
7160
+ def(children, "_", type);
7161
+ } else {
7162
+ normalizeObjectSlots(
7163
+ children,
7164
+ instance.slots = {},
7165
+ instance
7166
+ );
7167
+ }
7168
+ } else {
7169
+ instance.slots = {};
7170
+ if (children) {
7171
+ normalizeVNodeSlots(instance, children);
7172
+ }
7173
+ }
7174
+ def(instance.slots, InternalObjectKey, 1);
7175
+ };
7176
+ const updateSlots = (instance, children, optimized) => {
7177
+ const { vnode, slots } = instance;
7178
+ let needDeletionCheck = true;
7179
+ let deletionComparisonTarget = EMPTY_OBJ;
7180
+ if (vnode.shapeFlag & 32) {
7181
+ const type = children._;
7182
+ if (type) {
7183
+ if (process.env.NODE_ENV !== "production" && isHmrUpdating) {
7184
+ extend(slots, children);
7185
+ } else if (optimized && type === 1) {
7186
+ needDeletionCheck = false;
7187
+ } else {
7188
+ extend(slots, children);
7189
+ if (!optimized && type === 1) {
7190
+ delete slots._;
7190
7191
  }
7191
- context.provides[key] = value;
7192
- return app;
7193
7192
  }
7194
- };
7195
- {
7196
- installAppCompatProperties(app, context, render);
7193
+ } else {
7194
+ needDeletionCheck = !children.$stable;
7195
+ normalizeObjectSlots(children, slots, instance);
7197
7196
  }
7198
- return app;
7199
- };
7200
- }
7197
+ deletionComparisonTarget = children;
7198
+ } else if (children) {
7199
+ normalizeVNodeSlots(instance, children);
7200
+ deletionComparisonTarget = { default: 1 };
7201
+ }
7202
+ if (needDeletionCheck) {
7203
+ for (const key in slots) {
7204
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
7205
+ delete slots[key];
7206
+ }
7207
+ }
7208
+ }
7209
+ };
7201
7210
 
7202
7211
  function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
7203
7212
  if (isArray(rawRef)) {
@@ -10408,6 +10417,12 @@ function defineSlots() {
10408
10417
  if (process.env.NODE_ENV !== "production") {
10409
10418
  warnRuntimeUsage(`defineSlots`);
10410
10419
  }
10420
+ return null;
10421
+ }
10422
+ function defineModel() {
10423
+ if (process.env.NODE_ENV !== "production") {
10424
+ warnRuntimeUsage("defineModel");
10425
+ }
10411
10426
  }
10412
10427
  function withDefaults(props, defaults) {
10413
10428
  if (process.env.NODE_ENV !== "production") {
@@ -10421,6 +10436,40 @@ function useSlots() {
10421
10436
  function useAttrs() {
10422
10437
  return getContext().attrs;
10423
10438
  }
10439
+ function useModel(props, name, options) {
10440
+ const i = getCurrentInstance();
10441
+ if (process.env.NODE_ENV !== "production" && !i) {
10442
+ warn(`useModel() called without active instance.`);
10443
+ return ref();
10444
+ }
10445
+ if (process.env.NODE_ENV !== "production" && !i.propsOptions[0][name]) {
10446
+ warn(`useModel() called with prop "${name}" which is not declared.`);
10447
+ return ref();
10448
+ }
10449
+ if (options && options.local) {
10450
+ const proxy = ref(props[name]);
10451
+ watch(
10452
+ () => props[name],
10453
+ (v) => proxy.value = v
10454
+ );
10455
+ watch(proxy, (value) => {
10456
+ if (value !== props[name]) {
10457
+ i.emit(`update:${name}`, value);
10458
+ }
10459
+ });
10460
+ return proxy;
10461
+ } else {
10462
+ return {
10463
+ __v_isRef: true,
10464
+ get value() {
10465
+ return props[name];
10466
+ },
10467
+ set value(value) {
10468
+ i.emit(`update:${name}`, value);
10469
+ }
10470
+ };
10471
+ }
10472
+ }
10424
10473
  function getContext() {
10425
10474
  const i = getCurrentInstance();
10426
10475
  if (process.env.NODE_ENV !== "production" && !i) {
@@ -10428,11 +10477,14 @@ function getContext() {
10428
10477
  }
10429
10478
  return i.setupContext || (i.setupContext = createSetupContext(i));
10430
10479
  }
10431
- function mergeDefaults(raw, defaults) {
10432
- const props = isArray(raw) ? raw.reduce(
10480
+ function normalizePropsOrEmits(props) {
10481
+ return isArray(props) ? props.reduce(
10433
10482
  (normalized, p) => (normalized[p] = {}, normalized),
10434
10483
  {}
10435
- ) : raw;
10484
+ ) : props;
10485
+ }
10486
+ function mergeDefaults(raw, defaults) {
10487
+ const props = normalizePropsOrEmits(raw);
10436
10488
  for (const key in defaults) {
10437
10489
  if (key.startsWith("__skip"))
10438
10490
  continue;
@@ -10454,6 +10506,13 @@ function mergeDefaults(raw, defaults) {
10454
10506
  }
10455
10507
  return props;
10456
10508
  }
10509
+ function mergeModels(a, b) {
10510
+ if (!a || !b)
10511
+ return a || b;
10512
+ if (isArray(a) && isArray(b))
10513
+ return a.concat(b);
10514
+ return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
10515
+ }
10457
10516
  function createPropsRestProxy(props, excludedKeys) {
10458
10517
  const ret = {};
10459
10518
  for (const key in props) {
@@ -10719,7 +10778,7 @@ function isMemoSame(cached, memo) {
10719
10778
  return true;
10720
10779
  }
10721
10780
 
10722
- const version = "3.3.0-alpha.7";
10781
+ const version = "3.3.0-alpha.9";
10723
10782
  const _ssrUtils = {
10724
10783
  createComponentInstance,
10725
10784
  setupComponent,
@@ -12431,6 +12490,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12431
12490
  defineCustomElement: defineCustomElement,
12432
12491
  defineEmits: defineEmits,
12433
12492
  defineExpose: defineExpose,
12493
+ defineModel: defineModel,
12434
12494
  defineOptions: defineOptions,
12435
12495
  defineProps: defineProps,
12436
12496
  defineSSRCustomElement: defineSSRCustomElement,
@@ -12458,6 +12518,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12458
12518
  isVNode: isVNode,
12459
12519
  markRaw: markRaw,
12460
12520
  mergeDefaults: mergeDefaults,
12521
+ mergeModels: mergeModels,
12461
12522
  mergeProps: mergeProps,
12462
12523
  nextTick: nextTick,
12463
12524
  normalizeClass: normalizeClass,
@@ -12516,6 +12577,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12516
12577
  useAttrs: useAttrs,
12517
12578
  useCssModule: useCssModule,
12518
12579
  useCssVars: useCssVars,
12580
+ useModel: useModel,
12519
12581
  useSSRContext: useSSRContext,
12520
12582
  useSlots: useSlots,
12521
12583
  useTransitionState: useTransitionState,
@@ -12580,4 +12642,4 @@ var Vue$1 = Vue;
12580
12642
 
12581
12643
  const { configureCompat } = Vue$1;
12582
12644
 
12583
- export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue$1 as default, 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 };
12645
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed, configureCompat, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, Vue$1 as default, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, 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, 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 };