@adonisjs/inertia 1.0.0-1 → 1.0.0-11

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.
Files changed (35) hide show
  1. package/build/app.css.stub +39 -0
  2. package/build/{chunk-TO74VVAR.js → chunk-CXICUKHN.js} +49 -7
  3. package/build/{stubs/config.stub → config.stub} +9 -1
  4. package/build/index.d.ts +2 -2
  5. package/build/index.js +150 -35
  6. package/build/providers/inertia_provider.d.ts +10 -3
  7. package/build/providers/inertia_provider.js +25 -18
  8. package/build/react/app.tsx.stub +25 -0
  9. package/build/react/home.tsx.stub +21 -0
  10. package/build/react/root.edge.stub +22 -0
  11. package/build/react/ssr.tsx.stub +17 -0
  12. package/build/react/tsconfig.json.stub +25 -0
  13. package/build/solid/app.tsx.stub +24 -0
  14. package/build/solid/home.tsx.stub +21 -0
  15. package/build/solid/root.edge.stub +21 -0
  16. package/build/solid/ssr.tsx.stub +19 -0
  17. package/build/solid/tsconfig.json.stub +26 -0
  18. package/build/src/helpers.d.ts +12 -0
  19. package/build/src/helpers.js +14 -0
  20. package/build/src/inertia_middleware.d.ts +13 -4
  21. package/build/src/inertia_middleware.js +1 -1
  22. package/build/src/plugins/edge/plugin.js +85 -0
  23. package/build/src/plugins/{api_client.d.ts → japa/api_client.d.ts} +1 -1
  24. package/build/src/plugins/{api_client.js → japa/api_client.js} +1 -1
  25. package/build/src/plugins/vite.d.ts +26 -0
  26. package/build/src/plugins/vite.js +33 -0
  27. package/build/src/types.d.ts +27 -0
  28. package/build/vue/app.ts.stub +27 -0
  29. package/build/vue/home.vue.stub +21 -0
  30. package/build/vue/root.edge.stub +21 -0
  31. package/build/vue/ssr.ts.stub +22 -0
  32. package/build/vue/tsconfig.json.stub +26 -0
  33. package/package.json +48 -40
  34. package/build/src/plugins/edge.js +0 -41
  35. /package/build/src/plugins/{edge.d.ts → edge/plugin.d.ts} +0 -0
@@ -0,0 +1,39 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/css/app.css') })
3
+ }}}
4
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap');
5
+
6
+ * {
7
+ margin: 0;
8
+ padding: 0;
9
+ }
10
+
11
+ html,
12
+ body,
13
+ #app {
14
+ background-color: #F7F8FA;
15
+ font-family: 'Poppins', sans-serif;
16
+ color: #46444c;
17
+ height: 100%;
18
+ width: 100%;
19
+ }
20
+
21
+ .title {
22
+ font-size: 42px;
23
+ font-weight: 500;
24
+ color: #5a45ff;
25
+ }
26
+
27
+ .container {
28
+ display: flex;
29
+ justify-content: center;
30
+ align-items: center;
31
+ flex-direction: column;
32
+ height: 100%;
33
+ width: 100%;
34
+ }
35
+
36
+ a {
37
+ text-decoration: underline;
38
+ color: #5a45ff;
39
+ }
@@ -1,10 +1,13 @@
1
1
  // src/inertia.ts
2
2
  var kLazySymbol = Symbol("lazy");
3
3
  var Inertia = class {
4
- constructor(ctx, config) {
4
+ constructor(ctx, config, viteRuntime) {
5
5
  this.ctx = ctx;
6
6
  this.config = config;
7
+ this.viteRuntime = viteRuntime;
8
+ this.#sharedData = config.sharedData;
7
9
  }
10
+ #sharedData = {};
8
11
  /**
9
12
  * Check if a value is a lazy prop
10
13
  */
@@ -54,19 +57,57 @@ var Inertia = class {
54
57
  return {
55
58
  component,
56
59
  version: this.config.versionCache.getVersion(),
57
- props: await this.#resolvePageProps(component, { ...this.config.sharedData, ...pageProps }),
60
+ props: await this.#resolvePageProps(component, { ...this.#sharedData, ...pageProps }),
58
61
  url: this.ctx.request.url(true)
59
62
  };
60
63
  }
64
+ /**
65
+ * If the page should be rendered on the server
66
+ */
67
+ #shouldRenderOnServer(component) {
68
+ const isSsrEnabled = this.config.ssr.enabled;
69
+ const isSsrEnabledForPage = this.config.ssr.pages ? this.config.ssr.pages.includes(component) : true;
70
+ return isSsrEnabled && isSsrEnabledForPage;
71
+ }
72
+ /**
73
+ * Render the page on the server
74
+ *
75
+ * On development, we use the Vite Runtime API
76
+ * On production, we just import and use the SSR bundle generated by Vite
77
+ */
78
+ async #renderOnServer(pageObject, viewProps) {
79
+ let render;
80
+ if (this.viteRuntime) {
81
+ render = await this.viteRuntime.executeEntrypoint(this.config.ssr.entrypoint);
82
+ } else {
83
+ render = await import(this.config.ssr.bundle);
84
+ }
85
+ const result = await render.default(pageObject);
86
+ return this.ctx.view.render(this.config.rootView, {
87
+ ...viewProps,
88
+ page: { ssrHead: result.head, ssrBody: result.body }
89
+ });
90
+ }
91
+ /**
92
+ * Share data for the current request.
93
+ * This data will override any shared data defined in the config.
94
+ */
95
+ share(data) {
96
+ this.#sharedData = { ...this.#sharedData, ...data };
97
+ }
61
98
  /**
62
99
  * Render a page using Inertia
63
100
  */
64
- async render(component, pageProps) {
101
+ async render(component, pageProps, viewProps) {
65
102
  const pageObject = await this.#buildPageObject(component, pageProps);
66
103
  const isInertiaRequest = !!this.ctx.request.header("x-inertia");
67
104
  if (!isInertiaRequest) {
68
- return this.ctx.view.render(this.config.rootView, { page: pageObject });
105
+ const shouldRenderOnServer = this.#shouldRenderOnServer(component);
106
+ if (shouldRenderOnServer)
107
+ return this.#renderOnServer(pageObject, viewProps);
108
+ return this.ctx.view.render(this.config.rootView, { ...viewProps, page: pageObject });
69
109
  }
110
+ this.ctx.response.header("x-inertia", "true");
70
111
  return pageObject;
71
112
  }
72
113
  /**
@@ -94,18 +135,19 @@ var Inertia = class {
94
135
 
95
136
  // src/inertia_middleware.ts
96
137
  var InertiaMiddleware = class {
97
- constructor(config) {
138
+ constructor(config, vite) {
98
139
  this.config = config;
140
+ this.#runtime = vite?.getRuntime();
99
141
  }
142
+ #runtime;
100
143
  async handle(ctx, next) {
101
144
  const { response, request } = ctx;
102
- ctx.inertia = new Inertia(ctx, this.config);
145
+ ctx.inertia = new Inertia(ctx, this.config, this.#runtime);
103
146
  await next();
104
147
  const isInertiaRequest = !!request.header("x-inertia");
105
148
  if (!isInertiaRequest)
106
149
  return;
107
150
  response.header("Vary", "Accept");
108
- response.header("X-Inertia", "true");
109
151
  const method = request.method();
110
152
  if (response.getStatus() === 302 && ["PUT", "PATCH", "DELETE"].includes(method)) {
111
153
  response.status(303);
@@ -7,7 +7,7 @@ export default defineConfig({
7
7
  /**
8
8
  * Path to the Edge view that will be used as the root view for Inertia responses
9
9
  */
10
- rootView: 'home',
10
+ rootView: 'root',
11
11
 
12
12
  /**
13
13
  * Data that should be shared with all rendered pages
@@ -15,4 +15,12 @@ export default defineConfig({
15
15
  sharedData: {
16
16
  errors: (ctx) => ctx.session.flashMessages.get('errors'),
17
17
  },
18
+
19
+ /**
20
+ * Options for the server-side rendering
21
+ */
22
+ ssr: {
23
+ enabled: {{ ssr }},
24
+ entrypoint: '{{ ssrEntrypoint }}'
25
+ }
18
26
  })
package/build/index.d.ts CHANGED
@@ -8,11 +8,11 @@ import '@adonisjs/core/http';
8
8
  */
9
9
  declare function configure(command: Configure): Promise<void>;
10
10
 
11
- declare const stubsRoot: string;
12
-
13
11
  /**
14
12
  * Define the Inertia configuration
15
13
  */
16
14
  declare function defineConfig(config: InertiaConfig): ConfigProvider<ResolvedConfig>;
17
15
 
16
+ declare const stubsRoot: string;
17
+
18
18
  export { configure, defineConfig, stubsRoot };
package/build/index.js CHANGED
@@ -1,70 +1,179 @@
1
1
  // configure.ts
2
- var ADAPTERS = ["Vue 3", "React", "Svelte"];
2
+ import string from "@poppinss/utils/string";
3
+
4
+ // stubs/main.ts
5
+ import { getDirname } from "@poppinss/utils";
6
+ var stubsRoot = getDirname(import.meta.url);
7
+
8
+ // configure.ts
9
+ var ADAPTERS = ["vue", "react", "svelte", "solid"];
3
10
  var ADAPTERS_INFO = {
4
- "Vue 3": {
11
+ vue: {
12
+ stubFolder: "vue",
13
+ appExtension: "ts",
14
+ componentsExtension: "vue",
5
15
  dependencies: [
6
16
  { name: "@inertiajs/vue3", isDevDependency: false },
7
17
  { name: "vue", isDevDependency: false },
8
18
  { name: "@vitejs/plugin-vue", isDevDependency: true }
9
- ]
19
+ ],
20
+ ssrDependencies: [{ name: "@vue/server-renderer", isDevDependency: false }],
21
+ viteRegister: {
22
+ pluginCall: "vue()",
23
+ importDeclarations: [{ isNamed: false, module: "@vitejs/plugin-vue", identifier: "vue" }]
24
+ },
25
+ ssrEntrypoint: "resources/ssr.ts"
10
26
  },
11
- "React": {
27
+ react: {
28
+ stubFolder: "react",
29
+ appExtension: "tsx",
30
+ componentsExtension: "tsx",
12
31
  dependencies: [
13
- { name: "@inertiajs/inertia-react", isDevDependency: false },
32
+ { name: "@inertiajs/react", isDevDependency: false },
14
33
  { name: "react", isDevDependency: false },
15
34
  { name: "react-dom", isDevDependency: false },
16
35
  { name: "@vitejs/plugin-react", isDevDependency: true },
17
36
  { name: "@types/react", isDevDependency: true },
18
37
  { name: "@types/react-dom", isDevDependency: true }
19
- ]
38
+ ],
39
+ viteRegister: {
40
+ pluginCall: "react()",
41
+ importDeclarations: [{ isNamed: false, module: "@vitejs/plugin-react", identifier: "react" }]
42
+ },
43
+ ssrEntrypoint: "resources/ssr.tsx"
20
44
  },
21
- "Svelte": {
45
+ svelte: {
46
+ stubFolder: "svelte",
47
+ appExtension: "ts",
48
+ componentsExtension: "svelte",
22
49
  dependencies: [
23
- { name: "@inertiajs/inertia-svelte", isDevDependency: false },
50
+ { name: "@inertiajs/svelte", isDevDependency: false },
24
51
  { name: "svelte", isDevDependency: false },
25
52
  { name: "@sveltejs/vite-plugin-svelte", isDevDependency: true }
26
- ]
53
+ ],
54
+ viteRegister: {
55
+ pluginCall: "svelte()",
56
+ importDeclarations: [
57
+ { isNamed: false, module: "@sveltejs/vite-plugin-svelte", identifier: "svelte" }
58
+ ]
59
+ },
60
+ ssrEntrypoint: "resources/ssr.ts"
61
+ },
62
+ solid: {
63
+ stubFolder: "solid",
64
+ appExtension: "tsx",
65
+ componentsExtension: "tsx",
66
+ dependencies: [
67
+ { name: "solid-js", isDevDependency: false },
68
+ { name: "inertia-adapter-solid", isDevDependency: false },
69
+ { name: "vite-plugin-solid", isDevDependency: true },
70
+ { name: "@solidjs/meta", isDevDependency: false }
71
+ ],
72
+ viteRegister: {
73
+ pluginCall: "solid()",
74
+ ssrPluginCall: "solid({ ssr: true })",
75
+ importDeclarations: [{ isNamed: false, module: "vite-plugin-solid", identifier: "solid" }]
76
+ },
77
+ ssrEntrypoint: "resources/ssr.tsx"
27
78
  }
28
79
  };
80
+ async function defineExampleRoute(command, codemods) {
81
+ const tsMorph = await codemods.getTsMorphProject();
82
+ const routesFile = tsMorph?.getSourceFile(command.app.makePath("./start/routes.ts"));
83
+ if (!routesFile) {
84
+ return command.logger.warning("Unable to find the routes file");
85
+ }
86
+ const isAlreadyDefined = routesFile.getText().includes("/inertia");
87
+ if (isAlreadyDefined) {
88
+ command.logger.warning("/inertia route is already defined. Skipping");
89
+ return;
90
+ }
91
+ const action = command.logger.action("update start/routes.ts file");
92
+ try {
93
+ routesFile?.addStatements((writer) => {
94
+ writer.writeLine(`router.on('/inertia').renderInertia('home', { version: 6 })`);
95
+ });
96
+ await tsMorph?.save();
97
+ action.succeeded();
98
+ } catch (error) {
99
+ codemods.emit("error", error);
100
+ action.failed(error.message);
101
+ }
102
+ }
29
103
  async function configure(command) {
30
- const adapter = await command.prompt.choice(
31
- "Select the Inertia adapter you want to use",
32
- ADAPTERS,
33
- { name: "adapter" }
34
- );
35
- const pkgToInstall = ADAPTERS_INFO[adapter].dependencies;
36
- const withSsr = await command.prompt.confirm("Do you want to enable server-side rendering?", {
37
- name: "ssr"
38
- });
39
- if (withSsr) {
40
- pkgToInstall.push(...ADAPTERS_INFO[adapter].ssrDependencies || []);
104
+ let adapter = command.parsedFlags.adapter;
105
+ let ssr = command.parsedFlags.ssr;
106
+ let shouldInstallPackages = command.parsedFlags.install;
107
+ if (adapter === void 0) {
108
+ adapter = await command.prompt.choice(
109
+ "Select the Inertia adapter you want to use",
110
+ ADAPTERS.map((adapterName) => string.capitalCase(adapterName)),
111
+ { name: "adapter", result: (value) => value.toLowerCase() }
112
+ );
113
+ }
114
+ if (ssr === void 0) {
115
+ ssr = await command.prompt.confirm("Do you want to use server-side rendering?", {
116
+ name: "ssr"
117
+ });
41
118
  }
119
+ if (adapter in ADAPTERS_INFO === false) {
120
+ command.logger.error(
121
+ `The selected adapter "${adapter}" is invalid. Select one from: ${string.sentence(
122
+ Object.keys(ADAPTERS_INFO)
123
+ )}`
124
+ );
125
+ command.exitCode = 1;
126
+ return;
127
+ }
128
+ const adapterInfo = ADAPTERS_INFO[adapter];
42
129
  const codemods = await command.createCodemods();
43
130
  await codemods.updateRcFile((rcFile) => {
44
131
  rcFile.addProvider("@adonisjs/inertia/inertia_provider");
45
132
  });
46
- codemods.registerMiddleware("router", [
133
+ await codemods.registerMiddleware("router", [
47
134
  { path: "@adonisjs/inertia/inertia_middleware", position: "after" }
48
135
  ]);
49
- await command.publishStub("config.stub");
50
- const shouldInstallPackages = await command.prompt.confirm(
51
- `Do you want to install dependencies ${pkgToInstall.map((pkg) => pkg.name).join(", ")}?`,
52
- { name: "install" }
136
+ const appExt = adapterInfo.appExtension;
137
+ const stubFolder = adapterInfo.stubFolder;
138
+ const compExt = adapterInfo.componentsExtension;
139
+ await codemods.makeUsingStub(stubsRoot, "config.stub", {
140
+ ssr,
141
+ ssrEntrypoint: adapterInfo.ssrEntrypoint
142
+ });
143
+ await codemods.makeUsingStub(stubsRoot, `app.css.stub`, {});
144
+ await codemods.makeUsingStub(stubsRoot, `${stubFolder}/root.edge.stub`, {});
145
+ await codemods.makeUsingStub(stubsRoot, `${stubFolder}/tsconfig.json.stub`, {});
146
+ await codemods.makeUsingStub(stubsRoot, `${stubFolder}/app.${appExt}.stub`, {});
147
+ await codemods.makeUsingStub(stubsRoot, `${stubFolder}/home.${compExt}.stub`, {});
148
+ if (ssr) {
149
+ await codemods.makeUsingStub(stubsRoot, `${stubFolder}/ssr.${appExt}.stub`, {});
150
+ }
151
+ const inertiaPluginCall = ssr ? `inertia({ ssr: { enabled: true, entrypoint: 'resources/ssr.${appExt}' } })` : `inertia({ ssr: { enabled: false } })`;
152
+ await codemods.registerVitePlugin(inertiaPluginCall, [
153
+ { isNamed: false, module: "@adonisjs/inertia/client", identifier: "inertia" }
154
+ ]);
155
+ await codemods.registerVitePlugin(
156
+ ssr && adapterInfo.viteRegister.ssrPluginCall ? adapterInfo.viteRegister.ssrPluginCall : adapterInfo.viteRegister.pluginCall,
157
+ adapterInfo.viteRegister.importDeclarations
53
158
  );
159
+ await defineExampleRoute(command, codemods);
160
+ const pkgToInstall = adapterInfo.dependencies;
161
+ if (ssr && adapterInfo.ssrDependencies) {
162
+ pkgToInstall.push(...adapterInfo.ssrDependencies);
163
+ }
164
+ if (shouldInstallPackages === void 0) {
165
+ shouldInstallPackages = await command.prompt.confirm(
166
+ `Do you want to install dependencies ${pkgToInstall.map((pkg) => pkg.name).join(", ")}?`,
167
+ { name: "install" }
168
+ );
169
+ }
54
170
  if (shouldInstallPackages) {
55
- command.installPackages(pkgToInstall);
171
+ await codemods.installPackages(pkgToInstall);
56
172
  } else {
57
- command.listPackagesToInstall(pkgToInstall);
173
+ await codemods.listPackagesToInstall(pkgToInstall);
58
174
  }
59
- command.logger.success(
60
- "Inertia was configured successfully. Please note that you still need to update your vite config, setup your Edge root view and others things. Read the docs for more info."
61
- );
62
175
  }
63
176
 
64
- // stubs/main.ts
65
- import { getDirname } from "@poppinss/utils";
66
- var stubsRoot = getDirname(import.meta.url);
67
-
68
177
  // src/define_config.ts
69
178
  import { configProvider } from "@adonisjs/core";
70
179
 
@@ -124,7 +233,13 @@ function defineConfig(config) {
124
233
  return {
125
234
  rootView: config.rootView ?? "root",
126
235
  sharedData: config.sharedData || {},
127
- versionCache
236
+ versionCache,
237
+ ssr: {
238
+ enabled: config.ssr?.enabled ?? false,
239
+ pages: config.ssr?.pages,
240
+ entrypoint: config.ssr?.entrypoint ?? app.makePath("resources/ssr.ts"),
241
+ bundle: config.ssr?.bundle ?? app.makePath("ssr/ssr.js")
242
+ }
128
243
  };
129
244
  });
130
245
  }
@@ -1,5 +1,14 @@
1
1
  import { ApplicationService } from '@adonisjs/core/types';
2
2
 
3
+ declare module '@adonisjs/core/http' {
4
+ interface BriskRoute {
5
+ /**
6
+ * Render an inertia page without defining an
7
+ * explicit route handler
8
+ */
9
+ renderInertia(component: string, props?: Record<string, any>, viewProps?: Record<string, any>): void;
10
+ }
11
+ }
3
12
  /**
4
13
  * Inertia provider
5
14
  */
@@ -10,10 +19,8 @@ declare class InertiaProvider {
10
19
  * Registers edge plugin when edge is installed
11
20
  */
12
21
  protected registerEdgePlugin(): Promise<void>;
13
- /**
14
- * Register Inertia bindings
15
- */
16
22
  register(): Promise<void>;
23
+ boot(): Promise<void>;
17
24
  }
18
25
 
19
26
  export { InertiaProvider as default };
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  InertiaMiddleware
3
- } from "../chunk-TO74VVAR.js";
3
+ } from "../chunk-CXICUKHN.js";
4
4
 
