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

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.
@@ -8,16 +8,18 @@ var TYPES_EXTRACTION_HELPER = {
8
8
  vue3: `import type { VNodeProps, AllowedComponentProps, ComponentInstance } from 'vue'
9
9
 
10
10
  type ExtractProps<T> = Omit<
11
- ComponentInstance<T>['$props'][K],
11
+ ComponentInstance<T>['$props'],
12
12
  keyof VNodeProps | keyof AllowedComponentProps
13
13
  >`,
14
14
  react: `import type React from 'react'
15
+ import type { Prettify } from '@adonisjs/core/types/common'
15
16
 
16
- type ExtractProps<T> = T extends React.FC<infer Props>
17
- ? Props
18
- : T extends React.Component<infer Props>
19
- ? Props
20
- : never`
17
+ type ExtractProps<T> =
18
+ T extends React.FC<infer Props>
19
+ ? Prettify<Omit<Props, 'children'>>
20
+ : T extends React.Component<infer Props>
21
+ ? Prettify<Omit<Props, 'children'>>
22
+ : never`
21
23
  };
22
24
  var indexPages = function(config) {
23
25
  if (!SUPPORTED_FRAMEWORKS.includes(config.framework)) {
@@ -26,14 +28,29 @@ var indexPages = function(config) {
26
28
  );
27
29
  }
28
30
  return {
31
+ /**
32
+ * Executes the page indexing process to generate TypeScript definitions.
33
+ *
34
+ * @param _ - Unused first parameter (assembler context)
35
+ * @param indexGenerator - The index generator instance used to register the pages type generation
36
+ */
29
37
  run(_, indexGenerator) {
30
38
  indexGenerator.add("inertiaPages", {
31
39
  source: "inertia/pages",
32
40
  glob: GLOB[config.framework],
33
41
  output: ".adonisjs/server/pages.d.ts",
42
+ /**
43
+ * Generates the TypeScript module declaration for Inertia pages.
44
+ *
45
+ * @param vfs - Virtual file system containing the scanned page files
46
+ * @param buffer - Buffer instance for writing the generated TypeScript code
47
+ * @param __ - Unused third parameter
48
+ * @param helpers - Helper utilities for path manipulation and imports
49
+ */
34
50
  as(vfs, buffer, __, helpers) {
35
51
  const filesList = vfs.asList();
36
- buffer.write(TYPES_EXTRACTION_HELPER[config.framework]);
52
+ buffer.writeLine(`import '@adonisjs/inertia/types'`);
53
+ buffer.writeLine(TYPES_EXTRACTION_HELPER[config.framework]);
37
54
  buffer.write(`declare module '@adonisjs/inertia/types' {`).indent();
38
55
  buffer.write(`export interface InertiaPages {`).indent();
39
56
  Object.keys(filesList).forEach((key) => {
@@ -55,14 +72,13 @@ function defineConfig(config) {
55
72
  return lodash.merge(
56
73
  {
57
74
  rootView: "inertia_layout",
58
- entrypoint: "inertia/app/app.ts",
59
75
  history: {
60
76
  encrypt: false
61
77
  },
62
78
  ssr: {
63
79
  enabled: false,
64
80
  bundle: "ssr/ssr.js",
65
- entrypoint: "inertia/app/ssr.ts"
81
+ entrypoint: "inertia/ssr.tsx"
66
82
  }
67
83
  },
68
84
  config
@@ -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";
@@ -79,10 +79,10 @@ function isAlwaysProp(propValue) {
79
79
  function isOptionalProp(propValue) {
80
80
  return OPTIONAL_PROP in propValue;
81
81
  }
82
- async function unpackPropValue(value) {
83
- return serialize(value);
82
+ async function unpackPropValue(value, containerResolver) {
83
+ return serialize(value, containerResolver);
84
84
  }
85
- async function buildStandardVisitProps(pageProps) {
85
+ async function buildStandardVisitProps(pageProps, containerResolver) {
86
86
  const mergeProps = [];
87
87
  const deepMergeProps = [];
88
88
  const newProps = {};
@@ -141,11 +141,11 @@ async function buildStandardVisitProps(pageProps) {
141
141
  await Promise.all(
142
142
  unpackedValues.map(async ({ key, value }) => {
143
143
  if (typeof value === "function") {
144
- return Promise.resolve(value()).then((r) => unpackPropValue(r)).then((jsonValue) => {
144
+ return Promise.resolve(value()).then((r) => unpackPropValue(r, containerResolver)).then((jsonValue) => {
145
145
  newProps[key] = jsonValue;
146
146
  });
147
147
  } else {
148
- return unpackPropValue(value).then((jsonValue) => {
148
+ return unpackPropValue(value, containerResolver).then((jsonValue) => {
149
149
  newProps[key] = jsonValue;
150
150
  });
151
151
  }
@@ -158,7 +158,7 @@ async function buildStandardVisitProps(pageProps) {
158
158
  deferredProps
159
159
  };
160
160
  }
161
- async function buildPartialRequestProps(pageProps, cherryPickProps) {
161
+ async function buildPartialRequestProps(pageProps, cherryPickProps, containerResolver) {
162
162
  const mergeProps = [];
163
163
  const deepMergeProps = [];
164
164
  const newProps = {};
@@ -208,11 +208,11 @@ async function buildPartialRequestProps(pageProps, cherryPickProps) {
208
208
  await Promise.all(
209
209
  unpackedValues.map(async ({ key, value }) => {
210
210
  if (typeof value === "function") {
211
- return Promise.resolve(value()).then((r) => unpackPropValue(r)).then((jsonValue) => {
211
+ return Promise.resolve(value()).then((r) => unpackPropValue(r, containerResolver)).then((jsonValue) => {
212
212
  newProps[key] = jsonValue;
213
213
  });
214
214
  } else {
215
- return unpackPropValue(value).then((jsonValue) => {
215
+ return unpackPropValue(value, containerResolver).then((jsonValue) => {
216
216
  newProps[key] = jsonValue;
217
217
  });
218
218
  }
@@ -260,7 +260,7 @@ var Inertia = class {
260
260
  this.#shouldEncryptHistory = config.encryptHistory ?? false;
261
261
  this.#cachedVersion = this.config.assetsVersion ? String(this.config.assetsVersion) : void 0;
262
262
  }
263
- #sharedState;
263
+ #sharedStateProviders;
264
264
  #cachedRequestInfo;
265
265
  /**
266
266
  * Optional server-side renderer for SSR functionality
@@ -341,6 +341,12 @@ var Inertia = class {
341
341
  * Resolve the root view template
342
342
  *
343
343
  * Handles both static strings and dynamic functions for the root view.
344
+ *
345
+ * @example
346
+ * ```js
347
+ * const viewName = this.#resolveRootView()
348
+ * this.ctx.view.render(viewName, { page: pageObject })
349
+ * ```
344
350
  */
345
351
  #resolveRootView() {
346
352
  return typeof this.config.rootView === "function" ? this.config.rootView(this.ctx) : this.config.rootView;
@@ -349,13 +355,37 @@ var Inertia = class {
349
355
  * Constructs and serializes the page props for a given component
350
356
  *
351
357
  * Handles both full page loads and partial requests with prop filtering.
358
+ * Merges shared state providers with page-specific props, and handles
359
+ * prop cherry-picking for partial reloads based on the `only` and `except` parameters.
352
360
  *
353
361
  * @param component - The component name being rendered
354
362
  * @param requestInfo - Information about the current request
355
363
  * @param pageProps - Raw page props to be processed
364
+ *
365
+ * @example
366
+ * ```js
367
+ * const result = await this.#buildPageProps('Dashboard', requestInfo, {
368
+ * user: { name: 'John' },
369
+ * posts: defer(() => getPosts())
370
+ * })
371
+ * ```
356
372
  */
357
- #buildPageProps(component, requestInfo, pageProps) {
358
- const finalProps = { ...this.#sharedState, ...pageProps };
373
+ async #buildPageProps(component, requestInfo, pageProps) {
374
+ let finalProps;
375
+ if (this.#sharedStateProviders) {
376
+ const sharedState = await Promise.all(
377
+ this.#sharedStateProviders.map((provider) => {
378
+ return typeof provider === "function" ? provider() : provider;
379
+ })
380
+ ).then((resolvedSharedState) => {
381
+ return resolvedSharedState.reduce((result, state) => {
382
+ return { ...result, ...state };
383
+ }, {});
384
+ });
385
+ finalProps = { ...sharedState, ...pageProps };
386
+ } else {
387
+ finalProps = { ...pageProps };
388
+ }
359
389
  if (requestInfo.partialComponent === component) {
360
390
  const only = requestInfo.onlyProps;
361
391
  const except = requestInfo.exceptProps ?? [];
@@ -367,15 +397,24 @@ var Inertia = class {
367
397
  });
368
398
  debug_default("building props for a partial reload %O", requestInfo);
369
399
  debug_default("cherry picking props %s", cherryPickProps);
370
- return buildPartialRequestProps(finalProps, cherryPickProps);
400
+ return buildPartialRequestProps(finalProps, cherryPickProps, this.ctx.containerResolver);
371
401
  }
372
402
  debug_default("building props for a standard visit %O", requestInfo);
373
- return buildStandardVisitProps(finalProps);
403
+ return buildStandardVisitProps(finalProps, this.ctx.containerResolver);
374
404
  }
375
405
  /**
376
- * Handle Inertia request by setting headers and returning page object
406
+ * Handle Inertia AJAX request by setting appropriate headers
407
+ *
408
+ * Sets the `X-Inertia` header to 'true' indicating this is an Inertia response,
409
+ * then returns the page object which will be serialized as JSON.
377
410
  *
378
411
  * @param pageObject - The page object to return
412
+ *
413
+ * @example
414
+ * ```js
415
+ * const pageObj = await this.page('Dashboard', props)
416
+ * return this.#handleInertiaRequest(pageObj)
417
+ * ```
379
418
  */
380
419
  #handleInertiaRequest(pageObject) {
381
420
  this.ctx.response.header(InertiaHeaders.Inertia, "true");
@@ -386,6 +425,7 @@ var Inertia = class {
386
425
  *
387
426
  * @param pageObject - The page object to render
388
427
  * @param viewProps - Additional props to pass to the root view template
428
+ * @returns Promise resolving to the rendered HTML string
389
429
  */
390
430
  async #renderWithSSR(pageObject, viewProps) {
391
431
  if (!this.#serverRenderer) {
@@ -403,6 +443,7 @@ var Inertia = class {
403
443
  *
404
444
  * @param pageObject - The page object to render
405
445
  * @param viewProps - Additional props to pass to the root view template
446
+ * @returns Promise resolving to the rendered HTML string
406
447
  */
407
448
  async #renderClientSide(pageObject, viewProps) {
408
449
  debug_default("rendering shell for SPA %O", pageObject);
@@ -413,6 +454,9 @@ var Inertia = class {
413
454
  *
414
455
  * Parses various Inertia headers to determine request type and props filtering.
415
456
  *
457
+ * @param reCompute - Whether to recompute the request info instead of using cached version
458
+ * @returns The request information object containing Inertia-specific data
459
+ *
416
460
  * @example
417
461
  * ```js
418
462
  * const info = inertia.requestInfo()
@@ -441,13 +485,15 @@ var Inertia = class {
441
485
  * Compute and cache the assets version
442
486
  *
443
487
  * Uses Vite manifest hash when available, otherwise defaults to '1'.
488
+ *
489
+ * @returns The computed version string for asset versioning
444
490
  */
445
491
  getVersion() {
446
492
  if (this.#cachedVersion) {
447
493
  return this.#cachedVersion;
448
494
  }
449
495
  if (this.#vite?.hasManifestFile) {
450
- this.#cachedVersion = createHash("md5").update(JSON.stringify(this.#vite.manifest)).digest("hex");
496
+ this.#cachedVersion = createHash("md5").update(JSON.stringify(this.#vite.manifest())).digest("hex");
451
497
  } else {
452
498
  this.#cachedVersion = "1";
453
499
  }
@@ -459,6 +505,7 @@ var Inertia = class {
459
505
  * Checks global SSR settings and component-specific configuration.
460
506
  *
461
507
  * @param component - The component name to check
508
+ * @returns Promise resolving to true if SSR is enabled for the component
462
509
  *
463
510
  * @example
464
511
  * ```js
@@ -488,6 +535,7 @@ var Inertia = class {
488
535
  * in every page render alongside page-specific props.
489
536
  *
490
537
  * @param sharedState - Props to share across all pages
538
+ * @returns The Inertia instance for method chaining
491
539
  *
492
540
  * @example
493
541
  * ```js
@@ -504,7 +552,10 @@ var Inertia = class {
504
552
  * ```
505
553
  */
506
554
  share(sharedState) {
507
- this.#sharedState = { ...this.#sharedState, ...sharedState };
555
+ if (!this.#sharedStateProviders) {
556
+ this.#sharedStateProviders = [];
557
+ }
558
+ this.#sharedStateProviders.push(sharedState);
508
559
  return this;
509
560
  }
510
561
  /**
@@ -514,6 +565,7 @@ var Inertia = class {
514
565
  *
515
566
  * @param page - The page component name
516
567
  * @param pageProps - Props to pass to the page component
568
+ * @returns Promise resolving to the complete page object
517
569
  *
518
570
  * @example
519
571
  * ```js
@@ -553,8 +605,7 @@ var Inertia = class {
553
605
  * @param page - The page component name to render
554
606
  * @param pageProps - Props to pass to the page component
555
607
  * @param viewProps - Additional props to pass to the root view template
556
- *
557
- * @returns PageObject for Inertia requests, HTML string for initial page loads
608
+ * @returns Promise resolving to PageObject for Inertia requests, HTML string for initial page loads
558
609
  *
559
610
  * @example
560
611
  * ```js
@@ -678,7 +729,7 @@ var ServerRenderer = class {
678
729
  * @returns Promise resolving to an object with rendered head and body HTML
679
730
  *
680
731
  * @example
681
- * ```typescript
732
+ * ```js
682
733
  * const pageObject = {
683
734
  * component: 'Home',
684
735
  * props: { user: { name: 'John' } },
@@ -741,6 +792,7 @@ var InertiaManager = class {
741
792
  * Creates a new Inertia instance for a specific HTTP request
742
793
  *
743
794
  * @param ctx - HTTP context for the current request
795
+ * @returns A new Inertia instance configured for the given request
744
796
  *
745
797
  * @example
746
798
  * ```js
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  defineConfig
3
- } from "../chunk-PDP56GPP.js";
3
+ } from "../chunk-5QRJHXXQ.js";
4
4
  import {
5
5
  Inertia,
6
6
  ServerRenderer
7
- } from "../chunk-74S2VAL7.js";
7
+ } from "../chunk-YQ72YL64.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
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  defineConfig,
3
3
  indexPages
4
- } from "./chunk-PDP56GPP.js";
4
+ } from "./chunk-5QRJHXXQ.js";
5
5
  import {
6
6
  Inertia,
7
7
  InertiaManager,
8
8
  ServerRenderer,
9
9
  symbols_exports
10
- } from "./chunk-74S2VAL7.js";
10
+ } from "./chunk-YQ72YL64.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,6 +1,6 @@
1
1
  import { type Route } from '@adonisjs/core/http';
2
2
  import type { ApplicationService } from '@adonisjs/core/types';
3
- import type { AsPageProps, InertiaPages } from '../src/types.js';
3
+ import type { AsPageProps, ComponentProps, InertiaPages, SharedProps } from '../src/types.js';
4
4
  declare module '@adonisjs/core/http' {
5
5
  interface BriskRoute {
6
6
  /**
@@ -29,7 +29,7 @@ declare module '@adonisjs/core/http' {
29
29
  * })
30
30
  * ```
31
31
  */
32
- renderInertia<Page extends keyof InertiaPages>(component: Page, props: AsPageProps<InertiaPages[Page]>, viewProps?: Record<string, any>): Route;
32
+ renderInertia<Page extends keyof InertiaPages>(component: Page, props: InertiaPages[Page] extends ComponentProps ? AsPageProps<Omit<InertiaPages[Page], keyof SharedProps>> : never, viewProps?: Record<string, any>): Route;
33
33
  }
34
34
  }
35
35
  /**
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  InertiaManager
3
- } from "../chunk-74S2VAL7.js";
4
- import "../chunk-DISC5OYC.js";
3
+ } from "../chunk-YQ72YL64.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,27 @@
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
+ * @param layout - Optional layout component to assign to the resolved page
9
+ * @returns Promise resolving to the page component
10
+ *
11
+ * @example
12
+ * ```js
13
+ * // Single path resolution
14
+ * const component = await resolvePageComponent('Home', {
15
+ * 'Home': () => import('./pages/Home.vue'),
16
+ * 'About': () => import('./pages/About.vue')
17
+ * })
18
+ *
19
+ * // Multiple path resolution (fallback)
20
+ * const component = await resolvePageComponent(['Dashboard/Admin', 'Dashboard'], {
21
+ * 'Dashboard': () => import('./pages/Dashboard.vue')
22
+ * })
23
+ * ```
24
+ *
25
+ * @throws Error When none of the provided paths can be resolved in the pages registry
26
+ */
27
+ export declare function resolvePageComponent<T>(path: string | string[], pages: Record<string, Promise<T> | (() => Promise<T>) | T>, layout?: any): Promise<T>;
@@ -0,0 +1,30 @@
1
+ import "../../chunk-MLKGABMK.js";
2
+
3
+ // src/client/helpers.ts
4
+ async function resolvePageComponent(path, pages, layout) {
5
+ for (const p of Array.isArray(path) ? path : [path]) {
6
+ const page = pages[p];
7
+ if (typeof page === "undefined") {
8
+ continue;
9
+ }
10
+ const resolvedPage = await (typeof page === "function" ? page() : page);
11
+ if (!resolvedPage) {
12
+ throw new Error(
13
+ `Invalid page exported from "${path}". Make sure to default export a function`
14
+ );
15
+ }
16
+ if ("default" in resolvedPage === false) {
17
+ throw new Error(
18
+ `Invalid page exported from "${path}". Make sure to default export a function`
19
+ );
20
+ }
21
+ if (layout && !resolvedPage.default.layout) {
22
+ resolvedPage.default.layout = layout;
23
+ }
24
+ return resolvedPage;
25
+ }
26
+ throw new Error(`Page not found: "${path}"`);
27
+ }
28
+ export {
29
+ resolvePageComponent
30
+ };
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import type { Tuyau } from '@tuyau/core/client';
3
+ import type { AdonisRegistry } from '@tuyau/core/types';
4
+ /**
5
+ * Provider component that makes the Tuyau client available to child components.
6
+ *
7
+ * This component should wrap your entire application or the part of your
8
+ * application that needs access to type-safe routing functionality.
9
+ *
10
+ */
11
+ export declare function TuyauProvider<R extends AdonisRegistry>(props: {
12
+ children: React.ReactNode;
13
+ client: Tuyau<R>;
14
+ }): React.JSX.Element;
15
+ /**
16
+ * Hook to access the Tuyau client from any component within a TuyauProvider.
17
+ *
18
+ * Provides type-safe access to route generation and navigation utilities.
19
+ * Must be used within a component tree wrapped by TuyauProvider.
20
+ *
21
+ * @returns The Tuyau client instance with full type safety
22
+ * @throws Error if used outside of a TuyauProvider
23
+ */
24
+ export declare function useTuyau(): Tuyau<any>;
@@ -0,0 +1,3 @@
1
+ export * from './context.tsx';
2
+ export * from './router.ts';
3
+ export * from './link.tsx';
@@ -0,0 +1,72 @@
1
+ import "../../../chunk-MLKGABMK.js";
2
+
3
+ // src/client/react/context.tsx
4
+ import React from "react";
5
+ var TuyauContext = React.createContext(null);
6
+ function TuyauProvider(props) {
7
+ return /* @__PURE__ */ React.createElement(TuyauContext.Provider, { value: props.client }, props.children);
8
+ }
9
+ function useTuyau() {
10
+ const context = React.useContext(TuyauContext);
11
+ if (!context) throw new Error("You must wrap your app in a TuyauProvider");
12
+ return context;
13
+ }
14
+
15
+ // src/client/react/router.ts
16
+ import { router as InertiaRouter } from "@inertiajs/react";
17
+ function useRouter() {
18
+ const tuyau = useTuyau();
19
+ return {
20
+ /**
21
+ * Navigate to a route with type-safe parameters and options.
22
+ *
23
+ * Automatically resolves the route URL and HTTP method based on the
24
+ * route definition, then performs the navigation using Inertia's router.
25
+ *
26
+ * @param props - Route navigation parameters including route name and params
27
+ * @param options - Optional Inertia visit options for controlling navigation behavior
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * // Navigate to a simple route
32
+ * router.visit({ route: 'dashboard' })
33
+ *
34
+ * // Navigate with parameters
35
+ * router.visit({ route: 'user.edit', params: { id: userId } })
36
+ * ```
37
+ */
38
+ visit: (props, options) => {
39
+ const routeInfo = tuyau.getRoute(props.route, { params: props.params });
40
+ const url = routeInfo.url;
41
+ return InertiaRouter.visit(url, {
42
+ ...options,
43
+ method: routeInfo.methods[0].toLowerCase()
44
+ });
45
+ }
46
+ };
47
+ }
48
+
49
+ // src/client/react/link.tsx
50
+ import React2 from "react";
51
+ import { Link as InertiaLink } from "@inertiajs/react";
52
+ function LinkInner(props, ref) {
53
+ const { route, params, ...linkProps } = props;
54
+ const tuyau = useTuyau();
55
+ const routeInfo = tuyau.getRoute(props.route, { params });
56
+ return /* @__PURE__ */ React2.createElement(
57
+ InertiaLink,
58
+ {
59
+ ...linkProps,
60
+ href: routeInfo.url,
61
+ method: routeInfo.methods[0].toLowerCase(),
62
+ ref
63
+ }
64
+ );
65
+ }
66
+ var Link = React2.forwardRef(LinkInner);
67
+ export {
68
+ Link,
69
+ TuyauProvider,
70
+ useRouter,
71
+ useTuyau
72
+ };
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import type { UserRegistry } from '@tuyau/core/types';
3
+ import { Link as InertiaLink } from '@inertiajs/react';
4
+ import { AreAllOptional } from '@poppinss/utils/types';
5
+ /**
6
+ * Get parameter tuple type for a route
7
+ */
8
+ type ExtractParamsTuple<Route extends keyof UserRegistry> = UserRegistry[Route]['types']['paramsTuple'];
9
+ /**
10
+ * Get parameter object type for a route
11
+ */
12
+ type ExtractParamsObject<Route extends keyof UserRegistry> = UserRegistry[Route]['types']['params'];
13
+ /**
14
+ * Get params format for a route
15
+ */
16
+ type RouteParamsFormats<Route extends keyof UserRegistry> = ExtractParamsObject<Route> extends Record<string, never> ? never : ExtractParamsTuple<Route> | ExtractParamsObject<Route>;
17
+ /**
18
+ * Parameters required for route navigation with proper type safety.
19
+ */
20
+ export type LinkParams<Route extends keyof UserRegistry> = {
21
+ route: Route;
22
+ } & (RouteParamsFormats<Route> extends never ? {
23
+ params?: never;
24
+ } : AreAllOptional<ExtractParamsObject<Route>> extends true ? {
25
+ params?: RouteParamsFormats<Route>;
26
+ } : {
27
+ params: RouteParamsFormats<Route>;
28
+ });
29
+ /**
30
+ * Props for the Link component extending InertiaLink props
31
+ * with route-specific type safety and parameter validation.
32
+ */
33
+ type LinkProps<Route extends keyof UserRegistry> = Omit<React.ComponentPropsWithoutRef<typeof InertiaLink>, 'href' | 'method'> & LinkParams<Route>;
34
+ /**
35
+ * Internal Link component implementation with forward ref support.
36
+ * Resolves route parameters and generates the appropriate URL and HTTP method
37
+ * for Inertia navigation.
38
+ *
39
+ * @param props - Link properties including route and parameters
40
+ * @param ref - Forward ref for the underlying InertiaLink component
41
+ */
42
+ declare function LinkInner<Route extends keyof UserRegistry>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>): React.JSX.Element;
43
+ /**
44
+ * Type-safe Link component for Inertia.js navigation.
45
+ *
46
+ * Provides compile-time route validation and automatic parameter type checking
47
+ * based on your application's route definitions. Automatically resolves the
48
+ * correct URL and HTTP method for each route.
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * // Link to a route without parameters
53
+ * <Link route="home">Home</Link>
54
+ *
55
+ * // Link to a route with required parameters
56
+ * <Link route="user.show" params={{ id: 1 }}>
57
+ * View User
58
+ * </Link>
59
+ * ```
60
+ */
61
+ export declare const Link: <Route extends keyof UserRegistry>(props: LinkProps<Route> & {
62
+ ref?: React.Ref<React.ElementRef<typeof InertiaLink>>;
63
+ }) => ReturnType<typeof LinkInner>;
64
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { UserRegistry } from '@tuyau/core/types';
2
+ import { router as InertiaRouter } from '@inertiajs/react';
3
+ import type { LinkParams } from './link.tsx';
4
+ /**
5
+ * Custom hook providing type-safe navigation utilities for Inertia.js.
6
+ *
7
+ * Returns an enhanced router object with type-safe navigation methods
8
+ * that automatically resolve route URLs and HTTP methods based on
9
+ * your application's route definitions.
10
+ *
11
+ * @returns Router object with type-safe navigation methods
12
+ */
13
+ export declare function useRouter(): {
14
+ /**
15
+ * Navigate to a route with type-safe parameters and options.
16
+ *
17
+ * Automatically resolves the route URL and HTTP method based on the
18
+ * route definition, then performs the navigation using Inertia's router.
19
+ *
20
+ * @param props - Route navigation parameters including route name and params
21
+ * @param options - Optional Inertia visit options for controlling navigation behavior
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * // Navigate to a simple route
26
+ * router.visit({ route: 'dashboard' })
27
+ *
28
+ * // Navigate with parameters
29
+ * router.visit({ route: 'user.edit', params: { id: userId } })
30
+ * ```
31
+ */
32
+ visit: <Route extends keyof UserRegistry>(props: LinkParams<Route>, options?: Parameters<typeof InertiaRouter.visit>[1]) => any;
33
+ };
@@ -21,6 +21,8 @@ export type InertiaPluginOptions = {
21
21
  output?: string;
22
22
  } | {
23
23
  enabled: false;
24
+ entrypoint?: string;
25
+ output?: string;
24
26
  };
