@cabloy/vue-runtime-core 3.5.31 → 3.5.32

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.
@@ -1042,1273 +1042,1271 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
1042
1042
  return ret;
1043
1043
  }
1044
1044
 
1045
- /*! #__NO_SIDE_EFFECTS__ */
1046
- // @__NO_SIDE_EFFECTS__
1047
- function defineComponent(options, extraOptions) {
1048
- return shared.isFunction(options) ? (
1049
- // #8236: extend call and options.name access are considered side-effects
1050
- // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1051
- /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
1052
- ) : options;
1053
- }
1054
-
1055
- function useId() {
1056
- const i = getCurrentInstance();
1057
- if (i) {
1058
- return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++;
1059
- }
1060
- return "";
1061
- }
1062
- function markAsyncBoundary(instance) {
1063
- instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
1064
- }
1065
-
1066
- function useTemplateRef(key) {
1067
- const i = getCurrentInstance();
1068
- const r = reactivity.shallowRef(null);
1069
- if (i) {
1070
- const refs = i.refs === shared.EMPTY_OBJ ? i.refs = {} : i.refs;
1071
- {
1072
- Object.defineProperty(refs, key, {
1073
- enumerable: true,
1074
- get: () => r.value,
1075
- set: (val) => r.value = val
1076
- });
1077
- }
1078
- }
1079
- const ret = r;
1080
- return ret;
1081
- }
1082
-
1083
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
1084
- if (shared.isArray(rawRef)) {
1085
- rawRef.forEach(
1086
- (r, i) => setRef(
1087
- r,
1088
- oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
1089
- parentSuspense,
1090
- vnode,
1091
- isUnmount
1092
- )
1093
- );
1094
- return;
1095
- }
1096
- if (isAsyncWrapper(vnode) && !isUnmount) {
1097
- if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
1098
- setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
1099
- }
1100
- return;
1101
- }
1102
- const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
1103
- const value = isUnmount ? null : refValue;
1104
- const { i: owner, r: ref } = rawRef;
1105
- const oldRef = oldRawRef && oldRawRef.r;
1106
- const refs = owner.refs === shared.EMPTY_OBJ ? owner.refs = {} : owner.refs;
1107
- const setupState = owner.setupState;
1108
- const rawSetupState = reactivity.toRaw(setupState);
1109
- const canSetSetupRef = setupState === shared.EMPTY_OBJ ? () => false : (key) => {
1110
- return shared.hasOwn(rawSetupState, key);
1111
- };
1112
- if (oldRef != null && oldRef !== ref) {
1113
- if (shared.isString(oldRef)) {
1114
- refs[oldRef] = null;
1115
- if (canSetSetupRef(oldRef)) {
1116
- setupState[oldRef] = null;
1117
- }
1118
- } else if (reactivity.isRef(oldRef)) {
1119
- oldRef.value = null;
1120
- }
1121
- }
1122
- if (shared.isFunction(ref)) {
1123
- callWithErrorHandling(ref, owner, 12, [value, refs]);
1124
- } else {
1125
- const _isString = shared.isString(ref);
1126
- const _isRef = reactivity.isRef(ref);
1127
- if (_isString || _isRef) {
1128
- const doSet = () => {
1129
- if (rawRef.f) {
1130
- const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : ref.value;
1131
- if (isUnmount) {
1132
- shared.isArray(existing) && shared.remove(existing, refValue);
1133
- } else {
1134
- if (!shared.isArray(existing)) {
1135
- if (_isString) {
1136
- refs[ref] = [refValue];
1137
- if (canSetSetupRef(ref)) {
1138
- setupState[ref] = refs[ref];
1139
- }
1140
- } else {
1141
- ref.value = [refValue];
1142
- if (rawRef.k) refs[rawRef.k] = ref.value;
1143
- }
1144
- } else if (!existing.includes(refValue)) {
1145
- existing.push(refValue);
1146
- }
1147
- }
1148
- } else if (_isString) {
1149
- refs[ref] = value;
1150
- if (canSetSetupRef(ref)) {
1151
- setupState[ref] = value;
1152
- }
1153
- } else if (_isRef) {
1154
- ref.value = value;
1155
- if (rawRef.k) refs[rawRef.k] = value;
1156
- } else ;
1045
+ const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
1046
+ const KeepAliveImpl = {
1047
+ name: `KeepAlive`,
1048
+ // Marker for special handling inside the renderer. We are not using a ===
1049
+ // check directly on KeepAlive in the renderer, because importing it directly
1050
+ // would prevent it from being tree-shaken.
1051
+ __isKeepAlive: true,
1052
+ props: {
1053
+ include: [String, RegExp, Array],
1054
+ exclude: [String, RegExp, Array],
1055
+ max: [String, Number]
1056
+ },
1057
+ setup(props, { slots }) {
1058
+ const instance = getCurrentInstance();
1059
+ const sharedContext = instance.ctx;
1060
+ if (!sharedContext.renderer) {
1061
+ return () => {
1062
+ const children = slots.default && slots.default();
1063
+ return children && children.length === 1 ? children[0] : children;
1157
1064
  };
1158
- if (value) {
1159
- doSet.id = -1;
1160
- queuePostRenderEffect(doSet, parentSuspense);
1161
- } else {
1162
- doSet();
1163
- }
1164
1065
  }
1165
- }
1166
- }
1167
-
1168
- let hasLoggedMismatchError = false;
1169
- const logMismatchError = () => {
1170
- if (hasLoggedMismatchError) {
1171
- return;
1172
- }
1173
- console.error("Hydration completed but contains mismatches.");
1174
- hasLoggedMismatchError = true;
1175
- };
1176
- const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
1177
- const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
1178
- const getContainerType = (container) => {
1179
- if (container.nodeType !== 1) return void 0;
1180
- if (isSVGContainer(container)) return "svg";
1181
- if (isMathMLContainer(container)) return "mathml";
1182
- return void 0;
1183
- };
1184
- const isComment = (node) => node.nodeType === 8;
1185
- function createHydrationFunctions(rendererInternals) {
1186
- const {
1187
- mt: mountComponent,
1188
- p: patch,
1189
- o: {
1190
- patchProp,
1191
- createText,
1192
- nextSibling,
1193
- parentNode,
1194
- remove,
1195
- insert,
1196
- createComment
1197
- }
1198
- } = rendererInternals;
1199
- const hydrate = (vnode, container) => {
1200
- if (!container.hasChildNodes()) {
1201
- patch(null, vnode, container);
1202
- flushPostFlushCbs();
1203
- container._vnode = vnode;
1204
- return;
1205
- }
1206
- hydrateNode(container.firstChild, vnode, null, null, null);
1207
- flushPostFlushCbs();
1208
- container._vnode = vnode;
1209
- };
1210
- const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
1211
- optimized = optimized || !!vnode.dynamicChildren;
1212
- const isFragmentStart = isComment(node) && node.data === "[";
1213
- const onMismatch = () => handleMismatch(
1214
- node,
1215
- vnode,
1216
- parentComponent,
1217
- parentSuspense,
1218
- slotScopeIds,
1219
- isFragmentStart
1220
- );
1221
- const { type, ref, shapeFlag, patchFlag } = vnode;
1222
- let domType = node.nodeType;
1223
- vnode.el = node;
1224
- if (patchFlag === -2) {
1225
- optimized = false;
1226
- vnode.dynamicChildren = null;
1227
- }
1228
- let nextNode = null;
1229
- switch (type) {
1230
- case Text:
1231
- if (domType !== 3) {
1232
- if (vnode.children === "") {
1233
- insert(vnode.el = createText(""), parentNode(node), node);
1234
- nextNode = node;
1235
- } else {
1236
- nextNode = onMismatch();
1237
- }
1238
- } else {
1239
- if (node.data !== vnode.children) {
1240
- node.data = vnode.children;
1241
- }
1242
- nextNode = nextSibling(node);
1243
- }
1244
- break;
1245
- case Comment:
1246
- if (isTemplateNode(node)) {
1247
- nextNode = nextSibling(node);
1248
- replaceNode(
1249
- vnode.el = node.content.firstChild,
1250
- node,
1251
- parentComponent
1252
- );
1253
- } else if (domType !== 8 || isFragmentStart) {
1254
- nextNode = onMismatch();
1255
- } else {
1256
- nextNode = nextSibling(node);
1066
+ const cache = /* @__PURE__ */ new Map();
1067
+ const keys = /* @__PURE__ */ new Set();
1068
+ let current = null;
1069
+ const parentSuspense = instance.suspense;
1070
+ const {
1071
+ renderer: {
1072
+ p: patch,
1073
+ m: move,
1074
+ um: _unmount,
1075
+ o: { createElement }
1076
+ }
1077
+ } = sharedContext;
1078
+ const storageContainer = createElement("div");
1079
+ sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
1080
+ const instance2 = vnode.component;
1081
+ move(vnode, container, anchor, 0, parentSuspense);
1082
+ patch(
1083
+ instance2.vnode,
1084
+ vnode,
1085
+ container,
1086
+ anchor,
1087
+ instance2,
1088
+ parentSuspense,
1089
+ namespace,
1090
+ vnode.slotScopeIds,
1091
+ optimized
1092
+ );
1093
+ queuePostRenderEffect(() => {
1094
+ instance2.isDeactivated = false;
1095
+ if (instance2.a) {
1096
+ shared.invokeArrayFns(instance2.a);
1257
1097
  }
1258
- break;
1259
- case Static:
1260
- if (isFragmentStart) {
1261
- node = nextSibling(node);
1262
- domType = node.nodeType;
1098
+ const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
1099
+ if (vnodeHook) {
1100
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1263
1101
  }
1264
- if (domType === 1 || domType === 3) {
1265
- nextNode = node;
1266
- const needToAdoptContent = !vnode.children.length;
1267
- for (let i = 0; i < vnode.staticCount; i++) {
1268
- if (needToAdoptContent)
1269
- vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
1270
- if (i === vnode.staticCount - 1) {
1271
- vnode.anchor = nextNode;
1272
- }
1273
- nextNode = nextSibling(nextNode);
1274
- }
1275
- return isFragmentStart ? nextSibling(nextNode) : nextNode;
1276
- } else {
1277
- onMismatch();
1102
+ }, parentSuspense);
1103
+ };
1104
+ sharedContext.deactivate = (vnode) => {
1105
+ const instance2 = vnode.component;
1106
+ invalidateMount(instance2.m);
1107
+ invalidateMount(instance2.a);
1108
+ move(vnode, storageContainer, null, 1, parentSuspense);
1109
+ queuePostRenderEffect(() => {
1110
+ if (instance2.da) {
1111
+ shared.invokeArrayFns(instance2.da);
1278
1112
  }
1279
- break;
1280
- case Fragment:
1281
- if (!isFragmentStart) {
1282
- nextNode = onMismatch();
1283
- } else {
1284
- nextNode = hydrateFragment(
1285
- node,
1286
- vnode,
1287
- parentComponent,
1288
- parentSuspense,
1289
- slotScopeIds,
1290
- optimized
1291
- );
1113
+ const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
1114
+ if (vnodeHook) {
1115
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1292
1116
  }
1293
- break;
1294
- default:
1295
- if (shapeFlag & 1) {
1296
- if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
1297
- nextNode = onMismatch();
1298
- } else {
1299
- nextNode = hydrateElement(
1300
- node,
1301
- vnode,
1302
- parentComponent,
1303
- parentSuspense,
1304
- slotScopeIds,
1305
- optimized
1306
- );
1307
- }
1308
- } else if (shapeFlag & 6) {
1309
- vnode.slotScopeIds = slotScopeIds;
1310
- const container = parentNode(node);
1311
- if (isFragmentStart) {
1312
- nextNode = locateClosingAnchor(node);
1313
- } else if (isComment(node) && node.data === "teleport start") {
1314
- nextNode = locateClosingAnchor(node, node.data, "teleport end");
1315
- } else {
1316
- nextNode = nextSibling(node);
1317
- }
1318
- mountComponent(
1319
- vnode,
1320
- container,
1321
- null,
1322
- parentComponent,
1323
- parentSuspense,
1324
- getContainerType(container),
1325
- optimized
1326
- );
1327
- if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
1328
- let subTree;
1329
- if (isFragmentStart) {
1330
- subTree = createVNode(Fragment);
1331
- subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
1332
- } else {
1333
- subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
1334
- }
1335
- subTree.el = node;
1336
- vnode.component.subTree = subTree;
1337
- }
1338
- } else if (shapeFlag & 64) {
1339
- if (domType !== 8) {
1340
- nextNode = onMismatch();
1341
- } else {
1342
- nextNode = vnode.type.hydrate(
1343
- node,
1344
- vnode,
1345
- parentComponent,
1346
- parentSuspense,
1347
- slotScopeIds,
1348
- optimized,
1349
- rendererInternals,
1350
- hydrateChildren
1351
- );
1352
- }
1353
- } else if (shapeFlag & 128) {
1354
- nextNode = vnode.type.hydrate(
1355
- node,
1356
- vnode,
1357
- parentComponent,
1358
- parentSuspense,
1359
- getContainerType(parentNode(node)),
1360
- slotScopeIds,
1361
- optimized,
1362
- rendererInternals,
1363
- hydrateNode
1364
- );
1365
- } else ;
1366
- }
1367
- if (ref != null) {
1368
- setRef(ref, null, parentSuspense, vnode);
1117
+ instance2.isDeactivated = true;
1118
+ }, parentSuspense);
1119
+ };
1120
+ function unmount(vnode) {
1121
+ resetShapeFlag(vnode);
1122
+ _unmount(vnode, instance, parentSuspense, true);
1369
1123
  }
1370
- return nextNode;
1371
- };
1372
- function _getValidZova(instance) {
1373
- while (instance) {
1374
- if (instance.zova) return instance.zova;
1375
- instance = instance.parent;
1124
+ function pruneCache(filter) {
1125
+ cache.forEach((vnode, key) => {
1126
+ const name = vnode.key;
1127
+ if (name && !filter(name)) {
1128
+ pruneCacheEntry(key);
1129
+ }
1130
+ });
1376
1131
  }
1377
- }
1378
- const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1379
- optimized = optimized || !!vnode.dynamicChildren;
1380
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
1381
- const forcePatch = type === "input" || type === "option";
1382
- if (forcePatch || patchFlag !== -1) {
1383
- if (dirs) {
1384
- invokeDirectiveHook(vnode, null, parentComponent, "created");
1132
+ function pruneCacheEntry(key) {
1133
+ const cached = cache.get(key);
1134
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
1135
+ unmount(cached);
1136
+ } else if (current) {
1137
+ resetShapeFlag(current);
1385
1138
  }
1386
- let needCallTransitionHooks = false;
1387
- if (isTemplateNode(el)) {
1388
- needCallTransitionHooks = needTransition(
1389
- null,
1390
- // no need check parentSuspense in hydration
1391
- transition
1392
- ) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
1393
- const content = el.content.firstChild;
1394
- if (needCallTransitionHooks) {
1395
- transition.beforeEnter(content);
1139
+ cache.delete(key);
1140
+ keys.delete(key);
1141
+ }
1142
+ watch(
1143
+ () => [props.include, props.exclude],
1144
+ ([include, exclude]) => {
1145
+ include && pruneCache((name) => matches(include, name));
1146
+ exclude && pruneCache((name) => !matches(exclude, name));
1147
+ },
1148
+ // prune post-render after `current` has been updated
1149
+ { flush: "post", deep: true }
1150
+ );
1151
+ let pendingCacheKey = null;
1152
+ const cacheSubtree = () => {
1153
+ if (pendingCacheKey != null) {
1154
+ if (isSuspense(instance.subTree.type)) {
1155
+ queuePostRenderEffect(() => {
1156
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1157
+ }, instance.subTree.suspense);
1158
+ } else {
1159
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1396
1160
  }
1397
- replaceNode(content, el, parentComponent);
1398
- vnode.el = el = content;
1399
1161
  }
1400
- if (shapeFlag & 16 && // skip if element has innerHTML / textContent
1401
- !(props && (props.innerHTML || props.textContent))) {
1402
- let next = hydrateChildren(
1403
- el.firstChild,
1404
- vnode,
1405
- el,
1406
- parentComponent,
1407
- parentSuspense,
1408
- slotScopeIds,
1409
- optimized
1410
- );
1411
- while (next) {
1412
- if (!isMismatchAllowed(el, 1 /* CHILDREN */)) {
1413
- logMismatchError();
1414
- }
1415
- const cur = next;
1416
- next = next.nextSibling;
1417
- remove(cur);
1418
- }
1419
- } else if (shapeFlag & 8) {
1420
- let clientText = vnode.children;
1421
- if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
1422
- clientText = clientText.slice(1);
1423
- }
1424
- if (el.textContent !== clientText) {
1425
- if (!isMismatchAllowed(el, 0 /* TEXT */)) {
1426
- logMismatchError();
1427
- }
1428
- el.textContent = vnode.children;
1162
+ };
1163
+ onMounted(cacheSubtree);
1164
+ onUpdated(cacheSubtree);
1165
+ onBeforeUnmount(() => {
1166
+ cache.forEach((cached) => {
1167
+ const { subTree, suspense } = instance;
1168
+ const vnode = getInnerChild(subTree);
1169
+ if (cached.type === vnode.type && cached.key === vnode.key) {
1170
+ resetShapeFlag(vnode);
1171
+ const da = vnode.component.da;
1172
+ da && queuePostRenderEffect(da, suspense);
1173
+ return;
1429
1174
  }
1175
+ unmount(cached);
1176
+ });
1177
+ });
1178
+ return () => {
1179
+ pendingCacheKey = null;
1180
+ if (!slots.default) {
1181
+ return current = null;
1430
1182
  }
1431
- if (props) {
1432
- if (forcePatch || !optimized || patchFlag & (16 | 32)) {
1433
- const isCustomElement = el.tagName.includes("-");
1434
- for (const key in props) {
1435
- let clientValue = props[key];
1436
- const zova = _getValidZova(parentComponent);
1437
- if (zova) {
1438
- const res = zova.meta.$ssr._hydratePropHasMismatch(
1439
- el,
1440
- key,
1441
- clientValue,
1442
- vnode,
1443
- parentComponent
1444
- );
1445
- if (res.ignore) ; else {
1446
- clientValue = res.clientValue;
1447
- }
1448
- }
1449
- if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
1450
- key[0] === "." || isCustomElement) {
1451
- patchProp(el, key, null, props[key], void 0, parentComponent);
1452
- }
1453
- }
1454
- } else if (props.onClick) {
1455
- patchProp(
1456
- el,
1457
- "onClick",
1458
- null,
1459
- props.onClick,
1460
- void 0,
1461
- parentComponent
1462
- );
1463
- } else if (patchFlag & 4 && reactivity.isReactive(props.style)) {
1464
- for (const key in props.style) props.style[key];
1465
- }
1183
+ const children = slots.default();
1184
+ const rawVNode = children[0];
1185
+ if (children.length > 1) {
1186
+ current = null;
1187
+ return children;
1188
+ } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
1189
+ current = null;
1190
+ return rawVNode;
1466
1191
  }
1467
- let vnodeHooks;
1468
- if (vnodeHooks = props && props.onVnodeBeforeMount) {
1469
- invokeVNodeHook(vnodeHooks, parentComponent, vnode);
1192
+ let vnode = getInnerChild(rawVNode);
1193
+ if (vnode.type === Comment) {
1194
+ current = null;
1195
+ return vnode;
1470
1196
  }
1471
- if (dirs) {
1472
- invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
1197
+ const comp = vnode.type;
1198
+ const name = vnode.key;
1199
+ const { include, exclude, max } = props;
1200
+ if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
1201
+ vnode.shapeFlag &= ~256;
1202
+ current = vnode;
1203
+ return rawVNode;
1473
1204
  }
1474
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
1475
- queueEffectWithSuspense(() => {
1476
- vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
1477
- needCallTransitionHooks && transition.enter(el);
1478
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
1479
- }, parentSuspense);
1205
+ const key = vnode.key == null ? comp : vnode.key;
1206
+ const cachedVNode = cache.get(key);
1207
+ if (vnode.el) {
1208
+ vnode = cloneVNode(vnode);
1209
+ if (rawVNode.shapeFlag & 128) {
1210
+ rawVNode.ssContent = vnode;
1211
+ }
1480
1212
  }
1481
- }
1482
- return el.nextSibling;
1483
- };
1484
- const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1485
- optimized = optimized || !!parentVNode.dynamicChildren;
1486
- const children = parentVNode.children;
1487
- const l = children.length;
1488
- for (let i = 0; i < l; i++) {
1489
- const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
1490
- const isText = vnode.type === Text;
1491
- if (node) {
1492
- if (isText && !optimized) {
1493
- if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
1494
- insert(
1495
- createText(
1496
- node.data.slice(vnode.children.length)
1497
- ),
1498
- container,
1499
- nextSibling(node)
1500
- );
1501
- node.data = vnode.children;
1502
- }
1213
+ pendingCacheKey = key;
1214
+ if (cachedVNode) {
1215
+ vnode.el = cachedVNode.el;
1216
+ vnode.component = cachedVNode.component;
1217
+ vnode.component.zovaHostProviders = vnode.zovaHostProviders;
1218
+ if (vnode.transition) {
1219
+ setTransitionHooks(vnode, vnode.transition);
1503
1220
  }
1504
- node = hydrateNode(
1505
- node,
1506
- vnode,
1507
- parentComponent,
1508
- parentSuspense,
1509
- slotScopeIds,
1510
- optimized
1511
- );
1512
- } else if (isText && !vnode.children) {
1513
- insert(vnode.el = createText(""), container);
1221
+ vnode.shapeFlag |= 512;
1222
+ keys.delete(key);
1223
+ keys.add(key);
1514
1224
  } else {
1515
- if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
1516
- logMismatchError();
1225
+ keys.add(key);
1226
+ if (max && keys.size > parseInt(max, 10)) {
1227
+ pruneCacheEntry(keys.values().next().value);
1517
1228
  }
1518
- patch(
1519
- null,
1520
- vnode,
1521
- container,
1522
- null,
1523
- parentComponent,
1524
- parentSuspense,
1525
- getContainerType(container),
1526
- slotScopeIds
1527
- );
1528
1229
  }
1230
+ vnode.shapeFlag |= 256;
1231
+ current = vnode;
1232
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
1233
+ };
1234
+ }
1235
+ };
1236
+ const KeepAlive = KeepAliveImpl;
1237
+ function matches(pattern, name) {
1238
+ if (shared.isArray(pattern)) {
1239
+ return pattern.some((p) => matches(p, name));
1240
+ } else if (shared.isString(pattern)) {
1241
+ return pattern.split(",").includes(name);
1242
+ } else if (shared.isRegExp(pattern)) {
1243
+ pattern.lastIndex = 0;
1244
+ return pattern.test(name);
1245
+ }
1246
+ return false;
1247
+ }
1248
+ function onActivated(hook, target) {
1249
+ registerKeepAliveHook(hook, "a", target);
1250
+ }
1251
+ function onDeactivated(hook, target) {
1252
+ registerKeepAliveHook(hook, "da", target);
1253
+ }
1254
+ function registerKeepAliveHook(hook, type, target = currentInstance) {
1255
+ const wrappedHook = hook.__wdc || (hook.__wdc = () => {
1256
+ let current = target;
1257
+ while (current) {
1258
+ if (current.isDeactivated) {
1259
+ return;
1260
+ }
1261
+ current = current.parent;
1529
1262
  }
1530
- return node;
1531
- };
1532
- const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1533
- const { slotScopeIds: fragmentSlotScopeIds } = vnode;
1534
- if (fragmentSlotScopeIds) {
1535
- slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
1263
+ return hook();
1264
+ });
1265
+ injectHook(type, wrappedHook, target);
1266
+ if (target) {
1267
+ let current = target.parent;
1268
+ while (current && current.parent) {
1269
+ if (isKeepAlive(current.parent.vnode)) {
1270
+ injectToKeepAliveRoot(wrappedHook, type, target, current);
1271
+ }
1272
+ current = current.parent;
1536
1273
  }
1537
- const container = parentNode(node);
1538
- const next = hydrateChildren(
1539
- nextSibling(node),
1540
- vnode,
1541
- container,
1542
- parentComponent,
1543
- parentSuspense,
1544
- slotScopeIds,
1545
- optimized
1546
- );
1547
- if (next && isComment(next) && next.data === "]") {
1548
- return nextSibling(vnode.anchor = next);
1274
+ }
1275
+ }
1276
+ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
1277
+ const injected = injectHook(
1278
+ type,
1279
+ hook,
1280
+ keepAliveRoot,
1281
+ true
1282
+ /* prepend */
1283
+ );
1284
+ onUnmounted(() => {
1285
+ shared.remove(keepAliveRoot[type], injected);
1286
+ }, target);
1287
+ }
1288
+ function resetShapeFlag(vnode) {
1289
+ vnode.shapeFlag &= ~256;
1290
+ vnode.shapeFlag &= ~512;
1291
+ }
1292
+ function getInnerChild(vnode) {
1293
+ return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
1294
+ }
1295
+
1296
+ function injectHook(type, hook, target = currentInstance, prepend = false) {
1297
+ if (target) {
1298
+ const hooks = target[type] || (target[type] = []);
1299
+ const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
1300
+ reactivity.pauseTracking();
1301
+ const reset = setCurrentInstance(target);
1302
+ const res = callWithAsyncErrorHandling(hook, target, type, args);
1303
+ reset();
1304
+ reactivity.resetTracking();
1305
+ return res;
1306
+ });
1307
+ if (prepend) {
1308
+ hooks.unshift(wrappedHook);
1549
1309
  } else {
1550
- logMismatchError();
1551
- insert(vnode.anchor = createComment(`]`), container, next);
1552
- return next;
1553
- }
1554
- };
1555
- const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
1556
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
1557
- logMismatchError();
1558
- }
1559
- vnode.el = null;
1560
- if (isFragment) {
1561
- const end = locateClosingAnchor(node);
1562
- while (true) {
1563
- const next2 = nextSibling(node);
1564
- if (next2 && next2 !== end) {
1565
- remove(next2);
1566
- } else {
1567
- break;
1568
- }
1569
- }
1310
+ hooks.push(wrappedHook);
1570
1311
  }
1571
- const next = nextSibling(node);
1572
- const container = parentNode(node);
1573
- remove(node);
1574
- patch(
1575
- null,
1576
- vnode,
1577
- container,
1578
- next,
1579
- parentComponent,
1580
- parentSuspense,
1581
- getContainerType(container),
1582
- slotScopeIds
1312
+ return wrappedHook;
1313
+ }
1314
+ }
1315
+ const createHook = (lifecycle) => (hook, target = currentInstance) => {
1316
+ if (!isInSSRComponentSetup || lifecycle === "sp") {
1317
+ injectHook(lifecycle, (...args) => hook(...args), target);
1318
+ }
1319
+ if (lifecycle === "m" && target && target.isMounted) {
1320
+ hook();
1321
+ }
1322
+ };
1323
+ const onBeforeMount = createHook("bm");
1324
+ const onMounted = createHook("m");
1325
+ const onBeforeUpdate = createHook(
1326
+ "bu"
1327
+ );
1328
+ const onUpdated = createHook("u");
1329
+ const onBeforeUnmount = createHook(
1330
+ "bum"
1331
+ );
1332
+ const onUnmounted = createHook("um");
1333
+ const onServerPrefetch = createHook(
1334
+ "sp"
1335
+ );
1336
+ const onRenderTriggered = createHook("rtg");
1337
+ const onRenderTracked = createHook("rtc");
1338
+ function onErrorCaptured(hook, target = currentInstance) {
1339
+ injectHook("ec", hook, target);
1340
+ }
1341
+
1342
+ const COMPONENTS = "components";
1343
+ const DIRECTIVES = "directives";
1344
+ function resolveComponent(name, maybeSelfReference) {
1345
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
1346
+ }
1347
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
1348
+ function resolveDynamicComponent(component) {
1349
+ if (shared.isString(component)) {
1350
+ return resolveAsset(COMPONENTS, component, false) || component;
1351
+ } else {
1352
+ return component || NULL_DYNAMIC_COMPONENT;
1353
+ }
1354
+ }
1355
+ function resolveDirective(name) {
1356
+ return resolveAsset(DIRECTIVES, name);
1357
+ }
1358
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
1359
+ const instance = currentRenderingInstance || currentInstance;
1360
+ if (instance) {
1361
+ const Component = instance.type;
1362
+ if (type === COMPONENTS) {
1363
+ const selfName = getComponentName(
1364
+ Component,
1365
+ false
1366
+ );
1367
+ if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
1368
+ return Component;
1369
+ }
1370
+ }
1371
+ const res = (
1372
+ // local registration
1373
+ // check instance[type] first which is resolved for options API
1374
+ resolve(instance[type] || Component[type], name) || // global registration
1375
+ resolve(instance.appContext[type], name)
1583
1376
  );
1584
- if (parentComponent) {
1585
- parentComponent.vnode.el = vnode.el;
1586
- updateHOCHostEl(parentComponent, vnode.el);
1377
+ if (!res && maybeSelfReference) {
1378
+ return Component;
1587
1379
  }
1588
- return next;
1589
- };
1590
- const locateClosingAnchor = (node, open = "[", close = "]") => {
1591
- let match = 0;
1592
- while (node) {
1593
- node = nextSibling(node);
1594
- if (node && isComment(node)) {
1595
- if (node.data === open) match++;
1596
- if (node.data === close) {
1597
- if (match === 0) {
1598
- return nextSibling(node);
1599
- } else {
1600
- match--;
1601
- }
1602
- }
1603
- }
1380
+ return res;
1381
+ }
1382
+ }
1383
+ function resolve(registry, name) {
1384
+ return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
1385
+ }
1386
+
1387
+ function renderList(source, renderItem, cache, index) {
1388
+ let ret;
1389
+ const cached = cache && cache[index];
1390
+ const sourceIsArray = shared.isArray(source);
1391
+ if (sourceIsArray || shared.isString(source)) {
1392
+ const sourceIsReactiveArray = sourceIsArray && reactivity.isReactive(source);
1393
+ let needsWrap = false;
1394
+ if (sourceIsReactiveArray) {
1395
+ needsWrap = !reactivity.isShallow(source);
1396
+ source = reactivity.shallowReadArray(source);
1604
1397
  }
1605
- return node;
1606
- };
1607
- const replaceNode = (newNode, oldNode, parentComponent) => {
1608
- const parentNode2 = oldNode.parentNode;
1609
- if (parentNode2) {
1610
- parentNode2.replaceChild(newNode, oldNode);
1398
+ ret = new Array(source.length);
1399
+ for (let i = 0, l = source.length; i < l; i++) {
1400
+ ret[i] = renderItem(
1401
+ needsWrap ? reactivity.toReactive(source[i]) : source[i],
1402
+ i,
1403
+ void 0,
1404
+ cached && cached[i]
1405
+ );
1611
1406
  }
1612
- let parent = parentComponent;
1613
- while (parent) {
1614
- if (parent.vnode.el === oldNode) {
1615
- parent.vnode.el = parent.subTree.el = newNode;
1616
- }
1617
- parent = parent.parent;
1407
+ } else if (typeof source === "number") {
1408
+ ret = new Array(source);
1409
+ for (let i = 0; i < source; i++) {
1410
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
1618
1411
  }
1619
- };
1620
- const isTemplateNode = (node) => {
1621
- return node.nodeType === 1 && node.tagName === "TEMPLATE";
1622
- };
1623
- return [hydrate, hydrateNode];
1624
- }
1625
- const allowMismatchAttr = "data-allow-mismatch";
1626
- const MismatchTypeString = {
1627
- [0 /* TEXT */]: "text",
1628
- [1 /* CHILDREN */]: "children",
1629
- [2 /* CLASS */]: "class",
1630
- [3 /* STYLE */]: "style",
1631
- [4 /* ATTRIBUTE */]: "attribute"
1632
- };
1633
- function isMismatchAllowed(el, allowedType) {
1634
- if (allowedType === 0 /* TEXT */ || allowedType === 1 /* CHILDREN */) {
1635
- while (el && !el.hasAttribute(allowMismatchAttr)) {
1636
- el = el.parentElement;
1412
+ } else if (shared.isObject(source)) {
1413
+ if (source[Symbol.iterator]) {
1414
+ ret = Array.from(
1415
+ source,
1416
+ (item, i) => renderItem(item, i, void 0, cached && cached[i])
1417
+ );
1418
+ } else {
1419
+ const keys = Object.keys(source);
1420
+ ret = new Array(keys.length);
1421
+ for (let i = 0, l = keys.length; i < l; i++) {
1422
+ const key = keys[i];
1423
+ ret[i] = renderItem(source[key], key, i, cached && cached[i]);
1424
+ }
1637
1425
  }
1638
- }
1639
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
1640
- if (allowedAttr == null) {
1641
- return false;
1642
- } else if (allowedAttr === "") {
1643
- return true;
1644
1426
  } else {
1645
- const list = allowedAttr.split(",");
1646
- if (allowedType === 0 /* TEXT */ && list.includes("children")) {
1647
- return true;
1427
+ ret = [];
1428
+ }
1429
+ if (cache) {
1430
+ cache[index] = ret;
1431
+ }
1432
+ return ret;
1433
+ }
1434
+
1435
+ function createSlots(slots, dynamicSlots) {
1436
+ for (let i = 0; i < dynamicSlots.length; i++) {
1437
+ const slot = dynamicSlots[i];
1438
+ if (shared.isArray(slot)) {
1439
+ for (let j = 0; j < slot.length; j++) {
1440
+ slots[slot[j].name] = slot[j].fn;
1441
+ }
1442
+ } else if (slot) {
1443
+ slots[slot.name] = slot.key ? (...args) => {
1444
+ const res = slot.fn(...args);
1445
+ if (res) res.key = slot.key;
1446
+ return res;
1447
+ } : slot.fn;
1648
1448
  }
1649
- return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
1650
1449
  }
1450
+ return slots;
1651
1451
  }
1652
1452
 
1653
- const requestIdleCallback = shared.getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
1654
- const cancelIdleCallback = shared.getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
1655
- const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
1656
- const id = requestIdleCallback(hydrate, { timeout });
1657
- return () => cancelIdleCallback(id);
1658
- };
1659
- function elementIsVisibleInViewport(el) {
1660
- const { top, left, bottom, right } = el.getBoundingClientRect();
1661
- const { innerHeight, innerWidth } = window;
1662
- return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
1453
+ /*! #__NO_SIDE_EFFECTS__ */
1454
+ // @__NO_SIDE_EFFECTS__
1455
+ function defineComponent(options, extraOptions) {
1456
+ return shared.isFunction(options) ? (
1457
+ // #8236: extend call and options.name access are considered side-effects
1458
+ // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1459
+ /* @__PURE__ */ (() => shared.extend({ name: options.name }, extraOptions, { setup: options }))()
1460
+ ) : options;
1663
1461
  }
1664
- const hydrateOnVisible = (opts) => (hydrate, forEach) => {
1665
- const ob = new IntersectionObserver((entries) => {
1666
- for (const e of entries) {
1667
- if (!e.isIntersecting) continue;
1668
- ob.disconnect();
1669
- hydrate();
1670
- break;
1671
- }
1672
- }, opts);
1673
- forEach((el) => {
1674
- if (!(el instanceof Element)) return;
1675
- if (elementIsVisibleInViewport(el)) {
1676
- hydrate();
1677
- ob.disconnect();
1678
- return false;
1679
- }
1680
- ob.observe(el);
1681
- });
1682
- return () => ob.disconnect();
1683
- };
1684
- const hydrateOnMediaQuery = (query) => (hydrate) => {
1685
- if (query) {
1686
- const mql = matchMedia(query);
1687
- if (mql.matches) {
1688
- hydrate();
1689
- } else {
1690
- mql.addEventListener("change", hydrate, { once: true });
1691
- return () => mql.removeEventListener("change", hydrate);
1462
+
1463
+ function useId() {
1464
+ const i = getCurrentInstance();
1465
+ if (i) {
1466
+ return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++;
1467
+ }
1468
+ return "";
1469
+ }
1470
+ function markAsyncBoundary(instance) {
1471
+ instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
1472
+ }
1473
+
1474
+ function useTemplateRef(key) {
1475
+ const i = getCurrentInstance();
1476
+ const r = reactivity.shallowRef(null);
1477
+ if (i) {
1478
+ const refs = i.refs === shared.EMPTY_OBJ ? i.refs = {} : i.refs;
1479
+ {
1480
+ Object.defineProperty(refs, key, {
1481
+ enumerable: true,
1482
+ get: () => r.value,
1483
+ set: (val) => r.value = val
1484
+ });
1692
1485
  }
1693
1486
  }
1694
- };
1695
- const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => {
1696
- if (shared.isString(interactions)) interactions = [interactions];
1697
- let hasHydrated = false;
1698
- const doHydrate = (e) => {
1699
- if (!hasHydrated) {
1700
- hasHydrated = true;
1701
- teardown();
1702
- hydrate();
1703
- e.target.dispatchEvent(new e.constructor(e.type, e));
1487
+ const ret = r;
1488
+ return ret;
1489
+ }
1490
+
1491
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
1492
+ if (shared.isArray(rawRef)) {
1493
+ rawRef.forEach(
1494
+ (r, i) => setRef(
1495
+ r,
1496
+ oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
1497
+ parentSuspense,
1498
+ vnode,
1499
+ isUnmount
1500
+ )
1501
+ );
1502
+ return;
1503
+ }
1504
+ if (isAsyncWrapper(vnode) && !isUnmount) {
1505
+ if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
1506
+ setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
1704
1507
  }
1508
+ return;
1509
+ }
1510
+ const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
1511
+ const value = isUnmount ? null : refValue;
1512
+ const { i: owner, r: ref } = rawRef;
1513
+ const oldRef = oldRawRef && oldRawRef.r;
1514
+ const refs = owner.refs === shared.EMPTY_OBJ ? owner.refs = {} : owner.refs;
1515
+ const setupState = owner.setupState;
1516
+ const rawSetupState = reactivity.toRaw(setupState);
1517
+ const canSetSetupRef = setupState === shared.EMPTY_OBJ ? () => false : (key) => {
1518
+ return shared.hasOwn(rawSetupState, key);
1705
1519
  };
1706
- const teardown = () => {
1707
- forEach((el) => {
1708
- for (const i of interactions) {
1709
- el.removeEventListener(i, doHydrate);
1710
- }
1711
- });
1712
- };
1713
- forEach((el) => {
1714
- for (const i of interactions) {
1715
- el.addEventListener(i, doHydrate, { once: true });
1716
- }
1717
- });
1718
- return teardown;
1719
- };
1720
- function forEachElement(node, cb) {
1721
- if (isComment(node) && node.data === "[") {
1722
- let depth = 1;
1723
- let next = node.nextSibling;
1724
- while (next) {
1725
- if (next.nodeType === 1) {
1726
- const result = cb(next);
1727
- if (result === false) {
1728
- break;
1729
- }
1730
- } else if (isComment(next)) {
1731
- if (next.data === "]") {
1732
- if (--depth === 0) break;
1733
- } else if (next.data === "[") {
1734
- depth++;
1735
- }
1520
+ if (oldRef != null && oldRef !== ref) {
1521
+ if (shared.isString(oldRef)) {
1522
+ refs[oldRef] = null;
1523
+ if (canSetSetupRef(oldRef)) {
1524
+ setupState[oldRef] = null;
1736
1525
  }
1737
- next = next.nextSibling;
1526
+ } else if (reactivity.isRef(oldRef)) {
1527
+ oldRef.value = null;
1738
1528
  }
1529
+ }
1530
+ if (shared.isFunction(ref)) {
1531
+ callWithErrorHandling(ref, owner, 12, [value, refs]);
1739
1532
  } else {
1740
- cb(node);
1533
+ const _isString = shared.isString(ref);
1534
+ const _isRef = reactivity.isRef(ref);
1535
+ if (_isString || _isRef) {
1536
+ const doSet = () => {
1537
+ if (rawRef.f) {
1538
+ const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : ref.value;
1539
+ if (isUnmount) {
1540
+ shared.isArray(existing) && shared.remove(existing, refValue);
1541
+ } else {
1542
+ if (!shared.isArray(existing)) {
1543
+ if (_isString) {
1544
+ refs[ref] = [refValue];
1545
+ if (canSetSetupRef(ref)) {
1546
+ setupState[ref] = refs[ref];
1547
+ }
1548
+ } else {
1549
+ ref.value = [refValue];
1550
+ if (rawRef.k) refs[rawRef.k] = ref.value;
1551
+ }
1552
+ } else if (!existing.includes(refValue)) {
1553
+ existing.push(refValue);
1554
+ }
1555
+ }
1556
+ } else if (_isString) {
1557
+ refs[ref] = value;
1558
+ if (canSetSetupRef(ref)) {
1559
+ setupState[ref] = value;
1560
+ }
1561
+ } else if (_isRef) {
1562
+ ref.value = value;
1563
+ if (rawRef.k) refs[rawRef.k] = value;
1564
+ } else ;
1565
+ };
1566
+ if (value) {
1567
+ doSet.id = -1;
1568
+ queuePostRenderEffect(doSet, parentSuspense);
1569
+ } else {
1570
+ doSet();
1571
+ }
1572
+ }
1741
1573
  }
1742
1574
  }
1743
1575
 
1744
- const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
1745
- function _getValidZova(instance) {
1746
- while (instance) {
1747
- if (instance.zova) return instance.zova;
1748
- instance = instance.parent;
1749
- }
1750
- }
1751
- /*! #__NO_SIDE_EFFECTS__ */
1752
- // @__NO_SIDE_EFFECTS__
1753
- function defineAsyncComponent(source) {
1754
- if (shared.isFunction(source)) {
1755
- source = { loader: source };
1576
+ let hasLoggedMismatchError = false;
1577
+ const logMismatchError = () => {
1578
+ if (hasLoggedMismatchError) {
1579
+ return;
1756
1580
  }
1581
+ console.error("Hydration completed but contains mismatches.");
1582
+ hasLoggedMismatchError = true;
1583
+ };
1584
+ const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
1585
+ const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
1586
+ const getContainerType = (container) => {
1587
+ if (container.nodeType !== 1) return void 0;
1588
+ if (isSVGContainer(container)) return "svg";
1589
+ if (isMathMLContainer(container)) return "mathml";
1590
+ return void 0;
1591
+ };
1592
+ const isComment = (node) => node.nodeType === 8;
1593
+ function createHydrationFunctions(rendererInternals) {
1757
1594
  const {
1758
- loader,
1759
- loadingComponent,
1760
- errorComponent,
1761
- delay = 200,
1762
- hydrate: hydrateStrategy,
1763
- timeout,
1764
- // undefined = never times out
1765
- suspensible = true,
1766
- onError: userOnError
1767
- } = source;
1768
- let pendingRequest = null;
1769
- let resolvedComp;
1770
- let retries = 0;
1771
- const retry = () => {
1772
- retries++;
1773
- pendingRequest = null;
1774
- return load();
1775
- };
1776
- const load = () => {
1777
- let thisRequest;
1778
- return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
1779
- err = err instanceof Error ? err : new Error(String(err));
1780
- if (userOnError) {
1781
- return new Promise((resolve, reject) => {
1782
- const userRetry = () => resolve(retry());
1783
- const userFail = () => reject(err);
1784
- userOnError(err, userRetry, userFail, retries + 1);
1785
- });
1786
- } else {
1787
- throw err;
1788
- }
1789
- }).then((comp) => {
1790
- if (thisRequest !== pendingRequest && pendingRequest) {
1791
- return pendingRequest;
1792
- }
1793
- if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
1794
- comp = comp.default;
1795
- }
1796
- resolvedComp = comp;
1797
- return comp;
1798
- }));
1595
+ mt: mountComponent,
1596
+ p: patch,
1597
+ o: {
1598
+ patchProp,
1599
+ createText,
1600
+ nextSibling,
1601
+ parentNode,
1602
+ remove,
1603
+ insert,
1604
+ createComment
1605
+ }
1606
+ } = rendererInternals;
1607
+ const hydrate = (vnode, container) => {
1608
+ if (!container.hasChildNodes()) {
1609
+ patch(null, vnode, container);
1610
+ flushPostFlushCbs();
1611
+ container._vnode = vnode;
1612
+ return;
1613
+ }
1614
+ hydrateNode(container.firstChild, vnode, null, null, null);
1615
+ flushPostFlushCbs();
1616
+ container._vnode = vnode;
1799
1617
  };
1800
- return defineComponent({
1801
- name: "AsyncComponentWrapper",
1802
- __asyncLoader: load,
1803
- __asyncHydrate(el, instance, hydrate) {
1804
- const doHydrate = hydrateStrategy ? () => {
1805
- const teardown = hydrateStrategy(
1806
- hydrate,
1807
- (cb) => forEachElement(el, cb)
1808
- );
1809
- if (teardown) {
1810
- (instance.bum || (instance.bum = [])).push(teardown);
1811
- }
1812
- } : hydrate;
1813
- if (resolvedComp) {
1814
- doHydrate();
1815
- } else {
1816
- const zova = _getValidZova(instance);
1817
- zova.meta.$ssr._hydratingInc();
1818
- load().then(() => {
1819
- !instance.isUnmounted && doHydrate();
1820
- zova.meta.$ssr._hydratingDec();
1821
- });
1822
- }
1823
- },
1824
- get __asyncResolved() {
1825
- return resolvedComp;
1826
- },
1827
- setup() {
1828
- const instance = currentInstance;
1829
- markAsyncBoundary(instance);
1830
- if (resolvedComp) {
1831
- return () => createInnerComp(resolvedComp, instance);
1832
- }
1833
- const onError = (err) => {
1834
- pendingRequest = null;
1835
- handleError(
1836
- err,
1837
- instance,
1838
- 13,
1839
- !errorComponent
1840
- );
1841
- };
1842
- if (suspensible && instance.suspense || isInSSRComponentSetup) {
1843
- return load().then((comp) => {
1844
- return () => createInnerComp(comp, instance);
1845
- }).catch((err) => {
1846
- onError(err);
1847
- return () => errorComponent ? createVNode(errorComponent, {
1848
- error: err
1849
- }) : null;
1850
- });
1851
- }
1852
- const loaded = reactivity.ref(false);
1853
- const error = reactivity.ref();
1854
- const delayed = reactivity.ref(!!delay);
1855
- if (delay) {
1856
- setTimeout(() => {
1857
- delayed.value = false;
1858
- }, delay);
1859
- }
1860
- if (timeout != null) {
1861
- setTimeout(() => {
1862
- if (!loaded.value && !error.value) {
1863
- const err = new Error(
1864
- `Async component timed out after ${timeout}ms.`
1865
- );
1866
- onError(err);
1867
- error.value = err;
1618
+ const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
1619
+ optimized = optimized || !!vnode.dynamicChildren;
1620
+ const isFragmentStart = isComment(node) && node.data === "[";
1621
+ const onMismatch = () => handleMismatch(
1622
+ node,
1623
+ vnode,
1624
+ parentComponent,
1625
+ parentSuspense,
1626
+ slotScopeIds,
1627
+ isFragmentStart
1628
+ );
1629
+ const { type, ref, shapeFlag, patchFlag } = vnode;
1630
+ let domType = node.nodeType;
1631
+ vnode.el = node;
1632
+ if (patchFlag === -2) {
1633
+ optimized = false;
1634
+ vnode.dynamicChildren = null;
1635
+ }
1636
+ let nextNode = null;
1637
+ switch (type) {
1638
+ case Text:
1639
+ if (domType !== 3) {
1640
+ if (vnode.children === "") {
1641
+ insert(vnode.el = createText(""), parentNode(node), node);
1642
+ nextNode = node;
1643
+ } else {
1644
+ nextNode = onMismatch();
1868
1645
  }
1869
- }, timeout);
1870
- }
1871
- load().then(() => {
1872
- loaded.value = true;
1873
- if (instance.parent && isKeepAlive(instance.parent.vnode)) {
1874
- instance.parent.update();
1875
- }
1876
- }).catch((err) => {
1877
- onError(err);
1878
- error.value = err;
1879
- });
1880
- return () => {
1881
- if (loaded.value && resolvedComp) {
1882
- return createInnerComp(resolvedComp, instance);
1883
- } else if (error.value && errorComponent) {
1884
- return createVNode(errorComponent, {
1885
- error: error.value
1886
- });
1887
- } else if (loadingComponent && !delayed.value) {
1888
- return createVNode(loadingComponent);
1646
+ } else {
1647
+ if (node.data !== vnode.children) {
1648
+ node.data = vnode.children;
1649
+ }
1650
+ nextNode = nextSibling(node);
1889
1651
  }
1890
- };
1891
- }
1892
- });
1893
- }
1894
- function createInnerComp(comp, parent) {
1895
- const { ref: ref2, props, children, ce } = parent.vnode;
1896
- const vnode = createVNode(comp, props, children);
1897
- vnode.ref = ref2;
1898
- vnode.ce = ce;
1899
- delete parent.vnode.ce;
1900
- vnode.zovaHostProviders = parent.vnode.zovaHostProviders;
1901
- return vnode;
1902
- }
1903
-
1904
- const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
1905
- const KeepAliveImpl = {
1906
- name: `KeepAlive`,
1907
- // Marker for special handling inside the renderer. We are not using a ===
1908
- // check directly on KeepAlive in the renderer, because importing it directly
1909
- // would prevent it from being tree-shaken.
1910
- __isKeepAlive: true,
1911
- props: {
1912
- include: [String, RegExp, Array],
1913
- exclude: [String, RegExp, Array],
1914
- max: [String, Number]
1915
- },
1916
- setup(props, { slots }) {
1917
- const instance = getCurrentInstance();
1918
- const sharedContext = instance.ctx;
1919
- if (!sharedContext.renderer) {
1920
- return () => {
1921
- const children = slots.default && slots.default();
1922
- return children && children.length === 1 ? children[0] : children;
1923
- };
1924
- }
1925
- const cache = /* @__PURE__ */ new Map();
1926
- const keys = /* @__PURE__ */ new Set();
1927
- let current = null;
1928
- const parentSuspense = instance.suspense;
1929
- const {
1930
- renderer: {
1931
- p: patch,
1932
- m: move,
1933
- um: _unmount,
1934
- o: { createElement }
1935
- }
1936
- } = sharedContext;
1937
- const storageContainer = createElement("div");
1938
- sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
1939
- const instance2 = vnode.component;
1940
- move(vnode, container, anchor, 0, parentSuspense);
1941
- patch(
1942
- instance2.vnode,
1943
- vnode,
1944
- container,
1945
- anchor,
1946
- instance2,
1947
- parentSuspense,
1948
- namespace,
1949
- vnode.slotScopeIds,
1950
- optimized
1951
- );
1952
- queuePostRenderEffect(() => {
1953
- instance2.isDeactivated = false;
1954
- if (instance2.a) {
1955
- shared.invokeArrayFns(instance2.a);
1652
+ break;
1653
+ case Comment:
1654
+ if (isTemplateNode(node)) {
1655
+ nextNode = nextSibling(node);
1656
+ replaceNode(
1657
+ vnode.el = node.content.firstChild,
1658
+ node,
1659
+ parentComponent
1660
+ );
1661
+ } else if (domType !== 8 || isFragmentStart) {
1662
+ nextNode = onMismatch();
1663
+ } else {
1664
+ nextNode = nextSibling(node);
1956
1665
  }
1957
- const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
1958
- if (vnodeHook) {
1959
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1666
+ break;
1667
+ case Static:
1668
+ if (isFragmentStart) {
1669
+ node = nextSibling(node);
1670
+ domType = node.nodeType;
1960
1671
  }
1961
- }, parentSuspense);
1962
- };
1963
- sharedContext.deactivate = (vnode) => {
1964
- const instance2 = vnode.component;
1965
- invalidateMount(instance2.m);
1966
- invalidateMount(instance2.a);
1967
- move(vnode, storageContainer, null, 1, parentSuspense);
1968
- queuePostRenderEffect(() => {
1969
- if (instance2.da) {
1970
- shared.invokeArrayFns(instance2.da);
1672
+ if (domType === 1 || domType === 3) {
1673
+ nextNode = node;
1674
+ const needToAdoptContent = !vnode.children.length;
1675
+ for (let i = 0; i < vnode.staticCount; i++) {
1676
+ if (needToAdoptContent)
1677
+ vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
1678
+ if (i === vnode.staticCount - 1) {
1679
+ vnode.anchor = nextNode;
1680
+ }
1681
+ nextNode = nextSibling(nextNode);
1682
+ }
1683
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
1684
+ } else {
1685
+ onMismatch();
1971
1686
  }
1972
- const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
1973
- if (vnodeHook) {
1974
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1687
+ break;
1688
+ case Fragment:
1689
+ if (!isFragmentStart) {
1690
+ nextNode = onMismatch();
1691
+ } else {
1692
+ nextNode = hydrateFragment(
1693
+ node,
1694
+ vnode,
1695
+ parentComponent,
1696
+ parentSuspense,
1697
+ slotScopeIds,
1698
+ optimized
1699
+ );
1975
1700
  }
1976
- instance2.isDeactivated = true;
1977
- }, parentSuspense);
1978
- };
1979
- function unmount(vnode) {
1980
- resetShapeFlag(vnode);
1981
- _unmount(vnode, instance, parentSuspense, true);
1701
+ break;
1702
+ default:
1703
+ if (shapeFlag & 1) {
1704
+ if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
1705
+ nextNode = onMismatch();
1706
+ } else {
1707
+ nextNode = hydrateElement(
1708
+ node,
1709
+ vnode,
1710
+ parentComponent,
1711
+ parentSuspense,
1712
+ slotScopeIds,
1713
+ optimized
1714
+ );
1715
+ }
1716
+ } else if (shapeFlag & 6) {
1717
+ vnode.slotScopeIds = slotScopeIds;
1718
+ const container = parentNode(node);
1719
+ if (isFragmentStart) {
1720
+ nextNode = locateClosingAnchor(node);
1721
+ } else if (isComment(node) && node.data === "teleport start") {
1722
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
1723
+ } else {
1724
+ nextNode = nextSibling(node);
1725
+ }
1726
+ mountComponent(
1727
+ vnode,
1728
+ container,
1729
+ null,
1730
+ parentComponent,
1731
+ parentSuspense,
1732
+ getContainerType(container),
1733
+ optimized
1734
+ );
1735
+ if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
1736
+ let subTree;
1737
+ if (isFragmentStart) {
1738
+ subTree = createVNode(Fragment);
1739
+ subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
1740
+ } else {
1741
+ subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
1742
+ }
1743
+ subTree.el = node;
1744
+ vnode.component.subTree = subTree;
1745
+ }
1746
+ } else if (shapeFlag & 64) {
1747
+ if (domType !== 8) {
1748
+ nextNode = onMismatch();
1749
+ } else {
1750
+ nextNode = vnode.type.hydrate(
1751
+ node,
1752
+ vnode,
1753
+ parentComponent,
1754
+ parentSuspense,
1755
+ slotScopeIds,
1756
+ optimized,
1757
+ rendererInternals,
1758
+ hydrateChildren
1759
+ );
1760
+ }
1761
+ } else if (shapeFlag & 128) {
1762
+ nextNode = vnode.type.hydrate(
1763
+ node,
1764
+ vnode,
1765
+ parentComponent,
1766
+ parentSuspense,
1767
+ getContainerType(parentNode(node)),
1768
+ slotScopeIds,
1769
+ optimized,
1770
+ rendererInternals,
1771
+ hydrateNode
1772
+ );
1773
+ } else ;
1982
1774
  }
1983
- function pruneCache(filter) {
1984
- cache.forEach((vnode, key) => {
1985
- const name = getComponentName(vnode.type);
1986
- if (name && !filter(name)) {
1987
- pruneCacheEntry(key);
1988
- }
1989
- });
1775
+ if (ref != null) {
1776
+ setRef(ref, null, parentSuspense, vnode);
1990
1777
  }
1991
- function pruneCacheEntry(key) {
1992
- const cached = cache.get(key);
1993
- if (cached && (!current || !isSameVNodeType(cached, current))) {
1994
- unmount(cached);
1995
- } else if (current) {
1996
- resetShapeFlag(current);
1997
- }
1998
- cache.delete(key);
1999
- keys.delete(key);
1778
+ return nextNode;
1779
+ };
1780
+ function _getValidZova(instance) {
1781
+ while (instance) {
1782
+ if (instance.zova) return instance.zova;
1783
+ instance = instance.parent;
2000
1784
  }
2001
- watch(
2002
- () => [props.include, props.exclude],
2003
- ([include, exclude]) => {
2004
- include && pruneCache((name) => matches(include, name));
2005
- exclude && pruneCache((name) => !matches(exclude, name));
2006
- },
2007
- // prune post-render after `current` has been updated
2008
- { flush: "post", deep: true }
2009
- );
2010
- let pendingCacheKey = null;
2011
- const cacheSubtree = () => {
2012
- if (pendingCacheKey != null) {
2013
- if (isSuspense(instance.subTree.type)) {
2014
- queuePostRenderEffect(() => {
2015
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
2016
- }, instance.subTree.suspense);
2017
- } else {
2018
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1785
+ }
1786
+ const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1787
+ optimized = optimized || !!vnode.dynamicChildren;
1788
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
1789
+ const forcePatch = type === "input" || type === "option";
1790
+ if (forcePatch || patchFlag !== -1) {
1791
+ if (dirs) {
1792
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
1793
+ }
1794
+ let needCallTransitionHooks = false;
1795
+ if (isTemplateNode(el)) {
1796
+ needCallTransitionHooks = needTransition(
1797
+ null,
1798
+ // no need check parentSuspense in hydration
1799
+ transition
1800
+ ) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
1801
+ const content = el.content.firstChild;
1802
+ if (needCallTransitionHooks) {
1803
+ transition.beforeEnter(content);
2019
1804
  }
1805
+ replaceNode(content, el, parentComponent);
1806
+ vnode.el = el = content;
2020
1807
  }
2021
- };
2022
- onMounted(cacheSubtree);
2023
- onUpdated(cacheSubtree);
2024
- onBeforeUnmount(() => {
2025
- cache.forEach((cached) => {
2026
- const { subTree, suspense } = instance;
2027
- const vnode = getInnerChild(subTree);
2028
- if (cached.type === vnode.type && cached.key === vnode.key) {
2029
- resetShapeFlag(vnode);
2030
- const da = vnode.component.da;
2031
- da && queuePostRenderEffect(da, suspense);
2032
- return;
1808
+ if (shapeFlag & 16 && // skip if element has innerHTML / textContent
1809
+ !(props && (props.innerHTML || props.textContent))) {
1810
+ let next = hydrateChildren(
1811
+ el.firstChild,
1812
+ vnode,
1813
+ el,
1814
+ parentComponent,
1815
+ parentSuspense,
1816
+ slotScopeIds,
1817
+ optimized
1818
+ );
1819
+ while (next) {
1820
+ if (!isMismatchAllowed(el, 1 /* CHILDREN */)) {
1821
+ logMismatchError();
1822
+ }
1823
+ const cur = next;
1824
+ next = next.nextSibling;
1825
+ remove(cur);
1826
+ }
1827
+ } else if (shapeFlag & 8) {
1828
+ let clientText = vnode.children;
1829
+ if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
1830
+ clientText = clientText.slice(1);
1831
+ }
1832
+ if (el.textContent !== clientText) {
1833
+ if (!isMismatchAllowed(el, 0 /* TEXT */)) {
1834
+ logMismatchError();
1835
+ }
1836
+ el.textContent = vnode.children;
2033
1837
  }
2034
- unmount(cached);
2035
- });
2036
- });
2037
- return () => {
2038
- pendingCacheKey = null;
2039
- if (!slots.default) {
2040
- return current = null;
2041
1838
  }
2042
- const children = slots.default();
2043
- const rawVNode = children[0];
2044
- if (children.length > 1) {
2045
- current = null;
2046
- return children;
2047
- } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
2048
- current = null;
2049
- return rawVNode;
1839
+ if (props) {
1840
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
1841
+ const isCustomElement = el.tagName.includes("-");
1842
+ for (const key in props) {
1843
+ let clientValue = props[key];
1844
+ const zova = _getValidZova(parentComponent);
1845
+ if (zova) {
1846
+ const res = zova.meta.$ssr._hydratePropHasMismatch(
1847
+ el,
1848
+ key,
1849
+ clientValue,
1850
+ vnode,
1851
+ parentComponent
1852
+ );
1853
+ if (res.ignore) ; else {
1854
+ clientValue = res.clientValue;
1855
+ }
1856
+ }
1857
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || shared.isOn(key) && !shared.isReservedProp(key) || // force hydrate v-bind with .prop modifiers
1858
+ key[0] === "." || isCustomElement) {
1859
+ patchProp(el, key, null, props[key], void 0, parentComponent);
1860
+ }
1861
+ }
1862
+ } else if (props.onClick) {
1863
+ patchProp(
1864
+ el,
1865
+ "onClick",
1866
+ null,
1867
+ props.onClick,
1868
+ void 0,
1869
+ parentComponent
1870
+ );
1871
+ } else if (patchFlag & 4 && reactivity.isReactive(props.style)) {
1872
+ for (const key in props.style) props.style[key];
1873
+ }
2050
1874
  }
2051
- let vnode = getInnerChild(rawVNode);
2052
- if (vnode.type === Comment) {
2053
- current = null;
2054
- return vnode;
1875
+ let vnodeHooks;
1876
+ if (vnodeHooks = props && props.onVnodeBeforeMount) {
1877
+ invokeVNodeHook(vnodeHooks, parentComponent, vnode);
2055
1878
  }
2056
- const comp = vnode.type;
2057
- const name = getComponentName(
2058
- isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
2059
- );
2060
- const { include, exclude, max } = props;
2061
- if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
2062
- vnode.shapeFlag &= ~256;
2063
- current = vnode;
2064
- return rawVNode;
1879
+ if (dirs) {
1880
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
2065
1881
  }
2066
- const key = vnode.key == null ? comp : vnode.key;
2067
- const cachedVNode = cache.get(key);
2068
- if (vnode.el) {
2069
- vnode = cloneVNode(vnode);
2070
- if (rawVNode.shapeFlag & 128) {
2071
- rawVNode.ssContent = vnode;
2072
- }
1882
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
1883
+ queueEffectWithSuspense(() => {
1884
+ vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
1885
+ needCallTransitionHooks && transition.enter(el);
1886
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
1887
+ }, parentSuspense);
2073
1888
  }
2074
- pendingCacheKey = key;
2075
- if (cachedVNode) {
2076
- vnode.el = cachedVNode.el;
2077
- vnode.component = cachedVNode.component;
2078
- vnode.component.zovaHostProviders = vnode.zovaHostProviders;
2079
- if (vnode.transition) {
2080
- setTransitionHooks(vnode, vnode.transition);
1889
+ }
1890
+ return el.nextSibling;
1891
+ };
1892
+ const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1893
+ optimized = optimized || !!parentVNode.dynamicChildren;
1894
+ const children = parentVNode.children;
1895
+ const l = children.length;
1896
+ for (let i = 0; i < l; i++) {
1897
+ const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
1898
+ const isText = vnode.type === Text;
1899
+ if (node) {
1900
+ if (isText && !optimized) {
1901
+ if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
1902
+ insert(
1903
+ createText(
1904
+ node.data.slice(vnode.children.length)
1905
+ ),
1906
+ container,
1907
+ nextSibling(node)
1908
+ );
1909
+ node.data = vnode.children;
1910
+ }
2081
1911
  }
2082
- vnode.shapeFlag |= 512;
2083
- keys.delete(key);
2084
- keys.add(key);
1912
+ node = hydrateNode(
1913
+ node,
1914
+ vnode,
1915
+ parentComponent,
1916
+ parentSuspense,
1917
+ slotScopeIds,
1918
+ optimized
1919
+ );
1920
+ } else if (isText && !vnode.children) {
1921
+ insert(vnode.el = createText(""), container);
2085
1922
  } else {
2086
- keys.add(key);
2087
- if (max && keys.size > parseInt(max, 10)) {
2088
- pruneCacheEntry(keys.values().next().value);
1923
+ if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
1924
+ logMismatchError();
1925
+ }
1926
+ patch(
1927
+ null,
1928
+ vnode,
1929
+ container,
1930
+ null,
1931
+ parentComponent,
1932
+ parentSuspense,
1933
+ getContainerType(container),
1934
+ slotScopeIds
1935
+ );
1936
+ }
1937
+ }
1938
+ return node;
1939
+ };
1940
+ const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1941
+ const { slotScopeIds: fragmentSlotScopeIds } = vnode;
1942
+ if (fragmentSlotScopeIds) {
1943
+ slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
1944
+ }
1945
+ const container = parentNode(node);
1946
+ const next = hydrateChildren(
1947
+ nextSibling(node),
1948
+ vnode,
1949
+ container,
1950
+ parentComponent,
1951
+ parentSuspense,
1952
+ slotScopeIds,
1953
+ optimized
1954
+ );
1955
+ if (next && isComment(next) && next.data === "]") {
1956
+ return nextSibling(vnode.anchor = next);
1957
+ } else {
1958
+ logMismatchError();
1959
+ insert(vnode.anchor = createComment(`]`), container, next);
1960
+ return next;
1961
+ }
1962
+ };
1963
+ const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
1964
+ if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
1965
+ logMismatchError();
1966
+ }
1967
+ vnode.el = null;
1968
+ if (isFragment) {
1969
+ const end = locateClosingAnchor(node);
1970
+ while (true) {
1971
+ const next2 = nextSibling(node);
1972
+ if (next2 && next2 !== end) {
1973
+ remove(next2);
1974
+ } else {
1975
+ break;
2089
1976
  }
2090
1977
  }
2091
- vnode.shapeFlag |= 256;
2092
- current = vnode;
2093
- return isSuspense(rawVNode.type) ? rawVNode : vnode;
2094
- };
2095
- }
2096
- };
2097
- const KeepAlive = KeepAliveImpl;
2098
- function matches(pattern, name) {
2099
- if (shared.isArray(pattern)) {
2100
- return pattern.some((p) => matches(p, name));
2101
- } else if (shared.isString(pattern)) {
2102
- return pattern.split(",").includes(name);
2103
- } else if (shared.isRegExp(pattern)) {
2104
- pattern.lastIndex = 0;
2105
- return pattern.test(name);
2106
- }
2107
- return false;
2108
- }
2109
- function onActivated(hook, target) {
2110
- registerKeepAliveHook(hook, "a", target);
2111
- }
2112
- function onDeactivated(hook, target) {
2113
- registerKeepAliveHook(hook, "da", target);
2114
- }
2115
- function registerKeepAliveHook(hook, type, target = currentInstance) {
2116
- const wrappedHook = hook.__wdc || (hook.__wdc = () => {
2117
- let current = target;
2118
- while (current) {
2119
- if (current.isDeactivated) {
2120
- return;
1978
+ }
1979
+ const next = nextSibling(node);
1980
+ const container = parentNode(node);
1981
+ remove(node);
1982
+ patch(
1983
+ null,
1984
+ vnode,
1985
+ container,
1986
+ next,
1987
+ parentComponent,
1988
+ parentSuspense,
1989
+ getContainerType(container),
1990
+ slotScopeIds
1991
+ );
1992
+ if (parentComponent) {
1993
+ parentComponent.vnode.el = vnode.el;
1994
+ updateHOCHostEl(parentComponent, vnode.el);
1995
+ }
1996
+ return next;
1997
+ };
1998
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
1999
+ let match = 0;
2000
+ while (node) {
2001
+ node = nextSibling(node);
2002
+ if (node && isComment(node)) {
2003
+ if (node.data === open) match++;
2004
+ if (node.data === close) {
2005
+ if (match === 0) {
2006
+ return nextSibling(node);
2007
+ } else {
2008
+ match--;
2009
+ }
2010
+ }
2121
2011
  }
2122
- current = current.parent;
2123
2012
  }
2124
- return hook();
2125
- });
2126
- injectHook(type, wrappedHook, target);
2127
- if (target) {
2128
- let current = target.parent;
2129
- while (current && current.parent) {
2130
- if (isKeepAlive(current.parent.vnode)) {
2131
- injectToKeepAliveRoot(wrappedHook, type, target, current);
2013
+ return node;
2014
+ };
2015
+ const replaceNode = (newNode, oldNode, parentComponent) => {
2016
+ const parentNode2 = oldNode.parentNode;
2017
+ if (parentNode2) {
2018
+ parentNode2.replaceChild(newNode, oldNode);
2019
+ }
2020
+ let parent = parentComponent;
2021
+ while (parent) {
2022
+ if (parent.vnode.el === oldNode) {
2023
+ parent.vnode.el = parent.subTree.el = newNode;
2132
2024
  }
2133
- current = current.parent;
2025
+ parent = parent.parent;
2134
2026
  }
2135
- }
2136
- }
2137
- function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
2138
- const injected = injectHook(
2139
- type,
2140
- hook,
2141
- keepAliveRoot,
2142
- true
2143
- /* prepend */
2144
- );
2145
- onUnmounted(() => {
2146
- shared.remove(keepAliveRoot[type], injected);
2147
- }, target);
2148
- }
2149
- function resetShapeFlag(vnode) {
2150
- vnode.shapeFlag &= ~256;
2151
- vnode.shapeFlag &= ~512;
2152
- }
2153
- function getInnerChild(vnode) {
2154
- return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
2027
+ };
2028
+ const isTemplateNode = (node) => {
2029
+ return node.nodeType === 1 && node.tagName === "TEMPLATE";
2030
+ };
2031
+ return [hydrate, hydrateNode];
2155
2032
  }
2156
-
2157
- function injectHook(type, hook, target = currentInstance, prepend = false) {
2158
- if (target) {
2159
- const hooks = target[type] || (target[type] = []);
2160
- const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
2161
- reactivity.pauseTracking();
2162
- const reset = setCurrentInstance(target);
2163
- const res = callWithAsyncErrorHandling(hook, target, type, args);
2164
- reset();
2165
- reactivity.resetTracking();
2166
- return res;
2167
- });
2168
- if (prepend) {
2169
- hooks.unshift(wrappedHook);
2170
- } else {
2171
- hooks.push(wrappedHook);
2033
+ const allowMismatchAttr = "data-allow-mismatch";
2034
+ const MismatchTypeString = {
2035
+ [0 /* TEXT */]: "text",
2036
+ [1 /* CHILDREN */]: "children",
2037
+ [2 /* CLASS */]: "class",
2038
+ [3 /* STYLE */]: "style",
2039
+ [4 /* ATTRIBUTE */]: "attribute"
2040
+ };
2041
+ function isMismatchAllowed(el, allowedType) {
2042
+ if (allowedType === 0 /* TEXT */ || allowedType === 1 /* CHILDREN */) {
2043
+ while (el && !el.hasAttribute(allowMismatchAttr)) {
2044
+ el = el.parentElement;
2172
2045
  }
2173
- return wrappedHook;
2174
2046
  }
2175
- }
2176
- const createHook = (lifecycle) => (hook, target = currentInstance) => {
2177
- if (!isInSSRComponentSetup || lifecycle === "sp") {
2178
- injectHook(lifecycle, (...args) => hook(...args), target);
2179
- }
2180
- if (lifecycle === "m" && target && target.isMounted) {
2181
- hook();
2182
- }
2183
- };
2184
- const onBeforeMount = createHook("bm");
2185
- const onMounted = createHook("m");
2186
- const onBeforeUpdate = createHook(
2187
- "bu"
2188
- );
2189
- const onUpdated = createHook("u");
2190
- const onBeforeUnmount = createHook(
2191
- "bum"
2192
- );
2193
- const onUnmounted = createHook("um");
2194
- const onServerPrefetch = createHook(
2195
- "sp"
2196
- );
2197
- const onRenderTriggered = createHook("rtg");
2198
- const onRenderTracked = createHook("rtc");
2199
- function onErrorCaptured(hook, target = currentInstance) {
2200
- injectHook("ec", hook, target);
2201
- }
2202
-
2203
- const COMPONENTS = "components";
2204
- const DIRECTIVES = "directives";
2205
- function resolveComponent(name, maybeSelfReference) {
2206
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2207
- }
2208
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2209
- function resolveDynamicComponent(component) {
2210
- if (shared.isString(component)) {
2211
- return resolveAsset(COMPONENTS, component, false) || component;
2047
+ const allowedAttr = el && el.getAttribute(allowMismatchAttr);
2048
+ if (allowedAttr == null) {
2049
+ return false;
2050
+ } else if (allowedAttr === "") {
2051
+ return true;
2212
2052
  } else {
2213
- return component || NULL_DYNAMIC_COMPONENT;
2214
- }
2215
- }
2216
- function resolveDirective(name) {
2217
- return resolveAsset(DIRECTIVES, name);
2218
- }
2219
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2220
- const instance = currentRenderingInstance || currentInstance;
2221
- if (instance) {
2222
- const Component = instance.type;
2223
- if (type === COMPONENTS) {
2224
- const selfName = getComponentName(
2225
- Component,
2226
- false
2227
- );
2228
- if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
2229
- return Component;
2230
- }
2231
- }
2232
- const res = (
2233
- // local registration
2234
- // check instance[type] first which is resolved for options API
2235
- resolve(instance[type] || Component[type], name) || // global registration
2236
- resolve(instance.appContext[type], name)
2237
- );
2238
- if (!res && maybeSelfReference) {
2239
- return Component;
2053
+ const list = allowedAttr.split(",");
2054
+ if (allowedType === 0 /* TEXT */ && list.includes("children")) {
2055
+ return true;
2240
2056
  }
2241
- return res;
2057
+ return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
2242
2058
  }
2243
2059
  }
2244
- function resolve(registry, name) {
2245
- return registry && (registry[name] || registry[shared.camelize(name)] || registry[shared.capitalize(shared.camelize(name))]);
2246
- }
2247
2060
 
2248
- function renderList(source, renderItem, cache, index) {
2249
- let ret;
2250
- const cached = cache && cache[index];
2251
- const sourceIsArray = shared.isArray(source);
2252
- if (sourceIsArray || shared.isString(source)) {
2253
- const sourceIsReactiveArray = sourceIsArray && reactivity.isReactive(source);
2254
- let needsWrap = false;
2255
- if (sourceIsReactiveArray) {
2256
- needsWrap = !reactivity.isShallow(source);
2257
- source = reactivity.shallowReadArray(source);
2258
- }
2259
- ret = new Array(source.length);
2260
- for (let i = 0, l = source.length; i < l; i++) {
2261
- ret[i] = renderItem(
2262
- needsWrap ? reactivity.toReactive(source[i]) : source[i],
2263
- i,
2264
- void 0,
2265
- cached && cached[i]
2266
- );
2061
+ const requestIdleCallback = shared.getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
2062
+ const cancelIdleCallback = shared.getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
2063
+ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
2064
+ const id = requestIdleCallback(hydrate, { timeout });
2065
+ return () => cancelIdleCallback(id);
2066
+ };
2067
+ function elementIsVisibleInViewport(el) {
2068
+ const { top, left, bottom, right } = el.getBoundingClientRect();
2069
+ const { innerHeight, innerWidth } = window;
2070
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
2071
+ }
2072
+ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
2073
+ const ob = new IntersectionObserver((entries) => {
2074
+ for (const e of entries) {
2075
+ if (!e.isIntersecting) continue;
2076
+ ob.disconnect();
2077
+ hydrate();
2078
+ break;
2267
2079
  }
2268
- } else if (typeof source === "number") {
2269
- ret = new Array(source);
2270
- for (let i = 0; i < source; i++) {
2271
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
2080
+ }, opts);
2081
+ forEach((el) => {
2082
+ if (!(el instanceof Element)) return;
2083
+ if (elementIsVisibleInViewport(el)) {
2084
+ hydrate();
2085
+ ob.disconnect();
2086
+ return false;
2272
2087
  }
2273
- } else if (shared.isObject(source)) {
2274
- if (source[Symbol.iterator]) {
2275
- ret = Array.from(
2276
- source,
2277
- (item, i) => renderItem(item, i, void 0, cached && cached[i])
2278
- );
2088
+ ob.observe(el);
2089
+ });
2090
+ return () => ob.disconnect();
2091
+ };
2092
+ const hydrateOnMediaQuery = (query) => (hydrate) => {
2093
+ if (query) {
2094
+ const mql = matchMedia(query);
2095
+ if (mql.matches) {
2096
+ hydrate();
2279
2097
  } else {
2280
- const keys = Object.keys(source);
2281
- ret = new Array(keys.length);
2282
- for (let i = 0, l = keys.length; i < l; i++) {
2283
- const key = keys[i];
2284
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
2098
+ mql.addEventListener("change", hydrate, { once: true });
2099
+ return () => mql.removeEventListener("change", hydrate);
2100
+ }
2101
+ }
2102
+ };
2103
+ const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => {
2104
+ if (shared.isString(interactions)) interactions = [interactions];
2105
+ let hasHydrated = false;
2106
+ const doHydrate = (e) => {
2107
+ if (!hasHydrated) {
2108
+ hasHydrated = true;
2109
+ teardown();
2110
+ hydrate();
2111
+ e.target.dispatchEvent(new e.constructor(e.type, e));
2112
+ }
2113
+ };
2114
+ const teardown = () => {
2115
+ forEach((el) => {
2116
+ for (const i of interactions) {
2117
+ el.removeEventListener(i, doHydrate);
2118
+ }
2119
+ });
2120
+ };
2121
+ forEach((el) => {
2122
+ for (const i of interactions) {
2123
+ el.addEventListener(i, doHydrate, { once: true });
2124
+ }
2125
+ });
2126
+ return teardown;
2127
+ };
2128
+ function forEachElement(node, cb) {
2129
+ if (isComment(node) && node.data === "[") {
2130
+ let depth = 1;
2131
+ let next = node.nextSibling;
2132
+ while (next) {
2133
+ if (next.nodeType === 1) {
2134
+ const result = cb(next);
2135
+ if (result === false) {
2136
+ break;
2137
+ }
2138
+ } else if (isComment(next)) {
2139
+ if (next.data === "]") {
2140
+ if (--depth === 0) break;
2141
+ } else if (next.data === "[") {
2142
+ depth++;
2143
+ }
2285
2144
  }
2145
+ next = next.nextSibling;
2286
2146
  }
2287
2147
  } else {
2288
- ret = [];
2289
- }
2290
- if (cache) {
2291
- cache[index] = ret;
2148
+ cb(node);
2292
2149
  }
2293
- return ret;
2294
2150
  }
2295
2151
 
2296
- function createSlots(slots, dynamicSlots) {
2297
- for (let i = 0; i < dynamicSlots.length; i++) {
2298
- const slot = dynamicSlots[i];
2299
- if (shared.isArray(slot)) {
2300
- for (let j = 0; j < slot.length; j++) {
2301
- slots[slot[j].name] = slot[j].fn;
2152
+ const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
2153
+ function _getValidZova(instance) {
2154
+ while (instance) {
2155
+ if (instance.zova) return instance.zova;
2156
+ instance = instance.parent;
2157
+ }
2158
+ }
2159
+ /*! #__NO_SIDE_EFFECTS__ */
2160
+ // @__NO_SIDE_EFFECTS__
2161
+ function defineAsyncComponent(source) {
2162
+ if (shared.isFunction(source)) {
2163
+ source = { loader: source };
2164
+ }
2165
+ const {
2166
+ loader,
2167
+ loadingComponent,
2168
+ errorComponent,
2169
+ delay = 200,
2170
+ hydrate: hydrateStrategy,
2171
+ timeout,
2172
+ // undefined = never times out
2173
+ suspensible = true,
2174
+ onError: userOnError
2175
+ } = source;
2176
+ let pendingRequest = null;
2177
+ let resolvedComp;
2178
+ let retries = 0;
2179
+ const retry = () => {
2180
+ retries++;
2181
+ pendingRequest = null;
2182
+ return load();
2183
+ };
2184
+ const load = () => {
2185
+ let thisRequest;
2186
+ return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
2187
+ err = err instanceof Error ? err : new Error(String(err));
2188
+ if (userOnError) {
2189
+ return new Promise((resolve, reject) => {
2190
+ const userRetry = () => resolve(retry());
2191
+ const userFail = () => reject(err);
2192
+ userOnError(err, userRetry, userFail, retries + 1);
2193
+ });
2194
+ } else {
2195
+ throw err;
2302
2196
  }
2303
- } else if (slot) {
2304
- slots[slot.name] = slot.key ? (...args) => {
2305
- const res = slot.fn(...args);
2306
- if (res) res.key = slot.key;
2307
- return res;
2308
- } : slot.fn;
2197
+ }).then((comp) => {
2198
+ if (thisRequest !== pendingRequest && pendingRequest) {
2199
+ return pendingRequest;
2200
+ }
2201
+ if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
2202
+ comp = comp.default;
2203
+ }
2204
+ resolvedComp = comp;
2205
+ return comp;
2206
+ }));
2207
+ };
2208
+ return defineComponent({
2209
+ name: "AsyncComponentWrapper",
2210
+ __asyncLoader: load,
2211
+ __asyncHydrate(el, instance, hydrate) {
2212
+ const doHydrate = hydrateStrategy ? () => {
2213
+ const teardown = hydrateStrategy(
2214
+ hydrate,
2215
+ (cb) => forEachElement(el, cb)
2216
+ );
2217
+ if (teardown) {
2218
+ (instance.bum || (instance.bum = [])).push(teardown);
2219
+ }
2220
+ } : hydrate;
2221
+ if (resolvedComp) {
2222
+ doHydrate();
2223
+ } else {
2224
+ const zova = _getValidZova(instance);
2225
+ zova.meta.$ssr._hydratingInc();
2226
+ load().then(() => {
2227
+ !instance.isUnmounted && doHydrate();
2228
+ zova.meta.$ssr._hydratingDec();
2229
+ });
2230
+ }
2231
+ },
2232
+ get __asyncResolved() {
2233
+ return resolvedComp;
2234
+ },
2235
+ setup() {
2236
+ const instance = currentInstance;
2237
+ markAsyncBoundary(instance);
2238
+ if (resolvedComp) {
2239
+ return () => createInnerComp(resolvedComp, instance);
2240
+ }
2241
+ const onError = (err) => {
2242
+ pendingRequest = null;
2243
+ handleError(
2244
+ err,
2245
+ instance,
2246
+ 13,
2247
+ !errorComponent
2248
+ );
2249
+ };
2250
+ if (suspensible && instance.suspense || isInSSRComponentSetup) {
2251
+ return load().then((comp) => {
2252
+ return () => createInnerComp(comp, instance);
2253
+ }).catch((err) => {
2254
+ onError(err);
2255
+ return () => errorComponent ? createVNode(errorComponent, {
2256
+ error: err
2257
+ }) : null;
2258
+ });
2259
+ }
2260
+ const loaded = reactivity.ref(false);
2261
+ const error = reactivity.ref();
2262
+ const delayed = reactivity.ref(!!delay);
2263
+ if (delay) {
2264
+ setTimeout(() => {
2265
+ delayed.value = false;
2266
+ }, delay);
2267
+ }
2268
+ if (timeout != null) {
2269
+ setTimeout(() => {
2270
+ if (!loaded.value && !error.value) {
2271
+ const err = new Error(
2272
+ `Async component timed out after ${timeout}ms.`
2273
+ );
2274
+ onError(err);
2275
+ error.value = err;
2276
+ }
2277
+ }, timeout);
2278
+ }
2279
+ load().then(() => {
2280
+ loaded.value = true;
2281
+ if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2282
+ instance.parent.update();
2283
+ }
2284
+ }).catch((err) => {
2285
+ onError(err);
2286
+ error.value = err;
2287
+ });
2288
+ return () => {
2289
+ if (loaded.value && resolvedComp) {
2290
+ return createInnerComp(resolvedComp, instance);
2291
+ } else if (error.value && errorComponent) {
2292
+ return createVNode(errorComponent, {
2293
+ error: error.value
2294
+ });
2295
+ } else if (loadingComponent && !delayed.value) {
2296
+ return createVNode(loadingComponent);
2297
+ }
2298
+ };
2309
2299
  }
2310
- }
2311
- return slots;
2300
+ });
2301
+ }
2302
+ function createInnerComp(comp, parent) {
2303
+ const { ref: ref2, props, children, ce } = parent.vnode;
2304
+ const vnode = createVNode(comp, props, children);
2305
+ vnode.ref = ref2;
2306
+ vnode.ce = ce;
2307
+ delete parent.vnode.ce;
2308
+ vnode.zovaHostProviders = parent.vnode.zovaHostProviders;
2309
+ return vnode;
2312
2310
  }
2313
2311
 
2314
2312
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {