@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.
@@ -3553,33 +3553,41 @@ function setActiveBranch(suspense, branch) {
3553
3553
  }
3554
3554
  }
3555
3555
 
3556
- function provide(key, value) {
3557
- if (!currentInstance) {
3558
- if (process.env.NODE_ENV !== "production") {
3559
- warn(`provide() can only be used inside setup().`);
3560
- }
3561
- } else {
3562
- let provides = currentInstance.provides;
3563
- const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3564
- if (parentProvides === provides) {
3565
- provides = currentInstance.provides = Object.create(parentProvides);
3566
- }
3567
- provides[key] = value;
3568
- }
3569
- }
3570
- function inject(key, defaultValue, treatDefaultAsFactory = false) {
3571
- const instance = currentInstance || currentRenderingInstance;
3572
- if (instance) {
3573
- const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
3574
- if (provides && key in provides) {
3575
- return provides[key];
3576
- } else if (arguments.length > 1) {
3577
- return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
3578
- } else if (process.env.NODE_ENV !== "production") {
3579
- warn(`injection "${String(key)}" not found.`);
3556
+ const legacyDirectiveHookMap = {
3557
+ beforeMount: "bind",
3558
+ mounted: "inserted",
3559
+ updated: ["update", "componentUpdated"],
3560
+ unmounted: "unbind"
3561
+ };
3562
+ function mapCompatDirectiveHook(name, dir, instance) {
3563
+ const mappedName = legacyDirectiveHookMap[name];
3564
+ if (mappedName) {
3565
+ if (isArray(mappedName)) {
3566
+ const hook = [];
3567
+ mappedName.forEach((mapped) => {
3568
+ const mappedHook = dir[mapped];
3569
+ if (mappedHook) {
3570
+ softAssertCompatEnabled(
3571
+ "CUSTOM_DIR",
3572
+ instance,
3573
+ mapped,
3574
+ name
3575
+ );
3576
+ hook.push(mappedHook);
3577
+ }
3578
+ });
3579
+ return hook.length ? hook : void 0;
3580
+ } else {
3581
+ if (dir[mappedName]) {
3582
+ softAssertCompatEnabled(
3583
+ "CUSTOM_DIR",
3584
+ instance,
3585
+ mappedName,
3586
+ name
3587
+ );
3588
+ }
3589
+ return dir[mappedName];
3580
3590
  }
3581
- } else if (process.env.NODE_ENV !== "production") {
3582
- warn(`inject() can only be used inside setup() or functional components.`);
3583
3591
  }
3584
3592
  }
3585
3593
 
@@ -3839,6 +3847,68 @@ function traverse(value, seen) {
3839
3847
  return value;
3840
3848
  }
3841
3849
 
3850
+ function validateDirectiveName(name) {
3851
+ if (isBuiltInDirective(name)) {
3852
+ warn("Do not use built-in directive ids as custom directive id: " + name);
3853
+ }
3854
+ }
3855
+ function withDirectives(vnode, directives) {
3856
+ const internalInstance = currentRenderingInstance;
3857
+ if (internalInstance === null) {
3858
+ process.env.NODE_ENV !== "production" && warn(`withDirectives can only be used inside render functions.`);
3859
+ return vnode;
3860
+ }
3861
+ const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
3862
+ const bindings = vnode.dirs || (vnode.dirs = []);
3863
+ for (let i = 0; i < directives.length; i++) {
3864
+ let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
3865
+ if (dir) {
3866
+ if (isFunction(dir)) {
3867
+ dir = {
3868
+ mounted: dir,
3869
+ updated: dir
3870
+ };
3871
+ }
3872
+ if (dir.deep) {
3873
+ traverse(value);
3874
+ }
3875
+ bindings.push({
3876
+ dir,
3877
+ instance,
3878
+ value,
3879
+ oldValue: void 0,
3880
+ arg,
3881
+ modifiers
3882
+ });
3883
+ }
3884
+ }
3885
+ return vnode;
3886
+ }
3887
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
3888
+ const bindings = vnode.dirs;
3889
+ const oldBindings = prevVNode && prevVNode.dirs;
3890
+ for (let i = 0; i < bindings.length; i++) {
3891
+ const binding = bindings[i];
3892
+ if (oldBindings) {
3893
+ binding.oldValue = oldBindings[i].value;
3894
+ }
3895
+ let hook = binding.dir[name];
3896
+ if (!hook) {
3897
+ hook = mapCompatDirectiveHook(name, binding.dir, instance);
3898
+ }
3899
+ if (hook) {
3900
+ pauseTracking();
3901
+ callWithAsyncErrorHandling(hook, instance, 8, [
3902
+ vnode.el,
3903
+ binding,
3904
+ vnode,
3905
+ prevVNode
3906
+ ]);
3907
+ resetTracking();
3908
+ }
3909
+ }
3910
+ }
3911
+
3842
3912
  function useTransitionState() {
3843
3913
  const state = {
3844
3914
  isMounted: false,
@@ -4645,106 +4715,6 @@ function getCompatListeners(instance) {
4645
4715
  return listeners;
4646
4716
  }
4647
4717
 
4648
- const legacyDirectiveHookMap = {
4649
- beforeMount: "bind",
4650
- mounted: "inserted",
4651
- updated: ["update", "componentUpdated"],
4652
- unmounted: "unbind"
4653
- };
4654
- function mapCompatDirectiveHook(name, dir, instance) {
4655
- const mappedName = legacyDirectiveHookMap[name];
4656
- if (mappedName) {
4657
- if (isArray(mappedName)) {
4658
- const hook = [];
4659
- mappedName.forEach((mapped) => {
4660
- const mappedHook = dir[mapped];
4661
- if (mappedHook) {
4662
- softAssertCompatEnabled(
4663
- "CUSTOM_DIR",
4664
- instance,
4665
- mapped,
4666
- name
4667
- );
4668
- hook.push(mappedHook);
4669
- }
4670
- });
4671
- return hook.length ? hook : void 0;
4672
- } else {
4673
- if (dir[mappedName]) {
4674
- softAssertCompatEnabled(
4675
- "CUSTOM_DIR",
4676
- instance,
4677
- mappedName,
4678
- name
4679
- );
4680
- }
4681
- return dir[mappedName];
4682
- }
4683
- }
4684
- }
4685
-
4686
- function validateDirectiveName(name) {
4687
- if (isBuiltInDirective(name)) {
4688
- warn("Do not use built-in directive ids as custom directive id: " + name);
4689
- }
4690
- }
4691
- function withDirectives(vnode, directives) {
4692
- const internalInstance = currentRenderingInstance;
4693
- if (internalInstance === null) {
4694
- process.env.NODE_ENV !== "production" && warn(`withDirectives can only be used inside render functions.`);
4695
- return vnode;
4696
- }
4697
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
4698
- const bindings = vnode.dirs || (vnode.dirs = []);
4699
- for (let i = 0; i < directives.length; i++) {
4700
- let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4701
- if (dir) {
4702
- if (isFunction(dir)) {
4703
- dir = {
4704
- mounted: dir,
4705
- updated: dir
4706
- };
4707
- }
4708
- if (dir.deep) {
4709
- traverse(value);
4710
- }
4711
- bindings.push({
4712
- dir,
4713
- instance,
4714
- value,
4715
- oldValue: void 0,
4716
- arg,
4717
- modifiers
4718
- });
4719
- }
4720
- }
4721
- return vnode;
4722
- }
4723
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
4724
- const bindings = vnode.dirs;
4725
- const oldBindings = prevVNode && prevVNode.dirs;
4726
- for (let i = 0; i < bindings.length; i++) {
4727
- const binding = bindings[i];
4728
- if (oldBindings) {
4729
- binding.oldValue = oldBindings[i].value;
4730
- }
4731
- let hook = binding.dir[name];
4732
- if (!hook) {
4733
- hook = mapCompatDirectiveHook(name, binding.dir, instance);
4734
- }
4735
- if (hook) {
4736
- pauseTracking();
4737
- callWithAsyncErrorHandling(hook, instance, 8, [
4738
- vnode.el,
4739
- binding,
4740
- vnode,
4741
- prevVNode
4742
- ]);
4743
- resetTracking();
4744
- }
4745
- }
4746
- }
4747
-
4748
4718
  const COMPONENTS = "components";
4749
4719
  const DIRECTIVES = "directives";
4750
4720
  const FILTERS = "filters";
@@ -6087,1182 +6057,1221 @@ function mergeWatchOptions(to, from) {
6087
6057
  return merged;
6088
6058
  }
6089
6059
 
6090
- function createPropsDefaultThis(instance, rawProps, propKey) {
6091
- return new Proxy(
6092
- {},
6093
- {
6094
- get(_, key) {
6095
- process.env.NODE_ENV !== "production" && warnDeprecation$1("PROPS_DEFAULT_THIS", null, propKey);
6096
- if (key === "$options") {
6097
- return resolveMergedOptions(instance);
6098
- }
6099
- if (key in rawProps) {
6100
- return rawProps[key];
6101
- }
6102
- const injections = instance.type.inject;
6103
- if (injections) {
6104
- if (isArray(injections)) {
6105
- if (injections.includes(key)) {
6106
- return inject(key);
6107
- }
6108
- } else if (key in injections) {
6109
- return inject(key);
6110
- }
6060
+ function installLegacyConfigWarnings(config) {
6061
+ const legacyConfigOptions = {
6062
+ silent: "CONFIG_SILENT",
6063
+ devtools: "CONFIG_DEVTOOLS",
6064
+ ignoredElements: "CONFIG_IGNORED_ELEMENTS",
6065
+ keyCodes: "CONFIG_KEY_CODES",
6066
+ productionTip: "CONFIG_PRODUCTION_TIP"
6067
+ };
6068
+ Object.keys(legacyConfigOptions).forEach((key) => {
6069
+ let val = config[key];
6070
+ Object.defineProperty(config, key, {
6071
+ enumerable: true,
6072
+ get() {
6073
+ return val;
6074
+ },
6075
+ set(newVal) {
6076
+ if (!isCopyingConfig) {
6077
+ warnDeprecation$1(legacyConfigOptions[key], null);
6111
6078
  }
6079
+ val = newVal;
6112
6080
  }
6113
- }
6114
- );
6081
+ });
6082
+ });
6115
6083
  }
6116
-
6117
- function shouldSkipAttr(key, instance) {
6118
- if (key === "is") {
6119
- return true;
6120
- }
6121
- if ((key === "class" || key === "style") && isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
6122
- return true;
6123
- }
6124
- if (isOn(key) && isCompatEnabled$1("INSTANCE_LISTENERS", instance)) {
6125
- return true;
6126
- }
6127
- if (key.startsWith("routerView") || key === "registerRouteInstance") {
6128
- return true;
6129
- }
6130
- return false;
6084
+ function installLegacyOptionMergeStrats(config) {
6085
+ config.optionMergeStrategies = new Proxy({}, {
6086
+ get(target, key) {
6087
+ if (key in target) {
6088
+ return target[key];
6089
+ }
6090
+ if (key in internalOptionMergeStrats && softAssertCompatEnabled(
6091
+ "CONFIG_OPTION_MERGE_STRATS",
6092
+ null
6093
+ )) {
6094
+ return internalOptionMergeStrats[key];
6095
+ }
6096
+ }
6097
+ });
6131
6098
  }
6132
6099
 
6133
- function initProps(instance, rawProps, isStateful, isSSR = false) {
6134
- const props = {};
6135
- const attrs = {};
6136
- def(attrs, InternalObjectKey, 1);
6137
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
6138
- setFullProps(instance, rawProps, props, attrs);
6139
- for (const key in instance.propsOptions[0]) {
6140
- if (!(key in props)) {
6141
- props[key] = void 0;
6100
+ let isCopyingConfig = false;
6101
+ let singletonApp;
6102
+ let singletonCtor;
6103
+ function createCompatVue$1(createApp, createSingletonApp) {
6104
+ singletonApp = createSingletonApp({});
6105
+ const Vue = singletonCtor = function Vue2(options = {}) {
6106
+ return createCompatApp(options, Vue2);
6107
+ };
6108
+ function createCompatApp(options = {}, Ctor) {
6109
+ assertCompatEnabled("GLOBAL_MOUNT", null);
6110
+ const { data } = options;
6111
+ if (data && !isFunction(data) && softAssertCompatEnabled("OPTIONS_DATA_FN", null)) {
6112
+ options.data = () => data;
6142
6113
  }
6143
- }
6144
- if (process.env.NODE_ENV !== "production") {
6145
- validateProps(rawProps || {}, props, instance);
6146
- }
6147
- if (isStateful) {
6148
- instance.props = isSSR ? props : shallowReactive(props);
6149
- } else {
6150
- if (!instance.type.props) {
6151
- instance.props = attrs;
6114
+ const app = createApp(options);
6115
+ if (Ctor !== Vue) {
6116
+ applySingletonPrototype(app, Ctor);
6117
+ }
6118
+ const vm = app._createRoot(options);
6119
+ if (options.el) {
6120
+ return vm.$mount(options.el);
6152
6121
  } else {
6153
- instance.props = props;
6122
+ return vm;
6154
6123
  }
6155
6124
  }
6156
- instance.attrs = attrs;
6157
- }
6158
- function isInHmrContext(instance) {
6159
- while (instance) {
6160
- if (instance.type.__hmrId)
6161
- return true;
6162
- instance = instance.parent;
6163
- }
6164
- }
6165
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
6166
- const {
6167
- props,
6168
- attrs,
6169
- vnode: { patchFlag }
6170
- } = instance;
6171
- const rawCurrentProps = toRaw(props);
6172
- const [options] = instance.propsOptions;
6173
- let hasAttrsChanged = false;
6174
- if (
6175
- // always force full diff in dev
6176
- // - #1942 if hmr is enabled with sfc component
6177
- // - vite#872 non-sfc component used by sfc component
6178
- !(process.env.NODE_ENV !== "production" && isInHmrContext(instance)) && (optimized || patchFlag > 0) && !(patchFlag & 16)
6179
- ) {
6180
- if (patchFlag & 8) {
6181
- const propsToUpdate = instance.vnode.dynamicProps;
6182
- for (let i = 0; i < propsToUpdate.length; i++) {
6183
- let key = propsToUpdate[i];
6184
- if (isEmitListener(instance.emitsOptions, key)) {
6185
- continue;
6186
- }
6187
- const value = rawProps[key];
6188
- if (options) {
6189
- if (hasOwn(attrs, key)) {
6190
- if (value !== attrs[key]) {
6191
- attrs[key] = value;
6192
- hasAttrsChanged = true;
6193
- }
6194
- } else {
6195
- const camelizedKey = camelize(key);
6196
- props[camelizedKey] = resolvePropValue(
6197
- options,
6198
- rawCurrentProps,
6199
- camelizedKey,
6200
- value,
6201
- instance,
6202
- false
6203
- /* isAbsent */
6204
- );
6205
- }
6206
- } else {
6207
- {
6208
- if (isOn(key) && key.endsWith("Native")) {
6209
- key = key.slice(0, -6);
6210
- } else if (shouldSkipAttr(key, instance)) {
6211
- continue;
6212
- }
6213
- }
6214
- if (value !== attrs[key]) {
6215
- attrs[key] = value;
6216
- hasAttrsChanged = true;
6217
- }
6218
- }
6219
- }
6125
+ Vue.version = `2.6.14-compat:${"3.3.0-alpha.9"}`;
6126
+ Vue.config = singletonApp.config;
6127
+ Vue.use = (p, ...options) => {
6128
+ if (p && isFunction(p.install)) {
6129
+ p.install(Vue, ...options);
6130
+ } else if (isFunction(p)) {
6131
+ p(Vue, ...options);
6220
6132
  }
6221
- } else {
6222
- if (setFullProps(instance, rawProps, props, attrs)) {
6223
- hasAttrsChanged = true;
6133
+ return Vue;
6134
+ };
6135
+ Vue.mixin = (m) => {
6136
+ singletonApp.mixin(m);
6137
+ return Vue;
6138
+ };
6139
+ Vue.component = (name, comp) => {
6140
+ if (comp) {
6141
+ singletonApp.component(name, comp);
6142
+ return Vue;
6143
+ } else {
6144
+ return singletonApp.component(name);
6224
6145
  }
6225
- let kebabKey;
6226
- for (const key in rawCurrentProps) {
6227
- if (!rawProps || // for camelCase
6228
- !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
6229
- // and converted to camelCase (#955)
6230
- ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
6231
- if (options) {
6232
- if (rawPrevProps && // for camelCase
6233
- (rawPrevProps[key] !== void 0 || // for kebab-case
6234
- rawPrevProps[kebabKey] !== void 0)) {
6235
- props[key] = resolvePropValue(
6236
- options,
6237
- rawCurrentProps,
6238
- key,
6239
- void 0,
6240
- instance,
6241
- true
6242
- /* isAbsent */
6243
- );
6244
- }
6245
- } else {
6246
- delete props[key];
6247
- }
6248
- }
6146
+ };
6147
+ Vue.directive = (name, dir) => {
6148
+ if (dir) {
6149
+ singletonApp.directive(name, dir);
6150
+ return Vue;
6151
+ } else {
6152
+ return singletonApp.directive(name);
6249
6153
  }
6250
- if (attrs !== rawCurrentProps) {
6251
- for (const key in attrs) {
6252
- if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
6253
- delete attrs[key];
6254
- hasAttrsChanged = true;
6255
- }
6154
+ };
6155
+ Vue.options = { _base: Vue };
6156
+ let cid = 1;
6157
+ Vue.cid = cid;
6158
+ Vue.nextTick = nextTick;
6159
+ const extendCache = /* @__PURE__ */ new WeakMap();
6160
+ function extendCtor(extendOptions = {}) {
6161
+ assertCompatEnabled("GLOBAL_EXTEND", null);
6162
+ if (isFunction(extendOptions)) {
6163
+ extendOptions = extendOptions.options;
6164
+ }
6165
+ if (extendCache.has(extendOptions)) {
6166
+ return extendCache.get(extendOptions);
6167
+ }
6168
+ const Super = this;
6169
+ function SubVue(inlineOptions) {
6170
+ if (!inlineOptions) {
6171
+ return createCompatApp(SubVue.options, SubVue);
6172
+ } else {
6173
+ return createCompatApp(
6174
+ mergeOptions(
6175
+ extend({}, SubVue.options),
6176
+ inlineOptions,
6177
+ internalOptionMergeStrats
6178
+ ),
6179
+ SubVue
6180
+ );
6256
6181
  }
6257
6182
  }
6183
+ SubVue.super = Super;
6184
+ SubVue.prototype = Object.create(Vue.prototype);
6185
+ SubVue.prototype.constructor = SubVue;
6186
+ const mergeBase = {};
6187
+ for (const key in Super.options) {
6188
+ const superValue = Super.options[key];
6189
+ mergeBase[key] = isArray(superValue) ? superValue.slice() : isObject(superValue) ? extend(/* @__PURE__ */ Object.create(null), superValue) : superValue;
6190
+ }
6191
+ SubVue.options = mergeOptions(
6192
+ mergeBase,
6193
+ extendOptions,
6194
+ internalOptionMergeStrats
6195
+ );
6196
+ SubVue.options._base = SubVue;
6197
+ SubVue.extend = extendCtor.bind(SubVue);
6198
+ SubVue.mixin = Super.mixin;
6199
+ SubVue.use = Super.use;
6200
+ SubVue.cid = ++cid;
6201
+ extendCache.set(extendOptions, SubVue);
6202
+ return SubVue;
6258
6203
  }
6259
- if (hasAttrsChanged) {
6260
- trigger(instance, "set", "$attrs");
6261
- }
6262
- if (process.env.NODE_ENV !== "production") {
6263
- validateProps(rawProps || {}, props, instance);
6264
- }
6265
- }
6266
- function setFullProps(instance, rawProps, props, attrs) {
6267
- const [options, needCastKeys] = instance.propsOptions;
6268
- let hasAttrsChanged = false;
6269
- let rawCastValues;
6270
- if (rawProps) {
6271
- for (let key in rawProps) {
6272
- if (isReservedProp(key)) {
6273
- continue;
6274
- }
6275
- {
6276
- if (key.startsWith("onHook:")) {
6277
- softAssertCompatEnabled(
6278
- "INSTANCE_EVENT_HOOKS",
6279
- instance,
6280
- key.slice(2).toLowerCase()
6281
- );
6282
- }
6283
- if (key === "inline-template") {
6284
- continue;
6285
- }
6286
- }
6287
- const value = rawProps[key];
6288
- let camelKey;
6289
- if (options && hasOwn(options, camelKey = camelize(key))) {
6290
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
6291
- props[camelKey] = value;
6292
- } else {
6293
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
6294
- }
6295
- } else if (!isEmitListener(instance.emitsOptions, key)) {
6296
- {
6297
- if (isOn(key) && key.endsWith("Native")) {
6298
- key = key.slice(0, -6);
6299
- } else if (shouldSkipAttr(key, instance)) {
6300
- continue;
6301
- }
6302
- }
6303
- if (!(key in attrs) || value !== attrs[key]) {
6304
- attrs[key] = value;
6305
- hasAttrsChanged = true;
6306
- }
6307
- }
6204
+ Vue.extend = extendCtor.bind(Vue);
6205
+ Vue.set = (target, key, value) => {
6206
+ assertCompatEnabled("GLOBAL_SET", null);
6207
+ target[key] = value;
6208
+ };
6209
+ Vue.delete = (target, key) => {
6210
+ assertCompatEnabled("GLOBAL_DELETE", null);
6211
+ delete target[key];
6212
+ };
6213
+ Vue.observable = (target) => {
6214
+ assertCompatEnabled("GLOBAL_OBSERVABLE", null);
6215
+ return reactive(target);
6216
+ };
6217
+ Vue.filter = (name, filter) => {
6218
+ if (filter) {
6219
+ singletonApp.filter(name, filter);
6220
+ return Vue;
6221
+ } else {
6222
+ return singletonApp.filter(name);
6308
6223
  }
6309
- }
6310
- if (needCastKeys) {
6311
- const rawCurrentProps = toRaw(props);
6312
- const castValues = rawCastValues || EMPTY_OBJ;
6313
- for (let i = 0; i < needCastKeys.length; i++) {
6314
- const key = needCastKeys[i];
6315
- props[key] = resolvePropValue(
6316
- options,
6317
- rawCurrentProps,
6318
- key,
6319
- castValues[key],
6320
- instance,
6321
- !hasOwn(castValues, key)
6322
- );
6224
+ };
6225
+ const util = {
6226
+ warn: process.env.NODE_ENV !== "production" ? warn : NOOP,
6227
+ extend,
6228
+ mergeOptions: (parent, child, vm) => mergeOptions(
6229
+ parent,
6230
+ child,
6231
+ vm ? void 0 : internalOptionMergeStrats
6232
+ ),
6233
+ defineReactive
6234
+ };
6235
+ Object.defineProperty(Vue, "util", {
6236
+ get() {
6237
+ assertCompatEnabled("GLOBAL_PRIVATE_UTIL", null);
6238
+ return util;
6323
6239
  }
6240
+ });
6241
+ Vue.configureCompat = configureCompat$1;
6242
+ return Vue;
6243
+ }
6244
+ function installAppCompatProperties(app, context, render) {
6245
+ installFilterMethod(app, context);
6246
+ installLegacyOptionMergeStrats(app.config);
6247
+ if (!singletonApp) {
6248
+ return;
6324
6249
  }
6325
- return hasAttrsChanged;
6250
+ installCompatMount(app, context, render);
6251
+ installLegacyAPIs(app);
6252
+ applySingletonAppMutations(app);
6253
+ if (process.env.NODE_ENV !== "production")
6254
+ installLegacyConfigWarnings(app.config);
6326
6255
  }
6327
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
6328
- const opt = options[key];
6329
- if (opt != null) {
6330
- const hasDefault = hasOwn(opt, "default");
6331
- if (hasDefault && value === void 0) {
6332
- const defaultValue = opt.default;
6333
- if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
6334
- const { propsDefaults } = instance;
6335
- if (key in propsDefaults) {
6336
- value = propsDefaults[key];
6337
- } else {
6338
- setCurrentInstance(instance);
6339
- value = propsDefaults[key] = defaultValue.call(
6340
- isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props, key) : null,
6341
- props
6342
- );
6343
- unsetCurrentInstance();
6344
- }
6345
- } else {
6346
- value = defaultValue;
6347
- }
6256
+ function installFilterMethod(app, context) {
6257
+ context.filters = {};
6258
+ app.filter = (name, filter) => {
6259
+ assertCompatEnabled("FILTERS", null);
6260
+ if (!filter) {
6261
+ return context.filters[name];
6348
6262
  }
6349
- if (opt[0 /* shouldCast */]) {
6350
- if (isAbsent && !hasDefault) {
6351
- value = false;
6352
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
6353
- value = true;
6354
- }
6263
+ if (process.env.NODE_ENV !== "production" && context.filters[name]) {
6264
+ warn(`Filter "${name}" has already been registered.`);
6355
6265
  }
6356
- }
6357
- return value;
6266
+ context.filters[name] = filter;
6267
+ return app;
6268
+ };
6358
6269
  }
6359
- function normalizePropsOptions(comp, appContext, asMixin = false) {
6360
- const cache = appContext.propsCache;
6361
- const cached = cache.get(comp);
6362
- if (cached) {
6363
- return cached;
6364
- }
6365
- const raw = comp.props;
6366
- const normalized = {};
6367
- const needCastKeys = [];
6368
- let hasExtends = false;
6369
- if (__VUE_OPTIONS_API__ && !isFunction(comp)) {
6370
- const extendProps = (raw2) => {
6371
- if (isFunction(raw2)) {
6372
- raw2 = raw2.options;
6270
+ function installLegacyAPIs(app) {
6271
+ Object.defineProperties(app, {
6272
+ // so that app.use() can work with legacy plugins that extend prototypes
6273
+ prototype: {
6274
+ get() {
6275
+ process.env.NODE_ENV !== "production" && warnDeprecation$1("GLOBAL_PROTOTYPE", null);
6276
+ return app.config.globalProperties;
6277
+ }
6278
+ },
6279
+ nextTick: { value: nextTick },
6280
+ extend: { value: singletonCtor.extend },
6281
+ set: { value: singletonCtor.set },
6282
+ delete: { value: singletonCtor.delete },
6283
+ observable: { value: singletonCtor.observable },
6284
+ util: {
6285
+ get() {
6286
+ return singletonCtor.util;
6373
6287
  }
6374
- hasExtends = true;
6375
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
6376
- extend(normalized, props);
6377
- if (keys)
6378
- needCastKeys.push(...keys);
6379
- };
6380
- if (!asMixin && appContext.mixins.length) {
6381
- appContext.mixins.forEach(extendProps);
6382
6288
  }
6383
- if (comp.extends) {
6384
- extendProps(comp.extends);
6289
+ });
6290
+ }
6291
+ function applySingletonAppMutations(app) {
6292
+ app._context.mixins = [...singletonApp._context.mixins];
6293
+ ["components", "directives", "filters"].forEach((key) => {
6294
+ app._context[key] = Object.create(singletonApp._context[key]);
6295
+ });
6296
+ isCopyingConfig = true;
6297
+ for (const key in singletonApp.config) {
6298
+ if (key === "isNativeTag")
6299
+ continue;
6300
+ if (isRuntimeOnly() && (key === "isCustomElement" || key === "compilerOptions")) {
6301
+ continue;
6385
6302
  }
6386
- if (comp.mixins) {
6387
- comp.mixins.forEach(extendProps);
6303
+ const val = singletonApp.config[key];
6304
+ app.config[key] = isObject(val) ? Object.create(val) : val;
6305
+ if (key === "ignoredElements" && isCompatEnabled$1("CONFIG_IGNORED_ELEMENTS", null) && !isRuntimeOnly() && isArray(val)) {
6306
+ app.config.compilerOptions.isCustomElement = (tag) => {
6307
+ return val.some((v) => isString(v) ? v === tag : v.test(tag));
6308
+ };
6388
6309
  }
6389
6310
  }
6390
- if (!raw && !hasExtends) {
6391
- if (isObject(comp)) {
6392
- cache.set(comp, EMPTY_ARR);
6393
- }
6394
- return EMPTY_ARR;
6311
+ isCopyingConfig = false;
6312
+ applySingletonPrototype(app, singletonCtor);
6313
+ }
6314
+ function applySingletonPrototype(app, Ctor) {
6315
+ const enabled = isCompatEnabled$1("GLOBAL_PROTOTYPE", null);
6316
+ if (enabled) {
6317
+ app.config.globalProperties = Object.create(Ctor.prototype);
6395
6318
  }
6396
- if (isArray(raw)) {
6397
- for (let i = 0; i < raw.length; i++) {
6398
- if (process.env.NODE_ENV !== "production" && !isString(raw[i])) {
6399
- warn(`props must be strings when using array syntax.`, raw[i]);
6400
- }
6401
- const normalizedKey = camelize(raw[i]);
6402
- if (validatePropName(normalizedKey)) {
6403
- normalized[normalizedKey] = EMPTY_OBJ;
6404
- }
6405
- }
6406
- } else if (raw) {
6407
- if (process.env.NODE_ENV !== "production" && !isObject(raw)) {
6408
- warn(`invalid props options`, raw);
6409
- }
6410
- for (const key in raw) {
6411
- const normalizedKey = camelize(key);
6412
- if (validatePropName(normalizedKey)) {
6413
- const opt = raw[key];
6414
- const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
6415
- if (prop) {
6416
- const booleanIndex = getTypeIndex(Boolean, prop.type);
6417
- const stringIndex = getTypeIndex(String, prop.type);
6418
- prop[0 /* shouldCast */] = booleanIndex > -1;
6419
- prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
6420
- if (booleanIndex > -1 || hasOwn(prop, "default")) {
6421
- needCastKeys.push(normalizedKey);
6422
- }
6423
- }
6319
+ let hasPrototypeAugmentations = false;
6320
+ const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
6321
+ for (const key in descriptors) {
6322
+ if (key !== "constructor") {
6323
+ hasPrototypeAugmentations = true;
6324
+ if (enabled) {
6325
+ Object.defineProperty(
6326
+ app.config.globalProperties,
6327
+ key,
6328
+ descriptors[key]
6329
+ );
6424
6330
  }
6425
6331
  }
6426
6332
  }
6427
- const res = [normalized, needCastKeys];
6428
- if (isObject(comp)) {
6429
- cache.set(comp, res);
6430
- }
6431
- return res;
6432
- }
6433
- function validatePropName(key) {
6434
- if (key[0] !== "$") {
6435
- return true;
6436
- } else if (process.env.NODE_ENV !== "production") {
6437
- warn(`Invalid prop name: "${key}" is a reserved property.`);
6438
- }
6439
- return false;
6440
- }
6441
- function getType(ctor) {
6442
- const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
6443
- return match ? match[2] : ctor === null ? "null" : "";
6444
- }
6445
- function isSameType(a, b) {
6446
- return getType(a) === getType(b);
6447
- }
6448
- function getTypeIndex(type, expectedTypes) {
6449
- if (isArray(expectedTypes)) {
6450
- return expectedTypes.findIndex((t) => isSameType(t, type));
6451
- } else if (isFunction(expectedTypes)) {
6452
- return isSameType(expectedTypes, type) ? 0 : -1;
6453
- }
6454
- return -1;
6455
- }
6456
- function validateProps(rawProps, props, instance) {
6457
- const resolvedValues = toRaw(props);
6458
- const options = instance.propsOptions[0];
6459
- for (const key in options) {
6460
- let opt = options[key];
6461
- if (opt == null)
6462
- continue;
6463
- validateProp(
6464
- key,
6465
- resolvedValues[key],
6466
- opt,
6467
- !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
6468
- );
6333
+ if (process.env.NODE_ENV !== "production" && hasPrototypeAugmentations) {
6334
+ warnDeprecation$1("GLOBAL_PROTOTYPE", null);
6469
6335
  }
6470
6336
  }
6471
- function validateProp(name, value, prop, isAbsent) {
6472
- const { type, required, validator, skipCheck } = prop;
6473
- if (required && isAbsent) {
6474
- warn('Missing required prop: "' + name + '"');
6475
- return;
6476
- }
6477
- if (value == null && !prop.required) {
6478
- return;
6479
- }
6480
- if (type != null && type !== true && !skipCheck) {
6481
- let isValid = false;
6482
- const types = isArray(type) ? type : [type];
6483
- const expectedTypes = [];
6484
- for (let i = 0; i < types.length && !isValid; i++) {
6485
- const { valid, expectedType } = assertType(value, types[i]);
6486
- expectedTypes.push(expectedType || "");
6487
- isValid = valid;
6337
+ function installCompatMount(app, context, render) {
6338
+ let isMounted = false;
6339
+ app._createRoot = (options) => {
6340
+ const component = app._component;
6341
+ const vnode = createVNode(component, options.propsData || null);
6342
+ vnode.appContext = context;
6343
+ const hasNoRender = !isFunction(component) && !component.render && !component.template;
6344
+ const emptyRender = () => {
6345
+ };
6346
+ const instance = createComponentInstance(vnode, null, null);
6347
+ if (hasNoRender) {
6348
+ instance.render = emptyRender;
6488
6349
  }
6489
- if (!isValid) {
6490
- warn(getInvalidTypeMessage(name, value, expectedTypes));
6491
- return;
6350
+ setupComponent(instance);
6351
+ vnode.component = instance;
6352
+ vnode.isCompatRoot = true;
6353
+ instance.ctx._compat_mount = (selectorOrEl) => {
6354
+ if (isMounted) {
6355
+ process.env.NODE_ENV !== "production" && warn(`Root instance is already mounted.`);
6356
+ return;
6357
+ }
6358
+ let container;
6359
+ if (typeof selectorOrEl === "string") {
6360
+ const result = document.querySelector(selectorOrEl);
6361
+ if (!result) {
6362
+ process.env.NODE_ENV !== "production" && warn(
6363
+ `Failed to mount root instance: selector "${selectorOrEl}" returned null.`
6364
+ );
6365
+ return;
6366
+ }
6367
+ container = result;
6368
+ } else {
6369
+ container = selectorOrEl || document.createElement("div");
6370
+ }
6371
+ const isSVG = container instanceof SVGElement;
6372
+ if (process.env.NODE_ENV !== "production") {
6373
+ context.reload = () => {
6374
+ const cloned = cloneVNode(vnode);
6375
+ cloned.component = null;
6376
+ render(cloned, container, isSVG);
6377
+ };
6378
+ }
6379
+ if (hasNoRender && instance.render === emptyRender) {
6380
+ if (process.env.NODE_ENV !== "production") {
6381
+ for (let i = 0; i < container.attributes.length; i++) {
6382
+ const attr = container.attributes[i];
6383
+ if (attr.name !== "v-cloak" && /^(v-|:|@)/.test(attr.name)) {
6384
+ warnDeprecation$1("GLOBAL_MOUNT_CONTAINER", null);
6385
+ break;
6386
+ }
6387
+ }
6388
+ }
6389
+ instance.render = null;
6390
+ component.template = container.innerHTML;
6391
+ finishComponentSetup(
6392
+ instance,
6393
+ false,
6394
+ true
6395
+ /* skip options */
6396
+ );
6397
+ }
6398
+ container.innerHTML = "";
6399
+ render(vnode, container, isSVG);
6400
+ if (container instanceof Element) {
6401
+ container.removeAttribute("v-cloak");
6402
+ container.setAttribute("data-v-app", "");
6403
+ }
6404
+ isMounted = true;
6405
+ app._container = container;
6406
+ container.__vue_app__ = app;
6407
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6408
+ devtoolsInitApp(app, version);
6409
+ }
6410
+ return instance.proxy;
6411
+ };
6412
+ instance.ctx._compat_destroy = () => {
6413
+ if (isMounted) {
6414
+ render(null, app._container);
6415
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6416
+ devtoolsUnmountApp(app);
6417
+ }
6418
+ delete app._container.__vue_app__;
6419
+ } else {
6420
+ const { bum, scope, um } = instance;
6421
+ if (bum) {
6422
+ invokeArrayFns(bum);
6423
+ }
6424
+ if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
6425
+ instance.emit("hook:beforeDestroy");
6426
+ }
6427
+ if (scope) {
6428
+ scope.stop();
6429
+ }
6430
+ if (um) {
6431
+ invokeArrayFns(um);
6432
+ }
6433
+ if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
6434
+ instance.emit("hook:destroyed");
6435
+ }
6436
+ }
6437
+ };
6438
+ return instance.proxy;
6439
+ };
6440
+ }
6441
+ const methodsToPatch = [
6442
+ "push",
6443
+ "pop",
6444
+ "shift",
6445
+ "unshift",
6446
+ "splice",
6447
+ "sort",
6448
+ "reverse"
6449
+ ];
6450
+ const patched = /* @__PURE__ */ new WeakSet();
6451
+ function defineReactive(obj, key, val) {
6452
+ if (isObject(val) && !isReactive(val) && !patched.has(val)) {
6453
+ const reactiveVal = reactive(val);
6454
+ if (isArray(val)) {
6455
+ methodsToPatch.forEach((m) => {
6456
+ val[m] = (...args) => {
6457
+ Array.prototype[m].call(reactiveVal, ...args);
6458
+ };
6459
+ });
6460
+ } else {
6461
+ Object.keys(val).forEach((key2) => {
6462
+ try {
6463
+ defineReactiveSimple(val, key2, val[key2]);
6464
+ } catch (e) {
6465
+ }
6466
+ });
6492
6467
  }
6493
6468
  }
6494
- if (validator && !validator(value)) {
6495
- warn('Invalid prop: custom validator check failed for prop "' + name + '".');
6469
+ const i = obj.$;
6470
+ if (i && obj === i.proxy) {
6471
+ defineReactiveSimple(i.ctx, key, val);
6472
+ i.accessCache = /* @__PURE__ */ Object.create(null);
6473
+ } else if (isReactive(obj)) {
6474
+ obj[key] = val;
6475
+ } else {
6476
+ defineReactiveSimple(obj, key, val);
6496
6477
  }
6497
6478
  }
6498
- const isSimpleType = /* @__PURE__ */ makeMap(
6499
- "String,Number,Boolean,Function,Symbol,BigInt"
6500
- );
6501
- function assertType(value, type) {
6502
- let valid;
6503
- const expectedType = getType(type);
6504
- if (isSimpleType(expectedType)) {
6505
- const t = typeof value;
6506
- valid = t === expectedType.toLowerCase();
6507
- if (!valid && t === "object") {
6508
- valid = value instanceof type;
6479
+ function defineReactiveSimple(obj, key, val) {
6480
+ val = isObject(val) ? reactive(val) : val;
6481
+ Object.defineProperty(obj, key, {
6482
+ enumerable: true,
6483
+ configurable: true,
6484
+ get() {
6485
+ track(obj, "get", key);
6486
+ return val;
6487
+ },
6488
+ set(newVal) {
6489
+ val = isObject(newVal) ? reactive(newVal) : newVal;
6490
+ trigger(obj, "set", key, newVal);
6509
6491
  }
6510
- } else if (expectedType === "Object") {
6511
- valid = isObject(value);
6512
- } else if (expectedType === "Array") {
6513
- valid = isArray(value);
6514
- } else if (expectedType === "null") {
6515
- valid = value === null;
6516
- } else {
6517
- valid = value instanceof type;
6518
- }
6492
+ });
6493
+ }
6494
+
6495
+ function createAppContext() {
6519
6496
  return {
6520
- valid,
6521
- expectedType
6497
+ app: null,
6498
+ config: {
6499
+ isNativeTag: NO,
6500
+ performance: false,
6501
+ globalProperties: {},
6502
+ optionMergeStrategies: {},
6503
+ errorHandler: void 0,
6504
+ warnHandler: void 0,
6505
+ compilerOptions: {}
6506
+ },
6507
+ mixins: [],
6508
+ components: {},
6509
+ directives: {},
6510
+ provides: /* @__PURE__ */ Object.create(null),
6511
+ optionsCache: /* @__PURE__ */ new WeakMap(),
6512
+ propsCache: /* @__PURE__ */ new WeakMap(),
6513
+ emitsCache: /* @__PURE__ */ new WeakMap()
6522
6514
  };
6523
6515
  }
6524
- function getInvalidTypeMessage(name, value, expectedTypes) {
6525
- let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
6526
- const expectedType = expectedTypes[0];
6527
- const receivedType = toRawType(value);
6528
- const expectedValue = styleValue(value, expectedType);
6529
- const receivedValue = styleValue(value, receivedType);
6530
- if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
6531
- message += ` with value ${expectedValue}`;
6532
- }
6533
- message += `, got ${receivedType} `;
6534
- if (isExplicable(receivedType)) {
6535
- message += `with value ${receivedValue}.`;
6536
- }
6537
- return message;
6538
- }
6539
- function styleValue(value, type) {
6540
- if (type === "String") {
6541
- return `"${value}"`;
6542
- } else if (type === "Number") {
6543
- return `${Number(value)}`;
6544
- } else {
6545
- return `${value}`;
6546
- }
6547
- }
6548
- function isExplicable(type) {
6549
- const explicitTypes = ["string", "number", "boolean"];
6550
- return explicitTypes.some((elem) => type.toLowerCase() === elem);
6551
- }
6552
- function isBoolean(...args) {
6553
- return args.some((elem) => elem.toLowerCase() === "boolean");
6554
- }
6555
-
6556
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
6557
- const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
6558
- const normalizeSlot = (key, rawSlot, ctx) => {
6559
- if (rawSlot._n) {
6560
- return rawSlot;
6561
- }
6562
- const normalized = withCtx((...args) => {
6563
- if (process.env.NODE_ENV !== "production" && currentInstance) {
6564
- warn(
6565
- `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.`
6566
- );
6567
- }
6568
- return normalizeSlotValue(rawSlot(...args));
6569
- }, ctx);
6570
- normalized._c = false;
6571
- return normalized;
6572
- };
6573
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
6574
- const ctx = rawSlots._ctx;
6575
- for (const key in rawSlots) {
6576
- if (isInternalKey(key))
6577
- continue;
6578
- const value = rawSlots[key];
6579
- if (isFunction(value)) {
6580
- slots[key] = normalizeSlot(key, value, ctx);
6581
- } else if (value != null) {
6582
- if (process.env.NODE_ENV !== "production" && !isCompatEnabled$1("RENDER_FUNCTION", instance)) {
6583
- warn(
6584
- `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
6585
- );
6586
- }
6587
- const normalized = normalizeSlotValue(value);
6588
- slots[key] = () => normalized;
6589
- }
6590
- }
6591
- };
6592
- const normalizeVNodeSlots = (instance, children) => {
6593
- if (process.env.NODE_ENV !== "production" && !isKeepAlive(instance.vnode) && !isCompatEnabled$1("RENDER_FUNCTION", instance)) {
6594
- warn(
6595
- `Non-function value encountered for default slot. Prefer function slots for better performance.`
6596
- );
6597
- }
6598
- const normalized = normalizeSlotValue(children);
6599
- instance.slots.default = () => normalized;
6600
- };
6601
- const initSlots = (instance, children) => {
6602
- if (instance.vnode.shapeFlag & 32) {
6603
- const type = children._;
6604
- if (type) {
6605
- instance.slots = toRaw(children);
6606
- def(children, "_", type);
6607
- } else {
6608
- normalizeObjectSlots(
6609
- children,
6610
- instance.slots = {},
6611
- instance
6612
- );
6516
+ let uid$1 = 0;
6517
+ function createAppAPI(render, hydrate) {
6518
+ return function createApp(rootComponent, rootProps = null) {
6519
+ if (!isFunction(rootComponent)) {
6520
+ rootComponent = extend({}, rootComponent);
6613
6521
  }
6614
- } else {
6615
- instance.slots = {};
6616
- if (children) {
6617
- normalizeVNodeSlots(instance, children);
6522
+ if (rootProps != null && !isObject(rootProps)) {
6523
+ process.env.NODE_ENV !== "production" && warn(`root props passed to app.mount() must be an object.`);
6524
+ rootProps = null;
6618
6525
  }
6619
- }
6620
- def(instance.slots, InternalObjectKey, 1);
6621
- };
6622
- const updateSlots = (instance, children, optimized) => {
6623
- const { vnode, slots } = instance;
6624
- let needDeletionCheck = true;
6625
- let deletionComparisonTarget = EMPTY_OBJ;
6626
- if (vnode.shapeFlag & 32) {
6627
- const type = children._;
6628
- if (type) {
6629
- if (process.env.NODE_ENV !== "production" && isHmrUpdating) {
6630
- extend(slots, children);
6631
- } else if (optimized && type === 1) {
6632
- needDeletionCheck = false;
6633
- } else {
6634
- extend(slots, children);
6635
- if (!optimized && type === 1) {
6636
- delete slots._;
6526
+ const context = createAppContext();
6527
+ const installedPlugins = /* @__PURE__ */ new Set();
6528
+ let isMounted = false;
6529
+ const app = context.app = {
6530
+ _uid: uid$1++,
6531
+ _component: rootComponent,
6532
+ _props: rootProps,
6533
+ _container: null,
6534
+ _context: context,
6535
+ _instance: null,
6536
+ version,
6537
+ get config() {
6538
+ return context.config;
6539
+ },
6540
+ set config(v) {
6541
+ if (process.env.NODE_ENV !== "production") {
6542
+ warn(
6543
+ `app.config cannot be replaced. Modify individual options instead.`
6544
+ );
6637
6545
  }
6638
- }
6639
- } else {
6640
- needDeletionCheck = !children.$stable;
6641
- normalizeObjectSlots(children, slots, instance);
6642
- }
6643
- deletionComparisonTarget = children;
6644
- } else if (children) {
6645
- normalizeVNodeSlots(instance, children);
6646
- deletionComparisonTarget = { default: 1 };
6647
- }
6648
- if (needDeletionCheck) {
6649
- for (const key in slots) {
6650
- if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
6651
- delete slots[key];
6652
- }
6653
- }
6654
- }
6655
- };
6656
-
6657
- function installLegacyConfigWarnings(config) {
6658
- const legacyConfigOptions = {
6659
- silent: "CONFIG_SILENT",
6660
- devtools: "CONFIG_DEVTOOLS",
6661
- ignoredElements: "CONFIG_IGNORED_ELEMENTS",
6662
- keyCodes: "CONFIG_KEY_CODES",
6663
- productionTip: "CONFIG_PRODUCTION_TIP"
6664
- };
6665
- Object.keys(legacyConfigOptions).forEach((key) => {
6666
- let val = config[key];
6667
- Object.defineProperty(config, key, {
6668
- enumerable: true,
6669
- get() {
6670
- return val;
6671
6546
  },
6672
- set(newVal) {
6673
- if (!isCopyingConfig) {
6674
- warnDeprecation$1(legacyConfigOptions[key], null);
6547
+ use(plugin, ...options) {
6548
+ if (installedPlugins.has(plugin)) {
6549
+ process.env.NODE_ENV !== "production" && warn(`Plugin has already been applied to target app.`);
6550
+ } else if (plugin && isFunction(plugin.install)) {
6551
+ installedPlugins.add(plugin);
6552
+ plugin.install(app, ...options);
6553
+ } else if (isFunction(plugin)) {
6554
+ installedPlugins.add(plugin);
6555
+ plugin(app, ...options);
6556
+ } else if (process.env.NODE_ENV !== "production") {
6557
+ warn(
6558
+ `A plugin must either be a function or an object with an "install" function.`
6559
+ );
6560
+ }
6561
+ return app;
6562
+ },
6563
+ mixin(mixin) {
6564
+ if (__VUE_OPTIONS_API__) {
6565
+ if (!context.mixins.includes(mixin)) {
6566
+ context.mixins.push(mixin);
6567
+ } else if (process.env.NODE_ENV !== "production") {
6568
+ warn(
6569
+ "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
6570
+ );
6571
+ }
6572
+ } else if (process.env.NODE_ENV !== "production") {
6573
+ warn("Mixins are only available in builds supporting Options API");
6574
+ }
6575
+ return app;
6576
+ },
6577
+ component(name, component) {
6578
+ if (process.env.NODE_ENV !== "production") {
6579
+ validateComponentName(name, context.config);
6580
+ }
6581
+ if (!component) {
6582
+ return context.components[name];
6583
+ }
6584
+ if (process.env.NODE_ENV !== "production" && context.components[name]) {
6585
+ warn(`Component "${name}" has already been registered in target app.`);
6586
+ }
6587
+ context.components[name] = component;
6588
+ return app;
6589
+ },
6590
+ directive(name, directive) {
6591
+ if (process.env.NODE_ENV !== "production") {
6592
+ validateDirectiveName(name);
6593
+ }
6594
+ if (!directive) {
6595
+ return context.directives[name];
6596
+ }
6597
+ if (process.env.NODE_ENV !== "production" && context.directives[name]) {
6598
+ warn(`Directive "${name}" has already been registered in target app.`);
6599
+ }
6600
+ context.directives[name] = directive;
6601
+ return app;
6602
+ },
6603
+ mount(rootContainer, isHydrate, isSVG) {
6604
+ if (!isMounted) {
6605
+ if (process.env.NODE_ENV !== "production" && rootContainer.__vue_app__) {
6606
+ warn(
6607
+ `There is already an app instance mounted on the host container.
6608
+ If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
6609
+ );
6610
+ }
6611
+ const vnode = createVNode(
6612
+ rootComponent,
6613
+ rootProps
6614
+ );
6615
+ vnode.appContext = context;
6616
+ if (process.env.NODE_ENV !== "production") {
6617
+ context.reload = () => {
6618
+ render(cloneVNode(vnode), rootContainer, isSVG);
6619
+ };
6620
+ }
6621
+ if (isHydrate && hydrate) {
6622
+ hydrate(vnode, rootContainer);
6623
+ } else {
6624
+ render(vnode, rootContainer, isSVG);
6625
+ }
6626
+ isMounted = true;
6627
+ app._container = rootContainer;
6628
+ rootContainer.__vue_app__ = app;
6629
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6630
+ app._instance = vnode.component;
6631
+ devtoolsInitApp(app, version);
6632
+ }
6633
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
6634
+ } else if (process.env.NODE_ENV !== "production") {
6635
+ warn(
6636
+ `App has already been mounted.
6637
+ 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)\``
6638
+ );
6639
+ }
6640
+ },
6641
+ unmount() {
6642
+ if (isMounted) {
6643
+ render(null, app._container);
6644
+ if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
6645
+ app._instance = null;
6646
+ devtoolsUnmountApp(app);
6647
+ }
6648
+ delete app._container.__vue_app__;
6649
+ } else if (process.env.NODE_ENV !== "production") {
6650
+ warn(`Cannot unmount an app that is not mounted.`);
6651
+ }
6652
+ },
6653
+ provide(key, value) {
6654
+ if (process.env.NODE_ENV !== "production" && key in context.provides) {
6655
+ warn(
6656
+ `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
6657
+ );
6658
+ }
6659
+ context.provides[key] = value;
6660
+ return app;
6661
+ },
6662
+ runWithContext(fn) {
6663
+ currentApp = app;
6664
+ try {
6665
+ return fn();
6666
+ } finally {
6667
+ currentApp = null;
6675
6668
  }
6676
- val = newVal;
6677
- }
6678
- });
6679
- });
6680
- }
6681
- function installLegacyOptionMergeStrats(config) {
6682
- config.optionMergeStrategies = new Proxy({}, {
6683
- get(target, key) {
6684
- if (key in target) {
6685
- return target[key];
6686
- }
6687
- if (key in internalOptionMergeStrats && softAssertCompatEnabled(
6688
- "CONFIG_OPTION_MERGE_STRATS",
6689
- null
6690
- )) {
6691
- return internalOptionMergeStrats[key];
6692
- }
6693
- }
6694
- });
6695
- }
6696
-
6697
- let isCopyingConfig = false;
6698
- let singletonApp;
6699
- let singletonCtor;
6700
- function createCompatVue$1(createApp, createSingletonApp) {
6701
- singletonApp = createSingletonApp({});
6702
- const Vue = singletonCtor = function Vue2(options = {}) {
6703
- return createCompatApp(options, Vue2);
6704
- };
6705
- function createCompatApp(options = {}, Ctor) {
6706
- assertCompatEnabled("GLOBAL_MOUNT", null);
6707
- const { data } = options;
6708
- if (data && !isFunction(data) && softAssertCompatEnabled("OPTIONS_DATA_FN", null)) {
6709
- options.data = () => data;
6710
- }
6711
- const app = createApp(options);
6712
- if (Ctor !== Vue) {
6713
- applySingletonPrototype(app, Ctor);
6714
- }
6715
- const vm = app._createRoot(options);
6716
- if (options.el) {
6717
- return vm.$mount(options.el);
6718
- } else {
6719
- return vm;
6720
- }
6721
- }
6722
- Vue.version = `2.6.14-compat:${"3.3.0-alpha.7"}`;
6723
- Vue.config = singletonApp.config;
6724
- Vue.use = (p, ...options) => {
6725
- if (p && isFunction(p.install)) {
6726
- p.install(Vue, ...options);
6727
- } else if (isFunction(p)) {
6728
- p(Vue, ...options);
6729
- }
6730
- return Vue;
6731
- };
6732
- Vue.mixin = (m) => {
6733
- singletonApp.mixin(m);
6734
- return Vue;
6735
- };
6736
- Vue.component = (name, comp) => {
6737
- if (comp) {
6738
- singletonApp.component(name, comp);
6739
- return Vue;
6740
- } else {
6741
- return singletonApp.component(name);
6742
- }
6743
- };
6744
- Vue.directive = (name, dir) => {
6745
- if (dir) {
6746
- singletonApp.directive(name, dir);
6747
- return Vue;
6748
- } else {
6749
- return singletonApp.directive(name);
6750
- }
6751
- };
6752
- Vue.options = { _base: Vue };
6753
- let cid = 1;
6754
- Vue.cid = cid;
6755
- Vue.nextTick = nextTick;
6756
- const extendCache = /* @__PURE__ */ new WeakMap();
6757
- function extendCtor(extendOptions = {}) {
6758
- assertCompatEnabled("GLOBAL_EXTEND", null);
6759
- if (isFunction(extendOptions)) {
6760
- extendOptions = extendOptions.options;
6761
- }
6762
- if (extendCache.has(extendOptions)) {
6763
- return extendCache.get(extendOptions);
6764
- }
6765
- const Super = this;
6766
- function SubVue(inlineOptions) {
6767
- if (!inlineOptions) {
6768
- return createCompatApp(SubVue.options, SubVue);
6769
- } else {
6770
- return createCompatApp(
6771
- mergeOptions(
6772
- extend({}, SubVue.options),
6773
- inlineOptions,
6774
- internalOptionMergeStrats
6775
- ),
6776
- SubVue
6777
- );
6778
6669
  }
6670
+ };
6671
+ {
6672
+ installAppCompatProperties(app, context, render);
6779
6673
  }
6780
- SubVue.super = Super;
6781
- SubVue.prototype = Object.create(Vue.prototype);
6782
- SubVue.prototype.constructor = SubVue;
6783
- const mergeBase = {};
6784
- for (const key in Super.options) {
6785
- const superValue = Super.options[key];
6786
- mergeBase[key] = isArray(superValue) ? superValue.slice() : isObject(superValue) ? extend(/* @__PURE__ */ Object.create(null), superValue) : superValue;
6674
+ return app;
6675
+ };
6676
+ }
6677
+ let currentApp = null;
6678
+
6679
+ function provide(key, value) {
6680
+ if (!currentInstance) {
6681
+ if (process.env.NODE_ENV !== "production") {
6682
+ warn(`provide() can only be used inside setup().`);
6787
6683
  }
6788
- SubVue.options = mergeOptions(
6789
- mergeBase,
6790
- extendOptions,
6791
- internalOptionMergeStrats
6792
- );
6793
- SubVue.options._base = SubVue;
6794
- SubVue.extend = extendCtor.bind(SubVue);
6795
- SubVue.mixin = Super.mixin;
6796
- SubVue.use = Super.use;
6797
- SubVue.cid = ++cid;
6798
- extendCache.set(extendOptions, SubVue);
6799
- return SubVue;
6684
+ } else {
6685
+ let provides = currentInstance.provides;
6686
+ const parentProvides = currentInstance.parent && currentInstance.parent.provides;
6687
+ if (parentProvides === provides) {
6688
+ provides = currentInstance.provides = Object.create(parentProvides);
6689
+ }
6690
+ provides[key] = value;
6800
6691
  }
6801
- Vue.extend = extendCtor.bind(Vue);
6802
- Vue.set = (target, key, value) => {
6803
- assertCompatEnabled("GLOBAL_SET", null);
6804
- target[key] = value;
6805
- };
6806
- Vue.delete = (target, key) => {
6807
- assertCompatEnabled("GLOBAL_DELETE", null);
6808
- delete target[key];
6809
- };
6810
- Vue.observable = (target) => {
6811
- assertCompatEnabled("GLOBAL_OBSERVABLE", null);
6812
- return reactive(target);
6813
- };
6814
- Vue.filter = (name, filter) => {
6815
- if (filter) {
6816
- singletonApp.filter(name, filter);
6817
- return Vue;
6818
- } else {
6819
- return singletonApp.filter(name);
6692
+ }
6693
+ function inject(key, defaultValue, treatDefaultAsFactory = false) {
6694
+ const instance = currentInstance || currentRenderingInstance;
6695
+ if (instance || currentApp) {
6696
+ const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
6697
+ if (provides && key in provides) {
6698
+ return provides[key];
6699
+ } else if (arguments.length > 1) {
6700
+ return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
6701
+ } else if (process.env.NODE_ENV !== "production") {
6702
+ warn(`injection "${String(key)}" not found.`);
6820
6703
  }
6821
- };
6822
- const util = {
6823
- warn: process.env.NODE_ENV !== "production" ? warn : NOOP,
6824
- extend,
6825
- mergeOptions: (parent, child, vm) => mergeOptions(
6826
- parent,
6827
- child,
6828
- vm ? void 0 : internalOptionMergeStrats
6829
- ),
6830
- defineReactive
6831
- };
6832
- Object.defineProperty(Vue, "util", {
6833
- get() {
6834
- assertCompatEnabled("GLOBAL_PRIVATE_UTIL", null);
6835
- return util;
6704
+ } else if (process.env.NODE_ENV !== "production") {
6705
+ warn(`inject() can only be used inside setup() or functional components.`);
6706
+ }
6707
+ }
6708
+
6709
+ function createPropsDefaultThis(instance, rawProps, propKey) {
6710
+ return new Proxy(
6711
+ {},
6712
+ {
6713
+ get(_, key) {
6714
+ process.env.NODE_ENV !== "production" && warnDeprecation$1("PROPS_DEFAULT_THIS", null, propKey);
6715
+ if (key === "$options") {
6716
+ return resolveMergedOptions(instance);
6717
+ }
6718
+ if (key in rawProps) {
6719
+ return rawProps[key];
6720
+ }
6721
+ const injections = instance.type.inject;
6722
+ if (injections) {
6723
+ if (isArray(injections)) {
6724
+ if (injections.includes(key)) {
6725
+ return inject(key);
6726
+ }
6727
+ } else if (key in injections) {
6728
+ return inject(key);
6729
+ }
6730
+ }
6731
+ }
6836
6732
  }
6837
- });
6838
- Vue.configureCompat = configureCompat$1;
6839
- return Vue;
6733
+ );
6840
6734
  }
6841
- function installAppCompatProperties(app, context, render) {
6842
- installFilterMethod(app, context);
6843
- installLegacyOptionMergeStrats(app.config);
6844
- if (!singletonApp) {
6845
- return;
6735
+
6736
+ function shouldSkipAttr(key, instance) {
6737
+ if (key === "is") {
6738
+ return true;
6846
6739
  }
6847
- installCompatMount(app, context, render);
6848
- installLegacyAPIs(app);
6849
- applySingletonAppMutations(app);
6850
- if (process.env.NODE_ENV !== "production")
6851
- installLegacyConfigWarnings(app.config);
6740
+ if ((key === "class" || key === "style") && isCompatEnabled$1("INSTANCE_ATTRS_CLASS_STYLE", instance)) {
6741
+ return true;
6742
+ }
6743
+ if (isOn(key) && isCompatEnabled$1("INSTANCE_LISTENERS", instance)) {
6744
+ return true;
6745
+ }
6746
+ if (key.startsWith("routerView") || key === "registerRouteInstance") {
6747
+ return true;
6748
+ }
6749
+ return false;
6852
6750
  }
6853
- function installFilterMethod(app, context) {
6854
- context.filters = {};
6855
- app.filter = (name, filter) => {
6856
- assertCompatEnabled("FILTERS", null);
6857
- if (!filter) {
6858
- return context.filters[name];
6751
+
6752
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
6753
+ const props = {};
6754
+ const attrs = {};
6755
+ def(attrs, InternalObjectKey, 1);
6756
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
6757
+ setFullProps(instance, rawProps, props, attrs);
6758
+ for (const key in instance.propsOptions[0]) {
6759
+ if (!(key in props)) {
6760
+ props[key] = void 0;
6859
6761
  }
6860
- if (process.env.NODE_ENV !== "production" && context.filters[name]) {
6861
- warn(`Filter "${name}" has already been registered.`);
6762
+ }
6763
+ if (process.env.NODE_ENV !== "production") {
6764
+ validateProps(rawProps || {}, props, instance);
6765
+ }
6766
+ if (isStateful) {
6767
+ instance.props = isSSR ? props : shallowReactive(props);
6768
+ } else {
6769
+ if (!instance.type.props) {
6770
+ instance.props = attrs;
6771
+ } else {
6772
+ instance.props = props;
6862
6773
  }
6863
- context.filters[name] = filter;
6864
- return app;
6865
- };
6774
+ }
6775
+ instance.attrs = attrs;
6866
6776
  }
6867
- function installLegacyAPIs(app) {
6868
- Object.defineProperties(app, {
6869
- // so that app.use() can work with legacy plugins that extend prototypes
6870
- prototype: {
6871
- get() {
6872
- process.env.NODE_ENV !== "production" && warnDeprecation$1("GLOBAL_PROTOTYPE", null);
6873
- return app.config.globalProperties;
6874
- }
6875
- },
6876
- nextTick: { value: nextTick },
6877
- extend: { value: singletonCtor.extend },
6878
- set: { value: singletonCtor.set },
6879
- delete: { value: singletonCtor.delete },
6880
- observable: { value: singletonCtor.observable },
6881
- util: {
6882
- get() {
6883
- return singletonCtor.util;
6777
+ function isInHmrContext(instance) {
6778
+ while (instance) {
6779
+ if (instance.type.__hmrId)
6780
+ return true;
6781
+ instance = instance.parent;
6782
+ }
6783
+ }
6784
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
6785
+ const {
6786
+ props,
6787
+ attrs,
6788
+ vnode: { patchFlag }
6789
+ } = instance;
6790
+ const rawCurrentProps = toRaw(props);
6791
+ const [options] = instance.propsOptions;
6792
+ let hasAttrsChanged = false;
6793
+ if (
6794
+ // always force full diff in dev
6795
+ // - #1942 if hmr is enabled with sfc component
6796
+ // - vite#872 non-sfc component used by sfc component
6797
+ !(process.env.NODE_ENV !== "production" && isInHmrContext(instance)) && (optimized || patchFlag > 0) && !(patchFlag & 16)
6798
+ ) {
6799
+ if (patchFlag & 8) {
6800
+ const propsToUpdate = instance.vnode.dynamicProps;
6801
+ for (let i = 0; i < propsToUpdate.length; i++) {
6802
+ let key = propsToUpdate[i];
6803
+ if (isEmitListener(instance.emitsOptions, key)) {
6804
+ continue;
6805
+ }
6806
+ const value = rawProps[key];
6807
+ if (options) {
6808
+ if (hasOwn(attrs, key)) {
6809
+ if (value !== attrs[key]) {
6810
+ attrs[key] = value;
6811
+ hasAttrsChanged = true;
6812
+ }
6813
+ } else {
6814
+ const camelizedKey = camelize(key);
6815
+ props[camelizedKey] = resolvePropValue(
6816
+ options,
6817
+ rawCurrentProps,
6818
+ camelizedKey,
6819
+ value,
6820
+ instance,
6821
+ false
6822
+ /* isAbsent */
6823
+ );
6824
+ }
6825
+ } else {
6826
+ {
6827
+ if (isOn(key) && key.endsWith("Native")) {
6828
+ key = key.slice(0, -6);
6829
+ } else if (shouldSkipAttr(key, instance)) {
6830
+ continue;
6831
+ }
6832
+ }
6833
+ if (value !== attrs[key]) {
6834
+ attrs[key] = value;
6835
+ hasAttrsChanged = true;
6836
+ }
6837
+ }
6884
6838
  }
6885
6839
  }
6886
- });
6887
- }
6888
- function applySingletonAppMutations(app) {
6889
- app._context.mixins = [...singletonApp._context.mixins];
6890
- ["components", "directives", "filters"].forEach((key) => {
6891
- app._context[key] = Object.create(singletonApp._context[key]);
6892
- });
6893
- isCopyingConfig = true;
6894
- for (const key in singletonApp.config) {
6895
- if (key === "isNativeTag")
6896
- continue;
6897
- if (isRuntimeOnly() && (key === "isCustomElement" || key === "compilerOptions")) {
6898
- continue;
6840
+ } else {
6841
+ if (setFullProps(instance, rawProps, props, attrs)) {
6842
+ hasAttrsChanged = true;
6843
+ }
6844
+ let kebabKey;
6845
+ for (const key in rawCurrentProps) {
6846
+ if (!rawProps || // for camelCase
6847
+ !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
6848
+ // and converted to camelCase (#955)
6849
+ ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
6850
+ if (options) {
6851
+ if (rawPrevProps && // for camelCase
6852
+ (rawPrevProps[key] !== void 0 || // for kebab-case
6853
+ rawPrevProps[kebabKey] !== void 0)) {
6854
+ props[key] = resolvePropValue(
6855
+ options,
6856
+ rawCurrentProps,
6857
+ key,
6858
+ void 0,
6859
+ instance,
6860
+ true
6861
+ /* isAbsent */
6862
+ );
6863
+ }
6864
+ } else {
6865
+ delete props[key];
6866
+ }
6867
+ }
6899
6868
  }
6900
- const val = singletonApp.config[key];
6901
- app.config[key] = isObject(val) ? Object.create(val) : val;
6902
- if (key === "ignoredElements" && isCompatEnabled$1("CONFIG_IGNORED_ELEMENTS", null) && !isRuntimeOnly() && isArray(val)) {
6903
- app.config.compilerOptions.isCustomElement = (tag) => {
6904
- return val.some((v) => isString(v) ? v === tag : v.test(tag));
6905
- };
6869
+ if (attrs !== rawCurrentProps) {
6870
+ for (const key in attrs) {
6871
+ if (!rawProps || !hasOwn(rawProps, key) && !hasOwn(rawProps, key + "Native")) {
6872
+ delete attrs[key];
6873
+ hasAttrsChanged = true;
6874
+ }
6875
+ }
6906
6876
  }
6907
6877
  }
6908
- isCopyingConfig = false;
6909
- applySingletonPrototype(app, singletonCtor);
6910
- }
6911
- function applySingletonPrototype(app, Ctor) {
6912
- const enabled = isCompatEnabled$1("GLOBAL_PROTOTYPE", null);
6913
- if (enabled) {
6914
- app.config.globalProperties = Object.create(Ctor.prototype);
6878
+ if (hasAttrsChanged) {
6879
+ trigger(instance, "set", "$attrs");
6915
6880
  }
6916
- let hasPrototypeAugmentations = false;
6917
- const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
6918
- for (const key in descriptors) {
6919
- if (key !== "constructor") {
6920
- hasPrototypeAugmentations = true;
6921
- if (enabled) {
6922
- Object.defineProperty(
6923
- app.config.globalProperties,
6924
- key,
6925
- descriptors[key]
6926
- );
6881
+ if (process.env.NODE_ENV !== "production") {
6882
+ validateProps(rawProps || {}, props, instance);
6883
+ }
6884
+ }
6885
+ function setFullProps(instance, rawProps, props, attrs) {
6886
+ const [options, needCastKeys] = instance.propsOptions;
6887
+ let hasAttrsChanged = false;
6888
+ let rawCastValues;
6889
+ if (rawProps) {
6890
+ for (let key in rawProps) {
6891
+ if (isReservedProp(key)) {
6892
+ continue;
6893
+ }
6894
+ {
6895
+ if (key.startsWith("onHook:")) {
6896
+ softAssertCompatEnabled(
6897
+ "INSTANCE_EVENT_HOOKS",
6898
+ instance,
6899
+ key.slice(2).toLowerCase()
6900
+ );
6901
+ }
6902
+ if (key === "inline-template") {
6903
+ continue;
6904
+ }
6905
+ }
6906
+ const value = rawProps[key];
6907
+ let camelKey;
6908
+ if (options && hasOwn(options, camelKey = camelize(key))) {
6909
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
6910
+ props[camelKey] = value;
6911
+ } else {
6912
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
6913
+ }
6914
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
6915
+ {
6916
+ if (isOn(key) && key.endsWith("Native")) {
6917
+ key = key.slice(0, -6);
6918
+ } else if (shouldSkipAttr(key, instance)) {
6919
+ continue;
6920
+ }
6921
+ }
6922
+ if (!(key in attrs) || value !== attrs[key]) {
6923
+ attrs[key] = value;
6924
+ hasAttrsChanged = true;
6925
+ }
6927
6926
  }
6928
6927
  }
6929
6928
  }
6930
- if (process.env.NODE_ENV !== "production" && hasPrototypeAugmentations) {
6931
- warnDeprecation$1("GLOBAL_PROTOTYPE", null);
6929
+ if (needCastKeys) {
6930
+ const rawCurrentProps = toRaw(props);
6931
+ const castValues = rawCastValues || EMPTY_OBJ;
6932
+ for (let i = 0; i < needCastKeys.length; i++) {
6933
+ const key = needCastKeys[i];
6934
+ props[key] = resolvePropValue(
6935
+ options,
6936
+ rawCurrentProps,
6937
+ key,
6938
+ castValues[key],
6939
+ instance,
6940
+ !hasOwn(castValues, key)
6941
+ );
6942
+ }
6932
6943
  }
6944
+ return hasAttrsChanged;
6933
6945
  }
6934
- function installCompatMount(app, context, render) {
6935
- let isMounted = false;
6936
- app._createRoot = (options) => {
6937
- const component = app._component;
6938
- const vnode = createVNode(component, options.propsData || null);
6939
- vnode.appContext = context;
6940
- const hasNoRender = !isFunction(component) && !component.render && !component.template;
6941
- const emptyRender = () => {
6942
- };
6943
- const instance = createComponentInstance(vnode, null, null);
6944
- if (hasNoRender) {
6945
- instance.render = emptyRender;
6946
- }
6947
- setupComponent(instance);
6948
- vnode.component = instance;
6949
- vnode.isCompatRoot = true;
6950
- instance.ctx._compat_mount = (selectorOrEl) => {
6951
- if (isMounted) {
6952
- process.env.NODE_ENV !== "production" && warn(`Root instance is already mounted.`);
6953
- return;
6954
- }
6955
- let container;
6956
- if (typeof selectorOrEl === "string") {
6957
- const result = document.querySelector(selectorOrEl);
6958
- if (!result) {
6959
- process.env.NODE_ENV !== "production" && warn(
6960
- `Failed to mount root instance: selector "${selectorOrEl}" returned null.`
6946
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
6947
+ const opt = options[key];
6948
+ if (opt != null) {
6949
+ const hasDefault = hasOwn(opt, "default");
6950
+ if (hasDefault && value === void 0) {
6951
+ const defaultValue = opt.default;
6952
+ if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
6953
+ const { propsDefaults } = instance;
6954
+ if (key in propsDefaults) {
6955
+ value = propsDefaults[key];
6956
+ } else {
6957
+ setCurrentInstance(instance);
6958
+ value = propsDefaults[key] = defaultValue.call(
6959
+ isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props, key) : null,
6960
+ props
6961
6961
  );
6962
- return;
6962
+ unsetCurrentInstance();
6963
6963
  }
6964
- container = result;
6965
6964
  } else {
6966
- container = selectorOrEl || document.createElement("div");
6965
+ value = defaultValue;
6967
6966
  }
6968
- const isSVG = container instanceof SVGElement;
6969
- if (process.env.NODE_ENV !== "production") {
6970
- context.reload = () => {
6971
- const cloned = cloneVNode(vnode);
6972
- cloned.component = null;
6973
- render(cloned, container, isSVG);
6974
- };
6967
+ }
6968
+ if (opt[0 /* shouldCast */]) {
6969
+ if (isAbsent && !hasDefault) {
6970
+ value = false;
6971
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
6972
+ value = true;
6975
6973
  }
6976
- if (hasNoRender && instance.render === emptyRender) {
6977
- if (process.env.NODE_ENV !== "production") {
6978
- for (let i = 0; i < container.attributes.length; i++) {
6979
- const attr = container.attributes[i];
6980
- if (attr.name !== "v-cloak" && /^(v-|:|@)/.test(attr.name)) {
6981
- warnDeprecation$1("GLOBAL_MOUNT_CONTAINER", null);
6982
- break;
6983
- }
6984
- }
6985
- }
6986
- instance.render = null;
6987
- component.template = container.innerHTML;
6988
- finishComponentSetup(
6989
- instance,
6990
- false,
6991
- true
6992
- /* skip options */
6993
- );
6974
+ }
6975
+ }
6976
+ return value;
6977
+ }
6978
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
6979
+ const cache = appContext.propsCache;
6980
+ const cached = cache.get(comp);
6981
+ if (cached) {
6982
+ return cached;
6983
+ }
6984
+ const raw = comp.props;
6985
+ const normalized = {};
6986
+ const needCastKeys = [];
6987
+ let hasExtends = false;
6988
+ if (__VUE_OPTIONS_API__ && !isFunction(comp)) {
6989
+ const extendProps = (raw2) => {
6990
+ if (isFunction(raw2)) {
6991
+ raw2 = raw2.options;
6994
6992
  }
6995
- container.innerHTML = "";
6996
- render(vnode, container, isSVG);
6997
- if (container instanceof Element) {
6998
- container.removeAttribute("v-cloak");
6999
- container.setAttribute("data-v-app", "");
6993
+ hasExtends = true;
6994
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
6995
+ extend(normalized, props);
6996
+ if (keys)
6997
+ needCastKeys.push(...keys);
6998
+ };
6999
+ if (!asMixin && appContext.mixins.length) {
7000
+ appContext.mixins.forEach(extendProps);
7001
+ }
7002
+ if (comp.extends) {
7003
+ extendProps(comp.extends);
7004
+ }
7005
+ if (comp.mixins) {
7006
+ comp.mixins.forEach(extendProps);
7007
+ }
7008
+ }
7009
+ if (!raw && !hasExtends) {
7010
+ if (isObject(comp)) {
7011
+ cache.set(comp, EMPTY_ARR);
7012
+ }
7013
+ return EMPTY_ARR;
7014
+ }
7015
+ if (isArray(raw)) {
7016
+ for (let i = 0; i < raw.length; i++) {
7017
+ if (process.env.NODE_ENV !== "production" && !isString(raw[i])) {
7018
+ warn(`props must be strings when using array syntax.`, raw[i]);
7000
7019
  }
7001
- isMounted = true;
7002
- app._container = container;
7003
- container.__vue_app__ = app;
7004
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
7005
- devtoolsInitApp(app, version);
7020
+ const normalizedKey = camelize(raw[i]);
7021
+ if (validatePropName(normalizedKey)) {
7022
+ normalized[normalizedKey] = EMPTY_OBJ;
7006
7023
  }
7007
- return instance.proxy;
7008
- };
7009
- instance.ctx._compat_destroy = () => {
7010
- if (isMounted) {
7011
- render(null, app._container);
7012
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
7013
- devtoolsUnmountApp(app);
7014
- }
7015
- delete app._container.__vue_app__;
7016
- } else {
7017
- const { bum, scope, um } = instance;
7018
- if (bum) {
7019
- invokeArrayFns(bum);
7020
- }
7021
- if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
7022
- instance.emit("hook:beforeDestroy");
7023
- }
7024
- if (scope) {
7025
- scope.stop();
7026
- }
7027
- if (um) {
7028
- invokeArrayFns(um);
7029
- }
7030
- if (isCompatEnabled$1("INSTANCE_EVENT_HOOKS", instance)) {
7031
- instance.emit("hook:destroyed");
7024
+ }
7025
+ } else if (raw) {
7026
+ if (process.env.NODE_ENV !== "production" && !isObject(raw)) {
7027
+ warn(`invalid props options`, raw);
7028
+ }
7029
+ for (const key in raw) {
7030
+ const normalizedKey = camelize(key);
7031
+ if (validatePropName(normalizedKey)) {
7032
+ const opt = raw[key];
7033
+ const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
7034
+ if (prop) {
7035
+ const booleanIndex = getTypeIndex(Boolean, prop.type);
7036
+ const stringIndex = getTypeIndex(String, prop.type);
7037
+ prop[0 /* shouldCast */] = booleanIndex > -1;
7038
+ prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
7039
+ if (booleanIndex > -1 || hasOwn(prop, "default")) {
7040
+ needCastKeys.push(normalizedKey);
7041
+ }
7032
7042
  }
7033
7043
  }
7034
- };
7035
- return instance.proxy;
7036
- };
7037
- }
7038
- const methodsToPatch = [
7039
- "push",
7040
- "pop",
7041
- "shift",
7042
- "unshift",
7043
- "splice",
7044
- "sort",
7045
- "reverse"
7046
- ];
7047
- const patched = /* @__PURE__ */ new WeakSet();
7048
- function defineReactive(obj, key, val) {
7049
- if (isObject(val) && !isReactive(val) && !patched.has(val)) {
7050
- const reactiveVal = reactive(val);
7051
- if (isArray(val)) {
7052
- methodsToPatch.forEach((m) => {
7053
- val[m] = (...args) => {
7054
- Array.prototype[m].call(reactiveVal, ...args);
7055
- };
7056
- });
7057
- } else {
7058
- Object.keys(val).forEach((key2) => {
7059
- try {
7060
- defineReactiveSimple(val, key2, val[key2]);
7061
- } catch (e) {
7062
- }
7063
- });
7064
7044
  }
7065
7045
  }
7066
- const i = obj.$;
7067
- if (i && obj === i.proxy) {
7068
- defineReactiveSimple(i.ctx, key, val);
7069
- i.accessCache = /* @__PURE__ */ Object.create(null);
7070
- } else if (isReactive(obj)) {
7071
- obj[key] = val;
7072
- } else {
7073
- defineReactiveSimple(obj, key, val);
7046
+ const res = [normalized, needCastKeys];
7047
+ if (isObject(comp)) {
7048
+ cache.set(comp, res);
7049
+ }
7050
+ return res;
7051
+ }
7052
+ function validatePropName(key) {
7053
+ if (key[0] !== "$") {
7054
+ return true;
7055
+ } else if (process.env.NODE_ENV !== "production") {
7056
+ warn(`Invalid prop name: "${key}" is a reserved property.`);
7074
7057
  }
7058
+ return false;
7075
7059
  }
7076
- function defineReactiveSimple(obj, key, val) {
7077
- val = isObject(val) ? reactive(val) : val;
7078
- Object.defineProperty(obj, key, {
7079
- enumerable: true,
7080
- configurable: true,
7081
- get() {
7082
- track(obj, "get", key);
7083
- return val;
7084
- },
7085
- set(newVal) {
7086
- val = isObject(newVal) ? reactive(newVal) : newVal;
7087
- trigger(obj, "set", key, newVal);
7060
+ function getType(ctor) {
7061
+ const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
7062
+ return match ? match[2] : ctor === null ? "null" : "";
7063
+ }
7064
+ function isSameType(a, b) {
7065
+ return getType(a) === getType(b);
7066
+ }
7067
+ function getTypeIndex(type, expectedTypes) {
7068
+ if (isArray(expectedTypes)) {
7069
+ return expectedTypes.findIndex((t) => isSameType(t, type));
7070
+ } else if (isFunction(expectedTypes)) {
7071
+ return isSameType(expectedTypes, type) ? 0 : -1;
7072
+ }
7073
+ return -1;
7074
+ }
7075
+ function validateProps(rawProps, props, instance) {
7076
+ const resolvedValues = toRaw(props);
7077
+ const options = instance.propsOptions[0];
7078
+ for (const key in options) {
7079
+ let opt = options[key];
7080
+ if (opt == null)
7081
+ continue;
7082
+ validateProp(
7083
+ key,
7084
+ resolvedValues[key],
7085
+ opt,
7086
+ !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
7087
+ );
7088
+ }
7089
+ }
7090
+ function validateProp(name, value, prop, isAbsent) {
7091
+ const { type, required, validator, skipCheck } = prop;
7092
+ if (required && isAbsent) {
7093
+ warn('Missing required prop: "' + name + '"');
7094
+ return;
7095
+ }
7096
+ if (value == null && !required) {
7097
+ return;
7098
+ }
7099
+ if (type != null && type !== true && !skipCheck) {
7100
+ let isValid = false;
7101
+ const types = isArray(type) ? type : [type];
7102
+ const expectedTypes = [];
7103
+ for (let i = 0; i < types.length && !isValid; i++) {
7104
+ const { valid, expectedType } = assertType(value, types[i]);
7105
+ expectedTypes.push(expectedType || "");
7106
+ isValid = valid;
7088
7107
  }
7089
- });
7108
+ if (!isValid) {
7109
+ warn(getInvalidTypeMessage(name, value, expectedTypes));
7110
+ return;
7111
+ }
7112
+ }
7113
+ if (validator && !validator(value)) {
7114
+ warn('Invalid prop: custom validator check failed for prop "' + name + '".');
7115
+ }
7090
7116
  }
7091
-
7092
- function createAppContext() {
7117
+ const isSimpleType = /* @__PURE__ */ makeMap(
7118
+ "String,Number,Boolean,Function,Symbol,BigInt"
7119
+ );
7120
+ function assertType(value, type) {
7121
+ let valid;
7122
+ const expectedType = getType(type);
7123
+ if (isSimpleType(expectedType)) {
7124
+ const t = typeof value;
7125
+ valid = t === expectedType.toLowerCase();
7126
+ if (!valid && t === "object") {
7127
+ valid = value instanceof type;
7128
+ }
7129
+ } else if (expectedType === "Object") {
7130
+ valid = isObject(value);
7131
+ } else if (expectedType === "Array") {
7132
+ valid = isArray(value);
7133
+ } else if (expectedType === "null") {
7134
+ valid = value === null;
7135
+ } else {
7136
+ valid = value instanceof type;
7137
+ }
7093
7138
  return {
7094
- app: null,
7095
- config: {
7096
- isNativeTag: NO,
7097
- performance: false,
7098
- globalProperties: {},
7099
- optionMergeStrategies: {},
7100
- errorHandler: void 0,
7101
- warnHandler: void 0,
7102
- compilerOptions: {}
7103
- },
7104
- mixins: [],
7105
- components: {},
7106
- directives: {},
7107
- provides: /* @__PURE__ */ Object.create(null),
7108
- optionsCache: /* @__PURE__ */ new WeakMap(),
7109
- propsCache: /* @__PURE__ */ new WeakMap(),
7110
- emitsCache: /* @__PURE__ */ new WeakMap()
7139
+ valid,
7140
+ expectedType
7111
7141
  };
7112
7142
  }
7113
- let uid$1 = 0;
7114
- function createAppAPI(render, hydrate) {
7115
- return function createApp(rootComponent, rootProps = null) {
7116
- if (!isFunction(rootComponent)) {
7117
- rootComponent = extend({}, rootComponent);
7143
+ function getInvalidTypeMessage(name, value, expectedTypes) {
7144
+ let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
7145
+ const expectedType = expectedTypes[0];
7146
+ const receivedType = toRawType(value);
7147
+ const expectedValue = styleValue(value, expectedType);
7148
+ const receivedValue = styleValue(value, receivedType);
7149
+ if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
7150
+ message += ` with value ${expectedValue}`;
7151
+ }
7152
+ message += `, got ${receivedType} `;
7153
+ if (isExplicable(receivedType)) {
7154
+ message += `with value ${receivedValue}.`;
7155
+ }
7156
+ return message;
7157
+ }
7158
+ function styleValue(value, type) {
7159
+ if (type === "String") {
7160
+ return `"${value}"`;
7161
+ } else if (type === "Number") {
7162
+ return `${Number(value)}`;
7163
+ } else {
7164
+ return `${value}`;
7165
+ }
7166
+ }
7167
+ function isExplicable(type) {
7168
+ const explicitTypes = ["string", "number", "boolean"];
7169
+ return explicitTypes.some((elem) => type.toLowerCase() === elem);
7170
+ }
7171
+ function isBoolean(...args) {
7172
+ return args.some((elem) => elem.toLowerCase() === "boolean");
7173
+ }
7174
+
7175
+ const isInternalKey = (key) => key[0] === "_" || key === "$stable";
7176
+ const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
7177
+ const normalizeSlot = (key, rawSlot, ctx) => {
7178
+ if (rawSlot._n) {
7179
+ return rawSlot;
7180
+ }
7181
+ const normalized = withCtx((...args) => {
7182
+ if (process.env.NODE_ENV !== "production" && currentInstance) {
7183
+ warn(
7184
+ `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.`
7185
+ );
7118
7186
  }
7119
- if (rootProps != null && !isObject(rootProps)) {
7120
- process.env.NODE_ENV !== "production" && warn(`root props passed to app.mount() must be an object.`);
7121
- rootProps = null;
7187
+ return normalizeSlotValue(rawSlot(...args));
7188
+ }, ctx);
7189
+ normalized._c = false;
7190
+ return normalized;
7191
+ };
7192
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
7193
+ const ctx = rawSlots._ctx;
7194
+ for (const key in rawSlots) {
7195
+ if (isInternalKey(key))
7196
+ continue;
7197
+ const value = rawSlots[key];
7198
+ if (isFunction(value)) {
7199
+ slots[key] = normalizeSlot(key, value, ctx);
7200
+ } else if (value != null) {
7201
+ if (process.env.NODE_ENV !== "production" && !isCompatEnabled$1("RENDER_FUNCTION", instance)) {
7202
+ warn(
7203
+ `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
7204
+ );
7205
+ }
7206
+ const normalized = normalizeSlotValue(value);
7207
+ slots[key] = () => normalized;
7122
7208
  }
7123
- const context = createAppContext();
7124
- const installedPlugins = /* @__PURE__ */ new Set();
7125
- let isMounted = false;
7126
- const app = context.app = {
7127
- _uid: uid$1++,
7128
- _component: rootComponent,
7129
- _props: rootProps,
7130
- _container: null,
7131
- _context: context,
7132
- _instance: null,
7133
- version,
7134
- get config() {
7135
- return context.config;
7136
- },
7137
- set config(v) {
7138
- if (process.env.NODE_ENV !== "production") {
7139
- warn(
7140
- `app.config cannot be replaced. Modify individual options instead.`
7141
- );
7142
- }
7143
- },
7144
- use(plugin, ...options) {
7145
- if (installedPlugins.has(plugin)) {
7146
- process.env.NODE_ENV !== "production" && warn(`Plugin has already been applied to target app.`);
7147
- } else if (plugin && isFunction(plugin.install)) {
7148
- installedPlugins.add(plugin);
7149
- plugin.install(app, ...options);
7150
- } else if (isFunction(plugin)) {
7151
- installedPlugins.add(plugin);
7152
- plugin(app, ...options);
7153
- } else if (process.env.NODE_ENV !== "production") {
7154
- warn(
7155
- `A plugin must either be a function or an object with an "install" function.`
7156
- );
7157
- }
7158
- return app;
7159
- },
7160
- mixin(mixin) {
7161
- if (__VUE_OPTIONS_API__) {
7162
- if (!context.mixins.includes(mixin)) {
7163
- context.mixins.push(mixin);
7164
- } else if (process.env.NODE_ENV !== "production") {
7165
- warn(
7166
- "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
7167
- );
7168
- }
7169
- } else if (process.env.NODE_ENV !== "production") {
7170
- warn("Mixins are only available in builds supporting Options API");
7171
- }
7172
- return app;
7173
- },
7174
- component(name, component) {
7175
- if (process.env.NODE_ENV !== "production") {
7176
- validateComponentName(name, context.config);
7177
- }
7178
- if (!component) {
7179
- return context.components[name];
7180
- }
7181
- if (process.env.NODE_ENV !== "production" && context.components[name]) {
7182
- warn(`Component "${name}" has already been registered in target app.`);
7183
- }
7184
- context.components[name] = component;
7185
- return app;
7186
- },
7187
- directive(name, directive) {
7188
- if (process.env.NODE_ENV !== "production") {
7189
- validateDirectiveName(name);
7190
- }
7191
- if (!directive) {
7192
- return context.directives[name];
7193
- }
7194
- if (process.env.NODE_ENV !== "production" && context.directives[name]) {
7195
- warn(`Directive "${name}" has already been registered in target app.`);
7196
- }
7197
- context.directives[name] = directive;
7198
- return app;
7199
- },
7200
- mount(rootContainer, isHydrate, isSVG) {
7201
- if (!isMounted) {
7202
- if (process.env.NODE_ENV !== "production" && rootContainer.__vue_app__) {
7203
- warn(
7204
- `There is already an app instance mounted on the host container.
7205
- If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
7206
- );
7207
- }
7208
- const vnode = createVNode(
7209
- rootComponent,
7210
- rootProps
7211
- );
7212
- vnode.appContext = context;
7213
- if (process.env.NODE_ENV !== "production") {
7214
- context.reload = () => {
7215
- render(cloneVNode(vnode), rootContainer, isSVG);
7216
- };
7217
- }
7218
- if (isHydrate && hydrate) {
7219
- hydrate(vnode, rootContainer);
7220
- } else {
7221
- render(vnode, rootContainer, isSVG);
7222
- }
7223
- isMounted = true;
7224
- app._container = rootContainer;
7225
- rootContainer.__vue_app__ = app;
7226
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
7227
- app._instance = vnode.component;
7228
- devtoolsInitApp(app, version);
7229
- }
7230
- return getExposeProxy(vnode.component) || vnode.component.proxy;
7231
- } else if (process.env.NODE_ENV !== "production") {
7232
- warn(
7233
- `App has already been mounted.
7234
- 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)\``
7235
- );
7236
- }
7237
- },
7238
- unmount() {
7239
- if (isMounted) {
7240
- render(null, app._container);
7241
- if (process.env.NODE_ENV !== "production" || __VUE_PROD_DEVTOOLS__) {
7242
- app._instance = null;
7243
- devtoolsUnmountApp(app);
7244
- }
7245
- delete app._container.__vue_app__;
7246
- } else if (process.env.NODE_ENV !== "production") {
7247
- warn(`Cannot unmount an app that is not mounted.`);
7248
- }
7249
- },
7250
- provide(key, value) {
7251
- if (process.env.NODE_ENV !== "production" && key in context.provides) {
7252
- warn(
7253
- `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
7254
- );
7209
+ }
7210
+ };
7211
+ const normalizeVNodeSlots = (instance, children) => {
7212
+ if (process.env.NODE_ENV !== "production" && !isKeepAlive(instance.vnode) && !isCompatEnabled$1("RENDER_FUNCTION", instance)) {
7213
+ warn(
7214
+ `Non-function value encountered for default slot. Prefer function slots for better performance.`
7215
+ );
7216
+ }
7217
+ const normalized = normalizeSlotValue(children);
7218
+ instance.slots.default = () => normalized;
7219
+ };
7220
+ const initSlots = (instance, children) => {
7221
+ if (instance.vnode.shapeFlag & 32) {
7222
+ const type = children._;
7223
+ if (type) {
7224
+ instance.slots = toRaw(children);
7225
+ def(children, "_", type);
7226
+ } else {
7227
+ normalizeObjectSlots(
7228
+ children,
7229
+ instance.slots = {},
7230
+ instance
7231
+ );
7232
+ }
7233
+ } else {
7234
+ instance.slots = {};
7235
+ if (children) {
7236
+ normalizeVNodeSlots(instance, children);
7237
+ }
7238
+ }
7239
+ def(instance.slots, InternalObjectKey, 1);
7240
+ };
7241
+ const updateSlots = (instance, children, optimized) => {
7242
+ const { vnode, slots } = instance;
7243
+ let needDeletionCheck = true;
7244
+ let deletionComparisonTarget = EMPTY_OBJ;
7245
+ if (vnode.shapeFlag & 32) {
7246
+ const type = children._;
7247
+ if (type) {
7248
+ if (process.env.NODE_ENV !== "production" && isHmrUpdating) {
7249
+ extend(slots, children);
7250
+ } else if (optimized && type === 1) {
7251
+ needDeletionCheck = false;
7252
+ } else {
7253
+ extend(slots, children);
7254
+ if (!optimized && type === 1) {
7255
+ delete slots._;
7255
7256
  }
7256
- context.provides[key] = value;
7257
- return app;
7258
7257
  }
7259
- };
7260
- {
7261
- installAppCompatProperties(app, context, render);
7258
+ } else {
7259
+ needDeletionCheck = !children.$stable;
7260
+ normalizeObjectSlots(children, slots, instance);
7262
7261
  }
7263
- return app;
7264
- };
7265
- }
7262
+ deletionComparisonTarget = children;
7263
+ } else if (children) {
7264
+ normalizeVNodeSlots(instance, children);
7265
+ deletionComparisonTarget = { default: 1 };
7266
+ }
7267
+ if (needDeletionCheck) {
7268
+ for (const key in slots) {
7269
+ if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
7270
+ delete slots[key];
7271
+ }
7272
+ }
7273
+ }
7274
+ };
7266
7275
 
7267
7276
  function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
7268
7277
  if (isArray(rawRef)) {
@@ -10473,6 +10482,12 @@ function defineSlots() {
10473
10482
  if (process.env.NODE_ENV !== "production") {
10474
10483
  warnRuntimeUsage(`defineSlots`);
10475
10484
  }
10485
+ return null;
10486
+ }
10487
+ function defineModel() {
10488
+ if (process.env.NODE_ENV !== "production") {
10489
+ warnRuntimeUsage("defineModel");
10490
+ }
10476
10491
  }
10477
10492
  function withDefaults(props, defaults) {
10478
10493
  if (process.env.NODE_ENV !== "production") {
@@ -10486,6 +10501,40 @@ function useSlots() {
10486
10501
  function useAttrs() {
10487
10502
  return getContext().attrs;
10488
10503
  }
10504
+ function useModel(props, name, options) {
10505
+ const i = getCurrentInstance();
10506
+ if (process.env.NODE_ENV !== "production" && !i) {
10507
+ warn(`useModel() called without active instance.`);
10508
+ return ref();
10509
+ }
10510
+ if (process.env.NODE_ENV !== "production" && !i.propsOptions[0][name]) {
10511
+ warn(`useModel() called with prop "${name}" which is not declared.`);
10512
+ return ref();
10513
+ }
10514
+ if (options && options.local) {
10515
+ const proxy = ref(props[name]);
10516
+ watch(
10517
+ () => props[name],
10518
+ (v) => proxy.value = v
10519
+ );
10520
+ watch(proxy, (value) => {
10521
+ if (value !== props[name]) {
10522
+ i.emit(`update:${name}`, value);
10523
+ }
10524
+ });
10525
+ return proxy;
10526
+ } else {
10527
+ return {
10528
+ __v_isRef: true,
10529
+ get value() {
10530
+ return props[name];
10531
+ },
10532
+ set value(value) {
10533
+ i.emit(`update:${name}`, value);
10534
+ }
10535
+ };
10536
+ }
10537
+ }
10489
10538
  function getContext() {
10490
10539
  const i = getCurrentInstance();
10491
10540
  if (process.env.NODE_ENV !== "production" && !i) {
@@ -10493,11 +10542,14 @@ function getContext() {
10493
10542
  }
10494
10543
  return i.setupContext || (i.setupContext = createSetupContext(i));
10495
10544
  }
10496
- function mergeDefaults(raw, defaults) {
10497
- const props = isArray(raw) ? raw.reduce(
10545
+ function normalizePropsOrEmits(props) {
10546
+ return isArray(props) ? props.reduce(
10498
10547
  (normalized, p) => (normalized[p] = {}, normalized),
10499
10548
  {}
10500
- ) : raw;
10549
+ ) : props;
10550
+ }
10551
+ function mergeDefaults(raw, defaults) {
10552
+ const props = normalizePropsOrEmits(raw);
10501
10553
  for (const key in defaults) {
10502
10554
  if (key.startsWith("__skip"))
10503
10555
  continue;
@@ -10519,6 +10571,13 @@ function mergeDefaults(raw, defaults) {
10519
10571
  }
10520
10572
  return props;
10521
10573
  }
10574
+ function mergeModels(a, b) {
10575
+ if (!a || !b)
10576
+ return a || b;
10577
+ if (isArray(a) && isArray(b))
10578
+ return a.concat(b);
10579
+ return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
10580
+ }
10522
10581
  function createPropsRestProxy(props, excludedKeys) {
10523
10582
  const ret = {};
10524
10583
  for (const key in props) {
@@ -10784,7 +10843,7 @@ function isMemoSame(cached, memo) {
10784
10843
  return true;
10785
10844
  }
10786
10845
 
10787
- const version = "3.3.0-alpha.7";
10846
+ const version = "3.3.0-alpha.9";
10788
10847
  const _ssrUtils = {
10789
10848
  createComponentInstance,
10790
10849
  setupComponent,
@@ -12496,6 +12555,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12496
12555
  defineCustomElement: defineCustomElement,
12497
12556
  defineEmits: defineEmits,
12498
12557
  defineExpose: defineExpose,
12558
+ defineModel: defineModel,
12499
12559
  defineOptions: defineOptions,
12500
12560
  defineProps: defineProps,
12501
12561
  defineSSRCustomElement: defineSSRCustomElement,
@@ -12523,6 +12583,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12523
12583
  isVNode: isVNode,
12524
12584
  markRaw: markRaw,
12525
12585
  mergeDefaults: mergeDefaults,
12586
+ mergeModels: mergeModels,
12526
12587
  mergeProps: mergeProps,
12527
12588
  nextTick: nextTick,
12528
12589
  normalizeClass: normalizeClass,
@@ -12581,6 +12642,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12581
12642
  useAttrs: useAttrs,
12582
12643
  useCssModule: useCssModule,
12583
12644
  useCssVars: useCssVars,
12645
+ useModel: useModel,
12584
12646
  useSSRContext: useSSRContext,
12585
12647
  useSlots: useSlots,
12586
12648
  useTransitionState: useTransitionState,
@@ -16773,7 +16835,7 @@ const transformText = (node, context) => {
16773
16835
  const seen$1 = /* @__PURE__ */ new WeakSet();
16774
16836
  const transformOnce = (node, context) => {
16775
16837
  if (node.type === 1 && findDir(node, "once", true)) {
16776
- if (seen$1.has(node) || context.inVOnce) {
16838
+ if (seen$1.has(node) || context.inVOnce || context.inSSR) {
16777
16839
  return;
16778
16840
  }
16779
16841
  seen$1.add(node);
@@ -17628,4 +17690,4 @@ var Vue$1 = Vue;
17628
17690
 
17629
17691
  const { configureCompat } = Vue$1;
17630
17692
 
17631
- 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 };
17693
+ 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 };