@adonisjs/inertia 1.0.0-20 → 1.0.0-22
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/build/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Vite } from '@adonisjs/vite';
|
|
|
2
2
|
import { HttpContext } from '@adonisjs/core/http';
|
|
3
3
|
import { NextFn } from '@adonisjs/core/types/http';
|
|
4
4
|
import { ResolvedConfig, Data, PageProps, PageObject, MaybePromise } from './types.js';
|
|
5
|
+
import '@tuyau/utils/types';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Symbol used to identify lazy props
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Serialize } from '@tuyau/utils/types';
|
|
1
2
|
import { HttpContext } from '@adonisjs/core/http';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -105,5 +106,23 @@ interface PageObject<TPageProps extends PageProps = PageProps> {
|
|
|
105
106
|
ssrHead?: string;
|
|
106
107
|
ssrBody?: string;
|
|
107
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Helper for infering the page props from a Controller method that returns
|
|
111
|
+
* inertia.render
|
|
112
|
+
*
|
|
113
|
+
* ```ts
|
|
114
|
+
* // Your Adonis Controller
|
|
115
|
+
* class MyController {
|
|
116
|
+
* index() {
|
|
117
|
+
* return inertia.render('foo', { foo: 1 })
|
|
118
|
+
* }
|
|
119
|
+
* }
|
|
120
|
+
*
|
|
121
|
+
* // Your React component
|
|
122
|
+
* export default MyReactComponent(props: InferPageProps<Controller, 'index'>) {
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
type InferPageProps<Controller, Method extends keyof Controller> = Controller[Method] extends (...args: any[]) => any ? Serialize<Exclude<Awaited<ReturnType<Controller[Method]>>, string>['props']> : never;
|
|
108
127
|
|
|
109
|
-
export type { AssetsVersion, Data, InertiaConfig, MaybePromise, PageObject, PageProps, ResolvedConfig, SharedData, SharedDatumFactory };
|
|
128
|
+
export type { AssetsVersion, Data, InertiaConfig, InferPageProps, MaybePromise, PageObject, PageProps, ResolvedConfig, SharedData, SharedDatumFactory };
|
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": "1.0.0-
|
|
4
|
+
"version": "1.0.0-22",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@japa/runner": "3.1.1",
|
|
54
54
|
"@japa/snapshot": "^2.0.4",
|
|
55
55
|
"@swc/core": "^1.4.8",
|
|
56
|
+
"@tuyau/utils": "^0.0.1",
|
|
56
57
|
"@types/node": "^20.11.30",
|
|
57
58
|
"@types/qs": "^6.9.14",
|
|
58
59
|
"@types/supertest": "^6.0.2",
|