5
5
  // providers/inertia_provider.ts
6
6
  import { configProvider } from "@adonisjs/core";
7
7
  import { RuntimeException } from "@poppinss/utils";
8
+ import { BriskRoute } from "@adonisjs/core/http";
8
9
  var InertiaProvider = class {
9
10
  constructor(app) {
10
11
  this.app = app;
@@ -13,26 +14,32 @@ var InertiaProvider = class {
13
14
  * Registers edge plugin when edge is installed
14
15
  */
15
16
  async registerEdgePlugin() {
16
- try {
17
- const edgeExports = await import("edge.js");
18
- const { edgePluginInertia } = await import("../src/plugins/edge.js");
19
- edgeExports.default.use(edgePluginInertia());
20
- } catch {
21
- }
17
+ if (!this.app.usingEdgeJS)
18
+ return;
19
+ const edgeExports = await import("edge.js");
20
+ const { edgePluginInertia } = await import("../src/plugins/edge/plugin.js");
21
+ edgeExports.default.use(edgePluginInertia());
22
22
  }
23
- /**
24
- * Register Inertia bindings
25
- */
26
23
  async register() {
27
- const inertiaConfigProvider = this.app.config.get("inertia");
28
- const config = await configProvider.resolve(this.app, inertiaConfigProvider);
29
- if (!config) {
30
- throw new RuntimeException(
31
- 'Invalid "config/inertia.ts" file. Make sure you are using the "defineConfig" method'
32
- );
33
- }
34
- this.app.container.singleton(InertiaMiddleware, () => new InertiaMiddleware(config));
24
+ this.app.container.singleton(InertiaMiddleware, async () => {
25
+ const inertiaConfigProvider = this.app.config.get("inertia");
26
+ const config = await configProvider.resolve(this.app, inertiaConfigProvider);
27
+ const vite = await this.app.container.make("vite");
28
+ if (!config) {
29
+ throw new RuntimeException(
30
+ 'Invalid "config/inertia.ts" file. Make sure you are using the "defineConfig" method'
31
+ );
32
+ }
33
+ return new InertiaMiddleware(config, vite);
34
+ });
35
+ }
36
+ async boot() {
35
37
  await this.registerEdgePlugin();
38
+ BriskRoute.macro("renderInertia", function(template, props, viewProps) {
39
+ return this.setHandler(({ inertia }) => {
40
+ return inertia.render(template, props, viewProps);
41
+ });
42
+ });
36
43
  }
37
44
  };
38
45
  export {
@@ -0,0 +1,25 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/app.tsx') })
3
+ }}}
4
+ import './css/app.css';
5
+
6
+ import { createRoot } from 'react-dom/client';
7
+ import { createInertiaApp } from '@inertiajs/react';
8
+
9
+ const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS'
10
+
11
+ createInertiaApp({
12
+ progress: { color: '#5468FF' },
13
+
14
+ title: (title) => {{ '`${title} - ${appName}`' }},
15
+
16
+ resolve: (name) => {
17
+ const pages = import.meta.glob('./pages/**/*.tsx', { eager: true })
18
+ {{ 'return pages[`./pages/${name}.tsx`]' }}
19
+ },
20
+
21
+ setup({ el, App, props }) {
22
+ const root = createRoot(el);
23
+ root.render(<App {...props} />);
24
+ },
25
+ });
@@ -0,0 +1,21 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/pages/home.tsx') })
3
+ }}}
4
+ import { Head } from '@inertiajs/react'
5
+
6
+ export default function Home(props: { version: number }) {
7
+ return (
8
+ <>
9
+ <Head title="Homepage" />
10
+
11
+ <div className="container">
12
+ <div className="title">AdonisJS {props.version} x Inertia x React</div>
13
+
14
+ <span>
15
+ Learn more about AdonisJS and Inertia.js by visiting the{' '}
16
+ <a href="https://docs.adonisjs.com/inertia">AdonisJS documentation</a>.
17
+ </span>
18
+ </div>
19
+ </>
20
+ )
21
+ }
@@ -0,0 +1,22 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/views/root.edge') })
3
+ }}}
4
+ <!DOCTYPE html>
5
+ <html>
6
+
7
+ <head>
8
+ <meta charset="utf-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+
11
+ <title inertia>AdonisJS x Inertia x React</title>
12
+
13
+ @viteReactRefresh()
14
+ @vite(['resources/app.tsx'])
15
+ @inertiaHead()
16
+ </head>
17
+
18
+ <body>
19
+ @inertia()
20
+ </body>
21
+
22
+ </html>
@@ -0,0 +1,17 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/ssr.tsx') })
3
+ }}}
4
+ import ReactDOMServer from 'react-dom/server'
5
+ import { createInertiaApp } from '@inertiajs/react'
6
+
7
+ export default function render(page: any) {
8
+ return createInertiaApp({
9
+ page,
10
+ render: ReactDOMServer.renderToString,
11
+ resolve: (name) => {
12
+ const pages = import.meta.glob('./pages/**/*.tsx', { eager: true })
13
+ {{ 'return pages[`./pages/${name}.tsx`]' }}
14
+ },
15
+ setup: ({ App, props }) => <App {...props} />,
16
+ })
17
+ }
@@ -0,0 +1,25 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/tsconfig.json') })
3
+ }}}
4
+ {
5
+ "compilerOptions": {
6
+ "target": "ESNext",
7
+ "jsx": "react-jsx",
8
+ "lib": ["DOM", "ESNext", "DOM.Iterable", "ES2020"],
9
+ "useDefineForClassFields": true,
10
+ "baseUrl": ".",
11
+ "module": "ESNext",
12
+ "moduleResolution": "Bundler",
13
+ "paths": {
14
+ "@/*": ["./*"],
15
+ "~/*": ["../*"],
16
+ },
17
+ "resolveJsonModule": true,
18
+ "types": ["vite/client"],
19
+ "allowSyntheticDefaultImports": true,
20
+ "esModuleInterop": true,
21
+ "verbatimModuleSyntax": true,
22
+ "skipLibCheck": true,
23
+ },
24
+ "include": ["./**/*.ts", "./**/*.tsx"],
25
+ }
@@ -0,0 +1,24 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/app.tsx') })
3
+ }}}
4
+ import './css/app.css'
5
+
6
+ import { render } from 'solid-js/web'
7
+ import { createInertiaApp } from 'inertia-adapter-solid'
8
+
9
+ const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS'
10
+
11
+ createInertiaApp({
12
+ progress: { color: '#5468FF' },
13
+
14
+ title: (title) => {{ '`${title} - ${appName}`' }},
15
+
16
+ resolve(name) {
17
+ const pages = import.meta.glob('./pages/**/*.tsx', { eager: true })
18
+ {{ 'return pages[`./pages/${name}.tsx`]' }}
19
+ },
20
+
21
+ setup({ el, App, props }) {
22
+ render(() => <App {...props} />, el)
23
+ },
24
+ })
@@ -0,0 +1,21 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/pages/home.tsx') })
3
+ }}}
4
+ import { Title } from '@solidjs/meta'
5
+
6
+ export default function Home(props: { version: number }) {
7
+ return (
8
+ <>
9
+ <Title>Homepage</Title>
10
+
11
+ <div class="container">
12
+ <div class="title">AdonisJS {props.version} x Inertia x Solid.js</div>
13
+
14
+ <span>
15
+ Learn more about AdonisJS and Inertia.js by visiting the{' '}
16
+ <a href="https://docs.adonisjs.com/inertia">AdonisJS documentation</a>.
17
+ </span>
18
+ </div>
19
+ </>
20
+ )
21
+ }
@@ -0,0 +1,21 @@
1
+ {{{
2
+ exports({ to: app.makePath('resources/views/root.edge') })
3
+ }}}
4
+ <!DOCTYPE html>
5
+ <html>
6
+
7
+ <head>
8
+ <meta charset="utf-8">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+
11
+ <title inertia>AdonisJS x Inertia x SolidJS</title>
12
+
13
+ @vite(['resources/app.tsx'])
14
+ @inertiaHead()
15
+ </head>
16
+
17
+ <body>
18
+ @inertia()
19
+ </body>
20
+
21
+ </html>