@vue/runtime-vapor 3.6.0-alpha.7 → 3.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { VNode, GenericComponentInstance, TransitionHooks, TransitionState, TransitionProps, Plugin, SchedulerJob, EmitsOptions, ComponentObjectPropsOptions, ExtractPropTypes, ReservedProps, AllowedComponentProps, ComponentCustomProps, EmitsToProps, ExtractDefaultPropTypes, EmitFn, ComponentTypeEmits, TypeEmitsToOptions, GenericAppContext, EffectScope as EffectScope$1, ShallowUnwrapRef, SuspenseBoundary, LifecycleHook, NormalizedPropsOptions, ObjectEmitsOptions, ComponentInternalOptions, AsyncComponentInternalOptions, ComponentPropsOptions, CreateAppFunction, AsyncComponentLoader, AsyncComponentOptions, DirectiveModifiers, CustomElementOptions, VueElementBase } from '@vue/runtime-dom';
2
- import { Ref, EffectScope, ReactiveEffect, ComputedRef, ShallowRef } from '@vue/reactivity';
2
+ import { Ref, EffectScope, ReactiveEffect, ShallowRef } from '@vue/reactivity';
3
3
  import { Prettify, IsKeyValues, Namespace, NormalizedStyle } from '@vue/shared';
4
4
 
5
5
  type NodeRef = string | Ref | ((ref: Element | VaporComponentInstance, refs: Record<string, any>) => void);
