@adonisjs/inertia 1.0.0-10 → 1.0.0-12

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.
@@ -85,7 +85,7 @@ var Inertia = class {
85
85
  const result = await render.default(pageObject);
86
86
  return this.ctx.view.render(this.config.rootView, {
87
87
  ...viewProps,
88
- page: { ssrHead: result.head, ssrBody: result.body }
88
+ page: { ssrHead: result.head, ssrBody: result.body, ...pageObject }
89
89
  });
90
90
  }
91
91
  /**
package/build/index.js CHANGED
@@ -1,11 +1,14 @@
1
+ // configure.ts
2
+ import string from "@poppinss/utils/string";
3
+
1
4
  // stubs/main.ts
2
5
  import { getDirname } from "@poppinss/utils";
3
6
  var stubsRoot = getDirname(import.meta.url);
4
7
 
5
8
  // configure.ts
6
- var ADAPTERS = ["Vue 3", "React", "Svelte", "Solid"];
9
+ var ADAPTERS = ["vue", "react", "svelte", "solid"];
7
10
  var ADAPTERS_INFO = {
8
- "Vue 3": {
11
+ vue: {
9
12
  stubFolder: "vue",
10
13
  appExtension: "ts",
11
14
  componentsExtension: "vue",
@@ -21,7 +24,7 @@ var ADAPTERS_INFO = {
21
24
  },
22
25
  ssrEntrypoint: "resources/ssr.ts"
23
26
  },
24
- "React": {
27
+ react: {
25
28
  stubFolder: "react",
26
29
  appExtension: "tsx",
27
30
  componentsExtension: "tsx",
@@ -39,7 +42,7 @@ var ADAPTERS_INFO = {
39
42
  },
40
43
  ssrEntrypoint: "resources/ssr.tsx"
41
44
  },
42
- "Svelte": {
45
+ svelte: {
43
46
  stubFolder: "svelte",
44
47
  appExtension: "ts",
45
48
  componentsExtension: "svelte",
@@ -56,7 +59,7 @@ var ADAPTERS_INFO = {
56
59
  },
57
60
  ssrEntrypoint: "resources/ssr.ts"
58
61
  },
59
- "Solid": {
62
+ solid: {
60
63
  stubFolder: "solid",
61
64
  appExtension: "tsx",
62
65
  componentsExtension: "tsx",
@@ -98,14 +101,30 @@ async function defineExampleRoute(command, codemods) {
98
101
  }
99
102
  }
100
103
  async function configure(command) {
101
- const adapter = await command.prompt.choice(
102
- "Select the Inertia adapter you want to use",
103
- ADAPTERS,
104
- { name: "adapter" }
105
- );
106
- const ssr = await command.prompt.confirm("Do you want to use server-side rendering?", {
107
- name: "ssr"
108
- });
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
+ });
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
+ }
109
128
  const adapterInfo = ADAPTERS_INFO[adapter];
110
129
  const codemods = await command.createCodemods();
111
130
  await codemods.updateRcFile((rcFile) => {
@@ -142,17 +161,17 @@ async function configure(command) {
142
161
  if (ssr && adapterInfo.ssrDependencies) {
143
162
  pkgToInstall.push(...adapterInfo.ssrDependencies);
144
163
  }
145
- const shouldInstallPackages = await command.prompt.confirm(
146
- `Do you want to install dependencies ${pkgToInstall.map((pkg) => pkg.name).join(", ")}?`,
147
- { name: "install" }
148
- );
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
+ }
149
170
  if (shouldInstallPackages) {
150
171
  await codemods.installPackages(pkgToInstall);
151
172
  } else {
152
173
  await codemods.listPackagesToInstall(pkgToInstall);
153
174
  }
154
- const colors = command.colors;
155
- command.ui.instructions().heading("Inertia was successfully configured !").add(`We have added a dummy ${colors.cyan("/inertia")} route in your project.`).add(`Try visiting it in your browser after starting your server to see Inertia in action`).add("Happy coding !").render();
156
175
  }
157
176
 
158
177
  // src/define_config.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InertiaMiddleware
3
- } from "../chunk-CXICUKHN.js";
3
+ } from "../chunk-RTJXBXWZ.js";
4
4
 
5
5
  // providers/inertia_provider.ts
6
6
  import { configProvider } from "@adonisjs/core";
@@ -2,7 +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 { ViteRuntime } from 'vite/runtime';
5
- import { ResolvedConfig, Data, PageProps, MaybePromise } from './types.js';
5
+ import { ResolvedConfig, Data, PageProps, PageObject, MaybePromise } from './types.js';
6
6
 
7
7
  /**
8
8
  * Symbol used to identify lazy props
@@ -25,12 +25,7 @@ declare class Inertia {
25
25
  /**
26
26
  * Render a page using Inertia
27
27
  */
28
- render<TPageProps extends Record<string, any> = PageProps, TViewProps extends Record<string, any> = PageProps>(component: string, pageProps?: TPageProps, viewProps?: TViewProps): Promise<string | {
29
- component: string;
30
- version: string | number;
31
- props: any;
32
- url: string;
33
- }>;
28
+ render<TPageProps extends Record<string, any> = PageProps, TViewProps extends Record<string, any> = PageProps>(component: string, pageProps?: TPageProps, viewProps?: TViewProps): Promise<string | PageObject>;
34
29
  /**
35
30
  * Create a lazy prop
36
31
  *
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InertiaMiddleware
3
- } from "../chunk-CXICUKHN.js";
3
+ } from "../chunk-RTJXBXWZ.js";
4
4
  export {
5
5
  InertiaMiddleware as default
6
6
  };
@@ -92,5 +92,13 @@ interface ResolvedConfig {
92
92
  bundle: string;
93
93
  };
94
94
  }
95
+ interface PageObject {
96
+ component: string;
97
+ version: string | number;
98
+ props: PageProps;
99
+ url: string;
100
+ ssrHead?: string;
101
+ ssrBody?: string;
102
+ }
95
103
 
96
- export type { AssetsVersion, Data, InertiaConfig, MaybePromise, PageProps, ResolvedConfig, SharedData, SharedDatumFactory };
104
+ export type { AssetsVersion, Data, InertiaConfig, 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-10",
4
+ "version": "1.0.0-12",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
@@ -44,7 +44,7 @@
44
44
  "@adonisjs/prettier-config": "^1.2.2",
45
45
  "@adonisjs/session": "7.1.1",
46
46
  "@adonisjs/tsconfig": "^1.2.2",
47
- "@adonisjs/vite": "^3.0.0-2",
47
+ "@adonisjs/vite": "^3.0.0-4",
48
48
  "@japa/api-client": "^2.0.2",
49
49
  "@japa/assert": "2.1.0",
50
50
  "@japa/expect-type": "^2.0.1",
@@ -83,7 +83,7 @@
83
83
  "peerDependencies": {
84
84
  "@adonisjs/core": "^6.2.0",
85
85
  "@adonisjs/session": "^7.0.0",
86
- "@adonisjs/vite": "^3.0.0-2",
86
+ "@adonisjs/vite": "^3.0.0-4",
87
87
  "@japa/api-client": "^2.0.0",
88
88
  "edge.js": "^6.0.0"
89
89
  },