@adonisjs/inertia 4.0.0-next.2 → 4.0.0-next.3
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/{chunk-GO6QSFRS.js → chunk-A6EKUU4C.js} +1 -1
- package/build/{chunk-PDP56GPP.js → chunk-PJU4O2LR.js} +18 -6
- package/build/factories/main.js +2 -2
- package/build/index.js +2 -2
- package/build/providers/inertia_provider.js +1 -1
- package/build/src/client/helpers.d.ts +1 -1
- package/build/src/index_pages.d.ts +24 -0
- package/build/src/inertia.d.ts +3 -3
- package/build/src/inertia_middleware.d.ts +2 -2
- package/build/src/inertia_middleware.js +1 -1
- package/build/src/server_renderer.d.ts +1 -1
- package/build/src/types.d.ts +2 -2
- package/package.json +6 -6
|
@@ -447,7 +447,7 @@ var Inertia = class {
|
|
|
447
447
|
return this.#cachedVersion;
|
|
448
448
|
}
|
|
449
449
|
if (this.#vite?.hasManifestFile) {
|
|
450
|
-
this.#cachedVersion = createHash("md5").update(JSON.stringify(this.#vite.manifest)).digest("hex");
|
|
450
|
+
this.#cachedVersion = createHash("md5").update(JSON.stringify(this.#vite.manifest())).digest("hex");
|
|
451
451
|
} else {
|
|
452
452
|
this.#cachedVersion = "1";
|
|
453
453
|
}
|
|
@@ -13,11 +13,8 @@ type ExtractProps<T> = Omit<
|
|
|
13
13
|
>`,
|
|
14
14
|
react: `import type React from 'react'
|
|
15
15
|
|
|
16
|
-
type ExtractProps<T> =
|
|
17
|
-
? Props
|
|
18
|
-
: T extends React.Component<infer Props>
|
|
19
|
-
? Props
|
|
20
|
-
: never`
|
|
16
|
+
type ExtractProps<T> =
|
|
17
|
+
T extends React.FC<infer Props> ? Props : T extends React.Component<infer Props> ? Props : never`
|
|
21
18
|
};
|
|
22
19
|
var indexPages = function(config) {
|
|
23
20
|
if (!SUPPORTED_FRAMEWORKS.includes(config.framework)) {
|
|
@@ -26,14 +23,29 @@ var indexPages = function(config) {
|
|
|
26
23
|
);
|
|
27
24
|
}
|
|
28
25
|
return {
|
|
26
|
+
/**
|
|
27
|
+
* Executes the page indexing process to generate TypeScript definitions.
|
|
28
|
+
*
|
|
29
|
+
* @param _ - Unused first parameter (assembler context)
|
|
30
|
+
* @param indexGenerator - The index generator instance used to register the pages type generation
|
|
31
|
+
*/
|
|
29
32
|
run(_, indexGenerator) {
|
|
30
33
|
indexGenerator.add("inertiaPages", {
|
|
31
34
|
source: "inertia/pages",
|
|
32
35
|
glob: GLOB[config.framework],
|
|
33
36
|
output: ".adonisjs/server/pages.d.ts",
|
|
37
|
+
/**
|
|
38
|
+
* Generates the TypeScript module declaration for Inertia pages.
|
|
39
|
+
*
|
|
40
|
+
* @param vfs - Virtual file system containing the scanned page files
|
|
41
|
+
* @param buffer - Buffer instance for writing the generated TypeScript code
|
|
42
|
+
* @param __ - Unused third parameter
|
|
43
|
+
* @param helpers - Helper utilities for path manipulation and imports
|
|
44
|
+
*/
|
|
34
45
|
as(vfs, buffer, __, helpers) {
|
|
35
46
|
const filesList = vfs.asList();
|
|
36
|
-
buffer.
|
|
47
|
+
buffer.writeLine(`import '@adonisjs/inertia/types'`);
|
|
48
|
+
buffer.writeLine(TYPES_EXTRACTION_HELPER[config.framework]);
|
|
37
49
|
buffer.write(`declare module '@adonisjs/inertia/types' {`).indent();
|
|
38
50
|
buffer.write(`export interface InertiaPages {`).indent();
|
|
39
51
|
Object.keys(filesList).forEach((key) => {
|
package/build/factories/main.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineConfig
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-PJU4O2LR.js";
|
|
4
4
|
import {
|
|
5
5
|
Inertia,
|
|
6
6
|
ServerRenderer
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-A6EKUU4C.js";
|
|
8
8
|
import "../chunk-4EZ2J6OA.js";
|
|
9
9
|
import {
|
|
10
10
|
InertiaHeaders
|
package/build/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineConfig,
|
|
3
3
|
indexPages
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PJU4O2LR.js";
|
|
5
5
|
import {
|
|
6
6
|
Inertia,
|
|
7
7
|
InertiaManager,
|
|
8
8
|
ServerRenderer,
|
|
9
9
|
symbols_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-A6EKUU4C.js";
|
|
11
11
|
import "./chunk-4EZ2J6OA.js";
|
|
12
12
|
import {
|
|
13
13
|
InertiaHeaders
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @throws {Error} When none of the provided paths can be resolved in the pages registry
|
|
24
24
|
*/
|
|
25
|
-
export declare function resolvePageComponent<T>(path: string | string[], pages: Record<string, Promise<T> | (() => Promise<T>)>): Promise<T>;
|
|
25
|
+
export declare function resolvePageComponent<T>(path: string | string[], pages: Record<string, Promise<T> | (() => Promise<T>) | T>): Promise<T>;
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an AdonisJS assembler hook to automatically generate TypeScript definitions
|
|
3
|
+
* for Inertia.js pages based on the specified framework.
|
|
4
|
+
*
|
|
5
|
+
* This function scans page components in the 'inertia/pages' directory and generates
|
|
6
|
+
* type definitions that map page names to their component props.
|
|
7
|
+
*
|
|
8
|
+
* @param config - Configuration object specifying the frontend framework
|
|
9
|
+
* @param config.framework - The frontend framework ('vue3' or 'react')
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // In your adonisrc.ts file
|
|
13
|
+
* export default defineConfig({
|
|
14
|
+
* assembler: {
|
|
15
|
+
* onBuildStarting: [indexPages({ framework: 'vue3' })]
|
|
16
|
+
* }
|
|
17
|
+
* })
|
|
18
|
+
*/
|
|
1
19
|
export declare const indexPages: (config: {
|
|
2
20
|
framework: "vue3" | "react";
|
|
3
21
|
}) => {
|
|
22
|
+
/**
|
|
23
|
+
* Executes the page indexing process to generate TypeScript definitions.
|
|
24
|
+
*
|
|
25
|
+
* @param _ - Unused first parameter (assembler context)
|
|
26
|
+
* @param indexGenerator - The index generator instance used to register the pages type generation
|
|
27
|
+
*/
|
|
4
28
|
run(_: import("@adonisjs/assembler").DevServer | import("@adonisjs/assembler").TestRunner | import("@adonisjs/assembler").Bundler, indexGenerator: import("@adonisjs/assembler/index_generator").IndexGenerator): void;
|
|
5
29
|
};
|
package/build/src/inertia.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { defer, merge, always, optional, deepMerge } from './props.ts';
|
|
|
23
23
|
* inertia.location('/dashboard')
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
export declare class Inertia<Pages
|
|
26
|
+
export declare class Inertia<Pages> {
|
|
27
27
|
#private;
|
|
28
28
|
protected ctx: HttpContext;
|
|
29
29
|
protected config: InertiaConfig;
|
|
@@ -175,7 +175,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
|
|
|
175
175
|
* })
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
|
-
page<Page extends keyof Pages & string>(page: Page, pageProps: AsPageProps<Pages[Page]>): Promise<PageObject<Pages[Page]>>;
|
|
178
|
+
page<Page extends keyof Pages & string>(page: Page, pageProps: Pages[Page] extends ComponentProps ? AsPageProps<Pages[Page]> : never): Promise<PageObject<Pages[Page]>>;
|
|
179
179
|
/**
|
|
180
180
|
* Render a page using Inertia
|
|
181
181
|
*
|
|
@@ -202,7 +202,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
|
|
|
202
202
|
* const html = await inertia.render('Home', { welcome: 'Hello World' })
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
205
|
-
render<Page extends keyof Pages & string>(page: Page, pageProps: AsPageProps<Pages[Page]
|
|
205
|
+
render<Page extends keyof Pages & string>(page: Page, pageProps: Pages[Page] extends ComponentProps ? AsPageProps<Pages[Page]> : never, viewProps?: Record<string, any>): Promise<string | PageObject<Pages[Page]>>;
|
|
206
206
|
/**
|
|
207
207
|
* Clear the browser history on the next navigation
|
|
208
208
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
2
|
import { type Inertia } from './inertia.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { InertiaPages, PageProps } from './types.js';
|
|
4
4
|
declare module '@adonisjs/core/http' {
|
|
5
5
|
interface HttpContext {
|
|
6
|
-
inertia: Inertia<InertiaPages
|
|
6
|
+
inertia: Inertia<InertiaPages>;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
/**
|
package/build/src/types.d.ts
CHANGED
|
@@ -290,7 +290,7 @@ export type InertiaConfigInput = DeepPartial<InertiaConfig>;
|
|
|
290
290
|
*
|
|
291
291
|
* @template Props - The props type for the page component
|
|
292
292
|
*/
|
|
293
|
-
export type PageObject<Props
|
|
293
|
+
export type PageObject<Props> = {
|
|
294
294
|
/**
|
|
295
295
|
* The name/path of the component to render
|
|
296
296
|
*/
|
|
@@ -373,7 +373,7 @@ export interface InertiaPages {
|
|
|
373
373
|
* @param page - The page object containing component and props data
|
|
374
374
|
* @returns Promise resolving to an object with head tags and body HTML
|
|
375
375
|
*/
|
|
376
|
-
export type RenderInertiaSsrApp = (page: PageObject) => Promise<{
|
|
376
|
+
export type RenderInertiaSsrApp = (page: PageObject<any>) => Promise<{
|
|
377
377
|
head: string[];
|
|
378
378
|
body: string;
|
|
379
379
|
}>;
|
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.3",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -58,21 +58,21 @@
|
|
|
58
58
|
"@japa/snapshot": "^2.0.9",
|
|
59
59
|
"@poppinss/ts-exec": "^1.4.1",
|
|
60
60
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
61
|
-
"@types/node": "^24.
|
|
61
|
+
"@types/node": "^24.5.2",
|
|
62
62
|
"@types/supertest": "^6.0.3",
|
|
63
63
|
"c8": "^10.1.3",
|
|
64
64
|
"copyfiles": "^2.4.1",
|
|
65
65
|
"cross-env": "^10.0.0",
|
|
66
|
-
"del-cli": "^
|
|
66
|
+
"del-cli": "^7.0.0",
|
|
67
67
|
"edge.js": "^6.3.0",
|
|
68
|
-
"eslint": "^9.
|
|
68
|
+
"eslint": "^9.36.0",
|
|
69
69
|
"get-port": "^7.1.0",
|
|
70
70
|
"prettier": "^3.6.2",
|
|
71
|
-
"release-it": "^19.0.
|
|
71
|
+
"release-it": "^19.0.5",
|
|
72
72
|
"supertest": "^7.1.4",
|
|
73
73
|
"tsup": "^8.5.0",
|
|
74
74
|
"typescript": "~5.9.2",
|
|
75
|
-
"vite": "^7.1.
|
|
75
|
+
"vite": "^7.1.7"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@poppinss/utils": "^7.0.0-next.3",
|