@vue/runtime-dom 3.1.0 → 3.1.4

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.
@@ -497,34 +497,38 @@ const get = /*#__PURE__*/ createGetter();
497
497
  const shallowGet = /*#__PURE__*/ createGetter(false, true);
498
498
  const readonlyGet = /*#__PURE__*/ createGetter(true);
499
499
  const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
500
- const arrayInstrumentations = {};
501
- ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
502
- const method = Array.prototype[key];
503
- arrayInstrumentations[key] = function (...args) {
504
- const arr = toRaw(this);
505
- for (let i = 0, l = this.length; i < l; i++) {
506
- track(arr, "get" /* GET */, i + '');
507
- }
508
- // we run the method using the original args first (which may be reactive)
509
- const res = method.apply(arr, args);
510
- if (res === -1 || res === false) {
511
- // if that didn't work, run it again using raw values.
512
- return method.apply(arr, args.map(toRaw));
513
- }
514
- else {
500
+ const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
501
+ function createArrayInstrumentations() {
502
+ const instrumentations = {};
503
+ ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
504
+ const method = Array.prototype[key];
505
+ instrumentations[key] = function (...args) {
506
+ const arr = toRaw(this);
507
+ for (let i = 0, l = this.length; i < l; i++) {
508
+ track(arr, "get" /* GET */, i + '');
509
+ }
510
+ // we run the method using the original args first (which may be reactive)
511
+ const res = method.apply(arr, args);
512
+ if (res === -1 || res === false) {
513
+ // if that didn't work, run it again using raw values.
514
+ return method.apply(arr, args.map(toRaw));
515
+ }
516
+ else {
517
+ return res;
518
+ }
519
+ };
520
+ });
521
+ ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
522
+ const method = Array.prototype[key];
523
+ instrumentations[key] = function (...args) {
524
+ pauseTracking();
525
+ const res = method.apply(this, args);
526
+ resetTracking();
515
527
  return res;
516
- }
517
- };
518
- });
519
- ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
520
- const method = Array.prototype[key];
521
- arrayInstrumentations[key] = function (...args) {
522
- pauseTracking();
523
- const res = method.apply(this, args);
524
- resetTracking();
525
- return res;
526
- };
527
- });
528
+ };
529
+ });
530
+ return instrumentations;
531
+ }
528
532
  function createGetter(isReadonly = false, shallow = false) {
529
533
  return function get(target, key, receiver) {
530
534
  if (key === "__v_isReactive" /* IS_REACTIVE */) {
@@ -643,14 +647,14 @@ const readonlyHandlers = {
643
647
  return true;
644
648
  }
645
649
  };
646
- const shallowReactiveHandlers = extend({}, mutableHandlers, {
650
+ const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
647
651
  get: shallowGet,
648
652
  set: shallowSet
649
653
  });
650
654
  // Props handlers are special in the sense that it should not unwrap top-level
651
655
  // refs (in order to allow refs to be explicitly passed down), but should
652
656
  // retain the reactivity of the normal readonly object.
653
- const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
657
+ const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
654
658
  get: shallowReadonlyGet
655
659
  });
656
660
 
@@ -820,73 +824,82 @@ function createReadonlyMethod(type) {
820
824
  return type === "delete" /* DELETE */ ? false : this;
821
825
  };
822
826
  }
