one 2.0.0-beta.108.1 → 2.0.0-beta.111.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.
@@ -458,14 +458,23 @@ function syncStoreRootState() {
458
458
  }
459
459
  }
460
460
  }
461
+ function useRootStateSnapshot(snapshot2) {
462
+ const [state, rerender] = (0, import_react.useReducer)(snapshot2, void 0, snapshot2);
463
+ (0, import_react.useEffect)(() => {
464
+ const unsubscribe = subscribeToRootState(rerender);
465
+ rerender();
466
+ return unsubscribe;
467
+ }, []);
468
+ const browserPath = (0, import_path2.getSafeWindowPath)();
469
+ return browserPath !== void 0 && routeInfo?.unstable_globalHref === browserPath + window.location.hash ? snapshot2() : state;
470
+ }
461
471
  function useStoreRootState() {
462
472
  syncStoreRootState();
463
- const state = (0, import_react.useSyncExternalStore)(subscribeToRootState, rootStateSnapshot, rootStateSnapshot);
464
- return (0, import_react.useDeferredValue)(state);
473
+ return (0, import_react.useDeferredValue)(useRootStateSnapshot(rootStateSnapshot));
465
474
  }
466
475
  function useStoreRouteInfo() {
467
476
  syncStoreRootState();
468
- return (0, import_react.useSyncExternalStore)(subscribeToRootState, routeInfoSnapshot, routeInfoSnapshot);
477
+ return useRootStateSnapshot(routeInfoSnapshot);
469
478
  }
