pastoria 1.2.1 → 2.0.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.
- package/package.json +1 -1
- package/templates/router.tsx +29 -38
package/package.json
CHANGED
package/templates/router.tsx
CHANGED
|
@@ -332,6 +332,9 @@ export function router__createAppFromEntryPoint(
|
|
|
332
332
|
);
|
|
333
333
|
|
|
334
334
|
useMemo(() => {
|
|
335
|
+
// Skip during SSR - entry point is already loaded before rendering
|
|
336
|
+
if (typeof window === 'undefined') return;
|
|
337
|
+
|
|
335
338
|
const route = location.route();
|
|
336
339
|
if (route) {
|
|
337
340
|
// Cast needed for same reason as loadRouteEntryPoint - see that function's docs
|
|
@@ -477,64 +480,52 @@ function router__evaluateNavigationDirection(nav: NavigationDirection) {
|
|
|
477
480
|
|
|
478
481
|
export function useNavigation() {
|
|
479
482
|
const {setLocation} = useContext(RouterContext);
|
|
480
|
-
const [isPending, startTransition] = useTransition();
|
|
481
483
|
|
|
482
484
|
return useMemo(() => {
|
|
483
485
|
function push(nav: NavigationDirection) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
router__evaluateNavigationDirection(nav),
|
|
488
|
-
'push',
|
|
489
|
-
),
|
|
490
|
-
);
|
|
491
|
-
});
|
|
486
|
+
setLocation(
|
|
487
|
+
RouterLocation.parse(router__evaluateNavigationDirection(nav), 'push'),
|
|
488
|
+
);
|
|
492
489
|
}
|
|
493
490
|
|
|
494
491
|
function replace(nav: NavigationDirection) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
);
|
|
502
|
-
});
|
|
492
|
+
setLocation(
|
|
493
|
+
RouterLocation.parse(
|
|
494
|
+
router__evaluateNavigationDirection(nav),
|
|
495
|
+
'replace',
|
|
496
|
+
),
|
|
497
|
+
);
|
|
503
498
|
}
|
|
504
499
|
|
|
505
500
|
function pushRoute<R extends RouteId>(
|
|
506
501
|
routeId: R,
|
|
507
502
|
params: z.input<RouterConf[R]['schema']>,
|
|
508
503
|
) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
);
|
|
516
|
-
});
|
|
504
|
+
setLocation(
|
|
505
|
+
RouterLocation.parse(
|
|
506
|
+
router__createPathForRoute(routeId, params),
|
|
507
|
+
'push',
|
|
508
|
+
),
|
|
509
|
+
);
|
|
517
510
|
}
|
|
518
511
|
|
|
519
512
|
function replaceRoute<R extends RouteId>(
|
|
520
513
|
routeId: R,
|
|
521
514
|
params: z.input<RouterConf[R]['schema']>,
|
|
522
515
|
) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
);
|
|
533
|
-
});
|
|
516
|
+
setLocation((prevLoc) =>
|
|
517
|
+
RouterLocation.parse(
|
|
518
|
+
router__createPathForRoute(routeId, {
|
|
519
|
+
...prevLoc.params(),
|
|
520
|
+
...params,
|
|
521
|
+
}),
|
|
522
|
+
'replace',
|
|
523
|
+
),
|
|
524
|
+
);
|
|
534
525
|
}
|
|
535
526
|
|
|
536
|
-
return {push, replace, pushRoute, replaceRoute
|
|
537
|
-
}, [setLocation
|
|
527
|
+
return {push, replace, pushRoute, replaceRoute} as const;
|
|
528
|
+
}, [setLocation]);
|
|
538
529
|
}
|
|
539
530
|
|
|
540
531
|
export function Link({
|