@adonisjs/inertia 1.0.0-13 → 1.0.0-14

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.
@@ -1,10 +1,9 @@
1
1
  // src/server_renderer.ts
2
2
  var styleFileRE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\?)/;
3
3
  var ServerRenderer = class {
4
- constructor(config, viteRuntime, viteDevServer) {
4
+ constructor(config, vite) {
5
5
  this.config = config;
6
- this.viteRuntime = viteRuntime;
7
- this.viteDevServer = viteDevServer;
6
+ this.vite = vite;
8
7
  }
9
8
  /**
10
9
  * If the module is a style module
@@ -61,12 +60,14 @@ var ServerRenderer = class {
61
60
  async render(pageObject) {
62
61
  let render;
63
62
  let preloadTags = [];
64
- if (this.viteRuntime && this.viteDevServer) {
65
- render = await this.viteRuntime.executeEntrypoint(this.config.ssr.entrypoint);
66
- const entryMod = this.viteDevServer.moduleGraph.getModuleById(this.config.entrypoint);
63
+ if (this.vite) {
64
+ const devServer = this.vite.getDevServer();
65
+ const runtime = await this.vite.createRuntime();
66
+ render = await runtime.executeEntrypoint(this.config.ssr.entrypoint);
67
+ const entryMod = devServer.moduleGraph.getModuleById(this.config.entrypoint);
67
68
  const pageMod = this.#findPageModule(entryMod, pageObject);
68
69
  if (pageMod)
69
- await this.viteRuntime.executeUrl(pageMod.url);
70
+ await runtime.executeUrl(pageMod.url);
70
71
  const preloadUrls = /* @__PURE__ */ new Set();
71
72
  const visitedModules = /* @__PURE__ */ new Set();
72
73
  if (pageMod)
@@ -86,13 +87,12 @@ var ServerRenderer = class {
86
87
  // src/inertia.ts
87
88
  var kLazySymbol = Symbol("lazy");
88
89
  var Inertia = class {
89
- constructor(ctx, config, viteRuntime, viteDevServer) {
90
+ constructor(ctx, config, vite) {
90
91
  this.ctx = ctx;
91
92
  this.config = config;
92
- this.viteRuntime = viteRuntime;
93
- this.viteDevServer = viteDevServer;
93
+ this.vite = vite;
94
94
  this.#sharedData = config.sharedData;
95
- this.#serverRenderer = new ServerRenderer(config, viteRuntime, viteDevServer);
95
+ this.#serverRenderer = new ServerRenderer(config, vite);
96
96
  }
97
97
  #sharedData = {};
98
98
  #serverRenderer;
@@ -217,14 +217,10 @@ var InertiaMiddleware = class {
217
217
  constructor(config, vite) {
218
218
  this.config = config;
219
219
  this.vite = vite;
220
- this.#runtime = vite?.getRuntime();
221
- this.#viteDevServer = vite?.getDevServer();
222
220
  }
223
- #runtime;
224
- #viteDevServer;
225
221
  async handle(ctx, next) {
226
222
  const { response, request } = ctx;
227
- ctx.inertia = new Inertia(ctx, this.config, this.#runtime, this.#viteDevServer);
223
+ ctx.inertia = new Inertia(ctx, this.config, this.vite);
228
224
  await next();
229
225
  const isInertiaRequest = !!request.header("x-inertia");
230
226
  if (!isInertiaRequest)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InertiaMiddleware
3
- } from "../chunk-WJOEJN5R.js";
3
+ } from "../chunk-NVJNYWGW.js";
4
4
 
5
5
  // providers/inertia_provider.ts
6
6
  import { configProvider } from "@adonisjs/core";
@@ -1,8 +1,6 @@
1
1
  import { Vite } from '@adonisjs/vite';
2
2
  import { HttpContext } from '@adonisjs/core/http';
3
3
  import { NextFn } from '@adonisjs/core/types/http';
4
- import { ViteDevServer } from 'vite';
5
- import { ViteRuntime } from 'vite/runtime';
6
4
  import { ResolvedConfig, Data, PageProps, PageObject, MaybePromise } from './types.js';
7
5
 
8
6
  /**
@@ -16,9 +14,8 @@ declare class Inertia {
16
14
  #private;
17
15
  protected ctx: HttpContext;
18
16
  protected config: ResolvedConfig;
19
- protected viteRuntime?: ViteRuntime | undefined;
20
- protected viteDevServer?: ViteDevServer | undefined;
21
- constructor(ctx: HttpContext, config: ResolvedConfig, viteRuntime?: ViteRuntime | undefined, viteDevServer?: ViteDevServer | undefined);
17
+ protected vite?: Vite | undefined;
18
+ constructor(ctx: HttpContext, config: ResolvedConfig, vite?: Vite | undefined);
22
19
  /**
23
20
  * Share data for the current request.
24
21
  * This data will override any shared data defined in the config.
@@ -61,7 +58,6 @@ declare module '@adonisjs/core/http' {
61
58
  * set appropriate headers/status
62
59
  */
63
60
  declare class InertiaMiddleware {
64
- #private;
65
61
  protected config: ResolvedConfig;
66
62
  protected vite?: Vite | undefined;
67
63
  constructor(config: ResolvedConfig, vite?: Vite | undefined);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  InertiaMiddleware
3
- } from "../chunk-WJOEJN5R.js";
3
+ } from "../chunk-NVJNYWGW.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-13",
4
+ "version": "1.0.0-14",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
@@ -44,7 +44,7 @@
44
44
  "@adonisjs/prettier-config": "^1.2.2",
45
45
  "@adonisjs/session": "7.1.1",
46
46
  "@adonisjs/tsconfig": "^1.2.2",
47
- "@adonisjs/vite": "^3.0.0-4",
47
+ "@adonisjs/vite": "^3.0.0-6",
48
48
  "@japa/api-client": "^2.0.2",
49
49
  "@japa/assert": "2.1.0",
50
50
  "@japa/expect-type": "^2.0.1",
@@ -84,7 +84,7 @@
84
84
  "peerDependencies": {
85
85
  "@adonisjs/core": "^6.2.0",
86
86
  "@adonisjs/session": "^7.0.0",
87
- "@adonisjs/vite": "^3.0.0-4",
87
+ "@adonisjs/vite": "^3.0.0-6",
88
88
  "@japa/api-client": "^2.0.0",
89
89
  "edge.js": "^6.0.0"
90
90
  },