@typed/router 1.0.0-beta.2 → 1.0.0-beta.4

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.
Files changed (31) hide show
  1. package/README.md +1 -1
  2. package/dist/CurrentRoute.d.ts +2 -2
  3. package/dist/CurrentRoute.d.ts.map +1 -1
  4. package/dist/CurrentRoute.js +4 -4
  5. package/dist/Matcher.d.ts +18 -19
  6. package/dist/Matcher.d.ts.map +1 -1
  7. package/dist/Matcher.js +112 -109
  8. package/dist/MatcherV2.d.ts +3 -0
  9. package/dist/MatcherV2.d.ts.map +1 -0
  10. package/dist/MatcherV2.js +1 -0
  11. package/dist/test-utils/matcherBrowserHarness.d.ts +10 -0
  12. package/dist/test-utils/matcherBrowserHarness.d.ts.map +1 -0
  13. package/dist/test-utils/matcherBrowserHarness.js +13 -0
  14. package/package.json +21 -18
  15. package/src/CurrentRoute.ts +5 -5
  16. package/src/Matcher.browser.test.ts +767 -0
  17. package/src/Matcher.test.ts +348 -73
  18. package/src/Matcher.ts +170 -166
  19. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--back---restores-previous-match-1.png +0 -0
  20. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--catchTag-RouteNotFound-can-navigate-and-re-match--browser-history--1.png +0 -0
  21. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--decodes-query-params-from-pathname-search-1.png +0 -0
  22. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--function-Matcher-catch--and-composition--browser--instance-catchTag-does-not-catch-RouteGuardError-from-guards-1.png +0 -0
  23. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--history-back-restores-previous-match--popstate-sync--1.png +0 -0
  24. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--path-and-query-params-both-decode--distinct-names--1.png +0 -0
  25. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--prefix-scopes-routes-under-a-path-segment-1.png +0 -0
  26. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--provideService-supplies-a-service-to-handlers-1.png +0 -0
  27. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--query-param-wins-over-path-param-when-names-collide-1.png +0 -0
  28. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--redirectTo-navigates-away-from-unmatched-path--side-effect--1.png +0 -0
  29. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--redirectTo-navigates-then-matches-target-route-1.png +0 -0
  30. package/src/__screenshots__/Matcher.browser.test.ts/typed-router-Matcher--browser--reuses-shared-layers-and-layouts-across-route-changes-1.png +0 -0
  31. package/src/test-utils/matcherBrowserHarness.ts +22 -0
@@ -0,0 +1,3 @@
1
+ export interface Matcher<A, E, R> {
2
+ }
3
+ //# sourceMappingURL=MatcherV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MatcherV2.d.ts","sourceRoot":"","sources":["../src/MatcherV2.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;CAE/B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import * as Effect from "effect/Effect";
2
+ /**
3
+ * Build an absolute URL for the Vitest browser page origin (same pattern as in-memory tests using http://localhost/...).
4
+ */
5
+ export declare const absoluteUrl: (path: string, win?: Window & typeof globalThis) => string;
6
+ /**
7
+ * Run an effect with {@link BrowserRouter} scoped over the real (or test) `window`.
8
+ */
9
+ export declare const runWithBrowserRouter: <A, E, R>(effect: Effect.Effect<A, E, R>, win?: Window & typeof globalThis) => Promise<A>;
10
+ //# sourceMappingURL=matcherBrowserHarness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matcherBrowserHarness.d.ts","sourceRoot":"","sources":["../../src/test-utils/matcherBrowserHarness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,MAAK,MAAM,GAAG,OAAO,UAA8B,KAAG,MAG/F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAC1C,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC9B,MAAK,MAAM,GAAG,OAAO,UAA8B,KAClD,OAAO,CAAC,CAAC,CACuE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { BrowserRouter } from "../Router.js";
3
+ /**
4
+ * Build an absolute URL for the Vitest browser page origin (same pattern as in-memory tests using http://localhost/...).
5
+ */
6
+ export const absoluteUrl = (path, win = globalThis.window) => {
7
+ const normalized = path.startsWith("/") ? path : `/${path}`;
8
+ return new URL(normalized, win.location.origin).href;
9
+ };
10
+ /**
11
+ * Run an effect with {@link BrowserRouter} scoped over the real (or test) `window`.
12
+ */
13
+ export const runWithBrowserRouter = (effect, win = globalThis.window) => effect.pipe(Effect.provide(BrowserRouter(win)), Effect.scoped, Effect.runPromise);
package/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "@typed/router",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
+ "files": [
5
+ "dist",
6
+ "src"
7
+ ],
4
8
  "type": "module",
