@stratal/inertia 0.0.20 → 0.0.22

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/dist/index.mjs CHANGED
@@ -1,14 +1,9 @@
1
- import { n as runTypeGeneration, t as findPagesDir } from "./type-generator-C5JljyzK.mjs";
2
- import { DI_TOKENS, Scope, Transient, inject } from "stratal/di";
1
+ import { t as __decorate } from "./decorate-CzXVx7ZH.mjs";
3
2
  import { ApplicationError } from "stratal/errors";
4
- import { I18N_TOKENS } from "stratal/i18n";
5
3
  import { Module } from "stratal/module";
6
4
  import { Delete, Get, Patch, Post, Put, ROUTER_TOKENS, Route, RouterContext, SchemaValidationError } from "stratal/router";
7
- import { spawn } from "node:child_process";
8
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
9
- import { dirname, join, relative } from "node:path";
10
- import { Command } from "stratal/quarry";
11
- import { watch } from "node:fs/promises";
5
+ import { DI_TOKENS, Request, Singleton, Transient, inject } from "stratal/di";
6
+ import { I18N_TOKENS } from "stratal/i18n";
12
7
  import { LOGGER_TOKENS } from "stratal/logger";
13
8
  import { deleteCookie, getSignedCookie, setSignedCookie } from "hono/cookie";
14
9
  import { z } from "stratal/validation";
@@ -49,325 +44,6 @@ function augmentRouterContext(resolveService) {
49
44
  });
50
45
  }
51
46
  //#endregion
