@vue/runtime-vapor 3.6.0-beta.13 → 3.6.0-beta.14
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.
- package/dist/runtime-vapor.d.ts +17 -60
- package/dist/runtime-vapor.esm-bundler.js +703 -605
- package/package.json +4 -4
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/runtime-vapor v3.6.0-beta.
|
|
2
|
+
* @vue/runtime-vapor v3.6.0-beta.14
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
6
|
import { EffectScope, Fragment, NULL_DYNAMIC_COMPONENT, Static, TransitionPropsValidators, VaporSlot, VueElementBase, activate, baseApplyTranslation, baseEmit, baseNormalizePropsOptions, baseResolveTransitionHooks, baseUseCssVars, callPendingCbs, callWithAsyncErrorHandling, callWithErrorHandling, checkTransitionMode, createAppAPI, createAsyncComponentContext, createCanSetSetupRefChecker, createInternalObject, createVNode, currentInstance, currentInstance as currentInstance$1, deactivate, devtoolsComponentAdded, endMeasure, ensureHydrationRenderer, ensureRenderer, ensureValidVNode, ensureVaporSlotFallback, expose, flushOnAppMount, forceReflow, getAttributeMismatch, getComponentName, getFunctionalFallthrough, getInheritedScopeIds, getTransitionRawChildren, handleError, handleMovedChildren, hasCSSTransform, initFeatureFlags, invalidateMount, invokeDirectiveHook, isAsyncWrapper, isEmitListener, isHydrating, isKeepAlive, isMapEqual, isMismatchAllowed, isRef, isSetEqual, isTeleportDeferred, isTeleportDisabled, isTemplateNode, isTemplateRefKey, isVNode, isValidHtmlOrSvgAttribute, knownTemplateRefs, leaveCbKey, markAsyncBoundary, matches, mergeProps, nextUid, normalizeContainer, normalizeRef, normalizeVNode, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onMounted, onScopeDispose, onUpdated, patchStyle, performAsyncHydrate, performTransitionEnter, performTransitionLeave, popWarningContext, pushWarningContext, queueJob, queuePostFlushCb, registerHMR, renderSlot, resetShapeFlag, resolveComponent, resolveDynamicComponent, resolvePropValue, resolveTeleportTarget, resolveTransitionProps, setCurrentInstance, setCurrentRenderingInstance, setDevtoolsHook, setRef, setTransitionHooks, setVarsOnNode, shallowReactive, shallowRef, shouldSetAsProp, shouldSetAsPropForVueCE, shouldUpdateComponent, simpleSetCurrentInstance, startMeasure, toClassSet, toStyleMap, unregisterHMR, unsafeToTrustedHTML, useAsyncComponentState, useTransitionState, vModelCheckboxInit, vModelCheckboxUpdate, vModelGetValue, vModelSelectInit, vModelSetSelected, vModelTextInit, vModelTextUpdate, vShowHidden, vShowOriginalDisplay, validateProps, warn, warnExtraneousAttributes, warnPropMismatch, watch, withAsyncContext as withAsyncContext$1, withCtx, withKeys, withModifiers, xlinkNS } from "@vue/runtime-dom";
|
|
7
7
|
import { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, camelize, canSetValueDirectly, extend, getEscapedCssVarName, getGlobalThis, hasOwn, includeBooleanAttr, invokeArrayFns, isArray, isFunction, isObject, isOn, isPlainObject, isPromise, isReservedProp, isString, looseEqual, normalizeClass, normalizeCssVarValue, normalizeStyle, parseStringStyle, remove as remove$1, stringifyStyle, toDisplayString } from "@vue/shared";
|
|
8
|
-
import { EffectScope as EffectScope$1, ReactiveEffect, computed, effectScope, getCurrentScope, isReactive, isReadonly, isRef as isRef$1, isShallow, markRaw, onEffectCleanup, onScopeDispose as onScopeDispose$1, pauseTracking, proxyRefs, resetTracking, setActiveSub, shallowReadArray, shallowRef as shallowRef$1, toRaw, toReactive, toReadonly, traverse, unref, watch as watch$1 } from "@vue/reactivity";
|
|
8
|
+
import { EffectScope as EffectScope$1, ReactiveEffect, computed, effectScope, getCurrentScope, isReactive, isReadonly, isRef as isRef$1, isShallow, markRaw, onEffectCleanup, onScopeDispose as onScopeDispose$1, pauseTracking, proxyRefs, resetTracking, setActiveSub, shallowReactive as shallowReactive$1, shallowReadArray, shallowRef as shallowRef$1, toRaw, toReactive, toReadonly, traverse, unref, watch as watch$1 } from "@vue/reactivity";
|
|
9
9
|
//#region packages/runtime-vapor/src/insertionState.ts
|
|
10
10
|
let insertionParent;
|
|
11
11
|
let insertionAnchor;
|
|
@@ -482,7 +482,7 @@ var RenderEffect = class extends ReactiveEffect {
|
|
|
482
482
|
this.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
|
|
483
483
|
this.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
|
|
484
484
|
}
|
|
485
|
-
if (
|
|
485
|
+
if (!!(process.env.NODE_ENV !== "production")) (instance.renderEffects || (instance.renderEffects = [])).push(this);
|
|
486
486
|
job.i = instance;
|
|
487
487
|
}
|
|
488
488
|
this.job = job;
|
|
@@ -550,7 +550,10 @@ function resolveFunctionSource(source) {
|
|
|
550
550
|
}
|
|
551
551
|
function snapshotRawProps(rawProps) {
|
|
552
552
|
const snapshot = Object.create(null);
|
|
553
|
-
for (const key in rawProps) if (key !== "$")
|
|
553
|
+
for (const key in rawProps) if (key !== "$") {
|
|
554
|
+
const value = resolveSource(rawProps[key]);
|
|
555
|
+
snapshot[key] = () => value;
|
|
556
|
+
}
|
|
554
557
|
const dynamicSources = rawProps.$;
|
|
555
558
|
if (dynamicSources) {
|
|
556
559
|
const snapshotSources = [];
|
|
@@ -562,7 +565,10 @@ function snapshotRawProps(rawProps) {
|
|
|
562
565
|
for (const key in resolved) value[key] = resolved[key];
|
|
563
566
|
snapshotSources[i] = () => value;
|
|
564
567
|
} else {
|
|
565
|
-
for (const key in source)
|
|
568
|
+
for (const key in source) {
|
|
569
|
+
const resolved = resolveSource(source[key]);
|
|
570
|
+
value[key] = () => resolved;
|
|
571
|
+
}
|
|
566
572
|
snapshotSources[i] = value;
|
|
567
573
|
}
|
|
568
574
|
}
|
|
@@ -1240,22 +1246,77 @@ function setScopeId(block, scopeIds) {
|
|
|
1240
1246
|
if (block instanceof Element) for (const id of scopeIds) block.setAttribute(id, "");
|
|
1241
1247
|
else if (isVaporComponent(block)) setScopeId(block.block, scopeIds);
|
|
1242
1248
|
else if (isArray(block)) for (const b of block) setScopeId(b, scopeIds);
|
|
1243
|
-
else if (isFragment(block))
|
|
1249
|
+
else if (isFragment(block)) {
|
|
1250
|
+
trackScopeIdFragment(block, scopeIds, false);
|
|
1251
|
+
setScopeId(block.nodes, scopeIds);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
const trackedScopeIdFragments = /* @__PURE__ */ new WeakMap();
|
|
1255
|
+
function trackScopeIdFragment(frag, scopeIds, recursive = true) {
|
|
1256
|
+
if (isInteropEnabled && isInteropFragment(frag)) setInteropFragmentScopeIds(frag, scopeIds);
|
|
1257
|
+
else if (trackFragmentScopeIds(frag, scopeIds)) (frag.onBeforeInsert || (frag.onBeforeInsert = [])).push((nodes) => setScopeId(nodes, scopeIds));
|
|
1258
|
+
if (recursive) trackScopeIdsInBlock(frag.nodes, scopeIds);
|
|
1259
|
+
}
|
|
1260
|
+
function trackFragmentScopeIds(frag, scopeIds) {
|
|
1261
|
+
const key = scopeIds.join(" ");
|
|
1262
|
+
let trackedScopeIds = trackedScopeIdFragments.get(frag);
|
|
1263
|
+
if (!trackedScopeIds) {
|
|
1264
|
+
trackedScopeIds = /* @__PURE__ */ new Set();
|
|
1265
|
+
trackedScopeIdFragments.set(frag, trackedScopeIds);
|
|
1266
|
+
} else if (trackedScopeIds.has(key)) return false;
|
|
1267
|
+
trackedScopeIds.add(key);
|
|
1268
|
+
return true;
|
|
1269
|
+
}
|
|
1270
|
+
function setInteropFragmentScopeIds(frag, scopeIds) {
|
|
1271
|
+
const vnode = frag.vnode;
|
|
1272
|
+
if (!vnode) return;
|
|
1273
|
+
const existing = vnode.slotScopeIds;
|
|
1274
|
+
if (!existing) {
|
|
1275
|
+
vnode.slotScopeIds = scopeIds;
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
for (let i = 0; i < scopeIds.length; i++) if (!existing.includes(scopeIds[i])) existing.push(scopeIds[i]);
|
|
1279
|
+
}
|
|
1280
|
+
function trackScopeIdsInBlock(block, scopeIds) {
|
|
1281
|
+
if (isVaporComponent(block)) trackScopeIdsInBlock(block.block, scopeIds);
|
|
1282
|
+
else if (isArray(block)) for (const b of block) trackScopeIdsInBlock(b, scopeIds);
|
|
1283
|
+
else if (isFragment(block)) trackScopeIdFragment(block, scopeIds);
|
|
1284
|
+
}
|
|
1285
|
+
const trackedInheritedScopeIdFragments = /* @__PURE__ */ new WeakMap();
|
|
1286
|
+
function trackInheritedScopeIdFragment(instance, frag) {
|
|
1287
|
+
let trackedInstances = trackedInheritedScopeIdFragments.get(frag);
|
|
1288
|
+
if (!trackedInstances) {
|
|
1289
|
+
trackedInstances = /* @__PURE__ */ new WeakSet();
|
|
1290
|
+
trackedInheritedScopeIdFragments.set(frag, trackedInstances);
|
|
1291
|
+
} else if (trackedInstances.has(instance)) return;
|
|
1292
|
+
trackedInstances.add(instance);
|
|
1293
|
+
(frag.onUpdated || (frag.onUpdated = [])).push(() => applyInheritedScopeIdToRoot(instance));
|
|
1294
|
+
}
|
|
1295
|
+
function applyInheritedScopeIdToRoot(instance) {
|
|
1296
|
+
const { scopeId } = instance;
|
|
1297
|
+
if (!scopeId) return;
|
|
1298
|
+
const root = getRootElement(instance, (frag) => trackInheritedScopeIdFragment(instance, frag));
|
|
1299
|
+
if (root) root.setAttribute(scopeId, "");
|
|
1300
|
+
return root;
|
|
1301
|
+
}
|
|
1302
|
+
function trackComponentScopeId(instance) {
|
|
1303
|
+
const { parent, scopeId } = instance;
|
|
1304
|
+
if (!parent || !scopeId) return;
|
|
1305
|
+
getRootElement(instance, (frag) => trackInheritedScopeIdFragment(instance, frag));
|
|
1244
1306
|
}
|
|
1245
1307
|
function setComponentScopeId(instance) {
|
|
1246
1308
|
const { parent, scopeId } = instance;
|
|
1247
1309
|
if (!parent || !scopeId) return;
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
if (parentScopeId !== scopeId) scopeIds.push(scopeId);
|
|
1252
|
-
else if (parentScopeId) scopeIds.push(parentScopeId);
|
|
1253
|
-
if (isInteropEnabled && parent.subTree && parent.subTree.component === instance && parent.vnode.scopeId) {
|
|
1254
|
-
scopeIds.push(parent.vnode.scopeId);
|
|
1310
|
+
const root = applyInheritedScopeIdToRoot(instance);
|
|
1311
|
+
if (isInteropEnabled && root && parent.subTree && parent.subTree.component === instance && parent.vnode.scopeId) {
|
|
1312
|
+
root.setAttribute(parent.vnode.scopeId, "");
|
|
1255
1313
|
const inheritedScopeIds = getInheritedScopeIds(parent.vnode, parent.parent);
|
|
1256
|
-
|
|
1314
|
+
for (let i = 0; i < inheritedScopeIds.length; i++) root.setAttribute(inheritedScopeIds[i], "");
|
|
1257
1315
|
}
|
|
1258
|
-
|
|
1316
|
+
}
|
|
1317
|
+
function getCurrentScopeId() {
|
|
1318
|
+
const scopeOwner = getScopeOwner();
|
|
1319
|
+
return scopeOwner ? scopeOwner.type.__scopeId : void 0;
|
|
1259
1320
|
}
|
|
1260
1321
|
//#endregion
|
|
1261
1322
|
//#region packages/runtime-vapor/src/componentSlots.ts
|
|
@@ -1284,6 +1345,36 @@ function setCurrentSlotScopeIds(scopeIds) {
|
|
|
1284
1345
|
currentSlotScopeIds = scopeIds;
|
|
1285
1346
|
}
|
|
1286
1347
|
}
|
|
1348
|
+
const rawSlotsOwnerMap = /* @__PURE__ */ new WeakMap();
|
|
1349
|
+
const rawSlotWrappersCache = /* @__PURE__ */ new WeakMap();
|
|
1350
|
+
function normalizeRawSlots(rawSlots) {
|
|
1351
|
+
if (!rawSlots) return rawSlots;
|
|
1352
|
+
const normalized = isFunction(rawSlots) ? { default: rawSlots } : rawSlots;
|
|
1353
|
+
if (!rawSlotsOwnerMap.has(normalized)) rawSlotsOwnerMap.set(normalized, getScopeOwner());
|
|
1354
|
+
return normalized;
|
|
1355
|
+
}
|
|
1356
|
+
function withSlotOwner(slots, fn) {
|
|
1357
|
+
if (!rawSlotsOwnerMap.has(slots)) return fn();
|
|
1358
|
+
const prevOwner = setCurrentSlotOwner(rawSlotsOwnerMap.get(slots) || null);
|
|
1359
|
+
try {
|
|
1360
|
+
return fn();
|
|
1361
|
+
} finally {
|
|
1362
|
+
setCurrentSlotOwner(prevOwner);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
function getOwnedSlot(slots, key, slot) {
|
|
1366
|
+
if (!rawSlotsOwnerMap.has(slots)) return slot;
|
|
1367
|
+
let wrappers = rawSlotWrappersCache.get(slots);
|
|
1368
|
+
if (!wrappers) rawSlotWrappersCache.set(slots, wrappers = /* @__PURE__ */ new Map());
|
|
1369
|
+
const cached = wrappers.get(key);
|
|
1370
|
+
if (cached && cached.slot === slot) return cached.wrapped;
|
|
1371
|
+
const wrapped = ((...args) => withSlotOwner(slots, () => slot(...args)));
|
|
1372
|
+
wrappers.set(key, {
|
|
1373
|
+
slot,
|
|
1374
|
+
wrapped
|
|
1375
|
+
});
|
|
1376
|
+
return wrapped;
|
|
1377
|
+
}
|
|
1287
1378
|
const dynamicSlotsProxyHandlers = {
|
|
1288
1379
|
get: getSlot,
|
|
1289
1380
|
has: (target, key) => !!getSlot(target, key),
|
|
@@ -1296,17 +1387,14 @@ const dynamicSlotsProxyHandlers = {
|
|
|
1296
1387
|
};
|
|
1297
1388
|
},
|
|
1298
1389
|
ownKeys(target) {
|
|
1299
|
-
|
|
1390
|
+
const keys = new Set(Object.keys(target).filter((k) => k !== "$"));
|
|
1300
1391
|
const dynamicSources = target.$;
|
|
1301
|
-
if (dynamicSources) {
|
|
1302
|
-
|
|
1303
|
-
for (const
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
} else keys.push(...Object.keys(source));
|
|
1308
|
-
}
|
|
1309
|
-
return keys;
|
|
1392
|
+
if (dynamicSources) for (const source of dynamicSources) if (isFunction(source)) {
|
|
1393
|
+
const slot = withSlotOwner(target, () => resolveFunctionSource(source));
|
|
1394
|
+
if (slot) if (isArray(slot)) for (const s of slot) keys.add(String(s.name));
|
|
1395
|
+
else keys.add(String(slot.name));
|
|
1396
|
+
} else for (const key of Object.keys(source)) keys.add(key);
|
|
1397
|
+
return [...keys];
|
|
1310
1398
|
},
|
|
1311
1399
|
set: NO,
|
|
1312
1400
|
deleteProperty: NO
|
|
@@ -1320,16 +1408,16 @@ function getSlot(target, key) {
|
|
|
1320
1408
|
while (i--) {
|
|
1321
1409
|
source = dynamicSources[i];
|
|
1322
1410
|
if (isFunction(source)) {
|
|
1323
|
-
const slot = resolveFunctionSource(source);
|
|
1411
|
+
const slot = withSlotOwner(target, () => resolveFunctionSource(source));
|
|
1324
1412
|
if (slot) {
|
|
1325
1413
|
if (isArray(slot)) {
|
|
1326
|
-
for (let j = slot.length - 1; j >= 0; j--) if (String(slot[j].name) === key) return slot[j].fn;
|
|
1327
|
-
} else if (String(slot.name) === key) return slot.fn;
|
|
1414
|
+
for (let j = slot.length - 1; j >= 0; j--) if (String(slot[j].name) === key) return getOwnedSlot(target, key, slot[j].fn);
|
|
1415
|
+
} else if (String(slot.name) === key) return getOwnedSlot(target, key, slot.fn);
|
|
1328
1416
|
}
|
|
1329
|
-
} else if (hasOwn(source, key)) return source[key];
|
|
1417
|
+
} else if (hasOwn(source, key)) return getOwnedSlot(target, key, source[key]);
|
|
1330
1418
|
}
|
|
1331
1419
|
}
|
|
1332
|
-
if (hasOwn(target, key)) return target[key];
|
|
1420
|
+
if (hasOwn(target, key)) return getOwnedSlot(target, key, target[key]);
|
|
1333
1421
|
}
|
|
1334
1422
|
/**
|
|
1335
1423
|
* Tracks the slot owner (the component that defines the slot content).
|
|
@@ -1352,24 +1440,6 @@ function setCurrentSlotOwner(owner) {
|
|
|
1352
1440
|
function getScopeOwner() {
|
|
1353
1441
|
return currentSlotOwner || currentInstance;
|
|
1354
1442
|
}
|
|
1355
|
-
/**
|
|
1356
|
-
* Wrap a slot function to track the slot owner.
|
|
1357
|
-
*
|
|
1358
|
-
* This ensures:
|
|
1359
|
-
* 1. createSlot gets rawSlots from the correct instance (slot owner)
|
|
1360
|
-
* 2. elements inherit the slot owner's scopeId
|
|
1361
|
-
*/
|
|
1362
|
-
function withVaporCtx(fn) {
|
|
1363
|
-
const owner = getScopeOwner();
|
|
1364
|
-
return (...args) => {
|
|
1365
|
-
const prevOwner = setCurrentSlotOwner(owner);
|
|
1366
|
-
try {
|
|
1367
|
-
return fn(...args);
|
|
1368
|
-
} finally {
|
|
1369
|
-
setCurrentSlotOwner(prevOwner);
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
1443
|
function createSlot(name = "default", rawProps, fallback, flags = 0) {
|
|
1374
1444
|
if (isInteropEnabled && isCollectingVdomSlotVNodes) return;
|
|
1375
1445
|
const _insertionParent = insertionParent;
|
|
@@ -1381,6 +1451,7 @@ function createSlot(name = "default", rawProps, fallback, flags = 0) {
|
|
|
1381
1451
|
const scopeId = !(flags & 1) && instance.type.__scopeId;
|
|
1382
1452
|
const slotScopeIds = scopeId ? [`${scopeId}-s`] : null;
|
|
1383
1453
|
const once = !!(flags & 2);
|
|
1454
|
+
const slotRoot = !!(flags & 4);
|
|
1384
1455
|
const slotProps = rawProps ? new Proxy(once ? snapshotRawProps(rawProps) : rawProps, rawPropsProxyHandlers) : EMPTY_OBJ;
|
|
1385
1456
|
if (once && fallback) {
|
|
1386
1457
|
const originalFallback = fallback;
|
|
@@ -1389,15 +1460,24 @@ function createSlot(name = "default", rawProps, fallback, flags = 0) {
|
|
|
1389
1460
|
let fragment;
|
|
1390
1461
|
if (isRef(rawSlots._) && isInteropEnabled) {
|
|
1391
1462
|
if (isHydrating$1) hydrationCursor = enterHydrationCursor();
|
|
1392
|
-
fragment = instance.appContext.vapor.vdomSlot(rawSlots._, name, slotProps, instance, fallback, once);
|
|
1463
|
+
fragment = instance.appContext.vapor.vdomSlot(rawSlots._, name, slotProps, instance, fallback, once, slotRoot);
|
|
1393
1464
|
} else {
|
|
1394
1465
|
if (isHydrating$1) hydrationCursor = captureHydrationCursor();
|
|
1395
|
-
const
|
|
1396
|
-
slotFragment
|
|
1466
|
+
const isCustomElementSlot = !!(instance.ce || instance.parent && isAsyncWrapper(instance.parent) && instance.parent.ce);
|
|
1467
|
+
const slotFragment = isHydrating$1 || !!fallback || !!getCurrentSlotBoundary() || isCustomElementSlot ? new SlotFragment(slotRoot) : void 0;
|
|
1468
|
+
let dynamicFragment;
|
|
1469
|
+
if (slotFragment) {
|
|
1470
|
+
fragment = slotFragment;
|
|
1471
|
+
if (isHydrating$1) slotFragment.forwarded = currentSlotOwner != null && currentSlotOwner !== currentInstance;
|
|
1472
|
+
} else {
|
|
1473
|
+
dynamicFragment = new DynamicFragment(!!(process.env.NODE_ENV !== "production") ? "slot" : void 0, false, false);
|
|
1474
|
+
dynamicFragment.isSlot = true;
|
|
1475
|
+
fragment = dynamicFragment;
|
|
1476
|
+
}
|
|
1397
1477
|
const isDynamicName = isFunction(name);
|
|
1398
1478
|
const renderSlot = () => {
|
|
1399
1479
|
const slotName = isFunction(name) ? name() : name;
|
|
1400
|
-
if (
|
|
1480
|
+
if (isCustomElementSlot) {
|
|
1401
1481
|
const el = /* @__PURE__ */ createElement("slot");
|
|
1402
1482
|
const setSlotProps = () => {
|
|
1403
1483
|
setDynamicProps(el, [slotProps, slotName !== "default" ? { name: slotName } : {}]);
|
|
@@ -1413,8 +1493,10 @@ function createSlot(name = "default", rawProps, fallback, flags = 0) {
|
|
|
1413
1493
|
return;
|
|
1414
1494
|
}
|
|
1415
1495
|
const slot = getSlot(rawSlots, slotName);
|
|
1416
|
-
if (slot) slotFragment.updateSlot(getBoundSlot(slot), fallback);
|
|
1417
|
-
else
|
|
1496
|
+
if (slot) if (slotFragment) slotFragment.updateSlot(getBoundSlot(slot), fallback);
|
|
1497
|
+
else dynamicFragment.update(getBoundSlot(slot));
|
|
1498
|
+
else if (slotFragment) slotFragment.updateSlot(void 0, fallback);
|
|
1499
|
+
else dynamicFragment.update();
|
|
1418
1500
|
};
|
|
1419
1501
|
let cachedSlot;
|
|
1420
1502
|
let cachedBoundSlot;
|
|
@@ -1439,7 +1521,8 @@ function createSlot(name = "default", rawProps, fallback, flags = 0) {
|
|
|
1439
1521
|
if (slotScopeIds) setScopeId(fragment, slotScopeIds);
|
|
1440
1522
|
if (_insertionParent) insert(fragment, _insertionParent, _insertionAnchor);
|
|
1441
1523
|
} else {
|
|
1442
|
-
if (fragment
|
|
1524
|
+
if (isInteropEnabled && isInteropFragment(fragment)) fragment.hydrate();
|
|
1525
|
+
if (slotScopeIds) trackScopeIdFragment(fragment, slotScopeIds);
|
|
1443
1526
|
exitHydrationCursor(hydrationCursor);
|
|
1444
1527
|
}
|
|
1445
1528
|
return fragment;
|
|
@@ -1504,7 +1587,7 @@ function isVaporTransition(component) {
|
|
|
1504
1587
|
}
|
|
1505
1588
|
//#endregion
|
|
1506
1589
|
//#region packages/runtime-vapor/src/fragment.ts
|
|
1507
|
-
const EMPTY_BLOCK = EMPTY_ARR;
|
|
1590
|
+
const EMPTY_BLOCK$1 = EMPTY_ARR;
|
|
1508
1591
|
var VaporFragment = class {
|
|
1509
1592
|
constructor(nodes) {
|
|
1510
1593
|
this.renderInstance = currentInstance;
|
|
@@ -1515,30 +1598,32 @@ var VaporFragment = class {
|
|
|
1515
1598
|
}
|
|
1516
1599
|
runWithRenderCtx(fn, scope) {
|
|
1517
1600
|
const prevInstance = setCurrentInstance(this.renderInstance, scope);
|
|
1518
|
-
const keepAliveCtx = isKeepAliveEnabled ? this.keepAliveCtx || null : null;
|
|
1519
|
-
if (currentSlotOwner === this.slotOwner && currentSlotBoundary === this.inheritedSlotBoundary && (!isKeepAliveEnabled || currentKeepAliveCtx === keepAliveCtx)) try {
|
|
1520
|
-
return fn();
|
|
1521
|
-
} finally {
|
|
1522
|
-
setCurrentInstance(...prevInstance);
|
|
1523
|
-
}
|
|
1524
|
-
const prevSlotOwner = setCurrentSlotOwner(this.slotOwner);
|
|
1525
|
-
let prevKeepAliveCtx = null;
|
|
1526
|
-
if (isKeepAliveEnabled) prevKeepAliveCtx = setCurrentKeepAliveCtx(keepAliveCtx);
|
|
1527
|
-
const prevBoundary = setCurrentSlotBoundary(this.inheritedSlotBoundary);
|
|
1528
1601
|
try {
|
|
1529
|
-
return fn
|
|
1602
|
+
return runWithFragmentCtx(this, fn);
|
|
1530
1603
|
} finally {
|
|
1531
|
-
setCurrentSlotBoundary(prevBoundary);
|
|
1532
|
-
if (isKeepAliveEnabled) setCurrentKeepAliveCtx(prevKeepAliveCtx);
|
|
1533
|
-
setCurrentSlotOwner(prevSlotOwner);
|
|
1534
1604
|
setCurrentInstance(...prevInstance);
|
|
1535
1605
|
}
|
|
1536
1606
|
}
|
|
1537
1607
|
};
|
|
1608
|
+
function runWithFragmentCtx(fragment, fn) {
|
|
1609
|
+
const keepAliveCtx = isKeepAliveEnabled ? fragment.keepAliveCtx || null : null;
|
|
1610
|
+
if (currentSlotOwner === fragment.slotOwner && currentSlotBoundary === fragment.inheritedSlotBoundary && (!isKeepAliveEnabled || currentKeepAliveCtx === keepAliveCtx)) return fn();
|
|
1611
|
+
const prevSlotOwner = setCurrentSlotOwner(fragment.slotOwner);
|
|
1612
|
+
let prevKeepAliveCtx = null;
|
|
1613
|
+
if (isKeepAliveEnabled) prevKeepAliveCtx = setCurrentKeepAliveCtx(keepAliveCtx);
|
|
1614
|
+
const prevBoundary = setCurrentSlotBoundary(fragment.inheritedSlotBoundary);
|
|
1615
|
+
try {
|
|
1616
|
+
return fn();
|
|
1617
|
+
} finally {
|
|
1618
|
+
setCurrentSlotBoundary(prevBoundary);
|
|
1619
|
+
if (isKeepAliveEnabled) setCurrentKeepAliveCtx(prevKeepAliveCtx);
|
|
1620
|
+
setCurrentSlotOwner(prevSlotOwner);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1538
1623
|
var ForFragment = class extends VaporFragment {
|
|
1539
|
-
constructor(nodes) {
|
|
1624
|
+
constructor(nodes, trackSlotBoundary) {
|
|
1540
1625
|
super(nodes);
|
|
1541
|
-
trackSlotBoundaryDirtying(this);
|
|
1626
|
+
if (trackSlotBoundary) trackSlotBoundaryDirtying(this);
|
|
1542
1627
|
}
|
|
1543
1628
|
onReset(fn) {
|
|
1544
1629
|
(this.resetListeners || (this.resetListeners = [])).push(fn);
|
|
@@ -1570,8 +1655,8 @@ function queueAnchorInsert(parentNode$1, nextNode, createAnchor) {
|
|
|
1570
1655
|
});
|
|
1571
1656
|
}
|
|
1572
1657
|
var DynamicFragment = class extends VaporFragment {
|
|
1573
|
-
constructor(anchorLabel, keyed = false, locate = true, trackSlotBoundary =
|
|
1574
|
-
super(EMPTY_BLOCK);
|
|
1658
|
+
constructor(anchorLabel, keyed = false, locate = true, trackSlotBoundary = false) {
|
|
1659
|
+
super(EMPTY_BLOCK$1);
|
|
1575
1660
|
if (keyed) this.keyed = true;
|
|
1576
1661
|
if (isTransitionEnabled && currentInstance && isVaporTransition(currentInstance.type)) this.inTransition = true;
|
|
1577
1662
|
if (isHydrating$1) {
|
|
@@ -1583,12 +1668,17 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1583
1668
|
}
|
|
1584
1669
|
if (trackSlotBoundary) trackSlotBoundaryDirtying(this);
|
|
1585
1670
|
}
|
|
1586
|
-
update(render, key = render, noScope = false) {
|
|
1671
|
+
update(render, key = render, noScope = false, shouldInsert = true) {
|
|
1587
1672
|
if (key === this.current) {
|
|
1588
|
-
if (isHydrating$1 && this.
|
|
1673
|
+
if (isHydrating$1 && !this.isSlot) this.hydrate(true);
|
|
1589
1674
|
return;
|
|
1590
1675
|
}
|
|
1591
1676
|
const transition = isTransitionEnabled ? this.$transition : void 0;
|
|
1677
|
+
const wasMounted = this.current !== void 0;
|
|
1678
|
+
if (wasMounted) {
|
|
1679
|
+
const onBeforeUpdate = this.onBeforeUpdate;
|
|
1680
|
+
if (onBeforeUpdate) for (let i = 0; i < onBeforeUpdate.length; i++) onBeforeUpdate[i]();
|
|
1681
|
+
}
|
|
1592
1682
|
if (transition && transition.state.isLeaving) {
|
|
1593
1683
|
this.current = key;
|
|
1594
1684
|
const pending = this.pending;
|
|
@@ -1605,8 +1695,8 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1605
1695
|
}
|
|
1606
1696
|
const instance = currentInstance;
|
|
1607
1697
|
const prevSub = setActiveSub();
|
|
1608
|
-
const parent = isHydrating$1
|
|
1609
|
-
if (
|
|
1698
|
+
const parent = !isHydrating$1 && shouldInsert ? this.anchor.parentNode : null;
|
|
1699
|
+
if (wasMounted) {
|
|
1610
1700
|
const scope = this.scope;
|
|
1611
1701
|
if (scope) {
|
|
1612
1702
|
let retainScope = false;
|
|
@@ -1622,8 +1712,8 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1622
1712
|
const pending = this.pending;
|
|
1623
1713
|
if (pending) {
|
|
1624
1714
|
this.pending = void 0;
|
|
1625
|
-
this.renderBranch(pending.render, transition, parent, pending.key, pending.noScope);
|
|
1626
|
-
} else this.renderBranch(render, transition, parent, key, noScope);
|
|
1715
|
+
this.renderBranch(pending.render, transition, parent, pending.key, pending.noScope, true);
|
|
1716
|
+
} else this.renderBranch(render, transition, parent, key, noScope, true);
|
|
1627
1717
|
} finally {
|
|
1628
1718
|
setCurrentInstance(...prevInstance);
|
|
1629
1719
|
}
|
|
@@ -1637,7 +1727,7 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1637
1727
|
}
|
|
1638
1728
|
let reusingDeferredAnchor = false;
|
|
1639
1729
|
if (isHydrating$1) {
|
|
1640
|
-
const isRevivingDeferredBranch = isInDeferredHydrationBoundary() && !!render && this.
|
|
1730
|
+
const isRevivingDeferredBranch = isInDeferredHydrationBoundary() && !!render && !this.isSlot && !isValidBlock(this.nodes);
|
|
1641
1731
|
reusingDeferredAnchor = isRevivingDeferredBranch && !!this.anchor && !!this.anchor.parentNode;
|
|
1642
1732
|
if (isRevivingDeferredBranch) {
|
|
1643
1733
|
let slotEndAnchor = null;
|
|
@@ -1645,11 +1735,11 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1645
1735
|
if (anchor) setCurrentHydrationNode(markHydrationAnchor(anchor));
|
|
1646
1736
|
}
|
|
1647
1737
|
}
|
|
1648
|
-
this.renderBranch(render, transition, parent, key, noScope);
|
|
1738
|
+
this.renderBranch(render, transition, parent, key, noScope, wasMounted || !!parent);
|
|
1649
1739
|
setActiveSub(prevSub);
|
|
1650
|
-
if (isHydrating$1 && this.
|
|
1740
|
+
if (isHydrating$1 && !this.isSlot && !reusingDeferredAnchor) this.hydrate(render == null);
|
|
1651
1741
|
}
|
|
1652
|
-
renderBranch(render, transition, parent, key, noScope = false) {
|
|
1742
|
+
renderBranch(render, transition, parent, key, noScope = false, notifyUpdated = !!parent) {
|
|
1653
1743
|
this.current = key;
|
|
1654
1744
|
if (render) {
|
|
1655
1745
|
const keepAliveCtx = isKeepAliveEnabled ? this.keepAliveCtx : null;
|
|
@@ -1661,7 +1751,7 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1661
1751
|
} else this.scope = void 0;
|
|
1662
1752
|
const renderBranch = () => {
|
|
1663
1753
|
try {
|
|
1664
|
-
this.nodes = this.runWithRenderCtx(() => (useScope ? this.scope.run(render) : render()) || EMPTY_BLOCK, this.scope);
|
|
1754
|
+
this.nodes = this.runWithRenderCtx(() => (useScope ? this.scope.run(render) : render()) || EMPTY_BLOCK$1, this.scope);
|
|
1665
1755
|
} finally {
|
|
1666
1756
|
const key = this.keyed ? this.current : this.$key;
|
|
1667
1757
|
if (key !== void 0 && (transition || this.inTransition || keepAliveCtx)) setBlockKey(this.nodes, key);
|
|
@@ -1678,14 +1768,12 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1678
1768
|
}
|
|
1679
1769
|
} else {
|
|
1680
1770
|
this.scope = void 0;
|
|
1681
|
-
this.nodes = EMPTY_BLOCK;
|
|
1682
|
-
}
|
|
1683
|
-
if (parent) {
|
|
1684
|
-
const onUpdated = this.onUpdated;
|
|
1685
|
-
if (onUpdated) onUpdated.forEach((hook) => hook(this.nodes));
|
|
1771
|
+
this.nodes = EMPTY_BLOCK$1;
|
|
1686
1772
|
}
|
|
1773
|
+
const onUpdated = this.onUpdated;
|
|
1774
|
+
if (notifyUpdated && onUpdated) onUpdated.forEach((hook) => hook(this.nodes));
|
|
1687
1775
|
}
|
|
1688
|
-
hydrate(isEmpty = false
|
|
1776
|
+
hydrate(isEmpty = false) {
|
|
1689
1777
|
if (!isHydrating$1) return;
|
|
1690
1778
|
let advanceAfterRestore = null;
|
|
1691
1779
|
let exitHydrationBoundary;
|
|
@@ -1720,12 +1808,12 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1720
1808
|
return;
|
|
1721
1809
|
}
|
|
1722
1810
|
}
|
|
1723
|
-
if (!isSlot && this.anchorLabel && currentHydrationNode && !isHydratingSlotFallbackActive() && !isComment(currentHydrationNode, "]")) {
|
|
1811
|
+
if (!this.isSlot && this.anchorLabel && currentHydrationNode && !isHydratingSlotFallbackActive() && !isComment(currentHydrationNode, "]")) {
|
|
1724
1812
|
const parentNode$4 = /* @__PURE__ */ parentNode(currentHydrationNode);
|
|
1725
1813
|
const anchor = nextLogicalSibling(currentHydrationNode);
|
|
1726
1814
|
const reusableAnchor = anchor && anchor.nodeType === 8 && isReusableDynamicFragmentAnchor(anchor, this.anchorLabel) && /* @__PURE__ */ parentNode(anchor) ? anchor : null;
|
|
1727
1815
|
if (parentNode$4) {
|
|
1728
|
-
this.nodes = EMPTY_BLOCK;
|
|
1816
|
+
this.nodes = EMPTY_BLOCK$1;
|
|
1729
1817
|
if (reusableAnchor) reuseAnchor(reusableAnchor);
|
|
1730
1818
|
else cleanupAndInsertRuntimeAnchor(parentNode$4, anchor, currentHydrationNode, anchor);
|
|
1731
1819
|
return;
|
|
@@ -1734,7 +1822,7 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1734
1822
|
}
|
|
1735
1823
|
if (this.anchorLabel && !isValidBlock(this.nodes) && this.nodes instanceof Comment && isReusableDynamicFragmentAnchor(this.nodes, this.anchorLabel) && /* @__PURE__ */ parentNode(this.nodes)) {
|
|
1736
1824
|
const anchor = this.nodes;
|
|
1737
|
-
this.nodes = EMPTY_BLOCK;
|
|
1825
|
+
this.nodes = EMPTY_BLOCK$1;
|
|
1738
1826
|
reuseAnchor(anchor);
|
|
1739
1827
|
return;
|
|
1740
1828
|
}
|
|
@@ -1742,15 +1830,15 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1742
1830
|
const parentNode$5 = /* @__PURE__ */ parentNode(currentHydrationNode);
|
|
1743
1831
|
const nextNode = nextLogicalSibling(currentHydrationNode);
|
|
1744
1832
|
if (parentNode$5) {
|
|
1745
|
-
this.nodes = EMPTY_BLOCK;
|
|
1833
|
+
this.nodes = EMPTY_BLOCK$1;
|
|
1746
1834
|
cleanupAndInsertRuntimeAnchor(parentNode$5, nextNode, currentHydrationNode, nextNode);
|
|
1747
1835
|
return;
|
|
1748
1836
|
}
|
|
1749
1837
|
}
|
|
1750
1838
|
const currentSlotEndAnchor = getCurrentSlotEndAnchor();
|
|
1751
|
-
const forwardedSlot = isSlot ? this.forwarded : false;
|
|
1752
|
-
const slotAnchor = isSlot ? currentSlotEndAnchor : null;
|
|
1753
|
-
const closeOwner = getDynamicCloseOwner(isSlot, forwardedSlot, this.anchorLabel, this.nodes, currentSlotEndAnchor);
|
|
1839
|
+
const forwardedSlot = this.isSlot ? this.forwarded : false;
|
|
1840
|
+
const slotAnchor = this.isSlot ? currentSlotEndAnchor : null;
|
|
1841
|
+
const closeOwner = getDynamicCloseOwner(!!this.isSlot, forwardedSlot, this.anchorLabel, this.nodes, currentSlotEndAnchor);
|
|
1754
1842
|
if (closeOwner === 1) {
|
|
1755
1843
|
const anchor = locateHydrationBoundaryClose(slotAnchor || currentHydrationNode, slotAnchor || null);
|
|
1756
1844
|
if (isComment(anchor, "]")) {
|
|
@@ -1776,7 +1864,7 @@ var DynamicFragment = class extends VaporFragment {
|
|
|
1776
1864
|
parentNode$3 = currentSlotEndAnchor.parentNode;
|
|
1777
1865
|
nextNode = currentSlotEndAnchor;
|
|
1778
1866
|
} else {
|
|
1779
|
-
const node =
|
|
1867
|
+
const node = findBlockBoundary(this.nodes);
|
|
1780
1868
|
parentNode$3 = node.parentNode;
|
|
1781
1869
|
nextNode = node.nextNode;
|
|
1782
1870
|
}
|
|
@@ -1820,58 +1908,14 @@ function getRedirectedBoundary(boundary) {
|
|
|
1820
1908
|
function trackSlotBoundaryDirtying(fragment) {
|
|
1821
1909
|
const boundary = currentSlotBoundary;
|
|
1822
1910
|
if (!boundary) return;
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
if (block instanceof Node) return node(block);
|
|
1827
|
-
if (isVaporComponent(block)) return walkSlotFallbackBlock(block.block, node, fragment);
|
|
1828
|
-
if (isArray(block)) {
|
|
1829
|
-
for (const child of block) if (walkSlotFallbackBlock(child, node, fragment)) return true;
|
|
1830
|
-
return false;
|
|
1831
|
-
}
|
|
1832
|
-
return fragment(block, (block) => walkSlotFallbackBlock(block, node, fragment));
|
|
1833
|
-
}
|
|
1834
|
-
function resolveSlotFallbackCarrierOwner(block) {
|
|
1835
|
-
let owner = null;
|
|
1836
|
-
walkSlotFallbackBlock(block, () => false, (block) => {
|
|
1837
|
-
owner = block;
|
|
1838
|
-
return true;
|
|
1839
|
-
});
|
|
1840
|
-
return owner;
|
|
1841
|
-
}
|
|
1842
|
-
function findFirstSlotFallbackCarrierNode(block) {
|
|
1843
|
-
let node = null;
|
|
1844
|
-
walkSlotFallbackBlock(block, (value) => {
|
|
1845
|
-
node = value;
|
|
1846
|
-
return true;
|
|
1847
|
-
}, (block, walk) => {
|
|
1848
|
-
if (walk(block.nodes)) return true;
|
|
1849
|
-
if (block.anchor) {
|
|
1850
|
-
node = block.anchor;
|
|
1851
|
-
return true;
|
|
1852
|
-
}
|
|
1853
|
-
return false;
|
|
1911
|
+
let prevValid = isValidBlock(fragment);
|
|
1912
|
+
(fragment.onBeforeUpdate || (fragment.onBeforeUpdate = [])).push(() => {
|
|
1913
|
+
prevValid = isValidBlock(fragment);
|
|
1854
1914
|
});
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
if (includeComments || !(block instanceof Comment)) nodes.push(block);
|
|
1860
|
-
return false;
|
|
1861
|
-
}, (block) => {
|
|
1862
|
-
collectBlockNodes(block.nodes, nodes, true);
|
|
1863
|
-
if (block.anchor) nodes.push(block.anchor);
|
|
1864
|
-
return false;
|
|
1865
|
-
});
|
|
1866
|
-
return nodes;
|
|
1867
|
-
}
|
|
1868
|
-
function mutateSlotFallbackCarrier(block, apply) {
|
|
1869
|
-
walkSlotFallbackBlock(block, (block) => {
|
|
1870
|
-
if (!(block instanceof Comment)) apply(block);
|
|
1871
|
-
return false;
|
|
1872
|
-
}, (block) => {
|
|
1873
|
-
apply(block);
|
|
1874
|
-
return false;
|
|
1915
|
+
(fragment.onUpdated || (fragment.onUpdated = [])).push(() => {
|
|
1916
|
+
const valid = isValidBlock(fragment);
|
|
1917
|
+
if (valid !== prevValid) boundary.markDirty();
|
|
1918
|
+
prevValid = valid;
|
|
1875
1919
|
});
|
|
1876
1920
|
}
|
|
1877
1921
|
function hasSlotFallback(boundary) {
|
|
@@ -1881,161 +1925,145 @@ function hasSlotFallback(boundary) {
|
|
|
1881
1925
|
}
|
|
1882
1926
|
return false;
|
|
1883
1927
|
}
|
|
1884
|
-
function renderSlotFallback(boundary, scope
|
|
1885
|
-
|
|
1886
|
-
return hasFallback ? block : void 0;
|
|
1887
|
-
}
|
|
1888
|
-
function renderSlotFallbackBlock(boundary, scope, args) {
|
|
1889
|
-
if (!boundary) return [[], false];
|
|
1928
|
+
function renderSlotFallback(boundary, scope) {
|
|
1929
|
+
if (!boundary) return;
|
|
1890
1930
|
const localFallback = boundary.getFallback();
|
|
1891
|
-
if (!localFallback) return
|
|
1892
|
-
const renderFallback = () => withOwnedSlotBoundary(getRedirectedBoundary(boundary), () => localFallback(
|
|
1893
|
-
const local = boundary.run(() =>
|
|
1894
|
-
if (isValidBlock(local)) return
|
|
1895
|
-
const
|
|
1896
|
-
return
|
|
1897
|
-
}
|
|
1898
|
-
function
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1931
|
+
if (!localFallback) return renderSlotFallback(boundary.parent, scope);
|
|
1932
|
+
const renderFallback = () => withOwnedSlotBoundary(getRedirectedBoundary(boundary), () => localFallback());
|
|
1933
|
+
const local = boundary.run(() => scope.run(renderFallback) || [], scope);
|
|
1934
|
+
if (isValidBlock(local)) return local;
|
|
1935
|
+
const inherited = renderSlotFallback(boundary.parent, scope);
|
|
1936
|
+
return inherited === void 0 ? local : inherited;
|
|
1937
|
+
}
|
|
1938
|
+
function detachBlock(block, parent) {
|
|
1939
|
+
if (block instanceof Node) {
|
|
1940
|
+
if (block.parentNode === parent) removeNode(block, parent);
|
|
1941
|
+
} else if (isVaporComponent(block)) {
|
|
1942
|
+
if (block.block) detachBlock(block.block, parent);
|
|
1943
|
+
} else if (isArray(block)) for (let i = 0; i < block.length; i++) detachBlock(block[i], parent);
|
|
1944
|
+
else {
|
|
1945
|
+
detachBlock(block.nodes, parent);
|
|
1946
|
+
if (!(block instanceof SlotFragment) && block.anchor && block.anchor.parentNode === parent) removeNode(block.anchor, parent);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
function markSlotFallbackDirty(state) {
|
|
1950
|
+
if (state.isDisposed()) return;
|
|
1951
|
+
if (state.isRenderingFallback) {
|
|
1952
|
+
state.pendingRecheck = true;
|
|
1908
1953
|
return;
|
|
1909
1954
|
}
|
|
1910
|
-
if (
|
|
1911
|
-
|
|
1955
|
+
if (state.isBusy()) {
|
|
1956
|
+
state.pendingRecheck = true;
|
|
1912
1957
|
return;
|
|
1913
1958
|
}
|
|
1914
|
-
recheckSlotFallback(
|
|
1959
|
+
recheckSlotFallback(state, true);
|
|
1915
1960
|
}
|
|
1916
|
-
function clearSlotFallback(
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1961
|
+
function clearSlotFallback(state) {
|
|
1962
|
+
const fallback = state.activeFallback;
|
|
1963
|
+
if (fallback) {
|
|
1964
|
+
const parentNode = state.getParentNode();
|
|
1965
|
+
if (parentNode) remove(fallback, parentNode);
|
|
1966
|
+
state.activeFallback = null;
|
|
1921
1967
|
}
|
|
1922
|
-
if (
|
|
1923
|
-
|
|
1924
|
-
|
|
1968
|
+
if (state.fallbackScope) {
|
|
1969
|
+
state.fallbackScope.stop();
|
|
1970
|
+
state.fallbackScope = void 0;
|
|
1925
1971
|
}
|
|
1926
1972
|
}
|
|
1927
|
-
function
|
|
1928
|
-
const scope = new EffectScope$1();
|
|
1973
|
+
function renderSlotFallbackState(state) {
|
|
1974
|
+
const scope = new EffectScope$1(true);
|
|
1929
1975
|
let renderedFallback;
|
|
1930
|
-
|
|
1976
|
+
state.isRenderingFallback = true;
|
|
1931
1977
|
try {
|
|
1932
|
-
renderedFallback = renderSlotFallback(
|
|
1978
|
+
renderedFallback = renderSlotFallback(state.boundary, scope);
|
|
1933
1979
|
} catch (err) {
|
|
1934
1980
|
scope.stop();
|
|
1935
1981
|
throw err;
|
|
1936
1982
|
} finally {
|
|
1937
|
-
|
|
1983
|
+
state.isRenderingFallback = false;
|
|
1938
1984
|
}
|
|
1939
1985
|
if (!renderedFallback) {
|
|
1940
1986
|
scope.stop();
|
|
1941
|
-
return
|
|
1987
|
+
return;
|
|
1942
1988
|
}
|
|
1943
1989
|
return {
|
|
1944
|
-
found: true,
|
|
1945
1990
|
block: renderedFallback,
|
|
1946
1991
|
scope
|
|
1947
1992
|
};
|
|
1948
1993
|
}
|
|
1949
|
-
function
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
const
|
|
1953
|
-
const lastNode = fallbackNodes[fallbackNodes.length - 1];
|
|
1954
|
-
if (!carrierNodes.length || !lastNode) return;
|
|
1955
|
-
const parentNode = carrierNodes[0].parentNode;
|
|
1956
|
-
if (!parentNode || lastNode.parentNode !== parentNode) return;
|
|
1957
|
-
let inOrder = true;
|
|
1958
|
-
let nextNode = lastNode.nextSibling;
|
|
1959
|
-
for (const carrierNode of carrierNodes) {
|
|
1960
|
-
if (carrierNode.parentNode !== parentNode) return;
|
|
1961
|
-
if (carrierNode !== nextNode) {
|
|
1962
|
-
inOrder = false;
|
|
1963
|
-
break;
|
|
1964
|
-
}
|
|
1965
|
-
nextNode = carrierNode.nextSibling;
|
|
1966
|
-
}
|
|
1967
|
-
if (inOrder) return;
|
|
1968
|
-
let anchor = lastNode.nextSibling;
|
|
1969
|
-
for (let i = carrierNodes.length - 1; i >= 0; i--) {
|
|
1970
|
-
const carrierNode = carrierNodes[i];
|
|
1971
|
-
parentNode.insertBefore(carrierNode, anchor);
|
|
1972
|
-
anchor = carrierNode;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
function ensureSlotFallbackOrderHook(outlet, block) {
|
|
1976
|
-
if (!isFragment(block)) return;
|
|
1977
|
-
const fragment = block;
|
|
1978
|
-
if (fragment.hasSlotFallbackOrderHook) return;
|
|
1979
|
-
(fragment.onUpdated || (fragment.onUpdated = [])).push(() => syncSlotFallbackOrder(outlet, fragment));
|
|
1980
|
-
fragment.hasSlotFallbackOrderHook = true;
|
|
1981
|
-
}
|
|
1982
|
-
function insertActiveSlotFallback(outlet) {
|
|
1983
|
-
if (isHydrating$1 || !outlet.activeFallback) return;
|
|
1984
|
-
const parentNode = outlet.getParentNode();
|
|
1994
|
+
function insertActiveSlotFallback(state) {
|
|
1995
|
+
const fallback = state.activeFallback;
|
|
1996
|
+
if (isHydrating$1 || !fallback || !isValidBlock(fallback)) return;
|
|
1997
|
+
const parentNode = state.getParentNode();
|
|
1985
1998
|
if (!parentNode) return;
|
|
1986
|
-
|
|
1987
|
-
insert(outlet.activeFallback, parentNode, carrierAnchor && carrierAnchor.parentNode === parentNode ? carrierAnchor : outlet.getAnchor());
|
|
1999
|
+
insert(fallback, parentNode, state.getAnchor());
|
|
1988
2000
|
}
|
|
1989
|
-
function commitSlotFallback(
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2001
|
+
function commitSlotFallback(state, block, scope, detachContent) {
|
|
2002
|
+
const parentNode = state.getParentNode();
|
|
2003
|
+
if (detachContent && !isHydrating$1 && parentNode) detachBlock(state.getContent(), parentNode);
|
|
2004
|
+
state.activeFallback = block;
|
|
2005
|
+
state.fallbackScope = scope;
|
|
1993
2006
|
if (isTransitionEnabled) {
|
|
1994
|
-
const
|
|
1995
|
-
if (
|
|
2007
|
+
const transitionState = state;
|
|
2008
|
+
if (transitionState.$transition) {
|
|
1996
2009
|
setBlockKey(block, "_fb");
|
|
1997
|
-
|
|
2010
|
+
transitionState.$transition = applyTransitionHooks(block, transitionState.$transition);
|
|
1998
2011
|
}
|
|
1999
2012
|
}
|
|
2000
|
-
insertActiveSlotFallback(
|
|
2013
|
+
insertActiveSlotFallback(state);
|
|
2001
2014
|
}
|
|
2002
|
-
function
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2015
|
+
function renderAndCommitSlotFallback(state, hadFallback) {
|
|
2016
|
+
const result = renderSlotFallbackState(state);
|
|
2017
|
+
clearSlotFallback(state);
|
|
2018
|
+
if (result) {
|
|
2019
|
+
commitSlotFallback(state, result.block, result.scope, !hadFallback);
|
|
2020
|
+
if (state.pendingRecheck) {
|
|
2021
|
+
state.pendingRecheck = false;
|
|
2022
|
+
recheckSlotFallback(state, true);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2008
2025
|
}
|
|
2009
|
-
function disposeSlotFallback(
|
|
2010
|
-
clearSlotFallback(
|
|
2011
|
-
|
|
2012
|
-
|
|
2026
|
+
function disposeSlotFallback(state) {
|
|
2027
|
+
clearSlotFallback(state);
|
|
2028
|
+
state.pendingRecheck = false;
|
|
2029
|
+
state.lastNodesValid = void 0;
|
|
2013
2030
|
}
|
|
2014
|
-
function recheckSlotFallback(
|
|
2015
|
-
if (
|
|
2016
|
-
|
|
2031
|
+
function recheckSlotFallback(state, force = false) {
|
|
2032
|
+
if (state.isRenderingFallback) {
|
|
2033
|
+
state.pendingRecheck = true;
|
|
2017
2034
|
return;
|
|
2018
2035
|
}
|
|
2019
|
-
const
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
commitSlotFallback(outlet, result.block, result.scope);
|
|
2028
|
-
if (outlet.pendingRecheck && outlet.rerunRecheckAfterFallbackRender !== false) {
|
|
2029
|
-
outlet.pendingRecheck = false;
|
|
2030
|
-
recheckSlotFallback(outlet, true);
|
|
2031
|
-
}
|
|
2032
|
-
} else clearSlotFallback(outlet);
|
|
2033
|
-
}
|
|
2036
|
+
const fallback = state.activeFallback;
|
|
2037
|
+
const fallbackValid = fallback ? isValidBlock(fallback) : false;
|
|
2038
|
+
const contentValid = state.isContentValid();
|
|
2039
|
+
const prevNodesValid = state.lastNodesValid === void 0 ? fallback ? fallbackValid : contentValid : state.lastNodesValid;
|
|
2040
|
+
if (!force && contentValid && !fallback && prevNodesValid) {
|
|
2041
|
+
state.syncNodes();
|
|
2042
|
+
state.lastNodesValid = true;
|
|
2043
|
+
return;
|
|
2034
2044
|
}
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2045
|
+
if (contentValid) {
|
|
2046
|
+
const content = state.getContent();
|
|
2047
|
+
const hadFallback = !!fallback;
|
|
2048
|
+
clearSlotFallback(state);
|
|
2049
|
+
if (!isHydrating$1 && hadFallback) {
|
|
2050
|
+
const parentNode = state.getParentNode();
|
|
2051
|
+
if (parentNode) insert(content, parentNode, state.getAnchor());
|
|
2052
|
+
}
|
|
2053
|
+
} else if (fallback) {
|
|
2054
|
+
if (prevNodesValid) {
|
|
2055
|
+
if (!fallbackValid && !hasSlotFallback(state.boundary.parent)) {
|
|
2056
|
+
const parentNode = state.getParentNode();
|
|
2057
|
+
if (parentNode) detachBlock(fallback, parentNode);
|
|
2058
|
+
} else if (force) renderAndCommitSlotFallback(state, true);
|
|
2059
|
+
} else if (fallbackValid) insertActiveSlotFallback(state);
|
|
2060
|
+
else if (force) renderAndCommitSlotFallback(state, true);
|
|
2061
|
+
} else renderAndCommitSlotFallback(state, false);
|
|
2062
|
+
const nextFallback = state.activeFallback;
|
|
2063
|
+
const nextNodesValid = nextFallback ? isValidBlock(nextFallback) : state.isContentValid();
|
|
2064
|
+
state.syncNodes();
|
|
2065
|
+
state.lastNodesValid = nextNodesValid;
|
|
2066
|
+
if (prevNodesValid !== nextNodesValid) state.notifyFallbackValidityChange();
|
|
2039
2067
|
}
|
|
2040
2068
|
let currentHydratingSlotBoundaryState = null;
|
|
2041
2069
|
function setCurrentHydratingSlotBoundaryState(state) {
|
|
@@ -2090,16 +2118,18 @@ function isReusableDynamicFragmentAnchor(node, anchorLabel) {
|
|
|
2090
2118
|
return isComment(node, anchorLabel) || isComment(node, "") && (anchorLabel === "dynamic-component" || anchorLabel === "async component" || anchorLabel === "keyed");
|
|
2091
2119
|
}
|
|
2092
2120
|
var SlotFragment = class extends DynamicFragment {
|
|
2093
|
-
constructor() {
|
|
2121
|
+
constructor(notifyParent = false) {
|
|
2094
2122
|
super(isHydrating$1 || !!(process.env.NODE_ENV !== "production") ? "slot" : void 0, false, false, false);
|
|
2123
|
+
this.isSlot = true;
|
|
2095
2124
|
this.disposed = false;
|
|
2096
2125
|
this.forwarded = false;
|
|
2097
2126
|
this.parentSlotBoundary = getCurrentSlotBoundary();
|
|
2098
2127
|
this.activeFallback = null;
|
|
2099
2128
|
this.pendingRecheck = false;
|
|
2100
2129
|
this.isRenderingFallback = false;
|
|
2101
|
-
this.
|
|
2130
|
+
this.content = EMPTY_BLOCK$1;
|
|
2102
2131
|
this.isUpdatingSlot = false;
|
|
2132
|
+
this.notifyParent = notifyParent;
|
|
2103
2133
|
if (!isHydrating$1) this.insert = (parent, anchor) => this.insertSlot(parent, anchor);
|
|
2104
2134
|
this.remove = (parent) => this.removeSlot(parent);
|
|
2105
2135
|
}
|
|
@@ -2124,55 +2154,46 @@ var SlotFragment = class extends DynamicFragment {
|
|
|
2124
2154
|
get slotFallbackBoundary() {
|
|
2125
2155
|
return this.ensureSlotFallbackBoundary();
|
|
2126
2156
|
}
|
|
2127
|
-
getEffectiveOutput() {
|
|
2128
|
-
return getSlotEffectiveOutput(this);
|
|
2129
|
-
}
|
|
2130
2157
|
insertSlot(parent, anchor) {
|
|
2131
2158
|
this.disposed = false;
|
|
2132
|
-
if (this.fallbackBlock) {
|
|
2133
|
-
insert(this.fallbackBlock, parent, anchor);
|
|
2134
|
-
mutateSlotFallbackCarrier(this.nodes, (block) => insert(block, parent, anchor));
|
|
2135
|
-
return;
|
|
2136
|
-
}
|
|
2137
2159
|
insert(this.nodes, parent, anchor);
|
|
2138
2160
|
}
|
|
2139
2161
|
removeSlot(parent) {
|
|
2140
2162
|
this.disposed = true;
|
|
2141
|
-
|
|
2142
|
-
|
|
2163
|
+
const nodes = this.nodes;
|
|
2164
|
+
remove(nodes, parent);
|
|
2165
|
+
if (this.activeFallback === nodes) this.activeFallback = null;
|
|
2143
2166
|
disposeSlotFallback(this);
|
|
2144
2167
|
}
|
|
2168
|
+
updateContent(render, key) {
|
|
2169
|
+
this.nodes = this.content;
|
|
2170
|
+
this.update(render, key, false, !this.activeFallback);
|
|
2171
|
+
this.content = this.nodes;
|
|
2172
|
+
}
|
|
2145
2173
|
updateSlot(render, fallback, key = render || fallback) {
|
|
2146
2174
|
const prevLocalFallback = this.localFallback;
|
|
2147
2175
|
this.localFallback = fallback;
|
|
2148
|
-
const fallbackChanged = prevLocalFallback !== fallback;
|
|
2149
|
-
const fastSlotKey = key === void 0 ? render : key;
|
|
2150
|
-
if (!isHydrating$1 && !fallback && !this.parentSlotBoundary && !this._slotFallbackBoundary) {
|
|
2151
|
-
this.update(render, fastSlotKey);
|
|
2152
|
-
return;
|
|
2153
|
-
}
|
|
2154
2176
|
const boundary = this.slotFallbackBoundary;
|
|
2155
|
-
const slotRender = render ? () => withOwnedSlotBoundary(boundary, render) : () =>
|
|
2156
|
-
const slotKey = key === void 0 ? slotRender : key;
|
|
2177
|
+
const slotRender = render ? () => withOwnedSlotBoundary(boundary, render) : () => EMPTY_BLOCK$1;
|
|
2157
2178
|
this.isUpdatingSlot = true;
|
|
2158
2179
|
this.pendingRecheck = false;
|
|
2159
2180
|
try {
|
|
2160
|
-
const shouldForce =
|
|
2181
|
+
const shouldForce = prevLocalFallback !== fallback;
|
|
2161
2182
|
if (isHydrating$1) withHydratingSlotBoundary(() => {
|
|
2162
2183
|
const prev = isHydratingSlotFallbackActive();
|
|
2163
2184
|
try {
|
|
2164
2185
|
if (hasSlotFallback(boundary)) setCurrentHydratingSlotFallbackActive(true);
|
|
2165
|
-
this.
|
|
2166
|
-
const contentValid = isValidBlock(this.
|
|
2186
|
+
this.updateContent(slotRender, key);
|
|
2187
|
+
const contentValid = isValidBlock(this.content);
|
|
2167
2188
|
recheckSlotFallback(this, shouldForce);
|
|
2168
2189
|
if (!hasSlotFallback(boundary) || contentValid) setCurrentHydratingSlotFallbackActive(prev);
|
|
2169
|
-
this.hydrate(!isValidBlock(this.
|
|
2190
|
+
this.hydrate(!isValidBlock(this.nodes));
|
|
2170
2191
|
} finally {
|
|
2171
2192
|
setCurrentHydratingSlotFallbackActive(prev);
|
|
2172
2193
|
}
|
|
2173
2194
|
});
|
|
2174
2195
|
else {
|
|
2175
|
-
this.
|
|
2196
|
+
this.updateContent(slotRender, key);
|
|
2176
2197
|
recheckSlotFallback(this, shouldForce);
|
|
2177
2198
|
}
|
|
2178
2199
|
} finally {
|
|
@@ -2181,7 +2202,7 @@ var SlotFragment = class extends DynamicFragment {
|
|
|
2181
2202
|
}
|
|
2182
2203
|
}
|
|
2183
2204
|
getContent() {
|
|
2184
|
-
return this.
|
|
2205
|
+
return this.content;
|
|
2185
2206
|
}
|
|
2186
2207
|
getParentNode() {
|
|
2187
2208
|
return this.anchor ? this.anchor.parentNode : null;
|
|
@@ -2195,16 +2216,28 @@ var SlotFragment = class extends DynamicFragment {
|
|
|
2195
2216
|
isDisposed() {
|
|
2196
2217
|
return this.disposed;
|
|
2197
2218
|
}
|
|
2219
|
+
isContentValid() {
|
|
2220
|
+
return isValidBlock(this.content);
|
|
2221
|
+
}
|
|
2222
|
+
syncNodes() {
|
|
2223
|
+
this.nodes = this.activeFallback || this.content;
|
|
2224
|
+
}
|
|
2198
2225
|
notifyFallbackValidityChange() {
|
|
2199
|
-
if (this.parentSlotBoundary) this.parentSlotBoundary.markDirty();
|
|
2226
|
+
if (this.notifyParent && this.parentSlotBoundary) this.parentSlotBoundary.markDirty();
|
|
2200
2227
|
}
|
|
2201
2228
|
};
|
|
2202
2229
|
function isFragment(val) {
|
|
2203
2230
|
return val instanceof VaporFragment;
|
|
2204
2231
|
}
|
|
2232
|
+
function isInteropFragment(val) {
|
|
2233
|
+
return val instanceof VaporFragment && val.vnode !== void 0;
|
|
2234
|
+
}
|
|
2205
2235
|
function isDynamicFragment(val) {
|
|
2206
2236
|
return val instanceof DynamicFragment;
|
|
2207
2237
|
}
|
|
2238
|
+
function isSlotFragment(val) {
|
|
2239
|
+
return val instanceof DynamicFragment && !!val.isSlot;
|
|
2240
|
+
}
|
|
2208
2241
|
//#endregion
|
|
2209
2242
|
//#region packages/runtime-vapor/src/teleport.ts
|
|
2210
2243
|
let isTeleportEnabled = false;
|
|
@@ -2229,11 +2262,9 @@ function isValidBlock(block) {
|
|
|
2229
2262
|
else if (isVaporComponent(block)) return isValidBlock(block.block);
|
|
2230
2263
|
else if (isArray(block)) return block.length > 0 && block.some(isValidBlock);
|
|
2231
2264
|
else {
|
|
2232
|
-
|
|
2233
|
-
if (isBlockValid) return isBlockValid.call(block);
|
|
2265
|
+
if (isInteropEnabled && block.isBlockValid) return block.isBlockValid();
|
|
2234
2266
|
if (block.validityPending) return true;
|
|
2235
|
-
|
|
2236
|
-
return isValidBlock(getEffectiveOutput ? getEffectiveOutput.call(block) : block.nodes);
|
|
2267
|
+
return isValidBlock(block.nodes);
|
|
2237
2268
|
}
|
|
2238
2269
|
}
|
|
2239
2270
|
function insert(block, parent, anchor = null, parentSuspense) {
|
|
@@ -2320,7 +2351,7 @@ function normalizeBlock(block) {
|
|
|
2320
2351
|
}
|
|
2321
2352
|
return nodes;
|
|
2322
2353
|
}
|
|
2323
|
-
function
|
|
2354
|
+
function findBlockBoundary(block) {
|
|
2324
2355
|
const lastChild = findLastChild(block);
|
|
2325
2356
|
let { parentNode, nextSibling: nextNode } = lastChild;
|
|
2326
2357
|
if (nextNode && isComment(nextNode, "]") && isFragmentBlock(block) && !isComment(lastChild, "]")) nextNode = nextNode.nextSibling;
|
|
@@ -2347,73 +2378,42 @@ function isFragmentBlock(block) {
|
|
|
2347
2378
|
//#endregion
|
|
2348
2379
|
//#region packages/runtime-vapor/src/hmr.ts
|
|
2349
2380
|
function hmrRerender(instance) {
|
|
2350
|
-
const
|
|
2351
|
-
const parent =
|
|
2352
|
-
|
|
2353
|
-
|
|
2381
|
+
const { parentNode, nextNode: anchor } = findBlockBoundary(instance.block);
|
|
2382
|
+
const parent = parentNode;
|
|
2383
|
+
if (instance.renderEffects) {
|
|
2384
|
+
instance.renderEffects.forEach((e) => e.stop());
|
|
2385
|
+
instance.renderEffects.length = 0;
|
|
2386
|
+
}
|
|
2354
2387
|
remove(instance.block, parent);
|
|
2355
2388
|
const prev = setCurrentInstance(instance);
|
|
2356
2389
|
pushWarningContext(instance);
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2390
|
+
try {
|
|
2391
|
+
devRender(instance);
|
|
2392
|
+
} finally {
|
|
2393
|
+
popWarningContext();
|
|
2394
|
+
setCurrentInstance(...prev);
|
|
2395
|
+
}
|
|
2360
2396
|
insert(instance.block, parent, anchor);
|
|
2361
2397
|
}
|
|
2362
2398
|
function hmrReload(instance, newComp) {
|
|
2363
|
-
|
|
2364
|
-
|
|
2399
|
+
const parentInstance = instance.parent;
|
|
2400
|
+
if (parentInstance) {
|
|
2401
|
+
parentInstance.hmrRerender();
|
|
2365
2402
|
return;
|
|
2366
2403
|
}
|
|
2367
|
-
const
|
|
2368
|
-
const parent =
|
|
2369
|
-
const anchor = normalized[normalized.length - 1].nextSibling;
|
|
2404
|
+
const { parentNode, nextNode: anchor } = findBlockBoundary(instance.block);
|
|
2405
|
+
const parent = parentNode;
|
|
2370
2406
|
unmountComponent(instance, parent);
|
|
2371
|
-
const parentInstance = instance.parent;
|
|
2372
2407
|
const prev = setCurrentInstance(parentInstance);
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
}
|
|
2379
|
-
/**
|
|
2380
|
-
* dev only
|
|
2381
|
-
* update parentInstance.block to ensure that the correct parent and
|
|
2382
|
-
* anchor are found during parentInstance HMR rerender/reload, as
|
|
2383
|
-
* `normalizeBlock` relies on the current instance.block
|
|
2384
|
-
*/
|
|
2385
|
-
function updateParentBlockOnHmrReload(parentInstance, instance, newInstance) {
|
|
2386
|
-
if (parentInstance) parentInstance.block = replaceBlockInstance(parentInstance.block, instance, newInstance);
|
|
2387
|
-
}
|
|
2388
|
-
/**
|
|
2389
|
-
* dev only
|
|
2390
|
-
* during root component HMR reload, since the old component will be unmounted
|
|
2391
|
-
* and a new one will be mounted, we need to update the teleport's nodes
|
|
2392
|
-
* to ensure that the correct parent and anchor are found during parentInstance
|
|
2393
|
-
* HMR rerender/reload, as `normalizeBlock` relies on the current instance.block
|
|
2394
|
-
*/
|
|
2395
|
-
function updateParentTeleportOnHmrReload(instance, newInstance) {
|
|
2396
|
-
const teleport = instance.parentTeleport;
|
|
2397
|
-
if (teleport) {
|
|
2398
|
-
newInstance.parentTeleport = teleport;
|
|
2399
|
-
teleport.nodes = replaceBlockInstance(teleport.nodes, instance, newInstance);
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
function replaceBlockInstance(block, instance, newInstance) {
|
|
2403
|
-
if (block === instance) return newInstance;
|
|
2404
|
-
if (isArray(block)) {
|
|
2405
|
-
for (let i = 0; i < block.length; i++) block[i] = replaceBlockInstance(block[i], instance, newInstance);
|
|
2406
|
-
return block;
|
|
2407
|
-
}
|
|
2408
|
-
if (isVaporComponent(block)) {
|
|
2409
|
-
block.block = replaceBlockInstance(block.block, instance, newInstance);
|
|
2410
|
-
return block;
|
|
2411
|
-
}
|
|
2412
|
-
if (isFragment(block)) {
|
|
2413
|
-
block.nodes = replaceBlockInstance(block.nodes, instance, newInstance);
|
|
2414
|
-
return block;
|
|
2408
|
+
let newInstance;
|
|
2409
|
+
try {
|
|
2410
|
+
newInstance = createComponent(newComp, instance.rawProps, instance.rawSlots, instance.isSingleRoot, void 0, instance.appContext);
|
|
2411
|
+
} finally {
|
|
2412
|
+
setCurrentInstance(...prev);
|
|
2415
2413
|
}
|
|
2416
|
-
|
|
2414
|
+
mountComponent(newInstance, parent, anchor);
|
|
2415
|
+
const app = instance.appContext.app;
|
|
2416
|
+
if (app && app._instance === instance) app._instance = newInstance;
|
|
2417
2417
|
}
|
|
2418
2418
|
//#endregion
|
|
2419
2419
|
//#region packages/runtime-vapor/src/suspense.ts
|
|
@@ -2431,10 +2431,7 @@ function setParentSuspense(suspense) {
|
|
|
2431
2431
|
}
|
|
2432
2432
|
//#endregion
|
|
2433
2433
|
//#region packages/runtime-vapor/src/component.ts
|
|
2434
|
-
function
|
|
2435
|
-
return rawSlots && isFunction(rawSlots) ? { default: rawSlots } : rawSlots;
|
|
2436
|
-
}
|
|
2437
|
-
function createComponent(component, rawProps, rawSlots, isSingleRoot, once, appContext = currentInstance && currentInstance.appContext || emptyContext, managedMount = false) {
|
|
2434
|
+
function createComponent(component, rawProps, rawSlots, isSingleRoot, once, appContext = currentInstance && currentInstance.appContext || emptyContext, managedMount = false, ce) {
|
|
2438
2435
|
const wasInOnceSlot = inOnceSlot;
|
|
2439
2436
|
if (wasInOnceSlot) once = true;
|
|
2440
2437
|
if (isInteropEnabled && isCollectingVdomSlotVNodes) {
|
|
@@ -2492,7 +2489,7 @@ function createComponent(component, rawProps, rawSlots, isSingleRoot, once, appC
|
|
|
2492
2489
|
} else frag.hydrate();
|
|
2493
2490
|
return frag;
|
|
2494
2491
|
}
|
|
2495
|
-
const instance = new VaporComponentInstance(component, rawProps, rawSlots, appContext, once);
|
|
2492
|
+
const instance = new VaporComponentInstance(component, rawProps, rawSlots, appContext, once, ce);
|
|
2496
2493
|
if (isKeepAliveEnabled && currentKeepAliveCtx && !isAsyncWrapper(instance)) {
|
|
2497
2494
|
currentKeepAliveCtx.processShapeFlag(instance);
|
|
2498
2495
|
setCurrentKeepAliveCtx(null);
|
|
@@ -2534,7 +2531,7 @@ function createComponent(component, rawProps, rawSlots, isSingleRoot, once, appC
|
|
|
2534
2531
|
if (isSuspenseEnabled && isHydrating$1 && hydrationClose && instance.suspense && instance.asyncDep && !instance.asyncResolved && instance.restoreAsyncContext) {
|
|
2535
2532
|
deferHydrationBoundary = true;
|
|
2536
2533
|
instance.deferredHydrationBoundary = () => {
|
|
2537
|
-
if (instance.block && hydrationClose &&
|
|
2534
|
+
if (instance.block && hydrationClose && findBlockBoundary(instance.block).nextNode === hydrationClose.nextSibling) setCurrentHydrationNode(hydrationClose);
|
|
2538
2535
|
finalizeHydrationBoundary();
|
|
2539
2536
|
};
|
|
2540
2537
|
exitHydrationCursor(hydrationCursor);
|
|
@@ -2616,7 +2613,7 @@ const emptyContext = {
|
|
|
2616
2613
|
provides: /* @__PURE__ */ Object.create(null)
|
|
2617
2614
|
};
|
|
2618
2615
|
var VaporComponentInstance = class {
|
|
2619
|
-
constructor(comp, rawProps, rawSlots, appContext, once) {
|
|
2616
|
+
constructor(comp, rawProps, rawSlots, appContext, once, ce) {
|
|
2620
2617
|
this.accessedAttrs = false;
|
|
2621
2618
|
this.vapor = true;
|
|
2622
2619
|
this.uid = nextUid();
|
|
@@ -2662,9 +2659,9 @@ var VaporComponentInstance = class {
|
|
|
2662
2659
|
} else this.props = this.attrs = EMPTY_OBJ;
|
|
2663
2660
|
const normalizedRawSlots = normalizeRawSlots(rawSlots);
|
|
2664
2661
|
this.rawSlots = normalizedRawSlots || EMPTY_OBJ;
|
|
2665
|
-
this.slots = normalizedRawSlots ?
|
|
2662
|
+
this.slots = normalizedRawSlots ? new Proxy(normalizedRawSlots, dynamicSlotsProxyHandlers) : EMPTY_OBJ;
|
|
2666
2663
|
this.scopeId = getCurrentScopeId();
|
|
2667
|
-
if (
|
|
2664
|
+
if (ce) ce(this);
|
|
2668
2665
|
if (!!(process.env.NODE_ENV !== "production")) if (this.props === this.attrs) this.accessedAttrs = true;
|
|
2669
2666
|
else {
|
|
2670
2667
|
const attrs = this.attrs;
|
|
@@ -2798,7 +2795,7 @@ function mountComponent(instance, parent, anchor) {
|
|
|
2798
2795
|
if (!isHydrating$1) {
|
|
2799
2796
|
insert(instance.block, parent, anchor);
|
|
2800
2797
|
setComponentScopeId(instance);
|
|
2801
|
-
}
|
|
2798
|
+
} else trackComponentScopeId(instance);
|
|
2802
2799
|
if (instance.m) queuePostFlushCb(instance.m);
|
|
2803
2800
|
if (isKeepAliveEnabled && instance.shapeFlag & 256 && instance.a) queuePostFlushCb(instance.a);
|
|
2804
2801
|
instance.isMounted = true;
|
|
@@ -2864,27 +2861,65 @@ function handleSetupResult(setupResult, component, instance) {
|
|
|
2864
2861
|
else if (setupResult === EMPTY_OBJ && component.render) instance.block = callRender(component.render, instance, setupResult);
|
|
2865
2862
|
else instance.block = setupResult;
|
|
2866
2863
|
if (instance.hasFallthrough && component.inheritAttrs !== false && Object.keys(instance.attrs).length) {
|
|
2867
|
-
const
|
|
2868
|
-
|
|
2869
|
-
|
|
2864
|
+
const getFallthroughAttrs = isFunction(component) && !(isTransitionEnabled ? isVaporTransition(component) : false) ? () => getFunctionalFallthrough(instance.attrs) : () => instance.attrs;
|
|
2865
|
+
applyFallthroughAttrs(instance.block, instance, getFallthroughAttrs);
|
|
2866
|
+
}
|
|
2867
|
+
if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
|
|
2868
|
+
}
|
|
2869
|
+
function applyFallthroughAttrs(block, instance, getFallthroughAttrs, scope) {
|
|
2870
|
+
let hasSlotFragment = false;
|
|
2871
|
+
let dynamicFragments;
|
|
2872
|
+
const root = getRootElement(block, (frag) => {
|
|
2873
|
+
if (frag.isSlot) hasSlotFragment = true;
|
|
2874
|
+
else (dynamicFragments || (dynamicFragments = [])).push(frag);
|
|
2875
|
+
}, false);
|
|
2876
|
+
const dynamicRoot = root ? void 0 : getSingleDynamicRootChain(block);
|
|
2877
|
+
const fragmentsToRegister = root ? dynamicFragments : dynamicRoot && dynamicRoot.fragments;
|
|
2878
|
+
if (fragmentsToRegister) {
|
|
2879
|
+
for (const frag of fragmentsToRegister) if (!frag.isSlot) registerDynamicFragmentFallthroughAttrs(frag, instance, getFallthroughAttrs);
|
|
2880
|
+
}
|
|
2881
|
+
if (root && !hasSlotFragment) {
|
|
2882
|
+
const applyEffect = () => renderEffect(() => {
|
|
2883
|
+
const attrs = getFallthroughAttrs();
|
|
2870
2884
|
if (attrs) applyFallthroughProps(root, attrs);
|
|
2871
2885
|
});
|
|
2872
|
-
|
|
2886
|
+
scope ? scope.run(applyEffect) : applyEffect();
|
|
2887
|
+
} else if (!!(process.env.NODE_ENV !== "production") && (hasSlotFragment || dynamicRoot && dynamicRoot.hasNonSingleRoot || isTeleportEnabled && containsTeleportFragment(block) || !instance.accessedAttrs && isArray(block) && block.length)) warnExtraneousAttributes(instance.attrs);
|
|
2888
|
+
}
|
|
2889
|
+
function getSingleDynamicRootChain(block) {
|
|
2890
|
+
if (block instanceof DynamicFragment) {
|
|
2891
|
+
const { nodes } = block;
|
|
2892
|
+
const nested = getSingleDynamicRootChain(nodes);
|
|
2893
|
+
return {
|
|
2894
|
+
fragments: nested ? [block, ...nested.fragments] : [block],
|
|
2895
|
+
hasNonSingleRoot: nested ? nested.hasNonSingleRoot : isArray(nodes) && nodes.some((child) => !(child instanceof Comment))
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
if (isFragment(block) && !(isTeleportEnabled && isTeleportFragment(block))) return getSingleDynamicRootChain(block.nodes);
|
|
2899
|
+
if (isArray(block)) {
|
|
2900
|
+
let singleRoot;
|
|
2901
|
+
let hasComment = false;
|
|
2902
|
+
for (const child of block) {
|
|
2903
|
+
if (child instanceof Comment) {
|
|
2904
|
+
hasComment = true;
|
|
2905
|
+
continue;
|
|
2906
|
+
}
|
|
2907
|
+
const childRoot = getSingleDynamicRootChain(child);
|
|
2908
|
+
if (!childRoot || singleRoot) return;
|
|
2909
|
+
singleRoot = childRoot;
|
|
2910
|
+
}
|
|
2911
|
+
return hasComment ? singleRoot : void 0;
|
|
2873
2912
|
}
|
|
2874
|
-
if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
|
|
2875
2913
|
}
|
|
2876
|
-
function
|
|
2877
|
-
|
|
2878
|
-
|
|
2914
|
+
function containsTeleportFragment(block) {
|
|
2915
|
+
if (isTeleportFragment(block)) return true;
|
|
2916
|
+
if (isArray(block)) return block.some((child) => !(child instanceof Comment) && containsTeleportFragment(child));
|
|
2917
|
+
return isFragment(block) && containsTeleportFragment(block.nodes);
|
|
2879
2918
|
}
|
|
2880
|
-
function registerDynamicFragmentFallthroughAttrs(frag,
|
|
2919
|
+
function registerDynamicFragmentFallthroughAttrs(frag, instance, getFallthroughAttrs) {
|
|
2920
|
+
if (frag.hasFallthroughAttrs) return;
|
|
2881
2921
|
frag.hasFallthroughAttrs = true;
|
|
2882
|
-
(frag.onBeforeInsert || (frag.onBeforeInsert = [])).push((nodes) =>
|
|
2883
|
-
if (nodes instanceof Element) frag.scope.run(() => {
|
|
2884
|
-
renderEffect(() => applyFallthroughProps(nodes, attrs));
|
|
2885
|
-
});
|
|
2886
|
-
else if (!!(process.env.NODE_ENV !== "production") && (frag.anchorLabel === "slot" || isArray(nodes) && nodes.length)) warnExtraneousAttributes(attrs);
|
|
2887
|
-
});
|
|
2922
|
+
(frag.onBeforeInsert || (frag.onBeforeInsert = [])).push((nodes) => applyFallthroughAttrs(nodes, instance, getFallthroughAttrs, frag.scope));
|
|
2888
2923
|
}
|
|
2889
2924
|
//#endregion
|
|
2890
2925
|
//#region packages/runtime-vapor/src/apiCreateApp.ts
|
|
@@ -2994,17 +3029,20 @@ function defineVaporAsyncComponent(source) {
|
|
|
2994
3029
|
frag.update(() => createInnerComp(resolvedComp, instance));
|
|
2995
3030
|
return frag;
|
|
2996
3031
|
}
|
|
3032
|
+
frag.validityPending = true;
|
|
2997
3033
|
const onError = (err) => {
|
|
2998
3034
|
setPendingRequest(null);
|
|
2999
3035
|
handleError(err, instance, 13, !errorComponent);
|
|
3000
3036
|
};
|
|
3001
3037
|
if (suspensible && instance.suspense) return load().then(() => {
|
|
3002
3038
|
resolvedComp = getResolvedComp();
|
|
3039
|
+
frag.validityPending = false;
|
|
3003
3040
|
if (resolvedComp) frag.update(() => createInnerComp(resolvedComp, instance));
|
|
3004
3041
|
return frag;
|
|
3005
3042
|
}).catch((err) => {
|
|
3006
3043
|
onError(err);
|
|
3007
|
-
|
|
3044
|
+
frag.validityPending = false;
|
|
3045
|
+
if (errorComponent) frag.update(() => createErrorComp(errorComponent, instance, err));
|
|
3008
3046
|
return frag;
|
|
3009
3047
|
});
|
|
3010
3048
|
const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError);
|
|
@@ -3018,8 +3056,11 @@ function defineVaporAsyncComponent(source) {
|
|
|
3018
3056
|
resolvedComp = getResolvedComp();
|
|
3019
3057
|
let render;
|
|
3020
3058
|
if (loaded.value && resolvedComp) render = () => createInnerComp(resolvedComp, instance);
|
|
3021
|
-
else if (error.value && errorComponent)
|
|
3022
|
-
|
|
3059
|
+
else if (error.value && errorComponent) {
|
|
3060
|
+
const err = error.value;
|
|
3061
|
+
render = () => createErrorComp(errorComponent, instance, err);
|
|
3062
|
+
} else if (loadingComponent && !delayed.value) render = () => createInnerComp(loadingComponent, instance);
|
|
3063
|
+
frag.validityPending = !render && !error.value;
|
|
3023
3064
|
frag.update(render);
|
|
3024
3065
|
if (isKeepAliveEnabled && frag.keepAliveCtx) frag.keepAliveCtx.cacheBlock();
|
|
3025
3066
|
});
|
|
@@ -3027,6 +3068,9 @@ function defineVaporAsyncComponent(source) {
|
|
|
3027
3068
|
}
|
|
3028
3069
|
});
|
|
3029
3070
|
}
|
|
3071
|
+
function createErrorComp(comp, parent, error) {
|
|
3072
|
+
return createInnerComp(comp, parent, { error: () => error }, {});
|
|
3073
|
+
}
|
|
3030
3074
|
function createInnerComp(comp, parent, rawProps = parent.rawProps, rawSlots = parent.rawSlots) {
|
|
3031
3075
|
const prevInstance = setCurrentInstance(parent);
|
|
3032
3076
|
try {
|
|
@@ -3248,7 +3292,7 @@ function applyResolvedTransitionHooks(block, hooks) {
|
|
|
3248
3292
|
if (block.length === 1) block = block[0];
|
|
3249
3293
|
else if (block.length === 0) return { hooks };
|
|
3250
3294
|
}
|
|
3251
|
-
if (hooks.applyGroup && (block instanceof ForFragment || block
|
|
3295
|
+
if (hooks.applyGroup && (block instanceof ForFragment || isSlotFragment(block) || isVaporComponent(block) && isSlotFragment(block.block))) {
|
|
3252
3296
|
hooks.applyGroup(block, hooks.props, hooks.state, hooks.instance);
|
|
3253
3297
|
return { hooks };
|
|
3254
3298
|
}
|
|
@@ -3461,7 +3505,7 @@ const VaporKeepAlive = /* @__PURE__ */ withKeepAliveEnabled(/* @__PURE__ */ defi
|
|
|
3461
3505
|
cache.forEach((cached) => {
|
|
3462
3506
|
unsetShapeFlag(cached);
|
|
3463
3507
|
if (cached !== current) {
|
|
3464
|
-
const parentNode =
|
|
3508
|
+
const parentNode = findBlockBoundary(cached).parentNode;
|
|
3465
3509
|
if (parentNode) remove(cached, parentNode);
|
|
3466
3510
|
}
|
|
3467
3511
|
});
|
|
@@ -3553,7 +3597,7 @@ const VaporKeepAlive = /* @__PURE__ */ withKeepAliveEnabled(/* @__PURE__ */ defi
|
|
|
3553
3597
|
const cached = cache.get(key);
|
|
3554
3598
|
if (cached && (!current || cached !== current)) {
|
|
3555
3599
|
unsetShapeFlag(cached);
|
|
3556
|
-
const parentNode =
|
|
3600
|
+
const parentNode = findBlockBoundary(cached).parentNode;
|
|
3557
3601
|
if (parentNode) remove(cached, parentNode);
|
|
3558
3602
|
} else if (current) unsetShapeFlag(current);
|
|
3559
3603
|
cache.delete(key);
|
|
@@ -3685,9 +3729,6 @@ function getInnerBlock(block) {
|
|
|
3685
3729
|
else if (isFragment(block)) return getInnerBlock(block.nodes);
|
|
3686
3730
|
return [void 0, false];
|
|
3687
3731
|
}
|
|
3688
|
-
function isInteropFragment(block) {
|
|
3689
|
-
return !!(isFragment(block) && block.vnode);
|
|
3690
|
-
}
|
|
3691
3732
|
function getInstanceFromCache(cached) {
|
|
3692
3733
|
if (isVaporComponent(cached)) return cached;
|
|
3693
3734
|
if (isInteropEnabled) return cached.vnode.component;
|
|
@@ -3713,6 +3754,8 @@ function deactivate$1(instance, container) {
|
|
|
3713
3754
|
}
|
|
3714
3755
|
//#endregion
|
|
3715
3756
|
//#region packages/runtime-vapor/src/vdomInterop.ts
|
|
3757
|
+
const EMPTY_BLOCK = EMPTY_ARR;
|
|
3758
|
+
const EMPTY_VNODES = EMPTY_ARR;
|
|
3716
3759
|
function filterReservedProps(props) {
|
|
3717
3760
|
const filtered = {};
|
|
3718
3761
|
for (const key in props) if (!isReservedProp(key)) filtered[key] = props[key];
|
|
@@ -3720,7 +3763,7 @@ function filterReservedProps(props) {
|
|
|
3720
3763
|
}
|
|
3721
3764
|
const vaporInteropImpl = {
|
|
3722
3765
|
mount(vnode, container, anchor, parentComponent, parentSuspense, onBeforeMount, onVnodeBeforeMount) {
|
|
3723
|
-
|
|
3766
|
+
const selfAnchor = vnode.anchor = /* @__PURE__ */ createTextNode();
|
|
3724
3767
|
if (isHydrating$1) queuePostFlushCb(() => container.insertBefore(selfAnchor, anchor));
|
|
3725
3768
|
else {
|
|
3726
3769
|
vnode.el = selfAnchor;
|
|
@@ -3794,14 +3837,14 @@ const vaporInteropImpl = {
|
|
|
3794
3837
|
const anchor = vnode.anchor;
|
|
3795
3838
|
unmountComponent(instance, container);
|
|
3796
3839
|
if (!doRemove) {
|
|
3797
|
-
const blockContainer =
|
|
3840
|
+
const blockContainer = needsHostParentForRemove(instance.block) ? anchor && anchor.parentNode : void 0;
|
|
3798
3841
|
remove(instance.block, blockContainer);
|
|
3799
3842
|
}
|
|
3800
3843
|
}
|
|
3801
3844
|
} else if (vnode.vb) {
|
|
3802
3845
|
const anchor = vnode.anchor;
|
|
3803
3846
|
if (vnode.el && vnode.el !== anchor && isComment(vnode.el, "[")) slotStartAnchor = vnode.el;
|
|
3804
|
-
const blockContainer = container || (
|
|
3847
|
+
const blockContainer = container || (needsHostParentForRemove(vnode.vb) ? anchor && anchor.parentNode : void 0);
|
|
3805
3848
|
remove(vnode.vb, blockContainer);
|
|
3806
3849
|
stopVaporSlotScope(vnode);
|
|
3807
3850
|
}
|
|
@@ -3946,26 +3989,35 @@ const vaporSlotPropsProxyHandler = {
|
|
|
3946
3989
|
}
|
|
3947
3990
|
};
|
|
3948
3991
|
const vaporSlotWrappersCache = /* @__PURE__ */ new WeakMap();
|
|
3949
|
-
const vaporSlotsProxyHandler = {
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
slot
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3992
|
+
const vaporSlotsProxyHandler = {
|
|
3993
|
+
get(target, key) {
|
|
3994
|
+
const slot = isString(key) && !isInternalSlotKey(key) ? getSlot(target, key) : target[key];
|
|
3995
|
+
if (isFunction(slot)) {
|
|
3996
|
+
slot.__vapor = true;
|
|
3997
|
+
let wrappers = vaporSlotWrappersCache.get(target);
|
|
3998
|
+
if (!wrappers) vaporSlotWrappersCache.set(target, wrappers = /* @__PURE__ */ new Map());
|
|
3999
|
+
const cached = wrappers.get(key);
|
|
4000
|
+
if (cached && cached.slot === slot) return cached.wrapped;
|
|
4001
|
+
const wrapped = (props) => {
|
|
4002
|
+
return normalizeVaporSlotVNodes(slot, props) || [renderSlot({ [key]: slot }, key, props)];
|
|
4003
|
+
};
|
|
4004
|
+
wrapped.__vs = slot;
|
|
4005
|
+
wrappers.set(key, {
|
|
4006
|
+
slot,
|
|
4007
|
+
wrapped
|
|
4008
|
+
});
|
|
4009
|
+
return wrapped;
|
|
4010
|
+
}
|
|
4011
|
+
return slot;
|
|
4012
|
+
},
|
|
4013
|
+
ownKeys(target) {
|
|
4014
|
+
return Array.from(dynamicSlotsProxyHandlers.ownKeys(target)).filter((key) => isString(key) && !isInternalSlotKey(key));
|
|
4015
|
+
},
|
|
4016
|
+
getOwnPropertyDescriptor(target, key) {
|
|
4017
|
+
if (!isString(key) || isInternalSlotKey(key)) return;
|
|
4018
|
+
return dynamicSlotsProxyHandlers.getOwnPropertyDescriptor(target, key);
|
|
3966
4019
|
}
|
|
3967
|
-
|
|
3968
|
-
} };
|
|
4020
|
+
};
|
|
3969
4021
|
const collectedVdomSlotVNodes = /* @__PURE__ */ new WeakMap();
|
|
3970
4022
|
function normalizeVaporSlotVNodes(slot, props) {
|
|
3971
4023
|
if (props && hasVNodeSlotProps(props)) return;
|
|
@@ -4047,38 +4099,43 @@ function removeAttachedNodes(block, parent) {
|
|
|
4047
4099
|
if (block.parentNode === parent) remove(block, parent);
|
|
4048
4100
|
} else if (isArray(block)) for (let i = 0; i < block.length; i++) removeAttachedNodes(block[i], parent);
|
|
4049
4101
|
}
|
|
4050
|
-
function
|
|
4051
|
-
const props = vnode.props || (vnode.props = {});
|
|
4052
|
-
const existing = props.onVnodeUpdated;
|
|
4053
|
-
props.onVnodeUpdated = existing ? isArray(existing) ? [...existing, hook] : [existing, hook] : hook;
|
|
4054
|
-
}
|
|
4055
|
-
function appendVnodeBeforeUpdateHook(vnode, hook) {
|
|
4102
|
+
function appendVnodeHook(vnode, key, hook) {
|
|
4056
4103
|
const props = vnode.props || (vnode.props = {});
|
|
4057
|
-
const existing = props
|
|
4058
|
-
props
|
|
4104
|
+
const existing = props[key];
|
|
4105
|
+
props[key] = existing ? isArray(existing) ? [...existing, hook] : [existing, hook] : hook;
|
|
4059
4106
|
}
|
|
4060
|
-
function trackFragmentVNodeUpdates(frag, vnode) {
|
|
4107
|
+
function trackFragmentVNodeUpdates(frag, vnode, syncNodes) {
|
|
4061
4108
|
const beforeUpdate = () => {
|
|
4062
|
-
if (frag.onBeforeUpdate)
|
|
4109
|
+
if (frag.onBeforeUpdate) frag.onBeforeUpdate.forEach((bu) => bu());
|
|
4063
4110
|
};
|
|
4064
4111
|
const updated = () => {
|
|
4112
|
+
syncNodes();
|
|
4113
|
+
if (frag.onUpdated) frag.onUpdated.forEach((u) => u());
|
|
4114
|
+
};
|
|
4115
|
+
appendVnodeHook(vnode, "onVnodeBeforeUpdate", beforeUpdate);
|
|
4116
|
+
appendVnodeHook(vnode, "onVnodeUpdated", updated);
|
|
4117
|
+
}
|
|
4118
|
+
function createVNodeFragment(vnode) {
|
|
4119
|
+
const frag = createInteropFragment(EMPTY_BLOCK, vnode);
|
|
4120
|
+
frag.$key = vnode.key;
|
|
4121
|
+
let validityPending = !isHydrating$1;
|
|
4122
|
+
const syncNodes = () => {
|
|
4065
4123
|
frag.nodes = resolveVNodeNodes(vnode);
|
|
4066
|
-
|
|
4067
|
-
|
|
4124
|
+
validityPending = false;
|
|
4125
|
+
};
|
|
4126
|
+
frag.isBlockValid = () => validityPending ? true : isValidBlock(frag.nodes);
|
|
4127
|
+
trackFragmentVNodeUpdates(frag, vnode, syncNodes);
|
|
4128
|
+
return {
|
|
4129
|
+
frag,
|
|
4130
|
+
syncNodes
|
|
4068
4131
|
};
|
|
4069
|
-
appendVnodeBeforeUpdateHook(vnode, beforeUpdate);
|
|
4070
|
-
appendVnodeUpdatedHook(vnode, updated);
|
|
4071
4132
|
}
|
|
4072
4133
|
/**
|
|
4073
4134
|
* Mount VNode in vapor
|
|
4074
4135
|
*/
|
|
4075
4136
|
function mountVNode(internals, vnode, parentComponent) {
|
|
4076
4137
|
const suspense = parentSuspense || parentComponent && parentComponent.suspense;
|
|
4077
|
-
const frag =
|
|
4078
|
-
frag.validityPending = !isHydrating$1;
|
|
4079
|
-
frag.vnode = vnode;
|
|
4080
|
-
frag.$key = vnode.key;
|
|
4081
|
-
trackFragmentVNodeUpdates(frag, vnode);
|
|
4138
|
+
const { frag, syncNodes } = createVNodeFragment(vnode);
|
|
4082
4139
|
let isMounted = false;
|
|
4083
4140
|
const unmount = (parentNode, transition) => {
|
|
4084
4141
|
if (transition) setTransitionHooks(vnode, transition);
|
|
@@ -4091,8 +4148,7 @@ function mountVNode(internals, vnode, parentComponent) {
|
|
|
4091
4148
|
hydrateVNode(vnode, parentComponent);
|
|
4092
4149
|
onScopeDispose(unmount, true);
|
|
4093
4150
|
isMounted = true;
|
|
4094
|
-
|
|
4095
|
-
frag.validityPending = false;
|
|
4151
|
+
syncNodes();
|
|
4096
4152
|
};
|
|
4097
4153
|
frag.insert = (parentNode, anchor, transition) => {
|
|
4098
4154
|
if (isHydrating$1) return;
|
|
@@ -4111,8 +4167,7 @@ function mountVNode(internals, vnode, parentComponent) {
|
|
|
4111
4167
|
} else internals.m(vnode, parentNode, anchor, 2, parentComponent);
|
|
4112
4168
|
simpleSetCurrentInstance(prev);
|
|
4113
4169
|
}
|
|
4114
|
-
|
|
4115
|
-
frag.validityPending = false;
|
|
4170
|
+
syncNodes();
|
|
4116
4171
|
if (isMounted && frag.onUpdated) frag.onUpdated.forEach((m) => m());
|
|
4117
4172
|
};
|
|
4118
4173
|
frag.remove = unmount;
|
|
@@ -4125,11 +4180,8 @@ function createVDOMComponent(internals, component, parentComponent, rawProps, ra
|
|
|
4125
4180
|
const suspense = parentSuspense || parentComponent && parentComponent.suspense;
|
|
4126
4181
|
const useBridge = shouldUseRendererBridge(component);
|
|
4127
4182
|
const comp = useBridge ? ensureRendererBridge(component) : component;
|
|
4128
|
-
const
|
|
4129
|
-
frag
|
|
4130
|
-
const vnode = frag.vnode = createVNode(comp, rawProps && extend({}, new Proxy(rawProps, rawPropsProxyHandlers)));
|
|
4131
|
-
frag.$key = vnode.key;
|
|
4132
|
-
trackFragmentVNodeUpdates(frag, vnode);
|
|
4183
|
+
const vnode = createVNode(comp, rawProps && extend({}, new Proxy(rawProps, rawPropsProxyHandlers)));
|
|
4184
|
+
const { frag, syncNodes } = createVNodeFragment(vnode);
|
|
4133
4185
|
if (!isCollectingVdomSlotVNodes && isKeepAliveEnabled && currentKeepAliveCtx) {
|
|
4134
4186
|
currentKeepAliveCtx.processShapeFlag(frag);
|
|
4135
4187
|
if (component.__asyncLoader) {
|
|
@@ -4143,7 +4195,7 @@ function createVDOMComponent(internals, component, parentComponent, rawProps, ra
|
|
|
4143
4195
|
setCurrentKeepAliveCtx(null);
|
|
4144
4196
|
}
|
|
4145
4197
|
const wrapper = new VaporComponentInstance(useBridge ? comp : { props: component.props }, rawProps, rawSlots, parentComponent ? parentComponent.appContext : void 0, once);
|
|
4146
|
-
if (isCollectingVdomSlotVNodes) collectedVdomSlotVNodes.set(frag, createCollectedVDOMSlotVNode(component, rawProps, wrapper.
|
|
4198
|
+
if (isCollectingVdomSlotVNodes) collectedVdomSlotVNodes.set(frag, createCollectedVDOMSlotVNode(component, rawProps, wrapper.rawSlots));
|
|
4147
4199
|
vnode.vi = (instance) => {
|
|
4148
4200
|
instance.props = shallowReactive(wrapper.props);
|
|
4149
4201
|
const attrs = createInternalObject();
|
|
@@ -4166,7 +4218,7 @@ function createVDOMComponent(internals, component, parentComponent, rawProps, ra
|
|
|
4166
4218
|
};
|
|
4167
4219
|
}
|
|
4168
4220
|
});
|
|
4169
|
-
instance.slots = wrapper.
|
|
4221
|
+
instance.slots = wrapper.rawSlots === EMPTY_OBJ ? EMPTY_OBJ : new Proxy(wrapper.rawSlots, vaporSlotsProxyHandler);
|
|
4170
4222
|
};
|
|
4171
4223
|
let rawRef = null;
|
|
4172
4224
|
let isMounted = false;
|
|
@@ -4197,8 +4249,7 @@ function createVDOMComponent(internals, component, parentComponent, rawProps, ra
|
|
|
4197
4249
|
if (!isHydrating$1) return;
|
|
4198
4250
|
hydrateVNode(vnode, parentComponent);
|
|
4199
4251
|
isMounted = true;
|
|
4200
|
-
|
|
4201
|
-
frag.validityPending = false;
|
|
4252
|
+
syncNodes();
|
|
4202
4253
|
};
|
|
4203
4254
|
vnode.scopeId = getCurrentScopeId() || null;
|
|
4204
4255
|
vnode.slotScopeIds = currentSlotScopeIds;
|
|
@@ -4216,8 +4267,7 @@ function createVDOMComponent(internals, component, parentComponent, rawProps, ra
|
|
|
4216
4267
|
} else internals.m(vnode, parentNode, anchor, 2, parentComponent);
|
|
4217
4268
|
simpleSetCurrentInstance(prev);
|
|
4218
4269
|
}
|
|
4219
|
-
|
|
4220
|
-
frag.validityPending = false;
|
|
4270
|
+
syncNodes();
|
|
4221
4271
|
if (isMounted && frag.onUpdated) frag.onUpdated.forEach((m) => m());
|
|
4222
4272
|
};
|
|
4223
4273
|
frag.remove = unmount;
|
|
@@ -4257,12 +4307,6 @@ function ensureRendererBridge(component) {
|
|
|
4257
4307
|
if (!bridge) rendererBridgeCache.set(component, bridge = (props, { slots }) => createVNode(component, props, slots));
|
|
4258
4308
|
return bridge;
|
|
4259
4309
|
}
|
|
4260
|
-
function trackSlotVNodeUpdates(frag, vnode) {
|
|
4261
|
-
trackSlotVNodeUpdatesWithRefresh(vnode, () => {
|
|
4262
|
-
frag.nodes = resolveVNodeNodes(vnode);
|
|
4263
|
-
if (frag.onUpdated) frag.onUpdated.forEach((m) => m());
|
|
4264
|
-
});
|
|
4265
|
-
}
|
|
4266
4310
|
function hasValidVNodeContent(vnode) {
|
|
4267
4311
|
return !!ensureValidVNode(vnode.type === Fragment && isArray(vnode.children) ? vnode.children : [vnode]);
|
|
4268
4312
|
}
|
|
@@ -4270,13 +4314,12 @@ function isSlotOutletOnlyVNode(vnode) {
|
|
|
4270
4314
|
if (vnode.type === VaporSlot) return true;
|
|
4271
4315
|
return vnode.type === Fragment && isArray(vnode.children) && vnode.children.every((child) => isVNode(child) && isSlotOutletOnlyVNode(child));
|
|
4272
4316
|
}
|
|
4273
|
-
function hydrateForwardedEmptySlotFragment(vnode, parentComponent) {
|
|
4317
|
+
function hydrateForwardedEmptySlotFragment(vnode, parentComponent, contentValid) {
|
|
4274
4318
|
if (vnode.type !== Fragment || !isArray(vnode.children)) return false;
|
|
4275
4319
|
const children = vnode.children;
|
|
4276
4320
|
const inheritedEmptySlotEndAnchor = isComment(currentHydrationNode, "]") && isComment(currentHydrationNode.previousSibling, "[") ? currentHydrationNode : null;
|
|
4277
4321
|
const slotEndAnchor = getCurrentSlotEndAnchor() || inheritedEmptySlotEndAnchor;
|
|
4278
4322
|
const slotStartAnchor = slotEndAnchor && slotEndAnchor.previousSibling;
|
|
4279
|
-
const contentValid = hasValidVNodeContent(vnode);
|
|
4280
4323
|
if (!contentValid && currentHydrationNode === slotEndAnchor && slotStartAnchor && isComment(slotStartAnchor, "[")) {
|
|
4281
4324
|
vnode.el = slotStartAnchor;
|
|
4282
4325
|
vnode.anchor = slotEndAnchor;
|
|
@@ -4300,10 +4343,11 @@ function hydrateForwardedEmptySlotFragment(vnode, parentComponent) {
|
|
|
4300
4343
|
if (currentHydrationNode === fragmentEndAnchor) advanceHydrationNode(fragmentEndAnchor);
|
|
4301
4344
|
return true;
|
|
4302
4345
|
}
|
|
4303
|
-
function trackSlotVNodeUpdatesWithRefresh(vnode, refresh) {
|
|
4346
|
+
function trackSlotVNodeUpdatesWithRefresh(vnode, refresh, beforeUpdate) {
|
|
4304
4347
|
const onUpdated = () => refresh();
|
|
4305
4348
|
const track = (node) => {
|
|
4306
|
-
|
|
4349
|
+
if (beforeUpdate) appendVnodeHook(node, "onVnodeBeforeUpdate", beforeUpdate);
|
|
4350
|
+
appendVnodeHook(node, "onVnodeUpdated", onUpdated);
|
|
4307
4351
|
if (node.type === Fragment && isArray(node.children)) node.children.forEach((child) => {
|
|
4308
4352
|
if (isVNode(child)) track(child);
|
|
4309
4353
|
});
|
|
@@ -4313,73 +4357,81 @@ function trackSlotVNodeUpdatesWithRefresh(vnode, refresh) {
|
|
|
4313
4357
|
/**
|
|
4314
4358
|
* Mount vdom slot in vapor
|
|
4315
4359
|
*/
|
|
4316
|
-
function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallback, once) {
|
|
4360
|
+
function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallback, once, slotRoot) {
|
|
4317
4361
|
const suspense = parentSuspense || parentComponent.suspense;
|
|
4318
|
-
const frag =
|
|
4319
|
-
|
|
4320
|
-
frag.validityPending = !isHydrating$1;
|
|
4362
|
+
const frag = createInteropFragment();
|
|
4363
|
+
let validityPending = !isHydrating$1;
|
|
4321
4364
|
const instance = currentInstance;
|
|
4322
4365
|
let isMounted = false;
|
|
4323
4366
|
const contentState = {
|
|
4324
|
-
nodes:
|
|
4367
|
+
nodes: EMPTY_BLOCK,
|
|
4325
4368
|
valid: false,
|
|
4326
4369
|
rendered: null
|
|
4327
4370
|
};
|
|
4328
|
-
let currentParentNode;
|
|
4329
|
-
let currentAnchor;
|
|
4371
|
+
let currentParentNode = null;
|
|
4372
|
+
let currentAnchor = null;
|
|
4330
4373
|
let disposed = false;
|
|
4331
4374
|
const scope = effectScope();
|
|
4332
4375
|
const inheritedBoundary = frag.inheritedSlotBoundary;
|
|
4333
4376
|
let isContentUpdateRecheck = false;
|
|
4334
4377
|
let localFallback;
|
|
4335
|
-
let
|
|
4378
|
+
let fallbackState;
|
|
4379
|
+
frag.isBlockValid = () => {
|
|
4380
|
+
if (validityPending) return true;
|
|
4381
|
+
return fallbackState.activeFallback ? isValidBlock(fallbackState.activeFallback) : contentState.valid;
|
|
4382
|
+
};
|
|
4336
4383
|
const boundary = {
|
|
4337
4384
|
get parent() {
|
|
4338
4385
|
return inheritedBoundary;
|
|
4339
4386
|
},
|
|
4340
4387
|
getFallback: () => localFallback,
|
|
4341
|
-
run: (fn) =>
|
|
4342
|
-
markDirty: () => markSlotFallbackDirty(
|
|
4388
|
+
run: (fn) => runWithFragmentCtx(frag, fn),
|
|
4389
|
+
markDirty: () => markSlotFallbackDirty(fallbackState)
|
|
4343
4390
|
};
|
|
4344
|
-
|
|
4391
|
+
fallbackState = {
|
|
4345
4392
|
boundary,
|
|
4346
4393
|
activeFallback: null,
|
|
4347
4394
|
pendingRecheck: false,
|
|
4348
4395
|
isRenderingFallback: false,
|
|
4349
4396
|
getContent: () => contentState.nodes,
|
|
4350
|
-
getParentNode: () =>
|
|
4351
|
-
getAnchor: () => currentAnchor
|
|
4397
|
+
getParentNode: () => currentParentNode,
|
|
4398
|
+
getAnchor: () => currentAnchor,
|
|
4399
|
+
isBusy: () => false,
|
|
4352
4400
|
isDisposed: () => disposed,
|
|
4353
4401
|
isContentValid: () => contentState.valid,
|
|
4354
|
-
|
|
4355
|
-
frag.nodes =
|
|
4402
|
+
syncNodes: () => {
|
|
4403
|
+
frag.nodes = fallbackState.activeFallback || contentState.nodes;
|
|
4356
4404
|
},
|
|
4357
4405
|
notifyFallbackValidityChange: () => {
|
|
4358
|
-
if (!isContentUpdateRecheck && inheritedBoundary) inheritedBoundary.markDirty();
|
|
4406
|
+
if (slotRoot && !isContentUpdateRecheck && inheritedBoundary) inheritedBoundary.markDirty();
|
|
4359
4407
|
}
|
|
4360
4408
|
};
|
|
4409
|
+
if (slotRoot) trackSlotBoundaryDirtying(frag);
|
|
4361
4410
|
localFallback = fallback ? once ? () => withOnceSlot(() => fallback(internals, parentComponent)) : () => fallback(internals, parentComponent) : void 0;
|
|
4362
|
-
const setRenderedContent = (rendered) => {
|
|
4411
|
+
const setRenderedContent = (rendered, knownValid) => {
|
|
4363
4412
|
contentState.rendered = rendered;
|
|
4364
4413
|
if (isVNode(rendered)) {
|
|
4365
4414
|
contentState.nodes = resolveVNodeNodes(rendered);
|
|
4366
|
-
contentState.valid = hasValidVNodeContent(rendered);
|
|
4415
|
+
contentState.valid = knownValid === void 0 ? hasValidVNodeContent(rendered) : knownValid;
|
|
4367
4416
|
} else if (rendered) {
|
|
4368
4417
|
contentState.nodes = rendered;
|
|
4369
|
-
contentState.valid = isValidBlock(rendered);
|
|
4418
|
+
contentState.valid = knownValid === void 0 ? isValidBlock(rendered) : knownValid;
|
|
4370
4419
|
} else {
|
|
4371
|
-
contentState.nodes =
|
|
4420
|
+
contentState.nodes = EMPTY_BLOCK;
|
|
4372
4421
|
contentState.valid = false;
|
|
4373
4422
|
}
|
|
4374
|
-
|
|
4423
|
+
validityPending = false;
|
|
4375
4424
|
};
|
|
4376
4425
|
const notifyUpdated = () => {
|
|
4377
|
-
if (isMounted && frag.onUpdated) frag.onUpdated.forEach((
|
|
4426
|
+
if (isMounted && frag.onUpdated) frag.onUpdated.forEach((u) => u());
|
|
4427
|
+
};
|
|
4428
|
+
const notifyBeforeUpdate = () => {
|
|
4429
|
+
if (isMounted && frag.onBeforeUpdate) frag.onBeforeUpdate.forEach((bu) => bu());
|
|
4378
4430
|
};
|
|
4379
4431
|
const recheckAfterContentUpdate = (forceFallbackRecheck = false) => {
|
|
4380
4432
|
isContentUpdateRecheck = true;
|
|
4381
4433
|
try {
|
|
4382
|
-
recheckSlotFallback(
|
|
4434
|
+
recheckSlotFallback(fallbackState, forceFallbackRecheck);
|
|
4383
4435
|
} finally {
|
|
4384
4436
|
isContentUpdateRecheck = false;
|
|
4385
4437
|
}
|
|
@@ -4390,7 +4442,7 @@ function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallb
|
|
|
4390
4442
|
};
|
|
4391
4443
|
frag.insert = (parentNode, anchor) => {
|
|
4392
4444
|
if (isHydrating$1) return;
|
|
4393
|
-
currentParentNode = parentNode
|
|
4445
|
+
currentParentNode = parentNode;
|
|
4394
4446
|
currentAnchor = anchor;
|
|
4395
4447
|
if (!isMounted) {
|
|
4396
4448
|
scope.run(render);
|
|
@@ -4398,25 +4450,25 @@ function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallb
|
|
|
4398
4450
|
} else {
|
|
4399
4451
|
if (isVNode(contentState.rendered)) internals.m(contentState.rendered, parentNode, anchor, 2, parentComponent);
|
|
4400
4452
|
else if (contentState.rendered) insert(contentState.rendered, parentNode, anchor);
|
|
4401
|
-
insertActiveSlotFallback(
|
|
4453
|
+
insertActiveSlotFallback(fallbackState);
|
|
4402
4454
|
}
|
|
4403
4455
|
notifyUpdated();
|
|
4404
4456
|
};
|
|
4405
4457
|
frag.remove = (parentNode) => {
|
|
4406
|
-
|
|
4407
|
-
currentAnchor = currentAnchor || null;
|
|
4458
|
+
if (parentNode) currentParentNode = parentNode;
|
|
4408
4459
|
scope.stop();
|
|
4409
4460
|
disposed = true;
|
|
4410
4461
|
if (isVNode(contentState.rendered)) internals.um(contentState.rendered, parentComponent, null, !!parentNode);
|
|
4411
4462
|
else if (contentState.rendered) remove(contentState.rendered, parentNode);
|
|
4412
|
-
disposeSlotFallback(
|
|
4463
|
+
disposeSlotFallback(fallbackState);
|
|
4413
4464
|
};
|
|
4414
4465
|
const render = () => {
|
|
4415
4466
|
const prev = currentInstance;
|
|
4416
4467
|
simpleSetCurrentInstance(instance);
|
|
4417
4468
|
try {
|
|
4418
4469
|
const renderSlotContent = () => {
|
|
4419
|
-
|
|
4470
|
+
notifyBeforeUpdate();
|
|
4471
|
+
runWithFragmentCtx(frag, () => withOwnedSlotBoundary(boundary, () => {
|
|
4420
4472
|
let slotContent;
|
|
4421
4473
|
let slotContentValid = false;
|
|
4422
4474
|
if (slotsRef.value) {
|
|
@@ -4434,13 +4486,20 @@ function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallb
|
|
|
4434
4486
|
if (isVNode(hydratedContent)) {
|
|
4435
4487
|
frag.vnode = hydratedContent;
|
|
4436
4488
|
frag.$key = getVNodeKey(hydratedContent);
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4489
|
+
const refreshSlotVNode = () => {
|
|
4490
|
+
frag.nodes = resolveVNodeNodes(hydratedContent);
|
|
4491
|
+
if (frag.onUpdated) frag.onUpdated.forEach((m) => m());
|
|
4492
|
+
};
|
|
4493
|
+
trackSlotVNodeUpdatesWithRefresh(hydratedContent, refreshSlotVNode, slotRoot ? notifyBeforeUpdate : void 0);
|
|
4494
|
+
if (!hydrateForwardedEmptySlotFragment(hydratedContent, parentComponent, slotContentValid)) hydrateVNode(hydratedContent, parentComponent);
|
|
4495
|
+
const hydratedEnd = hydratedContent.anchor;
|
|
4496
|
+
currentParentNode = hydratedEnd.parentNode;
|
|
4497
|
+
currentAnchor = hydratedEnd.nextSibling;
|
|
4498
|
+
setRenderedContent(hydratedContent, slotContentValid);
|
|
4440
4499
|
} else if (hydratedContent) {
|
|
4441
4500
|
frag.vnode = null;
|
|
4442
4501
|
frag.$key = void 0;
|
|
4443
|
-
setRenderedContent(hydratedContent);
|
|
4502
|
+
setRenderedContent(hydratedContent, slotContentValid);
|
|
4444
4503
|
} else {
|
|
4445
4504
|
frag.vnode = null;
|
|
4446
4505
|
frag.$key = void 0;
|
|
@@ -4452,17 +4511,20 @@ function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallb
|
|
|
4452
4511
|
if (isVNode(slotContent)) {
|
|
4453
4512
|
frag.vnode = slotContent;
|
|
4454
4513
|
frag.$key = getVNodeKey(slotContent);
|
|
4455
|
-
|
|
4514
|
+
const refreshSlotVNode = () => {
|
|
4456
4515
|
const prevValid = contentState.valid;
|
|
4457
4516
|
const prevOutput = frag.nodes;
|
|
4458
4517
|
setRenderedContent(slotContent);
|
|
4459
4518
|
recheckAfterContentUpdate();
|
|
4460
4519
|
if (contentState.valid !== prevValid || !isSameResolvedOutput(prevOutput, frag.nodes)) notifyUpdated();
|
|
4461
|
-
}
|
|
4520
|
+
};
|
|
4521
|
+
trackSlotVNodeUpdatesWithRefresh(slotContent, refreshSlotVNode, slotRoot ? notifyBeforeUpdate : void 0);
|
|
4462
4522
|
const prevRendered = contentState.rendered;
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4523
|
+
const prevIsVNode = isVNode(prevRendered);
|
|
4524
|
+
const prevVNode = prevIsVNode && (!fallbackState.activeFallback || contentState.valid) ? prevRendered : null;
|
|
4525
|
+
if (prevRendered && !prevIsVNode) remove(prevRendered, currentParentNode);
|
|
4526
|
+
internals.p(prevVNode, slotContent, currentParentNode, currentAnchor, parentComponent, suspense, void 0, slotContent.slotScopeIds);
|
|
4527
|
+
setRenderedContent(slotContent, slotContentValid);
|
|
4466
4528
|
finishContentUpdate();
|
|
4467
4529
|
return;
|
|
4468
4530
|
}
|
|
@@ -4473,7 +4535,7 @@ function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallb
|
|
|
4473
4535
|
if (isVNode(prevRendered)) internals.um(prevRendered, parentComponent, null, true);
|
|
4474
4536
|
else if (prevRendered) remove(prevRendered, currentParentNode);
|
|
4475
4537
|
insert(slotContent, currentParentNode, currentAnchor);
|
|
4476
|
-
setRenderedContent(slotContent);
|
|
4538
|
+
setRenderedContent(slotContent, slotContentValid);
|
|
4477
4539
|
finishContentUpdate();
|
|
4478
4540
|
return;
|
|
4479
4541
|
}
|
|
@@ -4493,23 +4555,25 @@ function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallb
|
|
|
4493
4555
|
frag.hydrate = () => {
|
|
4494
4556
|
if (!isHydrating$1) return;
|
|
4495
4557
|
scope.run(render);
|
|
4496
|
-
currentParentNode
|
|
4497
|
-
|
|
4558
|
+
if (!currentParentNode) {
|
|
4559
|
+
currentAnchor = getCurrentSlotEndAnchor() || currentHydrationNode;
|
|
4560
|
+
currentParentNode = currentAnchor.parentNode;
|
|
4561
|
+
}
|
|
4498
4562
|
isMounted = true;
|
|
4499
4563
|
};
|
|
4500
4564
|
return frag;
|
|
4501
4565
|
}
|
|
4502
|
-
function
|
|
4503
|
-
if (isVaporComponent(block)) return isKeepAlive(block) ||
|
|
4504
|
-
if (isArray(block)) return block.some(
|
|
4505
|
-
if (isFragment(block)) return
|
|
4566
|
+
function needsHostParentForRemove(block) {
|
|
4567
|
+
if (isVaporComponent(block)) return isKeepAlive(block) || needsHostParentForRemove(block.block);
|
|
4568
|
+
if (isArray(block)) return block.some(needsHostParentForRemove);
|
|
4569
|
+
if (isFragment(block)) return needsHostParentForRemove(block.nodes);
|
|
4506
4570
|
return false;
|
|
4507
4571
|
}
|
|
4508
4572
|
const vaporInteropPlugin = (app) => {
|
|
4509
4573
|
enableSuspense();
|
|
4510
4574
|
setInteropEnabled();
|
|
4511
4575
|
const internals = ensureRenderer().internals;
|
|
4512
|
-
app._context.vapor = extend(vaporInteropImpl, {
|
|
4576
|
+
app._context.vapor = extend({}, vaporInteropImpl, {
|
|
4513
4577
|
vdomMount: createVDOMComponent.bind(null, internals),
|
|
4514
4578
|
vdomUnmount: internals.umt,
|
|
4515
4579
|
vdomSlot: renderVDOMSlot.bind(null, internals),
|
|
@@ -4532,30 +4596,17 @@ function createFallback(fallback, parentComponent, isVNodeFallback) {
|
|
|
4532
4596
|
const internals = ensureRenderer().internals;
|
|
4533
4597
|
return () => {
|
|
4534
4598
|
if (isVNodeFallback()) {
|
|
4535
|
-
const frag = createVNodeChildrenFragment(internals, () =>
|
|
4599
|
+
const frag = createVNodeChildrenFragment(internals, () => {
|
|
4600
|
+
const children = fallback();
|
|
4601
|
+
return children == null ? EMPTY_VNODES : normalizeInteropSlotValue(children);
|
|
4602
|
+
}, parentComponent);
|
|
4536
4603
|
if (isHydrating$1 && frag.hydrate) frag.hydrate();
|
|
4537
4604
|
return frag;
|
|
4538
4605
|
}
|
|
4539
4606
|
return fallback();
|
|
4540
4607
|
};
|
|
4541
4608
|
}
|
|
4542
|
-
const renderEmptyVNodes = () =>
|
|
4543
|
-
function runWithFragmentRenderCtx(fragment, fn) {
|
|
4544
|
-
const prevSlotOwner = setCurrentSlotOwner(fragment.slotOwner);
|
|
4545
|
-
let prevKeepAliveCtx = null;
|
|
4546
|
-
if (isKeepAliveEnabled) prevKeepAliveCtx = setCurrentKeepAliveCtx(fragment.keepAliveCtx || null);
|
|
4547
|
-
try {
|
|
4548
|
-
return withOwnedSlotBoundary(fragment.inheritedSlotBoundary, fn);
|
|
4549
|
-
} finally {
|
|
4550
|
-
if (isKeepAliveEnabled) setCurrentKeepAliveCtx(prevKeepAliveCtx);
|
|
4551
|
-
setCurrentSlotOwner(prevSlotOwner);
|
|
4552
|
-
}
|
|
4553
|
-
}
|
|
4554
|
-
function getSlotFallbackParentNode(currentParentNode, content) {
|
|
4555
|
-
if (currentParentNode) return currentParentNode;
|
|
4556
|
-
const carrierAnchor = findFirstSlotFallbackCarrierNode(content);
|
|
4557
|
-
return carrierAnchor ? carrierAnchor.parentNode : null;
|
|
4558
|
-
}
|
|
4609
|
+
const renderEmptyVNodes = () => EMPTY_VNODES;
|
|
4559
4610
|
function resolveInteropVaporSlotState(vnode) {
|
|
4560
4611
|
const slot = vnode.vs;
|
|
4561
4612
|
let state = slot.state;
|
|
@@ -4603,12 +4654,14 @@ function renderVaporSlot(vnode, parentComponent, parentSuspense) {
|
|
|
4603
4654
|
simpleSetCurrentInstance(parentComponent);
|
|
4604
4655
|
if (isSuspenseEnabled && parentSuspense) prevSuspense = setParentSuspense(parentSuspense);
|
|
4605
4656
|
try {
|
|
4606
|
-
if (!vnode.vs || !vnode.vs.slot) return
|
|
4657
|
+
if (!vnode.vs || !vnode.vs.slot) return EMPTY_BLOCK;
|
|
4607
4658
|
const slotState = resolveInteropVaporSlotState(vnode);
|
|
4608
|
-
const
|
|
4609
|
-
frag
|
|
4659
|
+
const scopeIds = getInteropVaporSlotScopeIds(vnode, parentComponent);
|
|
4660
|
+
const frag = createInteropFragment();
|
|
4661
|
+
let validityPending = !isHydrating$1;
|
|
4662
|
+
frag.isBlockValid = () => validityPending ? true : isValidBlock(frag.nodes);
|
|
4610
4663
|
const inheritedBoundary = frag.inheritedSlotBoundary;
|
|
4611
|
-
let contentNodes =
|
|
4664
|
+
let contentNodes = EMPTY_BLOCK;
|
|
4612
4665
|
let isResolvingContent = false;
|
|
4613
4666
|
let localFallback;
|
|
4614
4667
|
let outletFallback;
|
|
@@ -4616,13 +4669,13 @@ function renderVaporSlot(vnode, parentComponent, parentSuspense) {
|
|
|
4616
4669
|
let currentAnchor = null;
|
|
4617
4670
|
let slotScope;
|
|
4618
4671
|
let disposed = false;
|
|
4619
|
-
let
|
|
4672
|
+
let fallbackState;
|
|
4620
4673
|
let ownedSlotFragment;
|
|
4621
4674
|
let ownedSlotFragmentDirtyQueued = false;
|
|
4622
4675
|
const markInteropFallbackDirty = () => {
|
|
4623
4676
|
const target = ownedSlotFragment;
|
|
4624
4677
|
if (!target) {
|
|
4625
|
-
markSlotFallbackDirty(
|
|
4678
|
+
markSlotFallbackDirty(fallbackState);
|
|
4626
4679
|
return;
|
|
4627
4680
|
}
|
|
4628
4681
|
if (ownedSlotFragmentDirtyQueued) return;
|
|
@@ -4630,7 +4683,6 @@ function renderVaporSlot(vnode, parentComponent, parentSuspense) {
|
|
|
4630
4683
|
queuePostFlushCb(() => {
|
|
4631
4684
|
ownedSlotFragmentDirtyQueued = false;
|
|
4632
4685
|
markSlotFallbackDirty(target);
|
|
4633
|
-
syncActiveSlotFallback(target);
|
|
4634
4686
|
});
|
|
4635
4687
|
};
|
|
4636
4688
|
const outletFallbackBoundary = {
|
|
@@ -4638,7 +4690,7 @@ function renderVaporSlot(vnode, parentComponent, parentSuspense) {
|
|
|
4638
4690
|
return inheritedBoundary;
|
|
4639
4691
|
},
|
|
4640
4692
|
getFallback: () => slotState.outletFallback.value ? outletFallback : void 0,
|
|
4641
|
-
run: (fn) =>
|
|
4693
|
+
run: (fn) => runWithFragmentCtx(frag, fn),
|
|
4642
4694
|
markDirty: markInteropFallbackDirty
|
|
4643
4695
|
};
|
|
4644
4696
|
const localFallbackBoundary = {
|
|
@@ -4646,37 +4698,38 @@ function renderVaporSlot(vnode, parentComponent, parentSuspense) {
|
|
|
4646
4698
|
return outletFallbackBoundary;
|
|
4647
4699
|
},
|
|
4648
4700
|
getFallback: () => slotState.localFallback.value ? localFallback : void 0,
|
|
4649
|
-
run: (fn) =>
|
|
4701
|
+
run: (fn) => runWithFragmentCtx(frag, fn),
|
|
4650
4702
|
markDirty: markInteropFallbackDirty
|
|
4651
4703
|
};
|
|
4652
|
-
|
|
4704
|
+
fallbackState = {
|
|
4653
4705
|
boundary: localFallbackBoundary,
|
|
4654
4706
|
activeFallback: null,
|
|
4655
4707
|
pendingRecheck: false,
|
|
4656
4708
|
isRenderingFallback: false,
|
|
4657
4709
|
getContent: () => contentNodes,
|
|
4658
|
-
getParentNode: () =>
|
|
4710
|
+
getParentNode: () => currentParentNode,
|
|
4659
4711
|
getAnchor: () => currentAnchor,
|
|
4660
4712
|
isBusy: () => isResolvingContent,
|
|
4661
4713
|
isDisposed: () => disposed,
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
frag.
|
|
4714
|
+
isContentValid: () => isValidBlock(contentNodes),
|
|
4715
|
+
syncNodes: () => {
|
|
4716
|
+
frag.nodes = fallbackState.activeFallback || contentNodes;
|
|
4717
|
+
validityPending = false;
|
|
4665
4718
|
},
|
|
4666
4719
|
notifyFallbackValidityChange: () => {
|
|
4667
4720
|
if (inheritedBoundary) inheritedBoundary.markDirty();
|
|
4668
4721
|
}
|
|
4669
4722
|
};
|
|
4670
4723
|
const takePendingRecheck = () => {
|
|
4671
|
-
const shouldRecheck =
|
|
4672
|
-
|
|
4724
|
+
const shouldRecheck = fallbackState.pendingRecheck;
|
|
4725
|
+
fallbackState.pendingRecheck = false;
|
|
4673
4726
|
return shouldRecheck;
|
|
4674
4727
|
};
|
|
4675
4728
|
const dispose = (parentNode) => {
|
|
4676
4729
|
if (disposed) return;
|
|
4677
|
-
currentParentNode = parentNode
|
|
4730
|
+
if (parentNode) currentParentNode = parentNode;
|
|
4678
4731
|
disposed = true;
|
|
4679
|
-
disposeSlotFallback(
|
|
4732
|
+
disposeSlotFallback(fallbackState);
|
|
4680
4733
|
slotScope = void 0;
|
|
4681
4734
|
currentParentNode = null;
|
|
4682
4735
|
currentAnchor = null;
|
|
@@ -4684,22 +4737,23 @@ function renderVaporSlot(vnode, parentComponent, parentSuspense) {
|
|
|
4684
4737
|
try {
|
|
4685
4738
|
localFallback = createFallback(() => (slotState.localFallback.value || renderEmptyVNodes)(), parentComponent, () => !!slotState.localFallback.value && !!slotState.localFallback.value.__vdom);
|
|
4686
4739
|
outletFallback = createFallback(() => (slotState.outletFallback.value || renderEmptyVNodes)(), parentComponent, () => !!slotState.outletFallback.value && !!slotState.outletFallback.value.__vdom);
|
|
4687
|
-
const
|
|
4688
|
-
|
|
4740
|
+
const hasInteropFallback = !!slotState.localFallback.value || !!slotState.outletFallback.value;
|
|
4741
|
+
fallbackState.pendingRecheck = false;
|
|
4689
4742
|
const finalizeResolvedContent = (resolvedContent) => {
|
|
4690
|
-
if (
|
|
4691
|
-
|
|
4692
|
-
|
|
4743
|
+
if (resolvedContent && scopeIds) setScopeId(resolvedContent, scopeIds);
|
|
4744
|
+
if (hasInteropFallback && resolvedContent instanceof SlotFragment) return resolvedContent;
|
|
4745
|
+
contentNodes = resolvedContent || EMPTY_BLOCK;
|
|
4746
|
+
recheckSlotFallback(fallbackState, takePendingRecheck());
|
|
4693
4747
|
return resolvedContent;
|
|
4694
4748
|
};
|
|
4695
4749
|
let resolvedContent;
|
|
4696
4750
|
isResolvingContent = true;
|
|
4697
4751
|
try {
|
|
4698
|
-
if (isHydrating$1) resolvedContent = withHydratingSlotBoundary(() => finalizeResolvedContent(
|
|
4752
|
+
if (isHydrating$1) resolvedContent = withHydratingSlotBoundary(() => finalizeResolvedContent(runWithFragmentCtx(frag, () => {
|
|
4699
4753
|
const renderSlot = () => withOwnedSlotBoundary(localFallbackBoundary, () => invokeVaporSlot(vnode));
|
|
4700
4754
|
return hasSlotFallback(localFallbackBoundary) ? withHydratingSlotFallbackActive(renderSlot) : renderSlot();
|
|
4701
4755
|
})));
|
|
4702
|
-
else resolvedContent = finalizeResolvedContent(
|
|
4756
|
+
else resolvedContent = finalizeResolvedContent(runWithFragmentCtx(frag, () => withOwnedSlotBoundary(localFallbackBoundary, () => invokeVaporSlot(vnode))));
|
|
4703
4757
|
} finally {
|
|
4704
4758
|
isResolvingContent = false;
|
|
4705
4759
|
}
|
|
@@ -4710,30 +4764,30 @@ function renderVaporSlot(vnode, parentComponent, parentSuspense) {
|
|
|
4710
4764
|
onScopeDispose(() => dispose(), true);
|
|
4711
4765
|
});
|
|
4712
4766
|
}
|
|
4713
|
-
if (
|
|
4767
|
+
if (hasInteropFallback && resolvedContent instanceof SlotFragment) {
|
|
4714
4768
|
ownedSlotFragment = resolvedContent;
|
|
4715
4769
|
trackInteropFallbackChanges(vnode.vs.scope, slotState, () => markInteropFallbackDirty());
|
|
4716
4770
|
dispose();
|
|
4717
4771
|
return resolvedContent;
|
|
4718
4772
|
}
|
|
4719
|
-
|
|
4773
|
+
fallbackState.pendingRecheck = false;
|
|
4720
4774
|
frag.insert = (parentNode, anchor) => {
|
|
4721
4775
|
currentParentNode = parentNode;
|
|
4722
4776
|
currentAnchor = anchor;
|
|
4723
|
-
if (
|
|
4724
|
-
|
|
4725
|
-
mutateSlotFallbackCarrier(contentNodes, (block) => insert(block, parentNode, anchor));
|
|
4726
|
-
} else insert(frag.nodes, parentNode, anchor);
|
|
4777
|
+
if (fallbackState.activeFallback) insertActiveSlotFallback(fallbackState);
|
|
4778
|
+
else insert(frag.nodes, parentNode, anchor);
|
|
4727
4779
|
};
|
|
4728
4780
|
frag.remove = (parentNode) => {
|
|
4729
|
-
if (
|
|
4730
|
-
else remove(frag.nodes, parentNode);
|
|
4781
|
+
if (!fallbackState.activeFallback) remove(frag.nodes, parentNode);
|
|
4731
4782
|
dispose(parentNode);
|
|
4732
4783
|
};
|
|
4733
4784
|
trackInteropFallbackChanges(vnode.vs.scope, slotState, () => {
|
|
4734
|
-
recheckSlotFallback(
|
|
4735
|
-
syncActiveSlotFallback(outlet);
|
|
4785
|
+
recheckSlotFallback(fallbackState, true);
|
|
4736
4786
|
});
|
|
4787
|
+
if (isHydrating$1 && currentHydrationNode) {
|
|
4788
|
+
currentAnchor = currentHydrationNode;
|
|
4789
|
+
currentParentNode = currentAnchor.parentNode;
|
|
4790
|
+
}
|
|
4737
4791
|
return frag;
|
|
4738
4792
|
} catch (e) {
|
|
4739
4793
|
dispose();
|
|
@@ -4809,24 +4863,24 @@ function ensureVNodeHookState(instance, vnode) {
|
|
|
4809
4863
|
}
|
|
4810
4864
|
function createVNodeChildrenFragment(internals, render, parentComponent) {
|
|
4811
4865
|
const suspense = parentSuspense || parentComponent && parentComponent.suspense;
|
|
4812
|
-
const frag =
|
|
4866
|
+
const frag = createInteropFragment();
|
|
4813
4867
|
let contentValid = false;
|
|
4814
|
-
|
|
4815
|
-
frag.isBlockValid = () =>
|
|
4868
|
+
let validityPending = !isHydrating$1;
|
|
4869
|
+
frag.isBlockValid = () => validityPending ? true : contentValid;
|
|
4816
4870
|
let currentVNode = null;
|
|
4817
|
-
let currentChildren =
|
|
4871
|
+
let currentChildren = EMPTY_VNODES;
|
|
4818
4872
|
let currentParentNode = null;
|
|
4819
4873
|
let currentAnchor = null;
|
|
4820
4874
|
let isMounted = false;
|
|
4821
4875
|
let isRenderEffectStarted = false;
|
|
4822
4876
|
const scope = effectScope();
|
|
4823
4877
|
const syncResolvedNodes = (children = currentChildren) => {
|
|
4824
|
-
const prevValid =
|
|
4878
|
+
const prevValid = validityPending ? true : contentValid;
|
|
4825
4879
|
contentValid = !!ensureValidVNode(children);
|
|
4826
|
-
if (children.length === 0) frag.nodes =
|
|
4880
|
+
if (children.length === 0) frag.nodes = EMPTY_BLOCK;
|
|
4827
4881
|
else if (children.length === 1) frag.nodes = resolveVNodeNodes(children[0]);
|
|
4828
4882
|
else frag.nodes = children.map(resolveVNodeNodes);
|
|
4829
|
-
|
|
4883
|
+
validityPending = false;
|
|
4830
4884
|
return prevValid !== contentValid;
|
|
4831
4885
|
};
|
|
4832
4886
|
const notifyUpdated = (validityChanged = false) => {
|
|
@@ -4838,7 +4892,7 @@ function createVNodeChildrenFragment(internals, render, parentComponent) {
|
|
|
4838
4892
|
simpleSetCurrentInstance(parentComponent);
|
|
4839
4893
|
try {
|
|
4840
4894
|
renderEffect(() => {
|
|
4841
|
-
|
|
4895
|
+
runWithFragmentCtx(frag, () => {
|
|
4842
4896
|
const nextChildren = render();
|
|
4843
4897
|
if (isHydrating$1) {
|
|
4844
4898
|
nextChildren.forEach((vnode) => hydrateVNode(vnode, parentComponent));
|
|
@@ -4850,8 +4904,9 @@ function createVNodeChildrenFragment(internals, render, parentComponent) {
|
|
|
4850
4904
|
} else if (!isMounted) {
|
|
4851
4905
|
currentChildren = nextChildren;
|
|
4852
4906
|
currentVNode = createVNode(Fragment, null, nextChildren);
|
|
4853
|
-
|
|
4854
|
-
|
|
4907
|
+
const wasPending = validityPending;
|
|
4908
|
+
const validityChanged = syncResolvedNodes(nextChildren);
|
|
4909
|
+
if (!wasPending) notifyUpdated(validityChanged);
|
|
4855
4910
|
return;
|
|
4856
4911
|
} else if (!currentVNode) {
|
|
4857
4912
|
currentChildren = nextChildren;
|
|
@@ -4937,7 +4992,23 @@ function normalizeInteropSlots(rawSlots) {
|
|
|
4937
4992
|
});
|
|
4938
4993
|
return normalized;
|
|
4939
4994
|
}
|
|
4995
|
+
const interopSlotCache = /* @__PURE__ */ new WeakMap();
|
|
4940
4996
|
function normalizeInteropSlot(rawSlot, ctx) {
|
|
4997
|
+
let cache = interopSlotCache.get(rawSlot);
|
|
4998
|
+
if (!cache) interopSlotCache.set(rawSlot, cache = {});
|
|
4999
|
+
if (ctx) {
|
|
5000
|
+
let ctxCache = cache.ctx;
|
|
5001
|
+
if (!ctxCache) cache.ctx = ctxCache = /* @__PURE__ */ new WeakMap();
|
|
5002
|
+
const cached = ctxCache.get(ctx);
|
|
5003
|
+
if (cached) return cached;
|
|
5004
|
+
const normalized = createNormalizedInteropSlot(rawSlot, ctx);
|
|
5005
|
+
ctxCache.set(ctx, normalized);
|
|
5006
|
+
return normalized;
|
|
5007
|
+
}
|
|
5008
|
+
if (cache.noCtx) return cache.noCtx;
|
|
5009
|
+
return cache.noCtx = createNormalizedInteropSlot(rawSlot, ctx);
|
|
5010
|
+
}
|
|
5011
|
+
function createNormalizedInteropSlot(rawSlot, ctx) {
|
|
4941
5012
|
const normalized = withCtx((...args) => normalizeInteropSlotValue(rawSlot(...args)), ctx);
|
|
4942
5013
|
normalized._c = false;
|
|
4943
5014
|
return normalized;
|
|
@@ -4951,7 +5022,7 @@ function normalizeInteropDefaultSlot(value) {
|
|
|
4951
5022
|
function normalizeInteropSlotValue(value) {
|
|
4952
5023
|
return isArray(value) ? value.map((child) => normalizeVNode(child)) : [normalizeVNode(value)];
|
|
4953
5024
|
}
|
|
4954
|
-
const isInternalSlotKey = (key) => key === "_" || key === "_ctx" || key === "$stable";
|
|
5025
|
+
const isInternalSlotKey = (key) => key === "_" || key === "_ctx" || key === "$stable" || key === "$";
|
|
4955
5026
|
const interopSlotsSourceHandlers = {
|
|
4956
5027
|
get(target, key) {
|
|
4957
5028
|
const slots = target.value;
|
|
@@ -4963,7 +5034,7 @@ const interopSlotsSourceHandlers = {
|
|
|
4963
5034
|
},
|
|
4964
5035
|
ownKeys(target) {
|
|
4965
5036
|
const slots = target.value;
|
|
4966
|
-
return slots ? Object.keys(slots).filter((key) => !isInternalSlotKey(key)) :
|
|
5037
|
+
return slots ? Object.keys(slots).filter((key) => !isInternalSlotKey(key)) : EMPTY_ARR;
|
|
4967
5038
|
},
|
|
4968
5039
|
getOwnPropertyDescriptor(target, key) {
|
|
4969
5040
|
const slots = target.value;
|
|
@@ -5003,11 +5074,27 @@ function setInteropVnodeScopeId(instance, vnode, parentComponent) {
|
|
|
5003
5074
|
}
|
|
5004
5075
|
if (interopScopeIdRootMap.get(instance) === root) return;
|
|
5005
5076
|
interopScopeIdRootMap.set(instance, root);
|
|
5077
|
+
const scopeIds = getInteropVnodeScopeIds(vnode, parentComponent);
|
|
5078
|
+
if (!scopeIds) return;
|
|
5079
|
+
for (let i = 0; i < scopeIds.length; i++) root.setAttribute(scopeIds[i], "");
|
|
5080
|
+
}
|
|
5081
|
+
function getInteropVnodeScopeIds(vnode, parentComponent) {
|
|
5006
5082
|
const scopeIds = [];
|
|
5007
5083
|
if (vnode.scopeId) scopeIds.push(vnode.scopeId);
|
|
5008
5084
|
if (vnode.slotScopeIds) scopeIds.push(...vnode.slotScopeIds);
|
|
5009
5085
|
scopeIds.push(...getInheritedScopeIds(vnode, parentComponent));
|
|
5010
|
-
|
|
5086
|
+
return scopeIds.length ? scopeIds : void 0;
|
|
5087
|
+
}
|
|
5088
|
+
function getInteropVaporSlotScopeIds(vnode, parentComponent) {
|
|
5089
|
+
const scopeIds = [];
|
|
5090
|
+
if (vnode.slotScopeIds) scopeIds.push(...vnode.slotScopeIds);
|
|
5091
|
+
scopeIds.push(...getInheritedScopeIds(vnode, parentComponent));
|
|
5092
|
+
return scopeIds.length ? scopeIds : void 0;
|
|
5093
|
+
}
|
|
5094
|
+
function createInteropFragment(nodes = EMPTY_BLOCK, vnode = null) {
|
|
5095
|
+
const frag = new VaporFragment(nodes);
|
|
5096
|
+
frag.vnode = vnode;
|
|
5097
|
+
return frag;
|
|
5011
5098
|
}
|
|
5012
5099
|
//#endregion
|
|
5013
5100
|
//#region packages/runtime-vapor/src/components/Teleport.ts
|
|
@@ -5126,10 +5213,6 @@ var TeleportFragment = class extends VaporFragment {
|
|
|
5126
5213
|
}
|
|
5127
5214
|
bindChildren(block) {
|
|
5128
5215
|
if (this.parentComponent && this.parentComponent.ut) this.registerUpdateCssVars(block);
|
|
5129
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
5130
|
-
if (isVaporComponent(block)) block.parentTeleport = this;
|
|
5131
|
-
else if (isArray(block)) block.forEach((node) => isVaporComponent(node) && (node.parentTeleport = this));
|
|
5132
|
-
}
|
|
5133
5216
|
}
|
|
5134
5217
|
handleChildrenUpdate(children) {
|
|
5135
5218
|
if (isHydrating$1 || !this.parent || !this.mountContainer) {
|
|
@@ -5137,7 +5220,10 @@ var TeleportFragment = class extends VaporFragment {
|
|
|
5137
5220
|
return;
|
|
5138
5221
|
}
|
|
5139
5222
|
remove(this.nodes, this.mountContainer);
|
|
5140
|
-
|
|
5223
|
+
this.nodes = children;
|
|
5224
|
+
const onBeforeInsert = this.onBeforeInsert;
|
|
5225
|
+
if (onBeforeInsert) onBeforeInsert.forEach((fn) => fn(this.nodes));
|
|
5226
|
+
insert(children, this.mountContainer, this.mountAnchor);
|
|
5141
5227
|
this.bindChildren(this.nodes);
|
|
5142
5228
|
updateCssVars(this);
|
|
5143
5229
|
}
|
|
@@ -5145,6 +5231,8 @@ var TeleportFragment = class extends VaporFragment {
|
|
|
5145
5231
|
if (isTransitionEnabled && this.$transition && !this.isMounted) applyTransitionHooks(this.nodes, this.$transition);
|
|
5146
5232
|
if (this.isMounted) move(this.nodes, this.mountContainer = parent, this.mountAnchor = anchor, 2);
|
|
5147
5233
|
else {
|
|
5234
|
+
const onBeforeInsert = this.onBeforeInsert;
|
|
5235
|
+
if (onBeforeInsert) onBeforeInsert.forEach((fn) => fn(this.nodes));
|
|
5148
5236
|
insert(this.nodes, this.mountContainer = parent, this.mountAnchor = anchor);
|
|
5149
5237
|
this.isMounted = true;
|
|
5150
5238
|
}
|
|
@@ -5285,7 +5373,7 @@ const defineVaporSSRCustomElement = ((options, extraOptions) => {
|
|
|
5285
5373
|
});
|
|
5286
5374
|
var VaporElement = class extends VueElementBase {
|
|
5287
5375
|
constructor(def, props = {}, createAppFn = createVaporApp) {
|
|
5288
|
-
super(def, props, createAppFn);
|
|
5376
|
+
super(def, shallowReactive$1(props), createAppFn);
|
|
5289
5377
|
}
|
|
5290
5378
|
_needsHydration() {
|
|
5291
5379
|
const hydrate = vaporCustomElementHydrates.get(this.constructor);
|
|
@@ -5304,13 +5392,9 @@ var VaporElement = class extends VueElementBase {
|
|
|
5304
5392
|
this._app.mount(this._root);
|
|
5305
5393
|
if (!this.shadowRoot) this._renderSlots();
|
|
5306
5394
|
}
|
|
5307
|
-
_update() {
|
|
5308
|
-
if (!this._app) return;
|
|
5309
|
-
const renderEffects = this._instance.renderEffects;
|
|
5310
|
-
if (renderEffects) renderEffects.forEach((e) => e.run());
|
|
5311
|
-
}
|
|
5395
|
+
_update() {}
|
|
5312
5396
|
_unmount() {
|
|
5313
|
-
this._app.unmount();
|
|
5397
|
+
if (this._app) this._app.unmount();
|
|
5314
5398
|
if (this._instance && this._instance.ce) this._instance.ce = void 0;
|
|
5315
5399
|
this._app = this._instance = null;
|
|
5316
5400
|
}
|
|
@@ -5342,12 +5426,12 @@ var VaporElement = class extends VueElementBase {
|
|
|
5342
5426
|
else this._updateFragmentNodes(nodes, replacements);
|
|
5343
5427
|
}
|
|
5344
5428
|
_createComponent() {
|
|
5345
|
-
|
|
5429
|
+
const ce = (instance) => {
|
|
5346
5430
|
this._app._ceComponent = this._instance = instance;
|
|
5347
5431
|
if (!this.shadowRoot) this._instance.u = [this._renderSlots.bind(this)];
|
|
5348
5432
|
this._processInstance();
|
|
5349
5433
|
};
|
|
5350
|
-
createComponent(this._def, this._props, void 0, void 0, void 0, this._app._context);
|
|
5434
|
+
createComponent(this._def, this._props, void 0, void 0, void 0, this._app._context, false, ce);
|
|
5351
5435
|
}
|
|
5352
5436
|
};
|
|
5353
5437
|
//#endregion
|
|
@@ -5407,10 +5491,11 @@ function createIf(condition, b1, b2, flags = 1) {
|
|
|
5407
5491
|
}
|
|
5408
5492
|
frag = ok ? b1() : b2 ? b2() : [!!(process.env.NODE_ENV !== "production") ? /* @__PURE__ */ createComment("if") : /* @__PURE__ */ createTextNode()];
|
|
5409
5493
|
} else {
|
|
5410
|
-
const index = flags >>
|
|
5494
|
+
const index = flags >> 8;
|
|
5411
5495
|
const keyed = index > 0;
|
|
5412
5496
|
const keyBase = keyed ? (index - 1) * 2 : 0;
|
|
5413
|
-
|
|
5497
|
+
const trackSlotBoundary = !!(flags & 128);
|
|
5498
|
+
frag = isHydrating$1 || !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("if", keyed, false, trackSlotBoundary) : new DynamicFragment(void 0, keyed, false, trackSlotBoundary);
|
|
5414
5499
|
renderEffect(() => {
|
|
5415
5500
|
const ok = condition();
|
|
5416
5501
|
if (isHydrating$1) {
|
|
@@ -5482,10 +5567,10 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
5482
5567
|
let parentAnchor;
|
|
5483
5568
|
let pendingHydrationAnchor = false;
|
|
5484
5569
|
if (!isHydrating$1) parentAnchor = !!(process.env.NODE_ENV !== "production") ? /* @__PURE__ */ createComment("for") : /* @__PURE__ */ createTextNode();
|
|
5485
|
-
const frag = new ForFragment(oldBlocks);
|
|
5570
|
+
const frag = new ForFragment(oldBlocks, !!(flags & 32));
|
|
5486
5571
|
const instance = currentInstance$1;
|
|
5487
|
-
const canUseFastRemove = !!(flags & 1);
|
|
5488
5572
|
const isComponent = !!(flags & 2);
|
|
5573
|
+
const canUseFastRemove = !!(flags & 1) && !isComponent;
|
|
5489
5574
|
const isSingleNode = !!(flags & 8);
|
|
5490
5575
|
const isFragment = !!(flags & 16);
|
|
5491
5576
|
const slotOwner = currentSlotOwner;
|
|
@@ -5507,8 +5592,9 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
5507
5592
|
for (let i = 0; i < newLength; i++) newKeys[i] = getKey(...getItem(source, i));
|
|
5508
5593
|
}
|
|
5509
5594
|
const prevSub = setActiveSub();
|
|
5510
|
-
|
|
5511
|
-
if (
|
|
5595
|
+
const wasMounted = isMounted;
|
|
5596
|
+
if (wasMounted && frag.onBeforeUpdate) for (let i = 0; i < frag.onBeforeUpdate.length; i++) frag.onBeforeUpdate[i]();
|
|
5597
|
+
if (!wasMounted) {
|
|
5512
5598
|
isMounted = true;
|
|
5513
5599
|
if (isHydrating$1) hydrateList(source, newLength);
|
|
5514
5600
|
else for (let i = 0; i < newLength; i++) mount(source, i);
|
|
@@ -5525,7 +5611,10 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
5525
5611
|
}
|
|
5526
5612
|
} else if (!getKey) {
|
|
5527
5613
|
const commonLength = Math.min(newLength, oldLength);
|
|
5528
|
-
for (let i = 0; i < commonLength; i++)
|
|
5614
|
+
for (let i = 0; i < commonLength; i++) {
|
|
5615
|
+
const item = getItem(source, i);
|
|
5616
|
+
update(newBlocks[i] = oldBlocks[i], ...item);
|
|
5617
|
+
}
|
|
5529
5618
|
for (let i = oldLength; i < newLength; i++) mount(source, i);
|
|
5530
5619
|
for (let i = newLength; i < oldLength; i++) unmount(oldBlocks[i]);
|
|
5531
5620
|
} else {
|
|
@@ -5563,7 +5652,7 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
5563
5652
|
const currentKey = newKeys[i];
|
|
5564
5653
|
const oldBlock = oldBlocks[i];
|
|
5565
5654
|
const oldKey = oldBlock.key;
|
|
5566
|
-
if (oldKey === currentKey) update(newBlocks[i] = oldBlock, currentItem
|
|
5655
|
+
if (oldKey === currentKey) update(newBlocks[i] = oldBlock, ...currentItem);
|
|
5567
5656
|
else {
|
|
5568
5657
|
queuedBlocks[queuedBlocksLength++] = [
|
|
5569
5658
|
i,
|
|
@@ -5664,7 +5753,7 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
5664
5753
|
}
|
|
5665
5754
|
frag.nodes = [oldBlocks = newBlocks];
|
|
5666
5755
|
if (parentAnchor) frag.nodes.push(parentAnchor);
|
|
5667
|
-
if (
|
|
5756
|
+
if (wasMounted && frag.onUpdated) frag.onUpdated.forEach((m) => m());
|
|
5668
5757
|
setActiveSub(prevSub);
|
|
5669
5758
|
};
|
|
5670
5759
|
const needKey = renderItem.length > 1;
|
|
@@ -5692,7 +5781,11 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
5692
5781
|
if (frag.$transition.applyGroup) setBlockKey(block.nodes, block.key);
|
|
5693
5782
|
applyTransitionHooks(block.nodes, frag.$transition);
|
|
5694
5783
|
}
|
|
5695
|
-
if (parent)
|
|
5784
|
+
if (parent) {
|
|
5785
|
+
const onBeforeInsert = frag.onBeforeInsert;
|
|
5786
|
+
if (onBeforeInsert) onBeforeInsert.forEach((fn) => fn(block.nodes));
|
|
5787
|
+
insertForBlock(block, anchor);
|
|
5788
|
+
}
|
|
5696
5789
|
return block;
|
|
5697
5790
|
};
|
|
5698
5791
|
function hydrateList(source, newLength) {
|
|
@@ -5874,11 +5967,14 @@ function normalizeSource(source) {
|
|
|
5874
5967
|
isReadonlySource = isReadonly(source);
|
|
5875
5968
|
}
|
|
5876
5969
|
} else if (isString(source)) values = source.split("");
|
|
5877
|
-
else if (typeof source === "number") {
|
|
5878
|
-
|
|
5970
|
+
else if (typeof source === "number") if (!!(process.env.NODE_ENV !== "production") && (!Number.isInteger(source) || source < 0)) {
|
|
5971
|
+
warn(`The v-for range expects a positive integer value but got ${source}.`);
|
|
5972
|
+
values = [];
|
|
5973
|
+
} else {
|
|
5879
5974
|
values = new Array(source);
|
|
5880
5975
|
for (let i = 0; i < source; i++) values[i] = i + 1;
|
|
5881
|
-
}
|
|
5976
|
+
}
|
|
5977
|
+
else if (isObject(source)) if (source[Symbol.iterator]) values = Array.from(source);
|
|
5882
5978
|
else {
|
|
5883
5979
|
keys = Object.keys(source);
|
|
5884
5980
|
values = new Array(keys.length);
|
|
@@ -5915,8 +6011,7 @@ function normalizeAnchor(node) {
|
|
|
5915
6011
|
return;
|
|
5916
6012
|
} else if (isVaporComponent(node)) return normalizeAnchor(node.block);
|
|
5917
6013
|
else {
|
|
5918
|
-
const
|
|
5919
|
-
const nodes = getEffectiveOutput ? getEffectiveOutput.call(node) : node.nodes;
|
|
6014
|
+
const nodes = node.nodes;
|
|
5920
6015
|
return isValidBlock(nodes) ? normalizeAnchor(nodes) : node.anchor || normalizeAnchor(nodes);
|
|
5921
6016
|
}
|
|
5922
6017
|
}
|
|
@@ -5925,8 +6020,8 @@ function getRestElement(val, keys) {
|
|
|
5925
6020
|
for (const key in val) if (!keys.includes(key)) res[key] = val[key];
|
|
5926
6021
|
return res;
|
|
5927
6022
|
}
|
|
5928
|
-
function getDefaultValue(val,
|
|
5929
|
-
return val === void 0 ?
|
|
6023
|
+
function getDefaultValue(val, getDefaultVal) {
|
|
6024
|
+
return val === void 0 ? getDefaultVal() : val;
|
|
5930
6025
|
}
|
|
5931
6026
|
function isForBlock(block) {
|
|
5932
6027
|
return block instanceof ForBlock;
|
|
@@ -6117,12 +6212,15 @@ function setVarsOnBlock(block, vars) {
|
|
|
6117
6212
|
}
|
|
6118
6213
|
//#endregion
|
|
6119
6214
|
//#region packages/runtime-vapor/src/apiCreateDynamicComponent.ts
|
|
6120
|
-
function createDynamicComponent(getter, rawProps, rawSlots,
|
|
6215
|
+
function createDynamicComponent(getter, rawProps, rawSlots, flags = 0) {
|
|
6216
|
+
const isSingleRoot = !!(flags & 1);
|
|
6217
|
+
const once = !!(flags & 2);
|
|
6218
|
+
const slotRoot = !!(flags & 4);
|
|
6121
6219
|
const _insertionParent = insertionParent;
|
|
6122
6220
|
const _insertionAnchor = insertionAnchor;
|
|
6123
6221
|
if (!isHydrating$1) resetInsertionState();
|
|
6124
6222
|
const hydrationCursor = isHydrating$1 ? captureHydrationCursor() : null;
|
|
6125
|
-
const frag = isHydrating$1 || !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("dynamic-component") : new DynamicFragment();
|
|
6223
|
+
const frag = isHydrating$1 || !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("dynamic-component", false, true, slotRoot) : new DynamicFragment(void 0, false, true, slotRoot);
|
|
6126
6224
|
const normalizedRawSlots = normalizeRawSlots(rawSlots);
|
|
6127
6225
|
const scopeOwner = getScopeOwner();
|
|
6128
6226
|
const renderFn = () => {
|
|
@@ -6291,7 +6389,7 @@ const VaporTransitionGroup = /* @__PURE__ */ decorate(/* @__PURE__ */ defineVapo
|
|
|
6291
6389
|
for (let i = 0; i < children.length; i++) {
|
|
6292
6390
|
const child = children[i];
|
|
6293
6391
|
const el = isValidTransitionBlock(child) && child.$transition ? getTransitionElement(child) : void 0;
|
|
6294
|
-
if (el) {
|
|
6392
|
+
if (el && !el[vShowHidden]) {
|
|
6295
6393
|
prevChildren.push(child);
|
|
6296
6394
|
child.$transition.disabled = true;
|
|
6297
6395
|
positionMap.set(child, el.getBoundingClientRect());
|
|
@@ -6436,7 +6534,7 @@ function getTransitionBlocks(block, onFragment, onUpdateOwner) {
|
|
|
6436
6534
|
let children = [];
|
|
6437
6535
|
if (block instanceof Element) children.push(block);
|
|
6438
6536
|
else if (isVaporComponent(block)) {
|
|
6439
|
-
const isRootSlot = block.block
|
|
6537
|
+
const isRootSlot = block.block && isSlotFragment(block.block);
|
|
6440
6538
|
if (onUpdateOwner && !isRootSlot) onUpdateOwner(block);
|
|
6441
6539
|
const blocks = getTransitionBlocks(block.block, onFragment, isRootSlot ? onUpdateOwner : void 0);
|
|
6442
6540
|
inheritKey(blocks, block.$key);
|
|
@@ -6482,4 +6580,4 @@ function getFirstConnectedChild(children) {
|
|
|
6482
6580
|
}
|
|
6483
6581
|
}
|
|
6484
6582
|
//#endregion
|
|
6485
|
-
export { DynamicFragment, VaporElement, VaporFragment, VaporKeepAlive, VaporTeleport, VaporTransition, VaporTransitionGroup, applyCheckboxModel, applyDynamicModel, applyRadioModel, applySelectModel, applyTextModel, applyVShow, child, createAssetComponent, createComponent, createComponentWithFallback, createDynamicComponent, createFor, createForSlots, createIf, createInvoker, createKeyedFragment, createPlainElement, createSelector, createSlot, createTemplateRefSetter, createTextNode, createVaporApp, createVaporSSRApp, defineVaporAsyncComponent, defineVaporComponent, defineVaporCustomElement, defineVaporSSRCustomElement, delegate, delegateEvents, getDefaultValue, getRestElement, insert, isFragment, isVaporComponent, next, nthChild, on, onBinding, prepend, remove, renderEffect, setAttr, setBlockHtml, setBlockKey, setBlockText, setClass, setClassName, setDOMProp, setDynamicEvents, setDynamicProps, setElementText, setHtml, setInsertionState, setProp, setStaticTemplateRef, setStyle, setTemplateRefBinding, setText, setValue, template, txt, useVaporCssVars, vaporInteropPlugin, withAsyncContext,
|
|
6583
|
+
export { DynamicFragment, VaporElement, VaporFragment, VaporKeepAlive, VaporTeleport, VaporTransition, VaporTransitionGroup, applyCheckboxModel, applyDynamicModel, applyRadioModel, applySelectModel, applyTextModel, applyVShow, child, createAssetComponent, createComponent, createComponentWithFallback, createDynamicComponent, createFor, createForSlots, createIf, createInvoker, createKeyedFragment, createPlainElement, createSelector, createSlot, createTemplateRefSetter, createTextNode, createVaporApp, createVaporSSRApp, defineVaporAsyncComponent, defineVaporComponent, defineVaporCustomElement, defineVaporSSRCustomElement, delegate, delegateEvents, getDefaultValue, getRestElement, insert, isFragment, isVaporComponent, next, nthChild, on, onBinding, prepend, remove, renderEffect, setAttr, setBlockHtml, setBlockKey, setBlockText, setClass, setClassName, setDOMProp, setDynamicEvents, setDynamicProps, setElementText, setHtml, setInsertionState, setProp, setStaticTemplateRef, setStyle, setTemplateRefBinding, setText, setValue, template, txt, useVaporCssVars, vaporInteropPlugin, withAsyncContext, withVaporDirectives, withVaporKeys, withVaporModifiers };
|