@typed/router 0.6.4 → 0.8.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/dist/RouteMatch.js +1 -2
- package/dist/RouteMatch.js.map +1 -1
- package/dist/RouteMatcher.d.ts.map +1 -1
- package/dist/RouteMatcher.js +2 -5
- package/dist/RouteMatcher.js.map +1 -1
- package/dist/cjs/RouteMatch.js +1 -2
- package/dist/cjs/RouteMatch.js.map +1 -1
- package/dist/cjs/RouteMatcher.d.ts.map +1 -1
- package/dist/cjs/RouteMatcher.js +1 -4
- package/dist/cjs/RouteMatcher.js.map +1 -1
- package/dist/cjs/router.d.ts.map +1 -1
- package/dist/cjs/router.js +1 -1
- package/dist/cjs/router.js.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +1 -1
- package/dist/router.js.map +1 -1
- package/dist/tsconfig.cjs.build.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/RouteMatch.ts +1 -1
- package/src/RouteMatcher.ts +3 -5
- package/src/router.ts +3 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.cjs.build.json +24 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed/router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@effect/data": "^0.11.
|
|
22
|
+
"@effect/data": "^0.11.7",
|
|
23
23
|
"@effect/io": "^0.19.2",
|
|
24
|
-
"@typed/context": "0.
|
|
25
|
-
"@typed/dom": "8.
|
|
26
|
-
"@typed/fx": "1.
|
|
27
|
-
"@typed/html": "3.
|
|
28
|
-
"@typed/path": "0.
|
|
29
|
-
"@typed/route": "0.
|
|
24
|
+
"@typed/context": "0.8.1",
|
|
25
|
+
"@typed/dom": "8.8.1",
|
|
26
|
+
"@typed/fx": "1.8.1",
|
|
27
|
+
"@typed/html": "3.8.1",
|
|
28
|
+
"@typed/path": "0.3.0",
|
|
29
|
+
"@typed/route": "0.6.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "77671d9c890b6635f3ee49bfb63473ac31032a84",
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
package/src/RouteMatch.ts
CHANGED
|
@@ -35,7 +35,7 @@ export function RouteMatch<R, E, P extends string, R2, E2, R3, E3>(
|
|
|
35
35
|
provideContext: (env) =>
|
|
36
36
|
RouteMatch(
|
|
37
37
|
Route.provideContext(env)(route),
|
|
38
|
-
flow(match, Fx.
|
|
38
|
+
flow(match, Fx.provideSomeContext(env)),
|
|
39
39
|
layout ? Fx.provideContext(env)(layout) : undefined,
|
|
40
40
|
),
|
|
41
41
|
provideService: (tag, service) =>
|
package/src/RouteMatcher.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
import { identity, pipe } from '@effect/data/Function'
|
|
3
3
|
import * as Option from '@effect/data/Option'
|
|
4
|
-
import * as Cause from '@effect/io/Cause'
|
|
5
4
|
import * as Effect from '@effect/io/Effect'
|
|
6
5
|
import * as Fiber from '@effect/io/Fiber'
|
|
7
6
|
import type * as Layer from '@effect/io/Layer'
|
|
@@ -163,11 +162,10 @@ export function RouteMatcher<R, E>(routes: RouteMatcher<R, E>['routes']): RouteM
|
|
|
163
162
|
pipe(
|
|
164
163
|
render,
|
|
165
164
|
Fx.observe(outlet.set),
|
|
166
|
-
Effect.
|
|
167
|
-
|
|
168
|
-
? outlet.set(null)
|
|
169
|
-
: outlet.error(cause as Cause.Cause<never>),
|
|
165
|
+
Effect.catchAll((e: Redirect) =>
|
|
166
|
+
Redirect.is(e) ? router.currentPath.set(e.path) : Effect.fail(e),
|
|
170
167
|
),
|
|
168
|
+
Effect.onError(outlet.error),
|
|
171
169
|
Effect.forkDaemon,
|
|
172
170
|
),
|
|
173
171
|
)
|
package/src/router.ts
CHANGED
|
@@ -172,7 +172,8 @@ export function redirect(path: string) {
|
|
|
172
172
|
return Effect.fail<Redirect>(Redirect.make(path))
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
redirect.fx = (path: string)
|
|
175
|
+
redirect.fx = (path: string): Fx.Fx<never, Redirect, never> =>
|
|
176
|
+
Fx.fail<Redirect>(Redirect.make(path))
|
|
176
177
|
|
|
177
178
|
export const redirectTo = <R, E, P extends string>(
|
|
178
179
|
route: Route.Route<R, E, P>,
|
|
@@ -273,7 +274,7 @@ export const getBasePath = Router.with((r) => {
|
|
|
273
274
|
|
|
274
275
|
const patchHistory = Effect.gen(function* ($) {
|
|
275
276
|
const history = yield* $(History)
|
|
276
|
-
const historyEvents = Fx.
|
|
277
|
+
const historyEvents = Fx.makeSubject<never, void>()
|
|
277
278
|
const runtime = yield* $(Effect.runtime<never>())
|
|
278
279
|
const runFork = Runtime.runFork(runtime)
|
|
279
280
|
const cleanup = patchHistory_(history, () => runFork(historyEvents.event()))
|