25
27
  };
26
28
  /**
@@ -52,7 +54,7 @@ export type InertiaPluginOptions = {
52
54
  * inertia({
53
55
  * ssr: {
54
56
  * enabled: true,
55
- * entrypoint: 'inertia/app/ssr.ts',
57
+ * entrypoint: 'inertia/ssr.tsx',
56
58
  * output: 'build/ssr'
57
59
  * }
58
60
  * })
@@ -6,6 +6,7 @@ import type { InertiaConfig, InertiaConfigInput } from './types.js';
6
6
  * to create a complete Inertia configuration object.
7
7
  *
8
8
  * @param config - User configuration input to override defaults
9
+ * @returns Complete Inertia configuration object with defaults applied
9
10
  *
10
11
  * @example
11
12
  * ```js
@@ -1,5 +1,32 @@
1
+ /**
2
+ * Creates an AdonisJS assembler hook to automatically generate TypeScript definitions
3
+ * for Inertia.js pages based on the specified framework.
4
+ *
5
+ * This function scans page components in the 'inertia/pages' directory and generates
6
+ * type definitions that map page names to their component props.
7
+ *
8
+ * @param config - Configuration object specifying the frontend framework
9
+ * @param config.framework - The frontend framework ('vue3' or 'react')
10
+ * @returns Assembler hook object with run method for generating page types
11
+ *
12
+ * @example
13
+ * ```js
14
+ * // In your adonisrc.ts file
15
+ * export default defineConfig({
16
+ * assembler: {
17
+ * onBuildStarting: [indexPages({ framework: 'vue3' })]
18
+ * }
19
+ * })
20
+ * ```
21
+ */
1
22
  export declare const indexPages: (config: {
2
23
  framework: "vue3" | "react";
3
24
  }) => {
25
+ /**
26
+ * Executes the page indexing process to generate TypeScript definitions.
27
+ *
28
+ * @param _ - Unused first parameter (assembler context)
29
+ * @param indexGenerator - The index generator instance used to register the pages type generation
30
+ */
4
31
  run(_: import("@adonisjs/assembler").DevServer | import("@adonisjs/assembler").TestRunner | import("@adonisjs/assembler").Bundler, indexGenerator: import("@adonisjs/assembler/index_generator").IndexGenerator): void;
5
32
  };
