@adonisjs/inertia 1.0.0-4 → 1.0.0-5

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
@@ -8,11 +8,9 @@ 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
 
18
- export { configure, defineConfig, stubsRoot };
16
+ export { configure, defineConfig };
package/build/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ // stubs/main.ts
2
+ import { getDirname } from "@poppinss/utils";
3
+ var stubsRoot = getDirname(import.meta.url);
4
+
1
5
  // configure.ts
2
6
  var ADAPTERS = ["Vue 3", "React", "Svelte"];
3
7
  var ADAPTERS_INFO = {
@@ -43,28 +47,24 @@ async function configure(command) {
43
47
  await codemods.updateRcFile((rcFile) => {
44
48
  rcFile.addProvider("@adonisjs/inertia/inertia_provider");
45
49
  });
46
- codemods.registerMiddleware("router", [
50
+ await codemods.registerMiddleware("router", [
47
51
  { path: "@adonisjs/inertia/inertia_middleware", position: "after" }
48
52
  ]);
49
- await command.publishStub("config.stub");
53
+ await codemods.makeUsingStub(stubsRoot, "config.stub", {});
50
54
  const shouldInstallPackages = await command.prompt.confirm(
51
55
  `Do you want to install dependencies ${pkgToInstall.map((pkg) => pkg.name).join(", ")}?`,
52
56
  { name: "install" }
53
57
  );
54
58
  if (shouldInstallPackages) {
55
- command.installPackages(pkgToInstall);
59
+ await codemods.installPackages(pkgToInstall);
56
60
  } else {
57
- command.listPackagesToInstall(pkgToInstall);
61
+ await codemods.listPackagesToInstall(pkgToInstall);
58
62
  }
59
63
  command.logger.success(
60
64
  "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
65
  );
62
66
  }
63
67
 
64
- // stubs/main.ts
65
- import { getDirname } from "@poppinss/utils";
66
- var stubsRoot = getDirname(import.meta.url);
67
-
68
68
  // src/define_config.ts
69
69
  import { configProvider } from "@adonisjs/core";
70
70
 
@@ -130,6 +130,5 @@ function defineConfig(config) {
130
130
  }
131
131
  export {
132
132
  configure,
133
- defineConfig,
134
- stubsRoot
133
+ defineConfig
135
134
  };
@@ -13,25 +13,26 @@ var InertiaProvider = class {
13
13
  * Registers edge plugin when edge is installed
14
14
  */
15
15
  async registerEdgePlugin() {
16
- try {
17
- const edgeExports = await import("edge.js");
18
- const { edgePluginInertia } = await import("../src/plugins/edge/plugin.js");
19
- edgeExports.default.use(edgePluginInertia());
20
- } catch {
21
- }
16
+ if (!this.app.usingEdgeJS)
17
+ return;
18
+ const edgeExports = await import("edge.js");
19
+ const { edgePluginInertia } = await import("../src/plugins/edge/plugin.js");
20
+ edgeExports.default.use(edgePluginInertia());
22
21
  }
23
22
  /**
24
23
  * Register Inertia bindings
25
24
  */
26
25
  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));
26
+ this.app.container.singleton(InertiaMiddleware, async () => {
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
+ return new InertiaMiddleware(config);
35
+ });
35
36
  await this.registerEdgePlugin();
36
37
  }
37
38
  };
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",
4
+ "version": "1.0.0-5",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
@@ -36,49 +36,49 @@
36
36
  "prepublishOnly": "npm run build"
37
37
  },
38
38
  "devDependencies": {
39
- "@adonisjs/assembler": "6.1.3-25",
40
- "@adonisjs/core": "6.1.5-31",
41
- "@adonisjs/eslint-config": "^1.1.8",
42
- "@adonisjs/prettier-config": "^1.1.8",
43
- "@adonisjs/session": "7.0.0-13",
44
- "@adonisjs/tsconfig": "^1.1.8",
45
- "@japa/api-client": "^2.0.1",
46
- "@japa/assert": "2.0.1",
47
- "@japa/expect-type": "^2.0.0",
48
- "@japa/file-system": "^2.0.1",
49
- "@japa/plugin-adonisjs": "^2.0.1",
50
- "@japa/runner": "3.0.5",
51
- "@swc/core": "^1.3.96",
52
- "@types/node": "^20.9.0",
53
- "@types/qs": "^6.9.10",
39
+ "@adonisjs/assembler": "7.0.0-1",
40
+ "@adonisjs/core": "6.1.5-38",
41
+ "@adonisjs/eslint-config": "^1.2.1",
42
+ "@adonisjs/prettier-config": "^1.2.1",
43
+ "@adonisjs/session": "7.0.0-15",
44
+ "@adonisjs/tsconfig": "^1.2.1",
45
+ "@japa/api-client": "^2.0.2",
46
+ "@japa/assert": "2.1.0",
47
+ "@japa/expect-type": "^2.0.1",
48
+ "@japa/file-system": "^2.1.1",
49
+ "@japa/plugin-adonisjs": "^2.0.2",
50
+ "@japa/runner": "3.1.1",
51
+ "@swc/core": "^1.3.101",
52
+ "@types/node": "^20.10.6",
53
+ "@types/qs": "^6.9.11",
54
54
  "@types/supertest": "^2.0.16",
55
55
  "c8": "^8.0.1",
56
56
  "copyfiles": "^2.4.1",
57
57
  "del-cli": "^5.1.0",
58
58
  "edge-parser": "^9.0.0",
59
59
  "edge.js": "^6.0.0",
60
- "eslint": "^8.53.0",
60
+ "eslint": "^8.56.0",
61
61
  "get-port": "^7.0.0",
62
- "np": "^8.0.4",
63
- "prettier": "^3.0.3",
62
+ "np": "^9.2.0",
63
+ "prettier": "^3.1.1",
64
64
  "supertest": "^6.3.3",
65
65
  "tinybench": "^2.5.1",
66
- "ts-node": "^10.9.1",
67
- "tsup": "^7.3.0",
66
+ "ts-node": "^10.9.2",
67
+ "tsup": "^8.0.1",
68
68
  "typescript": "~5.2.2"
69
69
  },
70
70
  "dependencies": {
71
- "@poppinss/utils": "^6.5.1",
71
+ "@poppinss/utils": "^6.7.0",
72
72
  "crc-32": "^1.2.2",
73
73
  "edge-error": "^4.0.0",
74
74
  "html-entities": "^2.4.0",
75
75
  "qs": "^6.11.2"
76
76
  },
77
77
  "peerDependencies": {
78
- "@adonisjs/assembler": "6.1.3-25",
79
- "@adonisjs/core": "6.1.5-31",
80
- "@adonisjs/session": "7.0.0-13",
81
- "@japa/api-client": "^2.0.1",
78
+ "@adonisjs/assembler": "7.0.0-1",
79
+ "@adonisjs/core": "6.1.5-38",
80
+ "@adonisjs/session": "7.0.0-15",
81
+ "@japa/api-client": "^2.0.0",
82
82
  "edge.js": "^6.0.0"
83
83
  },
84
84
  "peerDependenciesMeta": {