@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typed/router",
3
- "version": "0.6.4",
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.5",
22
+ "@effect/data": "^0.11.7",
23
23
  "@effect/io": "^0.19.2",
24
- "@typed/context": "0.6.3",
25
- "@typed/dom": "8.6.4",
26
- "@typed/fx": "1.6.3",
27
- "@typed/html": "3.6.4",
28
- "@typed/path": "0.1.2",
29
- "@typed/route": "0.4.3"
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": "465332ee7c30a7eae517e4c79b4a984f38cdb5a6",
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.contramapContext(Context.merge(env))),
38
+ flow(match, Fx.provideSomeContext(env)),
39
39
  layout ? Fx.provideContext(env)(layout) : undefined,
40
40
  ),
41
41
  provideService: (tag, service) =>
@@ -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.onError((cause) =>
167
- Cause.isInterruptedOnly(cause)
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) => Fx.fail<Redirect>(Redirect.make(path))
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.Subject.unsafeMake<never, void>()
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()))