@firtoz/router-toolkit 7.0.0 → 7.0.2

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": "@firtoz/router-toolkit",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Type-safe React Router 7 framework mode helpers with enhanced fetching, form submission, and state management",
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -26,7 +26,7 @@
26
26
  "README.md"
27
27
  ],
28
28
  "scripts": {
29
- "typecheck": "tsc --noEmit -p ./tsconfig.json",
29
+ "typecheck": "tsgo --noEmit -p ./tsconfig.json",
30
30
  "lint": "biome check --write src",
31
31
  "lint:ci": "biome ci src",
32
32
  "format": "biome format src --write",
@@ -57,7 +57,7 @@
57
57
  "peerDependencies": {
58
58
  "@firtoz/maybe-error": "^1.5.1",
59
59
  "react": "^19.2.4",
60
- "react-router": "^7.13.0",
60
+ "react-router": "^7.13.2",
61
61
  "zod": "^4.3.6"
62
62
  },
63
63
  "engines": {
@@ -71,9 +71,9 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@testing-library/react": "^16.3.1",
74
- "@types/jsdom": "^27.0.0",
74
+ "@types/jsdom": "^28.0.1",
75
75
  "@types/react": "^19.2.14",
76
- "bun-types": "^1.3.9",
77
- "jsdom": "^28.1.0"
76
+ "bun-types": "^1.3.11",
77
+ "jsdom": "^29.0.1"
78
78
  }
79
79
  }
@@ -142,10 +142,12 @@ function FetcherRunner({
142
142
  }, [pendingSubmit, fetcher.submit]);
143
143
 
144
144
  React.useEffect(() => {
145
- const wasSubmitting = prevStateRef.current === "submitting";
145
+ const wasWorking =
146
+ prevStateRef.current === "submitting" ||
147
+ prevStateRef.current === "loading";
146
148
  prevStateRef.current = fetcher.state;
147
149
 
148
- if (wasSubmitting && fetcher.state === "idle" && !settledRef.current) {
150
+ if (wasWorking && fetcher.state === "idle" && !settledRef.current) {
149
151
  settledRef.current = true;
150
152
  if (fetcher.data !== undefined) {
151
153
  onSettle(id, fetcher.data, undefined);
@@ -22,20 +22,17 @@ export type { ActionResult };
22
22
 
23
23
  type RouteParams<R extends keyof RegisterPages> = RegisterPages[R]["params"];
24
24
 
25
- // Mirror HrefArgs logic: empty params → omit args; optional params → args optional; required → args required
26
- type Equal<X, Y> =
27
- (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
28
- ? true
29
- : false;
30
-
31
- type HasNoParams<R extends keyof RegisterPages> =
32
- Equal<
33
- RouteParams<R>,
34
- // biome-ignore lint/complexity/noBannedTypes: Intentionally empty for route with no params
35
- {}
36
- > extends true
37
- ? true
38
- : false;
25
+ /**
26
+ * True when the route has no dynamic segments (`params: {}` from React Router typegen).
27
+ * Uses `keyof extends never` so real empty params stay distinct from the `RegisterPages`
28
+ * fallback (`AnyPages` → `params: Record<string, …>` has `keyof` = `string`, not `never`).
29
+ * That avoids mis-resolving `submitJson(path, data)` as the route-args overload (strings only).
30
+ */
31
+ type HasNoParams<R extends keyof RegisterPages> = [
32
+ keyof RegisterPages[R]["params"],
33
+ ] extends [never]
34
+ ? true
35
+ : false;
39
36
 
40
37
  type HasOptionalParams<R extends keyof RegisterPages> =
41
38
  HasNoParams<R> extends true