@adonisjs/inertia 4.0.0-next.11 → 4.0.0-next.12
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Tuyau } from '@tuyau/core/client';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TuyauRegistry } from '@tuyau/core/types';
|
|
4
4
|
/**
|
|
5
5
|
* Provider component that makes the Tuyau client available to child components.
|
|
6
6
|
*
|
|
@@ -8,7 +8,7 @@ import type { AdonisRegistry } from '@tuyau/core/types';
|
|
|
8
8
|
* application that needs access to type-safe routing functionality.
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
|
-
export declare function TuyauProvider<R extends
|
|
11
|
+
export declare function TuyauProvider<R extends TuyauRegistry>(props: {
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
client: Tuyau<R>;
|
|
14
14
|
}): React.JSX.Element;
|
|
@@ -21,4 +21,4 @@ export declare function TuyauProvider<R extends AdonisRegistry>(props: {
|
|
|
21
21
|
* @returns The Tuyau client instance with full type safety
|
|
22
22
|
* @throws Error if used outside of a TuyauProvider
|
|
23
23
|
*/
|
|
24
|
-
export declare function useTuyau(): Tuyau<any>;
|
|
24
|
+
export declare function useTuyau(): Tuyau<any, any>;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { UserRegistry } from '@tuyau/core/types';
|
|
2
|
+
import type { UserRegistry, InferRoutes } from '@tuyau/core/types';
|
|
3
3
|
import { AreAllOptional } from '@poppinss/utils/types';
|
|
4
4
|
import { Link as InertiaLink } from '@inertiajs/react';
|
|
5
|
+
type Routes = InferRoutes<UserRegistry>;
|
|
5
6
|
/**
|
|
6
7
|
* Get parameter tuple type for a route
|
|
7
8
|
*/
|
|
8
|
-
type ExtractParamsTuple<Route extends keyof
|
|
9
|
+
type ExtractParamsTuple<Route extends keyof Routes> = Routes[Route]['types']['paramsTuple'];
|
|
9
10
|
/**
|
|
10
11
|
* Get parameter object type for a route
|
|
11
12
|
*/
|
|
12
|
-
type ExtractParamsObject<Route extends keyof
|
|
13
|
+
type ExtractParamsObject<Route extends keyof Routes> = Routes[Route]['types']['params'];
|
|
13
14
|
/**
|
|
14
15
|
* Get params format for a route
|
|
15
16
|
*/
|
|
16
|
-
type RouteParamsFormats<Route extends keyof
|
|
17
|
+
type RouteParamsFormats<Route extends keyof Routes> = ExtractParamsObject<Route> extends Record<string, never> ? never : ExtractParamsTuple<Route> | ExtractParamsObject<Route>;
|
|
17
18
|
/**
|
|
18
19
|
* Parameters required for route navigation with proper type safety.
|
|
19
20
|
*/
|
|
20
|
-
export type LinkParams<Route extends keyof
|
|
21
|
+
export type LinkParams<Route extends keyof Routes> = {
|
|
21
22
|
route: Route;
|
|
22
23
|
} & (RouteParamsFormats<Route> extends never ? {
|
|
23
24
|
params?: never;
|
|
@@ -30,7 +31,7 @@ export type LinkParams<Route extends keyof UserRegistry> = {
|
|
|
30
31
|
* Props for the Link component extending InertiaLink props
|
|
31
32
|
* with route-specific type safety and parameter validation.
|
|
32
33
|
*/
|
|
33
|
-
type LinkProps<Route extends keyof
|
|
34
|
+
type LinkProps<Route extends keyof Routes> = Omit<React.ComponentPropsWithoutRef<typeof InertiaLink>, 'href' | 'method'> & LinkParams<Route>;
|
|
34
35
|
/**
|
|
35
36
|
* Internal Link component implementation with forward ref support.
|
|
36
37
|
* Resolves route parameters and generates the appropriate URL and HTTP method
|
|
@@ -39,7 +40,7 @@ type LinkProps<Route extends keyof UserRegistry> = Omit<React.ComponentPropsWith
|
|
|
39
40
|
* @param props - Link properties including route and parameters
|
|
40
41
|
* @param ref - Forward ref for the underlying InertiaLink component
|
|
41
42
|
*/
|
|
42
|
-
declare function LinkInner<Route extends keyof
|
|
43
|
+
declare function LinkInner<Route extends keyof Routes>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>): React.JSX.Element;
|
|
43
44
|
/**
|
|
44
45
|
* Type-safe Link component for Inertia.js navigation.
|
|
45
46
|
*
|
|
@@ -58,7 +59,7 @@ declare function LinkInner<Route extends keyof UserRegistry>(props: LinkProps<Ro
|
|
|
58
59
|
* </Link>
|
|
59
60
|
* ```
|
|
60
61
|
*/
|
|
61
|
-
export declare const Link: <Route extends keyof
|
|
62
|
+
export declare const Link: <Route extends keyof Routes>(props: LinkProps<Route> & {
|
|
62
63
|
ref?: React.Ref<React.ElementRef<typeof InertiaLink>>;
|
|
63
64
|
}) => ReturnType<typeof LinkInner>;
|
|
64
65
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UserRegistry } from '@tuyau/core/types';
|
|
1
|
+
import type { UserRegistry, InferRoutes } from '@tuyau/core/types';
|
|
2
2
|
import { router as InertiaRouter } from '@inertiajs/react';
|
|
3
3
|
import type { LinkParams } from './link.tsx';
|
|
4
4
|
/**
|
|
@@ -29,5 +29,5 @@ export declare function useRouter(): {
|
|
|
29
29
|
* router.visit({ route: 'user.edit', params: { id: userId } })
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
visit: <Route extends keyof UserRegistry
|
|
32
|
+
visit: <Route extends keyof InferRoutes<UserRegistry>>(props: LinkParams<Route>, options?: Parameters<typeof InertiaRouter.visit>[1]) => any;
|
|
33
33
|
};
|
|
@@ -1,64 +1,67 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
readonly
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
declare const registry: {
|
|
2
|
+
routes: {
|
|
3
|
+
readonly 'users.index': {
|
|
4
|
+
readonly methods: ["GET", "HEAD"];
|
|
5
|
+
readonly pattern: "/";
|
|
6
|
+
readonly tokens: [{
|
|
7
|
+
readonly old: "/";
|
|
8
|
+
readonly type: 0;
|
|
9
|
+
readonly val: "/";
|
|
10
|
+
readonly end: "";
|
|
11
|
+
}];
|
|
12
|
+
readonly types: {
|
|
13
|
+
body: {};
|
|
14
|
+
paramsTuple: [];
|
|
15
|
+
params: {};
|
|
16
|
+
query: {};
|
|
17
|
+
response: unknown;
|
|
18
|
+
};
|
|
17
19
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
20
|
+
readonly 'users.comments.edit': {
|
|
21
|
+
readonly methods: ["GET", "HEAD"];
|
|
22
|
+
readonly pattern: "/users/:id/comments/:comment_id/edit";
|
|
23
|
+
readonly tokens: [{
|
|
24
|
+
readonly old: "/users";
|
|
25
|
+
readonly type: 0;
|
|
26
|
+
readonly val: "users";
|
|
27
|
+
readonly end: "/";
|
|
28
|
+
}, {
|
|
29
|
+
readonly old: ":id";
|
|
30
|
+
readonly type: 1;
|
|
31
|
+
readonly val: "id";
|
|
32
|
+
readonly end: "/";
|
|
33
|
+
}, {
|
|
34
|
+
readonly old: "/comments";
|
|
35
|
+
readonly type: 0;
|
|
36
|
+
readonly val: "comments";
|
|
37
|
+
readonly end: "/";
|
|
38
|
+
}, {
|
|
39
|
+
readonly old: ":comment_id";
|
|
40
|
+
readonly type: 1;
|
|
41
|
+
readonly val: "comment_id";
|
|
42
|
+
readonly end: "/edit";
|
|
43
|
+
}, {
|
|
44
|
+
readonly old: "/edit";
|
|
45
|
+
readonly type: 0;
|
|
46
|
+
readonly val: "edit";
|
|
47
|
+
readonly end: "";
|
|
48
|
+
}];
|
|
49
|
+
readonly types: {
|
|
50
|
+
body: {};
|
|
51
|
+
paramsTuple: [string, string];
|
|
52
|
+
params: {
|
|
53
|
+
id: string;
|
|
54
|
+
comment_id: string;
|
|
55
|
+
};
|
|
56
|
+
query: {};
|
|
57
|
+
response: unknown;
|
|
54
58
|
};
|
|
55
|
-
query: {};
|
|
56
|
-
response: unknown;
|
|
57
59
|
};
|
|
58
60
|
};
|
|
61
|
+
$tree: any;
|
|
59
62
|
};
|
|
60
63
|
declare module '@tuyau/core/types' {
|
|
61
|
-
type Registry = typeof
|
|
64
|
+
type Registry = typeof registry;
|
|
62
65
|
interface UserRegistry extends Registry {
|
|
63
66
|
}
|
|
64
67
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/inertia",
|
|
3
3
|
"description": "Official Inertia.js adapter for AdonisJS",
|
|
4
|
-
"version": "4.0.0-next.
|
|
4
|
+
"version": "4.0.0-next.12",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@japa/snapshot": "^2.0.9",
|
|
61
61
|
"@poppinss/ts-exec": "^1.4.1",
|
|
62
62
|
"@release-it/conventional-changelog": "^10.0.2",
|
|
63
|
-
"@tuyau/core": "^1.0.0-beta.
|
|
63
|
+
"@tuyau/core": "^1.0.0-beta.4",
|
|
64
64
|
"@types/node": "^24.10.1",
|
|
65
65
|
"@types/react": "^19.2.7",
|
|
66
66
|
"@types/supertest": "^6.0.3",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@inertiajs/react": "^2.2.15",
|
|
93
93
|
"@japa/api-client": "^3.1.0",
|
|
94
94
|
"@japa/plugin-adonisjs": "^5.0.0-next.0",
|
|
95
|
-
"@tuyau/core": "^1.0.0-beta.
|
|
95
|
+
"@tuyau/core": "^1.0.0-beta.4",
|
|
96
96
|
"edge.js": "^6.0.0",
|
|
97
97
|
"react": "^19.2.0"
|
|
98
98
|
},
|