@guren/server 1.1.0 → 1.2.0

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.
@@ -91,6 +91,8 @@ interface InertiaOptions {
91
91
  readonly headers?: HeadersInit;
92
92
  readonly request?: Request;
93
93
  readonly title?: string;
94
+ /** Value for the root `<html lang>` attribute. Defaults to "en". */
95
+ readonly lang?: string;
94
96
  readonly entry?: string;
95
97
  readonly importMap?: Record<string, string>;
96
98
  readonly styles?: string[];
@@ -1334,6 +1336,7 @@ type InertiaPageProps<TPage extends InertiaPageContractLike> = NonNullable<TPage
1334
1336
  * ```
1335
1337
  */
1336
1338
  declare class Controller {
1339
+ #private;
1337
1340
  /**
1338
1341
  * Dependencies to inject from the container.
1339
1342
  * Override in subclasses to declare required services.
@@ -1,4 +1,4 @@
1
- import { C as Container } from './Application-BnsyCKXY.js';
1
+ import { C as Container } from './Application-DN9Ndl37.js';
2
2
 
3
3
  /**
4
4
  * Parsed argument definition.
@@ -6,7 +6,7 @@ import standard from "figlet/importable-fonts/Standard.js";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@guren/server",
9
- version: "1.1.0",
9
+ version: "1.2.0",
10
10
  type: "module",
11
11
  license: "MIT",
12
12
  repository: {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-BnsyCKXY.js';
2
- export { A as Application, d as ApplicationListenOptions, e as ApplicationOptions, f as AuthPayload, g as AuthPluginOptions, h as CSRF_FORM_FIELD, i as CSRF_HEADER_NAME, j as CSRF_TOKEN_KEY, P as ContainerProvider, k as ContextualBinding, m as ContextualBindingBuilder, n as ContextualNeedsBuilder, o as Controller, p as ControllerInertiaProps, q as CsrfOptions, r as DatabaseChannelOptions, t as DatabaseNotification, u as ExceptionClass, v as ExceptionHandler, w as ExceptionHandlerOptions, x as ExceptionRenderer, y as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, z as HstsOptions, I as InertiaOptions, B as InertiaPagePayload, J as InertiaResponse, K as InertiaSharedProps, L as InertiaSsrContext, M as InertiaSsrOptions, O as InertiaSsrRenderer, R as InertiaSsrResult, T as InferInertiaProps, U as Job, V as JobClass, W as JobFailureHandler, X as JobHandler, Y as JobOptions, Z as Notifiable, _ as Notification, $ as NotificationAttachment, a0 as NotificationChannel, a1 as NotificationChannelFactory, a2 as NotificationClass, a3 as NotificationMailMessage, a4 as NotificationManagerOptions, a5 as ProviderManager, a6 as QueueConfig, a7 as QueueDriver, a8 as QueueDriverFactory, a9 as QueuedJob, aa as RendererRegistration, ab as ResolvedSharedInertiaProps, ac as ResourceRouteOptions, ad as RouteBuilder, ae as RouteContractOptions, af as RouteDefinition, ag as RouteOpenApiMetadata, ah as RouteResourceAction, ai as Router, aj as SecurityHeadersOptions, ak as SentNotification, al as ServiceBinding, am as ServiceClass, an as ServiceFactory, ao as ServiceProviderClass, ap as ServiceProviderConstructor, aq as ServiceProviderOptions, ar as SharedInertiaPropsResolver, as as SlackAttachment, at as SlackBlock, au as SlackMessage, av as VALIDATED_DATA_KEY, aw as ValidateRequestOptions, ax as ValidationSchema, ay as WorkerOptions, az as abort, aA as abortIf, aB as abortUnless, aC as clearJobRegistry, aD as createApp, aE as createContainer, aF as createCsrfMiddleware, aG as createExceptionHandler, aH as createHostAuthorizationMiddleware, aI as createNotificationManager, aJ as createQueueManager, aK as createSecurityHeaders, aL as csrfField, aM as formatValidationErrors, aN as getContainer, aO as getCsrfToken, aP as getExceptionHandler, aQ as getInertiaSharedPropsResolver, aR as getJob, aS as getNotificationManager, aT as getQueueDriver, aU as getRegisteredJobs, aV as getValidatedData, aW as inertia, aX as parseRequestPayload, aY as registerJob, aZ as resolve, a_ as setContainer, a$ as setExceptionHandler, b0 as setInertiaSharedProps, b1 as setNotificationManager, b2 as setQueueDriver, b3 as shareInertiaProps, b4 as validate, b5 as validateRequest, b6 as validateRequestWith, b7 as validateSafe, b8 as verifyCsrfToken } from './Application-BnsyCKXY.js';
1
+ import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-DN9Ndl37.js';
2
+ export { A as Application, d as ApplicationListenOptions, e as ApplicationOptions, f as AuthPayload, g as AuthPluginOptions, h as CSRF_FORM_FIELD, i as CSRF_HEADER_NAME, j as CSRF_TOKEN_KEY, P as ContainerProvider, k as ContextualBinding, m as ContextualBindingBuilder, n as ContextualNeedsBuilder, o as Controller, p as ControllerInertiaProps, q as CsrfOptions, r as DatabaseChannelOptions, t as DatabaseNotification, u as ExceptionClass, v as ExceptionHandler, w as ExceptionHandlerOptions, x as ExceptionRenderer, y as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, z as HstsOptions, I as InertiaOptions, B as InertiaPagePayload, J as InertiaResponse, K as InertiaSharedProps, L as InertiaSsrContext, M as InertiaSsrOptions, O as InertiaSsrRenderer, R as InertiaSsrResult, T as InferInertiaProps, U as Job, V as JobClass, W as JobFailureHandler, X as JobHandler, Y as JobOptions, Z as Notifiable, _ as Notification, $ as NotificationAttachment, a0 as NotificationChannel, a1 as NotificationChannelFactory, a2 as NotificationClass, a3 as NotificationMailMessage, a4 as NotificationManagerOptions, a5 as ProviderManager, a6 as QueueConfig, a7 as QueueDriver, a8 as QueueDriverFactory, a9 as QueuedJob, aa as RendererRegistration, ab as ResolvedSharedInertiaProps, ac as ResourceRouteOptions, ad as RouteBuilder, ae as RouteContractOptions, af as RouteDefinition, ag as RouteOpenApiMetadata, ah as RouteResourceAction, ai as Router, aj as SecurityHeadersOptions, ak as SentNotification, al as ServiceBinding, am as ServiceClass, an as ServiceFactory, ao as ServiceProviderClass, ap as ServiceProviderConstructor, aq as ServiceProviderOptions, ar as SharedInertiaPropsResolver, as as SlackAttachment, at as SlackBlock, au as SlackMessage, av as VALIDATED_DATA_KEY, aw as ValidateRequestOptions, ax as ValidationSchema, ay as WorkerOptions, az as abort, aA as abortIf, aB as abortUnless, aC as clearJobRegistry, aD as createApp, aE as createContainer, aF as createCsrfMiddleware, aG as createExceptionHandler, aH as createHostAuthorizationMiddleware, aI as createNotificationManager, aJ as createQueueManager, aK as createSecurityHeaders, aL as csrfField, aM as formatValidationErrors, aN as getContainer, aO as getCsrfToken, aP as getExceptionHandler, aQ as getInertiaSharedPropsResolver, aR as getJob, aS as getNotificationManager, aT as getQueueDriver, aU as getRegisteredJobs, aV as getValidatedData, aW as inertia, aX as parseRequestPayload, aY as registerJob, aZ as resolve, a_ as setContainer, a$ as setExceptionHandler, b0 as setInertiaSharedProps, b1 as setNotificationManager, b2 as setQueueDriver, b3 as shareInertiaProps, b4 as validate, b5 as validateRequest, b6 as validateRequestWith, b7 as validateSafe, b8 as verifyCsrfToken } from './Application-DN9Ndl37.js';
3
3
  import * as hono from 'hono';
4
4
  import { Context, MiddlewareHandler } from 'hono';
5
5
  export { Context } from 'hono';
@@ -38,8 +38,8 @@ export { DatabaseChannel, MailChannel, MailChannelOptions, MemoryChannel, SlackC
38
38
  import { B as BroadcastManager } from './BroadcastManager-CGWl9rUO.js';
39
39
  export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, c as BroadcastEvent, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, P as PresenceBroadcastDriver, h as PresenceChannel, i as PresenceChannelAuthorizer, j as PresenceMember, k as PrivateChannel, S as SSEClient, l as SSEMiddlewareOptions, W as WebSocketClient, m as createBroadcastManager, n as getBroadcastManager, s as setBroadcastManager } from './BroadcastManager-CGWl9rUO.js';
40
40
  export { RedisClient as BroadcastRedisClient, RedisDriverOptions as BroadcastRedisDriverOptions, MemoryDriver as MemoryBroadcastDriver, RedisDriver as RedisBroadcastDriver, createTypedBroadcaster } from './broadcasting/index.js';
41
- import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-BDtBETjm.js';
42
- export { A as ArgumentDefinition, c as CommandClass, C as ConsoleKernel, d as ConsoleKernelOptions, e as ProgressInterface, f as PromptInterface, S as ScheduledCommand, g as createConsoleKernel } from './ConsoleKernel-BDtBETjm.js';
41
+ import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-DxmUxdAz.js';
42
+ export { A as ArgumentDefinition, c as CommandClass, C as ConsoleKernel, d as ConsoleKernelOptions, e as ProgressInterface, f as PromptInterface, S as ScheduledCommand, g as createConsoleKernel } from './ConsoleKernel-DxmUxdAz.js';
43
43
  import * as readline from 'readline';
44
44
  export { R as AuthResponse, A as AuthUser, a as AuthorizationResponse, b as AuthorizeOptions, G as Gate, c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, f as PolicyInterface, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, j as ResponseBuilder, k as authorizeAbility, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from './Gate-CynjZCtS.js';
45
45
  export { AuthorizedContext, Policy, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, definePolicy, withAuthorization } from './authorization/index.js';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  logDevServerBanner,
3
3
  parseImportMap,
4
4
  startViteDevServer
5
- } from "./chunk-QH4NUKSV.js";
5
+ } from "./chunk-HLXL2AYJ.js";
6
6
  import {
7
7
  PendingSchedule,
8
8
  Schedule,
@@ -1803,8 +1803,9 @@ async function renderDocument(page, options) {
1803
1803
  const appMarkup = ssrResult?.body ?? `<script data-page="app" type="application/json">${serializedPage}</script><div id="app"></div>`;
1804
1804
  const bodyClass = resolveBodyClass(page.component);
1805
1805
  const bodyAttributes = bodyClass ? ` class="${escapeAttribute(bodyClass)}"` : "";
1806
+ const lang = escapeAttribute(options.lang ?? "en");
1806
1807
  return `<!DOCTYPE html>
1807
- <html lang="en">
1808
+ <html lang="${lang}">
1808
1809
  <head>
1809
1810
  ${headSegments.join("\n ")}
1810
1811
  </head>
@@ -2603,6 +2604,7 @@ var Controller = class {
2603
2604
  const propsWithShared = { ...sharedProps, ...props };
2604
2605
  const response = await inertia(component, propsWithShared, {
2605
2606
  ...rest,
2607
+ lang: rest.lang ?? this.#defaultInertiaLang(),
2606
2608
  url: url2,
2607
2609
  request: ctx.req.raw
2608
2610
  });
@@ -2612,6 +2614,27 @@ var Controller = class {
2612
2614
  };
2613
2615
  return response;
2614
2616
  }
2617
+ /**
2618
+ * Default `<html lang>` for Inertia responses when `options.lang` is not
2619
+ * provided: the request-scoped `locale` context variable (set by locale
2620
+ * middleware) wins over the app-wide i18n locale.
2621
+ */
2622
+ #defaultInertiaLang() {
2623
+ const vars = this.ctx.var;
2624
+ const requestLocale = vars?.locale;
2625
+ if (typeof requestLocale === "string" && requestLocale.length > 0) {
2626
+ return requestLocale;
2627
+ }
2628
+ const container = vars?.container;
2629
+ if (container?.has?.("i18n")) {
2630
+ const i18n = container.make?.("i18n");
2631
+ const locale = i18n?.getLocale?.();
2632
+ if (typeof locale === "string" && locale.length > 0) {
2633
+ return locale;
2634
+ }
2635
+ }
2636
+ return void 0;
2637
+ }
2615
2638
  json(data, init = {}) {
2616
2639
  return new Response(JSON.stringify(data), {
2617
2640
  ...init,
@@ -1,8 +1,8 @@
1
1
  import * as hono_aws_lambda from 'hono/aws-lambda';
2
2
  export { APIGatewayProxyResult, LambdaEvent } from 'hono/aws-lambda';
3
- import { A as Application } from '../Application-BnsyCKXY.js';
3
+ import { A as Application } from '../Application-DN9Ndl37.js';
4
4
  import { S as Scheduler } from '../Scheduler-BstvSca7.js';
5
- import { C as ConsoleKernel } from '../ConsoleKernel-BDtBETjm.js';
5
+ import { C as ConsoleKernel } from '../ConsoleKernel-DxmUxdAz.js';
6
6
  import 'hono';
7
7
  import '../api-token-BSSCLlFW.js';
8
8
  import '../AuthManager-SfhCNkAU.js';
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { S as ServiceProvider } from '../Application-BnsyCKXY.js';
2
+ import { S as ServiceProvider } from '../Application-DN9Ndl37.js';
3
3
  import 'hono';
4
4
  import '../api-token-BSSCLlFW.js';
5
5
  import '../AuthManager-SfhCNkAU.js';
@@ -1,5 +1,5 @@
1
- import { a0 as NotificationChannel, Z as Notifiable, _ as Notification, t as DatabaseNotification, r as DatabaseChannelOptions, au as SlackMessage, ak as SentNotification } from '../Application-BnsyCKXY.js';
2
- export { $ as NotificationAttachment, a1 as NotificationChannelFactory, a2 as NotificationClass, a3 as NotificationMailMessage, N as NotificationManager, a4 as NotificationManagerOptions, as as SlackAttachment, at as SlackBlock, aI as createNotificationManager, aS as getNotificationManager, b1 as setNotificationManager } from '../Application-BnsyCKXY.js';
1
+ import { a0 as NotificationChannel, Z as Notifiable, _ as Notification, t as DatabaseNotification, r as DatabaseChannelOptions, au as SlackMessage, ak as SentNotification } from '../Application-DN9Ndl37.js';
2
+ export { $ as NotificationAttachment, a1 as NotificationChannelFactory, a2 as NotificationClass, a3 as NotificationMailMessage, N as NotificationManager, a4 as NotificationManagerOptions, as as SlackAttachment, at as SlackBlock, aI as createNotificationManager, aS as getNotificationManager, b1 as setNotificationManager } from '../Application-DN9Ndl37.js';
3
3
  import { M as MailManager } from '../MailManager-DpMvYiP9.js';
4
4
  import 'hono';
5
5
  import '../api-token-BSSCLlFW.js';
@@ -1,5 +1,5 @@
1
- import { a7 as QueueDriver, a9 as QueuedJob, F as FailedJob, ay as WorkerOptions } from '../Application-BnsyCKXY.js';
2
- export { U as Job, V as JobClass, W as JobFailureHandler, X as JobHandler, Y as JobOptions, a6 as QueueConfig, a8 as QueueDriverFactory, Q as QueueManager, aC as clearJobRegistry, aJ as createQueueManager, aR as getJob, aT as getQueueDriver, aU as getRegisteredJobs, aY as registerJob, b2 as setQueueDriver } from '../Application-BnsyCKXY.js';
1
+ import { a7 as QueueDriver, a9 as QueuedJob, F as FailedJob, ay as WorkerOptions } from '../Application-DN9Ndl37.js';
2
+ export { U as Job, V as JobClass, W as JobFailureHandler, X as JobHandler, Y as JobOptions, a6 as QueueConfig, a8 as QueueDriverFactory, Q as QueueManager, aC as clearJobRegistry, aJ as createQueueManager, aR as getJob, aT as getQueueDriver, aU as getRegisteredJobs, aY as registerJob, b2 as setQueueDriver } from '../Application-DN9Ndl37.js';
3
3
  import { Redis } from 'ioredis';
4
4
  import 'hono';
5
5
  import '../api-token-BSSCLlFW.js';
@@ -1,5 +1,5 @@
1
- import { A as Application } from '../Application-BnsyCKXY.js';
2
- export { D as DevBannerOptions, G as GUREN_ASCII_ART, a as StartViteDevServerOptions, b as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-BnsyCKXY.js';
1
+ import { A as Application } from '../Application-DN9Ndl37.js';
2
+ export { D as DevBannerOptions, G as GUREN_ASCII_ART, a as StartViteDevServerOptions, b as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-DN9Ndl37.js';
3
3
  import 'hono';
4
4
  import '../api-token-BSSCLlFW.js';
5
5
  import '../AuthManager-SfhCNkAU.js';
@@ -3,7 +3,7 @@ import {
3
3
  logDevServerBanner,
4
4
  parseImportMap,
5
5
  startViteDevServer
6
- } from "../chunk-QH4NUKSV.js";
6
+ } from "../chunk-HLXL2AYJ.js";
7
7
  import {
8
8
  hash
9
9
  } from "../chunk-QQKTH5KX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/server",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {