@vue/runtime-core 3.3.0-alpha.8 → 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.
@@ -1080,28 +1080,6 @@ function setActiveBranch(suspense, branch) {
1080
1080
  }
1081
1081
  }
1082
1082
 
1083
- function provide(key, value) {
1084
- if (!currentInstance) ; else {
1085
- let provides = currentInstance.provides;
1086
- const parentProvides = currentInstance.parent && currentInstance.parent.provides;
1087
- if (parentProvides === provides) {
1088
- provides = currentInstance.provides = Object.create(parentProvides);
1089
- }
1090
- provides[key] = value;
1091
- }
1092
- }
1093
- function inject(key, defaultValue, treatDefaultAsFactory = false) {
1094
- const instance = currentInstance || currentRenderingInstance;
1095
- if (instance) {
1096
- const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;
1097
- if (provides && key in provides) {
1098
- return provides[key];
1099
- } else if (arguments.length > 1) {
1100
- return treatDefaultAsFactory && shared.isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;
1101
- } else ;
1102
- }
1103
- }
1104
-
1105
1083
  function watchEffect(effect, options) {
1106
1084
  return doWatch(effect, null, options);
1107
1085
  }
@@ -1317,6 +1295,59 @@ function traverse(value, seen) {
1317
1295
  return value;
1318
1296
  }
1319
1297
 
1298
+ function withDirectives(vnode, directives) {
1299
+ const internalInstance = currentRenderingInstance;
1300
+ if (internalInstance === null) {
1301
+ return vnode;
1302
+ }
1303
+ const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
1304
+ const bindings = vnode.dirs || (vnode.dirs = []);
1305
+ for (let i = 0; i < directives.length; i++) {
1306
+ let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
1307
+ if (dir) {
1308
+ if (shared.isFunction(dir)) {
1309
+ dir = {
1310
+ mounted: dir,
1311
+ updated: dir
1312
+ };
1313
+ }
1314
+ if (dir.deep) {
1315
+ traverse(value);
1316
+ }
1317
+ bindings.push({
1318
+ dir,
1319
+ instance,
1320
+ value,
1321
+ oldValue: void 0,
1322
+ arg,
1323
+ modifiers
1324
+ });
1325
+ }
1326
+ }
1327
+ return vnode;
1328
+ }
1329
+ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
1330
+ const bindings = vnode.dirs;
1331
+ const oldBindings = prevVNode && prevVNode.dirs;
1332
+ for (let i = 0; i < bindings.length; i++) {
1333
+ const binding = bindings[i];
1334
+ if (oldBindings) {
1335
+ binding.oldValue = oldBindings[i].value;
1336
+ }
1337
+ let hook = binding.dir[name];
1338
+ if (hook) {
1339
+ reactivity.pauseTracking();
1340
+ callWithAsyncErrorHandling(hook, instance, 8, [
1341
+ vnode.el,
1342
+ binding,
1343
+ vnode,
1344
+ prevVNode
1345
+ ]);
1346
+ reactivity.resetTracking();
1347
+ }
1348
+ }
1349
+ }
1350
+
1320
1351
  function useTransitionState() {
1321
1352
  const state = {
1322
1353
  isMounted: false,
@@ -2045,59 +2076,6 @@ function onErrorCaptured(hook, target = currentInstance) {
2045
2076
  injectHook("ec", hook, target);
2046
2077
  }
2047
2078
 
2048
- function withDirectives(vnode, directives) {
2049
- const internalInstance = currentRenderingInstance;
2050
- if (internalInstance === null) {
2051
- return vnode;
2052
- }
2053
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
2054
- const bindings = vnode.dirs || (vnode.dirs = []);
2055
- for (let i = 0; i < directives.length; i++) {
2056
- let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
2057
- if (dir) {
2058
- if (shared.isFunction(dir)) {
2059
- dir = {
2060
- mounted: dir,
2061
- updated: dir
2062
- };
2063
- }
2064
- if (dir.deep) {
2065
- traverse(value);
2066
- }
2067
- bindings.push({
2068
- dir,
2069
- instance,
2070
- value,
2071
- oldValue: void 0,
2072
- arg,
2073
- modifiers
2074
- });
2075
- }
2076
- }
2077
- return vnode;
2078
- }
2079
- function invokeDirectiveHook(vnode, prevVNode, instance, name) {
2080
- const bindings = vnode.dirs;
2081
- const oldBindings = prevVNode && prevVNode.dirs;
2082
- for (let i = 0; i < bindings.length; i++) {
2083
- const binding = bindings[i];
2084
- if (oldBindings) {
2085
- binding.oldValue = oldBindings[i].value;
2086
- }
2087
- let hook = binding.dir[name];
2088
- if (hook) {
2089
- reactivity.pauseTracking();
2090
- callWithAsyncErrorHandling(hook, instance, 8, [
2091
- vnode.el,
2092
- binding,
2093
- vnode,
2094
- prevVNode
2095
- ]);
2096
- reactivity.resetTracking();
2097
- }
2098
- }
2099
- }
2100
-
2101
2079
  const COMPONENTS = "components";
2102
2080
  const DIRECTIVES = "directives";
2103
2081
  function resolveComponent(name, maybeSelfReference) {
@@ -2722,6 +2700,148 @@ function mergeWatchOptions(to, from) {
2722
2700
  return merged;
2723
2701
  }
2724
2702
 
2703
+ function createAppContext() {
2704
+ return {
2705
+ app: null,
2706
+ config: {
2707
+ isNativeTag: shared.NO,
2708
+ performance: false,
2709
+ globalProperties: {},
2710
+ optionMergeStrategies: {},
2711
+ errorHandler: void 0,
2712
+ warnHandler: void 0,
2713
+ compilerOptions: {}
2714
+ },
2715
+ mixins: [],
2716
+ components: {},
2717
+ directives: {},
2718
+ provides: /* @__PURE__ */ Object.create(null),
2719
+ optionsCache: /* @__PURE__ */ new WeakMap(),
2720
+ propsCache: /* @__PURE__ */ new WeakMap(),
2721
+ emitsCache: /* @__PURE__ */ new WeakMap()
2722
+ };
2723
+ }
2724
+ let uid$1 = 0;
2725
+ function createAppAPI(render, hydrate) {
2726
+ return function createApp(rootComponent, rootProps = null) {
2727
+ if (!shared.isFunction(rootComponent)) {
2728
+ rootComponent = shared.extend({}, rootComponent);
2729
+ }
2730
+ if (rootProps != null && !shared.isObject(rootProps)) {
2731
+ rootProps = null;
2732
+ }
2733
+ const context = createAppContext();
2734
+ const installedPlugins = /* @__PURE__ */ new Set();
2735
+ let isMounted = false;
2736
+ const app = context.app = {
2737
+ _uid: uid$1++,
2738
+ _component: rootComponent,
2739
+ _props: rootProps,
2740
+ _container: null,
2741
+ _context: context,
2742
+ _instance: null,
2743
+ version,
2744
+ get config() {
2745
+ return context.config;
2746
+ },
2747
+ set config(v) {
2748
+ },
2749
+ use(plugin, ...options) {
2750
+ if (installedPlugins.has(plugin)) ; else if (plugin && shared.isFunction(plugin.install)) {
2751
+ installedPlugins.add(plugin);
2752
+ plugin.install(app, ...options);
2753
+ } else if (shared.isFunction(plugin)) {
2754
+ installedPlugins.add(plugin);
2755
+ plugin(app, ...options);
2756
+ } else ;
2757
+ return app;
2758
+ },
2759
+ mixin(mixin) {
2760
+ {
2761
+ if (!context.mixins.includes(mixin)) {
2762
+ context.mixins.push(mixin);
2763
+ }
2764
+ }
2765
+ return app;
2766
+ },
2767
+ component(name, component) {
2768
+ if (!component) {
2769
+ return context.components[name];
2770
+ }
2771
+ context.components[name] = component;
2772
+ return app;
2773
+ },
2774
+ directive(name, directive) {
2775
+ if (!directive) {
2776
+ return context.directives[name];
2777
+ }
2778
+ context.directives[name] = directive;
2779
+ return app;
2780
+ },
2781
+ mount(rootContainer, isHydrate, isSVG) {
2782
+ if (!isMounted) {
2783
+ const vnode = createVNode(
2784
+ rootComponent,
2785
+ rootProps
2786
+ );
2787
+ vnode.appContext = context;
2788
+ if (isHydrate && hydrate) {
2789
+ hydrate(vnode, rootContainer);
2790
+ } else {
2791
+ render(vnode, rootContainer, isSVG);
2792
+ }
2793
+ isMounted = true;
2794
+ app._container = rootContainer;
2795
+ rootContainer.__vue_app__ = app;
2796
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
2797
+ }
2798
+ },
2799
+ unmount() {
2800
+ if (isMounted) {
2801
+ render(null, app._container);
2802
+ delete app._container.__vue_app__;
2803
+ }
2804
+ },
2805
+ provide(key, value) {
2806
+ context.provides[key] = value;
2807
+ return app;
2808
+ },
2809
+ runWithContext(fn) {
2810
+ currentApp = app;
2811
+ try {
2812
+ return fn();
2813
+ } finally {
2814
+ currentApp = null;
2815
+ }
2816
+ }
2817
+ };
2818
+ return app;
2819
+ };
2820
+ }
2821
+ let currentApp = null;
2822
+
2823
+ function provide(key, value) {
2824
+ if (!currentInstance) ; else {
2825
+ let provides = currentInstance.provides;
2826
+ const parentProvides = currentInstance.parent && currentInstance.parent.provides;
2827
+ if (parentProvides === provides) {
2828
+ provides = currentInstance.provides = Object.create(parentProvides);
2829
+ }
2830
+ provides[key] = value;
2831
+ }
2832
+ }
2833
+ function inject(key, defaultValue, treatDefaultAsFactory = false) {
2834
+ const instance = currentInstance || currentRenderingInstance;
2835
+ if (instance || currentApp) {
2836
+ const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
2837
+ if (provides && key in provides) {
2838
+ return provides[key];
2839
+ } else if (arguments.length > 1) {
2840
+ return treatDefaultAsFactory && shared.isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
2841
+ } else ;
2842
+ }
2843
+ }
2844
+
2725
2845
  function initProps(instance, rawProps, isStateful, isSSR = false) {
2726
2846
  const props = {};
2727
2847
  const attrs = {};
@@ -3079,117 +3199,6 @@ const updateSlots = (instance, children, optimized) => {
3079
3199
  }
3080
3200
  };
3081
3201
 
3082
- function createAppContext() {
3083
- return {
3084
- app: null,
3085
- config: {
3086
- isNativeTag: shared.NO,
3087
- performance: false,
3088
- globalProperties: {},
3089
- optionMergeStrategies: {},
3090
- errorHandler: void 0,
3091
- warnHandler: void 0,
3092
- compilerOptions: {}
3093
- },
3094
- mixins: [],
3095
- components: {},
3096
- directives: {},
3097
- provides: /* @__PURE__ */ Object.create(null),
3098
- optionsCache: /* @__PURE__ */ new WeakMap(),
3099
- propsCache: /* @__PURE__ */ new WeakMap(),
3100
- emitsCache: /* @__PURE__ */ new WeakMap()
3101
- };
3102
- }
3103
- let uid$1 = 0;
3104
- function createAppAPI(render, hydrate) {
3105
- return function createApp(rootComponent, rootProps = null) {
3106
- if (!shared.isFunction(rootComponent)) {
3107
- rootComponent = shared.extend({}, rootComponent);
3108
- }
3109
- if (rootProps != null && !shared.isObject(rootProps)) {
3110
- rootProps = null;
3111
- }
3112
- const context = createAppContext();
3113
- const installedPlugins = /* @__PURE__ */ new Set();
3114
- let isMounted = false;
3115
- const app = context.app = {
3116
- _uid: uid$1++,
3117
- _component: rootComponent,
3118
- _props: rootProps,
3119
- _container: null,
3120
- _context: context,
3121
- _instance: null,
3122
- version,
3123
- get config() {
3124
- return context.config;
3125
- },
3126
- set config(v) {
3127
- },
3128
- use(plugin, ...options) {
3129
- if (installedPlugins.has(plugin)) ; else if (plugin && shared.isFunction(plugin.install)) {
3130
- installedPlugins.add(plugin);
3131
- plugin.install(app, ...options);
3132
- } else if (shared.isFunction(plugin)) {
3133
- installedPlugins.add(plugin);
3134
- plugin(app, ...options);
3135
- } else ;
3136
- return app;
3137
- },
3138
- mixin(mixin) {
3139
- {
3140
- if (!context.mixins.includes(mixin)) {
3141
- context.mixins.push(mixin);
3142
- }
3143
- }
3144
- return app;
3145
- },
3146
- component(name, component) {
3147
- if (!component) {
3148
- return context.components[name];
3149
- }
3150
- context.components[name] = component;
3151
- return app;
3152
- },
3153
- directive(name, directive) {
3154
- if (!directive) {
3155
- return context.directives[name];
3156
- }
3157
- context.directives[name] = directive;
3158
- return app;
3159
- },
3160
- mount(rootContainer, isHydrate, isSVG) {
3161
- if (!isMounted) {
3162
- const vnode = createVNode(
3163
- rootComponent,
3164
- rootProps
3165
- );
3166
- vnode.appContext = context;
3167
- if (isHydrate && hydrate) {
3168
- hydrate(vnode, rootContainer);
3169
- } else {
3170
- render(vnode, rootContainer, isSVG);
3171
- }
3172
- isMounted = true;
3173
- app._container = rootContainer;
3174
- rootContainer.__vue_app__ = app;
3175
- return getExposeProxy(vnode.component) || vnode.component.proxy;
3176
- }
3177
- },
3178
- unmount() {
3179
- if (isMounted) {
3180
- render(null, app._container);
3181
- delete app._container.__vue_app__;
3182
- }
3183
- },
3184
- provide(key, value) {
3185
- context.provides[key] = value;
3186
- return app;
3187
- }
3188
- };
3189
- return app;
3190
- };
3191
- }
3192
-
3193
3202
  function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3194
3203
  if (shared.isArray(rawRef)) {
3195
3204
  rawRef.forEach(
@@ -5810,6 +5819,9 @@ function defineExpose(exposed) {
5810
5819
  function defineOptions(options) {
5811
5820
  }
5812
5821
  function defineSlots() {
5822
+ return null;
5823
+ }
5824
+ function defineModel() {
5813
5825
  }
5814
5826
  function withDefaults(props, defaults) {
5815
5827
  return null;
@@ -5820,15 +5832,44 @@ function useSlots() {
5820
5832
  function useAttrs() {
5821
5833
  return getContext().attrs;
5822
5834
  }
5835
+ function useModel(props, name, options) {
5836
+ const i = getCurrentInstance();
5837
+ if (options && options.local) {
5838
+ const proxy = reactivity.ref(props[name]);
5839
+ watch(
5840
+ () => props[name],
5841
+ (v) => proxy.value = v
5842
+ );
5843
+ watch(proxy, (value) => {
5844
+ if (value !== props[name]) {
5845
+ i.emit(`update:${name}`, value);
5846
+ }
5847
+ });
5848
+ return proxy;
5849
+ } else {
5850
+ return {
5851
+ __v_isRef: true,
5852
+ get value() {
5853
+ return props[name];
5854
+ },
5855
+ set value(value) {
5856
+ i.emit(`update:${name}`, value);
5857
+ }
5858
+ };
5859
+ }
5860
+ }
5823
5861
  function getContext() {
5824
5862
  const i = getCurrentInstance();
5825
5863
  return i.setupContext || (i.setupContext = createSetupContext(i));
5826
5864
  }
5827
- function mergeDefaults(raw, defaults) {
5828
- const props = shared.isArray(raw) ? raw.reduce(
5865
+ function normalizePropsOrEmits(props) {
5866
+ return shared.isArray(props) ? props.reduce(
5829
5867
  (normalized, p) => (normalized[p] = {}, normalized),
5830
5868
  {}
5831
- ) : raw;
5869
+ ) : props;
5870
+ }
5871
+ function mergeDefaults(raw, defaults) {
5872
+ const props = normalizePropsOrEmits(raw);
5832
5873
  for (const key in defaults) {
5833
5874
  if (key.startsWith("__skip"))
5834
5875
  continue;
@@ -5848,6 +5889,13 @@ function mergeDefaults(raw, defaults) {
5848
5889
  }
5849
5890
  return props;
5850
5891
  }
5892
+ function mergeModels(a, b) {
5893
+ if (!a || !b)
5894
+ return a || b;
5895
+ if (shared.isArray(a) && shared.isArray(b))
5896
+ return a.concat(b);
5897
+ return shared.extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
5898
+ }
5851
5899
  function createPropsRestProxy(props, excludedKeys) {
5852
5900
  const ret = {};
5853
5901
  for (const key in props) {
@@ -5933,7 +5981,7 @@ function isMemoSame(cached, memo) {
5933
5981
  return true;
5934
5982
  }
5935
5983
 
5936
- const version = "3.3.0-alpha.8";
5984
+ const version = "3.3.0-alpha.9";
5937
5985
  const _ssrUtils = {
5938
5986
  createComponentInstance,
5939
5987
  setupComponent,
@@ -6010,6 +6058,7 @@ exports.defineAsyncComponent = defineAsyncComponent;
6010
6058
  exports.defineComponent = defineComponent;
6011
6059
  exports.defineEmits = defineEmits;
6012
6060
  exports.defineExpose = defineExpose;
6061
+ exports.defineModel = defineModel;
6013
6062
  exports.defineOptions = defineOptions;
6014
6063
  exports.defineProps = defineProps;
6015
6064
  exports.defineSlots = defineSlots;
@@ -6024,6 +6073,7 @@ exports.isMemoSame = isMemoSame;
6024
6073
  exports.isRuntimeOnly = isRuntimeOnly;
6025
6074
  exports.isVNode = isVNode;
6026
6075
  exports.mergeDefaults = mergeDefaults;
6076
+ exports.mergeModels = mergeModels;
6027
6077
  exports.mergeProps = mergeProps;
6028
6078
  exports.nextTick = nextTick;
6029
6079
  exports.onActivated = onActivated;
@@ -6059,6 +6109,7 @@ exports.ssrUtils = ssrUtils;
6059
6109
  exports.toHandlers = toHandlers;
6060
6110
  exports.transformVNodeArgs = transformVNodeArgs;
6061
6111
  exports.useAttrs = useAttrs;
6112
+ exports.useModel = useModel;
6062
6113
  exports.useSSRContext = useSSRContext;
6063
6114
  exports.useSlots = useSlots;
6064
6115
  exports.useTransitionState = useTransitionState;