@@ -29,6 +29,10 @@ declare class DynamicFragment extends VaporFragment {
29
29
  anchor: Node;
30
30
  scope: EffectScope | undefined;
31
31
  current?: BlockFn;
32
+ pending?: {
33
+ render?: BlockFn;
34
+ key: any;
35
+ };
32
36
  fallback?: BlockFn;
33
37
  anchorLabel?: string;
34
38
  attrs?: Record<string, any>;
@@ -93,9 +97,7 @@ type DynamicSlot = {
93
97
  name: string;
94
98
  fn: VaporSlot;
95
99
  };
96
- type DynamicSlotFn = (() => DynamicSlot | DynamicSlot[]) & {
97
- _cache?: ComputedRef<DynamicSlot | DynamicSlot[]>;
98
- };
100
+ type DynamicSlotFn = () => DynamicSlot | DynamicSlot[];
99
101
  type DynamicSlotSource = StaticSlots | DynamicSlotFn;
100
102
  /**
101
103
  * Wrap a slot function to track the slot owner.
@@ -145,7 +147,7 @@ type VaporComponentInstanceConstructor<T extends VaporComponentInstance> = {
145
147
  __isFragment?: never;
146
148
  __isTeleport?: never;
147
149
  __isSuspense?: never;
148
- new (props?: T['props']): T;
150
+ new (...args: any[]): T;
149
151
  };
150
152
  export type DefineVaporComponent<RuntimePropsOptions = {}, RuntimePropsKeys extends string = string, Emits extends EmitsOptions = {}, RuntimeEmitsKeys extends string = string, Slots extends StaticSlots = StaticSlots, Exposed extends Record<string, any> = Record<string, any>, TypeBlock extends Block = Block, TypeRefs extends Record<string, unknown> = {}, MakeDefaultsOptional extends boolean = true, InferredProps = string extends RuntimePropsKeys ? ComponentObjectPropsOptions extends RuntimePropsOptions ? {} : ExtractPropTypes<RuntimePropsOptions> : {
151
153
  [key in RuntimePropsKeys]?: any;
@@ -265,6 +267,7 @@ export declare class VaporComponentInstance<Props extends Record<string, any> =
265
267
  renderEffects?: RenderEffect[];
266
268
  hasFallthrough: boolean;
267
269
  shapeFlag?: number;
270
+ oncePropsCache?: Record<string | symbol, any>;
268
271
  isMounted: boolean;
269
272
  isUnmounted: boolean;
270
273
  isDeactivated: boolean;
@@ -458,6 +461,16 @@ export declare function createInvoker(handler: (...args: any[]) => any): (...arg
458
461
 
459
462
  export declare function createIf(condition: () => any, b1: BlockFn, b2?: BlockFn, once?: boolean): Block;
460
463
 
464
+ /**
465
+ * Create a dynamic fragment keyed by a reactive value for Vapor transitions.
466
+ * The fragment is re-rendered when the key changes to trigger enter/leave
467
+ * animations.
468
+ *
469
+ * Example:
470
+ * <VaporTransition>
471
+ * <h1 :key="count">{{ count }}</h1>
472
+ * </VaporTransition>
473
+ */
461
474
  export declare function createKeyedFragment(key: () => any, render: BlockFn): Block;
462
475
 
463
476
  type Source = any[] | Record<any, any> | number | Set<any> | Map<any, any>;
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @vue/runtime-vapor v3.6.0-alpha.7
2
+ * @vue/runtime-vapor v3.6.0-beta.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- import { isMismatchAllowed, warn, callWithAsyncErrorHandling, currentInstance, unsafeToTrustedHTML, patchStyle, xlinkNS, mergeProps, shouldSetAsProp, queuePostFlushCb, toClassSet, isSetEqual, warnPropMismatch, toStyleMap, vShowHidden, isMapEqual, isValidHtmlOrSvgAttribute, getAttributeMismatch, watch, onMounted, onUpdated, onBeforeUnmount, isAsyncWrapper, getComponentName, matches, devtoolsComponentAdded, resetShapeFlag, isKeepAlive, ensureRenderer, shallowRef, simpleSetCurrentInstance, renderSlot, ensureVaporSlotFallback, createVNode, shallowReactive, createInternalObject, isEmitListener, onScopeDispose, activate as activate$1, setTransitionHooks as setTransitionHooks$1, normalizeRef, isVNode, Fragment, isRef, ensureHydrationRenderer, setRef as setRef$1, deactivate as deactivate$1, baseEmit, baseNormalizePropsOptions, pushWarningContext, validateProps, popWarningContext, resolvePropValue, setCurrentInstance, startMeasure, queueJob, TransitionPropsValidators, leaveCbKey, baseResolveTransitionHooks, isTemplateNode, checkTransitionMode, resolveTransitionProps, useTransitionState, warnExtraneousAttributes, resolveTeleportTarget, isTeleportDisabled, isTeleportDeferred, performTransitionEnter, performTransitionLeave, getInheritedScopeIds, registerHMR, endMeasure, unregisterHMR, nextUid, EffectScope as EffectScope$1, expose, callWithErrorHandling, markAsyncBoundary, getFunctionalFallthrough, createAppAPI, initFeatureFlags, setDevtoolsHook, flushOnAppMount, normalizeContainer, createAsyncComponentContext, useAsyncComponentState, performAsyncHydrate, handleError, VueElementBase, createCanSetSetupRefChecker, baseUseCssVars, setVarsOnNode, resolveDynamicComponent, vShowOriginalDisplay, vModelTextInit, vModelCheckboxInit, vModelSelectInit, vModelTextUpdate, vModelCheckboxUpdate, vModelGetValue, vModelSetSelected, onBeforeUpdate, hasCSSTransform, callPendingCbs, forceReflow, handleMovedChildren, baseApplyTranslation } from '@vue/runtime-dom';
6
+ import { isMismatchAllowed, warn, callWithAsyncErrorHandling, currentInstance, unsafeToTrustedHTML, patchStyle, xlinkNS, mergeProps, shouldSetAsProp, queuePostFlushCb, toClassSet, isSetEqual, warnPropMismatch, toStyleMap, vShowHidden, isMapEqual, isValidHtmlOrSvgAttribute, getAttributeMismatch, watch, onMounted, onUpdated, onBeforeUnmount, isAsyncWrapper, getComponentName, matches, devtoolsComponentAdded, resetShapeFlag, isKeepAlive, ensureRenderer, shallowRef, simpleSetCurrentInstance, renderSlot, ensureVaporSlotFallback, createVNode, shallowReactive, createInternalObject, isEmitListener, onScopeDispose, activate as activate$1, setTransitionHooks as setTransitionHooks$1, normalizeRef, isVNode, Fragment, isRef, ensureHydrationRenderer, setRef as setRef$1, deactivate as deactivate$1, baseEmit, baseNormalizePropsOptions, pushWarningContext, validateProps, popWarningContext, setCurrentInstance, resolvePropValue, startMeasure, queueJob, TransitionPropsValidators, leaveCbKey, baseResolveTransitionHooks, isTemplateNode, checkTransitionMode, resolveTransitionProps, useTransitionState, warnExtraneousAttributes, resolveTeleportTarget, isTeleportDisabled, isTeleportDeferred, performTransitionEnter, performTransitionLeave, getInheritedScopeIds, registerHMR, endMeasure, unregisterHMR, nextUid, EffectScope as EffectScope$1, expose, callWithErrorHandling, markAsyncBoundary, getFunctionalFallthrough, createAppAPI, initFeatureFlags, setDevtoolsHook, flushOnAppMount, normalizeContainer, createAsyncComponentContext, useAsyncComponentState, performAsyncHydrate, handleError, VueElementBase, createCanSetSetupRefChecker, baseUseCssVars, setVarsOnNode, resolveDynamicComponent, vShowOriginalDisplay, vModelTextInit, vModelCheckboxInit, vModelSelectInit, vModelTextUpdate, vModelCheckboxUpdate, vModelGetValue, vModelSetSelected, onBeforeUpdate, hasCSSTransform, callPendingCbs, forceReflow, handleMovedChildren, baseApplyTranslation } from '@vue/runtime-dom';
7
7
  import { isArray, normalizeClass, normalizeStyle, includeBooleanAttr, toDisplayString, isString, parseStringStyle, isOn, canSetValueDirectly, camelize, stringifyStyle, normalizeCssVarValue, getEscapedCssVarName, isFunction, extend, invokeArrayFns, isReservedProp, EMPTY_OBJ, hasOwn, EMPTY_ARR, NO, YES, isPromise, getGlobalThis, isPlainObject, isObject, remove as remove$1, NOOP, looseEqual } from '@vue/shared';
8
- import { onEffectCleanup, pauseTracking, resetTracking, computed, ReactiveEffect, setActiveSub, EffectScope, onScopeDispose as onScopeDispose$1, markRaw, unref, proxyRefs, toRaw, watch as watch$1, isReactive, isShallow, shallowReadArray, isReadonly, toReadonly, toReactive, shallowRef as shallowRef$1, isRef as isRef$1, traverse } from '@vue/reactivity';
8
+ import { onEffectCleanup, computed, onScopeDispose as onScopeDispose$1, pauseTracking, resetTracking, ReactiveEffect, setActiveSub, EffectScope, markRaw, unref, proxyRefs, toRaw, watch as watch$1, isReactive, isShallow, shallowReadArray, isReadonly, toReadonly, toReactive, shallowRef as shallowRef$1, isRef as isRef$1, traverse } from '@vue/reactivity';
9
9
 
10
10
  let insertionParent;
11
11
  let insertionAnchor;
@@ -916,22 +916,19 @@ const VaporKeepAliveImpl = defineVaporComponent({
916
916
  };
917
917
  const processFragment = (frag) => {
918
918
  const [innerBlock, interop] = getInnerBlock(frag.nodes);
919
- if (!innerBlock || !shouldCache(innerBlock, props, interop)) return;
919
+ if (!innerBlock || !shouldCache(innerBlock, props, interop)) return false;
920
920
  if (interop) {
921
921
  if (cache.has(innerBlock.vnode.type)) {
922
922
  innerBlock.vnode.shapeFlag |= 512;
923
923
  }
924
- if (shouldCache(innerBlock, props, true)) {
925
- innerBlock.vnode.shapeFlag |= 256;
926
- }
924
+ innerBlock.vnode.shapeFlag |= 256;
927
925
  } else {
928
926
  if (cache.has(innerBlock.type)) {
929
927
  innerBlock.shapeFlag |= 512;
930
928
  }
931
- if (shouldCache(innerBlock, props)) {
932
- innerBlock.shapeFlag |= 256;
933
- }
929
+ innerBlock.shapeFlag |= 256;
934
930
  }
931
+ return true;
935
932
  };
936
933
  const cacheFragment = (fragment) => {
937
934
  const [innerBlock, interop] = getInnerBlock(fragment.nodes);
@@ -1008,9 +1005,11 @@ const VaporKeepAliveImpl = defineVaporComponent({
1008
1005
  const injectKeepAliveHooks = (frag) => {
1009
1006
  (frag.onBeforeTeardown || (frag.onBeforeTeardown = [])).push(
1010
1007
  (oldKey, nodes, scope) => {
1011
- processFragment(frag);
1012
- keptAliveScopes.set(oldKey, scope);
1013
- return true;
1008
+ if (processFragment(frag)) {
1009
+ keptAliveScopes.set(oldKey, scope);
1010
+ return true;
1011
+ }
1012
+ return false;
1014
1013
  }
1015
1014
  );
1016
1015
  (frag.onBeforeMount || (frag.onBeforeMount = [])).push(
@@ -1078,7 +1077,7 @@ function getInstanceFromCache(cached) {
1078
1077
  return cached.vnode.component;
1079
1078
  }
1080
1079
  function activate(instance, parentNode, anchor) {
1081
- insert(instance.block, parentNode, anchor);
1080
+ move(instance.block, parentNode, anchor, 0, instance);
1082
1081
  queuePostFlushCb(() => {
1083
1082
  instance.isDeactivated = false;
1084
1083
  if (instance.a) invokeArrayFns(instance.a);
@@ -1088,7 +1087,7 @@ function activate(instance, parentNode, anchor) {
1088
1087
  }
1089
1088
  }
1090
1089
  function deactivate(instance, container) {
1091
- insert(instance.block, container);
1090
+ move(instance.block, container, null, 1, instance);
1092
1091
  queuePostFlushCb(() => {
1093
1092
  if (instance.da) invokeArrayFns(instance.da);
1094
1093
  instance.isDeactivated = true;
@@ -1117,7 +1116,7 @@ function setParentSuspense(suspense) {
1117
1116
  }
1118
1117
  }
1119
1118
 
1120
- const interopKey = Symbol(`interop`);
1119
+ const interopKey = /* @__PURE__ */ Symbol(`interop`);
1121
1120
  const vaporInteropImpl = {
1122
1121
  mount(vnode, container, anchor, parentComponent, parentSuspense) {
1123
1122
  let selfAnchor = vnode.el = vnode.anchor = createTextNode();
@@ -1576,7 +1575,26 @@ function propGetter(rawProps, key) {
1576
1575
  }
1577
1576
 
1578
1577
  function resolveSource(source) {
1579
- return isFunction(source) ? source() : source;
1578
+ return isFunction(source) ? resolveFunctionSource(source) : source;
1579
+ }
1580
+ function resolveFunctionSource(source) {
1581
+ if (source._cache) {
1582
+ return source._cache.value;
1583
+ }
1584
+ const parent = currentInstance && currentInstance.parent;
1585
+ if (parent) {
1586
+ source._cache = computed(() => {
1587
+ const prev = setCurrentInstance(parent);
1588
+ try {
1589
+ return source();
1590
+ } finally {
1591
+ setCurrentInstance(...prev);
1592
+ }
1593
+ });
1594
+ onScopeDispose$1(() => source._cache = void 0);
1595
+ return source._cache.value;
1596
+ }
1597
+ return source();
1580
1598
  }
1581
1599
  function getPropsProxyHandlers(comp, once) {
1582
1600
  if (comp.__propsHandlers) {
@@ -1597,13 +1615,15 @@ function getPropsProxyHandlers(comp, once) {
1597
1615
  while (i--) {
1598
1616
  source = dynamicSources[i];
1599
1617
  isDynamic = isFunction(source);
1600
- source = isDynamic ? source() : source;
1618
+ source = isDynamic ? resolveFunctionSource(
1619
+ source
1620
+ ) : source;
1601
1621
  for (rawKey in source) {
1602
1622
  if (camelize(rawKey) === key) {
1603
1623
  return resolvePropValue(
1604
1624
  propsOptions,
1605
1625
  key,
1606
- isDynamic ? source[rawKey] : source[rawKey](),
1626
+ isDynamic ? source[rawKey] : resolveFunctionSource(source[rawKey]),
1607
1627
  instance,
1608
1628
  resolveDefault
1609
1629
  );
@@ -1631,14 +1651,23 @@ function getPropsProxyHandlers(comp, once) {
1631
1651
  true
1632
1652
  );
1633
1653
  };
1634
- const getPropValue = once ? (...args) => {
1635
- pauseTracking();
1636
- const value = getProp(...args);
1637
- resetTracking();
1638
- return value;
1639
- } : getProp;
1654
+ const withOnceCache = (getter) => {
1655
+ return ((instance, key) => {
1656
+ const cache = instance.oncePropsCache || (instance.oncePropsCache = {});
1657
+ if (!(key in cache)) {
1658
+ pauseTracking();
1659
+ try {
1660
+ cache[key] = getter(instance, key);
1661
+ } finally {
1662
+ resetTracking();
1663
+ }
1664
+ }
1665
+ return cache[key];
1666
+ });
1667
+ };
1668
+ const getOnceProp = withOnceCache(getProp);
1640
1669
  const propsHandlers = propsOptions ? {
1641
- get: (target, key) => getPropValue(target, key),
1670
+ get: (target, key) => (once ? getOnceProp : getProp)(target, key),
1642
1671
  has: (_, key) => isProp(key),
1643
1672
  ownKeys: () => Object.keys(propsOptions),
1644
1673
  getOwnPropertyDescriptor(target, key) {
@@ -1646,7 +1675,7 @@ function getPropsProxyHandlers(comp, once) {
1646
1675
  return {
1647
1676
  configurable: true,
1648
1677
  enumerable: true,
1649
- get: () => getPropValue(target, key)
1678
+ get: () => (once ? getOnceProp : getProp)(target, key)
1650
1679
  };
1651
1680
  }
1652
1681
  }
@@ -1669,14 +1698,11 @@ function getPropsProxyHandlers(comp, once) {
1669
1698
  return false;
1670
1699
  }
1671
1700
  };
1672
- const getAttrValue = once ? (...args) => {
1673
- pauseTracking();
1674
- const value = getAttr(...args);
1675
- resetTracking();
1676
- return value;
1677
- } : getAttr;
1701
+ const getOnceAttr = withOnceCache(
1702
+ (instance, key) => getAttr(instance.rawProps, key)
1703
+ );
1678
1704
  const attrsHandlers = {
1679
- get: (target, key) => getAttrValue(target.rawProps, key),
1705
+ get: (target, key) => once ? getOnceAttr(target, key) : getAttr(target.rawProps, key),
1680
1706
  has: (target, key) => hasAttr(target.rawProps, key),
1681
1707
  ownKeys: (target) => getKeysFromRawProps(target.rawProps).filter(isAttr),
1682
1708
  getOwnPropertyDescriptor(target, key) {
@@ -1684,7 +1710,7 @@ function getPropsProxyHandlers(comp, once) {
1684
1710
  return {
1685
1711
  configurable: true,
1686
1712
  enumerable: true,
1687
- get: () => getAttrValue(target.rawProps, key)
1713
+ get: () => once ? getOnceAttr(target, key) : getAttr(target.rawProps, key)
1688
1714
  };
1689
1715
  }
1690
1716
  }
@@ -1707,9 +1733,9 @@ function getAttrFromRawProps(rawProps, key) {
1707
1733
  while (i--) {
1708
1734
  source = dynamicSources[i];
1709
1735
  isDynamic = isFunction(source);
1710
- source = isDynamic ? source() : source;
1736
+ source = isDynamic ? resolveFunctionSource(source) : source;
1711
1737
  if (source && hasOwn(source, key)) {
1712
- const value = isDynamic ? source[key] : source[key]();
1738
+ const value = isDynamic ? source[key] : resolveFunctionSource(source[key]);
1713
1739
  if (merged) {
1714
1740
  merged.push(value);
1715
1741
  } else {
@@ -1754,7 +1780,9 @@ function getKeysFromRawProps(rawProps) {
1754
1780
  let i = dynamicSources.length;
1755
1781
  let source;
1756
1782
  while (i--) {
1757
- source = resolveSource(dynamicSources[i]);
1783
+ source = isFunction(dynamicSources[i]) ? resolveFunctionSource(
1784
+ dynamicSources[i]
1785
+ ) : dynamicSources[i];
1758
1786
  for (const key in source) {
1759
1787
  keys.push(key);
1760
1788
  }
@@ -1820,9 +1848,9 @@ function resolveDynamicProps(props) {
1820
1848
  if (props.$) {
1821
1849
  for (const source of props.$) {
1822
1850
  const isDynamic = isFunction(source);
1823
- const resolved = isDynamic ? source() : source;
1851
+ const resolved = isDynamic ? resolveFunctionSource(source) : source;
1824
1852
  for (const key in resolved) {
1825
- const value = isDynamic ? resolved[key] : resolved[key]();
1853
+ const value = isDynamic ? resolved[key] : resolveFunctionSource(source[key]);
1826
1854
  if (key === "class" || key === "style") {
1827
1855
  const existing = mergedRawProps[key];
1828
1856
  if (isArray(existing)) {
@@ -1874,12 +1902,6 @@ function setCurrentSlotScopeIds(scopeIds) {
1874
1902
  currentSlotScopeIds = scopeIds;
1875
1903
  }
1876
1904
  }
1877
- function resolveDynamicSlot(source) {
1878
- if (!source._cache) {
1879
- source._cache = computed(source);
1880
- }
1881
- return source._cache.value;
1882
- }
1883
1905
  const dynamicSlotsProxyHandlers = {
1884
1906
  get: getSlot,
1885
1907
  has: (target, key) => !!getSlot(target, key),
@@ -1900,7 +1922,7 @@ const dynamicSlotsProxyHandlers = {
1900
1922
  keys = keys.filter((k) => k !== "$");
1901
1923
  for (const source of dynamicSources) {
1902
1924
  if (isFunction(source)) {
1903
- const slot = resolveDynamicSlot(source);
1925
+ const slot = resolveFunctionSource(source);
1904
1926
  if (isArray(slot)) {
1905
1927
  for (const s of slot) keys.push(String(s.name));
1906
1928
  } else {
@@ -1925,7 +1947,7 @@ function getSlot(target, key) {
1925
1947
  while (i--) {
1926
1948
  source = dynamicSources[i];
1927
1949
  if (isFunction(source)) {
1928
- const slot = resolveDynamicSlot(source);
1950
+ const slot = resolveFunctionSource(source);
1929
1951
  if (slot) {
1930
1952
  if (isArray(slot)) {
1931
1953
  for (const s of slot) {
@@ -2152,26 +2174,15 @@ const VaporTransition = /* @__PURE__ */ decorate$1((props, { slots }) => {
2152
2174
  const { mode } = props;
2153
2175
  checkTransitionMode(mode);
2154
2176
  let resolvedProps;
2155
- let isMounted = false;
2156
- renderEffect(() => {
2157
- resolvedProps = resolveTransitionProps(props);
2158
- if (isMounted) {
2159
- if (isFragment(children)) {
2160
- children.$transition.props = resolvedProps;
2161
- } else {
2162
- const child = findTransitionBlock(children);
2163
- if (child) {
2164
- child.$transition.props = resolvedProps;
2165
- applyTransitionHooks(child, child.$transition, true);
2166
- }
2167
- }
2168
- } else {
2169
- isMounted = true;
2170
- }
2171
- });
2177
+ renderEffect(() => resolvedProps = resolveTransitionProps(props));
2172
2178
  const hooks = applyTransitionHooks(children, {
2173
2179
  state: useTransitionState(),
2174
- props: resolvedProps,
2180
+ // use proxy to keep props reference stable
2181
+ props: new Proxy({}, {
2182
+ get(_, key) {
2183
+ return resolvedProps[key];
2184
+ }
2185
+ }),
2175
2186
  instance
2176
2187
  });
2177
2188
  if (resetDisplay && resolvedProps.appear) {
@@ -2233,7 +2244,7 @@ function resolveTransitionHooks(block, props, state, instance, postClone) {
2233
2244
  hooks.instance = instance;
2234
2245
  return hooks;
2235
2246
  }
2236
- function applyTransitionHooks(block, hooks, isResolved = false) {
2247
+ function applyTransitionHooks(block, hooks) {
2237
2248
  if (isArray(block)) {
2238
2249
  block = block.filter((b) => !(b instanceof Comment));
2239
2250
  if (block.length === 1) {
@@ -2242,10 +2253,13 @@ function applyTransitionHooks(block, hooks, isResolved = false) {
2242
2253
  return hooks;
2243
2254
  }
2244
2255
  }
2245
- const isFrag = isFragment(block);
2246
- const child = isResolved ? block : findTransitionBlock(block, isFrag);
2256
+ const fragments = [];
2257
+ const child = findTransitionBlock(block, (frag) => fragments.push(frag));
2247
2258
  if (!child) {
2248
- if (isFrag) setTransitionHooksOnFragment(block, hooks);
2259
+ fragments.forEach((f) => f.$transition = hooks);
2260
+ if (!!(process.env.NODE_ENV !== "production") && fragments.length === 0) {
2261
+ warn("Transition component has no valid child element");
2262
+ }
2249
2263
  return hooks;
2250
2264
  }
2251
2265
  const { props, instance, state, delayedLeave } = hooks;
@@ -2258,7 +2272,7 @@ function applyTransitionHooks(block, hooks, isResolved = false) {
2258
2272
  );
2259
2273
  resolvedHooks.delayedLeave = delayedLeave;
2260
2274
  child.$transition = resolvedHooks;
2261
- if (isFrag) setTransitionHooksOnFragment(block, resolvedHooks);
2275
+ fragments.forEach((f) => f.$transition = resolvedHooks);
2262
2276
  return resolvedHooks;
2263
2277
  }
2264
2278
  function applyTransitionLeaveHooks(block, enterHooks, afterLeaveCb) {
@@ -2298,7 +2312,7 @@ function applyTransitionLeaveHooks(block, enterHooks, afterLeaveCb) {
2298
2312
  };
2299
2313
  }
2300
2314
  }
2301
- function findTransitionBlock(block, inFragment = false) {
2315
+ function findTransitionBlock(block, onFragment) {
2302
2316
  let child;
2303
2317
  if (block instanceof Node) {
2304
2318
  if (block instanceof Element) child = block;
@@ -2307,15 +2321,14 @@ function findTransitionBlock(block, inFragment = false) {
2307
2321
  child = block;
2308
2322
  } else {
2309
2323
  if (getComponentName(block.type) === displayName) return void 0;
2310
- child = findTransitionBlock(block.block, inFragment);
2324
+ child = findTransitionBlock(block.block, onFragment);
2311
2325
  if (child && child.$key === void 0) child.$key = block.uid;
2312
2326
  }
2313
2327
  } else if (isArray(block)) {
2314
2328
  let hasFound = false;
2315
2329
  for (const c of block) {
2316
2330
  if (c instanceof Comment) continue;
2317
- if (isFragment(c)) inFragment = true;
2318
- const item = findTransitionBlock(c, inFragment);
2331
+ const item = findTransitionBlock(c, onFragment);
2319
2332
  if (!!(process.env.NODE_ENV !== "production") && hasFound) {
2320
2333
  warn(
2321
2334
  "<transition> can only be used on a single element or component. Use <transition-group> for lists."
@@ -2327,16 +2340,13 @@ function findTransitionBlock(block, inFragment = false) {
2327
2340
  if (!!!(process.env.NODE_ENV !== "production")) break;
2328
2341
  }
2329
2342
  } else if (isFragment(block)) {
2330
- inFragment = true;
2331
2343
  if (block.insert) {
2332
2344
  child = block;
2333
2345
  } else {
2334
- child = findTransitionBlock(block.nodes, true);
2346
+ if (onFragment) onFragment(block);
2347
+ child = findTransitionBlock(block.nodes, onFragment);
2335
2348
  }
2336
2349
  }
2337
- if (!!(process.env.NODE_ENV !== "production") && !child && !inFragment) {
2338
- warn("Transition component has no valid child element");
2339
- }
2340
2350
  return child;
2341
2351
  }
2342
2352
  function setTransitionHooksOnFragment(block, hooks) {
@@ -2428,28 +2438,41 @@ class DynamicFragment extends VaporFragment {
2428
2438
  if (isHydrating) this.hydrate(true);
2429
2439
  return;
2430
2440
  }
2441
+ const transition = this.$transition;
2442
+ if (transition && transition.state.isLeaving) {
2443
+ this.current = key;
2444
+ this.pending = { render, key };
2445
+ return;
2446
+ }
2447
+ const prevKey = this.current;
2431
2448
  this.current = key;
2432
2449
  const instance = currentInstance;
2433
2450
  const prevSub = setActiveSub();
2434
2451
  const parent = isHydrating ? null : this.anchor.parentNode;
2435
- const transition = this.$transition;
2436
2452
  if (this.scope) {
2437
2453
  let preserveScope = false;
2438
2454
  if (this.onBeforeTeardown) {
2439
- preserveScope = this.onBeforeTeardown.some(
2440
- (hook) => hook(this.current, this.nodes, this.scope)
2441
- );
2455
+ for (const teardown of this.onBeforeTeardown) {
2456
+ if (teardown(prevKey, this.nodes, this.scope)) {
2457
+ preserveScope = true;
2458
+ }
2459
+ }
2442
2460
  }
2443
2461
  if (!preserveScope) {
2444
2462
  this.scope.stop();
2445
2463
  }
2446
2464
  const mode = transition && transition.mode;
2447
2465
  if (mode) {
2448
- applyTransitionLeaveHooks(
2449
- this.nodes,
2450
- transition,
2451
- () => this.renderBranch(render, transition, parent, instance)
2452
- );
2466
+ applyTransitionLeaveHooks(this.nodes, transition, () => {
2467
+ const pending = this.pending;
2468
+ if (pending) {
2469
+ this.pending = void 0;
2470
+ this.current = pending.key;
2471
+ this.renderBranch(pending.render, transition, parent, instance);
2472
+ } else {
2473
+ this.renderBranch(render, transition, parent, instance);
2474
+ }
2475
+ });
2453
2476
  parent && remove(this.nodes, parent);
2454
2477
  if (mode === "out-in") {
2455
2478
  setActiveSub(prevSub);
@@ -2876,6 +2899,79 @@ function insert(block, parent, anchor = null, parentSuspense) {
2876
2899
  }
2877
2900
  }
2878
2901
  }
2902
+ function move(block, parent, anchor = null, moveType = 1, parentComponent, parentSuspense) {
2903
+ anchor = anchor === 0 ? parent.$fc || _child(parent) : anchor;
2904
+ if (block instanceof Node) {
2905
+ if (block instanceof Element && block.$transition && !block.$transition.disabled && moveType !== 2) {
2906
+ if (moveType === 0) {
2907
+ performTransitionEnter(
2908
+ block,
2909
+ block.$transition,
2910
+ () => parent.insertBefore(block, anchor),
2911
+ parentSuspense,
2912
+ true
2913
+ );
2914
+ } else {
2915
+ performTransitionLeave(
2916
+ block,
2917
+ block.$transition,
2918
+ () => {
2919
+ if (moveType === 1 && parentComponent && parentComponent.isUnmounted) {
2920
+ block.remove();
2921
+ } else {
2922
+ parent.insertBefore(block, anchor);
2923
+ }
2924
+ },
2925
+ parentSuspense,
2926
+ true
2927
+ );
2928
+ }
2929
+ } else {
2930
+ parent.insertBefore(block, anchor);
2931
+ }
2932
+ } else if (isVaporComponent(block)) {
2933
+ if (block.isMounted) {
2934
+ move(
2935
+ block.block,
2936
+ parent,
2937
+ anchor,
2938
+ moveType,
2939
+ parentComponent,
2940
+ parentSuspense
2941
+ );
2942
+ } else {
2943
+ mountComponent(block, parent, anchor);
2944
+ }
2945
+ } else if (isArray(block)) {
2946
+ for (const b of block) {
2947
+ move(b, parent, anchor, moveType, parentComponent, parentSuspense);
2948
+ }
2949
+ } else {
2950
+ if (block.anchor) {
2951
+ move(
2952
+ block.anchor,
2953
+ parent,
2954
+ anchor,
2955
+ moveType,
2956
+ parentComponent,
2957
+ parentSuspense
2958
+ );
2959
+ anchor = block.anchor;
2960
+ }
2961
+ if (block.insert) {
2962
+ block.insert(parent, anchor, block.$transition);
2963
+ } else {
2964
+ move(
2965
+ block.nodes,
2966
+ parent,
2967
+ anchor,
2968
+ moveType,
2969
+ parentComponent,
2970
+ parentSuspense
2971
+ );
2972
+ }
2973
+ }
2974
+ }
2879
2975
  function prepend(parent, ...blocks) {
2880
2976
  let i = blocks.length;
2881
2977
  while (i--) insert(blocks[i], parent, 0);
@@ -3450,7 +3546,7 @@ function unmountComponent(instance, parentNode) {
3450
3546
  return;
3451
3547
  }
3452
3548
  if (instance.isMounted && !instance.isUnmounted) {
3453
- if (!!(process.env.NODE_ENV !== "production") && instance.type.__hmrId) {
3549
+ if (!!(process.env.NODE_ENV !== "production")) {
3454
3550
  unregisterHMR(instance);
3455
3551
  }
3456
3552
  if (instance.bum) {
@@ -3953,9 +4049,7 @@ function createKeyedFragment(key, render) {
3953
4049
  const _isLastInsertion = isLastInsertion;
3954
4050
  if (!isHydrating) resetInsertionState();
3955
4051
  const frag = !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("keyed") : new DynamicFragment();
3956
- renderEffect(() => {
3957
- frag.update(render, key());
3958
- });
4052
+ renderEffect(() => frag.update(render, key()));
3959
4053
  if (!isHydrating) {
3960
4054
  if (_insertionParent) insert(frag, _insertionParent, _insertionAnchor);
3961
4055
  } else {
@@ -4601,13 +4695,16 @@ function createDynamicComponent(getter, rawProps, rawSlots, isSingleRoot, once)
4601
4695
  const value = getter();
4602
4696
  const appContext = currentInstance && currentInstance.appContext || emptyContext;
4603
4697
  frag.update(
4604
- () => createComponentWithFallback(
4605
- resolveDynamicComponent(value),
4606
- rawProps,
4607
- rawSlots,
4608
- isSingleRoot,
4609
- once,
4610
- appContext
4698
+ () => (
4699
+ // Support integration with VaporRouterView/VaporRouterLink by accepting blocks
4700
+ isBlock(value) ? value : createComponentWithFallback(
4701
+ resolveDynamicComponent(value),
4702
+ rawProps,
4703
+ rawSlots,
4704
+ isSingleRoot,
4705
+ once,
4706
+ appContext
4707
+ )
4611
4708
  ),
4612
4709
  value
4613
4710
  );
@@ -4798,7 +4895,15 @@ const VaporTransitionGroup = decorate({
4798
4895
  setup(props, { slots }) {
4799
4896
  const instance = currentInstance;
4800
4897
  const state = useTransitionState();
4801
- const cssTransitionProps = resolveTransitionProps(props);
4898
+ let cssTransitionProps = resolveTransitionProps(props);
4899
+ const propsProxy = new Proxy({}, {
4900
+ get(_, key) {
4901
+ return cssTransitionProps[key];
4902
+ }
4903
+ });
4904
+ renderEffect(() => {
4905
+ cssTransitionProps = resolveTransitionProps(props);
4906
+ });
4802
4907
  let prevChildren;
4803
4908
  let children;
4804
4909
  const slottedBlock = slots.default && slots.default();
@@ -4849,7 +4954,7 @@ const VaporTransitionGroup = decorate({
4849
4954
  prevChildren = [];
4850
4955
  });
4851
4956
  setTransitionHooksOnFragment(slottedBlock, {
4852
- props: cssTransitionProps,
4957
+ props: propsProxy,
4853
4958
  state,
4854
4959
  instance
4855
4960
  });
@@ -4860,7 +4965,7 @@ const VaporTransitionGroup = decorate({
4860
4965
  if (child.$key != null) {
4861
4966
  const hooks = resolveTransitionHooks(
4862
4967
  child,
4863
- cssTransitionProps,
4968
+ propsProxy,
4864
4969
  state,
4865
4970
  instance
4866
4971
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-vapor",
3
- "version": "3.6.0-alpha.7",
3
+ "version": "3.6.0-beta.1",
4
4
  "description": "@vue/runtime-vapor",
5
5
  "main": "index.js",
6
6
  "module": "dist/runtime-vapor.esm-bundler.js",
@@ -38,10 +38,10 @@
38
38
  },
39
39
  "homepage": "https://github.com/vuejs/core/tree/dev/packages/runtime-vapor#readme",
40
40
  "dependencies": {
41
- "@vue/shared": "3.6.0-alpha.7",
42
- "@vue/reactivity": "3.6.0-alpha.7"
41
+ "@vue/shared": "3.6.0-beta.1",
42
+ "@vue/reactivity": "3.6.0-beta.1"
43
43
  },
44
44
  "peerDependencies": {
45
- "@vue/runtime-dom": "3.6.0-alpha.7"
45
+ "@vue/runtime-dom": "3.6.0-beta.1"
46
46
  }
47
47
  }