52
- //#region src/vite/create-vite-config.ts
53
- function writeTempViteConfig(options) {
54
- const configPath = join(join(options.cwd, "node_modules", ".stratal"), "vite.config.mjs");
55
- mkdirSync(dirname(configPath), { recursive: true });
56
- const hasUserConfig = existsSync(join(options.cwd, "vite.config.ts"));
57
- const serverConfig = options.server ? `server: { port: ${options.server.port}, host: ${options.server.host ? "true" : "undefined"} },` : "";
58
- const outDirConfig = options.outDir ? `outDir: '${options.outDir}',` : "";
59
- writeFileSync(configPath, `
60
- import { mergeConfig } from 'vite'
61
- import { cloudflare } from '@cloudflare/vite-plugin'
62
- import { stratalInertia } from '@stratal/inertia/vite'
63
-
64
- let inertiaPlugin = null
65
- try {
66
- const mod = await import('@inertiajs/vite')
67
- const inertia = mod.default ?? mod
68
- inertiaPlugin = inertia()
69
- } catch {}
70
-
71
- const baseConfig = {
72
- plugins: [
73
- cloudflare(${options.persistTo ? `{ persistState: { path: ${JSON.stringify(options.persistTo)} } }` : ""}),
74
- ...(inertiaPlugin ? [inertiaPlugin] : []),
75
- ...stratalInertia(),
76
- ],
77
- publicDir: '${join(options.cwd, "src", "inertia", "public").replace(/\\/g, "/")}',
78
- build: {
79
- ${outDirConfig}
80
- },
81
- ${serverConfig}
82
- }
83
-
84
- ${hasUserConfig ? `const userModule = await import('${join(options.cwd, "vite.config.ts").replace(/\\/g, "/")}')
85
- const userConfig = userModule.default ?? userModule
86
- export default mergeConfig(baseConfig, userConfig)` : "export default baseConfig"}
87
- `, "utf-8");
88
- return configPath;
89
- }
90
- //#endregion
91
- //#region src/commands/inertia-build.command.ts
92
- var InertiaBuildCommand = class extends Command {
93
- static command = "inertia:build {--outDir=dist : Output directory} {--ssr : Also build SSR bundle}";
94
- static description = "Build Inertia.js frontend for production";
95
- async handle() {
96
- const outDir = this.string("outDir") || "dist";
97
- const shouldBuildSsr = this.boolean("ssr");
98
- const cwd = process.cwd();
99
- if (!existsSync(join(cwd, "src/inertia/app.tsx"))) {
100
- this.fail("src/inertia/app.tsx not found. Run `quarry inertia:install` first.");
101
- return 1;
102
- }
103
- const configPath = writeTempViteConfig({
104
- cwd,
105
- outDir
106
- });
107
- this.info("Building Inertia.js frontend for production...");
108
- const clientCode = await this.spawnVite(cwd, configPath, ["build"]);
109
- if (clientCode !== 0) {
110
- this.fail("Client build failed.");
111
- return clientCode;
112
- }
113
- this.success("Client build complete!");
114
- if (shouldBuildSsr) {
115
- this.info("Building SSR bundle...");
116
- const ssrCode = await this.spawnVite(cwd, configPath, ["build", "--ssr"]);
117
- if (ssrCode !== 0) {
118
- this.fail("SSR build failed.");
119
- return ssrCode;
120
- }
121
- this.success("SSR build complete!");
122
- }
123
- this.success(`Output in ${outDir}/`);
124
- this.info("Deploy with: npx wrangler deploy");
125
- return 0;
126
- }
127
- spawnVite(cwd, configPath, args) {
128
- return new Promise((resolve) => {
129
- const child = spawn("npx", [
130
- "vite",
131
- "--config",
132
- configPath,
133
- ...args
134
- ], {
135
- cwd,
136
- stdio: "inherit",
137
- shell: true
138
- });
139
- child.on("error", (err) => {
140
- this.fail(`Vite process error: ${err.message}`);
141
- resolve(1);
142
- });
143
- child.on("close", (code) => {
144
- resolve(code ?? 0);
145
- });
146
- });
147
- }
148
- };
149
- //#endregion
150
- //#region src/commands/inertia-dev.command.ts
151
- var InertiaDevCommand = class extends Command {
152
- static command = "inertia:dev {--port= : Dev server port} {--host : Expose to network} {--persist-to= : Shared persist directory for @cloudflare/vite-plugin (relative to cwd; the plugin appends /v3). Use to share R2/KV/cache emulator state across multiple workers in dev.}";
153
- static description = "Start Inertia.js Vite development server";
154
- async handle() {
155
- const port = this.number("port");
156
- const host = this.boolean("host");
157
- const persistTo = this.string("persist-to");
158
- const cwd = process.cwd();
159
- if (!existsSync(join(cwd, "src/inertia/app.tsx"))) {
160
- this.fail("src/inertia/app.tsx not found. Run `quarry inertia:install` first.");
161
- return 1;
162
- }
163
- const configPath = writeTempViteConfig({
164
- cwd,
165
- server: {
166
- port,
167
- host
168
- },
169
- persistTo
170
- });
171
- this.info("Starting Vite dev server...");
172
- const args = [
173
- "vite",
174
- "dev",
175
- "--config",
176
- configPath
177
- ];
178
- if (host) args.push("--host");
179
- return new Promise((resolve) => {
180
- const child = spawn("npx", args, {
181
- cwd,
182
- stdio: "inherit",
183
- shell: true
184
- });
185
- child.on("error", (err) => {
186
- this.fail(`Failed to start dev server: ${err.message}`);
187
- resolve(1);
188
- });
189
- child.on("close", (code) => {
190
- resolve(code ?? 0);
191
- });
192
- });
193
- }
194
- };
195
- //#endregion
196
- //#region src/commands/inertia-install.command.ts
197
- const ROOT_HTML = `<!DOCTYPE html>
198
- <html lang="en">
199
- <head>
200
- <meta charset="utf-8" />
201
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
202
- @viteHead
203
- @inertiaHead
204
- </head>
205
- <body>
206
- @inertia
207
- @viteScripts
208
- </body>
209
- </html>`;
210
- const APP_TSX = `import { createInertiaApp } from '@inertiajs/react'
211
-
212
- createInertiaApp({
213
- resolve: async (name) => {
214
- const pages = import.meta.glob('./pages/**/*.tsx')
215
- const page = await pages[\`./pages/\${name}.tsx\`]?.()
216
- if (!page) throw new Error(\`Page not found: \${name}\`)
217
- return page
218
- },
219
- })`;
220
- const HOME_TSX = `export default function Home({ message }: { message: string }) {
221
- return (
222
- <div>
223
- <h1>{message}</h1>
224
- <p>This page is rendered with Inertia.js and Stratal.</p>
225
- </div>
226
- )
227
- }`;
228
- var InertiaInstallCommand = class extends Command {
229
- static command = "inertia:install {--skip-deps : Skip installing npm dependencies}";
230
- static description = "Scaffold Inertia.js files for a Stratal project";
231
- async handle() {
232
- const skipDeps = this.boolean("skip-deps");
233
- const cwd = process.cwd();
234
- const inertiaDir = join(cwd, "src", "inertia");
235
- const pagesDir = join(inertiaDir, "pages");
236
- this.info("Creating src/inertia/ directory...");
237
- mkdirSync(pagesDir, { recursive: true });
238
- const publicDir = join(inertiaDir, "public");
239
- mkdirSync(publicDir, { recursive: true });
240
- const gitkeepPath = join(publicDir, ".gitkeep");
241
- if (!existsSync(gitkeepPath)) writeFileSync(gitkeepPath, "", "utf-8");
242
- this.success("Created src/inertia/public/");
243
- const files = [
244
- {
245
- path: join(inertiaDir, "root.html"),
246
- content: ROOT_HTML,
247
- name: "root.html"
248
- },
249
- {
250
- path: join(inertiaDir, "app.tsx"),
251
- content: APP_TSX,
252
- name: "app.tsx"
253
- },
254
- {
255
- path: join(pagesDir, "Home.tsx"),
256
- content: HOME_TSX,
257
- name: "pages/Home.tsx"
258
- }
259
- ];
260
- for (const file of files) if (existsSync(file.path)) this.warn(`Skipping ${file.name} (already exists)`);
261
- else {
262
- writeFileSync(file.path, file.content, "utf-8");
263
- this.success(`Created src/inertia/${file.name}`);
264
- }
265
- const appModulePath = join(cwd, "src", "app.module.ts");
266
- if (existsSync(appModulePath)) {
267
- this.info("Updating src/app.module.ts...");
268
- try {
269
- if (await this.updateAppModule(appModulePath)) this.success("Updated src/app.module.ts with InertiaModule");
270
- else this.info("InertiaModule already configured in app.module.ts");
271
- } catch (err) {
272
- this.warn(`Could not auto-update app.module.ts: ${err.message}`);
273
- this.info("Please manually add InertiaModule.forRoot() to your module imports");
274
- }
275
- } else this.info("No src/app.module.ts found — please manually configure InertiaModule");
276
- try {
277
- const { outputPath, pageCount } = await runTypeGeneration(cwd);
278
- const relPath = relative(cwd, outputPath);
279
- this.success(`Generated ${relPath} (${pageCount} page${pageCount !== 1 ? "s" : ""})`);
280
- } catch {
281
- this.warn("Could not generate initial type definitions. Run `quarry inertia:types` manually.");
282
- }
283
- if (!skipDeps) {
284
- this.newLine();
285
- this.info("Install the following dependencies:");
286
- this.line(" npm install @stratal/inertia @inertiajs/react @inertiajs/vite react react-dom");
287
- this.line(" npm install -D @types/react @types/react-dom vite @cloudflare/vite-plugin");
288
- }
289
- this.newLine();
290
- this.success("Inertia.js scaffolding complete!");
291
- this.info("Run `quarry inertia:dev` to start the dev server");
292
- return 0;
293
- }
294
- async updateAppModule(modulePath) {
295
- const { Project, SyntaxKind } = await import("ts-morph");
296
- const sourceFile = new Project({ useInMemoryFileSystem: false }).addSourceFileAtPath(modulePath);
297
- if (sourceFile.getImportDeclaration((decl) => decl.getModuleSpecifierValue() === "@stratal/inertia")) return false;
298
- sourceFile.addImportDeclaration({
299
- defaultImport: "rootView",
300
- moduleSpecifier: "./inertia/root.html?raw"
301
- });
302
- sourceFile.addImportDeclaration({
303
- namedImports: ["InertiaModule"],
304
- moduleSpecifier: "@stratal/inertia"
305
- });
306
- const classes = sourceFile.getClasses();
307
- for (const cls of classes) {
308
- const moduleDecorator = cls.getDecorator("Module");
309
- if (!moduleDecorator) continue;
310
- const args = moduleDecorator.getArguments();
311
- if (args.length === 0) continue;
312
- const objLiteral = args[0].asKind(SyntaxKind.ObjectLiteralExpression);
313
- if (!objLiteral) continue;
314
- const importsProp = objLiteral.getProperty("imports");
315
- if (importsProp) {
316
- const arrayLiteral = (importsProp.asKind(SyntaxKind.PropertyAssignment)?.getInitializer())?.asKind(SyntaxKind.ArrayLiteralExpression);
317
- if (arrayLiteral) arrayLiteral.addElement(`InertiaModule.forRoot({\n rootView,\n })`);
318
- } else objLiteral.addPropertyAssignment({
319
- name: "imports",
320
- initializer: `[\n InertiaModule.forRoot({\n rootView,\n }),\n ]`
321
- });
322
- break;
323
- }
324
- await sourceFile.save();
325
- return true;
326
- }
327
- };
328
- //#endregion
329
- //#region src/commands/inertia-types.command.ts
330
- var InertiaTypesCommand = class extends Command {
331
- static command = "inertia:types {--watch : Watch for changes and regenerate}";
332
- static description = "Generate Inertia.js page type definitions";
333
- async handle() {
334
- const cwd = process.cwd();
335
- if (!existsSync(findPagesDir(cwd))) {
336
- this.fail("src/inertia/pages/ not found. Run `quarry inertia:install` first.");
337
- return 1;
338
- }
339
- if (!await this.generate(cwd)) return 1;
340
- if (this.boolean("watch")) {
341
- this.info("Watching for changes...");
342
- await this.watchForChanges(cwd);
343
- }
344
- return 0;
345
- }
346
- async generate(cwd) {
347
- try {
348
- const { outputPath, pageCount } = await runTypeGeneration(cwd);
349
- const relPath = relative(cwd, outputPath);
350
- this.success(`Generated ${relPath} (${pageCount} page${pageCount !== 1 ? "s" : ""})`);
351
- return true;
352
- } catch (err) {
353
- this.fail(`Type generation failed: ${err.message}`);
354
- return false;
355
- }
356
- }
357
- async watchForChanges(cwd) {
358
- const srcDir = join(cwd, "src");
359
- try {
360
- const watcher = watch(srcDir, { recursive: true });
361
- for await (const event of watcher) if (event.filename && /\.(tsx|ts)$/.test(event.filename)) {
362
- this.info(`Change detected: ${event.filename}`);
363
- await this.generate(cwd);
364
- }
365
- } catch (err) {
366
- this.fail(`Watch failed: ${err.message}`);
367
- }
368
- }
369
- };
370
- //#endregion
371
47
  //#region src/inertia.tokens.ts
