@tanstack/router-core 1.162.9 → 1.163.3

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
- import { Store } from '@tanstack/store';
2
1
  import { loadRouteChunk } from './load-matches.cjs';
2
+ import { Store } from '@tanstack/store';
3
3
  import { LRUCache } from './lru-cache.cjs';
4
4
  import { ProcessRouteTreeResult, ProcessedTree } from './new-process-route-tree.cjs';
5
5
  import { SearchParser, SearchSerializer } from './searchParams.cjs';
@@ -1,5 +1,5 @@
1
- import { Store } from '@tanstack/store';
2
1
  import { loadRouteChunk } from './load-matches.js';
2
+ import { Store } from '@tanstack/store';
3
3
  import { LRUCache } from './lru-cache.js';
4
4
  import { ProcessRouteTreeResult, ProcessedTree } from './new-process-route-tree.js';
5
5
  import { SearchParser, SearchSerializer } from './searchParams.js';
@@ -1,4 +1,4 @@
1
- import { Store } from "@tanstack/store";
1
+ import { createStore } from "@tanstack/store";
2
2
  import { createBrowserHistory, parseHref } from "@tanstack/history";
3
3
  import { isServer } from "@tanstack/router-core/isServer";
4
4
  import { batch } from "./utils/batch.js";
@@ -137,7 +137,7 @@ class RouterCore {
137
137
  getInitialRouterState(this.latestLocation)
138
138
  );
139
139
  } else {
140
- this.__store = new Store(getInitialRouterState(this.latestLocation));
140
+ this.__store = createStore(getInitialRouterState(this.latestLocation));
141
141
  setupScrollRestoration(this);
142
142
  }
143
143
  }
@@ -729,8 +729,9 @@ class RouterCore {
729
729
  this.startTransition(() => {
730
730
  this.startViewTransition(async () => {
731
731
  let exitingMatches = [];
732
- let enteringMatches = [];
733
- let stayingMatches = [];
732
+ let hookExitingMatches = [];
733
+ let hookEnteringMatches = [];
734
+ let hookStayingMatches = [];
734
735
  batch(() => {
735
736
  this.__store.setState((s) => {
736
737
  const previousMatches = s.matches;
@@ -738,11 +739,18 @@ class RouterCore {
738
739
  exitingMatches = previousMatches.filter(
739
740
  (match) => !newMatches.some((d) => d.id === match.id)
740
741
  );
741
- enteringMatches = newMatches.filter(
742
- (match) => !previousMatches.some((d) => d.id === match.id)
742
+ hookExitingMatches = previousMatches.filter(
743
+ (match) => !newMatches.some((d) => d.routeId === match.routeId)
743
744
  );
744
- stayingMatches = newMatches.filter(
745
- (match) => previousMatches.some((d) => d.id === match.id)
745
+ hookEnteringMatches = newMatches.filter(
746
+ (match) => !previousMatches.some(
747
+ (d) => d.routeId === match.routeId
748
+ )
749
+ );
750
+ hookStayingMatches = newMatches.filter(
751
+ (match) => previousMatches.some(
752
+ (d) => d.routeId === match.routeId
753
+ )
746
754
  );
747
755
  return {
748
756
  ...s,
@@ -767,9 +775,9 @@ class RouterCore {
767
775
  this.clearExpiredCache();
768
776
  });
769
777
  [
770
- [exitingMatches, "onLeave"],
771
- [enteringMatches, "onEnter"],
772
- [stayingMatches, "onStay"]
778
+ [hookExitingMatches, "onLeave"],
779
+ [hookEnteringMatches, "onEnter"],
780
+ [hookStayingMatches, "onStay"]
773
781
  ].forEach(([matches, hook]) => {
774
782
  matches.forEach((match) => {
775
783
  this.looseRoutesById[match.routeId].options[hook]?.(