@vue/runtime-core 3.5.0-alpha.4 → 3.5.0-beta.1

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-core v3.5.0-alpha.4
2
+ * @vue/runtime-core v3.5.0-beta.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -422,11 +422,8 @@ const TeleportImpl = {
422
422
  if (n1 == null) {
423
423
  const placeholder = n2.el = createText("");
424
424
  const mainAnchor = n2.anchor = createText("");
425
- const targetStart = n2.targetStart = createText("");
426
- const targetAnchor = n2.targetAnchor = createText("");
427
425
  insert(placeholder, container, anchor);
428
426
  insert(mainAnchor, container, anchor);
429
- targetStart[TeleportEndKey] = targetAnchor;
430
427
  const mount = (container2, anchor2) => {
431
428
  if (shapeFlag & 16) {
432
429
  mountChildren(
@@ -443,9 +440,8 @@ const TeleportImpl = {
443
440
  };
444
441
  const mountToTarget = () => {
445
442
  const target = n2.target = resolveTarget(n2.props, querySelector);
443
+ const targetAnchor = prepareAnchor(target, n2, createText, insert);
446
444
  if (target) {
447
- insert(targetStart, target);
448
- insert(targetAnchor, target);
449
445
  if (namespace !== "svg" && isTargetSVG(target)) {
450
446
  namespace = "svg";
451
447
  } else if (namespace !== "mathml" && isTargetMathML(target)) {
@@ -604,7 +600,7 @@ function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }
604
600
  }
605
601
  }
606
602
  function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
607
- o: { nextSibling, parentNode, querySelector }
603
+ o: { nextSibling, parentNode, querySelector, insert, createText }
608
604
  }, hydrateChildren) {
609
605
  const target = vnode.target = resolveTarget(
610
606
  vnode.props,
@@ -623,20 +619,28 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
623
619
  slotScopeIds,
624
620
  optimized
625
621
  );
626
- vnode.targetAnchor = targetNode;
622
+ vnode.targetStart = targetNode;
623
+ vnode.targetAnchor = targetNode && nextSibling(targetNode);
627
624
  } else {
628
625
  vnode.anchor = nextSibling(node);
629
626
  let targetAnchor = targetNode;
630
627
  while (targetAnchor) {
631
- targetAnchor = nextSibling(targetAnchor);
632
- if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
633
- vnode.targetAnchor = targetAnchor;
634
- target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
635
- break;
628
+ if (targetAnchor && targetAnchor.nodeType === 8) {
629
+ if (targetAnchor.data === "teleport start anchor") {
630
+ vnode.targetStart = targetAnchor;
631
+ } else if (targetAnchor.data === "teleport anchor") {
632
+ vnode.targetAnchor = targetAnchor;
633
+ target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
634
+ break;
635
+ }
636
636
  }
637
+ targetAnchor = nextSibling(targetAnchor);
638
+ }
639
+ if (!vnode.targetAnchor) {
640
+ prepareAnchor(target, vnode, createText, insert);
637
641
  }
638
642
  hydrateChildren(
639
- targetNode,
643
+ targetNode && nextSibling(targetNode),
640
644
  vnode,
641
645
  target,
642
646
  parentComponent,
@@ -662,6 +666,16 @@ function updateCssVars(vnode) {
662
666
  ctx.ut();
663
667
  }
664
668
  }
669
+ function prepareAnchor(target, vnode, createText, insert) {
670
+ const targetStart = vnode.targetStart = createText("");
671
+ const targetAnchor = vnode.targetAnchor = createText("");
672
+ targetStart[TeleportEndKey] = targetAnchor;
673
+ if (target) {
674
+ insert(targetStart, target);
675
+ insert(targetAnchor, target);
676
+ }
677
+ return targetAnchor;
678
+ }
665
679
 
666
680
  const leaveCbKey = Symbol("_leaveCb");
667
681
  const enterCbKey = Symbol("_enterCb");
@@ -1015,2160 +1029,2287 @@ function markAsyncBoundary(instance) {
1015
1029
  instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
1016
1030
  }
1017
1031
 
1018
- const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
1019
- /*! #__NO_SIDE_EFFECTS__ */
1020
- // @__NO_SIDE_EFFECTS__
1021
- function defineAsyncComponent(source) {
1022
- if (shared.isFunction(source)) {
1023
- source = { loader: source };
1032
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
1033
+ if (shared.isArray(rawRef)) {
1034
+ rawRef.forEach(
1035
+ (r, i) => setRef(
1036
+ r,
1037
+ oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
1038
+ parentSuspense,
1039
+ vnode,
1040
+ isUnmount
1041
+ )
1042
+ );
1043
+ return;
1024
1044
  }
1025
- const {
1026
- loader,
1027
- loadingComponent,
1028
- errorComponent,
1029
- delay = 200,
1030
- timeout,
1031
- // undefined = never times out
1032
- suspensible = true,
1033
- onError: userOnError
1034
- } = source;
1035
- let pendingRequest = null;
1036
- let resolvedComp;
1037
- let retries = 0;
1038
- const retry = () => {
1039
- retries++;
1040
- pendingRequest = null;
1041
- return load();
1042
- };
1043
- const load = () => {
1044
- let thisRequest;
1045
- return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
1046
- err = err instanceof Error ? err : new Error(String(err));
1047
- if (userOnError) {
1048
- return new Promise((resolve, reject) => {
1049
- const userRetry = () => resolve(retry());
1050
- const userFail = () => reject(err);
1051
- userOnError(err, userRetry, userFail, retries + 1);
1052
- });
1053
- } else {
1054
- throw err;
1055
- }
1056
- }).then((comp) => {
1057
- if (thisRequest !== pendingRequest && pendingRequest) {
1058
- return pendingRequest;
1059
- }
1060
- if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
1061
- comp = comp.default;
1062
- }
1063
- resolvedComp = comp;
1064
- return comp;
1065
- }));
1066
- };
1067
- return defineComponent({
1068
- name: "AsyncComponentWrapper",
1069
- __asyncLoader: load,
1070
- get __asyncResolved() {
1071
- return resolvedComp;
1072
- },
1073
- setup() {
1074
- const instance = currentInstance;
1075
- markAsyncBoundary(instance);
1076
- if (resolvedComp) {
1077
- return () => createInnerComp(resolvedComp, instance);
1078
- }
1079
- const onError = (err) => {
1080
- pendingRequest = null;
1081
- handleError(
1082
- err,
1083
- instance,
1084
- 13,
1085
- !errorComponent
1086
- );
1087
- };
1088
- if (suspensible && instance.suspense || isInSSRComponentSetup) {
1089
- return load().then((comp) => {
1090
- return () => createInnerComp(comp, instance);
1091
- }).catch((err) => {
1092
- onError(err);
1093
- return () => errorComponent ? createVNode(errorComponent, {
1094
- error: err
1095
- }) : null;
1096
- });
1097
- }
1098
- const loaded = reactivity.ref(false);
1099
- const error = reactivity.ref();
1100
- const delayed = reactivity.ref(!!delay);
1101
- if (delay) {
1102
- setTimeout(() => {
1103
- delayed.value = false;
1104
- }, delay);
1045
+ if (isAsyncWrapper(vnode) && !isUnmount) {
1046
+ return;
1047
+ }
1048
+ const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
1049
+ const value = isUnmount ? null : refValue;
1050
+ const { i: owner, r: ref } = rawRef;
1051
+ const oldRef = oldRawRef && oldRawRef.r;
1052
+ const refs = owner.refs === shared.EMPTY_OBJ ? owner.refs = {} : owner.refs;
1053
+ const setupState = owner.setupState;
1054
+ if (oldRef != null && oldRef !== ref) {
1055
+ if (shared.isString(oldRef)) {
1056
+ refs[oldRef] = null;
1057
+ if (shared.hasOwn(setupState, oldRef)) {
1058
+ setupState[oldRef] = null;
1105
1059
  }
1106
- if (timeout != null) {
1107
- setTimeout(() => {
1108
- if (!loaded.value && !error.value) {
1109
- const err = new Error(
1110
- `Async component timed out after ${timeout}ms.`
1111
- );
1112
- onError(err);
1113
- error.value = err;
1060
+ } else if (reactivity.isRef(oldRef)) {
1061
+ oldRef.value = null;
1062
+ }
1063
+ }
1064
+ if (shared.isFunction(ref)) {
1065
+ callWithErrorHandling(ref, owner, 12, [value, refs]);
1066
+ } else {
1067
+ const _isString = shared.isString(ref);
1068
+ const _isRef = reactivity.isRef(ref);
1069
+ if (_isString || _isRef) {
1070
+ const doSet = () => {
1071
+ if (rawRef.f) {
1072
+ const existing = _isString ? shared.hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
1073
+ if (isUnmount) {
1074
+ shared.isArray(existing) && shared.remove(existing, refValue);
1075
+ } else {
1076
+ if (!shared.isArray(existing)) {
1077
+ if (_isString) {
1078
+ refs[ref] = [refValue];
1079
+ if (shared.hasOwn(setupState, ref)) {
1080
+ setupState[ref] = refs[ref];
1081
+ }
1082
+ } else {
1083
+ ref.value = [refValue];
1084
+ if (rawRef.k) refs[rawRef.k] = ref.value;
1085
+ }
1086
+ } else if (!existing.includes(refValue)) {
1087
+ existing.push(refValue);
1088
+ }
1114
1089
  }
1115
- }, timeout);
1116
- }
1117
- load().then(() => {
1118
- loaded.value = true;
1119
- if (instance.parent && isKeepAlive(instance.parent.vnode)) {
1120
- queueJob(instance.parent.update);
1121
- }
1122
- }).catch((err) => {
1123
- onError(err);
1124
- error.value = err;
1125
- });
1126
- return () => {
1127
- if (loaded.value && resolvedComp) {
1128
- return createInnerComp(resolvedComp, instance);
1129
- } else if (error.value && errorComponent) {
1130
- return createVNode(errorComponent, {
1131
- error: error.value
1132
- });
1133
- } else if (loadingComponent && !delayed.value) {
1134
- return createVNode(loadingComponent);
1135
- }
1090
+ } else if (_isString) {
1091
+ refs[ref] = value;
1092
+ if (shared.hasOwn(setupState, ref)) {
1093
+ setupState[ref] = value;
1094
+ }
1095
+ } else if (_isRef) {
1096
+ ref.value = value;
1097
+ if (rawRef.k) refs[rawRef.k] = value;
1098
+ } else ;
1136
1099
  };
1100
+ if (value) {
1101
+ doSet.id = -1;
1102
+ queuePostRenderEffect(doSet, parentSuspense);
1103
+ } else {
1104
+ doSet();
1105
+ }
1137
1106
  }
1138
- });
1139
- }
1140
- function createInnerComp(comp, parent) {
1141
- const { ref: ref2, props, children, ce } = parent.vnode;
1142
- const vnode = createVNode(comp, props, children);
1143
- vnode.ref = ref2;
1144
- vnode.ce = ce;
1145
- delete parent.vnode.ce;
1146
- return vnode;
1107
+ }
1147
1108
  }
1148
1109
 
1149
- const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
1150
- const KeepAliveImpl = {
1151
- name: `KeepAlive`,
1152
- // Marker for special handling inside the renderer. We are not using a ===
1153
- // check directly on KeepAlive in the renderer, because importing it directly
1154
- // would prevent it from being tree-shaken.
1155
- __isKeepAlive: true,
1156
- props: {
1157
- include: [String, RegExp, Array],
1158
- exclude: [String, RegExp, Array],
1159
- max: [String, Number]
1160
- },
1161
- setup(props, { slots }) {
1162
- const instance = getCurrentInstance();
1163
- const sharedContext = instance.ctx;
1164
- if (!sharedContext.renderer) {
1165
- return () => {
1166
- const children = slots.default && slots.default();
1167
- return children && children.length === 1 ? children[0] : children;
1168
- };
1110
+ let hasLoggedMismatchError = false;
1111
+ const logMismatchError = () => {
1112
+ if (hasLoggedMismatchError) {
1113
+ return;
1114
+ }
1115
+ console.error("Hydration completed but contains mismatches.");
1116
+ hasLoggedMismatchError = true;
1117
+ };
1118
+ const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
1119
+ const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
1120
+ const getContainerType = (container) => {
1121
+ if (isSVGContainer(container)) return "svg";
1122
+ if (isMathMLContainer(container)) return "mathml";
1123
+ return void 0;
1124
+ };
1125
+ const isComment = (node) => node.nodeType === 8;
1126
+ function createHydrationFunctions(rendererInternals) {
1127
+ const {
1128
+ mt: mountComponent,
1129
+ p: patch,
1130
+ o: {
1131
+ patchProp,
1132
+ createText,
1133
+ nextSibling,
1134
+ parentNode,
1135
+ remove,
1136
+ insert,
1137
+ createComment
1169
1138
  }
1170
- const cache = /* @__PURE__ */ new Map();
1171
- const keys = /* @__PURE__ */ new Set();
1172
- let current = null;
1173
- const parentSuspense = instance.suspense;
1174
- const {
1175
- renderer: {
1176
- p: patch,
1177
- m: move,
1178
- um: _unmount,
1179
- o: { createElement }
1180
- }
1181
- } = sharedContext;
1182
- const storageContainer = createElement("div");
1183
- sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
1184
- const instance2 = vnode.component;
1185
- move(vnode, container, anchor, 0, parentSuspense);
1186
- patch(
1187
- instance2.vnode,
1188
- vnode,
1189
- container,
1190
- anchor,
1191
- instance2,
1192
- parentSuspense,
1193
- namespace,
1194
- vnode.slotScopeIds,
1195
- optimized
1196
- );
1197
- queuePostRenderEffect(() => {
1198
- instance2.isDeactivated = false;
1199
- if (instance2.a) {
1200
- shared.invokeArrayFns(instance2.a);
1201
- }
1202
- const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
1203
- if (vnodeHook) {
1204
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1205
- }
1206
- }, parentSuspense);
1207
- };
1208
- sharedContext.deactivate = (vnode) => {
1209
- const instance2 = vnode.component;
1210
- invalidateMount(instance2.m);
1211
- invalidateMount(instance2.a);
1212
- move(vnode, storageContainer, null, 1, parentSuspense);
1213
- queuePostRenderEffect(() => {
1214
- if (instance2.da) {
1215
- shared.invokeArrayFns(instance2.da);
1216
- }
1217
- const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
1218
- if (vnodeHook) {
1219
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1220
- }
1221
- instance2.isDeactivated = true;
1222
- }, parentSuspense);
1223
- };
1224
- function unmount(vnode) {
1225
- resetShapeFlag(vnode);
1226
- _unmount(vnode, instance, parentSuspense, true);
1227
- }
1228
- function pruneCache(filter) {
1229
- cache.forEach((vnode, key) => {
1230
- const name = getComponentName(vnode.type);
1231
- if (name && (!filter || !filter(name))) {
1232
- pruneCacheEntry(key);
1233
- }
1234
- });
1235
- }
1236
- function pruneCacheEntry(key) {
1237
- const cached = cache.get(key);
1238
- if (!current || !isSameVNodeType(cached, current)) {
1239
- unmount(cached);
1240
- } else if (current) {
1241
- resetShapeFlag(current);
1242
- }
1243
- cache.delete(key);
1244
- keys.delete(key);
1139
+ } = rendererInternals;
1140
+ const hydrate = (vnode, container) => {
1141
+ if (!container.hasChildNodes()) {
1142
+ patch(null, vnode, container);
1143
+ flushPostFlushCbs();
1144
+ container._vnode = vnode;
1145
+ return;
1245
1146
  }
1246
- watch(
1247
- () => [props.include, props.exclude],
1248
- ([include, exclude]) => {
1249
- include && pruneCache((name) => matches(include, name));
1250
- exclude && pruneCache((name) => !matches(exclude, name));
1251
- },
1252
- // prune post-render after `current` has been updated
1253
- { flush: "post", deep: true }
1147
+ hydrateNode(container.firstChild, vnode, null, null, null);
1148
+ flushPostFlushCbs();
1149
+ container._vnode = vnode;
1150
+ };
1151
+ const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
1152
+ optimized = optimized || !!vnode.dynamicChildren;
1153
+ const isFragmentStart = isComment(node) && node.data === "[";
1154
+ const onMismatch = () => handleMismatch(
1155
+ node,
1156
+ vnode,
1157
+ parentComponent,
1158
+ parentSuspense,
1159
+ slotScopeIds,
1160
+ isFragmentStart
1254
1161
  );
1255
- let pendingCacheKey = null;
1256
- const cacheSubtree = () => {
1257
- if (pendingCacheKey != null) {
1258
- if (isSuspense(instance.subTree.type)) {
1259
- queuePostRenderEffect(() => {
1260
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1261
- }, instance.subTree.suspense);
1162
+ const { type, ref, shapeFlag, patchFlag } = vnode;
1163
+ let domType = node.nodeType;
1164
+ vnode.el = node;
1165
+ if (patchFlag === -2) {
1166
+ optimized = false;
1167
+ vnode.dynamicChildren = null;
1168
+ }
1169
+ let nextNode = null;
1170
+ switch (type) {
1171
+ case Text:
1172
+ if (domType !== 3) {
1173
+ if (vnode.children === "") {
1174
+ insert(vnode.el = createText(""), parentNode(node), node);
1175
+ nextNode = node;
1176
+ } else {
1177
+ nextNode = onMismatch();
1178
+ }
1262
1179
  } else {
1263
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1180
+ if (node.data !== vnode.children) {
1181
+ logMismatchError();
1182
+ node.data = vnode.children;
1183
+ }
1184
+ nextNode = nextSibling(node);
1264
1185
  }
1265
- }
1266
- };
1267
- onMounted(cacheSubtree);
1268
- onUpdated(cacheSubtree);
1269
- onBeforeUnmount(() => {
1270
- cache.forEach((cached) => {
1271
- const { subTree, suspense } = instance;
1272
- const vnode = getInnerChild(subTree);
1273
- if (cached.type === vnode.type && cached.key === vnode.key) {
1274
- resetShapeFlag(vnode);
1275
- const da = vnode.component.da;
1276
- da && queuePostRenderEffect(da, suspense);
1277
- return;
1186
+ break;
1187
+ case Comment:
1188
+ if (isTemplateNode(node)) {
1189
+ nextNode = nextSibling(node);
1190
+ replaceNode(
1191
+ vnode.el = node.content.firstChild,
1192
+ node,
1193
+ parentComponent
1194
+ );
1195
+ } else if (domType !== 8 || isFragmentStart) {
1196
+ nextNode = onMismatch();
1197
+ } else {
1198
+ nextNode = nextSibling(node);
1278
1199
  }
1279
- unmount(cached);
1280
- });
1281
- });
1282
- return () => {
1283
- pendingCacheKey = null;
1284
- if (!slots.default) {
1285
- return null;
1286
- }
1287
- const children = slots.default();
1288
- const rawVNode = children[0];
1289
- if (children.length > 1) {
1290
- current = null;
1291
- return children;
1292
- } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
1293
- current = null;
1294
- return rawVNode;
1295
- }
1296
- let vnode = getInnerChild(rawVNode);
1297
- const comp = vnode.type;
1298
- const name = getComponentName(
1299
- isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
1300
- );
1301
- const { include, exclude, max } = props;
1302
- if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
1303
- current = vnode;
1304
- return rawVNode;
1305
- }
1306
- const key = vnode.key == null ? comp : vnode.key;
1307
- const cachedVNode = cache.get(key);
1308
- if (vnode.el) {
1309
- vnode = cloneVNode(vnode);
1310
- if (rawVNode.shapeFlag & 128) {
1311
- rawVNode.ssContent = vnode;
1200
+ break;
1201
+ case Static:
1202
+ if (isFragmentStart) {
1203
+ node = nextSibling(node);
1204
+ domType = node.nodeType;
1312
1205
  }
1313
- }
1314
- pendingCacheKey = key;
1315
- if (cachedVNode) {
1316
- vnode.el = cachedVNode.el;
1317
- vnode.component = cachedVNode.component;
1318
- if (vnode.transition) {
1319
- setTransitionHooks(vnode, vnode.transition);
1206
+ if (domType === 1 || domType === 3) {
1207
+ nextNode = node;
1208
+ const needToAdoptContent = !vnode.children.length;
1209
+ for (let i = 0; i < vnode.staticCount; i++) {
1210
+ if (needToAdoptContent)
1211
+ vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
1212
+ if (i === vnode.staticCount - 1) {
1213
+ vnode.anchor = nextNode;
1214
+ }
1215
+ nextNode = nextSibling(nextNode);
1216
+ }
1217
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
1218
+ } else {
1219
+ onMismatch();
1320
1220
  }
1321
- vnode.shapeFlag |= 512;
1322
- keys.delete(key);
1323
- keys.add(key);
1324
- } else {
1325
- keys.add(key);
1326
- if (max && keys.size > parseInt(max, 10)) {
1327
- pruneCacheEntry(keys.values().next().value);
1221
+ break;
1222
+ case Fragment:
1223
+ if (!isFragmentStart) {
1224
+ nextNode = onMismatch();
1225
+ } else {
1226
+ nextNode = hydrateFragment(
1227
+ node,
1228
+ vnode,
1229
+ parentComponent,
1230
+ parentSuspense,
1231
+ slotScopeIds,
1232
+ optimized
1233
+ );
1328
1234
  }
1329
- }
1330
- vnode.shapeFlag |= 256;
1331
- current = vnode;
1332
- return isSuspense(rawVNode.type) ? rawVNode : vnode;
1333
- };
1334
- }
1335
- };
1336
- const KeepAlive = KeepAliveImpl;
1337
- function matches(pattern, name) {
1338
- if (shared.isArray(pattern)) {
1339
- return pattern.some((p) => matches(p, name));
1340
- } else if (shared.isString(pattern)) {
1341
- return pattern.split(",").includes(name);
1342
- } else if (shared.isRegExp(pattern)) {
1343
- return pattern.test(name);
1344
- }
1345
- return false;
1346
- }
1347
- function onActivated(hook, target) {
1348
- registerKeepAliveHook(hook, "a", target);
1349
- }
1350
- function onDeactivated(hook, target) {
1351
- registerKeepAliveHook(hook, "da", target);
1352
- }
1353
- function registerKeepAliveHook(hook, type, target = currentInstance) {
1354
- const wrappedHook = hook.__wdc || (hook.__wdc = () => {
1355
- let current = target;
1356
- while (current) {
1357
- if (current.isDeactivated) {
1358
- return;
1359
- }
1360
- current = current.parent;
1361
- }
1362
- return hook();
1363
- });
1364
- injectHook(type, wrappedHook, target);
1365
- if (target) {
1366
- let current = target.parent;
1367
- while (current && current.parent) {
1368
- if (isKeepAlive(current.parent.vnode)) {
1369
- injectToKeepAliveRoot(wrappedHook, type, target, current);
1370
- }
1371
- current = current.parent;
1235
+ break;
1236
+ default:
1237
+ if (shapeFlag & 1) {
1238
+ if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
1239
+ nextNode = onMismatch();
1240
+ } else {
1241
+ nextNode = hydrateElement(
1242
+ node,
1243
+ vnode,
1244
+ parentComponent,
1245
+ parentSuspense,
1246
+ slotScopeIds,
1247
+ optimized
1248
+ );
1249
+ }
1250
+ } else if (shapeFlag & 6) {
1251
+ vnode.slotScopeIds = slotScopeIds;
1252
+ const container = parentNode(node);
1253
+ if (isFragmentStart) {
1254
+ nextNode = locateClosingAnchor(node);
1255
+ } else if (isComment(node) && node.data === "teleport start") {
1256
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
1257
+ } else {
1258
+ nextNode = nextSibling(node);
1259
+ }
1260
+ mountComponent(
1261
+ vnode,
1262
+ container,
1263
+ null,
1264
+ parentComponent,
1265
+ parentSuspense,
1266
+ getContainerType(container),
1267
+ optimized
1268
+ );
1269
+ if (isAsyncWrapper(vnode)) {
1270
+ let subTree;
1271
+ if (isFragmentStart) {
1272
+ subTree = createVNode(Fragment);
1273
+ subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
1274
+ } else {
1275
+ subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
1276
+ }
1277
+ subTree.el = node;
1278
+ vnode.component.subTree = subTree;
1279
+ }
1280
+ } else if (shapeFlag & 64) {
1281
+ if (domType !== 8) {
1282
+ nextNode = onMismatch();
1283
+ } else {
1284
+ nextNode = vnode.type.hydrate(
1285
+ node,
1286
+ vnode,
1287
+ parentComponent,
1288
+ parentSuspense,
1289
+ slotScopeIds,
1290
+ optimized,
1291
+ rendererInternals,
1292
+ hydrateChildren
1293
+ );
1294
+ }
1295
+ } else if (shapeFlag & 128) {
1296
+ nextNode = vnode.type.hydrate(
1297
+ node,
1298
+ vnode,
1299
+ parentComponent,
1300
+ parentSuspense,
1301
+ getContainerType(parentNode(node)),
1302
+ slotScopeIds,
1303
+ optimized,
1304
+ rendererInternals,
1305
+ hydrateNode
1306
+ );
1307
+ } else ;
1372
1308
  }
1373
- }
1374
- }
1375
- function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
1376
- const injected = injectHook(
1377
- type,
1378
- hook,
1379
- keepAliveRoot,
1380
- true
1381
- /* prepend */
1382
- );
1383
- onUnmounted(() => {
1384
- shared.remove(keepAliveRoot[type], injected);
1385
- }, target);
1386
- }
1387
- function resetShapeFlag(vnode) {
1388
- vnode.shapeFlag &= ~256;
1389
- vnode.shapeFlag &= ~512;
1390
- }
1391
- function getInnerChild(vnode) {
1392
- return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
1393
- }
1394
-
1395
- function injectHook(type, hook, target = currentInstance, prepend = false) {
1396
- if (target) {
1397
- const hooks = target[type] || (target[type] = []);
1398
- const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
1399
- reactivity.pauseTracking();
1400
- const reset = setCurrentInstance(target);
1401
- const res = callWithAsyncErrorHandling(hook, target, type, args);
1402
- reset();
1403
- reactivity.resetTracking();
1404
- return res;
1405
- });
1406
- if (prepend) {
1407
- hooks.unshift(wrappedHook);
1408
- } else {
1409
- hooks.push(wrappedHook);
1309
+ if (ref != null) {
1310
+ setRef(ref, null, parentSuspense, vnode);
1410
1311
  }
1411
- return wrappedHook;
1412
- }
1413
- }
1414
- const createHook = (lifecycle) => (hook, target = currentInstance) => {
1415
- if (!isInSSRComponentSetup || lifecycle === "sp") {
1416
- injectHook(lifecycle, (...args) => hook(...args), target);
1417
- }
1418
- };
1419
- const onBeforeMount = createHook("bm");
1420
- const onMounted = createHook("m");
1421
- const onBeforeUpdate = createHook("bu");
1422
- const onUpdated = createHook("u");
1423
- const onBeforeUnmount = createHook("bum");
1424
- const onUnmounted = createHook("um");
1425
- const onServerPrefetch = createHook("sp");
1426
- const onRenderTriggered = createHook(
1427
- "rtg"
1428
- );
1429
- const onRenderTracked = createHook(
1430
- "rtc"
1431
- );
1432
- function onErrorCaptured(hook, target = currentInstance) {
1433
- injectHook("ec", hook, target);
1434
- }
1435
-
1436
- const COMPONENTS = "components";
1437
- const DIRECTIVES = "directives";
1438
- function resolveComponent(name, maybeSelfReference) {
1439
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
1440
- }
1441
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
1442
- function resolveDynamicComponent(component) {
1443
- if (shared.isString(component)) {
1444
- return resolveAsset(COMPONENTS, component, false) || component;
1445
- } else {
1446
- return component || NULL_DYNAMIC_COMPONENT;
1447
- }
1448
- }
1449
- function resolveDirective(name) {
1450
- return resolveAsset(DIRECTIVES, name);
1451
- }
1452
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
1453
- const instance = currentRenderingInstance || currentInstance;
1454
- if (instance) {
1455
- const Component = instance.type;
1456
- if (type === COMPONENTS) {
1457
- const selfName = getComponentName(
1458
- Component,
1459
- false
1460
- );
1461
- if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
1462
- return Component;
1312
+ return nextNode;
1313
+ };
1314
+ const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1315
+ optimized = optimized || !!vnode.dynamicChildren;
1316
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
1317
+ const forcePatch = type === "input" || type === "option";
1318
+ if (forcePatch || patchFlag !== -1) {
1319
+ if (dirs) {
1320
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
1321
+ }
1322
+ let needCallTransitionHooks = false;
1323
+ if (isTemplateNode(el)) {
1324
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
1325
+ const content = el.content.firstChild;
1326
+ if (needCallTransitionHooks) {
1327
+ transition.beforeEnter(content);
1328
+ }
1329
+ replaceNode(content, el, parentComponent);
1330
+ vnode.el = el = content;
1331
+ }
1332
+ if (shapeFlag & 16 && // skip if element has innerHTML / textContent
1333
+ !(props && (props.innerHTML || props.textContent))) {
1334
+ let next = hydrateChildren(
1335
+ el.firstChild,
1336
+ vnode,
1337
+ el,
1338
+ parentComponent,
1339
+ parentSuspense,
1340
+ slotScopeIds,
1341
+ optimized
1342
+ );
1343
+ while (next) {
1344
+ if (!isMismatchAllowed(el, 1 /* CHILDREN */)) {
1345
+ logMismatchError();
1346
+ }
1347
+ const cur = next;
1348
+ next = next.nextSibling;
1349
+ remove(cur);
1350
+ }
1351
+ } else if (shapeFlag & 8) {
1352
+ if (el.textContent !== vnode.children) {
1353
+ if (!isMismatchAllowed(el, 0 /* TEXT */)) {
1354
+ logMismatchError();
1355
+ }
1356
+ el.textContent = vnode.children;
1357
+ }
1358
+ }
1359
+ if (props) {
1360
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
1361
+ const isCustomElement = el.tagName.includes("-");
1362
+ for (const key in props) {
1363
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
1364
+ key[0] === "." || isCustomElement) {
1365
+ patchProp(el, key, null, props[key], void 0, parentComponent);
1366
+ }
1367
+ }
1368
+ } else if (props.onClick) {
1369
+ patchProp(
1370
+ el,
1371
+ "onClick",
1372
+ null,
1373
+ props.onClick,
1374
+ void 0,
1375
+ parentComponent
1376
+ );
1377
+ } else if (patchFlag & 4 && reactivity.isReactive(props.style)) {
1378
+ for (const key in props.style) props.style[key];
1379
+ }
1380
+ }
1381
+ let vnodeHooks;
1382
+ if (vnodeHooks = props && props.onVnodeBeforeMount) {
1383
+ invokeVNodeHook(vnodeHooks, parentComponent, vnode);
1384
+ }
1385
+ if (dirs) {
1386
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
1387
+ }
1388
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
1389
+ queueEffectWithSuspense(() => {
1390
+ vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
1391
+ needCallTransitionHooks && transition.enter(el);
1392
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
1393
+ }, parentSuspense);
1463
1394
  }
1464
1395
  }
1465
- const res = (
1466
- // local registration
1467
- // check instance[type] first which is resolved for options API
1468
- resolve(instance[type] || Component[type], name) || // global registration
1469
- resolve(instance.appContext[type], name)
1470
- );
1471
- if (!res && maybeSelfReference) {
1472
- return Component;
1473
- }
1474
- return res;
1475
- }
1476
- }
1477
- function resolve(registry, name) {
1478
- return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
1479
- }
1480
-
1481
- function renderList(source, renderItem, cache, index) {
1482
- let ret;
1483
- const cached = cache && cache[index];
1484
- const sourceIsArray = shared.isArray(source);
1485
- const sourceIsReactiveArray = sourceIsArray && reactivity.isReactive(source);
1486
- if (sourceIsArray || shared.isString(source)) {
1487
- if (sourceIsReactiveArray) {
1488
- source = reactivity.shallowReadArray(source);
1489
- }
1490
- ret = new Array(source.length);
1491
- for (let i = 0, l = source.length; i < l; i++) {
1492
- ret[i] = renderItem(
1493
- sourceIsReactiveArray ? reactivity.toReactive(source[i]) : source[i],
1494
- i,
1495
- void 0,
1496
- cached && cached[i]
1497
- );
1396
+ return el.nextSibling;
1397
+ };
1398
+ const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1399
+ optimized = optimized || !!parentVNode.dynamicChildren;
1400
+ const children = parentVNode.children;
1401
+ const l = children.length;
1402
+ for (let i = 0; i < l; i++) {
1403
+ const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
1404
+ const isText = vnode.type === Text;
1405
+ if (node) {
1406
+ if (isText && !optimized) {
1407
+ let next = children[i + 1];
1408
+ if (next && (next = normalizeVNode(next)).type === Text) {
1409
+ insert(
1410
+ createText(
1411
+ node.data.slice(vnode.children.length)
1412
+ ),
1413
+ container,
1414
+ nextSibling(node)
1415
+ );
1416
+ node.data = vnode.children;
1417
+ }
1418
+ }
1419
+ node = hydrateNode(
1420
+ node,
1421
+ vnode,
1422
+ parentComponent,
1423
+ parentSuspense,
1424
+ slotScopeIds,
1425
+ optimized
1426
+ );
1427
+ } else if (isText && !vnode.children) {
1428
+ insert(vnode.el = createText(""), container);
1429
+ } else {
1430
+ if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
1431
+ logMismatchError();
1432
+ }
1433
+ patch(
1434
+ null,
1435
+ vnode,
1436
+ container,
1437
+ null,
1438
+ parentComponent,
1439
+ parentSuspense,
1440
+ getContainerType(container),
1441
+ slotScopeIds
1442
+ );
1443
+ }
1498
1444
  }
1499
- } else if (typeof source === "number") {
1500
- ret = new Array(source);
1501
- for (let i = 0; i < source; i++) {
1502
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
1445
+ return node;
1446
+ };
1447
+ const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1448
+ const { slotScopeIds: fragmentSlotScopeIds } = vnode;
1449
+ if (fragmentSlotScopeIds) {
1450
+ slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
1503
1451
  }
1504
- } else if (shared.isObject(source)) {
1505
- if (source[Symbol.iterator]) {
1506
- ret = Array.from(
1507
- source,
1508
- (item, i) => renderItem(item, i, void 0, cached && cached[i])
1509
- );
1452
+ const container = parentNode(node);
1453
+ const next = hydrateChildren(
1454
+ nextSibling(node),
1455
+ vnode,
1456
+ container,
1457
+ parentComponent,
1458
+ parentSuspense,
1459
+ slotScopeIds,
1460
+ optimized
1461
+ );
1462
+ if (next && isComment(next) && next.data === "]") {
1463
+ return nextSibling(vnode.anchor = next);
1510
1464
  } else {
1511
- const keys = Object.keys(source);
1512
- ret = new Array(keys.length);
1513
- for (let i = 0, l = keys.length; i < l; i++) {
1514
- const key = keys[i];
1515
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
1516
- }
1517
- }
1518
- } else {
1519
- ret = [];
1520
- }
1521
- if (cache) {
1522
- cache[index] = ret;
1523
- }
1524
- return ret;
1525
- }
1526
-
1527
- function createSlots(slots, dynamicSlots) {
1528
- for (let i = 0; i < dynamicSlots.length; i++) {
1529
- const slot = dynamicSlots[i];
1530
- if (shared.isArray(slot)) {
1531
- for (let j = 0; j < slot.length; j++) {
1532
- slots[slot[j].name] = slot[j].fn;
1533
- }
1534
- } else if (slot) {
1535
- slots[slot.name] = slot.key ? (...args) => {
1536
- const res = slot.fn(...args);
1537
- if (res) res.key = slot.key;
1538
- return res;
1539
- } : slot.fn;
1465
+ logMismatchError();
1466
+ insert(vnode.anchor = createComment(`]`), container, next);
1467
+ return next;
1540
1468
  }
1541
- }
1542
- return slots;
1543
- }
1544
-
1545
- function renderSlot(slots, name, props = {}, fallback, noSlotted) {
1546
- if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
1547
- if (name !== "default") props.name = name;
1548
- return createVNode("slot", props, fallback && fallback());
1549
- }
1550
- let slot = slots[name];
1551
- if (slot && slot._c) {
1552
- slot._d = false;
1553
- }
1554
- openBlock();
1555
- const validSlotContent = slot && ensureValidVNode(slot(props));
1556
- const rendered = createBlock(
1557
- Fragment,
1558
- {
1559
- key: (props.key || // slot content array of a dynamic conditional slot may have a branch
1560
- // key attached in the `createSlots` helper, respect that
1561
- validSlotContent && validSlotContent.key || `_${name}`) + // #7256 force differentiate fallback content from actual content
1562
- (!validSlotContent && fallback ? "_fb" : "")
1563
- },
1564
- validSlotContent || (fallback ? fallback() : []),
1565
- validSlotContent && slots._ === 1 ? 64 : -2
1566
- );
1567
- if (!noSlotted && rendered.scopeId) {
1568
- rendered.slotScopeIds = [rendered.scopeId + "-s"];
1569
- }
1570
- if (slot && slot._c) {
1571
- slot._d = true;
1572
- }
1573
- return rendered;
1574
- }
1575
- function ensureValidVNode(vnodes) {
1576
- return vnodes.some((child) => {
1577
- if (!isVNode(child)) return true;
1578
- if (child.type === Comment) return false;
1579
- if (child.type === Fragment && !ensureValidVNode(child.children))
1580
- return false;
1581
- return true;
1582
- }) ? vnodes : null;
1583
- }
1584
-
1585
- function toHandlers(obj, preserveCaseIfNecessary) {
1586
- const ret = {};
1587
- for (const key in obj) {
1588
- ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : shared.toHandlerKey(key)] = obj[key];
1589
- }
1590
- return ret;
1591
- }
1592
-
1593
- const getPublicInstance = (i) => {
1594
- if (!i) return null;
1595
- if (isStatefulComponent(i)) return getComponentPublicInstance(i);
1596
- return getPublicInstance(i.parent);
1597
- };
1598
- const publicPropertiesMap = (
1599
- // Move PURE marker to new line to workaround compiler discarding it
1600
- // due to type annotation
1601
- /* @__PURE__ */ shared.extend(/* @__PURE__ */ Object.create(null), {
1602
- $: (i) => i,
1603
- $el: (i) => i.vnode.el,
1604
- $data: (i) => i.data,
1605
- $props: (i) => i.props,
1606
- $attrs: (i) => i.attrs,
1607
- $slots: (i) => i.slots,
1608
- $refs: (i) => i.refs,
1609
- $parent: (i) => getPublicInstance(i.parent),
1610
- $root: (i) => getPublicInstance(i.root),
1611
- $emit: (i) => i.emit,
1612
- $options: (i) => resolveMergedOptions(i) ,
1613
- $forceUpdate: (i) => i.f || (i.f = () => {
1614
- queueJob(i.update);
1615
- }),
1616
- $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
1617
- $watch: (i) => instanceWatch.bind(i)
1618
- })
1619
- );
1620
- const hasSetupBinding = (state, key) => state !== shared.EMPTY_OBJ && !state.__isScriptSetup && shared.hasOwn(state, key);
1621
- const PublicInstanceProxyHandlers = {
1622
- get({ _: instance }, key) {
1623
- if (key === "__v_skip") {
1624
- return true;
1469
+ };
1470
+ const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
1471
+ if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
1472
+ logMismatchError();
1625
1473
  }
1626
- const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
1627
- let normalizedProps;
1628
- if (key[0] !== "$") {
1629
- const n = accessCache[key];
1630
- if (n !== void 0) {
1631
- switch (n) {
1632
- case 1 /* SETUP */:
1633
- return setupState[key];
1634
- case 2 /* DATA */:
1635
- return data[key];
1636
- case 4 /* CONTEXT */:
1637
- return ctx[key];
1638
- case 3 /* PROPS */:
1639
- return props[key];
1474
+ vnode.el = null;
1475
+ if (isFragment) {
1476
+ const end = locateClosingAnchor(node);
1477
+ while (true) {
1478
+ const next2 = nextSibling(node);
1479
+ if (next2 && next2 !== end) {
1480
+ remove(next2);
1481
+ } else {
1482
+ break;
1640
1483
  }
1641
- } else if (hasSetupBinding(setupState, key)) {
1642
- accessCache[key] = 1 /* SETUP */;
1643
- return setupState[key];
1644
- } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
1645
- accessCache[key] = 2 /* DATA */;
1646
- return data[key];
1647
- } else if (
1648
- // only cache other properties when instance has declared (thus stable)
1649
- // props
1650
- (normalizedProps = instance.propsOptions[0]) && shared.hasOwn(normalizedProps, key)
1651
- ) {
1652
- accessCache[key] = 3 /* PROPS */;
1653
- return props[key];
1654
- } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
1655
- accessCache[key] = 4 /* CONTEXT */;
1656
- return ctx[key];
1657
- } else if (shouldCacheAccess) {
1658
- accessCache[key] = 0 /* OTHER */;
1659
1484
  }
1660
1485
  }
1661
- const publicGetter = publicPropertiesMap[key];
1662
- let cssModule, globalProperties;
1663
- if (publicGetter) {
1664
- if (key === "$attrs") {
1665
- reactivity.track(instance.attrs, "get", "");
1666
- }
1667
- return publicGetter(instance);
1668
- } else if (
1669
- // css module (injected by vue-loader)
1670
- (cssModule = type.__cssModules) && (cssModule = cssModule[key])
1671
- ) {
1672
- return cssModule;
1673
- } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
1674
- accessCache[key] = 4 /* CONTEXT */;
1675
- return ctx[key];
1676
- } else if (
1677
- // global properties
1678
- globalProperties = appContext.config.globalProperties, shared.hasOwn(globalProperties, key)
1679
- ) {
1680
- {
1681
- return globalProperties[key];
1682
- }
1683
- } else ;
1684
- },
1685
- set({ _: instance }, key, value) {
1686
- const { data, setupState, ctx } = instance;
1687
- if (hasSetupBinding(setupState, key)) {
1688
- setupState[key] = value;
1689
- return true;
1690
- } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
1691
- data[key] = value;
1692
- return true;
1693
- } else if (shared.hasOwn(instance.props, key)) {
1694
- return false;
1695
- }
1696
- if (key[0] === "$" && key.slice(1) in instance) {
1697
- return false;
1698
- } else {
1699
- {
1700
- ctx[key] = value;
1486
+ const next = nextSibling(node);
1487
+ const container = parentNode(node);
1488
+ remove(node);
1489
+ patch(
1490
+ null,
1491
+ vnode,
1492
+ container,
1493
+ next,
1494
+ parentComponent,
1495
+ parentSuspense,
1496
+ getContainerType(container),
1497
+ slotScopeIds
1498
+ );
1499
+ return next;
1500
+ };
1501
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
1502
+ let match = 0;
1503
+ while (node) {
1504
+ node = nextSibling(node);
1505
+ if (node && isComment(node)) {
1506
+ if (node.data === open) match++;
1507
+ if (node.data === close) {
1508
+ if (match === 0) {
1509
+ return nextSibling(node);
1510
+ } else {
1511
+ match--;
1512
+ }
1513
+ }
1701
1514
  }
1702
1515
  }
1703
- return true;
1704
- },
1705
- has({
1706
- _: { data, setupState, accessCache, ctx, appContext, propsOptions }
1707
- }, key) {
1708
- let normalizedProps;
1709
- return !!accessCache[key] || data !== shared.EMPTY_OBJ && shared.hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && shared.hasOwn(normalizedProps, key) || shared.hasOwn(ctx, key) || shared.hasOwn(publicPropertiesMap, key) || shared.hasOwn(appContext.config.globalProperties, key);
1710
- },
1711
- defineProperty(target, key, descriptor) {
1712
- if (descriptor.get != null) {
1713
- target._.accessCache[key] = 0;
1714
- } else if (shared.hasOwn(descriptor, "value")) {
1715
- this.set(target, key, descriptor.value, null);
1516
+ return node;
1517
+ };
1518
+ const replaceNode = (newNode, oldNode, parentComponent) => {
1519
+ const parentNode2 = oldNode.parentNode;
1520
+ if (parentNode2) {
1521
+ parentNode2.replaceChild(newNode, oldNode);
1716
1522
  }
1717
- return Reflect.defineProperty(target, key, descriptor);
1718
- }
1719
- };
1720
- const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ shared.extend(
1721
- {},
1722
- PublicInstanceProxyHandlers,
1723
- {
1724
- get(target, key) {
1725
- if (key === Symbol.unscopables) {
1726
- return;
1523
+ let parent = parentComponent;
1524
+ while (parent) {
1525
+ if (parent.vnode.el === oldNode) {
1526
+ parent.vnode.el = parent.subTree.el = newNode;
1727
1527
  }
1728
- return PublicInstanceProxyHandlers.get(target, key, target);
1729
- },
1730
- has(_, key) {
1731
- const has = key[0] !== "_" && !shared.isGloballyAllowed(key);
1732
- return has;
1528
+ parent = parent.parent;
1733
1529
  }
1734
- }
1735
- );
1736
-
1737
- function defineProps() {
1738
- return null;
1739
- }
1740
- function defineEmits() {
1741
- return null;
1742
- }
1743
- function defineExpose(exposed) {
1744
- }
1745
- function defineOptions(options) {
1746
- }
1747
- function defineSlots() {
1748
- return null;
1749
- }
1750
- function defineModel() {
1751
- }
1752
- function withDefaults(props, defaults) {
1753
- return null;
1754
- }
1755
- function useSlots() {
1756
- return getContext().slots;
1757
- }
1758
- function useAttrs() {
1759
- return getContext().attrs;
1760
- }
1761
- function getContext() {
1762
- const i = getCurrentInstance();
1763
- return i.setupContext || (i.setupContext = createSetupContext(i));
1764
- }
1765
- function normalizePropsOrEmits(props) {
1766
- return shared.isArray(props) ? props.reduce(
1767
- (normalized, p) => (normalized[p] = null, normalized),
1768
- {}
1769
- ) : props;
1530
+ };
1531
+ const isTemplateNode = (node) => {
1532
+ return node.nodeType === 1 && node.tagName.toLowerCase() === "template";
1533
+ };
1534
+ return [hydrate, hydrateNode];
1770
1535
  }
1771
- function mergeDefaults(raw, defaults) {
1772
- const props = normalizePropsOrEmits(raw);
1773
- for (const key in defaults) {
1774
- if (key.startsWith("__skip")) continue;
1775
- let opt = props[key];
1776
- if (opt) {
1777
- if (shared.isArray(opt) || shared.isFunction(opt)) {
1778
- opt = props[key] = { type: opt, default: defaults[key] };
1779
- } else {
1780
- opt.default = defaults[key];
1781
- }
1782
- } else if (opt === null) {
1783
- opt = props[key] = { default: defaults[key] };
1784
- } else ;
1785
- if (opt && defaults[`__skip_${key}`]) {
1786
- opt.skipFactory = true;
1536
+ const allowMismatchAttr = "data-allow-mismatch";
1537
+ const MismatchTypeString = {
1538
+ [0 /* TEXT */]: "text",
1539
+ [1 /* CHILDREN */]: "children",
1540
+ [2 /* CLASS */]: "class",
1541
+ [3 /* STYLE */]: "style",
1542
+ [4 /* ATTRIBUTE */]: "attribute"
1543
+ };
1544
+ function isMismatchAllowed(el, allowedType) {
1545
+ if (allowedType === 0 /* TEXT */ || allowedType === 1 /* CHILDREN */) {
1546
+ while (el && !el.hasAttribute(allowMismatchAttr)) {
1547
+ el = el.parentElement;
1787
1548
  }
1788
1549
  }
1789
- return props;
1790
- }
1791
- function mergeModels(a, b) {
1792
- if (!a || !b) return a || b;
1793
- if (shared.isArray(a) && shared.isArray(b)) return a.concat(b);
1794
- return shared.extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
1795
- }
1796
- function createPropsRestProxy(props, excludedKeys) {
1797
- const ret = {};
1798
- for (const key in props) {
1799
- if (!excludedKeys.includes(key)) {
1800
- Object.defineProperty(ret, key, {
1801
- enumerable: true,
1802
- get: () => props[key]
1803
- });
1550
+ const allowedAttr = el && el.getAttribute(allowMismatchAttr);
1551
+ if (allowedAttr == null) {
1552
+ return false;
1553
+ } else if (allowedAttr === "") {
1554
+ return true;
1555
+ } else {
1556
+ const list = allowedAttr.split(",");
1557
+ if (allowedType === 0 /* TEXT */ && list.includes("children")) {
1558
+ return true;
1804
1559
  }
1560
+ return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
1805
1561
  }
1806
- return ret;
1807
1562
  }
1808
- function withAsyncContext(getAwaitable) {
1809
- const ctx = getCurrentInstance();
1810
- let awaitable = getAwaitable();
1811
- unsetCurrentInstance();
1812
- if (shared.isPromise(awaitable)) {
1813
- awaitable = awaitable.catch((e) => {
1814
- setCurrentInstance(ctx);
1815
- throw e;
1563
+
1564
+ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
1565
+ const id = requestIdleCallback(hydrate, { timeout });
1566
+ return () => cancelIdleCallback(id);
1567
+ };
1568
+ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
1569
+ const ob = new IntersectionObserver((entries) => {
1570
+ for (const e of entries) {
1571
+ if (!e.isIntersecting) continue;
1572
+ ob.disconnect();
1573
+ hydrate();
1574
+ break;
1575
+ }
1576
+ }, opts);
1577
+ forEach((el) => ob.observe(el));
1578
+ return () => ob.disconnect();
1579
+ };
1580
+ const hydrateOnMediaQuery = (query) => (hydrate) => {
1581
+ if (query) {
1582
+ const mql = matchMedia(query);
1583
+ if (mql.matches) {
1584
+ hydrate();
1585
+ } else {
1586
+ mql.addEventListener("change", hydrate, { once: true });
1587
+ return () => mql.removeEventListener("change", hydrate);
1588
+ }
1589
+ }
1590
+ };
1591
+ const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => {
1592
+ if (shared.isString(interactions)) interactions = [interactions];
1593
+ let hasHydrated = false;
1594
+ const doHydrate = (e) => {
1595
+ if (!hasHydrated) {
1596
+ hasHydrated = true;
1597
+ teardown();
1598
+ hydrate();
1599
+ e.target.dispatchEvent(new e.constructor(e.type, e));
1600
+ }
1601
+ };
1602
+ const teardown = () => {
1603
+ forEach((el) => {
1604
+ for (const i of interactions) {
1605
+ el.removeEventListener(i, doHydrate);
1606
+ }
1816
1607
  });
1608
+ };
1609
+ forEach((el) => {
1610
+ for (const i of interactions) {
1611
+ el.addEventListener(i, doHydrate, { once: true });
1612
+ }
1613
+ });
1614
+ return teardown;
1615
+ };
1616
+ function forEachElement(node, cb) {
1617
+ if (isComment(node) && node.data === "[") {
1618
+ let depth = 1;
1619
+ let next = node.nextSibling;
1620
+ while (next) {
1621
+ if (next.nodeType === 1) {
1622
+ cb(next);
1623
+ } else if (isComment(next)) {
1624
+ if (next.data === "]") {
1625
+ if (--depth === 0) break;
1626
+ } else if (next.data === "[") {
1627
+ depth++;
1628
+ }
1629
+ }
1630
+ next = next.nextSibling;
1631
+ }
1632
+ } else {
1633
+ cb(node);
1817
1634
  }
1818
- return [awaitable, () => setCurrentInstance(ctx)];
1819
1635
  }
1820
1636
 
1821
- let shouldCacheAccess = true;
1822
- function applyOptions(instance) {
1823
- const options = resolveMergedOptions(instance);
1824
- const publicThis = instance.proxy;
1825
- const ctx = instance.ctx;
1826
- shouldCacheAccess = false;
1827
- if (options.beforeCreate) {
1828
- callHook(options.beforeCreate, instance, "bc");
1637
+ const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
1638
+ /*! #__NO_SIDE_EFFECTS__ */
1639
+ // @__NO_SIDE_EFFECTS__
1640
+ function defineAsyncComponent(source) {
1641
+ if (shared.isFunction(source)) {
1642
+ source = { loader: source };
1829
1643
  }
1830
1644
  const {
1831
- // state
1832
- data: dataOptions,
1833
- computed: computedOptions,
1834
- methods,
1835
- watch: watchOptions,
1836
- provide: provideOptions,
1837
- inject: injectOptions,
1838
- // lifecycle
1839
- created,
1840
- beforeMount,
1841
- mounted,
1842
- beforeUpdate,
1843
- updated,
1844
- activated,
1845
- deactivated,
1846
- beforeDestroy,
1847
- beforeUnmount,
1848
- destroyed,
1849
- unmounted,
1850
- render,
1851
- renderTracked,
1852
- renderTriggered,
1853
- errorCaptured,
1854
- serverPrefetch,
1855
- // public API
1856
- expose,
1857
- inheritAttrs,
1858
- // assets
1859
- components,
1860
- directives,
1861
- filters
1862
- } = options;
1863
- const checkDuplicateProperties = null;
1864
- if (injectOptions) {
1865
- resolveInjections(injectOptions, ctx, checkDuplicateProperties);
1866
- }
1867
- if (methods) {
1868
- for (const key in methods) {
1869
- const methodHandler = methods[key];
1870
- if (shared.isFunction(methodHandler)) {
1871
- {
1872
- ctx[key] = methodHandler.bind(publicThis);
1645
+ loader,
1646
+ loadingComponent,
1647
+ errorComponent,
1648
+ delay = 200,
1649
+ hydrate: hydrateStrategy,
1650
+ timeout,
1651
+ // undefined = never times out
1652
+ suspensible = true,
1653
+ onError: userOnError
1654
+ } = source;
1655
+ let pendingRequest = null;
1656
+ let resolvedComp;
1657
+ let retries = 0;
1658
+ const retry = () => {
1659
+ retries++;
1660
+ pendingRequest = null;
1661
+ return load();
1662
+ };
1663
+ const load = () => {
1664
+ let thisRequest;
1665
+ return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
1666
+ err = err instanceof Error ? err : new Error(String(err));
1667
+ if (userOnError) {
1668
+ return new Promise((resolve, reject) => {
1669
+ const userRetry = () => resolve(retry());
1670
+ const userFail = () => reject(err);
1671
+ userOnError(err, userRetry, userFail, retries + 1);
1672
+ });
1673
+ } else {
1674
+ throw err;
1675
+ }
1676
+ }).then((comp) => {
1677
+ if (thisRequest !== pendingRequest && pendingRequest) {
1678
+ return pendingRequest;
1679
+ }
1680
+ if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
1681
+ comp = comp.default;
1682
+ }
1683
+ resolvedComp = comp;
1684
+ return comp;
1685
+ }));
1686
+ };
1687
+ return defineComponent({
1688
+ name: "AsyncComponentWrapper",
1689
+ __asyncLoader: load,
1690
+ __asyncHydrate(el, instance, hydrate) {
1691
+ const doHydrate = hydrateStrategy ? () => {
1692
+ const teardown = hydrateStrategy(
1693
+ hydrate,
1694
+ (cb) => forEachElement(el, cb)
1695
+ );
1696
+ if (teardown) {
1697
+ (instance.bum || (instance.bum = [])).push(teardown);
1873
1698
  }
1699
+ } : hydrate;
1700
+ if (resolvedComp) {
1701
+ doHydrate();
1702
+ } else {
1703
+ load().then(() => !instance.isUnmounted && doHydrate());
1704
+ }
1705
+ },
1706
+ get __asyncResolved() {
1707
+ return resolvedComp;
1708
+ },
1709
+ setup() {
1710
+ const instance = currentInstance;
1711
+ markAsyncBoundary(instance);
1712
+ if (resolvedComp) {
1713
+ return () => createInnerComp(resolvedComp, instance);
1714
+ }
1715
+ const onError = (err) => {
1716
+ pendingRequest = null;
1717
+ handleError(
1718
+ err,
1719
+ instance,
1720
+ 13,
1721
+ !errorComponent
1722
+ );
1723
+ };
1724
+ if (suspensible && instance.suspense || isInSSRComponentSetup) {
1725
+ return load().then((comp) => {
1726
+ return () => createInnerComp(comp, instance);
1727
+ }).catch((err) => {
1728
+ onError(err);
1729
+ return () => errorComponent ? createVNode(errorComponent, {
1730
+ error: err
1731
+ }) : null;
1732
+ });
1874
1733
  }
1875
- }
1876
- }
1877
- if (dataOptions) {
1878
- const data = dataOptions.call(publicThis, publicThis);
1879
- if (!shared.isObject(data)) ; else {
1880
- instance.data = reactivity.reactive(data);
1881
- }
1882
- }
1883
- shouldCacheAccess = true;
1884
- if (computedOptions) {
1885
- for (const key in computedOptions) {
1886
- const opt = computedOptions[key];
1887
- const get = shared.isFunction(opt) ? opt.bind(publicThis, publicThis) : shared.isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : shared.NOOP;
1888
- const set = !shared.isFunction(opt) && shared.isFunction(opt.set) ? opt.set.bind(publicThis) : shared.NOOP;
1889
- const c = computed({
1890
- get,
1891
- set
1892
- });
1893
- Object.defineProperty(ctx, key, {
1894
- enumerable: true,
1895
- configurable: true,
1896
- get: () => c.value,
1897
- set: (v) => c.value = v
1734
+ const loaded = reactivity.ref(false);
1735
+ const error = reactivity.ref();
1736
+ const delayed = reactivity.ref(!!delay);
1737
+ if (delay) {
1738
+ setTimeout(() => {
1739
+ delayed.value = false;
1740
+ }, delay);
1741
+ }
1742
+ if (timeout != null) {
1743
+ setTimeout(() => {
1744
+ if (!loaded.value && !error.value) {
1745
+ const err = new Error(
1746
+ `Async component timed out after ${timeout}ms.`
1747
+ );
1748
+ onError(err);
1749
+ error.value = err;
1750
+ }
1751
+ }, timeout);
1752
+ }
1753
+ load().then(() => {
1754
+ loaded.value = true;
1755
+ if (instance.parent && isKeepAlive(instance.parent.vnode)) {
1756
+ queueJob(instance.parent.update);
1757
+ }
1758
+ }).catch((err) => {
1759
+ onError(err);
1760
+ error.value = err;
1898
1761
  });
1762
+ return () => {
1763
+ if (loaded.value && resolvedComp) {
1764
+ return createInnerComp(resolvedComp, instance);
1765
+ } else if (error.value && errorComponent) {
1766
+ return createVNode(errorComponent, {
1767
+ error: error.value
1768
+ });
1769
+ } else if (loadingComponent && !delayed.value) {
1770
+ return createVNode(loadingComponent);
1771
+ }
1772
+ };
1899
1773
  }
1900
- }
1901
- if (watchOptions) {
1902
- for (const key in watchOptions) {
1903
- createWatcher(watchOptions[key], ctx, publicThis, key);
1774
+ });
1775
+ }
1776
+ function createInnerComp(comp, parent) {
1777
+ const { ref: ref2, props, children, ce } = parent.vnode;
1778
+ const vnode = createVNode(comp, props, children);
1779
+ vnode.ref = ref2;
1780
+ vnode.ce = ce;
1781
+ delete parent.vnode.ce;
1782
+ return vnode;
1783
+ }
1784
+
1785
+ const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
1786
+ const KeepAliveImpl = {
1787
+ name: `KeepAlive`,
1788
+ // Marker for special handling inside the renderer. We are not using a ===
1789
+ // check directly on KeepAlive in the renderer, because importing it directly
1790
+ // would prevent it from being tree-shaken.
1791
+ __isKeepAlive: true,
1792
+ props: {
1793
+ include: [String, RegExp, Array],
1794
+ exclude: [String, RegExp, Array],
1795
+ max: [String, Number]
1796
+ },
1797
+ setup(props, { slots }) {
1798
+ const instance = getCurrentInstance();
1799
+ const sharedContext = instance.ctx;
1800
+ if (!sharedContext.renderer) {
1801
+ return () => {
1802
+ const children = slots.default && slots.default();
1803
+ return children && children.length === 1 ? children[0] : children;
1804
+ };
1904
1805
  }
1905
- }
1906
- if (provideOptions) {
1907
- const provides = shared.isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
1908
- Reflect.ownKeys(provides).forEach((key) => {
1909
- provide(key, provides[key]);
1910
- });
1911
- }
1912
- if (created) {
1913
- callHook(created, instance, "c");
1914
- }
1915
- function registerLifecycleHook(register, hook) {
1916
- if (shared.isArray(hook)) {
1917
- hook.forEach((_hook) => register(_hook.bind(publicThis)));
1918
- } else if (hook) {
1919
- register(hook.bind(publicThis));
1806
+ const cache = /* @__PURE__ */ new Map();
1807
+ const keys = /* @__PURE__ */ new Set();
1808
+ let current = null;
1809
+ const parentSuspense = instance.suspense;
1810
+ const {
1811
+ renderer: {
1812
+ p: patch,
1813
+ m: move,
1814
+ um: _unmount,
1815
+ o: { createElement }
1816
+ }
1817
+ } = sharedContext;
1818
+ const storageContainer = createElement("div");
1819
+ sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
1820
+ const instance2 = vnode.component;
1821
+ move(vnode, container, anchor, 0, parentSuspense);
1822
+ patch(
1823
+ instance2.vnode,
1824
+ vnode,
1825
+ container,
1826
+ anchor,
1827
+ instance2,
1828
+ parentSuspense,
1829
+ namespace,
1830
+ vnode.slotScopeIds,
1831
+ optimized
1832
+ );
1833
+ queuePostRenderEffect(() => {
1834
+ instance2.isDeactivated = false;
1835
+ if (instance2.a) {
1836
+ shared.invokeArrayFns(instance2.a);
1837
+ }
1838
+ const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
1839
+ if (vnodeHook) {
1840
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1841
+ }
1842
+ }, parentSuspense);
1843
+ };
1844
+ sharedContext.deactivate = (vnode) => {
1845
+ const instance2 = vnode.component;
1846
+ invalidateMount(instance2.m);
1847
+ invalidateMount(instance2.a);
1848
+ move(vnode, storageContainer, null, 1, parentSuspense);
1849
+ queuePostRenderEffect(() => {
1850
+ if (instance2.da) {
1851
+ shared.invokeArrayFns(instance2.da);
1852
+ }
1853
+ const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
1854
+ if (vnodeHook) {
1855
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1856
+ }
1857
+ instance2.isDeactivated = true;
1858
+ }, parentSuspense);
1859
+ };
1860
+ function unmount(vnode) {
1861
+ resetShapeFlag(vnode);
1862
+ _unmount(vnode, instance, parentSuspense, true);
1920
1863
  }
1921
- }
1922
- registerLifecycleHook(onBeforeMount, beforeMount);
1923
- registerLifecycleHook(onMounted, mounted);
1924
- registerLifecycleHook(onBeforeUpdate, beforeUpdate);
1925
- registerLifecycleHook(onUpdated, updated);
1926
- registerLifecycleHook(onActivated, activated);
1927
- registerLifecycleHook(onDeactivated, deactivated);
1928
- registerLifecycleHook(onErrorCaptured, errorCaptured);
1929
- registerLifecycleHook(onRenderTracked, renderTracked);
1930
- registerLifecycleHook(onRenderTriggered, renderTriggered);
1931
- registerLifecycleHook(onBeforeUnmount, beforeUnmount);
1932
- registerLifecycleHook(onUnmounted, unmounted);
1933
- registerLifecycleHook(onServerPrefetch, serverPrefetch);
1934
- if (shared.isArray(expose)) {
1935
- if (expose.length) {
1936
- const exposed = instance.exposed || (instance.exposed = {});
1937
- expose.forEach((key) => {
1938
- Object.defineProperty(exposed, key, {
1939
- get: () => publicThis[key],
1940
- set: (val) => publicThis[key] = val
1941
- });
1864
+ function pruneCache(filter) {
1865
+ cache.forEach((vnode, key) => {
1866
+ const name = getComponentName(vnode.type);
1867
+ if (name && (!filter || !filter(name))) {
1868
+ pruneCacheEntry(key);
1869
+ }
1942
1870
  });
1943
- } else if (!instance.exposed) {
1944
- instance.exposed = {};
1945
1871
  }
1872
+ function pruneCacheEntry(key) {
1873
+ const cached = cache.get(key);
1874
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
1875
+ unmount(cached);
1876
+ } else if (current) {
1877
+ resetShapeFlag(current);
1878
+ }
1879
+ cache.delete(key);
1880
+ keys.delete(key);
1881
+ }
1882
+ watch(
1883
+ () => [props.include, props.exclude],
1884
+ ([include, exclude]) => {
1885
+ include && pruneCache((name) => matches(include, name));
1886
+ exclude && pruneCache((name) => !matches(exclude, name));
1887
+ },
1888
+ // prune post-render after `current` has been updated
1889
+ { flush: "post", deep: true }
1890
+ );
1891
+ let pendingCacheKey = null;
1892
+ const cacheSubtree = () => {
1893
+ if (pendingCacheKey != null) {
1894
+ if (isSuspense(instance.subTree.type)) {
1895
+ queuePostRenderEffect(() => {
1896
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1897
+ }, instance.subTree.suspense);
1898
+ } else {
1899
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1900
+ }
1901
+ }
1902
+ };
1903
+ onMounted(cacheSubtree);
1904
+ onUpdated(cacheSubtree);
1905
+ onBeforeUnmount(() => {
1906
+ cache.forEach((cached) => {
1907
+ const { subTree, suspense } = instance;
1908
+ const vnode = getInnerChild(subTree);
1909
+ if (cached.type === vnode.type && cached.key === vnode.key) {
1910
+ resetShapeFlag(vnode);
1911
+ const da = vnode.component.da;
1912
+ da && queuePostRenderEffect(da, suspense);
1913
+ return;
1914
+ }
1915
+ unmount(cached);
1916
+ });
1917
+ });
1918
+ return () => {
1919
+ pendingCacheKey = null;
1920
+ if (!slots.default) {
1921
+ return null;
1922
+ }
1923
+ const children = slots.default();
1924
+ const rawVNode = children[0];
1925
+ if (children.length > 1) {
1926
+ current = null;
1927
+ return children;
1928
+ } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
1929
+ current = null;
1930
+ return rawVNode;
1931
+ }
1932
+ let vnode = getInnerChild(rawVNode);
1933
+ if (vnode.type === Comment) {
1934
+ current = null;
1935
+ return vnode;
1936
+ }
1937
+ const comp = vnode.type;
1938
+ const name = getComponentName(
1939
+ isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
1940
+ );
1941
+ const { include, exclude, max } = props;
1942
+ if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
1943
+ current = vnode;
1944
+ return rawVNode;
1945
+ }
1946
+ const key = vnode.key == null ? comp : vnode.key;
1947
+ const cachedVNode = cache.get(key);
1948
+ if (vnode.el) {
1949
+ vnode = cloneVNode(vnode);
1950
+ if (rawVNode.shapeFlag & 128) {
1951
+ rawVNode.ssContent = vnode;
1952
+ }
1953
+ }
1954
+ pendingCacheKey = key;
1955
+ if (cachedVNode) {
1956
+ vnode.el = cachedVNode.el;
1957
+ vnode.component = cachedVNode.component;
1958
+ if (vnode.transition) {
1959
+ setTransitionHooks(vnode, vnode.transition);
1960
+ }
1961
+ vnode.shapeFlag |= 512;
1962
+ keys.delete(key);
1963
+ keys.add(key);
1964
+ } else {
1965
+ keys.add(key);
1966
+ if (max && keys.size > parseInt(max, 10)) {
1967
+ pruneCacheEntry(keys.values().next().value);
1968
+ }
1969
+ }
1970
+ vnode.shapeFlag |= 256;
1971
+ current = vnode;
1972
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
1973
+ };
1946
1974
  }
1947
- if (render && instance.render === shared.NOOP) {
1948
- instance.render = render;
1949
- }
1950
- if (inheritAttrs != null) {
1951
- instance.inheritAttrs = inheritAttrs;
1952
- }
1953
- if (components) instance.components = components;
1954
- if (directives) instance.directives = directives;
1955
- if (serverPrefetch) {
1956
- markAsyncBoundary(instance);
1975
+ };
1976
+ const KeepAlive = KeepAliveImpl;
1977
+ function matches(pattern, name) {
1978
+ if (shared.isArray(pattern)) {
1979
+ return pattern.some((p) => matches(p, name));
1980
+ } else if (shared.isString(pattern)) {
1981
+ return pattern.split(",").includes(name);
1982
+ } else if (shared.isRegExp(pattern)) {
1983
+ return pattern.test(name);
1957
1984
  }
1985
+ return false;
1958
1986
  }
1959
- function resolveInjections(injectOptions, ctx, checkDuplicateProperties = shared.NOOP) {
1960
- if (shared.isArray(injectOptions)) {
1961
- injectOptions = normalizeInject(injectOptions);
1962
- }
1963
- for (const key in injectOptions) {
1964
- const opt = injectOptions[key];
1965
- let injected;
1966
- if (shared.isObject(opt)) {
1967
- if ("default" in opt) {
1968
- injected = inject(
1969
- opt.from || key,
1970
- opt.default,
1971
- true
1972
- );
1973
- } else {
1974
- injected = inject(opt.from || key);
1987
+ function onActivated(hook, target) {
1988
+ registerKeepAliveHook(hook, "a", target);
1989
+ }
1990
+ function onDeactivated(hook, target) {
1991
+ registerKeepAliveHook(hook, "da", target);
1992
+ }
1993
+ function registerKeepAliveHook(hook, type, target = currentInstance) {
1994
+ const wrappedHook = hook.__wdc || (hook.__wdc = () => {
1995
+ let current = target;
1996
+ while (current) {
1997
+ if (current.isDeactivated) {
1998
+ return;
1975
1999
  }
1976
- } else {
1977
- injected = inject(opt);
2000
+ current = current.parent;
1978
2001
  }
1979
- if (reactivity.isRef(injected)) {
1980
- Object.defineProperty(ctx, key, {
1981
- enumerable: true,
1982
- configurable: true,
1983
- get: () => injected.value,
1984
- set: (v) => injected.value = v
1985
- });
1986
- } else {
1987
- ctx[key] = injected;
2002
+ return hook();
2003
+ });
2004
+ injectHook(type, wrappedHook, target);
2005
+ if (target) {
2006
+ let current = target.parent;
2007
+ while (current && current.parent) {
2008
+ if (isKeepAlive(current.parent.vnode)) {
2009
+ injectToKeepAliveRoot(wrappedHook, type, target, current);
2010
+ }
2011
+ current = current.parent;
1988
2012
  }
1989
2013
  }
1990
2014
  }
1991
- function callHook(hook, instance, type) {
1992
- callWithAsyncErrorHandling(
1993
- shared.isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
1994
- instance,
1995
- type
2015
+ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
2016
+ const injected = injectHook(
2017
+ type,
2018
+ hook,
2019
+ keepAliveRoot,
2020
+ true
2021
+ /* prepend */
1996
2022
  );
2023
+ onUnmounted(() => {
2024
+ shared.remove(keepAliveRoot[type], injected);
2025
+ }, target);
1997
2026
  }
1998
- function createWatcher(raw, ctx, publicThis, key) {
1999
- const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
2000
- if (shared.isString(raw)) {
2001
- const handler = ctx[raw];
2002
- if (shared.isFunction(handler)) {
2003
- watch(getter, handler);
2004
- }
2005
- } else if (shared.isFunction(raw)) {
2006
- watch(getter, raw.bind(publicThis));
2007
- } else if (shared.isObject(raw)) {
2008
- if (shared.isArray(raw)) {
2009
- raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
2010
- } else {
2011
- const handler = shared.isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
2012
- if (shared.isFunction(handler)) {
2013
- watch(getter, handler, raw);
2014
- }
2015
- }
2016
- } else ;
2017
- }
2018
- function resolveMergedOptions(instance) {
2019
- const base = instance.type;
2020
- const { mixins, extends: extendsOptions } = base;
2021
- const {
2022
- mixins: globalMixins,
2023
- optionsCache: cache,
2024
- config: { optionMergeStrategies }
2025
- } = instance.appContext;
2026
- const cached = cache.get(base);
2027
- let resolved;
2028
- if (cached) {
2029
- resolved = cached;
2030
- } else if (!globalMixins.length && !mixins && !extendsOptions) {
2031
- {
2032
- resolved = base;
2033
- }
2034
- } else {
2035
- resolved = {};
2036
- if (globalMixins.length) {
2037
- globalMixins.forEach(
2038
- (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
2039
- );
2040
- }
2041
- mergeOptions(resolved, base, optionMergeStrategies);
2042
- }
2043
- if (shared.isObject(base)) {
2044
- cache.set(base, resolved);
2045
- }
2046
- return resolved;
2027
+ function resetShapeFlag(vnode) {
2028
+ vnode.shapeFlag &= ~256;
2029
+ vnode.shapeFlag &= ~512;
2047
2030
  }
2048
- function mergeOptions(to, from, strats, asMixin = false) {
2049
- const { mixins, extends: extendsOptions } = from;
2050
- if (extendsOptions) {
2051
- mergeOptions(to, extendsOptions, strats, true);
2052
- }
2053
- if (mixins) {
2054
- mixins.forEach(
2055
- (m) => mergeOptions(to, m, strats, true)
2056
- );
2057
- }
2058
- for (const key in from) {
2059
- if (asMixin && key === "expose") ; else {
2060
- const strat = internalOptionMergeStrats[key] || strats && strats[key];
2061
- to[key] = strat ? strat(to[key], from[key]) : from[key];
2062
- }
2063
- }
2064
- return to;
2031
+ function getInnerChild(vnode) {
2032
+ return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
2065
2033
  }
2066
- const internalOptionMergeStrats = {
2067
- data: mergeDataFn,
2068
- props: mergeEmitsOrPropsOptions,
2069
- emits: mergeEmitsOrPropsOptions,
2070
- // objects
2071
- methods: mergeObjectOptions,
2072
- computed: mergeObjectOptions,
2073
- // lifecycle
2074
- beforeCreate: mergeAsArray,
2075
- created: mergeAsArray,
2076
- beforeMount: mergeAsArray,
2077
- mounted: mergeAsArray,
2078
- beforeUpdate: mergeAsArray,
2079
- updated: mergeAsArray,
2080
- beforeDestroy: mergeAsArray,
2081
- beforeUnmount: mergeAsArray,
2082
- destroyed: mergeAsArray,
2083
- unmounted: mergeAsArray,
2084
- activated: mergeAsArray,
2085
- deactivated: mergeAsArray,
2086
- errorCaptured: mergeAsArray,
2087
- serverPrefetch: mergeAsArray,
2088
- // assets
2089
- components: mergeObjectOptions,
2090
- directives: mergeObjectOptions,
2091
- // watch
2092
- watch: mergeWatchOptions,
2093
- // provide / inject
2094
- provide: mergeDataFn,
2095
- inject: mergeInject
2096
- };
2097
- function mergeDataFn(to, from) {
2098
- if (!from) {
2099
- return to;
2034
+
2035
+ function injectHook(type, hook, target = currentInstance, prepend = false) {
2036
+ if (target) {
2037
+ const hooks = target[type] || (target[type] = []);
2038
+ const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
2039
+ reactivity.pauseTracking();
2040
+ const reset = setCurrentInstance(target);
2041
+ const res = callWithAsyncErrorHandling(hook, target, type, args);
2042
+ reset();
2043
+ reactivity.resetTracking();
2044
+ return res;
2045
+ });
2046
+ if (prepend) {
2047
+ hooks.unshift(wrappedHook);
2048
+ } else {
2049
+ hooks.push(wrappedHook);
2050
+ }
2051
+ return wrappedHook;
2100
2052
  }
2101
- if (!to) {
2102
- return from;
2053
+ }
2054
+ const createHook = (lifecycle) => (hook, target = currentInstance) => {
2055
+ if (!isInSSRComponentSetup || lifecycle === "sp") {
2056
+ injectHook(lifecycle, (...args) => hook(...args), target);
2103
2057
  }
2104
- return function mergedDataFn() {
2105
- return (shared.extend)(
2106
- shared.isFunction(to) ? to.call(this, this) : to,
2107
- shared.isFunction(from) ? from.call(this, this) : from
2108
- );
2109
- };
2058
+ };
2059
+ const onBeforeMount = createHook("bm");
2060
+ const onMounted = createHook("m");
2061
+ const onBeforeUpdate = createHook(
2062
+ "bu"
2063
+ );
2064
+ const onUpdated = createHook("u");
2065
+ const onBeforeUnmount = createHook(
2066
+ "bum"
2067
+ );
2068
+ const onUnmounted = createHook("um");
2069
+ const onServerPrefetch = createHook(
2070
+ "sp"
2071
+ );
2072
+ const onRenderTriggered = createHook("rtg");
2073
+ const onRenderTracked = createHook("rtc");
2074
+ function onErrorCaptured(hook, target = currentInstance) {
2075
+ injectHook("ec", hook, target);
2110
2076
  }
2111
- function mergeInject(to, from) {
2112
- return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
2077
+
2078
+ const COMPONENTS = "components";
2079
+ const DIRECTIVES = "directives";
2080
+ function resolveComponent(name, maybeSelfReference) {
2081
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2113
2082
  }
2114
- function normalizeInject(raw) {
2115
- if (shared.isArray(raw)) {
2116
- const res = {};
2117
- for (let i = 0; i < raw.length; i++) {
2118
- res[raw[i]] = raw[i];
2119
- }
2120
- return res;
2083
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2084
+ function resolveDynamicComponent(component) {
2085
+ if (shared.isString(component)) {
2086
+ return resolveAsset(COMPONENTS, component, false) || component;
2087
+ } else {
2088
+ return component || NULL_DYNAMIC_COMPONENT;
2121
2089
  }
2122
- return raw;
2123
- }
2124
- function mergeAsArray(to, from) {
2125
- return to ? [...new Set([].concat(to, from))] : from;
2126
2090
  }
2127
- function mergeObjectOptions(to, from) {
2128
- return to ? shared.extend(/* @__PURE__ */ Object.create(null), to, from) : from;
2091
+ function resolveDirective(name) {
2092
+ return resolveAsset(DIRECTIVES, name);
2129
2093
  }
2130
- function mergeEmitsOrPropsOptions(to, from) {
2131
- if (to) {
2132
- if (shared.isArray(to) && shared.isArray(from)) {
2133
- return [.../* @__PURE__ */ new Set([...to, ...from])];
2094
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2095
+ const instance = currentRenderingInstance || currentInstance;
2096
+ if (instance) {
2097
+ const Component = instance.type;
2098
+ if (type === COMPONENTS) {
2099
+ const selfName = getComponentName(
2100
+ Component,
2101
+ false
2102
+ );
2103
+ if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
2104
+ return Component;
2105
+ }
2134
2106
  }
2135
- return shared.extend(
2136
- /* @__PURE__ */ Object.create(null),
2137
- normalizePropsOrEmits(to),
2138
- normalizePropsOrEmits(from != null ? from : {})
2107
+ const res = (
2108
+ // local registration
2109
+ // check instance[type] first which is resolved for options API
2110
+ resolve(instance[type] || Component[type], name) || // global registration
2111
+ resolve(instance.appContext[type], name)
2139
2112
  );
2140
- } else {
2141
- return from;
2113
+ if (!res && maybeSelfReference) {
2114
+ return Component;
2115
+ }
2116
+ return res;
2142
2117
  }
2143
2118
  }
2144
- function mergeWatchOptions(to, from) {
2145
- if (!to) return from;
2146
- if (!from) return to;
2147
- const merged = shared.extend(/* @__PURE__ */ Object.create(null), to);
2148
- for (const key in from) {
2149
- merged[key] = mergeAsArray(to[key], from[key]);
2150
- }
2151
- return merged;
2119
+ function resolve(registry, name) {
2120
+ return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
2152
2121
  }
2153
2122
 
2154
- function createAppContext() {
2155
- return {
2156
- app: null,
2157
- config: {
2158
- isNativeTag: shared.NO,
2159
- performance: false,
2160
- globalProperties: {},
2161
- optionMergeStrategies: {},
2162
- errorHandler: void 0,
2163
- warnHandler: void 0,
2164
- compilerOptions: {}
2165
- },
2166
- mixins: [],
2167
- components: {},
2168
- directives: {},
2169
- provides: /* @__PURE__ */ Object.create(null),
2170
- optionsCache: /* @__PURE__ */ new WeakMap(),
2171
- propsCache: /* @__PURE__ */ new WeakMap(),
2172
- emitsCache: /* @__PURE__ */ new WeakMap()
2173
- };
2174
- }
2175
- let uid$1 = 0;
2176
- function createAppAPI(render, hydrate) {
2177
- return function createApp(rootComponent, rootProps = null) {
2178
- if (!shared.isFunction(rootComponent)) {
2179
- rootComponent = shared.extend({}, rootComponent);
2123
+ function renderList(source, renderItem, cache, index) {
2124
+ let ret;
2125
+ const cached = cache && cache[index];
2126
+ const sourceIsArray = shared.isArray(source);
2127
+ if (sourceIsArray || shared.isString(source)) {
2128
+ const sourceIsReactiveArray = sourceIsArray && reactivity.isReactive(source);
2129
+ if (sourceIsReactiveArray) {
2130
+ source = reactivity.shallowReadArray(source);
2180
2131
  }
2181
- if (rootProps != null && !shared.isObject(rootProps)) {
2182
- rootProps = null;
2132
+ ret = new Array(source.length);
2133
+ for (let i = 0, l = source.length; i < l; i++) {
2134
+ ret[i] = renderItem(
2135
+ sourceIsReactiveArray ? reactivity.toReactive(source[i]) : source[i],
2136
+ i,
2137
+ void 0,
2138
+ cached && cached[i]
2139
+ );
2183
2140
  }
2184
- const context = createAppContext();
2185
- const installedPlugins = /* @__PURE__ */ new WeakSet();
2186
- const pluginCleanupFns = [];
2187
- let isMounted = false;
2188
- const app = context.app = {
2189
- _uid: uid$1++,
2190
- _component: rootComponent,
2191
- _props: rootProps,
2192
- _container: null,
2193
- _context: context,
2194
- _instance: null,
2195
- version,
2196
- get config() {
2197
- return context.config;
2198
- },
2199
- set config(v) {
2200
- },
2201
- use(plugin, ...options) {
2202
- if (installedPlugins.has(plugin)) ; else if (plugin && shared.isFunction(plugin.install)) {
2203
- installedPlugins.add(plugin);
2204
- plugin.install(app, ...options);
2205
- } else if (shared.isFunction(plugin)) {
2206
- installedPlugins.add(plugin);
2207
- plugin(app, ...options);
2208
- } else ;
2209
- return app;
2210
- },
2211
- mixin(mixin) {
2212
- {
2213
- if (!context.mixins.includes(mixin)) {
2214
- context.mixins.push(mixin);
2215
- }
2216
- }
2217
- return app;
2218
- },
2219
- component(name, component) {
2220
- if (!component) {
2221
- return context.components[name];
2222
- }
2223
- context.components[name] = component;
2224
- return app;
2225
- },
2226
- directive(name, directive) {
2227
- if (!directive) {
2228
- return context.directives[name];
2229
- }
2230
- context.directives[name] = directive;
2231
- return app;
2232
- },
2233
- mount(rootContainer, isHydrate, namespace) {
2234
- if (!isMounted) {
2235
- const vnode = createVNode(rootComponent, rootProps);
2236
- vnode.appContext = context;
2237
- if (namespace === true) {
2238
- namespace = "svg";
2239
- } else if (namespace === false) {
2240
- namespace = void 0;
2241
- }
2242
- if (isHydrate && hydrate) {
2243
- hydrate(vnode, rootContainer);
2244
- } else {
2245
- render(vnode, rootContainer, namespace);
2246
- }
2247
- isMounted = true;
2248
- app._container = rootContainer;
2249
- rootContainer.__vue_app__ = app;
2250
- return getComponentPublicInstance(vnode.component);
2251
- }
2252
- },
2253
- onUnmount(cleanupFn) {
2254
- pluginCleanupFns.push(cleanupFn);
2255
- },
2256
- unmount() {
2257
- if (isMounted) {
2258
- callWithAsyncErrorHandling(
2259
- pluginCleanupFns,
2260
- app._instance,
2261
- 16
2262
- );
2263
- render(null, app._container);
2264
- delete app._container.__vue_app__;
2265
- }
2266
- },
2267
- provide(key, value) {
2268
- context.provides[key] = value;
2269
- return app;
2270
- },
2271
- runWithContext(fn) {
2272
- const lastApp = currentApp;
2273
- currentApp = app;
2274
- try {
2275
- return fn();
2276
- } finally {
2277
- currentApp = lastApp;
2278
- }
2279
- }
2280
- };
2281
- return app;
2282
- };
2141
+ } else if (typeof source === "number") {
2142
+ ret = new Array(source);
2143
+ for (let i = 0; i < source; i++) {
2144
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
2145
+ }
2146
+ } else if (shared.isObject(source)) {
2147
+ if (source[Symbol.iterator]) {
2148
+ ret = Array.from(
2149
+ source,
2150
+ (item, i) => renderItem(item, i, void 0, cached && cached[i])
2151
+ );
2152
+ } else {
2153
+ const keys = Object.keys(source);
2154
+ ret = new Array(keys.length);
2155
+ for (let i = 0, l = keys.length; i < l; i++) {
2156
+ const key = keys[i];
2157
+ ret[i] = renderItem(source[key], key, i, cached && cached[i]);
2158
+ }
2159
+ }
2160
+ } else {
2161
+ ret = [];
2162
+ }
2163
+ if (cache) {
2164
+ cache[index] = ret;
2165
+ }
2166
+ return ret;
2283
2167
  }
2284
- let currentApp = null;
2285
2168
 
2286
- function provide(key, value) {
2287
- if (!currentInstance) ; else {
2288
- let provides = currentInstance.provides;
2289
- const parentProvides = currentInstance.parent && currentInstance.parent.provides;
2290
- if (parentProvides === provides) {
2291
- provides = currentInstance.provides = Object.create(parentProvides);
2169
+ function createSlots(slots, dynamicSlots) {
2170
+ for (let i = 0; i < dynamicSlots.length; i++) {
2171
+ const slot = dynamicSlots[i];
2172
+ if (shared.isArray(slot)) {
2173
+ for (let j = 0; j < slot.length; j++) {
2174
+ slots[slot[j].name] = slot[j].fn;
2175
+ }
2176
+ } else if (slot) {
2177
+ slots[slot.name] = slot.key ? (...args) => {
2178
+ const res = slot.fn(...args);
2179
+ if (res) res.key = slot.key;
2180
+ return res;
2181
+ } : slot.fn;
2292
2182
  }
2293
- provides[key] = value;
2294
2183
  }
2184
+ return slots;
2295
2185
  }
2296
- function inject(key, defaultValue, treatDefaultAsFactory = false) {
2297
- const instance = currentInstance || currentRenderingInstance;
2298
- if (instance || currentApp) {
2299
- const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
2300
- if (provides && key in provides) {
2301
- return provides[key];
2302
- } else if (arguments.length > 1) {
2303
- return treatDefaultAsFactory && shared.isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
2304
- } else ;
2186
+
2187
+ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
2188
+ if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
2189
+ if (name !== "default") props.name = name;
2190
+ return openBlock(), createBlock(
2191
+ Fragment,
2192
+ null,
2193
+ [createVNode("slot", props, fallback && fallback())],
2194
+ 64
2195
+ );
2196
+ }
2197
+ let slot = slots[name];
2198
+ if (slot && slot._c) {
2199
+ slot._d = false;
2200
+ }
2201
+ openBlock();
2202
+ const validSlotContent = slot && ensureValidVNode(slot(props));
2203
+ const rendered = createBlock(
2204
+ Fragment,
2205
+ {
2206
+ key: (props.key || // slot content array of a dynamic conditional slot may have a branch
2207
+ // key attached in the `createSlots` helper, respect that
2208
+ validSlotContent && validSlotContent.key || `_${name}`) + // #7256 force differentiate fallback content from actual content
2209
+ (!validSlotContent && fallback ? "_fb" : "")
2210
+ },
2211
+ validSlotContent || (fallback ? fallback() : []),
2212
+ validSlotContent && slots._ === 1 ? 64 : -2
2213
+ );
2214
+ if (!noSlotted && rendered.scopeId) {
2215
+ rendered.slotScopeIds = [rendered.scopeId + "-s"];
2216
+ }
2217
+ if (slot && slot._c) {
2218
+ slot._d = true;
2305
2219
  }
2220
+ return rendered;
2306
2221
  }
2307
- function hasInjectionContext() {
2308
- return !!(currentInstance || currentRenderingInstance || currentApp);
2222
+ function ensureValidVNode(vnodes) {
2223
+ return vnodes.some((child) => {
2224
+ if (!isVNode(child)) return true;
2225
+ if (child.type === Comment) return false;
2226
+ if (child.type === Fragment && !ensureValidVNode(child.children))
2227
+ return false;
2228
+ return true;
2229
+ }) ? vnodes : null;
2309
2230
  }
2310
2231
 
2311
- const internalObjectProto = {};
2312
- const createInternalObject = () => Object.create(internalObjectProto);
2313
- const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
2314
-
2315
- function initProps(instance, rawProps, isStateful, isSSR = false) {
2316
- const props = {};
2317
- const attrs = createInternalObject();
2318
- instance.propsDefaults = /* @__PURE__ */ Object.create(null);
2319
- setFullProps(instance, rawProps, props, attrs);
2320
- for (const key in instance.propsOptions[0]) {
2321
- if (!(key in props)) {
2322
- props[key] = void 0;
2323
- }
2324
- }
2325
- if (isStateful) {
2326
- instance.props = isSSR ? props : reactivity.shallowReactive(props);
2327
- } else {
2328
- if (!instance.type.props) {
2329
- instance.props = attrs;
2330
- } else {
2331
- instance.props = props;
2332
- }
2232
+ function toHandlers(obj, preserveCaseIfNecessary) {
2233
+ const ret = {};
2234
+ for (const key in obj) {
2235
+ ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : shared.toHandlerKey(key)] = obj[key];
2333
2236
  }
2334
- instance.attrs = attrs;
2237
+ return ret;
2335
2238
  }
2336
- function updateProps(instance, rawProps, rawPrevProps, optimized) {
2337
- const {
2338
- props,
2339
- attrs,
2340
- vnode: { patchFlag }
2341
- } = instance;
2342
- const rawCurrentProps = reactivity.toRaw(props);
2343
- const [options] = instance.propsOptions;
2344
- let hasAttrsChanged = false;
2345
- if (
2346
- // always force full diff in dev
2347
- // - #1942 if hmr is enabled with sfc component
2348
- // - vite#872 non-sfc component used by sfc component
2349
- (optimized || patchFlag > 0) && !(patchFlag & 16)
2350
- ) {
2351
- if (patchFlag & 8) {
2352
- const propsToUpdate = instance.vnode.dynamicProps;
2353
- for (let i = 0; i < propsToUpdate.length; i++) {
2354
- let key = propsToUpdate[i];
2355
- if (isEmitListener(instance.emitsOptions, key)) {
2356
- continue;
2357
- }
2358
- const value = rawProps[key];
2359
- if (options) {
2360
- if (shared.hasOwn(attrs, key)) {
2361
- if (value !== attrs[key]) {
2362
- attrs[key] = value;
2363
- hasAttrsChanged = true;
2364
- }
2365
- } else {
2366
- const camelizedKey = shared.camelize(key);
2367
- props[camelizedKey] = resolvePropValue(
2368
- options,
2369
- rawCurrentProps,
2370
- camelizedKey,
2371
- value,
2372
- instance,
2373
- false
2374
- );
2375
- }
2376
- } else {
2377
- if (value !== attrs[key]) {
2378
- attrs[key] = value;
2379
- hasAttrsChanged = true;
2380
- }
2239
+
2240
+ const getPublicInstance = (i) => {
2241
+ if (!i) return null;
2242
+ if (isStatefulComponent(i)) return getComponentPublicInstance(i);
2243
+ return getPublicInstance(i.parent);
2244
+ };
2245
+ const publicPropertiesMap = (
2246
+ // Move PURE marker to new line to workaround compiler discarding it
2247
+ // due to type annotation
2248
+ /* @__PURE__ */ shared.extend(/* @__PURE__ */ Object.create(null), {
2249
+ $: (i) => i,
2250
+ $el: (i) => i.vnode.el,
2251
+ $data: (i) => i.data,
2252
+ $props: (i) => i.props,
2253
+ $attrs: (i) => i.attrs,
2254
+ $slots: (i) => i.slots,
2255
+ $refs: (i) => i.refs,
2256
+ $parent: (i) => getPublicInstance(i.parent),
2257
+ $root: (i) => getPublicInstance(i.root),
2258
+ $host: (i) => i.ce,
2259
+ $emit: (i) => i.emit,
2260
+ $options: (i) => resolveMergedOptions(i) ,
2261
+ $forceUpdate: (i) => i.f || (i.f = () => {
2262
+ queueJob(i.update);
2263
+ }),
2264
+ $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
2265
+ $watch: (i) => instanceWatch.bind(i)
2266
+ })
2267
+ );
2268
+ const hasSetupBinding = (state, key) => state !== shared.EMPTY_OBJ && !state.__isScriptSetup && shared.hasOwn(state, key);
2269
+ const PublicInstanceProxyHandlers = {
2270
+ get({ _: instance }, key) {
2271
+ if (key === "__v_skip") {
2272
+ return true;
2273
+ }
2274
+ const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
2275
+ let normalizedProps;
2276
+ if (key[0] !== "$") {
2277
+ const n = accessCache[key];
2278
+ if (n !== void 0) {
2279
+ switch (n) {
2280
+ case 1 /* SETUP */:
2281
+ return setupState[key];
2282
+ case 2 /* DATA */:
2283
+ return data[key];
2284
+ case 4 /* CONTEXT */:
2285
+ return ctx[key];
2286
+ case 3 /* PROPS */:
2287
+ return props[key];
2381
2288
  }
2289
+ } else if (hasSetupBinding(setupState, key)) {
2290
+ accessCache[key] = 1 /* SETUP */;
2291
+ return setupState[key];
2292
+ } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
2293
+ accessCache[key] = 2 /* DATA */;
2294
+ return data[key];
2295
+ } else if (
2296
+ // only cache other properties when instance has declared (thus stable)
2297
+ // props
2298
+ (normalizedProps = instance.propsOptions[0]) && shared.hasOwn(normalizedProps, key)
2299
+ ) {
2300
+ accessCache[key] = 3 /* PROPS */;
2301
+ return props[key];
2302
+ } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
2303
+ accessCache[key] = 4 /* CONTEXT */;
2304
+ return ctx[key];
2305
+ } else if (shouldCacheAccess) {
2306
+ accessCache[key] = 0 /* OTHER */;
2382
2307
  }
2383
2308
  }
2384
- } else {
2385
- if (setFullProps(instance, rawProps, props, attrs)) {
2386
- hasAttrsChanged = true;
2387
- }
2388
- let kebabKey;
2389
- for (const key in rawCurrentProps) {
2390
- if (!rawProps || // for camelCase
2391
- !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
2392
- // and converted to camelCase (#955)
2393
- ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
2394
- if (options) {
2395
- if (rawPrevProps && // for camelCase
2396
- (rawPrevProps[key] !== void 0 || // for kebab-case
2397
- rawPrevProps[kebabKey] !== void 0)) {
2398
- props[key] = resolvePropValue(
2399
- options,
2400
- rawCurrentProps,
2401
- key,
2402
- void 0,
2403
- instance,
2404
- true
2405
- );
2406
- }
2407
- } else {
2408
- delete props[key];
2409
- }
2309
+ const publicGetter = publicPropertiesMap[key];
2310
+ let cssModule, globalProperties;
2311
+ if (publicGetter) {
2312
+ if (key === "$attrs") {
2313
+ reactivity.track(instance.attrs, "get", "");
2314
+ }
2315
+ return publicGetter(instance);
2316
+ } else if (
2317
+ // css module (injected by vue-loader)
2318
+ (cssModule = type.__cssModules) && (cssModule = cssModule[key])
2319
+ ) {
2320
+ return cssModule;
2321
+ } else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
2322
+ accessCache[key] = 4 /* CONTEXT */;
2323
+ return ctx[key];
2324
+ } else if (
2325
+ // global properties
2326
+ globalProperties = appContext.config.globalProperties, shared.hasOwn(globalProperties, key)
2327
+ ) {
2328
+ {
2329
+ return globalProperties[key];
2410
2330
  }
2331
+ } else ;
2332
+ },
2333
+ set({ _: instance }, key, value) {
2334
+ const { data, setupState, ctx } = instance;
2335
+ if (hasSetupBinding(setupState, key)) {
2336
+ setupState[key] = value;
2337
+ return true;
2338
+ } else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
2339
+ data[key] = value;
2340
+ return true;
2341
+ } else if (shared.hasOwn(instance.props, key)) {
2342
+ return false;
2411
2343
  }
2412
- if (attrs !== rawCurrentProps) {
2413
- for (const key in attrs) {
2414
- if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
2415
- delete attrs[key];
2416
- hasAttrsChanged = true;
2417
- }
2344
+ if (key[0] === "$" && key.slice(1) in instance) {
2345
+ return false;
2346
+ } else {
2347
+ {
2348
+ ctx[key] = value;
2418
2349
  }
2419
2350
  }
2420
- }
2421
- if (hasAttrsChanged) {
2422
- reactivity.trigger(instance.attrs, "set", "");
2423
- }
2424
- }
2425
- function setFullProps(instance, rawProps, props, attrs) {
2426
- const [options, needCastKeys] = instance.propsOptions;
2427
- let hasAttrsChanged = false;
2428
- let rawCastValues;
2429
- if (rawProps) {
2430
- for (let key in rawProps) {
2431
- if (shared.isReservedProp(key)) {
2432
- continue;
2433
- }
2434
- const value = rawProps[key];
2435
- let camelKey;
2436
- if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
2437
- if (!needCastKeys || !needCastKeys.includes(camelKey)) {
2438
- props[camelKey] = value;
2439
- } else {
2440
- (rawCastValues || (rawCastValues = {}))[camelKey] = value;
2441
- }
2442
- } else if (!isEmitListener(instance.emitsOptions, key)) {
2443
- if (!(key in attrs) || value !== attrs[key]) {
2444
- attrs[key] = value;
2445
- hasAttrsChanged = true;
2446
- }
2447
- }
2351
+ return true;
2352
+ },
2353
+ has({
2354
+ _: { data, setupState, accessCache, ctx, appContext, propsOptions }
2355
+ }, key) {
2356
+ let normalizedProps;
2357
+ return !!accessCache[key] || data !== shared.EMPTY_OBJ && shared.hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && shared.hasOwn(normalizedProps, key) || shared.hasOwn(ctx, key) || shared.hasOwn(publicPropertiesMap, key) || shared.hasOwn(appContext.config.globalProperties, key);
2358
+ },
2359
+ defineProperty(target, key, descriptor) {
2360
+ if (descriptor.get != null) {
2361
+ target._.accessCache[key] = 0;
2362
+ } else if (shared.hasOwn(descriptor, "value")) {
2363
+ this.set(target, key, descriptor.value, null);
2448
2364
  }
2365
+ return Reflect.defineProperty(target, key, descriptor);
2449
2366
  }
2450
- if (needCastKeys) {
2451
- const rawCurrentProps = reactivity.toRaw(props);
2452
- const castValues = rawCastValues || shared.EMPTY_OBJ;
2453
- for (let i = 0; i < needCastKeys.length; i++) {
2454
- const key = needCastKeys[i];
2455
- props[key] = resolvePropValue(
2456
- options,
2457
- rawCurrentProps,
2458
- key,
2459
- castValues[key],
2460
- instance,
2461
- !shared.hasOwn(castValues, key)
2462
- );
2367
+ };
2368
+ const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ shared.extend({}, PublicInstanceProxyHandlers, {
2369
+ get(target, key) {
2370
+ if (key === Symbol.unscopables) {
2371
+ return;
2463
2372
  }
2373
+ return PublicInstanceProxyHandlers.get(target, key, target);
2374
+ },
2375
+ has(_, key) {
2376
+ const has = key[0] !== "_" && !shared.isGloballyAllowed(key);
2377
+ return has;
2464
2378
  }
2465
- return hasAttrsChanged;
2379
+ });
2380
+
2381
+ function defineProps() {
2382
+ return null;
2466
2383
  }
2467
- function resolvePropValue(options, props, key, value, instance, isAbsent) {
2468
- const opt = options[key];
2469
- if (opt != null) {
2470
- const hasDefault = shared.hasOwn(opt, "default");
2471
- if (hasDefault && value === void 0) {
2472
- const defaultValue = opt.default;
2473
- if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
2474
- const { propsDefaults } = instance;
2475
- if (key in propsDefaults) {
2476
- value = propsDefaults[key];
2477
- } else {
2478
- const reset = setCurrentInstance(instance);
2479
- value = propsDefaults[key] = defaultValue.call(
2480
- null,
2481
- props
2482
- );
2483
- reset();
2484
- }
2384
+ function defineEmits() {
2385
+ return null;
2386
+ }
2387
+ function defineExpose(exposed) {
2388
+ }
2389
+ function defineOptions(options) {
2390
+ }
2391
+ function defineSlots() {
2392
+ return null;
2393
+ }
2394
+ function defineModel() {
2395
+ }
2396
+ function withDefaults(props, defaults) {
2397
+ return null;
2398
+ }
2399
+ function useSlots() {
2400
+ return getContext().slots;
2401
+ }
2402
+ function useAttrs() {
2403
+ return getContext().attrs;
2404
+ }
2405
+ function getContext() {
2406
+ const i = getCurrentInstance();
2407
+ return i.setupContext || (i.setupContext = createSetupContext(i));
2408
+ }
2409
+ function normalizePropsOrEmits(props) {
2410
+ return shared.isArray(props) ? props.reduce(
2411
+ (normalized, p) => (normalized[p] = null, normalized),
2412
+ {}
2413
+ ) : props;
2414
+ }
2415
+ function mergeDefaults(raw, defaults) {
2416
+ const props = normalizePropsOrEmits(raw);
2417
+ for (const key in defaults) {
2418
+ if (key.startsWith("__skip")) continue;
2419
+ let opt = props[key];
2420
+ if (opt) {
2421
+ if (shared.isArray(opt) || shared.isFunction(opt)) {
2422
+ opt = props[key] = { type: opt, default: defaults[key] };
2485
2423
  } else {
2486
- value = defaultValue;
2424
+ opt.default = defaults[key];
2487
2425
  }
2426
+ } else if (opt === null) {
2427
+ opt = props[key] = { default: defaults[key] };
2428
+ } else ;
2429
+ if (opt && defaults[`__skip_${key}`]) {
2430
+ opt.skipFactory = true;
2488
2431
  }
2489
- if (opt[0 /* shouldCast */]) {
2490
- if (isAbsent && !hasDefault) {
2491
- value = false;
2492
- } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
2493
- value = true;
2494
- }
2432
+ }
2433
+ return props;
2434
+ }
2435
+ function mergeModels(a, b) {
2436
+ if (!a || !b) return a || b;
2437
+ if (shared.isArray(a) && shared.isArray(b)) return a.concat(b);
2438
+ return shared.extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
2439
+ }
2440
+ function createPropsRestProxy(props, excludedKeys) {
2441
+ const ret = {};
2442
+ for (const key in props) {
2443
+ if (!excludedKeys.includes(key)) {
2444
+ Object.defineProperty(ret, key, {
2445
+ enumerable: true,
2446
+ get: () => props[key]
2447
+ });
2495
2448
  }
2496
2449
  }
2497
- return value;
2450
+ return ret;
2498
2451
  }
2499
- const mixinPropsCache = /* @__PURE__ */ new WeakMap();
2500
- function normalizePropsOptions(comp, appContext, asMixin = false) {
2501
- const cache = asMixin ? mixinPropsCache : appContext.propsCache;
2502
- const cached = cache.get(comp);
2503
- if (cached) {
2504
- return cached;
2452
+ function withAsyncContext(getAwaitable) {
2453
+ const ctx = getCurrentInstance();
2454
+ let awaitable = getAwaitable();
2455
+ unsetCurrentInstance();
2456
+ if (shared.isPromise(awaitable)) {
2457
+ awaitable = awaitable.catch((e) => {
2458
+ setCurrentInstance(ctx);
2459
+ throw e;
2460
+ });
2505
2461
  }
2506
- const raw = comp.props;
2507
- const normalized = {};
2508
- const needCastKeys = [];
2509
- let hasExtends = false;
2510
- if (!shared.isFunction(comp)) {
2511
- const extendProps = (raw2) => {
2512
- hasExtends = true;
2513
- const [props, keys] = normalizePropsOptions(raw2, appContext, true);
2514
- shared.extend(normalized, props);
2515
- if (keys) needCastKeys.push(...keys);
2516
- };
2517
- if (!asMixin && appContext.mixins.length) {
2518
- appContext.mixins.forEach(extendProps);
2519
- }
2520
- if (comp.extends) {
2521
- extendProps(comp.extends);
2522
- }
2523
- if (comp.mixins) {
2524
- comp.mixins.forEach(extendProps);
2462
+ return [awaitable, () => setCurrentInstance(ctx)];
2463
+ }
2464
+
2465
+ let shouldCacheAccess = true;
2466
+ function applyOptions(instance) {
2467
+ const options = resolveMergedOptions(instance);
2468
+ const publicThis = instance.proxy;
2469
+ const ctx = instance.ctx;
2470
+ shouldCacheAccess = false;
2471
+ if (options.beforeCreate) {
2472
+ callHook(options.beforeCreate, instance, "bc");
2473
+ }
2474
+ const {
2475
+ // state
2476
+ data: dataOptions,
2477
+ computed: computedOptions,
2478
+ methods,
2479
+ watch: watchOptions,
2480
+ provide: provideOptions,
2481
+ inject: injectOptions,
2482
+ // lifecycle
2483
+ created,
2484
+ beforeMount,
2485
+ mounted,
2486
+ beforeUpdate,
2487
+ updated,
2488
+ activated,
2489
+ deactivated,
2490
+ beforeDestroy,
2491
+ beforeUnmount,
2492
+ destroyed,
2493
+ unmounted,
2494
+ render,
2495
+ renderTracked,
2496
+ renderTriggered,
2497
+ errorCaptured,
2498
+ serverPrefetch,
2499
+ // public API
2500
+ expose,
2501
+ inheritAttrs,
2502
+ // assets
2503
+ components,
2504
+ directives,
2505
+ filters
2506
+ } = options;
2507
+ const checkDuplicateProperties = null;
2508
+ if (injectOptions) {
2509
+ resolveInjections(injectOptions, ctx, checkDuplicateProperties);
2510
+ }
2511
+ if (methods) {
2512
+ for (const key in methods) {
2513
+ const methodHandler = methods[key];
2514
+ if (shared.isFunction(methodHandler)) {
2515
+ {
2516
+ ctx[key] = methodHandler.bind(publicThis);
2517
+ }
2518
+ }
2525
2519
  }
2526
2520
  }
2527
- if (!raw && !hasExtends) {
2528
- if (shared.isObject(comp)) {
2529
- cache.set(comp, shared.EMPTY_ARR);
2521
+ if (dataOptions) {
2522
+ const data = dataOptions.call(publicThis, publicThis);
2523
+ if (!shared.isObject(data)) ; else {
2524
+ instance.data = reactivity.reactive(data);
2530
2525
  }
2531
- return shared.EMPTY_ARR;
2532
2526
  }
2533
- if (shared.isArray(raw)) {
2534
- for (let i = 0; i < raw.length; i++) {
2535
- const normalizedKey = shared.camelize(raw[i]);
2536
- if (validatePropName(normalizedKey)) {
2537
- normalized[normalizedKey] = shared.EMPTY_OBJ;
2538
- }
2527
+ shouldCacheAccess = true;
2528
+ if (computedOptions) {
2529
+ for (const key in computedOptions) {
2530
+ const opt = computedOptions[key];
2531
+ const get = shared.isFunction(opt) ? opt.bind(publicThis, publicThis) : shared.isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : shared.NOOP;
2532
+ const set = !shared.isFunction(opt) && shared.isFunction(opt.set) ? opt.set.bind(publicThis) : shared.NOOP;
2533
+ const c = computed({
2534
+ get,
2535
+ set
2536
+ });
2537
+ Object.defineProperty(ctx, key, {
2538
+ enumerable: true,
2539
+ configurable: true,
2540
+ get: () => c.value,
2541
+ set: (v) => c.value = v
2542
+ });
2539
2543
  }
2540
- } else if (raw) {
2541
- for (const key in raw) {
2542
- const normalizedKey = shared.camelize(key);
2543
- if (validatePropName(normalizedKey)) {
2544
- const opt = raw[key];
2545
- const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
2546
- if (prop) {
2547
- const booleanIndex = getTypeIndex(Boolean, prop.type);
2548
- const stringIndex = getTypeIndex(String, prop.type);
2549
- prop[0 /* shouldCast */] = booleanIndex > -1;
2550
- prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
2551
- if (booleanIndex > -1 || shared.hasOwn(prop, "default")) {
2552
- needCastKeys.push(normalizedKey);
2553
- }
2554
- }
2555
- }
2544
+ }
2545
+ if (watchOptions) {
2546
+ for (const key in watchOptions) {
2547
+ createWatcher(watchOptions[key], ctx, publicThis, key);
2556
2548
  }
2557
2549
  }
2558
- const res = [normalized, needCastKeys];
2559
- if (shared.isObject(comp)) {
2560
- cache.set(comp, res);
2550
+ if (provideOptions) {
2551
+ const provides = shared.isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
2552
+ Reflect.ownKeys(provides).forEach((key) => {
2553
+ provide(key, provides[key]);
2554
+ });
2561
2555
  }
2562
- return res;
2563
- }
2564
- function validatePropName(key) {
2565
- if (key[0] !== "$" && !shared.isReservedProp(key)) {
2566
- return true;
2556
+ if (created) {
2557
+ callHook(created, instance, "c");
2567
2558
  }
2568
- return false;
2569
- }
2570
- function getType(ctor) {
2571
- if (ctor === null) {
2572
- return "null";
2559
+ function registerLifecycleHook(register, hook) {
2560
+ if (shared.isArray(hook)) {
2561
+ hook.forEach((_hook) => register(_hook.bind(publicThis)));
2562
+ } else if (hook) {
2563
+ register(hook.bind(publicThis));
2564
+ }
2573
2565
  }
2574
- if (typeof ctor === "function") {
2575
- return ctor.name || "";
2576
- } else if (typeof ctor === "object") {
2577
- const name = ctor.constructor && ctor.constructor.name;
2578
- return name || "";
2566
+ registerLifecycleHook(onBeforeMount, beforeMount);
2567
+ registerLifecycleHook(onMounted, mounted);
2568
+ registerLifecycleHook(onBeforeUpdate, beforeUpdate);
2569
+ registerLifecycleHook(onUpdated, updated);
2570
+ registerLifecycleHook(onActivated, activated);
2571
+ registerLifecycleHook(onDeactivated, deactivated);
2572
+ registerLifecycleHook(onErrorCaptured, errorCaptured);
2573
+ registerLifecycleHook(onRenderTracked, renderTracked);
2574
+ registerLifecycleHook(onRenderTriggered, renderTriggered);
2575
+ registerLifecycleHook(onBeforeUnmount, beforeUnmount);
2576
+ registerLifecycleHook(onUnmounted, unmounted);
2577
+ registerLifecycleHook(onServerPrefetch, serverPrefetch);
2578
+ if (shared.isArray(expose)) {
2579
+ if (expose.length) {
2580
+ const exposed = instance.exposed || (instance.exposed = {});
2581
+ expose.forEach((key) => {
2582
+ Object.defineProperty(exposed, key, {
2583
+ get: () => publicThis[key],
2584
+ set: (val) => publicThis[key] = val
2585
+ });
2586
+ });
2587
+ } else if (!instance.exposed) {
2588
+ instance.exposed = {};
2589
+ }
2579
2590
  }
2580
- return "";
2581
- }
2582
- function isSameType(a, b) {
2583
- return getType(a) === getType(b);
2584
- }
2585
- function getTypeIndex(type, expectedTypes) {
2586
- if (shared.isArray(expectedTypes)) {
2587
- return expectedTypes.findIndex((t) => isSameType(t, type));
2588
- } else if (shared.isFunction(expectedTypes)) {
2589
- return isSameType(expectedTypes, type) ? 0 : -1;
2591
+ if (render && instance.render === shared.NOOP) {
2592
+ instance.render = render;
2590
2593
  }
2591
- return -1;
2592
- }
2593
-
2594
- const isInternalKey = (key) => key[0] === "_" || key === "$stable";
2595
- const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
2596
- const normalizeSlot = (key, rawSlot, ctx) => {
2597
- if (rawSlot._n) {
2598
- return rawSlot;
2594
+ if (inheritAttrs != null) {
2595
+ instance.inheritAttrs = inheritAttrs;
2599
2596
  }
2600
- const normalized = withCtx((...args) => {
2601
- if (false) ;
2602
- return normalizeSlotValue(rawSlot(...args));
2603
- }, ctx);
2604
- normalized._c = false;
2605
- return normalized;
2606
- };
2607
- const normalizeObjectSlots = (rawSlots, slots, instance) => {
2608
- const ctx = rawSlots._ctx;
2609
- for (const key in rawSlots) {
2610
- if (isInternalKey(key)) continue;
2611
- const value = rawSlots[key];
2612
- if (shared.isFunction(value)) {
2613
- slots[key] = normalizeSlot(key, value, ctx);
2614
- } else if (value != null) {
2615
- const normalized = normalizeSlotValue(value);
2616
- slots[key] = () => normalized;
2617
- }
2597
+ if (components) instance.components = components;
2598
+ if (directives) instance.directives = directives;
2599
+ if (serverPrefetch) {
2600
+ markAsyncBoundary(instance);
2618
2601
  }
2619
- };
2620
- const normalizeVNodeSlots = (instance, children) => {
2621
- const normalized = normalizeSlotValue(children);
2622
- instance.slots.default = () => normalized;
2623
- };
2624
- const assignSlots = (slots, children, optimized) => {
2625
- for (const key in children) {
2626
- if (optimized || key !== "_") {
2627
- slots[key] = children[key];
2628
- }
2602
+ }
2603
+ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = shared.NOOP) {
2604
+ if (shared.isArray(injectOptions)) {
2605
+ injectOptions = normalizeInject(injectOptions);
2629
2606
  }
2630
- };
2631
- const initSlots = (instance, children, optimized) => {
2632
- const slots = instance.slots = createInternalObject();
2633
- if (instance.vnode.shapeFlag & 32) {
2634
- const type = children._;
2635
- if (type) {
2636
- assignSlots(slots, children, optimized);
2637
- if (optimized) {
2638
- shared.def(slots, "_", type, true);
2607
+ for (const key in injectOptions) {
2608
+ const opt = injectOptions[key];
2609
+ let injected;
2610
+ if (shared.isObject(opt)) {
2611
+ if ("default" in opt) {
2612
+ injected = inject(
2613
+ opt.from || key,
2614
+ opt.default,
2615
+ true
2616
+ );
2617
+ } else {
2618
+ injected = inject(opt.from || key);
2639
2619
  }
2640
2620
  } else {
2641
- normalizeObjectSlots(children, slots);
2621
+ injected = inject(opt);
2642
2622
  }
2643
- } else if (children) {
2644
- normalizeVNodeSlots(instance, children);
2645
- }
2646
- };
2647
- const updateSlots = (instance, children, optimized) => {
2648
- const { vnode, slots } = instance;
2649
- let needDeletionCheck = true;
2650
- let deletionComparisonTarget = shared.EMPTY_OBJ;
2651
- if (vnode.shapeFlag & 32) {
2652
- const type = children._;
2653
- if (type) {
2654
- if (optimized && type === 1) {
2655
- needDeletionCheck = false;
2656
- } else {
2657
- assignSlots(slots, children, optimized);
2658
- }
2623
+ if (reactivity.isRef(injected)) {
2624
+ Object.defineProperty(ctx, key, {
2625
+ enumerable: true,
2626
+ configurable: true,
2627
+ get: () => injected.value,
2628
+ set: (v) => injected.value = v
2629
+ });
2659
2630
  } else {
2660
- needDeletionCheck = !children.$stable;
2661
- normalizeObjectSlots(children, slots);
2631
+ ctx[key] = injected;
2662
2632
  }
2663
- deletionComparisonTarget = children;
2664
- } else if (children) {
2665
- normalizeVNodeSlots(instance, children);
2666
- deletionComparisonTarget = { default: 1 };
2667
2633
  }
2668
- if (needDeletionCheck) {
2669
- for (const key in slots) {
2670
- if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
2671
- delete slots[key];
2634
+ }
2635
+ function callHook(hook, instance, type) {
2636
+ callWithAsyncErrorHandling(
2637
+ shared.isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
2638
+ instance,
2639
+ type
2640
+ );
2641
+ }
2642
+ function createWatcher(raw, ctx, publicThis, key) {
2643
+ const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
2644
+ if (shared.isString(raw)) {
2645
+ const handler = ctx[raw];
2646
+ if (shared.isFunction(handler)) {
2647
+ watch(getter, handler);
2648
+ }
2649
+ } else if (shared.isFunction(raw)) {
2650
+ watch(getter, raw.bind(publicThis));
2651
+ } else if (shared.isObject(raw)) {
2652
+ if (shared.isArray(raw)) {
2653
+ raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
2654
+ } else {
2655
+ const handler = shared.isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
2656
+ if (shared.isFunction(handler)) {
2657
+ watch(getter, handler, raw);
2672
2658
  }
2673
2659
  }
2660
+ } else ;
2661
+ }
2662
+ function resolveMergedOptions(instance) {
2663
+ const base = instance.type;
2664
+ const { mixins, extends: extendsOptions } = base;
2665
+ const {
2666
+ mixins: globalMixins,
2667
+ optionsCache: cache,
2668
+ config: { optionMergeStrategies }
2669
+ } = instance.appContext;
2670
+ const cached = cache.get(base);
2671
+ let resolved;
2672
+ if (cached) {
2673
+ resolved = cached;
2674
+ } else if (!globalMixins.length && !mixins && !extendsOptions) {
2675
+ {
2676
+ resolved = base;
2677
+ }
2678
+ } else {
2679
+ resolved = {};
2680
+ if (globalMixins.length) {
2681
+ globalMixins.forEach(
2682
+ (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
2683
+ );
2684
+ }
2685
+ mergeOptions(resolved, base, optionMergeStrategies);
2674
2686
  }
2675
- };
2676
-
2677
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
2678
- if (shared.isArray(rawRef)) {
2679
- rawRef.forEach(
2680
- (r, i) => setRef(
2681
- r,
2682
- oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
2683
- parentSuspense,
2684
- vnode,
2685
- isUnmount
2686
- )
2687
- );
2688
- return;
2687
+ if (shared.isObject(base)) {
2688
+ cache.set(base, resolved);
2689
2689
  }
2690
- if (isAsyncWrapper(vnode) && !isUnmount) {
2691
- return;
2690
+ return resolved;
2691
+ }
2692
+ function mergeOptions(to, from, strats, asMixin = false) {
2693
+ const { mixins, extends: extendsOptions } = from;
2694
+ if (extendsOptions) {
2695
+ mergeOptions(to, extendsOptions, strats, true);
2692
2696
  }
2693
- const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
2694
- const value = isUnmount ? null : refValue;
2695
- const { i: owner, r: ref } = rawRef;
2696
- const oldRef = oldRawRef && oldRawRef.r;
2697
- const refs = owner.refs === shared.EMPTY_OBJ ? owner.refs = {} : owner.refs;
2698
- const setupState = owner.setupState;
2699
- if (oldRef != null && oldRef !== ref) {
2700
- if (shared.isString(oldRef)) {
2701
- refs[oldRef] = null;
2702
- if (shared.hasOwn(setupState, oldRef)) {
2703
- setupState[oldRef] = null;
2704
- }
2705
- } else if (reactivity.isRef(oldRef)) {
2706
- oldRef.value = null;
2707
- }
2697
+ if (mixins) {
2698
+ mixins.forEach(
2699
+ (m) => mergeOptions(to, m, strats, true)
2700
+ );
2708
2701
  }
2709
- if (shared.isFunction(ref)) {
2710
- callWithErrorHandling(ref, owner, 12, [value, refs]);
2711
- } else {
2712
- const _isString = shared.isString(ref);
2713
- const _isRef = reactivity.isRef(ref);
2714
- if (_isString || _isRef) {
2715
- const doSet = () => {
2716
- if (rawRef.f) {
2717
- const existing = _isString ? shared.hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
2718
- if (isUnmount) {
2719
- shared.isArray(existing) && shared.remove(existing, refValue);
2720
- } else {
2721
- if (!shared.isArray(existing)) {
2722
- if (_isString) {
2723
- refs[ref] = [refValue];
2724
- if (shared.hasOwn(setupState, ref)) {
2725
- setupState[ref] = refs[ref];
2726
- }
2727
- } else {
2728
- ref.value = [refValue];
2729
- if (rawRef.k) refs[rawRef.k] = ref.value;
2730
- }
2731
- } else if (!existing.includes(refValue)) {
2732
- existing.push(refValue);
2733
- }
2734
- }
2735
- } else if (_isString) {
2736
- refs[ref] = value;
2737
- if (shared.hasOwn(setupState, ref)) {
2738
- setupState[ref] = value;
2739
- }
2740
- } else if (_isRef) {
2741
- ref.value = value;
2742
- if (rawRef.k) refs[rawRef.k] = value;
2743
- } else ;
2744
- };
2745
- if (value) {
2746
- doSet.id = -1;
2747
- queuePostRenderEffect(doSet, parentSuspense);
2748
- } else {
2749
- doSet();
2750
- }
2702
+ for (const key in from) {
2703
+ if (asMixin && key === "expose") ; else {
2704
+ const strat = internalOptionMergeStrats[key] || strats && strats[key];
2705
+ to[key] = strat ? strat(to[key], from[key]) : from[key];
2751
2706
  }
2752
2707
  }
2708
+ return to;
2753
2709
  }
2754
-
2755
- let hasLoggedMismatchError = false;
2756
- const logMismatchError = () => {
2757
- if (hasLoggedMismatchError) {
2758
- return;
2759
- }
2760
- console.error("Hydration completed but contains mismatches.");
2761
- hasLoggedMismatchError = true;
2762
- };
2763
- const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
2764
- const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
2765
- const getContainerType = (container) => {
2766
- if (isSVGContainer(container)) return "svg";
2767
- if (isMathMLContainer(container)) return "mathml";
2768
- return void 0;
2710
+ const internalOptionMergeStrats = {
2711
+ data: mergeDataFn,
2712
+ props: mergeEmitsOrPropsOptions,
2713
+ emits: mergeEmitsOrPropsOptions,
2714
+ // objects
2715
+ methods: mergeObjectOptions,
2716
+ computed: mergeObjectOptions,
2717
+ // lifecycle
2718
+ beforeCreate: mergeAsArray,
2719
+ created: mergeAsArray,
2720
+ beforeMount: mergeAsArray,
2721
+ mounted: mergeAsArray,
2722
+ beforeUpdate: mergeAsArray,
2723
+ updated: mergeAsArray,
2724
+ beforeDestroy: mergeAsArray,
2725
+ beforeUnmount: mergeAsArray,
2726
+ destroyed: mergeAsArray,
2727
+ unmounted: mergeAsArray,
2728
+ activated: mergeAsArray,
2729
+ deactivated: mergeAsArray,
2730
+ errorCaptured: mergeAsArray,
2731
+ serverPrefetch: mergeAsArray,
2732
+ // assets
2733
+ components: mergeObjectOptions,
2734
+ directives: mergeObjectOptions,
2735
+ // watch
2736
+ watch: mergeWatchOptions,
2737
+ // provide / inject
2738
+ provide: mergeDataFn,
2739
+ inject: mergeInject
2769
2740
  };
2770
- const isComment = (node) => node.nodeType === 8 /* COMMENT */;
2771
- function createHydrationFunctions(rendererInternals) {
2772
- const {
2773
- mt: mountComponent,
2774
- p: patch,
2775
- o: {
2776
- patchProp,
2777
- createText,
2778
- nextSibling,
2779
- parentNode,
2780
- remove,
2781
- insert,
2782
- createComment
2741
+ function mergeDataFn(to, from) {
2742
+ if (!from) {
2743
+ return to;
2744
+ }
2745
+ if (!to) {
2746
+ return from;
2747
+ }
2748
+ return function mergedDataFn() {
2749
+ return (shared.extend)(
2750
+ shared.isFunction(to) ? to.call(this, this) : to,
2751
+ shared.isFunction(from) ? from.call(this, this) : from
2752
+ );
2753
+ };
2754
+ }
2755
+ function mergeInject(to, from) {
2756
+ return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
2757
+ }
2758
+ function normalizeInject(raw) {
2759
+ if (shared.isArray(raw)) {
2760
+ const res = {};
2761
+ for (let i = 0; i < raw.length; i++) {
2762
+ res[raw[i]] = raw[i];
2783
2763
  }
2784
- } = rendererInternals;
2785
- const hydrate = (vnode, container) => {
2786
- if (!container.hasChildNodes()) {
2787
- patch(null, vnode, container);
2788
- flushPostFlushCbs();
2789
- container._vnode = vnode;
2790
- return;
2764
+ return res;
2765
+ }
2766
+ return raw;
2767
+ }
2768
+ function mergeAsArray(to, from) {
2769
+ return to ? [...new Set([].concat(to, from))] : from;
2770
+ }
2771
+ function mergeObjectOptions(to, from) {
2772
+ return to ? shared.extend(/* @__PURE__ */ Object.create(null), to, from) : from;
2773
+ }
2774
+ function mergeEmitsOrPropsOptions(to, from) {
2775
+ if (to) {
2776
+ if (shared.isArray(to) && shared.isArray(from)) {
2777
+ return [.../* @__PURE__ */ new Set([...to, ...from])];
2791
2778
  }
2792
- hydrateNode(container.firstChild, vnode, null, null, null);
2793
- flushPostFlushCbs();
2794
- container._vnode = vnode;
2795
- };
2796
- const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
2797
- optimized = optimized || !!vnode.dynamicChildren;
2798
- const isFragmentStart = isComment(node) && node.data === "[";
2799
- const onMismatch = () => handleMismatch(
2800
- node,
2801
- vnode,
2802
- parentComponent,
2803
- parentSuspense,
2804
- slotScopeIds,
2805
- isFragmentStart
2779
+ return shared.extend(
2780
+ /* @__PURE__ */ Object.create(null),
2781
+ normalizePropsOrEmits(to),
2782
+ normalizePropsOrEmits(from != null ? from : {})
2806
2783
  );
2807
- const { type, ref, shapeFlag, patchFlag } = vnode;
2808
- let domType = node.nodeType;
2809
- vnode.el = node;
2810
- if (patchFlag === -2) {
2811
- optimized = false;
2812
- vnode.dynamicChildren = null;
2784
+ } else {
2785
+ return from;
2786
+ }
2787
+ }
2788
+ function mergeWatchOptions(to, from) {
2789
+ if (!to) return from;
2790
+ if (!from) return to;
2791
+ const merged = shared.extend(/* @__PURE__ */ Object.create(null), to);
2792
+ for (const key in from) {
2793
+ merged[key] = mergeAsArray(to[key], from[key]);
2794
+ }
2795
+ return merged;
2796
+ }
2797
+
2798
+ function createAppContext() {
2799
+ return {
2800
+ app: null,
2801
+ config: {
2802
+ isNativeTag: shared.NO,
2803
+ performance: false,
2804
+ globalProperties: {},
2805
+ optionMergeStrategies: {},
2806
+ errorHandler: void 0,
2807
+ warnHandler: void 0,
2808
+ compilerOptions: {}
2809
+ },
2810
+ mixins: [],
2811
+ components: {},
2812
+ directives: {},
2813
+ provides: /* @__PURE__ */ Object.create(null),
2814
+ optionsCache: /* @__PURE__ */ new WeakMap(),
2815
+ propsCache: /* @__PURE__ */ new WeakMap(),
2816
+ emitsCache: /* @__PURE__ */ new WeakMap()
2817
+ };
2818
+ }
2819
+ let uid$1 = 0;
2820
+ function createAppAPI(render, hydrate) {
2821
+ return function createApp(rootComponent, rootProps = null) {
2822
+ if (!shared.isFunction(rootComponent)) {
2823
+ rootComponent = shared.extend({}, rootComponent);
2813
2824
  }
2814
- let nextNode = null;
2815
- switch (type) {
2816
- case Text:
2817
- if (domType !== 3 /* TEXT */) {
2818
- if (vnode.children === "") {
2819
- insert(vnode.el = createText(""), parentNode(node), node);
2820
- nextNode = node;
2821
- } else {
2822
- nextNode = onMismatch();
2823
- }
2824
- } else {
2825
- if (node.data !== vnode.children) {
2826
- logMismatchError();
2827
- node.data = vnode.children;
2825
+ if (rootProps != null && !shared.isObject(rootProps)) {
2826
+ rootProps = null;
2827
+ }
2828
+ const context = createAppContext();
2829
+ const installedPlugins = /* @__PURE__ */ new WeakSet();
2830
+ const pluginCleanupFns = [];
2831
+ let isMounted = false;
2832
+ const app = context.app = {
2833
+ _uid: uid$1++,
2834
+ _component: rootComponent,
2835
+ _props: rootProps,
2836
+ _container: null,
2837
+ _context: context,
2838
+ _instance: null,
2839
+ version,
2840
+ get config() {
2841
+ return context.config;
2842
+ },
2843
+ set config(v) {
2844
+ },
2845
+ use(plugin, ...options) {
2846
+ if (installedPlugins.has(plugin)) ; else if (plugin && shared.isFunction(plugin.install)) {
2847
+ installedPlugins.add(plugin);
2848
+ plugin.install(app, ...options);
2849
+ } else if (shared.isFunction(plugin)) {
2850
+ installedPlugins.add(plugin);
2851
+ plugin(app, ...options);
2852
+ } else ;
2853
+ return app;
2854
+ },
2855
+ mixin(mixin) {
2856
+ {
2857
+ if (!context.mixins.includes(mixin)) {
2858
+ context.mixins.push(mixin);
2828
2859
  }
2829
- nextNode = nextSibling(node);
2830
- }
2831
- break;
2832
- case Comment:
2833
- if (isTemplateNode(node)) {
2834
- nextNode = nextSibling(node);
2835
- replaceNode(
2836
- vnode.el = node.content.firstChild,
2837
- node,
2838
- parentComponent
2839
- );
2840
- } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
2841
- nextNode = onMismatch();
2842
- } else {
2843
- nextNode = nextSibling(node);
2844
- }
2845
- break;
2846
- case Static:
2847
- if (isFragmentStart) {
2848
- node = nextSibling(node);
2849
- domType = node.nodeType;
2850
2860
  }
2851
- if (domType === 1 /* ELEMENT */ || domType === 3 /* TEXT */) {
2852
- nextNode = node;
2853
- const needToAdoptContent = !vnode.children.length;
2854
- for (let i = 0; i < vnode.staticCount; i++) {
2855
- if (needToAdoptContent)
2856
- vnode.children += nextNode.nodeType === 1 /* ELEMENT */ ? nextNode.outerHTML : nextNode.data;
2857
- if (i === vnode.staticCount - 1) {
2858
- vnode.anchor = nextNode;
2859
- }
2860
- nextNode = nextSibling(nextNode);
2861
- }
2862
- return isFragmentStart ? nextSibling(nextNode) : nextNode;
2863
- } else {
2864
- onMismatch();
2861
+ return app;
2862
+ },
2863
+ component(name, component) {
2864
+ if (!component) {
2865
+ return context.components[name];
2865
2866
  }
2866
- break;
2867
- case Fragment:
2868
- if (!isFragmentStart) {
2869
- nextNode = onMismatch();
2870
- } else {
2871
- nextNode = hydrateFragment(
2872
- node,
2873
- vnode,
2874
- parentComponent,
2875
- parentSuspense,
2876
- slotScopeIds,
2877
- optimized
2878
- );
2867
+ context.components[name] = component;
2868
+ return app;
2869
+ },
2870
+ directive(name, directive) {
2871
+ if (!directive) {
2872
+ return context.directives[name];
2879
2873
  }
2880
- break;
2881
- default:
2882
- if (shapeFlag & 1) {
2883
- if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
2884
- nextNode = onMismatch();
2885
- } else {
2886
- nextNode = hydrateElement(
2887
- node,
2888
- vnode,
2889
- parentComponent,
2890
- parentSuspense,
2891
- slotScopeIds,
2892
- optimized
2893
- );
2874
+ context.directives[name] = directive;
2875
+ return app;
2876
+ },
2877
+ mount(rootContainer, isHydrate, namespace) {
2878
+ if (!isMounted) {
2879
+ const vnode = app._ceVNode || createVNode(rootComponent, rootProps);
2880
+ vnode.appContext = context;
2881
+ if (namespace === true) {
2882
+ namespace = "svg";
2883
+ } else if (namespace === false) {
2884
+ namespace = void 0;
2894
2885
  }
2895
- } else if (shapeFlag & 6) {
2896
- vnode.slotScopeIds = slotScopeIds;
2897
- const container = parentNode(node);
2898
- if (isFragmentStart) {
2899
- nextNode = locateClosingAnchor(node);
2900
- } else if (isComment(node) && node.data === "teleport start") {
2901
- nextNode = locateClosingAnchor(node, node.data, "teleport end");
2886
+ if (isHydrate && hydrate) {
2887
+ hydrate(vnode, rootContainer);
2902
2888
  } else {
2903
- nextNode = nextSibling(node);
2889
+ render(vnode, rootContainer, namespace);
2904
2890
  }
2905
- mountComponent(
2906
- vnode,
2907
- container,
2908
- null,
2909
- parentComponent,
2910
- parentSuspense,
2911
- getContainerType(container),
2912
- optimized
2891
+ isMounted = true;
2892
+ app._container = rootContainer;
2893
+ rootContainer.__vue_app__ = app;
2894
+ return getComponentPublicInstance(vnode.component);
2895
+ }
2896
+ },
2897
+ onUnmount(cleanupFn) {
2898
+ pluginCleanupFns.push(cleanupFn);
2899
+ },
2900
+ unmount() {
2901
+ if (isMounted) {
2902
+ callWithAsyncErrorHandling(
2903
+ pluginCleanupFns,
2904
+ app._instance,
2905
+ 16
2913
2906
  );
2914
- if (isAsyncWrapper(vnode)) {
2915
- let subTree;
2916
- if (isFragmentStart) {
2917
- subTree = createVNode(Fragment);
2918
- subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
2919
- } else {
2920
- subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
2907
+ render(null, app._container);
2908
+ delete app._container.__vue_app__;
2909
+ }
2910
+ },
2911
+ provide(key, value) {
2912
+ context.provides[key] = value;
2913
+ return app;
2914
+ },
2915
+ runWithContext(fn) {
2916
+ const lastApp = currentApp;
2917
+ currentApp = app;
2918
+ try {
2919
+ return fn();
2920
+ } finally {
2921
+ currentApp = lastApp;
2922
+ }
2923
+ }
2924
+ };
2925
+ return app;
2926
+ };
2927
+ }
2928
+ let currentApp = null;
2929
+
2930
+ function provide(key, value) {
2931
+ if (!currentInstance) ; else {
2932
+ let provides = currentInstance.provides;
2933
+ const parentProvides = currentInstance.parent && currentInstance.parent.provides;
2934
+ if (parentProvides === provides) {
2935
+ provides = currentInstance.provides = Object.create(parentProvides);
2936
+ }
2937
+ provides[key] = value;
2938
+ }
2939
+ }
2940
+ function inject(key, defaultValue, treatDefaultAsFactory = false) {
2941
+ const instance = currentInstance || currentRenderingInstance;
2942
+ if (instance || currentApp) {
2943
+ const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
2944
+ if (provides && key in provides) {
2945
+ return provides[key];
2946
+ } else if (arguments.length > 1) {
2947
+ return treatDefaultAsFactory && shared.isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
2948
+ } else ;
2949
+ }
2950
+ }
2951
+ function hasInjectionContext() {
2952
+ return !!(currentInstance || currentRenderingInstance || currentApp);
2953
+ }
2954
+
2955
+ const internalObjectProto = {};
2956
+ const createInternalObject = () => Object.create(internalObjectProto);
2957
+ const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
2958
+
2959
+ function initProps(instance, rawProps, isStateful, isSSR = false) {
2960
+ const props = {};
2961
+ const attrs = createInternalObject();
2962
+ instance.propsDefaults = /* @__PURE__ */ Object.create(null);
2963
+ setFullProps(instance, rawProps, props, attrs);
2964
+ for (const key in instance.propsOptions[0]) {
2965
+ if (!(key in props)) {
2966
+ props[key] = void 0;
2967
+ }
2968
+ }
2969
+ if (isStateful) {
2970
+ instance.props = isSSR ? props : reactivity.shallowReactive(props);
2971
+ } else {
2972
+ if (!instance.type.props) {
2973
+ instance.props = attrs;
2974
+ } else {
2975
+ instance.props = props;
2976
+ }
2977
+ }
2978
+ instance.attrs = attrs;
2979
+ }
2980
+ function updateProps(instance, rawProps, rawPrevProps, optimized) {
2981
+ const {
2982
+ props,
2983
+ attrs,
2984
+ vnode: { patchFlag }
2985
+ } = instance;
2986
+ const rawCurrentProps = reactivity.toRaw(props);
2987
+ const [options] = instance.propsOptions;
2988
+ let hasAttrsChanged = false;
2989
+ if (
2990
+ // always force full diff in dev
2991
+ // - #1942 if hmr is enabled with sfc component
2992
+ // - vite#872 non-sfc component used by sfc component
2993
+ (optimized || patchFlag > 0) && !(patchFlag & 16)
2994
+ ) {
2995
+ if (patchFlag & 8) {
2996
+ const propsToUpdate = instance.vnode.dynamicProps;
2997
+ for (let i = 0; i < propsToUpdate.length; i++) {
2998
+ let key = propsToUpdate[i];
2999
+ if (isEmitListener(instance.emitsOptions, key)) {
3000
+ continue;
3001
+ }
3002
+ const value = rawProps[key];
3003
+ if (options) {
3004
+ if (shared.hasOwn(attrs, key)) {
3005
+ if (value !== attrs[key]) {
3006
+ attrs[key] = value;
3007
+ hasAttrsChanged = true;
2921
3008
  }
2922
- subTree.el = node;
2923
- vnode.component.subTree = subTree;
2924
- }
2925
- } else if (shapeFlag & 64) {
2926
- if (domType !== 8 /* COMMENT */) {
2927
- nextNode = onMismatch();
2928
3009
  } else {
2929
- nextNode = vnode.type.hydrate(
2930
- node,
2931
- vnode,
2932
- parentComponent,
2933
- parentSuspense,
2934
- slotScopeIds,
2935
- optimized,
2936
- rendererInternals,
2937
- hydrateChildren
3010
+ const camelizedKey = shared.camelize(key);
3011
+ props[camelizedKey] = resolvePropValue(
3012
+ options,
3013
+ rawCurrentProps,
3014
+ camelizedKey,
3015
+ value,
3016
+ instance,
3017
+ false
2938
3018
  );
2939
3019
  }
2940
- } else if (shapeFlag & 128) {
2941
- nextNode = vnode.type.hydrate(
2942
- node,
2943
- vnode,
2944
- parentComponent,
2945
- parentSuspense,
2946
- getContainerType(parentNode(node)),
2947
- slotScopeIds,
2948
- optimized,
2949
- rendererInternals,
2950
- hydrateNode
2951
- );
2952
- } else ;
2953
- }
2954
- if (ref != null) {
2955
- setRef(ref, null, parentSuspense, vnode);
2956
- }
2957
- return nextNode;
2958
- };
2959
- const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
2960
- optimized = optimized || !!vnode.dynamicChildren;
2961
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
2962
- const forcePatch = type === "input" || type === "option";
2963
- if (forcePatch || patchFlag !== -1) {
2964
- if (dirs) {
2965
- invokeDirectiveHook(vnode, null, parentComponent, "created");
2966
- }
2967
- let needCallTransitionHooks = false;
2968
- if (isTemplateNode(el)) {
2969
- needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
2970
- const content = el.content.firstChild;
2971
- if (needCallTransitionHooks) {
2972
- transition.beforeEnter(content);
2973
- }
2974
- replaceNode(content, el, parentComponent);
2975
- vnode.el = el = content;
2976
- }
2977
- if (shapeFlag & 16 && // skip if element has innerHTML / textContent
2978
- !(props && (props.innerHTML || props.textContent))) {
2979
- let next = hydrateChildren(
2980
- el.firstChild,
2981
- vnode,
2982
- el,
2983
- parentComponent,
2984
- parentSuspense,
2985
- slotScopeIds,
2986
- optimized
2987
- );
2988
- while (next) {
2989
- logMismatchError();
2990
- const cur = next;
2991
- next = next.nextSibling;
2992
- remove(cur);
2993
- }
2994
- } else if (shapeFlag & 8) {
2995
- if (el.textContent !== vnode.children) {
2996
- logMismatchError();
2997
- el.textContent = vnode.children;
3020
+ } else {
3021
+ if (value !== attrs[key]) {
3022
+ attrs[key] = value;
3023
+ hasAttrsChanged = true;
3024
+ }
2998
3025
  }
2999
3026
  }
3000
- if (props) {
3001
- if (forcePatch || !optimized || patchFlag & (16 | 32)) {
3002
- for (const key in props) {
3003
- if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
3004
- key[0] === ".") {
3005
- patchProp(el, key, null, props[key], void 0, parentComponent);
3006
- }
3027
+ }
3028
+ } else {
3029
+ if (setFullProps(instance, rawProps, props, attrs)) {
3030
+ hasAttrsChanged = true;
3031
+ }
3032
+ let kebabKey;
3033
+ for (const key in rawCurrentProps) {
3034
+ if (!rawProps || // for camelCase
3035
+ !shared.hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
3036
+ // and converted to camelCase (#955)
3037
+ ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey))) {
3038
+ if (options) {
3039
+ if (rawPrevProps && // for camelCase
3040
+ (rawPrevProps[key] !== void 0 || // for kebab-case
3041
+ rawPrevProps[kebabKey] !== void 0)) {
3042
+ props[key] = resolvePropValue(
3043
+ options,
3044
+ rawCurrentProps,
3045
+ key,
3046
+ void 0,
3047
+ instance,
3048
+ true
3049
+ );
3007
3050
  }
3008
- } else if (props.onClick) {
3009
- patchProp(
3010
- el,
3011
- "onClick",
3012
- null,
3013
- props.onClick,
3014
- void 0,
3015
- parentComponent
3016
- );
3017
- } else if (patchFlag & 4 && reactivity.isReactive(props.style)) {
3018
- for (const key in props.style) props.style[key];
3051
+ } else {
3052
+ delete props[key];
3019
3053
  }
3020
3054
  }
3021
- let vnodeHooks;
3022
- if (vnodeHooks = props && props.onVnodeBeforeMount) {
3023
- invokeVNodeHook(vnodeHooks, parentComponent, vnode);
3055
+ }
3056
+ if (attrs !== rawCurrentProps) {
3057
+ for (const key in attrs) {
3058
+ if (!rawProps || !shared.hasOwn(rawProps, key) && true) {
3059
+ delete attrs[key];
3060
+ hasAttrsChanged = true;
3061
+ }
3024
3062
  }
3025
- if (dirs) {
3026
- invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
3063
+ }
3064
+ }
3065
+ if (hasAttrsChanged) {
3066
+ reactivity.trigger(instance.attrs, "set", "");
3067
+ }
3068
+ }
3069
+ function setFullProps(instance, rawProps, props, attrs) {
3070
+ const [options, needCastKeys] = instance.propsOptions;
3071
+ let hasAttrsChanged = false;
3072
+ let rawCastValues;
3073
+ if (rawProps) {
3074
+ for (let key in rawProps) {
3075
+ if (shared.isReservedProp(key)) {
3076
+ continue;
3027
3077
  }
3028
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
3029
- queueEffectWithSuspense(() => {
3030
- vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
3031
- needCallTransitionHooks && transition.enter(el);
3032
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
3033
- }, parentSuspense);
3078
+ const value = rawProps[key];
3079
+ let camelKey;
3080
+ if (options && shared.hasOwn(options, camelKey = shared.camelize(key))) {
3081
+ if (!needCastKeys || !needCastKeys.includes(camelKey)) {
3082
+ props[camelKey] = value;
3083
+ } else {
3084
+ (rawCastValues || (rawCastValues = {}))[camelKey] = value;
3085
+ }
3086
+ } else if (!isEmitListener(instance.emitsOptions, key)) {
3087
+ if (!(key in attrs) || value !== attrs[key]) {
3088
+ attrs[key] = value;
3089
+ hasAttrsChanged = true;
3090
+ }
3034
3091
  }
3035
3092
  }
3036
- return el.nextSibling;
3037
- };
3038
- const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
3039
- optimized = optimized || !!parentVNode.dynamicChildren;
3040
- const children = parentVNode.children;
3041
- const l = children.length;
3042
- for (let i = 0; i < l; i++) {
3043
- const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
3044
- const isText = vnode.type === Text;
3045
- if (node) {
3046
- if (isText && !optimized) {
3047
- let next = children[i + 1];
3048
- if (next && (next = normalizeVNode(next)).type === Text) {
3049
- insert(
3050
- createText(
3051
- node.data.slice(vnode.children.length)
3052
- ),
3053
- container,
3054
- nextSibling(node)
3055
- );
3056
- node.data = vnode.children;
3057
- }
3058
- }
3059
- node = hydrateNode(
3060
- node,
3061
- vnode,
3062
- parentComponent,
3063
- parentSuspense,
3064
- slotScopeIds,
3065
- optimized
3066
- );
3067
- } else if (isText && !vnode.children) {
3068
- insert(vnode.el = createText(""), container);
3093
+ }
3094
+ if (needCastKeys) {
3095
+ const rawCurrentProps = reactivity.toRaw(props);
3096
+ const castValues = rawCastValues || shared.EMPTY_OBJ;
3097
+ for (let i = 0; i < needCastKeys.length; i++) {
3098
+ const key = needCastKeys[i];
3099
+ props[key] = resolvePropValue(
3100
+ options,
3101
+ rawCurrentProps,
3102
+ key,
3103
+ castValues[key],
3104
+ instance,
3105
+ !shared.hasOwn(castValues, key)
3106
+ );
3107
+ }
3108
+ }
3109
+ return hasAttrsChanged;
3110
+ }
3111
+ function resolvePropValue(options, props, key, value, instance, isAbsent) {
3112
+ const opt = options[key];
3113
+ if (opt != null) {
3114
+ const hasDefault = shared.hasOwn(opt, "default");
3115
+ if (hasDefault && value === void 0) {
3116
+ const defaultValue = opt.default;
3117
+ if (opt.type !== Function && !opt.skipFactory && shared.isFunction(defaultValue)) {
3118
+ const { propsDefaults } = instance;
3119
+ if (key in propsDefaults) {
3120
+ value = propsDefaults[key];
3121
+ } else {
3122
+ const reset = setCurrentInstance(instance);
3123
+ value = propsDefaults[key] = defaultValue.call(
3124
+ null,
3125
+ props
3126
+ );
3127
+ reset();
3128
+ }
3069
3129
  } else {
3070
- logMismatchError();
3071
- patch(
3072
- null,
3073
- vnode,
3074
- container,
3075
- null,
3076
- parentComponent,
3077
- parentSuspense,
3078
- getContainerType(container),
3079
- slotScopeIds
3080
- );
3130
+ value = defaultValue;
3131
+ }
3132
+ if (instance.ce) {
3133
+ instance.ce._setProp(key, value);
3081
3134
  }
3082
3135
  }
3083
- return node;
3084
- };
3085
- const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
3086
- const { slotScopeIds: fragmentSlotScopeIds } = vnode;
3087
- if (fragmentSlotScopeIds) {
3088
- slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
3136
+ if (opt[0 /* shouldCast */]) {
3137
+ if (isAbsent && !hasDefault) {
3138
+ value = false;
3139
+ } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === shared.hyphenate(key))) {
3140
+ value = true;
3141
+ }
3089
3142
  }
3090
- const container = parentNode(node);
3091
- const next = hydrateChildren(
3092
- nextSibling(node),
3093
- vnode,
3094
- container,
3095
- parentComponent,
3096
- parentSuspense,
3097
- slotScopeIds,
3098
- optimized
3099
- );
3100
- if (next && isComment(next) && next.data === "]") {
3101
- return nextSibling(vnode.anchor = next);
3102
- } else {
3103
- logMismatchError();
3104
- insert(vnode.anchor = createComment(`]`), container, next);
3105
- return next;
3143
+ }
3144
+ return value;
3145
+ }
3146
+ const mixinPropsCache = /* @__PURE__ */ new WeakMap();
3147
+ function normalizePropsOptions(comp, appContext, asMixin = false) {
3148
+ const cache = asMixin ? mixinPropsCache : appContext.propsCache;
3149
+ const cached = cache.get(comp);
3150
+ if (cached) {
3151
+ return cached;
3152
+ }
3153
+ const raw = comp.props;
3154
+ const normalized = {};
3155
+ const needCastKeys = [];
3156
+ let hasExtends = false;
3157
+ if (!shared.isFunction(comp)) {
3158
+ const extendProps = (raw2) => {
3159
+ hasExtends = true;
3160
+ const [props, keys] = normalizePropsOptions(raw2, appContext, true);
3161
+ shared.extend(normalized, props);
3162
+ if (keys) needCastKeys.push(...keys);
3163
+ };
3164
+ if (!asMixin && appContext.mixins.length) {
3165
+ appContext.mixins.forEach(extendProps);
3106
3166
  }
3107
- };
3108
- const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
3109
- logMismatchError();
3110
- vnode.el = null;
3111
- if (isFragment) {
3112
- const end = locateClosingAnchor(node);
3113
- while (true) {
3114
- const next2 = nextSibling(node);
3115
- if (next2 && next2 !== end) {
3116
- remove(next2);
3117
- } else {
3118
- break;
3119
- }
3167
+ if (comp.extends) {
3168
+ extendProps(comp.extends);
3169
+ }
3170
+ if (comp.mixins) {
3171
+ comp.mixins.forEach(extendProps);
3172
+ }
3173
+ }
3174
+ if (!raw && !hasExtends) {
3175
+ if (shared.isObject(comp)) {
3176
+ cache.set(comp, shared.EMPTY_ARR);
3177
+ }
3178
+ return shared.EMPTY_ARR;
3179
+ }
3180
+ if (shared.isArray(raw)) {
3181
+ for (let i = 0; i < raw.length; i++) {
3182
+ const normalizedKey = shared.camelize(raw[i]);
3183
+ if (validatePropName(normalizedKey)) {
3184
+ normalized[normalizedKey] = shared.EMPTY_OBJ;
3120
3185
  }
3121
3186
  }
3122
- const next = nextSibling(node);
3123
- const container = parentNode(node);
3124
- remove(node);
3125
- patch(
3126
- null,
3127
- vnode,
3128
- container,
3129
- next,
3130
- parentComponent,
3131
- parentSuspense,
3132
- getContainerType(container),
3133
- slotScopeIds
3134
- );
3135
- return next;
3136
- };
3137
- const locateClosingAnchor = (node, open = "[", close = "]") => {
3138
- let match = 0;
3139
- while (node) {
3140
- node = nextSibling(node);
3141
- if (node && isComment(node)) {
3142
- if (node.data === open) match++;
3143
- if (node.data === close) {
3144
- if (match === 0) {
3145
- return nextSibling(node);
3146
- } else {
3147
- match--;
3187
+ } else if (raw) {
3188
+ for (const key in raw) {
3189
+ const normalizedKey = shared.camelize(key);
3190
+ if (validatePropName(normalizedKey)) {
3191
+ const opt = raw[key];
3192
+ const prop = normalized[normalizedKey] = shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : shared.extend({}, opt);
3193
+ const propType = prop.type;
3194
+ let shouldCast = false;
3195
+ let shouldCastTrue = true;
3196
+ if (shared.isArray(propType)) {
3197
+ for (let index = 0; index < propType.length; ++index) {
3198
+ const type = propType[index];
3199
+ const typeName = shared.isFunction(type) && type.name;
3200
+ if (typeName === "Boolean") {
3201
+ shouldCast = true;
3202
+ break;
3203
+ } else if (typeName === "String") {
3204
+ shouldCastTrue = false;
3205
+ }
3148
3206
  }
3207
+ } else {
3208
+ shouldCast = shared.isFunction(propType) && propType.name === "Boolean";
3209
+ }
3210
+ prop[0 /* shouldCast */] = shouldCast;
3211
+ prop[1 /* shouldCastTrue */] = shouldCastTrue;
3212
+ if (shouldCast || shared.hasOwn(prop, "default")) {
3213
+ needCastKeys.push(normalizedKey);
3149
3214
  }
3150
3215
  }
3151
3216
  }
3152
- return node;
3153
- };
3154
- const replaceNode = (newNode, oldNode, parentComponent) => {
3155
- const parentNode2 = oldNode.parentNode;
3156
- if (parentNode2) {
3157
- parentNode2.replaceChild(newNode, oldNode);
3217
+ }
3218
+ const res = [normalized, needCastKeys];
3219
+ if (shared.isObject(comp)) {
3220
+ cache.set(comp, res);
3221
+ }
3222
+ return res;
3223
+ }
3224
+ function validatePropName(key) {
3225
+ if (key[0] !== "$" && !shared.isReservedProp(key)) {
3226
+ return true;
3227
+ }
3228
+ return false;
3229
+ }
3230
+
3231
+ const isInternalKey = (key) => key[0] === "_" || key === "$stable";
3232
+ const normalizeSlotValue = (value) => shared.isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
3233
+ const normalizeSlot = (key, rawSlot, ctx) => {
3234
+ if (rawSlot._n) {
3235
+ return rawSlot;
3236
+ }
3237
+ const normalized = withCtx((...args) => {
3238
+ if (false) ;
3239
+ return normalizeSlotValue(rawSlot(...args));
3240
+ }, ctx);
3241
+ normalized._c = false;
3242
+ return normalized;
3243
+ };
3244
+ const normalizeObjectSlots = (rawSlots, slots, instance) => {
3245
+ const ctx = rawSlots._ctx;
3246
+ for (const key in rawSlots) {
3247
+ if (isInternalKey(key)) continue;
3248
+ const value = rawSlots[key];
3249
+ if (shared.isFunction(value)) {
3250
+ slots[key] = normalizeSlot(key, value, ctx);
3251
+ } else if (value != null) {
3252
+ const normalized = normalizeSlotValue(value);
3253
+ slots[key] = () => normalized;
3158
3254
  }
3159
- let parent = parentComponent;
3160
- while (parent) {
3161
- if (parent.vnode.el === oldNode) {
3162
- parent.vnode.el = parent.subTree.el = newNode;
3255
+ }
3256
+ };
3257
+ const normalizeVNodeSlots = (instance, children) => {
3258
+ const normalized = normalizeSlotValue(children);
3259
+ instance.slots.default = () => normalized;
3260
+ };
3261
+ const assignSlots = (slots, children, optimized) => {
3262
+ for (const key in children) {
3263
+ if (optimized || key !== "_") {
3264
+ slots[key] = children[key];
3265
+ }
3266
+ }
3267
+ };
3268
+ const initSlots = (instance, children, optimized) => {
3269
+ const slots = instance.slots = createInternalObject();
3270
+ if (instance.vnode.shapeFlag & 32) {
3271
+ const type = children._;
3272
+ if (type) {
3273
+ assignSlots(slots, children, optimized);
3274
+ if (optimized) {
3275
+ shared.def(slots, "_", type, true);
3163
3276
  }
3164
- parent = parent.parent;
3277
+ } else {
3278
+ normalizeObjectSlots(children, slots);
3165
3279
  }
3166
- };
3167
- const isTemplateNode = (node) => {
3168
- return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
3169
- };
3170
- return [hydrate, hydrateNode];
3171
- }
3280
+ } else if (children) {
3281
+ normalizeVNodeSlots(instance, children);
3282
+ }
3283
+ };
3284
+ const updateSlots = (instance, children, optimized) => {
3285
+ const { vnode, slots } = instance;
3286
+ let needDeletionCheck = true;
3287
+ let deletionComparisonTarget = shared.EMPTY_OBJ;
3288
+ if (vnode.shapeFlag & 32) {
3289
+ const type = children._;
3290
+ if (type) {
3291
+ if (optimized && type === 1) {
3292
+ needDeletionCheck = false;
3293
+ } else {
3294
+ assignSlots(slots, children, optimized);
3295
+ }
3296
+ } else {
3297
+ needDeletionCheck = !children.$stable;
3298
+ normalizeObjectSlots(children, slots);
3299
+ }
3300
+ deletionComparisonTarget = children;
3301
+ } else if (children) {
3302
+ normalizeVNodeSlots(instance, children);
3303
+ deletionComparisonTarget = { default: 1 };
3304
+ }
3305
+ if (needDeletionCheck) {
3306
+ for (const key in slots) {
3307
+ if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
3308
+ delete slots[key];
3309
+ }
3310
+ }
3311
+ }
3312
+ };
3172
3313
 
3173
3314
  const queuePostRenderEffect = queueEffectWithSuspense ;
3174
3315
  function createRenderer(options) {
@@ -3750,8 +3891,8 @@ function baseCreateRenderer(options, createHydrationFns) {
3750
3891
  const componentUpdateFn = () => {
3751
3892
  if (!instance.isMounted) {
3752
3893
  let vnodeHook;
3753
- const { el, props, type } = initialVNode;
3754
- const { bm, m, parent } = instance;
3894
+ const { el, props } = initialVNode;
3895
+ const { bm, m, parent, root, type } = instance;
3755
3896
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
3756
3897
  toggleRecurse(instance, false);
3757
3898
  if (bm) {
@@ -3772,18 +3913,19 @@ function baseCreateRenderer(options, createHydrationFns) {
3772
3913
  null
3773
3914
  );
3774
3915
  };
3775
- if (isAsyncWrapperVNode && !type.__asyncResolved) {
3776
- type.__asyncLoader().then(
3777
- // note: we are moving the render call into an async callback,
3778
- // which means it won't track dependencies - but it's ok because
3779
- // a server-rendered async wrapper is already in resolved state
3780
- // and it will never need to change.
3781
- () => !instance.isUnmounted && hydrateSubTree()
3916
+ if (isAsyncWrapperVNode) {
3917
+ type.__asyncHydrate(
3918
+ el,
3919
+ instance,
3920
+ hydrateSubTree
3782
3921
  );
3783
3922
  } else {
3784
3923
  hydrateSubTree();
3785
3924
  }
3786
3925
  } else {
3926
+ if (root.ce) {
3927
+ root.ce._injectChildStyle(type);
3928
+ }
3787
3929
  const subTree = instance.subTree = renderComponentRoot(instance);
3788
3930
  patch(
3789
3931
  null,
@@ -4396,13 +4538,13 @@ function baseCreateRenderer(options, createHydrationFns) {
4396
4538
  namespace
4397
4539
  );
4398
4540
  }
4541
+ container._vnode = vnode;
4399
4542
  if (!isFlushing) {
4400
4543
  isFlushing = true;
4401
4544
  flushPreFlushCbs();
4402
4545
  flushPostFlushCbs();
4403
4546
  isFlushing = false;
4404
4547
  }
4405
- container._vnode = vnode;
4406
4548
  };
4407
4549
  const internals = {
4408
4550
  p: patch,
@@ -4563,14 +4705,16 @@ function doWatch(source, cb, {
4563
4705
  const _cb = cb;
4564
4706
  cb = (...args) => {
4565
4707
  _cb(...args);
4566
- unwatch();
4708
+ watchHandle();
4567
4709
  };
4568
4710
  }
4569
4711
  const instance = currentInstance;
4570
- const reactiveGetter = (source2) => deep === true ? source2 : (
4571
- // for deep: false, only traverse root-level properties
4572
- traverse(source2, deep === false ? 1 : void 0)
4573
- );
4712
+ const reactiveGetter = (source2) => {
4713
+ if (deep) return source2;
4714
+ if (reactivity.isShallow(source2) || deep === false || deep === 0)
4715
+ return traverse(source2, 1);
4716
+ return traverse(source2);
4717
+ };
4574
4718
  let getter;
4575
4719
  let forceTrigger = false;
4576
4720
  let isMultiSource = false;
@@ -4613,7 +4757,8 @@ function doWatch(source, cb, {
4613
4757
  }
4614
4758
  if (cb && deep) {
4615
4759
  const baseGetter = getter;
4616
- getter = () => traverse(baseGetter());
4760
+ const depth = deep === true ? Infinity : deep;
4761
+ getter = () => traverse(baseGetter(), depth);
4617
4762
  }
4618
4763
  let cleanup;
4619
4764
  let onCleanup = (fn) => {
@@ -4638,7 +4783,12 @@ function doWatch(source, cb, {
4638
4783
  const ctx = useSSRContext();
4639
4784
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
4640
4785
  } else {
4641
- return shared.NOOP;
4786
+ const watchHandle2 = () => {
4787
+ };
4788
+ watchHandle2.stop = shared.NOOP;
4789
+ watchHandle2.resume = shared.NOOP;
4790
+ watchHandle2.pause = shared.NOOP;
4791
+ return watchHandle2;
4642
4792
  }
4643
4793
  }
4644
4794
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -4679,12 +4829,15 @@ function doWatch(source, cb, {
4679
4829
  }
4680
4830
  effect.scheduler = scheduler;
4681
4831
  const scope = reactivity.getCurrentScope();
4682
- const unwatch = () => {
4832
+ const watchHandle = () => {
4683
4833
  effect.stop();
4684
4834
  if (scope) {
4685
4835
  shared.remove(scope.effects, effect);
4686
4836
  }
4687
4837
  };
4838
+ watchHandle.pause = effect.pause.bind(effect);
4839
+ watchHandle.resume = effect.resume.bind(effect);
4840
+ watchHandle.stop = watchHandle;
4688
4841
  if (cb) {
4689
4842
  if (immediate) {
4690
4843
  job(true);
@@ -4699,8 +4852,8 @@ function doWatch(source, cb, {
4699
4852
  } else {
4700
4853
  effect.run();
4701
4854
  }
4702
- if (ssrCleanup) ssrCleanup.push(unwatch);
4703
- return unwatch;
4855
+ if (ssrCleanup) ssrCleanup.push(watchHandle);
4856
+ return watchHandle;
4704
4857
  }
4705
4858
  function instanceWatch(source, value, options) {
4706
4859
  const publicThis = this.proxy;
@@ -4782,7 +4935,8 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
4782
4935
  return options.get ? options.get(localValue) : localValue;
4783
4936
  },
4784
4937
  set(value) {
4785
- if (!shared.hasChanged(value, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
4938
+ const emittedValue = options.set ? options.set(value) : value;
4939
+ if (!shared.hasChanged(emittedValue, localValue) && !(prevSetValue !== shared.EMPTY_OBJ && shared.hasChanged(value, prevSetValue))) {
4786
4940
  return;
4787
4941
  }
4788
4942
  const rawProps = i.vnode.props;
@@ -4791,7 +4945,6 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
4791
4945
  localValue = value;
4792
4946
  trigger();
4793
4947
  }
4794
- const emittedValue = options.set ? options.set(value) : value;
4795
4948
  i.emit(`update:${name}`, emittedValue);
4796
4949
  if (shared.hasChanged(value, emittedValue) && shared.hasChanged(value, prevSetValue) && !shared.hasChanged(emittedValue, prevEmittedValue)) {
4797
4950
  trigger();
@@ -6322,11 +6475,13 @@ function useTemplateRef(key) {
6322
6475
  const r = reactivity.shallowRef(null);
6323
6476
  if (i) {
6324
6477
  const refs = i.refs === shared.EMPTY_OBJ ? i.refs = {} : i.refs;
6325
- Object.defineProperty(refs, key, {
6326
- enumerable: true,
6327
- get: () => r.value,
6328
- set: (val) => r.value = val
6329
- });
6478
+ {
6479
+ Object.defineProperty(refs, key, {
6480
+ enumerable: true,
6481
+ get: () => r.value,
6482
+ set: (val) => r.value = val
6483
+ });
6484
+ }
6330
6485
  }
6331
6486
  return r;
6332
6487
  }
@@ -6384,7 +6539,7 @@ function isMemoSame(cached, memo) {
6384
6539
  return true;
6385
6540
  }
6386
6541
 
6387
- const version = "3.5.0-alpha.4";
6542
+ const version = "3.5.0-beta.1";
6388
6543
  const warn$1 = shared.NOOP;
6389
6544
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
6390
6545
  const devtools = void 0;
@@ -6396,7 +6551,8 @@ const _ssrUtils = {
6396
6551
  setCurrentRenderingInstance,
6397
6552
  isVNode: isVNode,
6398
6553
  normalizeVNode,
6399
- getComponentPublicInstance
6554
+ getComponentPublicInstance,
6555
+ ensureValidVNode
6400
6556
  };
6401
6557
  const ssrUtils = _ssrUtils ;
6402
6558
  const resolveFilter = null;
@@ -6483,6 +6639,10 @@ exports.guardReactiveProps = guardReactiveProps;
6483
6639
  exports.h = h;
6484
6640
  exports.handleError = handleError;
6485
6641
  exports.hasInjectionContext = hasInjectionContext;
6642
+ exports.hydrateOnIdle = hydrateOnIdle;
6643
+ exports.hydrateOnInteraction = hydrateOnInteraction;
6644
+ exports.hydrateOnMediaQuery = hydrateOnMediaQuery;
6645
+ exports.hydrateOnVisible = hydrateOnVisible;
6486
6646
  exports.initCustomFormatter = initCustomFormatter;
6487
6647
  exports.inject = inject;
6488
6648
  exports.isMemoSame = isMemoSame;