@jsenv/navi 0.18.29 → 0.18.30

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.
@@ -12513,17 +12513,24 @@ const RootElement = () => {
12513
12513
  const SlotContext = createContext(null);
12514
12514
  const RouteInfoContext = createContext(null);
12515
12515
  const UpdateOnlyContext = createContext(false);
12516
- const elementSignals = new WeakMap();
12516
+ const ElementSignalMapContext = createContext(null);
12517
12517
  const Routes = ({
12518
12518
  element = jsx(RootElement, {}),
12519
12519
  children
12520
12520
  }) => {
12521
12521
  const routeInfo = useMatchingRouteInfo();
12522
12522
  const route = routeInfo?.route;
12523
- return jsx(Route, {
12524
- route: route,
12525
- element: element,
12526
- children: children
12523
+ const elementSignalMapRef = useRef(null);
12524
+ if (!elementSignalMapRef.current) {
12525
+ elementSignalMapRef.current = new Map();
12526
+ }
12527
+ return jsx(ElementSignalMapContext.Provider, {
12528
+ value: elementSignalMapRef.current,
12529
+ children: jsx(Route, {
12530
+ route: route,
12531
+ element: element,
12532
+ children: children
12533
+ })
12527
12534
  });
12528
12535
  };
12529
12536
  const useMatchingRouteInfo = () => useContext(RouteInfoContext);
@@ -12541,11 +12548,12 @@ const Route = ({
12541
12548
  const hasDiscoveredRef = useRef(false);
12542
12549
  const matchingInfoRef = useRef(null);
12543
12550
  const isUpdateOnly = useContext(UpdateOnlyContext);
12551
+ const elementSignalMap = useContext(ElementSignalMapContext);
12544
12552
 
12545
12553
  // Update the element signal for this route.
12546
12554
  // 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;
12555
+ if (route && elementSignalMap && elementSignalMap.has(route)) {
12556
+ elementSignalMap.get(route).value = element;
12549
12557
  }
12550
12558
  if (isUpdateOnly) {
12551
12559
  if (children) {
@@ -12558,9 +12566,9 @@ const Route = ({
12558
12566
  }
12559
12567
  if (!hasDiscoveredRef.current) {
12560
12568
  // Create the element signal during discovery
12561
- if (route && !elementSignals.has(route)) {
12569
+ if (route && elementSignalMap && !elementSignalMap.has(route)) {
12562
12570
  // eslint-disable-next-line signals/no-signal-in-component-body
12563
- elementSignals.set(route, signal(element));
12571
+ elementSignalMap.set(route, signal(element));
12564
12572
  }
12565
12573
  return jsx(RouteMatchManager, {
12566
12574
  element: element,
@@ -12615,6 +12623,7 @@ const RouteMatchManager = ({
12615
12623
  throw new Error("Route cannot have both route and fallback props");
12616
12624
  }
12617
12625
  const parentRegisterChildRoute = useContext(RegisterChildRouteContext);
12626
+ const elementSignalMap = useContext(ElementSignalMapContext);
12618
12627
  const elementId = getElementSignature(element);
12619
12628
  const candidateSet = new Set();
12620
12629
  let indexCandidate = null;
@@ -12645,6 +12654,7 @@ const RouteMatchManager = ({
12645
12654
  useLayoutEffect(() => {
12646
12655
  initRouteObserver({
12647
12656
  element,
12657
+ elementSignalMap,
12648
12658
  action,
12649
12659
  route,
12650
12660
  index,
@@ -12665,6 +12675,7 @@ const RouteMatchManager = ({
12665
12675
  };
12666
12676
  const initRouteObserver = ({
12667
12677
  element,
12678
+ elementSignalMap,
12668
12679
  action,
12669
12680
  route,
12670
12681
  index,
@@ -12758,7 +12769,7 @@ const initRouteObserver = ({
12758
12769
  // Read element from the signal (updated by update-only renders) when
12759
12770
  // available, falling back to the closure variable for routes without
12760
12771
  // a route prop (e.g. the Routes wrapper).
12761
- const elementSignal = route ? elementSignals.get(route) : undefined;
12772
+ const elementSignal = route && elementSignalMap ? elementSignalMap.get(route) : undefined;
12762
12773
  const currentElement = elementSignal ? elementSignal.value : element;
12763
12774
  const matchingRouteInfo = matchingRouteInfoSignal.value;
12764
12775
  useUITransitionContentId(matchingRouteInfo ? matchingRouteInfo.route.urlPattern : fallback ? "fallback" : undefined);