@adonisjs/inertia 4.0.0-next.15 → 4.0.0-next.17
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/factories/main.js +1 -1
- package/build/index.js +1 -1
- package/build/{inertia_manager-Di3J3hSG.js → inertia_manager-DnlZGgE1.js} +2 -2
- package/build/providers/inertia_provider.js +1 -1
- package/build/src/client/react/context.d.ts +1 -1
- package/build/src/client/react/form.d.ts +75 -0
- package/build/src/client/react/index.d.ts +1 -0
- package/build/src/client/react/index.js +27 -5
- package/build/src/client/react/link.d.ts +1 -1
- package/build/src/inertia_middleware.js +1 -1
- package/build/tsdown.config.d.ts +2 -0
- package/package.json +4 -27
package/build/factories/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ServerRenderer, r as Inertia } from "../inertia_manager-
|
|
1
|
+
import { n as ServerRenderer, r as Inertia } from "../inertia_manager-DnlZGgE1.js";
|
|
2
2
|
import { t as InertiaHeaders } from "../headers-DafWEpBh.js";
|
|
3
3
|
import "../debug-CBMTuPUm.js";
|
|
4
4
|
import { t as defineConfig } from "../inertia-CrPBlGRS.js";
|
package/build/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as symbols_exports, n as ServerRenderer, r as Inertia, t as InertiaManager } from "./inertia_manager-
|
|
1
|
+
import { i as symbols_exports, n as ServerRenderer, r as Inertia, t as InertiaManager } from "./inertia_manager-DnlZGgE1.js";
|
|
2
2
|
import { t as InertiaHeaders } from "./headers-DafWEpBh.js";
|
|
3
3
|
import "./debug-CBMTuPUm.js";
|
|
4
4
|
import { n as indexPages, t as defineConfig } from "./inertia-CrPBlGRS.js";
|
|
@@ -5,7 +5,7 @@ import { createHash } from "node:crypto";
|
|
|
5
5
|
import { serialize } from "@adonisjs/core/transformers";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
|
-
var
|
|
8
|
+
var __exportAll = (all, symbols) => {
|
|
9
9
|
let target = {};
|
|
10
10
|
for (var name in all) __defProp(target, name, {
|
|
11
11
|
get: all[name],
|
|
@@ -14,7 +14,7 @@ var __export = (all, symbols) => {
|
|
|
14
14
|
if (symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
15
|
return target;
|
|
16
16
|
};
|
|
17
|
-
var symbols_exports = /* @__PURE__ */
|
|
17
|
+
var symbols_exports = /* @__PURE__ */ __exportAll({
|
|
18
18
|
ALWAYS_PROP: () => ALWAYS_PROP,
|
|
19
19
|
DEEP_MERGE: () => DEEP_MERGE,
|
|
20
20
|
DEFERRED_PROP: () => DEFERRED_PROP,
|
|
@@ -11,7 +11,7 @@ import type { TuyauRegistry } from '@tuyau/core/types';
|
|
|
11
11
|
export declare function TuyauProvider<R extends TuyauRegistry>(props: {
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
client: Tuyau<R>;
|
|
14
|
-
}):
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
/**
|
|
16
16
|
* Hook to access the Tuyau client from any component within a TuyauProvider.
|
|
17
17
|
*
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { UserRegistry, InferRoutes } from '@tuyau/core/types';
|
|
3
|
+
import { AreAllOptional } from '@poppinss/utils/types';
|
|
4
|
+
import { Form as InertiaForm } from '@inertiajs/react';
|
|
5
|
+
type Routes = InferRoutes<UserRegistry>;
|
|
6
|
+
/**
|
|
7
|
+
* Get parameter tuple type for a route
|
|
8
|
+
*/
|
|
9
|
+
type ExtractParamsTuple<Route extends keyof Routes> = Routes[Route]['types']['paramsTuple'];
|
|
10
|
+
/**
|
|
11
|
+
* Get parameter object type for a route
|
|
12
|
+
*/
|
|
13
|
+
type ExtractParamsObject<Route extends keyof Routes> = Routes[Route]['types']['params'];
|
|
14
|
+
/**
|
|
15
|
+
* Get params format for a route
|
|
16
|
+
*/
|
|
17
|
+
type RouteParamsFormats<Route extends keyof Routes> = ExtractParamsObject<Route> extends Record<string, never> ? never : ExtractParamsTuple<Route> | ExtractParamsObject<Route>;
|
|
18
|
+
/**
|
|
19
|
+
* Parameters required for route navigation with proper type safety.
|
|
20
|
+
*/
|
|
21
|
+
export type FormParams<Route extends keyof Routes> = {
|
|
22
|
+
route: Route;
|
|
23
|
+
} & (RouteParamsFormats<Route> extends never ? {
|
|
24
|
+
params?: never;
|
|
25
|
+
} : AreAllOptional<ExtractParamsObject<Route>> extends true ? {
|
|
26
|
+
params?: RouteParamsFormats<Route>;
|
|
27
|
+
} : {
|
|
28
|
+
params: RouteParamsFormats<Route>;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Props for the Form component extending InertiaForm props
|
|
32
|
+
* with route-specific type safety and parameter validation.
|
|
33
|
+
*/
|
|
34
|
+
type FormProps<Route extends keyof Routes> = Omit<React.ComponentPropsWithoutRef<typeof InertiaForm>, 'action' | 'method'> & FormParams<Route>;
|
|
35
|
+
/**
|
|
36
|
+
* Internal Form component implementation with forward ref support.
|
|
37
|
+
* Resolves route parameters and generates the appropriate URL and HTTP method
|
|
38
|
+
* for Inertia form submission.
|
|
39
|
+
*/
|
|
40
|
+
declare function FormInner<Route extends keyof Routes>(props: FormProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaForm>>): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
/**
|
|
42
|
+
* Type-safe Form component for Inertia.js form submissions.
|
|
43
|
+
*
|
|
44
|
+
* Provides compile-time route validation and automatic parameter type checking
|
|
45
|
+
* based on your application's route definitions. Automatically resolves the
|
|
46
|
+
* correct URL and HTTP method for each route.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* // Form to a route without parameters
|
|
51
|
+
* <Form route="users.store">
|
|
52
|
+
* {({ processing }) => (
|
|
53
|
+
* <>
|
|
54
|
+
* <input type="text" name="name" />
|
|
55
|
+
* <button type="submit" disabled={processing}>Create</button>
|
|
56
|
+
* </>
|
|
57
|
+
* )}
|
|
58
|
+
* </Form>
|
|
59
|
+
*
|
|
60
|
+
* // Form to a route with required parameters
|
|
61
|
+
* <Form route="users.update" params={{ id: 1 }}>
|
|
62
|
+
* {({ errors }) => (
|
|
63
|
+
* <>
|
|
64
|
+
* <input type="text" name="name" />
|
|
65
|
+
* {errors.name && <div>{errors.name}</div>}
|
|
66
|
+
* <button type="submit">Update</button>
|
|
67
|
+
* </>
|
|
68
|
+
* )}
|
|
69
|
+
* </Form>
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const Form: <Route extends keyof Routes>(props: FormProps<Route> & {
|
|
73
|
+
ref?: React.Ref<React.ElementRef<typeof InertiaForm>>;
|
|
74
|
+
}) => ReturnType<typeof FormInner>;
|
|
75
|
+
export {};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Form as Form$1, Link as Link$1, router } from "@inertiajs/react";
|
|
3
4
|
const TuyauContext = React.createContext(null);
|
|
4
5
|
function TuyauProvider(props) {
|
|
5
|
-
return
|
|
6
|
+
return /* @__PURE__ */ jsx(TuyauContext.Provider, {
|
|
7
|
+
value: props.client,
|
|
8
|
+
children: props.children
|
|
9
|
+
});
|
|
6
10
|
}
|
|
7
11
|
function useTuyau() {
|
|
8
12
|
const context = React.useContext(TuyauContext);
|
|
@@ -21,9 +25,27 @@ function useRouter() {
|
|
|
21
25
|
} };
|
|
22
26
|
}
|
|
23
27
|
function LinkInner(props, ref) {
|
|
24
|
-
const { route, params, ...linkProps } = props;
|
|
28
|
+
const { route: _route, params, ...linkProps } = props;
|
|
25
29
|
const routeInfo = useTuyau().getRoute(props.route, { params });
|
|
26
|
-
return
|
|
30
|
+
return /* @__PURE__ */ jsx(Link$1, {
|
|
31
|
+
...linkProps,
|
|
32
|
+
href: routeInfo.url,
|
|
33
|
+
method: routeInfo.methods[0].toLowerCase(),
|
|
34
|
+
ref
|
|
35
|
+
});
|
|
27
36
|
}
|
|
28
37
|
const Link = React.forwardRef(LinkInner);
|
|
29
|
-
|
|
38
|
+
function FormInner(props, ref) {
|
|
39
|
+
const { route: _route, params, ...formProps } = props;
|
|
40
|
+
const routeInfo = useTuyau().getRoute(props.route, { params });
|
|
41
|
+
return /* @__PURE__ */ jsx(Form$1, {
|
|
42
|
+
...formProps,
|
|
43
|
+
action: {
|
|
44
|
+
url: routeInfo.url,
|
|
45
|
+
method: routeInfo.methods[0].toLowerCase()
|
|
46
|
+
},
|
|
47
|
+
ref
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const Form = React.forwardRef(FormInner);
|
|
51
|
+
export { Form, Link, TuyauProvider, useRouter, useTuyau };
|
|
@@ -40,7 +40,7 @@ type LinkProps<Route extends keyof Routes> = Omit<React.ComponentPropsWithoutRef
|
|
|
40
40
|
* @param props - Link properties including route and parameters
|
|
41
41
|
* @param ref - Forward ref for the underlying InertiaLink component
|
|
42
42
|
*/
|
|
43
|
-
declare function LinkInner<Route extends keyof Routes>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>):
|
|
43
|
+
declare function LinkInner<Route extends keyof Routes>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>): import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
/**
|
|
45
45
|
* Type-safe Link component for Inertia.js navigation.
|
|
46
46
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as InertiaManager } from "../inertia_manager-
|
|
1
|
+
import { t as InertiaManager } from "../inertia_manager-DnlZGgE1.js";
|
|
2
2
|
import { t as InertiaHeaders } from "../headers-DafWEpBh.js";
|
|
3
3
|
import { t as debug_default } from "../debug-CBMTuPUm.js";
|
|
4
4
|
const MUTATION_METHODS = [
|
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.
|
|
4
|
+
"version": "4.0.0-next.17",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@adonisjs/assembler": "^8.0.0-next.27",
|
|
47
47
|
"@adonisjs/core": "^7.0.0-next.16",
|
|
48
|
-
"@adonisjs/eslint-config": "^3.0.0-next.
|
|
48
|
+
"@adonisjs/eslint-config": "^3.0.0-next.6",
|
|
49
49
|
"@adonisjs/prettier-config": "^1.4.5",
|
|
50
50
|
"@adonisjs/session": "^8.0.0-next.1",
|
|
51
51
|
"@adonisjs/tsconfig": "^2.0.0-next.3",
|
|
52
|
-
"@adonisjs/vite": "^5.1.0-next.
|
|
52
|
+
"@adonisjs/vite": "^5.1.0-next.2",
|
|
53
53
|
"@inertiajs/react": "^2.3.4",
|
|
54
54
|
"@japa/api-client": "^3.1.1",
|
|
55
55
|
"@japa/assert": "4.2.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@japa/snapshot": "^2.0.10",
|
|
61
61
|
"@poppinss/ts-exec": "^1.4.1",
|
|
62
62
|
"@release-it/conventional-changelog": "^10.0.4",
|
|
63
|
-
"@tuyau/core": "^1.0.0-beta.
|
|
63
|
+
"@tuyau/core": "^1.0.0-beta.9",
|
|
64
64
|
"@types/node": "^25.0.3",
|
|
65
65
|
"@types/react": "^19.2.7",
|
|
66
66
|
"@types/supertest": "^6.0.3",
|
|
@@ -160,29 +160,6 @@
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
|
-
"tsdown": {
|
|
164
|
-
"entry": [
|
|
165
|
-
"./index.ts",
|
|
166
|
-
"./src/types.ts",
|
|
167
|
-
"./src/client/vite.ts",
|
|
168
|
-
"./src/client/helpers.ts",
|
|
169
|
-
"./factories/main.ts",
|
|
170
|
-
"./src/inertia_middleware.ts",
|
|
171
|
-
"./providers/inertia_provider.ts",
|
|
172
|
-
"./src/plugins/edge/plugin.ts",
|
|
173
|
-
"./src/plugins/japa/api_client.ts",
|
|
174
|
-
"./src/client/react/index.tsx"
|
|
175
|
-
],
|
|
176
|
-
"outDir": "./build",
|
|
177
|
-
"clean": true,
|
|
178
|
-
"format": "esm",
|
|
179
|
-
"minify": "dce-only",
|
|
180
|
-
"fixedExtension": false,
|
|
181
|
-
"dts": false,
|
|
182
|
-
"treeshake": false,
|
|
183
|
-
"sourcemaps": false,
|
|
184
|
-
"target": "esnext"
|
|
185
|
-
},
|
|
186
163
|
"c8": {
|
|
187
164
|
"reporter": [
|
|
188
165
|
"text",
|