@@ -1,8 +1,9 @@
1
1
  import { type Vite } from '@adonisjs/vite';
2
2
  import type { HttpContext } from '@adonisjs/core/http';
3
3
  import { type ServerRenderer } from './server_renderer.js';
4
- import type { PageProps, PageObject, AsPageProps, RequestInfo, InertiaConfig, ComponentProps } from './types.js';
4
+ import type { PageProps, PageObject, AsPageProps, RequestInfo, InertiaConfig, ComponentProps, SharedProps } from './types.js';
5
5
  import { defer, merge, always, optional, deepMerge } from './props.ts';
6
+ import { type AsyncOrSync } from '@poppinss/utils/types';
6
7
  /**
7
8
  * Main class used to interact with Inertia
8
9
  *
@@ -23,7 +24,7 @@ import { defer, merge, always, optional, deepMerge } from './props.ts';
23
24
  * inertia.location('/dashboard')
24
25
  * ```
25
26
  */
26
- export declare class Inertia<Pages extends Record<string, ComponentProps>> {
27
+ export declare class Inertia<Pages> {
27
28
  #private;
28
29
  protected ctx: HttpContext;
29
30
  protected config: InertiaConfig;
@@ -104,6 +105,9 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
104
105
  *
105
106
  * Parses various Inertia headers to determine request type and props filtering.
106
107
  *
108
+ * @param reCompute - Whether to recompute the request info instead of using cached version
109
+ * @returns The request information object containing Inertia-specific data
110
+ *
107
111
  * @example
108
112
  * ```js
109
113
  * const info = inertia.requestInfo()
@@ -117,6 +121,8 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
117
121
  * Compute and cache the assets version
118
122
  *
119
123
  * Uses Vite manifest hash when available, otherwise defaults to '1'.
124
+ *
125
+ * @returns The computed version string for asset versioning
120
126
  */
121
127
  getVersion(): string;
122
128
  /**
@@ -125,6 +131,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
125
131
  * Checks global SSR settings and component-specific configuration.
126
132
  *
127
133
  * @param component - The component name to check
134
+ * @returns Promise resolving to true if SSR is enabled for the component
128
135
  *
129
136
  * @example
130
137
  * ```js
@@ -143,6 +150,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
143
150
  * in every page render alongside page-specific props.
144
151
  *
145
152
  * @param sharedState - Props to share across all pages
153
+ * @returns The Inertia instance for method chaining
146
154
  *
147
155
  * @example
148
156
  * ```js
@@ -158,7 +166,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
158
166
  * .share({ permissions: userPermissions })
159
167
  * ```
160
168
  */
161
- share(sharedState: PageProps): this;
169
+ share(sharedState: PageProps | (() => AsyncOrSync<PageProps>)): this;
162
170
  /**
163
171
  * Build a page object with processed props and metadata
164
172
  *
@@ -166,6 +174,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
166
174
  *
167
175
  * @param page - The page component name
168
176
  * @param pageProps - Props to pass to the page component
177
+ * @returns Promise resolving to the complete page object
169
178
  *
170
179
  * @example
171
180
  * ```js
@@ -175,7 +184,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
175
184
  * })
176
185
  * ```
177
186
  */
178
- page<Page extends keyof Pages & string>(page: Page, pageProps: AsPageProps<Pages[Page]>): Promise<PageObject<Pages[Page]>>;
187
+ page<Page extends keyof Pages & string>(page: Page, pageProps: Pages[Page] extends ComponentProps ? AsPageProps<Omit<Pages[Page], keyof SharedProps>> : never): Promise<PageObject<Pages[Page]>>;
179
188
  /**
180
189
  * Render a page using Inertia
181
190
  *
@@ -187,8 +196,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
187
196
  * @param page - The page component name to render
188
197
  * @param pageProps - Props to pass to the page component
189
198
  * @param viewProps - Additional props to pass to the root view template
190
- *
191
- * @returns PageObject for Inertia requests, HTML string for initial page loads
199
+ * @returns Promise resolving to PageObject for Inertia requests, HTML string for initial page loads
192
200
  *
193
201
  * @example
194
202
  * ```js
@@ -202,7 +210,7 @@ export declare class Inertia<Pages extends Record<string, ComponentProps>> {
202
210
  * const html = await inertia.render('Home', { welcome: 'Hello World' })
203
211
  * ```
204
212
  */
205
- render<Page extends keyof Pages & string>(page: Page, pageProps: AsPageProps<Pages[Page]>, viewProps?: Record<string, any>): Promise<string | PageObject<Pages[Page]>>;
213
+ render<Page extends keyof Pages & string>(page: Page, pageProps: Pages[Page] extends ComponentProps ? AsPageProps<Omit<Pages[Page], keyof SharedProps>> : never, viewProps?: Record<string, any>): Promise<string | PageObject<Pages[Page]>>;
206
214
  /**
207
215
  * Clear the browser history on the next navigation
208
216
  *
@@ -35,6 +35,7 @@ export declare class InertiaManager {
35
35
  * Creates a new Inertia instance for a specific HTTP request
36
36
  *
37
37
  * @param ctx - HTTP context for the current request
38
+ * @returns A new Inertia instance configured for the given request
38
39
  *
39
40
  * @example
40
41
  * ```js
@@ -1,9 +1,9 @@
1
1
  import type { HttpContext } from '@adonisjs/core/http';
2
2
  import { type Inertia } from './inertia.js';
3
- import type { ComponentProps, InertiaPages, PageProps } from './types.js';
3
+ import type { InertiaPages, PageProps } from './types.js';
4
4
  declare module '@adonisjs/core/http' {
5
5
  interface HttpContext {
6
- inertia: Inertia<InertiaPages extends Record<string, ComponentProps> ? InertiaPages : never>;
6
+ inertia: Inertia<InertiaPages>;
7
7
  }
8
8
  }
9
9
  /**
@@ -51,8 +51,11 @@ export default abstract class BaseInertiaMiddleware {
51
51
  * This method should return an object containing data that will be
52
52
  * available to all Inertia pages as props.
53
53
  *
54
+ * @param ctx - The HTTP context object
55
+ * @returns Props to share across all pages
56
+ *
54
57
  * @example
55
- * ```ts
58
+ * ```js
56
59
  * async share() {
57
60
  * return {
58
61
  * user: ctx.auth?.user,
@@ -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-YQ72YL64.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;
@@ -65,7 +65,7 @@ var BaseInertiaMiddleware = class {
65
65
  const inertiaContainer = await ctx.containerResolver.make(InertiaManager);
66
66
  ctx.inertia = inertiaContainer.createForRequest(ctx);
67
67
  if (this.share) {
68
- ctx.inertia.share(await this.share(ctx));
68
+ ctx.inertia.share(() => this.share(ctx));
69
69
  }
70
70
  }
71
71
  /**
@@ -1,5 +1,6 @@
1
- import { type AsyncOrSync } from '@poppinss/utils/types';
1
+ import { type AsyncOrSync } from '@adonisjs/core/types/common';
2
2
  import { type DeferProp, type PageProps, type AlwaysProp, type OptionalProp, type MergeableProp, type ComponentProps, type UnPackedPageProps } from './types.ts';
3
+ import { type ContainerResolver } from '@adonisjs/core/container';
3
4
  /**
4
5
  * Creates a deferred prop that is never included in standard visits but must be shared with
5
6
  * the client during standard visits. Can be explicitly requested and supports merging.
@@ -138,9 +139,10 @@ export declare function deepMerge<T extends UnPackedPageProps | DeferProp<UnPack
138
139
  * This function is useful for runtime type checking and conditional prop handling.
139
140
  *
140
141
  * @param propValue - The object to check for deferred prop characteristics
142
+ * @returns True if the prop value is a deferred prop
141
143
  *
142
144
  * @example
143
- * ```javascript
145
+ * ```js
144
146
  * const prop = defer(() => ({ data: 'value' }))
145
147
  *
146
148
  * if (isDeferredProp(prop)) {
@@ -157,9 +159,10 @@ export declare function isDeferredProp<T extends UnPackedPageProps>(propValue: O
157
159
  * existing props rather than replaced during updates.
158
160
  *
159
161
  * @param propValue - The object to check for mergeable prop characteristics
162
+ * @returns True if the prop value is a mergeable prop
160
163
  *
161
164
  * @example
162
- * ```javascript
165
+ * ```js
163
166
  * const prop = merge({ items: [1, 2, 3] })
164
167
  *
165
168
  * if (isMergeableProp(prop)) {
@@ -176,9 +179,10 @@ export declare function isMergeableProp<T extends UnPackedPageProps | DeferProp<
176
179
  * responses, regardless of cherry-picking or selective prop requests.
177
180
  *
178
181
  * @param propValue - The object to check for always prop characteristics
182
+ * @returns True if the prop value is an always prop
179
183
  *
180
184
  * @example
181
- * ```javascript
185
+ * ```js
182
186
  * const prop = always({ userId: 123, permissions: ['read', 'write'] })
183
187
  *
184
188
  * if (isAlwaysProp(prop)) {
@@ -195,9 +199,10 @@ export declare function isAlwaysProp<T extends UnPackedPageProps>(propValue: Obj
195
199
  * when explicitly requested by the client, never in standard visits.
196
200
  *
197
201
  * @param propValue - The object to check for optional prop characteristics
202
+ * @returns True if the prop value is an optional prop
198
203
  *
199
204
  * @example
200
- * ```javascript
205
+ * ```js
201
206
  * const prop = optional(() => ({ detailedData: 'expensive computation' }))
202
207
  *
203
208
  * if (isOptionalProp(prop)) {
@@ -218,7 +223,8 @@ export declare function isOptionalProp<T extends UnPackedPageProps>(propValue: O
218
223
  * - Regular props: Included normally
219
224
  *
220
225
  * @param pageProps - The page props to process
221
- * @returns Object containing processed props, deferred props list, and merge props list
226
+ * @param containerResolver - Container resolver for dependency injection
227
+ * @returns Promise resolving to object containing processed props, deferred props list, and merge props list
222
228
  *
223
229
  * @example
224
230
  * ```js
@@ -230,7 +236,7 @@ export declare function isOptionalProp<T extends UnPackedPageProps>(propValue: O
230
236
  * // Returns: { props: { user: {...} }, deferredProps: { default: ['posts'] }, mergeProps: ['settings'] }
231
237
  * ```
232
238
  */
233
- export declare function buildStandardVisitProps(pageProps: PageProps): Promise<{
239
+ export declare function buildStandardVisitProps(pageProps: PageProps, containerResolver: ContainerResolver<any>): Promise<{
234
240
  props: ComponentProps;
235
241
  mergeProps: string[];
236
242
  deepMergeProps: string[];
@@ -250,7 +256,8 @@ export declare function buildStandardVisitProps(pageProps: PageProps): Promise<{
250
256
  *
251
257
  * @param pageProps - The page props to process
252
258
  * @param cherryPickProps - Array of prop names to include
253
- * @returns Object containing processed props and merge props list
259
+ * @param containerResolver - Container resolver for dependency injection
260
+ * @returns Promise resolving to object containing processed props and merge props list
254
261
  *
255
262
  * @example
256
263
  * ```js
@@ -261,7 +268,7 @@ export declare function buildStandardVisitProps(pageProps: PageProps): Promise<{
261
268
  * // Returns: { props: { posts: [...], stats: [...] }, mergeProps: [], deferredProps: {} }
262
269
  * ```
263
270
  */
264
- export declare function buildPartialRequestProps(pageProps: PageProps, cherryPickProps: string[]): Promise<{
271
+ export declare function buildPartialRequestProps(pageProps: PageProps, cherryPickProps: string[], containerResolver: ContainerResolver<any>): Promise<{
265
272
  props: ComponentProps;
266
273
  mergeProps: string[];
267
274
  deepMergeProps: string[];
@@ -36,7 +36,7 @@ export declare class ServerRenderer {
36
36
  * @returns Promise resolving to an object with rendered head and body HTML
37
37
  *
38
38
  * @example
39
- * ```typescript
39
+ * ```js
40
40
  * const pageObject = {
41
41
  * component: 'Home',
42
42
  * props: { user: { name: 'John' } },
@@ -47,7 +47,7 @@ export declare class ServerRenderer {
47
47
  * const { head, body } = await renderer.render(pageObject)
48
48
  * ```
49
49
  */
50
- render(pageObject: PageObject): Promise<{
50
+ render(pageObject: PageObject<any>): Promise<{
51
51
  head: string[];
52
52
  body: string;
53
53
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { HttpContext } from '@adonisjs/core/http';
2
2
  import { type ContainerResolver } from '@adonisjs/core/container';
3
3
  import type { JSONDataTypes } from '@adonisjs/core/types/transformers';
4
- import type { AsyncOrSync, DeepPartial, Prettify } from '@poppinss/utils/types';
4
+ import type { AsyncOrSync, DeepPartial, Prettify } from '@adonisjs/core/types/common';
5
5
  import { type DEEP_MERGE, type ALWAYS_PROP, type OPTIONAL_PROP, type TO_BE_MERGED, type DEFERRED_PROP } from './symbols.ts';
6
6
  /**
7
7
  * Representation of a resource item, collection and paginator that can be serialized
@@ -242,10 +242,6 @@ export type InertiaConfig = {
242
242
  * application
243
243
  */
244
244
  rootView: string | ((ctx: HttpContext) => string);
245
- /**
246
- * The entrypoint file to load in order to boot the frontend application.
247
- */
248
- entrypoint: string;
249
245
  /**
250
246
  * A fixed asset version value to use. Otherwise, it will be read from the
251
247
  * Vite manifest file.
@@ -290,7 +286,7 @@ export type InertiaConfigInput = DeepPartial<InertiaConfig>;
290
286
  *
291
287
  * @template Props - The props type for the page component
292
288
  */
293
- export type PageObject<Props extends PageProps = PageProps> = {
289
+ export type PageObject<Props> = {
294
290
  /**
295
291
  * The name/path of the component to render
296
292
  */
@@ -373,7 +369,7 @@ export interface InertiaPages {
373
369
  * @param page - The page object containing component and props data
374
370
  * @returns Promise resolving to an object with head tags and body HTML
375
371
  */
376
- export type RenderInertiaSsrApp = (page: PageObject) => Promise<{
372
+ export type RenderInertiaSsrApp = (page: PageObject<any>) => Promise<{
377
373
  head: string[];
378
374
  body: string;
379
375
  }>;
@@ -0,0 +1,65 @@
1
+ declare const routes: {
2
+ readonly 'users.index': {
3
+ readonly methods: ["GET", "HEAD"];
4
+ readonly pattern: "/";
5
+ readonly tokens: [{
6
+ readonly old: "/";
7
+ readonly type: 0;
8
+ readonly val: "/";
9
+ readonly end: "";
10
+ }];
11
+ readonly types: {
12
+ body: {};
13
+ paramsTuple: [];
14
+ params: {};
15
+ query: {};
16
+ response: unknown;
17
+ };
18
+ };
19
+ readonly 'users.comments.edit': {
20
+ readonly methods: ["GET", "HEAD"];
21
+ readonly pattern: "/users/:id/comments/:comment_id/edit";
22
+ readonly tokens: [{
23
+ readonly old: "/users";
24
+ readonly type: 0;
25
+ readonly val: "users";
26
+ readonly end: "/";
27
+ }, {
28
+ readonly old: ":id";
29
+ readonly type: 1;
30
+ readonly val: "id";
31
+ readonly end: "/";
32
+ }, {
33
+ readonly old: "/comments";
34
+ readonly type: 0;
35
+ readonly val: "comments";
36
+ readonly end: "/";
37
+ }, {
38
+ readonly old: ":comment_id";
39
+ readonly type: 1;
40
+ readonly val: "comment_id";
41
+ readonly end: "/edit";
42
+ }, {
43
+ readonly old: "/edit";
44
+ readonly type: 0;
45
+ readonly val: "edit";
46
+ readonly end: "";
47
+ }];
48
+ readonly types: {
49
+ body: {};
50
+ paramsTuple: [string, string];
51
+ params: {
52
+ id: string;
53
+ comment_id: string;
54
+ };
55
+ query: {};
56
+ response: unknown;
57
+ };
58
+ };
59
+ };
60
+ declare module '@tuyau/core/types' {
61
+ type Registry = typeof routes;
62
+ interface UserRegistry extends Registry {
63
+ }
64
+ }
65
+ export {};
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.10",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -18,6 +18,8 @@
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",
22
+ "./react": "./build/src/client/react/index.js",
21
23
  "./factories": "./build/factories/main.js"
22
24
  },
23
25
  "scripts": {
@@ -41,13 +43,14 @@
41
43
  "docs": "typedoc"
42
44
  },
43
45
  "devDependencies": {
44
- "@adonisjs/assembler": "^8.0.0-next.9",
45
- "@adonisjs/core": "^7.0.0-next.1",
46
- "@adonisjs/eslint-config": "^3.0.0-next.1",
46
+ "@adonisjs/assembler": "^8.0.0-next.14",
47
+ "@adonisjs/core": "^7.0.0-next.10",
48
+ "@adonisjs/eslint-config": "^3.0.0-next.4",
47
49
  "@adonisjs/prettier-config": "^1.4.5",
48
50
  "@adonisjs/session": "^8.0.0-next.0",
49
- "@adonisjs/tsconfig": "^2.0.0-next.0",
50
- "@adonisjs/vite": "^5.0.1-next.0",
51
+ "@adonisjs/tsconfig": "^2.0.0-next.3",
52
+ "@adonisjs/vite": "^5.1.0-next.0",
53
+ "@inertiajs/react": "^2.2.15",
51
54
  "@japa/api-client": "^3.1.0",
52
55
  "@japa/assert": "4.1.1",
53
56
  "@japa/expect-type": "^2.0.3",
@@ -57,21 +60,24 @@
57
60
  "@japa/snapshot": "^2.0.9",
58
61
  "@poppinss/ts-exec": "^1.4.1",
59
62
  "@release-it/conventional-changelog": "^10.0.1",
60
- "@types/node": "^24.3.1",
63
+ "@tuyau/core": "^1.0.0-beta.1",
64
+ "@types/node": "^24.8.1",
65
+ "@types/react": "^19.2.2",
61
66
  "@types/supertest": "^6.0.3",
62
67
  "c8": "^10.1.3",
63
68
  "copyfiles": "^2.4.1",
64
- "cross-env": "^10.0.0",
65
- "del-cli": "^6.0.0",
69
+ "cross-env": "^10.1.0",
70
+ "del-cli": "^7.0.0",
66
71
  "edge.js": "^6.3.0",
67
- "eslint": "^9.35.0",
72
+ "eslint": "^9.38.0",
68
73
  "get-port": "^7.1.0",
69
74
  "prettier": "^3.6.2",
70
- "release-it": "^19.0.4",
75
+ "react": "^19.2.0",
76
+ "release-it": "^19.0.5",
71
77
  "supertest": "^7.1.4",
72
78
  "tsup": "^8.5.0",
73
- "typescript": "~5.9.2",
74
- "vite": "^7.1.5"
79
+ "typescript": "~5.9.3",
80
+ "vite": "^7.1.10"
75
81
  },
76
82
  "dependencies": {
77
83
  "@poppinss/utils": "^7.0.0-next.3",
@@ -79,13 +85,16 @@
79
85
  "html-entities": "^2.6.0"
80
86
  },
81
87
  "peerDependencies": {
82
- "@adonisjs/assembler": "^8.0.0-next.7",
83
- "@adonisjs/core": "^7.0.0-next.0",
88
+ "@adonisjs/assembler": "^8.0.0-next.14",
89
+ "@adonisjs/core": "^7.0.0-next.10",
84
90
  "@adonisjs/session": "^8.0.0-next.0",
85
- "@adonisjs/vite": "^5.0.1-next.0",
91
+ "@adonisjs/vite": "^5.1.0-next.0",
92
+ "@inertiajs/react": "^2.2.15",
86
93
  "@japa/api-client": "^3.1.0",
87
94
  "@japa/plugin-adonisjs": "^5.0.0-next.0",
88
- "edge.js": "^6.0.0"
95
+ "@tuyau/core": "^1.0.0-beta.1",
96
+ "edge.js": "^6.0.0",
97
+ "react": "^19.2.0"
89
98
  },
90
99
  "peerDependenciesMeta": {
91
100
  "@adonisjs/assembler": {
@@ -96,6 +105,15 @@
96
105
  },
97
106
  "@japa/plugin-adonisjs": {
98
107
  "optional": true
108
+ },
109
+ "react": {
110
+ "optional": true
111
+ },
112
+ "@tuyau/core": {
113
+ "optional": true
114
+ },
115
+ "@inertiajs/react": {
116
+ "optional": true
99
117
  }
100
118
  },
101
119
  "keywords": [
@@ -132,8 +150,7 @@
132
150
  },
133
151
  "npm": {
134
152
  "publish": true,
135
- "skipChecks": true,
136
- "tag": "latest"
153
+ "skipChecks": true
137
154
  },
138
155
  "plugins": {
139
156
  "@release-it/conventional-changelog": {
@@ -148,11 +165,13 @@
148
165
  "./index.ts",
149
166
  "./src/types.ts",
150
167
  "./src/client/vite.ts",
168
+ "./src/client/helpers.ts",
151
169
  "./factories/main.ts",
152
170
  "./src/inertia_middleware.ts",
153
171
  "./providers/inertia_provider.ts",
154
172
  "./src/plugins/edge/plugin.ts",
155
- "./src/plugins/japa/api_client.ts"
173
+ "./src/plugins/japa/api_client.ts",
174
+ "./src/client/react/index.tsx"
156
175
  ],
157
176
  "outDir": "./build",
158
177
  "clean": true,