@adonisjs/inertia 1.0.0-19 → 1.0.0-20
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-7ZZGYDYU.js → chunk-PJEYAPJB.js} +16 -5
- package/build/providers/inertia_provider.js +1 -1
- package/build/react/tsconfig.json.stub +1 -1
- package/build/src/inertia_middleware.d.ts +1 -1
- package/build/src/inertia_middleware.js +1 -1
- package/build/src/types.d.ts +4 -4
- package/package.json +17 -17
|
@@ -150,12 +150,23 @@ var Inertia = class {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
|
-
* If the page should be rendered on the server
|
|
153
|
+
* If the page should be rendered on the server or not
|
|
154
|
+
*
|
|
155
|
+
* The ssr.pages config can be a list of pages or a function that returns a boolean
|
|
154
156
|
*/
|
|
155
|
-
#shouldRenderOnServer(component) {
|
|
157
|
+
async #shouldRenderOnServer(component) {
|
|
156
158
|
const isSsrEnabled = this.config.ssr.enabled;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
if (!isSsrEnabled)
|
|
160
|
+
return false;
|
|
161
|
+
let isSsrEnabledForPage = false;
|
|
162
|
+
if (typeof this.config.ssr.pages === "function") {
|
|
163
|
+
isSsrEnabledForPage = await this.config.ssr.pages(this.ctx, component);
|
|
164
|
+
} else if (this.config.ssr.pages) {
|
|
165
|
+
isSsrEnabledForPage = this.config.ssr.pages?.includes(component);
|
|
166
|
+
} else {
|
|
167
|
+
isSsrEnabledForPage = true;
|
|
168
|
+
}
|
|
169
|
+
return isSsrEnabledForPage;
|
|
159
170
|
}
|
|
160
171
|
/**
|
|
161
172
|
* Render the page on the server
|
|
@@ -181,7 +192,7 @@ var Inertia = class {
|
|
|
181
192
|
const pageObject = await this.#buildPageObject(component, pageProps);
|
|
182
193
|
const isInertiaRequest = !!this.ctx.request.header("x-inertia");
|
|
183
194
|
if (!isInertiaRequest) {
|
|
184
|
-
const shouldRenderOnServer = this.#shouldRenderOnServer(component);
|
|
195
|
+
const shouldRenderOnServer = await this.#shouldRenderOnServer(component);
|
|
185
196
|
if (shouldRenderOnServer)
|
|
186
197
|
return this.#renderOnServer(pageObject, viewProps);
|
|
187
198
|
return this.ctx.view.render(this.config.rootView, { ...viewProps, page: pageObject });
|
|
@@ -24,7 +24,7 @@ declare class Inertia {
|
|
|
24
24
|
/**
|
|
25
25
|
* Render a page using Inertia
|
|
26
26
|
*/
|
|
27
|
-
render<TPageProps extends Record<string, any> = PageProps, TViewProps extends Record<string, any> = PageProps>(component: string, pageProps?: TPageProps, viewProps?: TViewProps): Promise<string | PageObject
|
|
27
|
+
render<TPageProps extends Record<string, any> = PageProps, TViewProps extends Record<string, any> = PageProps>(component: string, pageProps?: TPageProps, viewProps?: TViewProps): Promise<string | PageObject<TPageProps>>;
|
|
28
28
|
/**
|
|
29
29
|
* Create a lazy prop
|
|
30
30
|
*
|
package/build/src/types.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ interface InertiaConfig {
|
|
|
71
71
|
/**
|
|
72
72
|
* List of components that should be rendered on the server
|
|
73
73
|
*/
|
|
74
|
-
pages?: string[];
|
|
74
|
+
pages?: string[] | ((ctx: HttpContext, page: string) => MaybePromise<boolean>);
|
|
75
75
|
/**
|
|
76
76
|
* Path to the SSR entrypoint file
|
|
77
77
|
*/
|
|
@@ -93,14 +93,14 @@ interface ResolvedConfig {
|
|
|
93
93
|
ssr: {
|
|
94
94
|
enabled: boolean;
|
|
95
95
|
entrypoint: string;
|
|
96
|
-
pages?: string[];
|
|
96
|
+
pages?: string[] | ((ctx: HttpContext, page: string) => MaybePromise<boolean>);
|
|
97
97
|
bundle: string;
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
interface PageObject {
|
|
100
|
+
interface PageObject<TPageProps extends PageProps = PageProps> {
|
|
101
101
|
component: string;
|
|
102
102
|
version: string | number;
|
|
103
|
-
props:
|
|
103
|
+
props: TPageProps;
|
|
104
104
|
url: string;
|
|
105
105
|
ssrHead?: string;
|
|
106
106
|
ssrBody?: string;
|
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-20",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@adonisjs/assembler": "^7.2.3",
|
|
42
42
|
"@adonisjs/core": "6.3.1",
|
|
43
|
-
"@adonisjs/eslint-config": "^1.
|
|
44
|
-
"@adonisjs/prettier-config": "^1.
|
|
45
|
-
"@adonisjs/session": "7.
|
|
46
|
-
"@adonisjs/tsconfig": "^1.
|
|
47
|
-
"@adonisjs/vite": "^3.0.0-
|
|
43
|
+
"@adonisjs/eslint-config": "^1.3.0",
|
|
44
|
+
"@adonisjs/prettier-config": "^1.3.0",
|
|
45
|
+
"@adonisjs/session": "7.3.0",
|
|
46
|
+
"@adonisjs/tsconfig": "^1.3.0",
|
|
47
|
+
"@adonisjs/vite": "^3.0.0-8",
|
|
48
48
|
"@japa/api-client": "^2.0.2",
|
|
49
49
|
"@japa/assert": "2.1.0",
|
|
50
50
|
"@japa/expect-type": "^2.0.1",
|
|
@@ -52,39 +52,39 @@
|
|
|
52
52
|
"@japa/plugin-adonisjs": "^3.0.0",
|
|
53
53
|
"@japa/runner": "3.1.1",
|
|
54
54
|
"@japa/snapshot": "^2.0.4",
|
|
55
|
-
"@swc/core": "^1.4.
|
|
56
|
-
"@types/node": "^20.11.
|
|
57
|
-
"@types/qs": "^6.9.
|
|
55
|
+
"@swc/core": "^1.4.8",
|
|
56
|
+
"@types/node": "^20.11.30",
|
|
57
|
+
"@types/qs": "^6.9.14",
|
|
58
58
|
"@types/supertest": "^6.0.2",
|
|
59
59
|
"@vavite/multibuild": "^4.1.1",
|
|
60
60
|
"c8": "^9.1.0",
|
|
61
61
|
"copyfiles": "^2.4.1",
|
|
62
62
|
"del-cli": "^5.1.0",
|
|
63
|
-
"edge-parser": "^9.0.
|
|
64
|
-
"edge.js": "^6.0.
|
|
63
|
+
"edge-parser": "^9.0.2",
|
|
64
|
+
"edge.js": "^6.0.2",
|
|
65
65
|
"eslint": "^8.57.0",
|
|
66
|
-
"get-port": "^7.
|
|
67
|
-
"np": "^10.0.
|
|
66
|
+
"get-port": "^7.1.0",
|
|
67
|
+
"np": "^10.0.2",
|
|
68
68
|
"prettier": "^3.2.5",
|
|
69
69
|
"supertest": "^6.3.4",
|
|
70
70
|
"tinybench": "^2.6.0",
|
|
71
71
|
"ts-node": "^10.9.2",
|
|
72
72
|
"tsup": "^8.0.2",
|
|
73
|
-
"typescript": "~5.
|
|
74
|
-
"vite": "^5.
|
|
73
|
+
"typescript": "~5.4.3",
|
|
74
|
+
"vite": "^5.2.6"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@poppinss/utils": "^6.7.2",
|
|
78
78
|
"crc-32": "^1.2.2",
|
|
79
79
|
"edge-error": "^4.0.1",
|
|
80
|
-
"html-entities": "^2.
|
|
80
|
+
"html-entities": "^2.5.2",
|
|
81
81
|
"locate-path": "^7.2.0",
|
|
82
82
|
"qs": "^6.11.2"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@adonisjs/core": "^6.2.0",
|
|
86
86
|
"@adonisjs/session": "^7.0.0",
|
|
87
|
-
"@adonisjs/vite": "^3.0.0-
|
|
87
|
+
"@adonisjs/vite": "^3.0.0-8",
|
|
88
88
|
"@japa/api-client": "^2.0.0",
|
|
89
89
|
"edge.js": "^6.0.0"
|
|
90
90
|
},
|