5
9
  "exports": {
6
10
  ".": {
@@ -15,25 +19,24 @@
15
19
  "publishConfig": {
16
20
  "access": "public"
17
21
  },
22
+ "scripts": {
23
+ "build": "[ -d dist ] || rm -f tsconfig.tsbuildinfo; tsc",
24
+ "test": "vitest run --passWithNoTests --config vitest.config.ts",
25
+ "test:browser": "vitest run --config vitest.browser.config.ts"
26
+ },
18
27
  "dependencies": {
19
- "effect": "4.0.0-beta.21",
28
+ "@typed/fx": "workspace:*",
29
+ "@typed/guard": "workspace:*",
30
+ "@typed/id": "workspace:*",
31
+ "@typed/navigation": "workspace:*",
32
+ "effect": "catalog:",
20
33
  "find-my-way-ts": "0.1.6",
21
- "hkt-core": "1.3.4",
22
- "@typed/fx": "2.0.0-beta.2",
23
- "@typed/id": "1.0.0-beta.2",
24
- "@typed/guard": "1.0.0-beta.2",
25
- "@typed/navigation": "1.0.0-beta.2"
34
+ "hkt-core": "1.3.5"
26
35
  },
27
36
  "devDependencies": {
28
- "typescript": "5.9.3",
29
- "vitest": "4.0.18"
30
- },
31
- "files": [
32
- "dist",
33
- "src"
34
- ],
35
- "scripts": {
36
- "build": "[ -d dist ] || rm -f tsconfig.tsbuildinfo; tsc",
37
- "test": "vitest run --passWithNoTests"
37
+ "@vitest/browser-playwright": "catalog:",
38
+ "playwright": "^1.59.1",
39
+ "typescript": "catalog:",
40
+ "vitest": "catalog:"
38
41
  }
39
- }
42
+ }
@@ -1,6 +1,6 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Layer from "effect/Layer";
3
- import * as ServiceMap from "effect/ServiceMap";
3
+ import * as Context from "effect/Context";
4
4
  import { Navigation } from "@typed/navigation/Navigation";
5
5
  import { Parse, type Route } from "./Route.js";
6
6
 
@@ -9,10 +9,10 @@ export interface CurrentRouteTree {
9
9
  readonly parent?: CurrentRouteTree | undefined;
10
10
  }
11
11
 
12
- export class CurrentRoute extends ServiceMap.Service<CurrentRoute, CurrentRouteTree>()(
12
+ export class CurrentRoute extends Context.Service<CurrentRoute, CurrentRouteTree>()(
13
13
  "@typed/router/CurrentRoute",
14
14
  {
15
- make: Effect.map(Navigation.base, (base) => ({ route: Parse(base) })),
15
+ make: Effect.map(Navigation.base, (base) => ({ route: Parse(base) } )),
16
16
  },
17
17
  ) {
18
18
  static readonly Default = Layer.effect(CurrentRoute, CurrentRoute.make);
@@ -20,8 +20,8 @@ export class CurrentRoute extends ServiceMap.Service<CurrentRoute, CurrentRouteT
20
20
  static readonly extend = (route: Route.Any) =>
21
21
  Layer.unwrap(
22
22
  Effect.gen(function* () {
23
- const services = yield* Effect.services<never>();
24
- const parent = ServiceMap.getOrUndefined(services, CurrentRoute);
23
+ const services = yield* Effect.context<never>();
24
+ const parent = Context.getOrUndefined(services, CurrentRoute);
25
25
  return Layer.succeed(CurrentRoute, {
26
26
  route,
27
27
  parent,