470
479
  function cleanup() {
471
480
  if (splashScreenAnimationFrame) cancelAnimationFrame(splashScreenAnimationFrame);
@@ -824,46 +833,48 @@ async function linkTo(href, event, options) {
824
833
  ...state,
825
834
  linkOptions: nextOptions
826
835
  } : state;
827
- updateState(optimisticState);
828
- pendingNavigationPathname = targetPathname;
829
- notifyRootStateSubscribers(optimisticState);
830
- if (event === "REPLACE") navigationRef.resetRoot(state);
831
- else {
832
- const action = (0, import_getNavigateAction.getNavigateAction)(state, freshRootState, event);
833
- const targetName = action.payload?.name;
834
- const isGroupTarget = typeof targetName === "string" && targetName.startsWith("(") && targetName.endsWith(")");
835
- const hasFreshRootState = freshRootState.type === "stack";
836
- const isRootTarget = action.target === freshRootState.key;
837
- const currentFocusedRoute = freshRootState.routes[freshRootState.index];
838
- const currentFocusedName = currentFocusedRoute?.name;
839
- if (isRootTarget && isGroupTarget && hasFreshRootState) {
840
- const targetRoute = state.routes[state.index ?? state.routes.length - 1];
841
- const targetRootName = targetRoute.name;
842
- if (currentFocusedName === targetRootName) {
843
- const routes = [...freshRootState.routes];
844
- routes[freshRootState.index] = {
845
- ...targetRoute,
846
- key: currentFocusedRoute?.key ?? targetRoute.key
847
- };
848
- navigationRef.resetRoot({
849
- ...freshRootState,
850
- routes
851
- });
852
- } else {
853
- const existingTargetRoute = freshRootState.routes.find((route) => route.name === targetRootName);
854
- const existingRoutes = freshRootState.routes.filter((route) => route.name !== targetRootName);
855
- const nextRootState = {
856
- ...freshRootState,
857
- routes: [...existingRoutes, {
836
+ const action = event === "REPLACE" ? null : (0, import_getNavigateAction.getNavigateAction)(state, freshRootState, event);
837
+ (0, import_react.startTransition)(() => {
838
+ updateState(optimisticState);
839
+ pendingNavigationPathname = targetPathname;
840
+ notifyRootStateSubscribers(optimisticState);
841
+ if (!action) navigationRef.resetRoot(state);
842
+ else {
843
+ const targetName = action.payload?.name;
844
+ const isGroupTarget = typeof targetName === "string" && targetName.startsWith("(") && targetName.endsWith(")");
845
+ const hasFreshRootState = freshRootState.type === "stack";
846
+ const isRootTarget = action.target === freshRootState.key;
847
+ const currentFocusedRoute = freshRootState.routes[freshRootState.index];
848
+ const currentFocusedName = currentFocusedRoute?.name;
849
+ if (isRootTarget && isGroupTarget && hasFreshRootState) {
850
+ const targetRoute = state.routes[state.index ?? state.routes.length - 1];
851
+ const targetRootName = targetRoute.name;
852
+ if (currentFocusedName === targetRootName) {
853
+ const routes = [...freshRootState.routes];
854
+ routes[freshRootState.index] = {
858
855
  ...targetRoute,
859
- key: existingTargetRoute?.key ?? `${targetRootName}-${freshRootState.key}`
860
- }],
861
- index: existingRoutes.length
862
- };
863
- navigationRef.resetRoot(nextRootState);
864
- }
865
- } else navigationRef.dispatch(action);
866
- }
856
+ key: currentFocusedRoute?.key ?? targetRoute.key
857
+ };
858
+ navigationRef.resetRoot({
859
+ ...freshRootState,
860
+ routes
861
+ });
862
+ } else {
863
+ const existingTargetRoute = freshRootState.routes.find((route) => route.name === targetRootName);
864
+ const existingRoutes = freshRootState.routes.filter((route) => route.name !== targetRootName);
865
+ const nextRootState = {
866
+ ...freshRootState,
867
+ routes: [...existingRoutes, {
868
+ ...targetRoute,
869
+ key: existingTargetRoute?.key ?? `${targetRootName}-${freshRootState.key}`
870
+ }],
871
+ index: existingRoutes.length
872
+ };
873
+ navigationRef.resetRoot(nextRootState);
874
+ }
875
+ } else navigationRef.dispatch(action);
876
+ }
877
+ });
867
878
  let warningTm;
868
879
  const interval = setInterval(() => {
869
880
  if (!navigationRef.isReady()) {
@@ -583,14 +583,23 @@ function syncStoreRootState() {
583
583
  }
584
584
  }
585
585
  }
586
+ function useRootStateSnapshot(snapshot2) {
587
+ var [state, rerender] = (0, import_react.useReducer)(snapshot2, void 0, snapshot2);
588
+ (0, import_react.useEffect)(function() {
589
+ var unsubscribe = subscribeToRootState(rerender);
590
+ rerender();
591
+ return unsubscribe;
592
+ }, []);
593
+ var browserPath = (0, import_path2.getSafeWindowPath)();
594
+ return browserPath !== void 0 && (routeInfo === null || routeInfo === void 0 ? void 0 : routeInfo.unstable_globalHref) === browserPath + window.location.hash ? snapshot2() : state;
595
+ }
586
596
  function useStoreRootState() {
587
597
  syncStoreRootState();
588
- var state = (0, import_react.useSyncExternalStore)(subscribeToRootState, rootStateSnapshot, rootStateSnapshot);
589
- return (0, import_react.useDeferredValue)(state);
598
+ return (0, import_react.useDeferredValue)(useRootStateSnapshot(rootStateSnapshot));
590
599
  }
591
600
  function useStoreRouteInfo() {
592
601
  syncStoreRootState();
593
- return (0, import_react.useSyncExternalStore)(subscribeToRootState, routeInfoSnapshot, routeInfoSnapshot);
602
+ return useRootStateSnapshot(routeInfoSnapshot);
594
603
  }
595
604
  function cleanup() {
596
605
  if (splashScreenAnimationFrame) cancelAnimationFrame(splashScreenAnimationFrame);
@@ -686,12 +695,12 @@ async function linkTo(href, event, options) {
686
695
  var _routeInfo_params;
687
696
  if (!segment.startsWith("[")) return segment;
688
697
  if (segment.startsWith("[...")) {
689
- var _ref3;
698
+ var _ref2;
690
699
  var _routeInfo_params1, _params_split;
691
700
  segment = segment.slice(4, -1);
692
701
  var params3 = routeInfo === null || routeInfo === void 0 ? void 0 : (_routeInfo_params1 = routeInfo.params) === null || _routeInfo_params1 === void 0 ? void 0 : _routeInfo_params1[segment];
693
702
  if (Array.isArray(params3)) return params3.join("/");
694
- return (_ref3 = params3 === null || params3 === void 0 ? void 0 : (_params_split = params3.split(",")) === null || _params_split === void 0 ? void 0 : _params_split.join("/")) !== null && _ref3 !== void 0 ? _ref3 : "";
703
+ return (_ref2 = params3 === null || params3 === void 0 ? void 0 : (_params_split = params3.split(",")) === null || _params_split === void 0 ? void 0 : _params_split.join("/")) !== null && _ref2 !== void 0 ? _ref2 : "";
695
704
  }
696
705
  segment = segment.slice(1, -1);
697
706
  return routeInfo === null || routeInfo === void 0 ? void 0 : (_routeInfo_params = routeInfo.params) === null || _routeInfo_params === void 0 ? void 0 : _routeInfo_params[segment];
@@ -811,54 +820,56 @@ async function linkTo(href, event, options) {
811
820
  ...state,
812
821
  linkOptions: nextOptions
813
822
  } : state;
814
- updateState(optimisticState);
815
- pendingNavigationPathname = targetPathname;
816
- notifyRootStateSubscribers(optimisticState);
817
- if (event === "REPLACE") navigationRef.resetRoot(state);
818
- else {
819
- var _action_payload;
820
- var action = (0, import_getNavigateAction.getNavigateAction)(state, freshRootState, event);
821
- var targetName = (_action_payload = action.payload) === null || _action_payload === void 0 ? void 0 : _action_payload.name;
822
- var isGroupTarget = typeof targetName === "string" && targetName.startsWith("(") && targetName.endsWith(")");
823
- var hasFreshRootState = freshRootState.type === "stack";
824
- var isRootTarget = action.target === freshRootState.key;
825
- var currentFocusedRoute = freshRootState.routes[freshRootState.index];
826
- var currentFocusedName = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.name;
827
- if (isRootTarget && isGroupTarget && hasFreshRootState) {
828
- var _state_index;
829
- var targetRoute = state.routes[(_state_index = state.index) !== null && _state_index !== void 0 ? _state_index : state.routes.length - 1];
830
- var targetRootName = targetRoute.name;
831
- if (currentFocusedName === targetRootName) {
832
- var _ref1;
833
- var routes = [...freshRootState.routes];
834
- routes[freshRootState.index] = {
835
- ...targetRoute,
836
- key: (_ref1 = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.key) !== null && _ref1 !== void 0 ? _ref1 : targetRoute.key
837
- };
838
- navigationRef.resetRoot({
839
- ...freshRootState,
840
- routes
841
- });
842
- } else {
843
- var _ref2;
844
- var existingTargetRoute = freshRootState.routes.find(function(route) {
845
- return route.name === targetRootName;
846
- });
847
- var existingRoutes = freshRootState.routes.filter(function(route) {
848
- return route.name !== targetRootName;
849
- });
850
- var nextRootState = {
851
- ...freshRootState,
852
- routes: [...existingRoutes, {
823
+ var action = event === "REPLACE" ? null : (0, import_getNavigateAction.getNavigateAction)(state, freshRootState, event);
824
+ (0, import_react.startTransition)(function() {
825
+ updateState(optimisticState);
826
+ pendingNavigationPathname = targetPathname;
827
+ notifyRootStateSubscribers(optimisticState);
828
+ if (!action) navigationRef.resetRoot(state);
829
+ else {
830
+ var _action_payload;
831
+ var targetName = (_action_payload = action.payload) === null || _action_payload === void 0 ? void 0 : _action_payload.name;
832
+ var isGroupTarget = typeof targetName === "string" && targetName.startsWith("(") && targetName.endsWith(")");
833
+ var hasFreshRootState = freshRootState.type === "stack";
834
+ var isRootTarget = action.target === freshRootState.key;
835
+ var currentFocusedRoute = freshRootState.routes[freshRootState.index];
836
+ var currentFocusedName = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.name;
837
+ if (isRootTarget && isGroupTarget && hasFreshRootState) {
838
+ var _state_index;
839
+ var targetRoute = state.routes[(_state_index = state.index) !== null && _state_index !== void 0 ? _state_index : state.routes.length - 1];
840
+ var targetRootName = targetRoute.name;
841
+ if (currentFocusedName === targetRootName) {
842
+ var _ref2;
843
+ var routes = [...freshRootState.routes];
844
+ routes[freshRootState.index] = {
853
845
  ...targetRoute,
854
- key: (_ref2 = existingTargetRoute === null || existingTargetRoute === void 0 ? void 0 : existingTargetRoute.key) !== null && _ref2 !== void 0 ? _ref2 : `${targetRootName}-${freshRootState.key}`
855
- }],
856
- index: existingRoutes.length
857
- };
858
- navigationRef.resetRoot(nextRootState);
859
- }
860
- } else navigationRef.dispatch(action);
861
- }
846
+ key: (_ref2 = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.key) !== null && _ref2 !== void 0 ? _ref2 : targetRoute.key
847
+ };
848
+ navigationRef.resetRoot({
849
+ ...freshRootState,
850
+ routes
851
+ });
852
+ } else {
853
+ var _ref1;
854
+ var existingTargetRoute = freshRootState.routes.find(function(route) {
855
+ return route.name === targetRootName;
856
+ });
857
+ var existingRoutes = freshRootState.routes.filter(function(route) {
858
+ return route.name !== targetRootName;
859
+ });
860
+ var nextRootState = {
861
+ ...freshRootState,
862
+ routes: [...existingRoutes, {
863
+ ...targetRoute,
864
+ key: (_ref1 = existingTargetRoute === null || existingTargetRoute === void 0 ? void 0 : existingTargetRoute.key) !== null && _ref1 !== void 0 ? _ref1 : `${targetRootName}-${freshRootState.key}`
865
+ }],
866
+ index: existingRoutes.length
867
+ };
868
+ navigationRef.resetRoot(nextRootState);
869
+ }
870
+ } else navigationRef.dispatch(action);
871
+ }
872
+ });
862
873
  var warningTm;
863
874
  var interval = setInterval(function() {
864
875
  if (!navigationRef.isReady()) {
@@ -583,14 +583,23 @@ function syncStoreRootState() {
583
583
  }
584
584
  }
585
585
  }
586
+ function useRootStateSnapshot(snapshot2) {
587
+ var [state, rerender] = (0, import_react.useReducer)(snapshot2, void 0, snapshot2);
588
+ (0, import_react.useEffect)(function() {
589
+ var unsubscribe = subscribeToRootState(rerender);
590
+ rerender();
591
+ return unsubscribe;
592
+ }, []);
593
+ var browserPath = (0, import_path2.getSafeWindowPath)();
594
+ return browserPath !== void 0 && (routeInfo === null || routeInfo === void 0 ? void 0 : routeInfo.unstable_globalHref) === browserPath + window.location.hash ? snapshot2() : state;
595
+ }
586
596
  function useStoreRootState() {
587
597
  syncStoreRootState();
588
- var state = (0, import_react.useSyncExternalStore)(subscribeToRootState, rootStateSnapshot, rootStateSnapshot);
589
- return (0, import_react.useDeferredValue)(state);
598
+ return (0, import_react.useDeferredValue)(useRootStateSnapshot(rootStateSnapshot));
590
599
  }
591
600
  function useStoreRouteInfo() {
592
601
  syncStoreRootState();
593
- return (0, import_react.useSyncExternalStore)(subscribeToRootState, routeInfoSnapshot, routeInfoSnapshot);
602
+ return useRootStateSnapshot(routeInfoSnapshot);
594
603
  }
595
604
  function cleanup() {
596
605
  if (splashScreenAnimationFrame) cancelAnimationFrame(splashScreenAnimationFrame);
@@ -686,12 +695,12 @@ async function linkTo(href, event, options) {
686
695
  var _routeInfo_params;
687
696
  if (!segment.startsWith("[")) return segment;
688
697
  if (segment.startsWith("[...")) {
689
- var _ref3;
698
+ var _ref2;
690
699
  var _routeInfo_params1, _params_split;
691
700
  segment = segment.slice(4, -1);
692
701
  var params3 = routeInfo === null || routeInfo === void 0 ? void 0 : (_routeInfo_params1 = routeInfo.params) === null || _routeInfo_params1 === void 0 ? void 0 : _routeInfo_params1[segment];
693
702
  if (Array.isArray(params3)) return params3.join("/");
694
- return (_ref3 = params3 === null || params3 === void 0 ? void 0 : (_params_split = params3.split(",")) === null || _params_split === void 0 ? void 0 : _params_split.join("/")) !== null && _ref3 !== void 0 ? _ref3 : "";
703
+ return (_ref2 = params3 === null || params3 === void 0 ? void 0 : (_params_split = params3.split(",")) === null || _params_split === void 0 ? void 0 : _params_split.join("/")) !== null && _ref2 !== void 0 ? _ref2 : "";
695
704
  }
696
705
  segment = segment.slice(1, -1);
697
706
  return routeInfo === null || routeInfo === void 0 ? void 0 : (_routeInfo_params = routeInfo.params) === null || _routeInfo_params === void 0 ? void 0 : _routeInfo_params[segment];
@@ -811,54 +820,56 @@ async function linkTo(href, event, options) {
811
820
  ...state,
812
821
  linkOptions: nextOptions
813
822
  } : state;
814
- updateState(optimisticState);
815
- pendingNavigationPathname = targetPathname;
816
- notifyRootStateSubscribers(optimisticState);
817
- if (event === "REPLACE") navigationRef.resetRoot(state);
818
- else {
819
- var _action_payload;
820
- var action = (0, import_getNavigateAction.getNavigateAction)(state, freshRootState, event);
821
- var targetName = (_action_payload = action.payload) === null || _action_payload === void 0 ? void 0 : _action_payload.name;
822
- var isGroupTarget = typeof targetName === "string" && targetName.startsWith("(") && targetName.endsWith(")");
823
- var hasFreshRootState = freshRootState.type === "stack";
824
- var isRootTarget = action.target === freshRootState.key;
825
- var currentFocusedRoute = freshRootState.routes[freshRootState.index];
826
- var currentFocusedName = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.name;
827
- if (isRootTarget && isGroupTarget && hasFreshRootState) {
828
- var _state_index;
829
- var targetRoute = state.routes[(_state_index = state.index) !== null && _state_index !== void 0 ? _state_index : state.routes.length - 1];
830
- var targetRootName = targetRoute.name;
831
- if (currentFocusedName === targetRootName) {
832
- var _ref1;
833
- var routes = [...freshRootState.routes];
834
- routes[freshRootState.index] = {
835
- ...targetRoute,
836
- key: (_ref1 = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.key) !== null && _ref1 !== void 0 ? _ref1 : targetRoute.key
837
- };
838
- navigationRef.resetRoot({
839
- ...freshRootState,
840
- routes
841
- });
842
- } else {
843
- var _ref2;
844
- var existingTargetRoute = freshRootState.routes.find(function(route) {
845
- return route.name === targetRootName;
846
- });
847
- var existingRoutes = freshRootState.routes.filter(function(route) {
848
- return route.name !== targetRootName;
849
- });
850
- var nextRootState = {
851
- ...freshRootState,
852
- routes: [...existingRoutes, {
823
+ var action = event === "REPLACE" ? null : (0, import_getNavigateAction.getNavigateAction)(state, freshRootState, event);
824
+ (0, import_react.startTransition)(function() {
825
+ updateState(optimisticState);
826
+ pendingNavigationPathname = targetPathname;
827
+ notifyRootStateSubscribers(optimisticState);
828
+ if (!action) navigationRef.resetRoot(state);
829
+ else {
830
+ var _action_payload;
831
+ var targetName = (_action_payload = action.payload) === null || _action_payload === void 0 ? void 0 : _action_payload.name;
832
+ var isGroupTarget = typeof targetName === "string" && targetName.startsWith("(") && targetName.endsWith(")");
833
+ var hasFreshRootState = freshRootState.type === "stack";
834
+ var isRootTarget = action.target === freshRootState.key;
835
+ var currentFocusedRoute = freshRootState.routes[freshRootState.index];
836
+ var currentFocusedName = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.name;
837
+ if (isRootTarget && isGroupTarget && hasFreshRootState) {
838
+ var _state_index;
839
+ var targetRoute = state.routes[(_state_index = state.index) !== null && _state_index !== void 0 ? _state_index : state.routes.length - 1];
840
+ var targetRootName = targetRoute.name;
841
+ if (currentFocusedName === targetRootName) {
842
+ var _ref2;
843
+ var routes = [...freshRootState.routes];
844
+ routes[freshRootState.index] = {
853
845
  ...targetRoute,
854
- key: (_ref2 = existingTargetRoute === null || existingTargetRoute === void 0 ? void 0 : existingTargetRoute.key) !== null && _ref2 !== void 0 ? _ref2 : `${targetRootName}-${freshRootState.key}`
855
- }],
856
- index: existingRoutes.length
857
- };
858
- navigationRef.resetRoot(nextRootState);
859
- }
860
- } else navigationRef.dispatch(action);
861
- }
846
+ key: (_ref2 = currentFocusedRoute === null || currentFocusedRoute === void 0 ? void 0 : currentFocusedRoute.key) !== null && _ref2 !== void 0 ? _ref2 : targetRoute.key
847
+ };
848
+ navigationRef.resetRoot({
849
+ ...freshRootState,
850
+ routes
851
+ });
852
+ } else {
853
+ var _ref1;
854
+ var existingTargetRoute = freshRootState.routes.find(function(route) {
855
+ return route.name === targetRootName;
856
+ });
857
+ var existingRoutes = freshRootState.routes.filter(function(route) {
858
+ return route.name !== targetRootName;
859
+ });
860
+ var nextRootState = {
861
+ ...freshRootState,
862
+ routes: [...existingRoutes, {
863
+ ...targetRoute,
864
+ key: (_ref1 = existingTargetRoute === null || existingTargetRoute === void 0 ? void 0 : existingTargetRoute.key) !== null && _ref1 !== void 0 ? _ref1 : `${targetRootName}-${freshRootState.key}`
865
+ }],
866
+ index: existingRoutes.length
867
+ };
868
+ navigationRef.resetRoot(nextRootState);
869
+ }
870
+ } else navigationRef.dispatch(action);
871
+ }
872
+ });
862
873
  var warningTm;
863
874
  var interval = setInterval(function() {
864
875
  if (!navigationRef.isReady()) {