@typed/router 0.17.5 → 0.17.7
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/dist/Redirect.d.ts +1 -1
- package/dist/Redirect.d.ts.map +1 -1
- package/dist/Redirect.js +2 -2
- package/dist/Redirect.js.map +1 -1
- package/dist/cjs/Redirect.d.ts +1 -1
- package/dist/cjs/Redirect.d.ts.map +1 -1
- package/dist/cjs/Redirect.js +2 -2
- package/dist/cjs/Redirect.js.map +1 -1
- package/dist/cjs/matchRoutes.d.ts.map +1 -1
- package/dist/cjs/matchRoutes.js +3 -2
- package/dist/cjs/matchRoutes.js.map +1 -1
- package/dist/matchRoutes.d.ts.map +1 -1
- package/dist/matchRoutes.js +3 -2
- package/dist/matchRoutes.js.map +1 -1
- package/dist/tsconfig.cjs.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/Redirect.ts +8 -2
- package/src/matchRoutes.ts +7 -5
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed/router",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"@effect/data": "^0.17.1",
|
|
23
23
|
"@effect/io": "^0.38.0",
|
|
24
24
|
"@typed/context": "0.17.1",
|
|
25
|
-
"@typed/dom": "8.17.
|
|
25
|
+
"@typed/dom": "8.17.2",
|
|
26
26
|
"@typed/error": "0.16.1",
|
|
27
27
|
"@typed/fx": "1.16.1",
|
|
28
|
-
"@typed/html": "3.17.
|
|
29
|
-
"@typed/navigation": "0.4.
|
|
30
|
-
"@typed/path": "0.6.
|
|
31
|
-
"@typed/route": "0.13.
|
|
28
|
+
"@typed/html": "3.17.6",
|
|
29
|
+
"@typed/navigation": "0.4.2",
|
|
30
|
+
"@typed/path": "0.6.2",
|
|
31
|
+
"@typed/route": "0.13.2"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "9083c6af485d129f95e5f7b07d1bfb285668b7dd",
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
package/src/Redirect.ts
CHANGED
|
@@ -11,11 +11,17 @@ export class Redirect extends E.tagged('@typed/router/Redirect') {
|
|
|
11
11
|
super(`Redirect to ${url}`)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
static redirect(
|
|
14
|
+
static redirect(
|
|
15
|
+
url: string,
|
|
16
|
+
options: NavigateOptions = { history: 'replace' },
|
|
17
|
+
): Effect.Effect<never, Redirect, never> {
|
|
15
18
|
return Effect.fail(new Redirect(url, options))
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
static redirectFx(
|
|
21
|
+
static redirectFx(
|
|
22
|
+
url: string,
|
|
23
|
+
options: NavigateOptions = { history: 'replace' },
|
|
24
|
+
): Fx.Fx<never, Redirect, never> {
|
|
19
25
|
return Fx.fail(new Redirect(url, options))
|
|
20
26
|
}
|
|
21
27
|
}
|
package/src/matchRoutes.ts
CHANGED
|
@@ -47,7 +47,8 @@ export function matchRoutes<
|
|
|
47
47
|
) as RENDERABLE
|
|
48
48
|
|
|
49
49
|
return [
|
|
50
|
-
|
|
50
|
+
// If the route is the a single slash, use the route directly to keep any parsing options.
|
|
51
|
+
match.route.path === '/' ? match.route : nestedRouter.route,
|
|
51
52
|
render,
|
|
52
53
|
match.options?.guard as
|
|
53
54
|
| ((params: ParamsOf<string>) => Effect.Effect<_R, NavigationError, boolean>)
|
|
@@ -105,11 +106,12 @@ export function matchRoutes<
|
|
|
105
106
|
return pipe(
|
|
106
107
|
matched,
|
|
107
108
|
isBrowser ? identity : Fx.take(1),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
Fx.
|
|
109
|
+
Fx.switchLatest,
|
|
110
|
+
Redirect.switchCatch((redirect) =>
|
|
111
|
+
Fx.fromFxEffect(
|
|
112
|
+
Effect.map(router.navigation.navigate(redirect.url, redirect.options), () => Fx.never()),
|
|
113
|
+
),
|
|
111
114
|
),
|
|
112
|
-
Fx.compact,
|
|
113
115
|
)
|
|
114
116
|
})
|
|
115
117
|
}
|