@adonisjs/inertia 4.0.0-next.1 → 4.0.0-next.2

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.
@@ -4,11 +4,11 @@ import {
4
4
  import {
5
5
  Inertia,
6
6
  ServerRenderer
7
- } from "../chunk-74S2VAL7.js";
7
+ } from "../chunk-GO6QSFRS.js";
8
+ import "../chunk-4EZ2J6OA.js";
8
9
  import {
9
10
  InertiaHeaders
10
11
  } from "../chunk-DISC5OYC.js";
11
- import "../chunk-4EZ2J6OA.js";
12
12
  import "../chunk-MLKGABMK.js";
13
13
 
14
14
  // factories/inertia_factory.ts
package/build/index.js CHANGED
@@ -7,11 +7,11 @@ import {
7
7
  InertiaManager,
8
8
  ServerRenderer,
9
9
  symbols_exports
10
- } from "./chunk-74S2VAL7.js";
10
+ } from "./chunk-GO6QSFRS.js";
11
+ import "./chunk-4EZ2J6OA.js";
11
12
  import {
12
13
  InertiaHeaders
13
14
  } from "./chunk-DISC5OYC.js";
14
- import "./chunk-4EZ2J6OA.js";
15
15
  import "./chunk-MLKGABMK.js";
16
16
  export {
17
17
  Inertia,
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  InertiaManager
3
- } from "../chunk-74S2VAL7.js";
4
- import "../chunk-DISC5OYC.js";
3
+ } from "../chunk-GO6QSFRS.js";
5
4
  import "../chunk-4EZ2J6OA.js";
5
+ import "../chunk-DISC5OYC.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
 
8
8
  // providers/inertia_provider.ts
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Resolves a page component from a given path or array of paths by looking up
3
+ * the component in the provided pages registry. Supports both direct promises
4
+ * and lazy-loaded functions that return promises.
5
+ *
6
+ * @param path - The page path(s) to resolve. Can be a single string or array of strings
7
+ * @param pages - Registry of page components where keys are paths and values are either promises or functions returning promises
8
+ *
9
+ * @example
10
+ * ```js
11
+ * // Single path resolution
12
+ * const component = await resolvePageComponent('Home', {
13
+ * 'Home': () => import('./pages/Home.vue'),
14
+ * 'About': () => import('./pages/About.vue')
15
+ * })
16
+ *
17
+ * // Multiple path resolution (fallback)
18
+ * const component = await resolvePageComponent(['Dashboard/Admin', 'Dashboard'], {
19
+ * 'Dashboard': () => import('./pages/Dashboard.vue')
20
+ * })
21
+ * ```
22
+ *
23
+ * @throws {Error} When none of the provided paths can be resolved in the pages registry
24
+ */
25
+ export declare function resolvePageComponent<T>(path: string | string[], pages: Record<string, Promise<T> | (() => Promise<T>)>): Promise<T>;
@@ -0,0 +1,16 @@
1
+ import "../../chunk-MLKGABMK.js";
2
+
3
+ // src/client/helpers.ts
4
+ async function resolvePageComponent(path, pages) {
5
+ for (const p of Array.isArray(path) ? path : [path]) {
6
+ const page = pages[p];
7
+ if (typeof page === "undefined") {
8
+ continue;
9
+ }
10
+ return typeof page === "function" ? page() : page;
11
+ }
12
+ throw new Error(`Page not found: ${path}`);
13
+ }
14
+ export {
15
+ resolvePageComponent
16
+ };
@@ -52,7 +52,7 @@ export type InertiaPluginOptions = {
52
52
  * inertia({
53
53
  * ssr: {
54
54
  * enabled: true,
55
- * entrypoint: 'inertia/app/ssr.ts',
55
+ * entrypoint: 'inertia/ssr.tsx',
56
56
  * output: 'build/ssr'
57
57
  * }
58
58
  * })
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  InertiaManager
3
- } from "../chunk-74S2VAL7.js";
4
- import {
5
- InertiaHeaders
6
- } from "../chunk-DISC5OYC.js";
3
+ } from "../chunk-GO6QSFRS.js";
7
4
  import {
8
5
  debug_default
9
6
  } from "../chunk-4EZ2J6OA.js";
7
+ import {
8
+ InertiaHeaders
9
+ } from "../chunk-DISC5OYC.js";
10
10
  import "../chunk-MLKGABMK.js";
11
11
 
12
12
  // src/inertia_middleware.ts
@@ -33,7 +33,7 @@ var BaseInertiaMiddleware = class {
33
33
  if (!ctx.session) {
34
34
  return {};
35
35
  }
36
- const inputErrors = ctx.session.flashMessages.get("inputErrorsBag");
36
+ const inputErrors = ctx.session.flashMessages.get("inputErrorsBag", {});
37
37
  const errors = Object.entries(inputErrors).reduce(
38
38
  (result, [field, messages]) => {
39
39
  result[field] = Array.isArray(messages) ? messages[0] : messages;
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.1",
4
+ "version": "4.0.0-next.2",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -18,6 +18,7 @@
18
18
  "./plugins/edge": "./build/src/plugins/edge/plugin.js",
19
19
  "./plugins/api_client": "./build/src/plugins/japa/api_client.js",
20
20
  "./vite": "./build/src/client/vite.js",
21
+ "./helpers": "./build/src/client/helpers.js",
21
22
  "./factories": "./build/factories/main.js"
22
23
  },
23
24
  "scripts": {
@@ -132,8 +133,7 @@
132
133
  },
133
134
  "npm": {
134
135
  "publish": true,
135
- "skipChecks": true,
136
- "tag": "latest"
136
+ "skipChecks": true
137
137
  },
138
138
  "plugins": {
139
139
  "@release-it/conventional-changelog": {
@@ -148,6 +148,7 @@
148
148
  "./index.ts",
149
149
  "./src/types.ts",
150
150
  "./src/client/vite.ts",
151
+ "./src/client/helpers.ts",
151
152
  "./factories/main.ts",
152
153
  "./src/inertia_middleware.ts",
153
154
  "./providers/inertia_provider.ts",
@@ -1,9 +1,9 @@
1
- import {
2
- InertiaHeaders
3
- } from "./chunk-DISC5OYC.js";
4
1
  import {
5
2
  debug_default
6
3
  } from "./chunk-4EZ2J6OA.js";
4
+ import {
5
+ InertiaHeaders
6
+ } from "./chunk-DISC5OYC.js";
7
7
  import {
8
8
  __export
9
9
  } from "./chunk-MLKGABMK.js";