@adonisjs/inertia 1.0.0-6 → 1.0.0-7

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,7 +4,9 @@ var Inertia = class {
4
4
  constructor(ctx, config) {
5
5
  this.ctx = ctx;
6
6
  this.config = config;
7
+ this.#sharedData = config.sharedData;
7
8
  }
9
+ #sharedData = {};
8
10
  /**
9
11
  * Check if a value is a lazy prop
10
12
  */
@@ -54,10 +56,17 @@ var Inertia = class {
54
56
  return {
55
57
  component,
56
58
  version: this.config.versionCache.getVersion(),
57
- props: await this.#resolvePageProps(component, { ...this.config.sharedData, ...pageProps }),
59
+ props: await this.#resolvePageProps(component, { ...this.#sharedData, ...pageProps }),
58
60
  url: this.ctx.request.url(true)
59
61
  };
60
62
  }
63
+ /**
64
+ * Share data for the current request.
65
+ * This data will override any shared data defined in the config.
66
+ */
67
+ share(data) {
68
+ this.#sharedData = { ...this.#sharedData, ...data };
69
+ }
61
70
  /**
62
71
  * Render a page using Inertia
63
72
  */
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InertiaMiddleware
3
- } from "../chunk-PZZVHQTV.js";
3
+ } from "../chunk-RXGBTZMN.js";
4
4
 
5
5
  // providers/inertia_provider.ts
6
6
  import { configProvider } from "@adonisjs/core";
@@ -1,6 +1,6 @@
1
1
  import { HttpContext } from '@adonisjs/core/http';
2
2
  import { NextFn } from '@adonisjs/core/types/http';
3
- import { ResolvedConfig, PageProps, MaybePromise } from './types.js';
3
+ import { ResolvedConfig, Data, PageProps, MaybePromise } from './types.js';
4
4
 
5
5
  /**
6
6
  * Symbol used to identify lazy props
@@ -14,6 +14,11 @@ declare class Inertia {
14
14
  protected ctx: HttpContext;
15
15
  protected config: ResolvedConfig;
16
16
  constructor(ctx: HttpContext, config: ResolvedConfig);
17
+ /**
18
+ * Share data for the current request.
19
+ * This data will override any shared data defined in the config.
20
+ */
21
+ share(data: Record<string, Data>): void;
17
22
  /**
18
23
  * Render a page using Inertia
19
24
  */
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InertiaMiddleware
3
- } from "../chunk-PZZVHQTV.js";
3
+ } from "../chunk-RXGBTZMN.js";
4
4
  export {
5
5
  InertiaMiddleware as default
6
6
  };
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-6",
4
+ "version": "1.0.0-7",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },