@jsenv/navi 0.18.28 → 0.18.29

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.
@@ -12512,6 +12512,8 @@ const RootElement = () => {
12512
12512
  };
12513
12513
  const SlotContext = createContext(null);
12514
12514
  const RouteInfoContext = createContext(null);
12515
+ const UpdateOnlyContext = createContext(false);
12516
+ const elementSignals = new WeakMap();
12515
12517
  const Routes = ({
12516
12518
  element = jsx(RootElement, {}),
12517
12519
  children
@@ -12538,7 +12540,28 @@ const Route = ({
12538
12540
  const forceRender = useForceRender();
12539
12541
  const hasDiscoveredRef = useRef(false);
12540
12542
  const matchingInfoRef = useRef(null);
12543
+ const isUpdateOnly = useContext(UpdateOnlyContext);
12544
+
12545
+ // Update the element signal for this route.
12546
+ // In update-only mode this is the only purpose of rendering this Route.
12547
+ if (route && elementSignals.has(route)) {
12548
+ elementSignals.get(route).value = element;
12549
+ }
12550
+ if (isUpdateOnly) {
12551
+ if (children) {
12552
+ return jsx(UpdateOnlyContext.Provider, {
12553
+ value: true,
12554
+ children: children
12555
+ });
12556
+ }
12557
+ return null;
12558
+ }
12541
12559
  if (!hasDiscoveredRef.current) {
12560
+ // Create the element signal during discovery
12561
+ if (route && !elementSignals.has(route)) {
12562
+ // eslint-disable-next-line signals/no-signal-in-component-body
12563
+ elementSignals.set(route, signal(element));
12564
+ }
12542
12565
  return jsx(RouteMatchManager, {
12543
12566
  element: element,
12544
12567
  action: action,
@@ -12562,7 +12585,14 @@ const Route = ({
12562
12585
  const {
12563
12586
  MatchingElement
12564
12587
  } = matchingInfo;
12565
- return jsx(MatchingElement, {});
12588
+ // After discovery: render MatchingElement for visible output, and keep
12589
+ // children alive in update-only mode so their element signals stay current.
12590
+ return jsxs(Fragment, {
12591
+ children: [jsx(MatchingElement, {}), children ? jsx(UpdateOnlyContext.Provider, {
12592
+ value: true,
12593
+ children: children
12594
+ }) : null]
12595
+ });
12566
12596
  };
12567
12597
  const RegisterChildRouteContext = createContext(null);
12568
12598
 
@@ -12725,18 +12755,23 @@ const initRouteObserver = ({
12725
12755
  const matchingRouteInfoSignal = signal();
12726
12756
  const SlotMatchingElementSignal = signal();
12727
12757
  const MatchingElement = () => {
12758
+ // Read element from the signal (updated by update-only renders) when
12759
+ // available, falling back to the closure variable for routes without
12760
+ // a route prop (e.g. the Routes wrapper).
12761
+ const elementSignal = route ? elementSignals.get(route) : undefined;
12762
+ const currentElement = elementSignal ? elementSignal.value : element;
12728
12763
  const matchingRouteInfo = matchingRouteInfoSignal.value;
12729
12764
  useUITransitionContentId(matchingRouteInfo ? matchingRouteInfo.route.urlPattern : fallback ? "fallback" : undefined);
12730
12765
  const SlotMatchingElement = SlotMatchingElementSignal.value;
12731
- element = action ? jsx(ActionRenderer, {
12766
+ const renderedElement = action ? jsx(ActionRenderer, {
12732
12767
  action: action,
12733
- children: element
12734
- }) : element;
12768
+ children: currentElement
12769
+ }) : currentElement;
12735
12770
  return jsx(RouteInfoContext.Provider, {
12736
12771
  value: matchingRouteInfo,
12737
12772
  children: jsx(SlotContext.Provider, {
12738
12773
  value: SlotMatchingElement,
12739
- children: element
12774
+ children: renderedElement
12740
12775
  })
12741
12776
  });
12742
12777
  };