@vue/runtime-vapor 3.6.0-beta.1 → 3.6.0-beta.2

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.
@@ -396,7 +396,6 @@ export declare function setInsertionState(parent: ParentNode & {
396
396
  $fc?: Node | null;
397
397
  }, anchor?: Node | 0 | null | number, last?: boolean): void;
398
398
 
399
- /*! #__NO_SIDE_EFFECTS__ */
400
399
  export declare function template(html: string, root?: boolean, ns?: Namespace): () => Node & {
401
400
  $root?: true;
402
401
  };
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vue/runtime-vapor v3.6.0-beta.1
2
+ * @vue/runtime-vapor v3.6.0-beta.2
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, 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';
6
+ import { queuePostFlushCb, isMismatchAllowed, warn, callWithAsyncErrorHandling, currentInstance, unsafeToTrustedHTML, patchStyle, xlinkNS, mergeProps, shouldSetAsProp, toClassSet, isSetEqual, warnPropMismatch, toStyleMap, vShowHidden, isMapEqual, isValidHtmlOrSvgAttribute, getAttributeMismatch, TransitionPropsValidators, isAsyncWrapper, getComponentName, isTemplateNode, checkTransitionMode, resolveTransitionProps, useTransitionState, baseResolveTransitionHooks, leaveCbKey, watch, onMounted, onUpdated, onBeforeUnmount, matches, devtoolsComponentAdded, resetShapeFlag, isKeepAlive, ensureRenderer, shallowRef, simpleSetCurrentInstance, renderSlot, ensureVaporSlotFallback, createVNode, shallowReactive, createInternalObject, isEmitListener, onScopeDispose, activate as activate$1, setTransitionHooks as setTransitionHooks$1, normalizeRef, setRef as setRef$1, Fragment, isRef, ensureHydrationRenderer, deactivate as deactivate$1, isVNode, baseEmit, baseNormalizePropsOptions, pushWarningContext, validateProps, popWarningContext, setCurrentInstance, resolvePropValue, startMeasure, queueJob, 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
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
 
@@ -30,22 +30,22 @@ function resetInsertionState() {
30
30
  insertionParent = insertionAnchor = isLastInsertion = void 0;
31
31
  }
32
32
 
33
- const isHydratingStack = [];
34
- let isHydrating = false;
35
33
  let currentHydrationNode = null;
36
- function pushIsHydrating(value) {
37
- isHydratingStack.push(isHydrating = value);
38
- }
39
- function popIsHydrating() {
40
- isHydratingStack.pop();
41
- isHydrating = isHydratingStack[isHydratingStack.length - 1] || false;
34
+ let _hydrateDynamicFragment;
35
+ let isHydrating = false;
36
+ function setIsHydrating(value) {
37
+ try {
38
+ return isHydrating;
39
+ } finally {
40
+ isHydrating = value;
41
+ }
42
42
  }
43
43
  function runWithoutHydration(fn) {
44
+ const prev = setIsHydrating(false);
44
45
  try {
45
- pushIsHydrating(false);
46
46
  return fn();
47
47
  } finally {
48
- popIsHydrating();
48
+ setIsHydrating(prev);
49
49
  }
50
50
  }
51
51
  let isOptimized$1 = false;
@@ -53,6 +53,7 @@ function performHydration(fn, setup, cleanup) {
53
53
  if (!isOptimized$1) {
54
54
  adoptTemplate = adoptTemplateImpl;
55
55
  locateHydrationNode = locateHydrationNodeImpl;
56
+ _hydrateDynamicFragment = hydrateDynamicFragmentImpl;
56
57
  Comment.prototype.$fe = void 0;
57
58
  Node.prototype.$pns = void 0;
58
59
  Node.prototype.$idx = void 0;
@@ -64,12 +65,12 @@ function performHydration(fn, setup, cleanup) {
64
65
  isOptimized$1 = true;
65
66
  }
66
67
  enableHydrationNodeLookup();
67
- pushIsHydrating(true);
68
+ const prev = setIsHydrating(true);
68
69
  setup();
69
70
  const res = fn();
70
71
  cleanup();
71
72
  currentHydrationNode = null;
72
- popIsHydrating();
73
+ setIsHydrating(prev);
73
74
  if (!isHydrating) disableHydrationNodeLookup();
74
75
  return res;
75
76
  }
@@ -229,6 +230,50 @@ function removeFragmentNodes(node, endAnchor) {
229
230
  }
230
231
  }
231
232
  }
233
+ function hydrateDynamicFragment(frag, isEmpty) {
234
+ _hydrateDynamicFragment && _hydrateDynamicFragment(frag, isEmpty);
235
+ }
236
+ function hydrateDynamicFragmentImpl(frag, isEmpty) {
237
+ if (frag.anchor) return;
238
+ if (frag.anchorLabel === "if") {
239
+ if (isEmpty) {
240
+ frag.anchor = locateFragmentEndAnchor("");
241
+ if (!!(process.env.NODE_ENV !== "production") && !frag.anchor) {
242
+ throw new Error(
243
+ "Failed to locate if anchor. this is likely a Vue internal bug."
244
+ );
245
+ } else {
246
+ if (!!(process.env.NODE_ENV !== "production")) {
247
+ frag.anchor.data = frag.anchorLabel;
248
+ }
249
+ return;
250
+ }
251
+ }
252
+ } else if (frag.anchorLabel === "slot") {
253
+ if (isEmpty && isComment(currentHydrationNode, "")) {
254
+ frag.anchor = currentHydrationNode;
255
+ if (!!(process.env.NODE_ENV !== "production")) {
256
+ frag.anchor.data = frag.anchorLabel;
257
+ }
258
+ return;
259
+ }
260
+ frag.anchor = locateFragmentEndAnchor();
261
+ if (!!(process.env.NODE_ENV !== "production") && !frag.anchor) {
262
+ throw new Error(
263
+ "Failed to locate slot anchor. this is likely a Vue internal bug."
264
+ );
265
+ } else {
266
+ return;
267
+ }
268
+ }
269
+ const { parentNode: pn, nextNode } = findBlockNode(frag.nodes);
270
+ queuePostFlushCb(() => {
271
+ pn.insertBefore(
272
+ frag.anchor = !!(process.env.NODE_ENV !== "production") ? createComment(frag.anchorLabel) : createTextNode(),
273
+ nextNode
274
+ );
275
+ });
276
+ }
232
277
 
233
278
  // @__NO_SIDE_EFFECTS__
234
279
  function createElement(tagName) {
@@ -847,7 +892,242 @@ function shouldForceHydrate(el, key) {
847
892
  tagName.includes("-");
848
893
  }
849
894
 
850
- /*! #__NO_SIDE_EFFECTS__ */
895
+ const displayName = "VaporTransition";
896
+ let registered = false;
897
+ const ensureTransitionHooksRegistered = () => {
898
+ if (!registered) {
899
+ registered = true;
900
+ registerTransitionHooks(
901
+ applyTransitionHooksImpl,
902
+ applyTransitionLeaveHooksImpl
903
+ );
904
+ }
905
+ };
906
+ const decorate$1 = (t) => {
907
+ t.displayName = displayName;
908
+ t.props = TransitionPropsValidators;
909
+ t.__vapor = true;
910
+ return t;
911
+ };
912
+ const VaporTransition = /* @__PURE__ */ decorate$1((props, { slots }) => {
913
+ ensureTransitionHooksRegistered();
914
+ let resetDisplay;
915
+ if (isHydrating && currentHydrationNode && isTemplateNode(currentHydrationNode)) {
916
+ const {
917
+ content: { firstChild },
918
+ parentNode
919
+ } = currentHydrationNode;
920
+ if (firstChild) {
921
+ if (firstChild instanceof HTMLElement || firstChild instanceof SVGElement) {
922
+ const originalDisplay = firstChild.style.display;
923
+ firstChild.style.display = "none";
924
+ resetDisplay = () => firstChild.style.display = originalDisplay;
925
+ }
926
+ parentNode.replaceChild(firstChild, currentHydrationNode);
927
+ setCurrentHydrationNode(firstChild);
928
+ }
929
+ }
930
+ const children = slots.default && slots.default();
931
+ if (!children) return [];
932
+ const instance = currentInstance;
933
+ const { mode } = props;
934
+ checkTransitionMode(mode);
935
+ let resolvedProps;
936
+ renderEffect(() => resolvedProps = resolveTransitionProps(props));
937
+ const hooks = applyTransitionHooksImpl(children, {
938
+ state: useTransitionState(),
939
+ // use proxy to keep props reference stable
940
+ props: new Proxy({}, {
941
+ get(_, key) {
942
+ return resolvedProps[key];
943
+ }
944
+ }),
945
+ instance
946
+ });
947
+ if (resetDisplay && resolvedProps.appear) {
948
+ const child = findTransitionBlock(children);
949
+ hooks.beforeEnter(child);
950
+ resetDisplay();
951
+ queuePostFlushCb(() => hooks.enter(child));
952
+ }
953
+ return children;
954
+ });
955
+ const getTransitionHooksContext = (key, props, state, instance, postClone) => {
956
+ const { leavingNodes } = state;
957
+ const context = {
958
+ setLeavingNodeCache: (el) => {
959
+ leavingNodes.set(key, el);
960
+ },
961
+ unsetLeavingNodeCache: (el) => {
962
+ const leavingNode = leavingNodes.get(key);
963
+ if (leavingNode === el) {
964
+ leavingNodes.delete(key);
965
+ }
966
+ },
967
+ earlyRemove: () => {
968
+ const leavingNode = leavingNodes.get(key);
969
+ if (leavingNode && leavingNode[leaveCbKey]) {
970
+ leavingNode[leaveCbKey]();
971
+ }
972
+ },
973
+ cloneHooks: (block) => {
974
+ const hooks = resolveTransitionHooks(
975
+ block,
976
+ props,
977
+ state,
978
+ instance,
979
+ postClone
980
+ );
981
+ if (postClone) postClone(hooks);
982
+ return hooks;
983
+ }
984
+ };
985
+ return context;
986
+ };
987
+ function resolveTransitionHooks(block, props, state, instance, postClone) {
988
+ const context = getTransitionHooksContext(
989
+ String(block.$key),
990
+ props,
991
+ state,
992
+ instance,
993
+ postClone
994
+ );
995
+ const hooks = baseResolveTransitionHooks(
996
+ context,
997
+ props,
998
+ state,
999
+ instance
1000
+ );
1001
+ hooks.state = state;
1002
+ hooks.props = props;
1003
+ hooks.instance = instance;
1004
+ return hooks;
1005
+ }
1006
+ function applyTransitionHooksImpl(block, hooks) {
1007
+ if (isArray(block)) {
1008
+ block = block.filter((b) => !(b instanceof Comment));
1009
+ if (block.length === 1) {
1010
+ block = block[0];
1011
+ } else if (block.length === 0) {
1012
+ return hooks;
1013
+ }
1014
+ }
1015
+ const fragments = [];
1016
+ const child = findTransitionBlock(block, (frag) => fragments.push(frag));
1017
+ if (!child) {
1018
+ fragments.forEach((f) => f.$transition = hooks);
1019
+ if (!!(process.env.NODE_ENV !== "production") && fragments.length === 0) {
1020
+ warn("Transition component has no valid child element");
1021
+ }
1022
+ return hooks;
1023
+ }
1024
+ const { props, instance, state, delayedLeave } = hooks;
1025
+ let resolvedHooks = resolveTransitionHooks(
1026
+ child,
1027
+ props,
1028
+ state,
1029
+ instance,
1030
+ (hooks2) => resolvedHooks = hooks2
1031
+ );
1032
+ resolvedHooks.delayedLeave = delayedLeave;
1033
+ child.$transition = resolvedHooks;
1034
+ fragments.forEach((f) => f.$transition = resolvedHooks);
1035
+ return resolvedHooks;
1036
+ }
1037
+ function applyTransitionLeaveHooksImpl(block, enterHooks, afterLeaveCb) {
1038
+ const leavingBlock = findTransitionBlock(block);
1039
+ if (!leavingBlock) return void 0;
1040
+ const { props, state, instance } = enterHooks;
1041
+ const leavingHooks = resolveTransitionHooks(
1042
+ leavingBlock,
1043
+ props,
1044
+ state,
1045
+ instance
1046
+ );
1047
+ leavingBlock.$transition = leavingHooks;
1048
+ const { mode } = props;
1049
+ if (mode === "out-in") {
1050
+ state.isLeaving = true;
1051
+ leavingHooks.afterLeave = () => {
1052
+ state.isLeaving = false;
1053
+ afterLeaveCb();
1054
+ leavingBlock.$transition = void 0;
1055
+ delete leavingHooks.afterLeave;
1056
+ };
1057
+ } else if (mode === "in-out") {
1058
+ leavingHooks.delayLeave = (block2, earlyRemove, delayedLeave) => {
1059
+ state.leavingNodes.set(String(leavingBlock.$key), leavingBlock);
1060
+ block2[leaveCbKey] = () => {
1061
+ earlyRemove();
1062
+ block2[leaveCbKey] = void 0;
1063
+ leavingBlock.$transition = void 0;
1064
+ delete enterHooks.delayedLeave;
1065
+ };
1066
+ enterHooks.delayedLeave = () => {
1067
+ delayedLeave();
1068
+ leavingBlock.$transition = void 0;
1069
+ delete enterHooks.delayedLeave;
1070
+ };
1071
+ };
1072
+ }
1073
+ }
1074
+ function findTransitionBlock(block, onFragment) {
1075
+ let child;
1076
+ if (block instanceof Node) {
1077
+ if (block instanceof Element) child = block;
1078
+ } else if (isVaporComponent(block)) {
1079
+ if (isAsyncWrapper(block) && !block.type.__asyncResolved) {
1080
+ child = block;
1081
+ } else {
1082
+ if (getComponentName(block.type) === displayName) return void 0;
1083
+ child = findTransitionBlock(block.block, onFragment);
1084
+ if (child && child.$key === void 0) child.$key = block.uid;
1085
+ }
1086
+ } else if (isArray(block)) {
1087
+ let hasFound = false;
1088
+ for (const c of block) {
1089
+ if (c instanceof Comment) continue;
1090
+ const item = findTransitionBlock(c, onFragment);
1091
+ if (!!(process.env.NODE_ENV !== "production") && hasFound) {
1092
+ warn(
1093
+ "<transition> can only be used on a single element or component. Use <transition-group> for lists."
1094
+ );
1095
+ break;
1096
+ }
1097
+ child = item;
1098
+ hasFound = true;
1099
+ if (!!!(process.env.NODE_ENV !== "production")) break;
1100
+ }
1101
+ } else if (isFragment(block)) {
1102
+ if (block.insert) {
1103
+ child = block;
1104
+ } else {
1105
+ if (onFragment) onFragment(block);
1106
+ child = findTransitionBlock(block.nodes, onFragment);
1107
+ }
1108
+ }
1109
+ return child;
1110
+ }
1111
+ function setTransitionHooksOnFragment(block, hooks) {
1112
+ if (isFragment(block)) {
1113
+ block.$transition = hooks;
1114
+ if (block.nodes && isFragment(block.nodes)) {
1115
+ setTransitionHooksOnFragment(block.nodes, hooks);
1116
+ }
1117
+ } else if (isArray(block)) {
1118
+ for (let i = 0; i < block.length; i++) {
1119
+ setTransitionHooksOnFragment(block[i], hooks);
1120
+ }
1121
+ }
1122
+ }
1123
+ function setTransitionHooks(block, hooks) {
1124
+ if (isVaporComponent(block)) {
1125
+ block = findTransitionBlock(block.block);
1126
+ if (!block) return;
1127
+ }
1128
+ block.$transition = hooks;
1129
+ }
1130
+
851
1131
  // @__NO_SIDE_EFFECTS__
852
1132
  function defineVaporComponent(comp, extraOptions) {
853
1133
  if (isFunction(comp)) {
@@ -860,7 +1140,7 @@ function defineVaporComponent(comp, extraOptions) {
860
1140
  return comp;
861
1141
  }
862
1142
 
863
- const VaporKeepAliveImpl = defineVaporComponent({
1143
+ const KeepAliveImpl = defineVaporComponent({
864
1144
  name: "VaporKeepAlive",
865
1145
  __isKeepAlive: true,
866
1146
  props: {
@@ -1040,6 +1320,7 @@ const VaporKeepAliveImpl = defineVaporComponent({
1040
1320
  return children;
1041
1321
  }
1042
1322
  });
1323
+ const VaporKeepAliveImpl = KeepAliveImpl;
1043
1324
  const shouldCache = (block, props, interop = false) => {
1044
1325
  const isAsync = !interop && isAsyncWrapper(block);
1045
1326
  const type = interop ? block.vnode.type : block.type;
@@ -1384,6 +1665,9 @@ function createVDOMComponent(internals, component, parentComponent, rawProps, ra
1384
1665
  },
1385
1666
  instance
1386
1667
  );
1668
+ if (isMounted && rawRef) {
1669
+ setRef$1(rawRef, null, null, vnode);
1670
+ }
1387
1671
  };
1388
1672
  return frag;
1389
1673
  }
@@ -1923,10 +2207,12 @@ const dynamicSlotsProxyHandlers = {
1923
2207
  for (const source of dynamicSources) {
1924
2208
  if (isFunction(source)) {
1925
2209
  const slot = resolveFunctionSource(source);
1926
- if (isArray(slot)) {
1927
- for (const s of slot) keys.push(String(s.name));
1928
- } else {
1929
- keys.push(String(slot.name));
2210
+ if (slot) {
2211
+ if (isArray(slot)) {
2212
+ for (const s of slot) keys.push(String(s.name));
2213
+ } else {
2214
+ keys.push(String(slot.name));
2215
+ }
1930
2216
  }
1931
2217
  } else {
1932
2218
  keys.push(...Object.keys(source));
@@ -2144,231 +2430,6 @@ function renderEffect(fn, noLifecycle = false) {
2144
2430
  effect.run();
2145
2431
  }
2146
2432
 
2147
- const displayName = "VaporTransition";
2148
- const decorate$1 = (t) => {
2149
- t.displayName = displayName;
2150
- t.props = TransitionPropsValidators;
2151
- t.__vapor = true;
2152
- return t;
2153
- };
2154
- const VaporTransition = /* @__PURE__ */ decorate$1((props, { slots }) => {
2155
- let resetDisplay;
2156
- if (isHydrating && currentHydrationNode && isTemplateNode(currentHydrationNode)) {
2157
- const {
2158
- content: { firstChild },
2159
- parentNode
2160
- } = currentHydrationNode;
2161
- if (firstChild) {
2162
- if (firstChild instanceof HTMLElement || firstChild instanceof SVGElement) {
2163
- const originalDisplay = firstChild.style.display;
2164
- firstChild.style.display = "none";
2165
- resetDisplay = () => firstChild.style.display = originalDisplay;
2166
- }
2167
- parentNode.replaceChild(firstChild, currentHydrationNode);
2168
- setCurrentHydrationNode(firstChild);
2169
- }
2170
- }
2171
- const children = slots.default && slots.default();
2172
- if (!children) return [];
2173
- const instance = currentInstance;
2174
- const { mode } = props;
2175
- checkTransitionMode(mode);
2176
- let resolvedProps;
2177
- renderEffect(() => resolvedProps = resolveTransitionProps(props));
2178
- const hooks = applyTransitionHooks(children, {
2179
- state: useTransitionState(),
2180
- // use proxy to keep props reference stable
2181
- props: new Proxy({}, {
2182
- get(_, key) {
2183
- return resolvedProps[key];
2184
- }
2185
- }),
2186
- instance
2187
- });
2188
- if (resetDisplay && resolvedProps.appear) {
2189
- const child = findTransitionBlock(children);
2190
- hooks.beforeEnter(child);
2191
- resetDisplay();
2192
- queuePostFlushCb(() => hooks.enter(child));
2193
- }
2194
- return children;
2195
- });
2196
- const getTransitionHooksContext = (key, props, state, instance, postClone) => {
2197
- const { leavingNodes } = state;
2198
- const context = {
2199
- setLeavingNodeCache: (el) => {
2200
- leavingNodes.set(key, el);
2201
- },
2202
- unsetLeavingNodeCache: (el) => {
2203
- const leavingNode = leavingNodes.get(key);
2204
- if (leavingNode === el) {
2205
- leavingNodes.delete(key);
2206
- }
2207
- },
2208
- earlyRemove: () => {
2209
- const leavingNode = leavingNodes.get(key);
2210
- if (leavingNode && leavingNode[leaveCbKey]) {
2211
- leavingNode[leaveCbKey]();
2212
- }
2213
- },
2214
- cloneHooks: (block) => {
2215
- const hooks = resolveTransitionHooks(
2216
- block,
2217
- props,
2218
- state,
2219
- instance,
2220
- postClone
2221
- );
2222
- if (postClone) postClone(hooks);
2223
- return hooks;
2224
- }
2225
- };
2226
- return context;
2227
- };
2228
- function resolveTransitionHooks(block, props, state, instance, postClone) {
2229
- const context = getTransitionHooksContext(
2230
- String(block.$key),
2231
- props,
2232
- state,
2233
- instance,
2234
- postClone
2235
- );
2236
- const hooks = baseResolveTransitionHooks(
2237
- context,
2238
- props,
2239
- state,
2240
- instance
2241
- );
2242
- hooks.state = state;
2243
- hooks.props = props;
2244
- hooks.instance = instance;
2245
- return hooks;
2246
- }
2247
- function applyTransitionHooks(block, hooks) {
2248
- if (isArray(block)) {
2249
- block = block.filter((b) => !(b instanceof Comment));
2250
- if (block.length === 1) {
2251
- block = block[0];
2252
- } else if (block.length === 0) {
2253
- return hooks;
2254
- }
2255
- }
2256
- const fragments = [];
2257
- const child = findTransitionBlock(block, (frag) => fragments.push(frag));
2258
- if (!child) {
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
- }
2263
- return hooks;
2264
- }
2265
- const { props, instance, state, delayedLeave } = hooks;
2266
- let resolvedHooks = resolveTransitionHooks(
2267
- child,
2268
- props,
2269
- state,
2270
- instance,
2271
- (hooks2) => resolvedHooks = hooks2
2272
- );
2273
- resolvedHooks.delayedLeave = delayedLeave;
2274
- child.$transition = resolvedHooks;
2275
- fragments.forEach((f) => f.$transition = resolvedHooks);
2276
- return resolvedHooks;
2277
- }
2278
- function applyTransitionLeaveHooks(block, enterHooks, afterLeaveCb) {
2279
- const leavingBlock = findTransitionBlock(block);
2280
- if (!leavingBlock) return void 0;
2281
- const { props, state, instance } = enterHooks;
2282
- const leavingHooks = resolveTransitionHooks(
2283
- leavingBlock,
2284
- props,
2285
- state,
2286
- instance
2287
- );
2288
- leavingBlock.$transition = leavingHooks;
2289
- const { mode } = props;
2290
- if (mode === "out-in") {
2291
- state.isLeaving = true;
2292
- leavingHooks.afterLeave = () => {
2293
- state.isLeaving = false;
2294
- afterLeaveCb();
2295
- leavingBlock.$transition = void 0;
2296
- delete leavingHooks.afterLeave;
2297
- };
2298
- } else if (mode === "in-out") {
2299
- leavingHooks.delayLeave = (block2, earlyRemove, delayedLeave) => {
2300
- state.leavingNodes.set(String(leavingBlock.$key), leavingBlock);
2301
- block2[leaveCbKey] = () => {
2302
- earlyRemove();
2303
- block2[leaveCbKey] = void 0;
2304
- leavingBlock.$transition = void 0;
2305
- delete enterHooks.delayedLeave;
2306
- };
2307
- enterHooks.delayedLeave = () => {
2308
- delayedLeave();
2309
- leavingBlock.$transition = void 0;
2310
- delete enterHooks.delayedLeave;
2311
- };
2312
- };
2313
- }
2314
- }
2315
- function findTransitionBlock(block, onFragment) {
2316
- let child;
2317
- if (block instanceof Node) {
2318
- if (block instanceof Element) child = block;
2319
- } else if (isVaporComponent(block)) {
2320
- if (isAsyncWrapper(block) && !block.type.__asyncResolved) {
2321
- child = block;
2322
- } else {
2323
- if (getComponentName(block.type) === displayName) return void 0;
2324
- child = findTransitionBlock(block.block, onFragment);
2325
- if (child && child.$key === void 0) child.$key = block.uid;
2326
- }
2327
- } else if (isArray(block)) {
2328
- let hasFound = false;
2329
- for (const c of block) {
2330
- if (c instanceof Comment) continue;
2331
- const item = findTransitionBlock(c, onFragment);
2332
- if (!!(process.env.NODE_ENV !== "production") && hasFound) {
2333
- warn(
2334
- "<transition> can only be used on a single element or component. Use <transition-group> for lists."
2335
- );
2336
- break;
2337
- }
2338
- child = item;
2339
- hasFound = true;
2340
- if (!!!(process.env.NODE_ENV !== "production")) break;
2341
- }
2342
- } else if (isFragment(block)) {
2343
- if (block.insert) {
2344
- child = block;
2345
- } else {
2346
- if (onFragment) onFragment(block);
2347
- child = findTransitionBlock(block.nodes, onFragment);
2348
- }
2349
- }
2350
- return child;
2351
- }
2352
- function setTransitionHooksOnFragment(block, hooks) {
2353
- if (isFragment(block)) {
2354
- block.$transition = hooks;
2355
- if (block.nodes && isFragment(block.nodes)) {
2356
- setTransitionHooksOnFragment(block.nodes, hooks);
2357
- }
2358
- } else if (isArray(block)) {
2359
- for (let i = 0; i < block.length; i++) {
2360
- setTransitionHooksOnFragment(block[i], hooks);
2361
- }
2362
- }
2363
- }
2364
- function setTransitionHooks(block, hooks) {
2365
- if (isVaporComponent(block)) {
2366
- block = findTransitionBlock(block.block);
2367
- if (!block) return;
2368
- }
2369
- block.$transition = hooks;
2370
- }
2371
-
2372
2433
  class VaporFragment {
2373
2434
  constructor(nodes) {
2374
2435
  this.vnode = null;
@@ -2384,45 +2445,7 @@ class DynamicFragment extends VaporFragment {
2384
2445
  constructor(anchorLabel) {
2385
2446
  super([]);
2386
2447
  this.hydrate = (isEmpty = false) => {
2387
- if (this.anchor) return;
2388
- if (this.anchorLabel === "if") {
2389
- if (isEmpty) {
2390
- this.anchor = locateFragmentEndAnchor("");
2391
- if (!!(process.env.NODE_ENV !== "production") && !this.anchor) {
2392
- throw new Error(
2393
- "Failed to locate if anchor. this is likely a Vue internal bug."
2394
- );
2395
- } else {
2396
- if (!!(process.env.NODE_ENV !== "production")) {
2397
- this.anchor.data = this.anchorLabel;
2398
- }
2399
- return;
2400
- }
2401
- }
2402
- } else if (this.anchorLabel === "slot") {
2403
- if (isEmpty && isComment(currentHydrationNode, "")) {
2404
- this.anchor = currentHydrationNode;
2405
- if (!!(process.env.NODE_ENV !== "production")) {
2406
- this.anchor.data = this.anchorLabel;
2407
- }
2408
- return;
2409
- }
2410
- this.anchor = locateFragmentEndAnchor();
2411
- if (!!(process.env.NODE_ENV !== "production") && !this.anchor) {
2412
- throw new Error(
2413
- "Failed to locate slot anchor. this is likely a Vue internal bug."
2414
- );
2415
- } else {
2416
- return;
2417
- }
2418
- }
2419
- const { parentNode, nextNode } = findBlockNode(this.nodes);
2420
- queuePostFlushCb(() => {
2421
- parentNode.insertBefore(
2422
- this.anchor = !!(process.env.NODE_ENV !== "production") ? createComment(this.anchorLabel) : createTextNode(),
2423
- nextNode
2424
- );
2425
- });
2448
+ hydrateDynamicFragment(this, isEmpty);
2426
2449
  };
2427
2450
  this.slotOwner = currentSlotOwner;
2428
2451
  if (isHydrating) {
@@ -2604,6 +2627,11 @@ const VaporTeleportImpl = {
2604
2627
  class TeleportFragment extends VaporFragment {
2605
2628
  constructor(props, slots) {
2606
2629
  super([]);
2630
+ /**
2631
+ * @internal marker for duck typing to avoid direct instanceof check
2632
+ * which prevents tree-shaking of TeleportFragment
2633
+ */
2634
+ this.__isTeleportFragment = true;
2607
2635
  this.insert = (container, anchor) => {
2608
2636
  if (isHydrating) return;
2609
2637
  this.placeholder = !!(process.env.NODE_ENV !== "production") ? createComment("teleport start") : createTextNode();
@@ -2817,7 +2845,10 @@ Server rendered element contains fewer child nodes than client nodes.`
2817
2845
  }
2818
2846
  }
2819
2847
  function isVaporTeleport(value) {
2820
- return value === VaporTeleportImpl;
2848
+ return !!(value && value.__isTeleport && value.__vapor);
2849
+ }
2850
+ function isTeleportFragment(value) {
2851
+ return !!(value && value.__isTeleportFragment);
2821
2852
  }
2822
2853
  function locateTeleportEndAnchor(node = currentHydrationNode) {
2823
2854
  while (node) {
@@ -3019,7 +3050,7 @@ function normalizeBlock(block) {
3019
3050
  } else if (isVaporComponent(block)) {
3020
3051
  nodes.push(...normalizeBlock(block.block));
3021
3052
  } else {
3022
- if (block instanceof TeleportFragment) {
3053
+ if (isTeleportFragment(block)) {
3023
3054
  nodes.push(block.placeholder, block.anchor);
3024
3055
  } else {
3025
3056
  nodes.push(...normalizeBlock(block.nodes));
@@ -3095,6 +3126,18 @@ function setComponentScopeId(instance) {
3095
3126
  setScopeId(instance.block, scopeIds);
3096
3127
  }
3097
3128
  }
3129
+ let _applyTransitionHooks;
3130
+ let _applyTransitionLeaveHooks;
3131
+ function registerTransitionHooks(applyHooks, applyLeaveHooks) {
3132
+ _applyTransitionHooks = applyHooks;
3133
+ _applyTransitionLeaveHooks = applyLeaveHooks;
3134
+ }
3135
+ function applyTransitionHooks(block, hooks) {
3136
+ return _applyTransitionHooks ? _applyTransitionHooks(block, hooks) : hooks;
3137
+ }
3138
+ function applyTransitionLeaveHooks(block, enterHooks, afterLeaveCb) {
3139
+ _applyTransitionLeaveHooks && _applyTransitionLeaveHooks(block, enterHooks, afterLeaveCb);
3140
+ }
3098
3141
 
3099
3142
  function hmrRerender(instance) {
3100
3143
  const normalized = normalizeBlock(instance.block);
@@ -3576,7 +3619,7 @@ function getRootElement(block, onDynamicFragment, recurse = true) {
3576
3619
  if (recurse && isVaporComponent(block)) {
3577
3620
  return getRootElement(block.block, onDynamicFragment, recurse);
3578
3621
  }
3579
- if (isFragment(block) && !(block instanceof TeleportFragment)) {
3622
+ if (isFragment(block) && !isTeleportFragment(block)) {
3580
3623
  if (block instanceof DynamicFragment && onDynamicFragment) {
3581
3624
  onDynamicFragment(block);
3582
3625
  }
@@ -3654,7 +3697,7 @@ function handleSetupResult(setupResult, component, instance) {
3654
3697
  });
3655
3698
  } else if (!!(process.env.NODE_ENV !== "production") && (!instance.accessedAttrs && isArray(instance.block) && instance.block.length || // preventing attrs fallthrough on Teleport
3656
3699
  // consistent with VDOM Teleport behavior
3657
- instance.block instanceof TeleportFragment)) {
3700
+ isTeleportFragment(instance.block))) {
3658
3701
  warnExtraneousAttributes(instance.attrs);
3659
3702
  }
3660
3703
  }
@@ -3991,7 +4034,6 @@ class VaporElement extends VueElementBase {
3991
4034
  }
3992
4035
 
3993
4036
  let t;
3994
- /*! #__NO_SIDE_EFFECTS__ */
3995
4037
  // @__NO_SIDE_EFFECTS__
3996
4038
  function template(html, root, ns) {
3997
4039
  let node;
@@ -4028,7 +4070,7 @@ function createIf(condition, b1, b2, once) {
4028
4070
  if (!isHydrating) resetInsertionState();
4029
4071
  let frag;
4030
4072
  if (once) {
4031
- frag = condition() ? b1() : b2 ? b2() : [];
4073
+ frag = condition() ? b1() : b2 ? b2() : [!!(process.env.NODE_ENV !== "production") ? createComment("if") : createTextNode()];
4032
4074
  } else {
4033
4075
  frag = isHydrating || !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("if") : new DynamicFragment();
4034
4076
  renderEffect(() => frag.update(condition() ? b1 : b2));
@@ -4659,11 +4701,11 @@ function resolveParentNode(block) {
4659
4701
  if (block instanceof Node) {
4660
4702
  return block.parentNode;
4661
4703
  } else if (isArray(block)) {
4662
- return resolveParentNode(block[0]);
4704
+ return resolveParentNode(block[block.length - 1]);
4663
4705
  } else if (isVaporComponent(block)) {
4664
4706
  return resolveParentNode(block.block);
4665
4707
  } else {
4666
- return resolveParentNode(block.nodes);
4708
+ return resolveParentNode(block.anchor || block.nodes);
4667
4709
  }
4668
4710
  }
4669
4711
  function setVars(instance, vars) {
@@ -4886,13 +4928,14 @@ const decorate = (t) => {
4886
4928
  t.__vapor = true;
4887
4929
  return t;
4888
4930
  };
4889
- const VaporTransitionGroup = decorate({
4931
+ const VaporTransitionGroupImpl = {
4890
4932
  name: "VaporTransitionGroup",
4891
4933
  props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
4892
4934
  tag: String,
4893
4935
  moveClass: String
4894
4936
  }),
4895
4937
  setup(props, { slots }) {
4938
+ ensureTransitionHooksRegistered();
4896
4939
  const instance = currentInstance;
4897
4940
  const state = useTransitionState();
4898
4941
  let cssTransitionProps = resolveTransitionProps(props);
@@ -4984,7 +5027,8 @@ const VaporTransitionGroup = decorate({
4984
5027
  return slottedBlock;
4985
5028
  }
4986
5029
  }
4987
- });
5030
+ };
5031
+ const VaporTransitionGroup = /* @__PURE__ */ decorate(VaporTransitionGroupImpl);
4988
5032
  function getTransitionBlocks(block) {
4989
5033
  let children = [];
4990
5034
  if (block instanceof Node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-vapor",
3
- "version": "3.6.0-beta.1",
3
+ "version": "3.6.0-beta.2",
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-beta.1",
42
- "@vue/reactivity": "3.6.0-beta.1"
41
+ "@vue/shared": "3.6.0-beta.2",
42
+ "@vue/reactivity": "3.6.0-beta.2"
43
43
  },
44
44
  "peerDependencies": {
45
- "@vue/runtime-dom": "3.6.0-beta.1"
45
+ "@vue/runtime-dom": "3.6.0-beta.2"
46
46
  }
47
47
  }