@adonisjs/inertia 1.0.0-25 → 1.0.0-26

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
@@ -1,8 +1,9 @@
1
1
  import Configure from '@adonisjs/core/commands/configure';
2
2
  import { ConfigProvider } from '@adonisjs/core/types';
3
- import { InertiaConfig, ResolvedConfig } from './src/types.js';
4
- import '@tuyau/utils/types';
3
+ import { I as InertiaConfig, R as ResolvedConfig } from './types-CyeRFf-Q.js';
5
4
  import '@adonisjs/core/http';
5
+ import '@tuyau/utils/types';
6
+ import '@adonisjs/vite';
6
7
 
7
8
  /**
8
9
  * Configures the package
@@ -1,51 +1,9 @@
1
1
  import { Vite } from '@adonisjs/vite';
2
2
  import { HttpContext } from '@adonisjs/core/http';
3
3
  import { NextFn } from '@adonisjs/core/types/http';
4
- import { ResolvedConfig, Data, PageProps, PageObject, MaybePromise } from './types.js';
4
+ import { a as Inertia, R as ResolvedConfig } from '../types-CyeRFf-Q.js';
5
5
  import '@tuyau/utils/types';
6
6
 
7
- /**
8
- * Symbol used to identify lazy props
9
- */
10
- declare const kLazySymbol: unique symbol;
11
- /**
12
- * Main class used to interact with Inertia
13
- */
14
- declare class Inertia {
15
- #private;
16
- protected ctx: HttpContext;
17
- protected config: ResolvedConfig;
18
- protected vite?: Vite | undefined;
19
- constructor(ctx: HttpContext, config: ResolvedConfig, vite?: Vite | undefined);
20
- /**
21
- * Share data for the current request.
22
- * This data will override any shared data defined in the config.
23
- */
24
- share(data: Record<string, Data>): void;
25
- /**
26
- * Render a page using Inertia
27
- */
28
- render<TPageProps extends Record<string, any> = PageProps, TViewProps extends Record<string, any> = PageProps>(component: string, pageProps?: TPageProps, viewProps?: TViewProps): Promise<string | PageObject<TPageProps>>;
29
- /**
30
- * Create a lazy prop
31
- *
32
- * Lazy props are never resolved on first visit, but only when the client
33
- * request a partial reload explicitely with this value.
34
- *
35
- * See https://inertiajs.com/partial-reloads#lazy-data-evaluation
36
- */
37
- lazy(callback: () => MaybePromise<any>): {
38
- [kLazySymbol]: () => MaybePromise<any>;
39
- };
40
- /**
41
- * This method can be used to redirect the user to an external website
42
- * or even a non-inertia route of your application.
43
- *
44
- * See https://inertiajs.com/redirects#external-redirects
45
- */
46
- location(url: string): Promise<void>;
47
- }
48
-
49
7
  /**
50
8
  * HttpContext augmentations
51
9
  */
@@ -1,8 +1,9 @@
1
1
  import { PluginFn } from '@japa/runner/types';
2
2
  import { ApplicationService } from '@adonisjs/core/types';
3
- import { PageProps } from '../../types.js';
4
- import '@tuyau/utils/types';
3
+ import { P as PageProps } from '../../../types-CyeRFf-Q.js';
5
4
  import '@adonisjs/core/http';
5
+ import '@tuyau/utils/types';
6
+ import '@adonisjs/vite';
6
7
 
7
8
  declare module '@japa/api-client' {
8
9
  interface ApiRequest {
@@ -1,134 +1,4 @@
1
- import { Serialize } from '@tuyau/utils/types';
2
- import { HttpContext } from '@adonisjs/core/http';
3
-
4
- /**
5
- * VersionCache is used to cache the version of the assets.
6
- *
7
- * If the user has provided a version, it will be used.
8
- * Otherwise, we will compute a hash from the manifest file
9
- * and cache it.
10
- */
11
- declare class VersionCache {
12
- #private;
13
- protected appRoot: URL;
14
- protected assetsVersion?: AssetsVersion;
15
- constructor(appRoot: URL, assetsVersion?: AssetsVersion);
16
- /**
17
- * Pre-compute the version
18
- */
19
- computeVersion(): Promise<this>;
20
- /**
21
- * Returns the current assets version
22
- */
23
- getVersion(): string | number;
24
- /**
25
- * Set the assets version
26
- */
27
- setVersion(version: AssetsVersion): Promise<void>;
28
- }
29
-
30
- type MaybePromise<T> = T | Promise<T>;
31
- /**
32
- * Props that will be passed to inertia render method
33
- */
34
- type PageProps = Record<string, unknown>;
35
- /**
36
- * Shared data types
37
- */
38
- type Data = string | number | object | boolean;
39
- type SharedDatumFactory = (ctx: HttpContext) => MaybePromise<Data>;
40
- type SharedData = Record<string, Data | SharedDatumFactory>;
41
- /**
42
- * Allowed values for the assets version
43
- */
44
- type AssetsVersion = string | number | undefined;
45
- interface InertiaConfig {
46
- /**
47
- * Path to the Edge view that will be used as the root view for Inertia responses.
48
- * @default root (resources/views/inertia_layout.edge)
49
- */
50
- rootView?: string;
51
- /**
52
- * Path to your client-side entrypoint file.
53
- */
54
- entrypoint?: string;
55
- /**
56
- * The version of your assets. Every client request will be checked against this version.
57
- * If the version is not the same, the client will do a full reload.
58
- */
59
- assetsVersion?: AssetsVersion;
60
- /**
61
- * Data that should be shared with all rendered pages
62
- */
63
- sharedData?: SharedData;
64
- /**
65
- * Options to configure SSR
66
- */
67
- ssr?: {
68
- /**
69
- * Enable or disable SSR
70
- */
71
- enabled: boolean;
72
- /**
73
- * List of components that should be rendered on the server
74
- */
75
- pages?: string[] | ((ctx: HttpContext, page: string) => MaybePromise<boolean>);
76
- /**
77
- * Path to the SSR entrypoint file
78
- */
79
- entrypoint?: string;
80
- /**
81
- * Path to the SSR bundled file that will be used in production
82
- */
83
- bundle?: string;
84
- };
85
- }
86
- /**
87
- * Resolved inertia configuration
88
- */
89
- interface ResolvedConfig {
90
- rootView: string;
91
- versionCache: VersionCache;
92
- sharedData: SharedData;
93
- ssr: {
94
- enabled: boolean;
95
- entrypoint: string;
96
- pages?: string[] | ((ctx: HttpContext, page: string) => MaybePromise<boolean>);
97
- bundle: string;
98
- };
99
- }
100
- interface PageObject<TPageProps extends PageProps = PageProps> {
101
- component: string;
102
- version: string | number;
103
- props: TPageProps;
104
- url: string;
105
- ssrHead?: string;
106
- ssrBody?: string;
107
- }
108
- /**
109
- * Helper for infering the page props from a Controller method that returns
110
- * inertia.render
111
- *
112
- * ```ts
113
- * // Your Adonis Controller
114
- * class MyController {
115
- * index() {
116
- * return inertia.render('foo', { foo: 1 })
117
- * }
118
- * }
119
- *
120
- * // Your React component
121
- * export default MyReactComponent(props: InferPageProps<Controller, 'index'>) {
122
- * }
123
- * ```
124
- */
125
- type InferPageProps<Controller, Method extends keyof Controller> = Controller[Method] extends (...args: any[]) => any ? Serialize<Exclude<Awaited<ReturnType<Controller[Method]>>, string>['props']> : never;
126
- /**
127
- * Signature for the method in the SSR entrypoint file
128
- */
129
- type RenderInertiaSsrApp = (page: PageObject) => Promise<{
130
- head: string[];
131
- body: string;
132
- }>;
133
-
134
- export type { AssetsVersion, Data, InertiaConfig, InferPageProps, MaybePromise, PageObject, PageProps, RenderInertiaSsrApp, ResolvedConfig, SharedData, SharedDatumFactory };
1
+ import '@adonisjs/core/http';
2
+ import '@tuyau/utils/types';
3
+ export { A as AssetsVersion, D as Data, I as InertiaConfig, d as InferPageProps, M as MaybePromise, c as PageObject, P as PageProps, e as RenderInertiaSsrApp, R as ResolvedConfig, b as SharedData, S as SharedDatumFactory } from '../types-CyeRFf-Q.js';
4
+ import '@adonisjs/vite';
@@ -0,0 +1,187 @@
1
+ import { HttpContext } from '@adonisjs/core/http';
2
+ import { Simplify, Serialize } from '@tuyau/utils/types';
3
+ import { Vite } from '@adonisjs/vite';
4
+
5
+ /**
6
+ * Symbol used to identify lazy props
7
+ */
8
+ declare const kLazySymbol: unique symbol;
9
+ /**
10
+ * Main class used to interact with Inertia
11
+ */
12
+ declare class Inertia {
13
+ #private;
14
+ protected ctx: HttpContext;
15
+ protected config: ResolvedConfig;
16
+ protected vite?: Vite | undefined;
17
+ constructor(ctx: HttpContext, config: ResolvedConfig, vite?: Vite | undefined);
18
+ /**
19
+ * Share data for the current request.
20
+ * This data will override any shared data defined in the config.
21
+ */
22
+ share(data: Record<string, Data>): void;
23
+ /**
24
+ * Render a page using Inertia
25
+ */
26
+ render<TPageProps extends Record<string, any> = {}, TViewProps extends Record<string, any> = {}>(component: string, pageProps?: TPageProps, viewProps?: TViewProps): Promise<string | PageObject<TPageProps>>;
27
+ /**
28
+ * Create a lazy prop
29
+ *
30
+ * Lazy props are never resolved on first visit, but only when the client
31
+ * request a partial reload explicitely with this value.
32
+ *
33
+ * See https://inertiajs.com/partial-reloads#lazy-data-evaluation
34
+ */
35
+ lazy<T>(callback: () => MaybePromise<T>): {
36
+ [kLazySymbol]: () => MaybePromise<T>;
37
+ };
38
+ /**
39
+ * This method can be used to redirect the user to an external website
40
+ * or even a non-inertia route of your application.
41
+ *
42
+ * See https://inertiajs.com/redirects#external-redirects
43
+ */
44
+ location(url: string): Promise<void>;
45
+ }
46
+
47
+ /**
48
+ * VersionCache is used to cache the version of the assets.
49
+ *
50
+ * If the user has provided a version, it will be used.
51
+ * Otherwise, we will compute a hash from the manifest file
52
+ * and cache it.
53
+ */
54
+ declare class VersionCache {
55
+ #private;
56
+ protected appRoot: URL;
57
+ protected assetsVersion?: AssetsVersion;
58
+ constructor(appRoot: URL, assetsVersion?: AssetsVersion);
59
+ /**
60
+ * Pre-compute the version
61
+ */
62
+ computeVersion(): Promise<this>;
63
+ /**
64
+ * Returns the current assets version
65
+ */
66
+ getVersion(): string | number;
67
+ /**
68
+ * Set the assets version
69
+ */
70
+ setVersion(version: AssetsVersion): Promise<void>;
71
+ }
72
+
73
+ type MaybePromise<T> = T | Promise<T>;
74
+ /**
75
+ * Props that will be passed to inertia render method
76
+ */
77
+ type PageProps = Record<string, unknown>;
78
+ /**
79
+ * Shared data types
80
+ */
81
+ type Data = string | number | object | boolean;
82
+ type SharedDatumFactory = (ctx: HttpContext) => MaybePromise<Data>;
83
+ type SharedData = Record<string, Data | SharedDatumFactory>;
84
+ /**
85
+ * Allowed values for the assets version
86
+ */
87
+ type AssetsVersion = string | number | undefined;
88
+ interface InertiaConfig {
89
+ /**
90
+ * Path to the Edge view that will be used as the root view for Inertia responses.
91
+ * @default root (resources/views/inertia_layout.edge)
92
+ */
93
+ rootView?: string;
94
+ /**
95
+ * Path to your client-side entrypoint file.
96
+ */
97
+ entrypoint?: string;
98
+ /**
99
+ * The version of your assets. Every client request will be checked against this version.
100
+ * If the version is not the same, the client will do a full reload.
101
+ */
102
+ assetsVersion?: AssetsVersion;
103
+ /**
104
+ * Data that should be shared with all rendered pages
105
+ */
106
+ sharedData?: SharedData;
107
+ /**
108
+ * Options to configure SSR
109
+ */
110
+ ssr?: {
111
+ /**
112
+ * Enable or disable SSR
113
+ */
114
+ enabled: boolean;
115
+ /**
116
+ * List of components that should be rendered on the server
117
+ */
118
+ pages?: string[] | ((ctx: HttpContext, page: string) => MaybePromise<boolean>);
119
+ /**
120
+ * Path to the SSR entrypoint file
121
+ */
122
+ entrypoint?: string;
123
+ /**
124
+ * Path to the SSR bundled file that will be used in production
125
+ */
126
+ bundle?: string;
127
+ };
128
+ }
129
+ /**
130
+ * Resolved inertia configuration
131
+ */
132
+ interface ResolvedConfig {
133
+ rootView: string;
134
+ versionCache: VersionCache;
135
+ sharedData: SharedData;
136
+ ssr: {
137
+ enabled: boolean;
138
+ entrypoint: string;
139
+ pages?: string[] | ((ctx: HttpContext, page: string) => MaybePromise<boolean>);
140
+ bundle: string;
141
+ };
142
+ }
143
+ interface PageObject<TPageProps extends PageProps = PageProps> {
144
+ component: string;
145
+ version: string | number;
146
+ props: TPageProps;
147
+ url: string;
148
+ ssrHead?: string;
149
+ ssrBody?: string;
150
+ }
151
+ type IsLazyProp<T> = T extends {
152
+ [kLazySymbol]: () => MaybePromise<any>;
153
+ } ? true : false;
154
+ type InferProps<T> = {
155
+ [K in keyof T as IsLazyProp<T[K]> extends true ? K : never]+?: T[K] extends {
156
+ [kLazySymbol]: () => MaybePromise<infer U>;
157
+ } ? U : T[K];
158
+ } & {
159
+ [K in keyof T as IsLazyProp<T[K]> extends true ? never : K]: T[K];
160
+ };
161
+ /**
162
+ * Helper for infering the page props from a Controller method that returns
163
+ * inertia.render
164
+ *
165
+ * ```ts
166
+ * // Your Adonis Controller
167
+ * class MyController {
168
+ * index() {
169
+ * return inertia.render('foo', { foo: 1 })
170
+ * }
171
+ * }
172
+ *
173
+ * // Your React component
174
+ * export default MyReactComponent(props: InferPageProps<Controller, 'index'>) {
175
+ * }
176
+ * ```
177
+ */
178
+ type InferPageProps<Controller, Method extends keyof Controller> = Controller[Method] extends (...args: any[]) => any ? Simplify<Serialize<InferProps<Exclude<Awaited<ReturnType<Controller[Method]>>, string>['props']>>> : never;
179
+ /**
180
+ * Signature for the method in the SSR entrypoint file
181
+ */
182
+ type RenderInertiaSsrApp = (page: PageObject) => Promise<{
183
+ head: string[];
184
+ body: string;
185
+ }>;
186
+
187
+ export { type AssetsVersion as A, type Data as D, type InertiaConfig as I, type MaybePromise as M, type PageProps as P, type ResolvedConfig as R, type SharedDatumFactory as S, Inertia as a, type SharedData as b, type PageObject as c, type InferPageProps as d, type RenderInertiaSsrApp as e };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@adonisjs/inertia",
3
3
  "description": "Official Inertia.js adapter for AdonisJS",
4
- "version": "1.0.0-25",
4
+ "version": "1.0.0-26",
5
5
  "engines": {
6
- "node": ">=18.16.0"
6
+ "node": ">=20.6.0"
7
7
  },
8
8
  "main": "build/index.js",
9
9
  "type": "module",
@@ -38,23 +38,23 @@
38
38
  "prepublishOnly": "npm run build"
39
39
  },
40
40
  "devDependencies": {
41
- "@adonisjs/assembler": "^7.2.3",
42
- "@adonisjs/core": "6.3.1",
41
+ "@adonisjs/assembler": "^7.5.1",
42
+ "@adonisjs/core": "6.8.0",
43
43
  "@adonisjs/eslint-config": "^1.3.0",
44
44
  "@adonisjs/prettier-config": "^1.3.0",
45
- "@adonisjs/session": "7.3.0",
45
+ "@adonisjs/session": "7.4.0",
46
46
  "@adonisjs/tsconfig": "^1.3.0",
47
47
  "@adonisjs/vite": "^3.0.0-8",
48
- "@japa/api-client": "^2.0.2",
49
- "@japa/assert": "2.1.0",
50
- "@japa/expect-type": "^2.0.1",
51
- "@japa/file-system": "^2.2.0",
52
- "@japa/plugin-adonisjs": "^3.0.0",
53
- "@japa/runner": "3.1.1",
54
- "@japa/snapshot": "^2.0.4",
55
- "@swc/core": "^1.4.8",
56
- "@types/node": "^20.11.30",
57
- "@types/qs": "^6.9.14",
48
+ "@japa/api-client": "^2.0.3",
49
+ "@japa/assert": "3.0.0",
50
+ "@japa/expect-type": "^2.0.2",
51
+ "@japa/file-system": "^2.3.0",
52
+ "@japa/plugin-adonisjs": "^3.0.1",
53
+ "@japa/runner": "3.1.4",
54
+ "@japa/snapshot": "^2.0.5",
55
+ "@swc/core": "^1.4.17",
56
+ "@types/node": "^20.12.7",
57
+ "@types/qs": "^6.9.15",
58
58
  "@types/supertest": "^6.0.2",
59
59
  "@vavite/multibuild": "^4.1.1",
60
60
  "c8": "^9.1.0",
@@ -65,22 +65,21 @@
65
65
  "eslint": "^8.57.0",
66
66
  "get-port": "^7.1.0",
67
67
  "prettier": "^3.2.5",
68
- "release-it": "^17.1.1",
68
+ "release-it": "^17.2.1",
69
69
  "supertest": "^6.3.4",
70
- "tinybench": "^2.6.0",
71
70
  "ts-node": "^10.9.2",
72
71
  "tsup": "^8.0.2",
73
- "typescript": "~5.4.3",
74
- "vite": "^5.2.6"
72
+ "typescript": "~5.4.5",
73
+ "vite": "^5.2.10"
75
74
  },
76
75
  "dependencies": {
77
- "@poppinss/utils": "^6.7.2",
78
- "@tuyau/utils": "^0.0.1",
76
+ "@poppinss/utils": "^6.7.3",
77
+ "@tuyau/utils": "^0.0.2",
79
78
  "crc-32": "^1.2.2",
80
79
  "edge-error": "^4.0.1",
81
80
  "html-entities": "^2.5.2",
82
81
  "locate-path": "^7.2.0",
83
- "qs": "^6.11.2"
82
+ "qs": "^6.12.1"
84
83
  },
85
84
  "peerDependencies": {
86
85
  "@adonisjs/core": "^6.2.0",