372
48
  const INERTIA_TOKENS = {
373
49
  Options: Symbol.for("stratal:inertia:options"),
@@ -377,28 +53,16 @@ const INERTIA_TOKENS = {
377
53
  SsrRenderer: Symbol.for("stratal:inertia:ssr-renderer")
378
54
  };
379
55
  //#endregion
380
- //#region \0@oxc-project+runtime@0.127.0/helpers/decorateMetadata.js
381
- function __decorateMetadata(k, v) {
382
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
383
- }
384
- //#endregion
385
- //#region \0@oxc-project+runtime@0.127.0/helpers/decorateParam.js
56
+ //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
386
57
  function __decorateParam(paramIndex, decorator) {
387
58
  return function(target, key) {
388
59
  decorator(target, key, paramIndex);
389
60
  };
390
61
  }
391
62
  //#endregion
392
- //#region \0@oxc-project+runtime@0.127.0/helpers/decorate.js
393
- function __decorate(decorators, target, key, desc) {
394
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
395
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
396
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
397
- return c > 3 && r && Object.defineProperty(target, key, r), r;
398
- }
399
- //#endregion
400
63
  //#region src/middleware/inertia.middleware.ts
401
64
  let InertiaMiddleware = class InertiaMiddleware {
65
+ options;
402
66
  constructor(options) {
403
67
  this.options = options;
404
68
  }
@@ -439,11 +103,7 @@ let InertiaMiddleware = class InertiaMiddleware {
439
103
  }
440
104
  }
441
105
  };