823
- const mutableInstrumentations = {
824
- get(key) {
825
- return get$1(this, key);
826
- },
827
- get size() {
828
- return size(this);
829
- },
830
- has: has$1,
831
- add,
832
- set: set$1,
833
- delete: deleteEntry,
834
- clear,
835
- forEach: createForEach(false, false)
836
- };
837
- const shallowInstrumentations = {
838
- get(key) {
839
- return get$1(this, key, false, true);
840
- },
841
- get size() {
842
- return size(this);
843
- },
844
- has: has$1,
845
- add,
846
- set: set$1,
847
- delete: deleteEntry,
848
- clear,
849
- forEach: createForEach(false, true)
850
- };
851
- const readonlyInstrumentations = {
852
- get(key) {
853
- return get$1(this, key, true);
854
- },
855
- get size() {
856
- return size(this, true);
857
- },
858
- has(key) {
859
- return has$1.call(this, key, true);
860
- },
861
- add: createReadonlyMethod("add" /* ADD */),
862
- set: createReadonlyMethod("set" /* SET */),
863
- delete: createReadonlyMethod("delete" /* DELETE */),
864
- clear: createReadonlyMethod("clear" /* CLEAR */),
865
- forEach: createForEach(true, false)
866
- };
867
- const shallowReadonlyInstrumentations = {
868
- get(key) {
869
- return get$1(this, key, true, true);
870
- },
871
- get size() {
872
- return size(this, true);
873
- },
874
- has(key) {
875
- return has$1.call(this, key, true);
876
- },
877
- add: createReadonlyMethod("add" /* ADD */),
878
- set: createReadonlyMethod("set" /* SET */),
879
- delete: createReadonlyMethod("delete" /* DELETE */),
880
- clear: createReadonlyMethod("clear" /* CLEAR */),
881
- forEach: createForEach(true, true)
882
- };
883
- const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
884
- iteratorMethods.forEach(method => {
885
- mutableInstrumentations[method] = createIterableMethod(method, false, false);
886
- readonlyInstrumentations[method] = createIterableMethod(method, true, false);
887
- shallowInstrumentations[method] = createIterableMethod(method, false, true);
888
- shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
889
- });
827
+ function createInstrumentations() {
828
+ const mutableInstrumentations = {
829
+ get(key) {
830
+ return get$1(this, key);
831
+ },
832
+ get size() {
833
+ return size(this);
834
+ },
835
+ has: has$1,
836
+ add,
837
+ set: set$1,
838
+ delete: deleteEntry,
839
+ clear,
840
+ forEach: createForEach(false, false)
841
+ };
842
+ const shallowInstrumentations = {
843
+ get(key) {
844
+ return get$1(this, key, false, true);
845
+ },
846
+ get size() {
847
+ return size(this);
848
+ },
849
+ has: has$1,
850
+ add,
851
+ set: set$1,
852
+ delete: deleteEntry,
853
+ clear,
854
+ forEach: createForEach(false, true)
855
+ };
856
+ const readonlyInstrumentations = {
857
+ get(key) {
858
+ return get$1(this, key, true);
859
+ },
860
+ get size() {
861
+ return size(this, true);
862
+ },
863
+ has(key) {
864
+ return has$1.call(this, key, true);
865
+ },
866
+ add: createReadonlyMethod("add" /* ADD */),
867
+ set: createReadonlyMethod("set" /* SET */),
868
+ delete: createReadonlyMethod("delete" /* DELETE */),
869
+ clear: createReadonlyMethod("clear" /* CLEAR */),
870
+ forEach: createForEach(true, false)
871
+ };
872
+ const shallowReadonlyInstrumentations = {
873
+ get(key) {
874
+ return get$1(this, key, true, true);
875
+ },
876
+ get size() {
877
+ return size(this, true);
878
+ },
879
+ has(key) {
880
+ return has$1.call(this, key, true);
881
+ },
882
+ add: createReadonlyMethod("add" /* ADD */),
883
+ set: createReadonlyMethod("set" /* SET */),
884
+ delete: createReadonlyMethod("delete" /* DELETE */),
885
+ clear: createReadonlyMethod("clear" /* CLEAR */),
886
+ forEach: createForEach(true, true)
887
+ };
888
+ const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
889
+ iteratorMethods.forEach(method => {
890
+ mutableInstrumentations[method] = createIterableMethod(method, false, false);
891
+ readonlyInstrumentations[method] = createIterableMethod(method, true, false);
892
+ shallowInstrumentations[method] = createIterableMethod(method, false, true);
893
+ shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
894
+ });
895
+ return [
896
+ mutableInstrumentations,
897
+ readonlyInstrumentations,
898
+ shallowInstrumentations,
899
+ shallowReadonlyInstrumentations
900
+ ];
901
+ }
902
+ const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
890
903
  function createInstrumentationGetter(isReadonly, shallow) {
891
904
  const instrumentations = shallow
892
905
  ? isReadonly
@@ -911,16 +924,16 @@ function createInstrumentationGetter(isReadonly, shallow) {
911
924
  };
912
925
  }
913
926
  const mutableCollectionHandlers = {
914
- get: createInstrumentationGetter(false, false)
927
+ get: /*#__PURE__*/ createInstrumentationGetter(false, false)
915
928
  };
916
929
  const shallowCollectionHandlers = {
917
- get: createInstrumentationGetter(false, true)
930
+ get: /*#__PURE__*/ createInstrumentationGetter(false, true)
918
931
  };
919
932
  const readonlyCollectionHandlers = {
920
- get: createInstrumentationGetter(true, false)
933
+ get: /*#__PURE__*/ createInstrumentationGetter(true, false)
921
934
  };
922
935
  const shallowReadonlyCollectionHandlers = {
923
- get: createInstrumentationGetter(true, true)
936
+ get: /*#__PURE__*/ createInstrumentationGetter(true, true)
924
937
  };
925
938
  function checkIdentityKeys(target, has, key) {
926
939
  const rawKey = toRaw(key);
@@ -1046,7 +1059,7 @@ function shallowRef(value) {
1046
1059
  return createRef(value, true);
1047
1060
  }
1048
1061
  class RefImpl {
1049
- constructor(_rawValue, _shallow = false) {
1062
+ constructor(_rawValue, _shallow) {
1050
1063
  this._rawValue = _rawValue;
1051
1064
  this._shallow = _shallow;
1052
1065
  this.__v_isRef = true;
@@ -1302,6 +1315,7 @@ function formatProp(key, value, raw) {
1302
1315
  }
1303
1316
 
1304
1317
  const ErrorTypeStrings = {
1318
+ ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
1305
1319
  ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
1306
1320
  ["c" /* CREATED */]: 'created hook',
1307
1321
  ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
@@ -2168,11 +2182,12 @@ function emit(instance, event, ...rawArgs) {
2168
2182
  const onceHandler = props[handlerName + `Once`];
2169
2183
  if (onceHandler) {
2170
2184
  if (!instance.emitted) {
2171
- (instance.emitted = {})[handlerName] = true;
2185
+ instance.emitted = {};
2172
2186
  }
2173
2187
  else if (instance.emitted[handlerName]) {
2174
2188
  return;
2175
2189
  }
2190
+ instance.emitted[handlerName] = true;
2176
2191
  callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
2177
2192
  }
2178
2193
  }
@@ -2643,6 +2658,12 @@ const SuspenseImpl = {
2643
2658
  // Force-casted public typing for h and TSX props inference
2644
2659
  const Suspense = (SuspenseImpl
2645
2660
  );
2661
+ function triggerEvent(vnode, name) {
2662
+ const eventListener = vnode.props && vnode.props[name];
2663
+ if (isFunction(eventListener)) {
2664
+ eventListener();
2665
+ }
2666
+ }
2646
2667
  function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
2647
2668
  const { p: patch, o: { createElement } } = rendererInternals;
2648
2669
  const hiddenContainer = createElement('div');
@@ -2652,6 +2673,9 @@ function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense
2652
2673
  // now check if we have encountered any async deps
2653
2674
  if (suspense.deps > 0) {
2654
2675
  // has async
2676
+ // invoke @fallback event
2677
+ triggerEvent(vnode, 'onPending');
2678
+ triggerEvent(vnode, 'onFallback');
2655
2679
  // mount the fallback tree
2656
2680
  patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2657
2681
  isSVG, slotScopeIds);
@@ -2739,10 +2763,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotSc
2739
2763
  else {
2740
2764
  // root node toggled
2741
2765
  // invoke @pending event
2742
- const onPending = n2.props && n2.props.onPending;
2743
- if (isFunction(onPending)) {
2744
- onPending();
2745
- }
2766
+ triggerEvent(n2, 'onPending');
2746
2767
  // mount pending branch in off-dom container
2747
2768
  suspense.pendingBranch = newBranch;
2748
2769
  suspense.pendingId++;
@@ -2855,10 +2876,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
2855
2876
  }
2856
2877
  suspense.effects = [];
2857
2878
  // invoke @resolve event
2858
- const onResolve = vnode.props && vnode.props.onResolve;
2859
- if (isFunction(onResolve)) {
2860
- onResolve();
2861
- }
2879
+ triggerEvent(vnode, 'onResolve');
2862
2880
  },
2863
2881
  fallback(fallbackVNode) {
2864
2882
  if (!suspense.pendingBranch) {
@@ -2866,10 +2884,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
2866
2884
  }
2867
2885
  const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
2868
2886
  // invoke @fallback event
2869
- const onFallback = vnode.props && vnode.props.onFallback;
2870
- if (isFunction(onFallback)) {
2871
- onFallback();
2872
- }
2887
+ triggerEvent(vnode, 'onFallback');
2873
2888
  const anchor = next(activeBranch);
2874
2889
  const mountFallback = () => {
2875
2890
  if (!suspense.isInFallback) {
@@ -2884,11 +2899,11 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
2884
2899
  if (delayEnter) {
2885
2900
  activeBranch.transition.afterLeave = mountFallback;
2886
2901
  }
2902
+ suspense.isInFallback = true;
2887
2903
  // unmount current active branch
2888
2904
  unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
2889
2905
  true // shouldRemove
2890
2906
  );
2891
- suspense.isInFallback = true;
2892
2907
  if (!delayEnter) {
2893
2908
  mountFallback();
2894
2909
  }
@@ -3083,7 +3098,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
3083
3098
  }
3084
3099
  else if (arguments.length > 1) {
3085
3100
  return treatDefaultAsFactory && isFunction(defaultValue)
3086
- ? defaultValue()
3101
+ ? defaultValue.call(instance.proxy)
3087
3102
  : defaultValue;
3088
3103
  }
3089
3104
  else {
@@ -4299,13 +4314,16 @@ function applyOptions(instance) {
4299
4314
  registerLifecycleHook(onServerPrefetch, serverPrefetch);
4300
4315
  if (isArray(expose)) {
4301
4316
  if (expose.length) {
4302
- const exposed = instance.exposed || (instance.exposed = proxyRefs({}));
4317
+ const exposed = instance.exposed || (instance.exposed = {});
4303
4318
  expose.forEach(key => {
4304
- exposed[key] = toRef(publicThis, key);
4319
+ Object.defineProperty(exposed, key, {
4320
+ get: () => publicThis[key],
4321
+ set: val => (publicThis[key] = val)
4322
+ });
4305
4323
  });
4306
4324
  }
4307
4325
  else if (!instance.exposed) {
4308
- instance.exposed = EMPTY_OBJ;
4326
+ instance.exposed = {};
4309
4327
  }
4310
4328
  }
4311
4329
  // options that are handled when creating the instance but also need to be
@@ -4442,25 +4460,23 @@ const internalOptionMergeStrats = {
4442
4460
  methods: mergeObjectOptions,
4443
4461
  computed: mergeObjectOptions,
4444
4462
  // lifecycle
4445
- beforeCreate: mergeHook,
4446
- created: mergeHook,
4447
- beforeMount: mergeHook,
4448
- mounted: mergeHook,
4449
- beforeUpdate: mergeHook,
4450
- updated: mergeHook,
4451
- beforeDestroy: mergeHook,
4452
- destroyed: mergeHook,
4453
- activated: mergeHook,
4454
- deactivated: mergeHook,
4455
- errorCaptured: mergeHook,
4456
- serverPrefetch: mergeHook,
4463
+ beforeCreate: mergeAsArray,
4464
+ created: mergeAsArray,
4465
+ beforeMount: mergeAsArray,
4466
+ mounted: mergeAsArray,
4467
+ beforeUpdate: mergeAsArray,
4468
+ updated: mergeAsArray,
4469
+ beforeDestroy: mergeAsArray,
4470
+ destroyed: mergeAsArray,
4471
+ activated: mergeAsArray,
4472
+ deactivated: mergeAsArray,
4473
+ errorCaptured: mergeAsArray,
4474
+ serverPrefetch: mergeAsArray,
4457
4475
  // assets
4458
4476
  components: mergeObjectOptions,
4459
4477
  directives: mergeObjectOptions,
4460
- // watch has special merge behavior in v2, but isn't actually needed in v3.
4461
- // since we are only exposing these for compat and nobody should be relying
4462
- // on the watch-specific behavior, just expose the object merge strat.
4463
- watch: mergeObjectOptions,
4478
+ // watch
4479
+ watch: mergeWatchOptions,
4464
4480
  // provide / inject
4465
4481
  provide: mergeDataFn,
4466
4482
  inject: mergeInject
@@ -4489,11 +4505,22 @@ function normalizeInject(raw) {
4489
4505
  }
4490
4506
  return raw;
4491
4507
  }
4492
- function mergeHook(to, from) {
4508
+ function mergeAsArray(to, from) {
4493
4509
  return to ? [...new Set([].concat(to, from))] : from;
4494
4510
  }
4495
4511
  function mergeObjectOptions(to, from) {
4496
4512
  return to ? extend(extend(Object.create(null), to), from) : from;
4513
+ }
4514
+ function mergeWatchOptions(to, from) {
4515
+ if (!to)
4516
+ return from;
4517
+ if (!from)
4518
+ return to;
4519
+ const merged = extend(Object.create(null), to);
4520
+ for (const key in from) {
4521
+ merged[key] = mergeAsArray(to[key], from[key]);
4522
+ }
4523
+ return merged;
4497
4524
  }
4498
4525
 
4499
4526
  function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
@@ -5150,6 +5177,7 @@ function createAppAPI(render, hydrate) {
5150
5177
  _props: rootProps,
5151
5178
  _container: null,
5152
5179
  _context: context,
5180
+ _instance: null,
5153
5181
  version,
5154
5182
  get config() {
5155
5183
  return context.config;
@@ -5237,6 +5265,7 @@ function createAppAPI(render, hydrate) {
5237
5265
  app._container = rootContainer;
5238
5266
  rootContainer.__vue_app__ = app;
5239
5267
  {
5268
+ app._instance = vnode.component;
5240
5269
  devtoolsInitApp(app, version);
5241
5270
  }
5242
5271
  return vnode.component.proxy;
@@ -5252,6 +5281,7 @@ function createAppAPI(render, hydrate) {
5252
5281
  if (isMounted) {
5253
5282
  render(null, app._container);
5254
5283
  {
5284
+ app._instance = null;
5255
5285
  devtoolsUnmountApp(app);
5256
5286
  }
5257
5287
  delete app._container.__vue_app__;
@@ -5288,8 +5318,9 @@ function createHydrationFunctions(rendererInternals) {
5288
5318
  const hydrate = (vnode, container) => {
5289
5319
  if (!container.hasChildNodes()) {
5290
5320
  warn(`Attempting to hydrate existing markup but container is empty. ` +
5291
- `Performing full mount instead.`);
5321
+ `Performing full mount instead.`);
5292
5322
  patch(null, vnode, container);
5323
+ flushPostFlushCbs();
5293
5324
  return;
5294
5325
  }
5295
5326
  hasMismatch = false;
@@ -5426,19 +5457,24 @@ function createHydrationFunctions(rendererInternals) {
5426
5457
  };
5427
5458
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
5428
5459
  optimized = optimized || !!vnode.dynamicChildren;
5429
- const { props, patchFlag, shapeFlag, dirs } = vnode;
5460
+ const { type, props, patchFlag, shapeFlag, dirs } = vnode;
5461
+ // #4006 for form elements with non-string v-model value bindings
5462
+ // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5463
+ const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5430
5464
  // skip props & children if this is hoisted static nodes
5431
- if (patchFlag !== -1 /* HOISTED */) {
5465
+ if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5432
5466
  if (dirs) {
5433
5467
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
5434
5468
  }
5435
5469
  // props
5436
5470
  if (props) {
5437
- if (!optimized ||
5471
+ if (forcePatchValue ||
5472
+ !optimized ||
5438
5473
  (patchFlag & 16 /* FULL_PROPS */ ||
5439
5474
  patchFlag & 32 /* HYDRATE_EVENTS */)) {
5440
5475
  for (const key in props) {
5441
- if (!isReservedProp(key) && isOn(key)) {
5476
+ if ((forcePatchValue && key.endsWith('value')) ||
5477
+ (isOn(key) && !isReservedProp(key))) {
5442
5478
  patchProp(el, key, null, props[key]);
5443
5479
  }
5444
5480
  }
@@ -5652,7 +5688,7 @@ const setRef = (rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) =>
5652
5688
  return;
5653
5689
  }
5654
5690
  const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
5655
- ? vnode.component.exposed || vnode.component.proxy
5691
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
5656
5692
  : vnode.el;
5657
5693
  const value = isUnmount ? null : refValue;
5658
5694
  const { i: owner, r: ref } = rawRef;
@@ -5822,7 +5858,19 @@ function baseCreateRenderer(options, createHydrationFns) {
5822
5858
  }
5823
5859
  };
5824
5860
  const mountStaticNode = (n2, container, anchor, isSVG) => {
5825
- [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
5861
+ // static nodes are only present when used with compiler-dom/runtime-dom
5862
+ // which guarantees presence of hostInsertStaticContent.
5863
+ const nodes = hostInsertStaticContent(n2.children, container, anchor, isSVG,
5864
+ // pass cached nodes if the static node is being mounted multiple times
5865
+ // so that runtime-dom can simply cloneNode() instead of inserting new
5866
+ // HTML
5867
+ n2.staticCache);
5868
+ // first mount - this is the orignal hoisted vnode. cache nodes.
5869
+ if (!n2.el) {
5870
+ n2.staticCache = nodes;
5871
+ }
5872
+ n2.el = nodes[0];
5873
+ n2.anchor = nodes[nodes.length - 1];
5826
5874
  };
5827
5875
  /**
5828
5876
  * Dev / HMR only
@@ -7454,7 +7502,6 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
7454
7502
  anchor: null,
7455
7503
  target: null,
7456
7504
  targetAnchor: null,
7457
- staticCount: 0,
7458
7505
  shapeFlag,
7459
7506
  patchFlag,
7460
7507
  dynamicProps,
@@ -7516,6 +7563,7 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
7516
7563
  target: vnode.target,
7517
7564
  targetAnchor: vnode.targetAnchor,
7518
7565
  staticCount: vnode.staticCount,
7566
+ staticCache: vnode.staticCache,
7519
7567
  shapeFlag: vnode.shapeFlag,
7520
7568
  // if the vnode is cloned with extra props, we can no longer assume its
7521
7569
  // existing patch flag to be reliable and need to add the FULL_PROPS flag.
@@ -7831,7 +7879,7 @@ const getPublicInstance = (i) => {
7831
7879
  if (!i)
7832
7880
  return null;
7833
7881
  if (isStatefulComponent(i))
7834
- return i.exposed ? i.exposed : i.proxy;
7882
+ return getExposeProxy(i) || i.proxy;
7835
7883
  return getPublicInstance(i.parent);
7836
7884
  };
7837
7885
  const publicPropertiesMap = extend(Object.create(null), {
@@ -7853,14 +7901,19 @@ const publicPropertiesMap = extend(Object.create(null), {
7853
7901
  const PublicInstanceProxyHandlers = {
7854
7902
  get({ _: instance }, key) {
7855
7903
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
7856
- // let @vue/reactivity know it should never observe Vue public instances.
7857
- if (key === "__v_skip" /* SKIP */) {
7858
- return true;
7859
- }
7860
7904
  // for internal formatters to know that this is a Vue instance
7861
7905
  if (key === '__isVue') {
7862
7906
  return true;
7863
7907
  }
7908
+ // prioritize <script setup> bindings during dev.
7909
+ // this allows even properties that start with _ or $ to be used - so that
7910
+ // it aligns with the production behavior where the render fn is inlined and
7911
+ // indeed has access to all declared variables.
7912
+ if (setupState !== EMPTY_OBJ &&
7913
+ setupState.__isScriptSetup &&
7914
+ hasOwn(setupState, key)) {
7915
+ return setupState[key];
7916
+ }
7864
7917
  // data / props / ctx
7865
7918
  // This getter gets called for every property access on the render context
7866
7919
  // during render and is a major hotspot. The most expensive part of this
@@ -8060,7 +8113,7 @@ function exposePropsOnRenderContext(instance) {
8060
8113
  function exposeSetupStateOnRenderContext(instance) {
8061
8114
  const { ctx, setupState } = instance;
8062
8115
  Object.keys(toRaw(setupState)).forEach(key => {
8063
- if (key[0] === '$' || key[0] === '_') {
8116
+ if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
8064
8117
  warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
8065
8118
  `which are reserved prefixes for Vue internals.`);
8066
8119
  return;
@@ -8093,6 +8146,7 @@ function createComponentInstance(vnode, parent, suspense) {
8093
8146
  render: null,
8094
8147
  proxy: null,
8095
8148
  exposed: null,
8149
+ exposeProxy: null,
8096
8150
  withProxy: null,
8097
8151
  effects: null,
8098
8152
  provides: parent ? parent.provides : Object.create(appContext.provides),
@@ -8208,7 +8262,7 @@ function setupStatefulComponent(instance, isSSR) {
8208
8262
  instance.accessCache = Object.create(null);
8209
8263
  // 1. create public instance / render proxy
8210
8264
  // also mark it raw so it's never observed
8211
- instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
8265
+ instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
8212
8266
  {
8213
8267
  exposePropsOnRenderContext(instance);
8214
8268
  }
@@ -8223,6 +8277,10 @@ function setupStatefulComponent(instance, isSSR) {
8223
8277
  resetTracking();
8224
8278
  currentInstance = null;
8225
8279
  if (isPromise(setupResult)) {
8280
+ const unsetInstance = () => {
8281
+ currentInstance = null;
8282
+ };
8283
+ setupResult.then(unsetInstance, unsetInstance);
8226
8284
  if (isSSR) {
8227
8285
  // return the promise so server-renderer can wait on it
8228
8286
  return setupResult
@@ -8338,11 +8396,9 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
8338
8396
  }
8339
8397
  }
8340
8398
  }
8341
- const attrHandlers = {
8399
+ const attrDevProxyHandlers = {
8342
8400
  get: (target, key) => {
8343
- {
8344
- markAttrsAccessed();
8345
- }
8401
+ markAttrsAccessed();
8346
8402
  return target[key];
8347
8403
  },
8348
8404
  set: () => {
@@ -8359,14 +8415,15 @@ function createSetupContext(instance) {
8359
8415
  if (instance.exposed) {
8360
8416
  warn(`expose() should be called only once per setup().`);
8361
8417
  }
8362
- instance.exposed = proxyRefs(exposed);
8418
+ instance.exposed = exposed || {};
8363
8419
  };
8364
8420
  {
8421
+ let attrs;
8365
8422
  // We use getters in dev in case libs like test-utils overwrite instance
8366
8423
  // properties (overwrites should not be done in prod)
8367
8424
  return Object.freeze({
8368
8425
  get attrs() {
8369
- return new Proxy(instance.attrs, attrHandlers);
8426
+ return (attrs || (attrs = new Proxy(instance.attrs, attrDevProxyHandlers)));
8370
8427
  },
8371
8428
  get slots() {
8372
8429
  return shallowReadonly(instance.slots);
@@ -8378,6 +8435,21 @@ function createSetupContext(instance) {
8378
8435
  });
8379
8436
  }
8380
8437
  }
8438
+ function getExposeProxy(instance) {
8439
+ if (instance.exposed) {
8440
+ return (instance.exposeProxy ||
8441
+ (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
8442
+ get(target, key) {
8443
+ if (key in target) {
8444
+ return target[key];
8445
+ }
8446
+ else if (key in publicPropertiesMap) {
8447
+ return publicPropertiesMap[key](instance);
8448
+ }
8449
+ }
8450
+ })));
8451
+ }
8452
+ }
8381
8453
  // record effects created during a component's setup() so that they can be
8382
8454
  // stopped when the component unmounts
8383
8455
  function recordInstanceBoundEffect(effect, instance = currentInstance) {
@@ -8426,30 +8498,133 @@ function computed$1(getterOrOptions) {
8426
8498
  return c;
8427
8499
  }
8428
8500
 
8501
+ // dev only
8502
+ const warnRuntimeUsage = (method) => warn(`${method}() is a compiler-hint helper that is only usable inside ` +
8503
+ `<script setup> of a single file component. Its arguments should be ` +
8504
+ `compiled away and passing it at runtime has no effect.`);
8429
8505
  // implementation
8430
8506
  function defineProps() {
8431
8507
  {
8432
- warn(`defineProps() is a compiler-hint helper that is only usable inside ` +
8433
- `<script setup> of a single file component. Its arguments should be ` +
8434
- `compiled away and passing it at runtime has no effect.`);
8508
+ warnRuntimeUsage(`defineProps`);
8435
8509
  }
8436
8510
  return null;
8437
8511
  }
8438
8512
  // implementation
8439
- function defineEmit() {
8513
+ function defineEmits() {
8440
8514
  {
8441
- warn(`defineEmit() is a compiler-hint helper that is only usable inside ` +
8442
- `<script setup> of a single file component. Its arguments should be ` +
8443
- `compiled away and passing it at runtime has no effect.`);
8515
+ warnRuntimeUsage(`defineEmits`);
8444
8516
  }
8445
8517
  return null;
8446
8518
  }
8519
+ /**
8520
+ * @deprecated use `defineEmits` instead.
8521
+ */
8522
+ const defineEmit = defineEmits;
8523
+ /**
8524
+ * Vue `<script setup>` compiler macro for declaring a component's exposed
8525
+ * instance properties when it is accessed by a parent component via template
8526
+ * refs.
8527
+ *
8528
+ * `<script setup>` components are closed by default - i.e. varaibles inside
8529
+ * the `<script setup>` scope is not exposed to parent unless explicitly exposed
8530
+ * via `defineExpose`.
8531
+ *
8532
+ * This is only usable inside `<script setup>`, is compiled away in the
8533
+ * output and should **not** be actually called at runtime.
8534
+ */
8535
+ function defineExpose(exposed) {
8536
+ {
8537
+ warnRuntimeUsage(`defineExpose`);
8538
+ }
8539
+ }
8540
+ /**
8541
+ * Vue `<script setup>` compiler macro for providing props default values when
8542
+ * using type-based `defineProps` decalration.
8543
+ *
8544
+ * Example usage:
8545
+ * ```ts
8546
+ * withDefaults(defineProps<{
8547
+ * size?: number
8548
+ * labels?: string[]
8549
+ * }>(), {
8550
+ * size: 3,
8551
+ * labels: () => ['default label']
8552
+ * })
8553
+ * ```
8554
+ *
8555
+ * This is only usable inside `<script setup>`, is compiled away in the output
8556
+ * and should **not** be actually called at runtime.
8557
+ */
8558
+ function withDefaults(props, defaults) {
8559
+ {
8560
+ warnRuntimeUsage(`withDefaults`);
8561
+ }
8562
+ return null;
8563
+ }
8564
+ /**
8565
+ * @deprecated use `useSlots` and `useAttrs` instead.
8566
+ */
8447
8567
  function useContext() {
8568
+ {
8569
+ warn(`\`useContext()\` has been deprecated and will be removed in the ` +
8570
+ `next minor release. Use \`useSlots()\` and \`useAttrs()\` instead.`);
8571
+ }
8572
+ return getContext();
8573
+ }
8574
+ function useSlots() {
8575
+ return getContext().slots;
8576
+ }
8577
+ function useAttrs() {
8578
+ return getContext().attrs;
8579
+ }
8580
+ function getContext() {
8448
8581
  const i = getCurrentInstance();
8449
8582
  if (!i) {
8450
8583
  warn(`useContext() called without active instance.`);
8451
8584
  }
8452
8585
  return i.setupContext || (i.setupContext = createSetupContext(i));
8586
+ }
8587
+ /**
8588
+ * Runtime helper for merging default declarations. Imported by compiled code
8589
+ * only.
8590
+ * @internal
8591
+ */
8592
+ function mergeDefaults(
8593
+ // the base props is compiler-generated and guaranteed to be in this shape.
8594
+ props, defaults) {
8595
+ for (const key in defaults) {
8596
+ const val = props[key];
8597
+ if (val) {
8598
+ val.default = defaults[key];
8599
+ }
8600
+ else if (val === null) {
8601
+ props[key] = { default: defaults[key] };
8602
+ }
8603
+ else {
8604
+ warn(`props default key "${key}" has no corresponding declaration.`);
8605
+ }
8606
+ }
8607
+ return props;
8608
+ }
8609
+ /**
8610
+ * Runtime helper for storing and resuming current instance context in
8611
+ * async setup().
8612
+ */
8613
+ function withAsyncContext(awaitable) {
8614
+ const ctx = getCurrentInstance();
8615
+ setCurrentInstance(null); // unset after storing instance
8616
+ if (!ctx) {
8617
+ warn(`withAsyncContext() called when there is no active context instance.`);
8618
+ }
8619
+ return isPromise(awaitable)
8620
+ ? awaitable.then(res => {
8621
+ setCurrentInstance(ctx);
8622
+ return res;
8623
+ }, err => {
8624
+ setCurrentInstance(ctx);
8625
+ throw err;
8626
+ })
8627
+ : awaitable;
8453
8628
  }
8454
8629
 
8455
8630
  // Actual implementation
@@ -8682,7 +8857,7 @@ function initCustomFormatter() {
8682
8857
  }
8683
8858
 
8684
8859
  // Core API ------------------------------------------------------------------
8685
- const version = "3.1.0";
8860
+ const version = "3.1.4";
8686
8861
  /**
8687
8862
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8688
8863
  * @internal
@@ -8699,8 +8874,6 @@ const compatUtils = (null);
8699
8874
 
8700
8875
  const svgNS = 'http://www.w3.org/2000/svg';
8701
8876
  const doc = (typeof document !== 'undefined' ? document : null);
8702
- let tempContainer;
8703
- let tempSVGContainer;
8704
8877
  const nodeOps = {
8705
8878
  insert: (child, parent, anchor) => {
8706
8879
  parent.insertBefore(child, anchor || null);
@@ -8751,24 +8924,60 @@ const nodeOps = {
8751
8924
  return cloned;
8752
8925
  },
8753
8926
  // __UNSAFE__
8754
- // Reason: innerHTML.
8927
+ // Reason: insertAdjacentHTML.
8755
8928
  // Static content here can only come from compiled templates.
8756
8929
  // As long as the user only uses trusted templates, this is safe.
8757
- insertStaticContent(content, parent, anchor, isSVG) {
8758
- const temp = isSVG
8759
- ? tempSVGContainer ||
8760
- (tempSVGContainer = doc.createElementNS(svgNS, 'svg'))
8761
- : tempContainer || (tempContainer = doc.createElement('div'));
8762
- temp.innerHTML = content;
8763
- const first = temp.firstChild;
8764
- let node = first;
8765
- let last = node;
8766
- while (node) {
8767
- last = node;
8768
- nodeOps.insert(node, parent, anchor);
8769
- node = temp.firstChild;
8930
+ insertStaticContent(content, parent, anchor, isSVG, cached) {
8931
+ if (cached) {
8932
+ let first;
8933
+ let last;
8934
+ let i = 0;
8935
+ let l = cached.length;
8936
+ for (; i < l; i++) {
8937
+ const node = cached[i].cloneNode(true);
8938
+ if (i === 0)
8939
+ first = node;
8940
+ if (i === l - 1)
8941
+ last = node;
8942
+ parent.insertBefore(node, anchor);
8943
+ }
8944
+ return [first, last];
8945
+ }
8946
+ // <parent> before | first ... last | anchor </parent>
8947
+ const before = anchor ? anchor.previousSibling : parent.lastChild;
8948
+ if (anchor) {
8949
+ let insertionPoint;
8950
+ let usingTempInsertionPoint = false;
8951
+ if (anchor instanceof Element) {
8952
+ insertionPoint = anchor;
8953
+ }
8954
+ else {
8955
+ // insertAdjacentHTML only works for elements but the anchor is not an
8956
+ // element...
8957
+ usingTempInsertionPoint = true;
8958
+ insertionPoint = isSVG
8959
+ ? doc.createElementNS(svgNS, 'g')
8960
+ : doc.createElement('div');
8961
+ parent.insertBefore(insertionPoint, anchor);
8962
+ }
8963
+ insertionPoint.insertAdjacentHTML('beforebegin', content);
8964
+ if (usingTempInsertionPoint) {
8965
+ parent.removeChild(insertionPoint);
8966
+ }
8770
8967
  }
8771
- return [first, last];
8968
+ else {
8969
+ parent.insertAdjacentHTML('beforeend', content);
8970
+ }
8971
+ let first = before ? before.nextSibling : parent.firstChild;
8972
+ const last = anchor ? anchor.previousSibling : parent.lastChild;
8973
+ const ret = [];
8974
+ while (first) {
8975
+ ret.push(first);
8976
+ if (first === last)
8977
+ break;
8978
+ first = first.nextSibling;
8979
+ }
8980
+ return ret;
8772
8981
  }
8773
8982
  };
8774
8983
 
@@ -10055,4 +10264,4 @@ function normalizeContainer(container) {
10055
10264
  return container;
10056
10265
  }
10057
10266
 
10058
- export { BaseTransition, Comment$1 as Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, Transition, TransitionGroup, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed$1 as computed, createApp, createBlock, createCommentVNode, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineEmit, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, hydrate, initCustomFormatter, inject, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, 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, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useContext, useCssModule, useCssVars, useSSRContext, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers, withScopeId };
10267
+ export { BaseTransition, Comment$1 as Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, Transition, TransitionGroup, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed$1 as computed, createApp, createBlock, createCommentVNode, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineEmit, defineEmits, defineExpose, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, hydrate, initCustomFormatter, inject, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, 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, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useContext, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withModifiers, withScopeId };