442
- InertiaMiddleware = __decorate([
443
- Transient(),
444
- __decorateParam(0, inject(INERTIA_TOKENS.Options)),
445
- __decorateMetadata("design:paramtypes", [Object])
446
- ], InertiaMiddleware);
106
+ InertiaMiddleware = __decorate([Transient(), __decorateParam(0, inject(INERTIA_TOKENS.Options))], InertiaMiddleware);
447
107
  //#endregion
448
108
  //#region src/types.ts
449
109
  const INERTIA_PROP_OPTIONAL = Symbol.for("stratal:inertia:prop:optional");
@@ -454,6 +114,9 @@ const INERTIA_PROP_ALWAYS = Symbol.for("stratal:inertia:prop:always");
454
114
  //#endregion
455
115
  //#region src/services/inertia.service.ts
456
116
  let InertiaService = class InertiaService {
117
+ options;
118
+ template;
119
+ ssr;
457
120
  sharedData = {};
458
121
  constructor(options, template, ssr) {
459
122
  this.options = options;
@@ -528,6 +191,7 @@ let InertiaService = class InertiaService {
528
191
  version: this.options.version ?? null,
529
192
  flash,
530
193
  rememberedState: {},
194
+ rescuedProps: [],
531
195
  ...result.mergeProps.length > 0 ? { mergeProps: result.mergeProps } : {},
532
196
  ...result.prependProps.length > 0 ? { prependProps: result.prependProps } : {},
533
197
  ...result.deepMergeProps.length > 0 ? { deepMergeProps: result.deepMergeProps } : {},
@@ -540,8 +204,9 @@ let InertiaService = class InertiaService {
540
204
  ...renderOptions.clearHistory ? { clearHistory: true } : {},
541
205
  ...renderOptions.preserveFragment ? { preserveFragment: true } : {}
542
206
  };
207
+ const status = renderOptions.status ?? 200;
543
208
  if (isInertia) return new Response(JSON.stringify(page), {
544
- status: 200,
209
+ status,
545
210
  headers: {
546
211
  "Content-Type": "application/json",
547
212
  "X-Inertia": "true",
@@ -554,7 +219,7 @@ let InertiaService = class InertiaService {
554
219
  } : await this.ssr.render(page);
555
220
  const html = this.template.render(page, ssrResult.head, ssrResult.body);
556
221
  return new Response(html, {
557
- status: 200,
222
+ status,
558
223
  headers: { "Content-Type": "text/html; charset=utf-8" }
559
224
  });
560
225
  }
@@ -614,6 +279,7 @@ let InertiaService = class InertiaService {
614
279
  const partialDataHeader = ctx.header("x-inertia-partial-data");
615
280
  const partialExceptHeader = ctx.header("x-inertia-partial-except");
616
281
  const resetHeader = ctx.header("x-inertia-reset");
282
+ const shouldResolveDeferred = ctx.header("x-inertia-resolve-deferred") === "true";
617
283
  const isPartialReload = isInertia && partialComponent === component && partialDataHeader;
618
284
  const requestedProps = partialDataHeader?.split(",").map((s) => s.trim()) ?? [];
619
285
  const exceptProps = partialExceptHeader?.split(",").map((s) => s.trim()) ?? [];
@@ -636,7 +302,8 @@ let InertiaService = class InertiaService {
636
302
  }
637
303
  if (this.isDeferredProp(value)) {
638
304
  if (isPartialReload && this.isRequested(key, requestedProps)) resolvedProps[key] = await value.callback();
639
- else if (!isPartialReload) {
305
+ else if (!isPartialReload) if (shouldResolveDeferred) resolvedProps[key] = await value.callback();
306
+ else {
640
307
  deferredProps[value.group] ??= [];
641
308
  deferredProps[value.group].push(key);
642
309
  }
@@ -723,15 +390,10 @@ let InertiaService = class InertiaService {
723
390
  }
724
391
  };
725
392
  InertiaService = __decorate([
726
- Transient(INERTIA_TOKENS.InertiaService),
393
+ Request(INERTIA_TOKENS.InertiaService),
727
394
  __decorateParam(0, inject(INERTIA_TOKENS.Options)),
728
395
  __decorateParam(1, inject(INERTIA_TOKENS.TemplateService)),
729
- __decorateParam(2, inject(INERTIA_TOKENS.SsrRenderer)),
730
- __decorateMetadata("design:paramtypes", [
731
- Object,
732
- Object,
733
- Object
734
- ])
396
+ __decorateParam(2, inject(INERTIA_TOKENS.SsrRenderer))
735
397
  ], InertiaService);
736
398
  //#endregion
737
399
  //#region src/services/manifest.service.ts
@@ -739,12 +401,11 @@ const DEFAULT_ENTRY_CLIENT_PATH = "src/inertia/app.tsx";
739
401
  let ManifestService = class ManifestService {
740
402
  manifest;
741
403
  entryClientPath;
404
+ isDev = Boolean(import.meta.env.DEV);
742
405
  constructor(options) {
743
- this.manifest = options.manifest ?? null;
406
+ this.manifest = globalThis.__STRATAL_INERTIA_MANIFEST__ ?? null;
744
407
  this.entryClientPath = (options.entryClientPath ?? DEFAULT_ENTRY_CLIENT_PATH).replace(/^\/+/, "");
745
- }
746
- get isDev() {
747
- return this.manifest === null;
408
+ if (!this.isDev && !this.manifest) throw new Error("@stratal/inertia: production build is missing the Vite client manifest. This is wired by stratalInertia() in vite.config.ts — confirm it is in your plugin list and that the client environment built successfully before the worker environment.");
748
409
  }
749
410
  getHeadTags() {
750
411
  if (this.isDev) return "<link rel=\"stylesheet\" href=\"/__inertia/ssr-css\" data-ssr-css />";
@@ -774,14 +435,12 @@ hot.on("vite:afterUpdate", () => {
774
435
  return tags.join("\n");
775
436
  }
776
437
  };
777
- ManifestService = __decorate([
778
- Transient(),
779
- __decorateParam(0, inject(INERTIA_TOKENS.Options)),
780
- __decorateMetadata("design:paramtypes", [Object])
781
- ], ManifestService);
438
+ ManifestService = __decorate([Transient(), __decorateParam(0, inject(INERTIA_TOKENS.Options))], ManifestService);
782
439
  //#endregion
783
440
  //#region src/services/ssr-renderer.service.ts
784
441
  let SsrRendererService = class SsrRendererService {
442
+ options;
443
+ logger;
785
444
  bundle = null;
786
445
  loadPromise = null;
787
446
  constructor(options, logger) {
@@ -820,14 +479,15 @@ let SsrRendererService = class SsrRendererService {
820
479
  }
821
480
  };
822
481
  SsrRendererService = __decorate([
823
- Transient(),
482
+ Singleton(),
824
483
  __decorateParam(0, inject(INERTIA_TOKENS.Options)),
825
- __decorateParam(1, inject(LOGGER_TOKENS.LoggerService)),
826
- __decorateMetadata("design:paramtypes", [Object, Object])
484
+ __decorateParam(1, inject(LOGGER_TOKENS.LoggerService))
827
485
  ], SsrRendererService);
828
486
  //#endregion
829
487
  //#region src/services/template.service.ts
830
488
  let TemplateService = class TemplateService {
489
+ options;
490
+ manifest;
831
491
  constructor(options, manifest) {
832
492
  this.options = options;
833
493
  this.manifest = manifest;
@@ -851,8 +511,7 @@ let TemplateService = class TemplateService {
851
511
  TemplateService = __decorate([
852
512
  Transient(),
853
513
  __decorateParam(0, inject(INERTIA_TOKENS.Options)),
854
- __decorateParam(1, inject(INERTIA_TOKENS.ManifestService)),
855
- __decorateMetadata("design:paramtypes", [Object, Object])
514
+ __decorateParam(1, inject(INERTIA_TOKENS.ManifestService))
856
515
  ], TemplateService);
857
516
  //#endregion
858
517
  //#region src/inertia.module.ts
@@ -885,7 +544,7 @@ let InertiaModule = _InertiaModule = class InertiaModule {
885
544
  if (context.type !== "http") return void 0;
886
545
  if (this.isPrecognitionRequest(context)) return this.handlePrecognitionValidationError(error, context);
887
546
  if (!this.isInertiaRequest(context)) return void 0;
888
- const issues = error.metadata?.issues ?? [];
547
+ const issues = error.issues ?? [];
889
548
  const errors = {};
890
549
  for (const issue of issues) errors[issue.path] = issue.message;
891
550
  context.ctx.flash("errors", errors);
@@ -893,12 +552,22 @@ let InertiaModule = _InertiaModule = class InertiaModule {
893
552
  });
894
553
  handler.renderable(ApplicationError, (error, context) => {
895
554
  if (context.type !== "http") return void 0;
896
- const message = context.ctx.getContainer().resolve(I18N_TOKENS.I18nService).t(error.message, error.metadata);
555
+ const message = error.message;
897
556
  if (this.isPrecognitionRequest(context)) return this.createPrecognitionErrorResponse({ _form: message });
898
557
  if (!this.isInertiaRequest(context)) return void 0;
899
558
  context.ctx.flash("errors", { _form: message });
900
559
  return this.redirectBack(context);
901
560
  });
561
+ handler.errorPage(async (errorResponse, status, context) => {
562
+ try {
563
+ return await context.ctx.getContainer().resolve(INERTIA_TOKENS.InertiaService).render(context.ctx, `Errors/${status}`, {
564
+ status,
565
+ message: errorResponse.message
566
+ }, { status });
567
+ } catch {
568
+ return;
569
+ }
570
+ });
902
571
  }
903
572
  onInitialize() {
904
573
  augmentRouterContext((ctx) => {
@@ -912,7 +581,7 @@ let InertiaModule = _InertiaModule = class InertiaModule {
912
581
  return context.ctx.header("precognition") === "true";
913
582
  }
914
583
  handlePrecognitionValidationError(error, context) {
915
- const issues = error.metadata?.issues ?? [];
584
+ const issues = error.issues ?? [];
916
585
  let errors = {};
917
586
  for (const issue of issues) errors[issue.path] = issue.message;
918
587
  const validateOnly = context.ctx.header("precognition-validate-only");
@@ -955,8 +624,7 @@ let InertiaModule = _InertiaModule = class InertiaModule {
955
624
  InertiaModule = _InertiaModule = __decorate([Module({ providers: [
956
625
  {
957
626
  provide: INERTIA_TOKENS.InertiaService,
958
- useClass: InertiaService,
959
- scope: Scope.Request
627
+ useClass: InertiaService
960
628
  },
961
629
  {
962
630
  provide: INERTIA_TOKENS.TemplateService,
@@ -968,13 +636,8 @@ InertiaModule = _InertiaModule = __decorate([Module({ providers: [
968
636
  },
969
637
  {
970
638
  provide: INERTIA_TOKENS.SsrRenderer,
971
- useClass: SsrRendererService,
972
- scope: Scope.Singleton
973
- },
974
- InertiaInstallCommand,
975
- InertiaTypesCommand,
976
- InertiaDevCommand,
977
- InertiaBuildCommand
639
+ useClass: SsrRendererService
640
+ }
978
641
  ] })], InertiaModule);
979
642
  //#endregion
980
643
  //#region src/flash/cookie-flash-store.ts
@@ -1166,6 +829,6 @@ let HandlePrecognitiveRequests = class HandlePrecognitiveRequests {
1166
829
  };
1167
830
  HandlePrecognitiveRequests = __decorate([Transient()], HandlePrecognitiveRequests);
1168
831
  //#endregion
1169
- export { CookieFlashStore, HandlePrecognitiveRequests, INERTIA_TOKENS, InertiaBuildCommand, InertiaDelete, InertiaDevCommand, InertiaGet, InertiaInstallCommand, InertiaMiddleware, InertiaModule, InertiaPatch, InertiaPost, InertiaPut, InertiaRoute, InertiaService, InertiaTypesCommand, ManifestService, SsrRendererService, TemplateService, runTypeGeneration };
832
+ export { CookieFlashStore, HandlePrecognitiveRequests, INERTIA_TOKENS, InertiaDelete, InertiaGet, InertiaMiddleware, InertiaModule, InertiaPatch, InertiaPost, InertiaPut, InertiaRoute, InertiaService, ManifestService, SsrRendererService, TemplateService };
1170
833
 
1171
834
  //# sourceMappingURL=index.mjs.map