@guren/server 2.19.0 → 2.21.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.
@@ -1,5 +1,5 @@
1
- import { r as getJob } from "../Job-CvDwk2Gj.js";
2
1
  import { n as detectServerlessRuntime } from "../serverless-D96rJb6x.js";
2
+ import { r as getJob } from "../Job-CvDwk2Gj.js";
3
3
  import { handle } from "hono/aws-lambda";
4
4
  //#region src/lambda/index.ts
5
5
  /** Create an AWS Lambda handler from an already booted Guren application. */
@@ -60,9 +60,9 @@ function getLambdaContext() {
60
60
  if (!isLambda()) return null;
61
61
  return {
62
62
  functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
63
- functionVersion: process.env.AWS_LAMBDA_FUNCTION_VERSION ?? "$LATEST",
64
- memorySize: parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE ?? "128", 10),
65
- region: process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION ?? "us-east-1",
63
+ functionVersion: process.env.AWS_LAMBDA_FUNCTION_VERSION || "$LATEST",
64
+ memorySize: parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || "128", 10),
65
+ region: process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || "us-east-1",
66
66
  logGroup: process.env.AWS_LAMBDA_LOG_GROUP_NAME,
67
67
  logStream: process.env.AWS_LAMBDA_LOG_STREAM_NAME,
68
68
  tmpDir: "/tmp"
@@ -1,2 +1,3 @@
1
- import { a as DailyFileChannel, c as matchDailyFileDate, d as LOG_LEVEL_PRIORITY, f as Logger, i as setLogManager, l as FileChannel, n as createLogManager, o as dailyFileDateStamp, p as filterSensitiveData, r as getLogManager, s as dailyFilePath, t as LogManager, u as ConsoleChannel } from "../logging-DcvkE5Dh.js";
1
+ import { n as filterSensitiveData, t as Logger } from "../Logger-DFifRAtc.js";
2
+ import { a as DailyFileChannel, c as matchDailyFileDate, d as LOG_LEVEL_PRIORITY, i as setLogManager, l as FileChannel, n as createLogManager, o as dailyFileDateStamp, r as getLogManager, s as dailyFilePath, t as LogManager, u as ConsoleChannel } from "../logging-DXmqqUl4.js";
2
3
  export { ConsoleChannel, DailyFileChannel, FileChannel, LOG_LEVEL_PRIORITY, LogManager, Logger, createLogManager, dailyFileDateStamp, dailyFilePath, filterSensitiveData, getLogManager, matchDailyFileDate, setLogManager };
@@ -1,118 +1,6 @@
1
+ import { r as isPromiseLike, t as Logger } from "./Logger-DFifRAtc.js";
1
2
  import * as path$1 from "node:path";
2
3
  import * as fs from "node:fs";
3
- //#region src/logging/Logger.ts
4
- const DEFAULT_FILTER_KEYS = [
5
- "password",
6
- "password_confirmation",
7
- "token",
8
- "secret",
9
- "credit_card",
10
- "creditCard",
11
- "card_number",
12
- "cardNumber",
13
- "cvv",
14
- "ssn",
15
- "authorization"
16
- ];
17
- /** Recursively replace values of sensitive keys in a log context object. */
18
- function filterSensitiveData(data, filterKeys, replacement = "[FILTERED]") {
19
- if (filterKeys.length === 0) return data;
20
- return filterObject(data, new Set(filterKeys.map((k) => k.toLowerCase())), replacement);
21
- }
22
- function filterObject(obj, keySet, replacement) {
23
- const result = {};
24
- for (const [key, value] of Object.entries(obj)) if (keySet.has(key.toLowerCase())) result[key] = replacement;
25
- else if (value !== null && typeof value === "object" && !Array.isArray(value)) result[key] = filterObject(value, keySet, replacement);
26
- else if (Array.isArray(value)) result[key] = value.map((item) => item !== null && typeof item === "object" && !Array.isArray(item) ? filterObject(item, keySet, replacement) : item);
27
- else result[key] = value;
28
- return result;
29
- }
30
- const reportLoggingError = (error) => {
31
- console.error("Logging error:", error);
32
- };
33
- /**
34
- * Whether a channel's `log()` handed back something to wait on. A duck-typed
35
- * check rather than `instanceof Promise`: a promise created in another realm
36
- * (a `node:vm` context, a worker's module graph) satisfies the channel
37
- * contract and would otherwise slip past the reporter as an unhandled rejection.
38
- */
39
- function isPromiseLike(value) {
40
- return typeof value === "object" && value !== null && typeof value.then === "function";
41
- }
42
- /** Logger instance for writing log entries. */
43
- var Logger = class Logger {
44
- channels;
45
- baseContext;
46
- filterKeys;
47
- replacement;
48
- constructor(channels, context = {}, options = {}) {
49
- this.channels = channels;
50
- this.baseContext = context;
51
- this.filterKeys = options.filterKeys ?? DEFAULT_FILTER_KEYS;
52
- this.replacement = options.replacement ?? "[FILTERED]";
53
- }
54
- emergency(message, context = {}) {
55
- this.log("emergency", message, context);
56
- }
57
- alert(message, context = {}) {
58
- this.log("alert", message, context);
59
- }
60
- critical(message, context = {}) {
61
- this.log("critical", message, context);
62
- }
63
- error(message, context = {}) {
64
- this.log("error", message, context);
65
- }
66
- warning(message, context = {}) {
67
- this.log("warning", message, context);
68
- }
69
- warn(message, context = {}) {
70
- this.warning(message, context);
71
- }
72
- notice(message, context = {}) {
73
- this.log("notice", message, context);
74
- }
75
- info(message, context = {}) {
76
- this.log("info", message, context);
77
- }
78
- debug(message, context = {}) {
79
- this.log("debug", message, context);
80
- }
81
- log(level, message, context = {}) {
82
- const merged = {
83
- ...this.baseContext,
84
- ...context
85
- };
86
- const entry = {
87
- level,
88
- message,
89
- context: this.filterKeys.length > 0 ? filterSensitiveData(merged, this.filterKeys, this.replacement) : merged,
90
- timestamp: /* @__PURE__ */ new Date()
91
- };
92
- for (const channel of this.channels) try {
93
- const pending = channel.log(entry);
94
- if (isPromiseLike(pending)) Promise.resolve(pending).catch(reportLoggingError);
95
- } catch (error) {
96
- reportLoggingError(error);
97
- }
98
- }
99
- withContext(context) {
100
- return new Logger(this.channels, {
101
- ...this.baseContext,
102
- ...context
103
- }, {
104
- filterKeys: this.filterKeys,
105
- replacement: this.replacement
106
- });
107
- }
108
- child(context) {
109
- return this.withContext(context);
110
- }
111
- async close() {
112
- for (const channel of this.channels) if (channel.close) await channel.close();
113
- }
114
- };
115
- //#endregion
116
4
  //#region src/logging/types.ts
117
5
  /** Log level priority (lower = more severe). */
118
6
  const LOG_LEVEL_PRIORITY = {
@@ -469,4 +357,4 @@ function getLogManager() {
469
357
  return globalLogManager;
470
358
  }
471
359
  //#endregion
472
- export { DailyFileChannel as a, matchDailyFileDate as c, LOG_LEVEL_PRIORITY as d, Logger as f, setLogManager as i, FileChannel as l, isPromiseLike as m, createLogManager as n, dailyFileDateStamp as o, filterSensitiveData as p, getLogManager as r, dailyFilePath as s, LogManager as t, ConsoleChannel as u };
360
+ export { DailyFileChannel as a, matchDailyFileDate as c, LOG_LEVEL_PRIORITY as d, setLogManager as i, FileChannel as l, createLogManager as n, dailyFileDateStamp as o, getLogManager as r, dailyFilePath as s, LogManager as t, ConsoleChannel as u };
@@ -3,6 +3,7 @@ import { Controller } from './Controller.js';
3
3
  import type { Container } from '../container/Container.js';
4
4
  import type { ValidationSchema } from '../http/middleware/validation.js';
5
5
  import { type MiddlewareCapabilities } from '../http/middleware/capabilities.js';
6
+ import { type PrototypeRouteHandler } from './prototype.js';
6
7
  /** Constructor type for Controller classes. */
7
8
  export type ControllerConstructor<T extends Controller = Controller> = (new (...args: any[]) => T) & {
8
9
  inject?: readonly string[];
@@ -17,7 +18,7 @@ export type RouteResult = Response | string | number | boolean | Record<string,
17
18
  * Inline handlers receive `next`, so Hono middleware (e.g.
18
19
  * `broadcast.sseMiddleware()`) can mount directly as a terminal handler.
19
20
  */
20
- export type RouteHandler<C extends ControllerConstructor = ControllerConstructor> = ((c: Context, next: Next) => RouteResult | Promise<RouteResult>) | ControllerAction<C>;
21
+ export type RouteHandler<C extends ControllerConstructor = ControllerConstructor> = ((c: Context, next: Next) => RouteResult | Promise<RouteResult>) | ControllerAction<C> | PrototypeRouteHandler;
21
22
  type ModelBindingResolver = (value: string) => Promise<unknown>;
22
23
  /** Model class with a findOrFail static method. */
23
24
  export interface BindableModel {
@@ -158,6 +159,8 @@ export interface RouteDefinition {
158
159
  bindings?: Record<string, string>;
159
160
  /** Agent metadata as declared (RFC 0016), no defaults applied. Absent: not a tool. */
160
161
  agent?: AgentRouteMetadata;
162
+ /** Still on its fixture (RFC 0021): registered with the `prototype` handler rather than a controller. */
163
+ prototype?: true;
161
164
  summary?: string;
162
165
  description?: string;
163
166
  tags?: string[];
@@ -222,22 +225,22 @@ export declare class Router<M extends string = never> {
222
225
  bind(param: string, modelOrResolver: RouteModelBinding | ModelBindingResolver): this;
223
226
  on<C extends ControllerConstructor>(method: string, path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
224
227
  on<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
225
- on<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
228
+ on<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
226
229
  get<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
227
230
  get<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
228
- get<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
231
+ get<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
229
232
  post<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
230
233
  post<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
231
- post<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
234
+ post<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
232
235
  put<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
233
236
  put<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
234
- put<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
237
+ put<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
235
238
  patch<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
236
239
  patch<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
237
- patch<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
240
+ patch<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
238
241
  delete<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
239
242
  delete<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
240
- delete<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
243
+ delete<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
241
244
  /**
242
245
  * HTTP QUERY (RFC 10008): safe and idempotent like GET, but carries a body.
243
246
  * Handlers must not mutate state — CSRF protection deliberately skips QUERY
@@ -245,7 +248,7 @@ export declare class Router<M extends string = never> {
245
248
  */
246
249
  query<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
247
250
  query<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
248
- query<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
251
+ query<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
249
252
  group(prefix: string, callback: (router: Router<M>) => void): this;
250
253
  route(name: string, params?: Record<string, string | number>): string;
251
254
  hasRoute(name: string): boolean;
@@ -273,24 +276,24 @@ declare class RouterMiddlewareGroupBuilder<M extends string = never> {
273
276
  group(callback: (router: Router<M>) => void): Router<M>;
274
277
  get<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
275
278
  get<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
276
- get<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
279
+ get<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
277
280
  post<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
278
281
  post<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
279
- post<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
282
+ post<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
280
283
  put<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
281
284
  put<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
282
- put<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
285
+ put<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
283
286
  patch<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
284
287
  patch<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
285
- patch<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
288
+ patch<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
286
289
  delete<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
287
290
  delete<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
288
- delete<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
291
+ delete<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
289
292
  query<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
290
293
  query<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
291
- query<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
294
+ query<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
292
295
  on<C extends ControllerConstructor>(method: string, path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): RouteBuilder<M>;
293
296
  on<TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: TypedRouteHandler<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>): RouteBuilder<M>;
294
- on<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C>): RouteBuilder<M>;
297
+ on<C extends ControllerConstructor, TParamsSchema extends SchemaLike<unknown>, TQuerySchema extends SchemaLike<unknown>, TBodySchema extends SchemaLike<unknown>, TOutputSchema extends SchemaLike<unknown>>(method: string, path: string, options: RouteContractOptions<TParamsSchema, TQuerySchema, TBodySchema, TOutputSchema>, handler: ControllerAction<C> | PrototypeRouteHandler): RouteBuilder<M>;
295
298
  }
296
299
  export {};
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Server side of prototype mode (RFC 0021 Part 2): a route registered with the
3
+ * `prototype` handler answers from the app's fixture module until a
4
+ * controller replaces it. Development only; `Application` refuses to boot such
5
+ * routes in production without `GUREN_PROTOTYPE_ROUTES=1`. The fixture
6
+ * contract is consumed structurally, so this never imports the client package.
7
+ */
8
+ import type { Context } from 'hono';
9
+ import type { ValidationSchema } from '../http/middleware/validation.js';
10
+ import type { ContainerLike } from '../container/types.js';
11
+ declare const PROTOTYPE_HANDLER: unique symbol;
12
+ /** The branded object `router.get(path, prototype)` registers; never a function, so contract wrapping cannot hide it. */
13
+ export interface PrototypeRouteHandler {
14
+ readonly [PROTOTYPE_HANDLER]: true;
15
+ }
16
+ export declare const prototype: PrototypeRouteHandler;
17
+ export declare function isPrototypeHandler(value: unknown): value is PrototypeRouteHandler;
18
+ export type PrototypeResult = {
19
+ kind: 'page';
20
+ component: string;
21
+ props: Record<string, unknown>;
22
+ } | {
23
+ kind: 'redirect';
24
+ to: string;
25
+ params?: Record<string, string | number>;
26
+ } | {
27
+ kind: 'location';
28
+ url: string;
29
+ } | {
30
+ kind: 'errors';
31
+ errors: Record<string, string>;
32
+ } | {
33
+ kind: 'not-found';
34
+ };
35
+ export interface PrototypeServerContext {
36
+ method: string;
37
+ url: string;
38
+ params: Record<string, string>;
39
+ query: Record<string, unknown>;
40
+ /** The raw request body, as the browser client hands it over; the route's schema has already validated it. */
41
+ body: unknown;
42
+ state: unknown;
43
+ shared: Record<string, unknown>;
44
+ page(contract: {
45
+ id: string;
46
+ component?: string;
47
+ }, props: Record<string, unknown>): PrototypeResult;
48
+ redirect(to: string, params?: Record<string, string | number>): PrototypeResult;
49
+ location(url: string): PrototypeResult;
50
+ /** No error bag: the framework's `ValidationException` has none, so the client-side `bag` is ignored here. */
51
+ errors(errors: Record<string, string>): PrototypeResult;
52
+ notFound(): PrototypeResult;
53
+ flash(key: string, value: unknown): void;
54
+ }
55
+ export type PrototypeServerHandler = (ctx: PrototypeServerContext) => PrototypeResult | Promise<PrototypeResult>;
56
+ /**
57
+ * What `definePrototype()` from `@guren/inertia-client/prototype` produces,
58
+ * seen from the server. Handlers are accepted at `(ctx: never) => unknown`:
59
+ * the client types each one against its own manifest and page contracts,
60
+ * which is contravariant with any concrete context declared here, and the
61
+ * runtime hands over {@link PrototypeServerContext} and checks the result's `kind`.
62
+ */
63
+ export interface PrototypeFixture {
64
+ manifest: Record<string, {
65
+ method: string;
66
+ path: string;
67
+ }>;
68
+ shared?: Record<string, unknown>;
69
+ state?: () => unknown;
70
+ notFoundPage?: {
71
+ id: string;
72
+ component?: string;
73
+ };
74
+ routes: Record<string, ((ctx: never) => unknown) | undefined>;
75
+ }
76
+ export type PrototypeFixtureModule = {
77
+ default: PrototypeFixture;
78
+ } | PrototypeFixture;
79
+ export type PrototypeFixtureLoader = () => Promise<PrototypeFixtureModule>;
80
+ /** Container key the loaded fixture is bound under once `Application` has validated the prototype routes. */
81
+ export declare const PROTOTYPE_FIXTURE_BINDING = "prototype.fixture";
82
+ export declare function loadPrototypeFixture(loader: PrototypeFixtureLoader): Promise<PrototypeFixture>;
83
+ export interface PrototypeRouteLike {
84
+ method: string;
85
+ path: string;
86
+ name?: string;
87
+ schemas?: {
88
+ params?: ValidationSchema<unknown>;
89
+ query?: ValidationSchema<unknown>;
90
+ body?: ValidationSchema<unknown>;
91
+ };
92
+ }
93
+ export interface PrototypeRouteDependencies {
94
+ container?: ContainerLike;
95
+ /** `Router.route()`, for a `redirect()` naming a route. */
96
+ routeUrl(name: string, params?: Record<string, string | number>): string;
97
+ }
98
+ /**
99
+ * The route's handler: the fixture entry for the route name, run against the
100
+ * same context shape the browser client builds. The route contract is enforced
101
+ * first (`params`, `query`, `body`; not `output`, which only a response has), so `guren
102
+ * audit`'s "runtime-enforced" verdict stays true here.
103
+ */
104
+ export declare function createPrototypeRouteHandler(route: PrototypeRouteLike, deps: PrototypeRouteDependencies): (c: Context) => Promise<Response>;
105
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The one rule for a `client` option that may be an ioredis instance or a
3
+ * function returning one: the function runs here, not where the config object
4
+ * was declared, so a declared-but-unselected store never dials. Cache and
5
+ * session both resolve through it — a second copy is how the two subsystems
6
+ * come to disagree about what `client` accepts.
7
+ */
8
+ export declare function resolveLazyRedisClient(client: unknown, label: string): unknown;
@@ -1,10 +1,10 @@
1
1
  import { n as trimTrailingSlashes } from "../trim-slashes-BLY9hKAa.js";
2
+ import { _ as parseImportMap, a as getManifestCss, c as isViteProduction, d as startViteDevServer, f as GUREN_ASCII_ART, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, u as normalizeDevServerUrl } from "../vite-manifest-CdfPfQdj.js";
2
3
  import { n as hash } from "../Hash-D2DFd8xX.js";
3
- import { _ as parseImportMap, a as getManifestCss, c as isViteProduction, d as startViteDevServer, f as GUREN_ASCII_ART, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, u as normalizeDevServerUrl } from "../vite-manifest-C57vi7J9.js";
4
4
  import { createRequire } from "node:module";
5
- import { realpath } from "node:fs/promises";
6
5
  import { dirname, extname, join, resolve, sep } from "node:path";
7
6
  import { fileURLToPath } from "node:url";
7
+ import { realpath } from "node:fs/promises";
8
8
  import { serveStatic } from "hono/bun";
9
9
  import { getMimeType } from "hono/utils/mime";
10
10
  //#region src/support/contained-path.ts
@@ -220,7 +220,7 @@ function registerDevAssets(app, options) {
220
220
  jsx: "transform",
221
221
  jsxFactory: "React.createElement",
222
222
  jsxFragment: "React.Fragment",
223
- define: { "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV ?? "development") }
223
+ define: { "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development") }
224
224
  };
225
225
  const transpile = {
226
226
  tsx: new Bun.Transpiler({
@@ -351,7 +351,7 @@ function createJsxRuntimeShim(helpers, runtimeUrl) {
351
351
  }).join("\n")}\n`;
352
352
  }
353
353
  function isDev() {
354
- return (process.env.NODE_ENV ?? "development") !== "production";
354
+ return process.env.NODE_ENV !== "production";
355
355
  }
356
356
  function deriveCssRoute(prefix) {
357
357
  const base = prefix.endsWith("/js") ? prefix.slice(0, -3) : prefix;
@@ -1,2 +1,2 @@
1
- import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver, t as StorageManager } from "../storage-BB59f07j.js";
1
+ import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver, t as StorageManager } from "../storage-D_yNe54O.js";
2
2
  export { LocalDriver, MemoryDriver, S3Driver, StorageManager, createStorageManager };
@@ -1,5 +1,10 @@
1
1
  import path from "node:path";
2
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
3
  //#region src/vite/plugin.ts
4
+ /** Where the generated shell goes; `.guren/` is already gitignored and codegen-owned. */
5
+ const PROTOTYPE_SHELL_FILE = ".guren/prototype/index.html";
6
+ /** The override a project may ship instead of the generated shell. */
7
+ const PROTOTYPE_SHELL_OVERRIDE = "resources/js/prototype/index.html";
3
8
  const defaultOptions = {
4
9
  appAlias: "@",
5
10
  appDir: ".",
@@ -20,16 +25,149 @@ function gurenVitePlugin(options = {}) {
20
25
  ...defaultOptions,
21
26
  ...options
22
27
  };
28
+ let prototype;
23
29
  return {
24
30
  name: "guren:vite-config",
25
31
  enforce: "pre",
26
32
  config(config, env) {
33
+ if (env?.mode === "prototype") {
34
+ prototype = ensurePrototype(config, resolved);
35
+ return;
36
+ }
37
+ prototype = void 0;
27
38
  ensureDefaults(config, resolved, env);
39
+ },
40
+ configResolved(config) {
41
+ if (prototype) prototype.outDir = path.resolve(config.root ?? prototype.root, config.build?.outDir ?? prototype.outDir);
42
+ },
43
+ configureServer(server) {
44
+ if (!prototype) return;
45
+ const shellPath = prototype.shellPath;
46
+ return () => {
47
+ server.middlewares.use(async (req, res, next) => {
48
+ if (req.method !== "GET" && req.method !== "HEAD") return next();
49
+ if (!String(req.headers.accept ?? "").includes("text/html")) return next();
50
+ const url = req.url ?? "/";
51
+ if (/\.[a-z0-9]+$/iu.test(url.split("?")[0] ?? "")) return next();
52
+ try {
53
+ const html = await server.transformIndexHtml(url, readFileSync(shellPath, "utf8"), req.originalUrl);
54
+ res.setHeader("Content-Type", "text/html; charset=utf-8");
55
+ res.end(html);
56
+ } catch (error) {
57
+ next(error);
58
+ }
59
+ });
60
+ };
61
+ },
62
+ writeBundle() {
63
+ if (prototype) finishPrototypeBuild(prototype);
28
64
  }
29
65
  };
30
66
  }
67
+ /**
68
+ * The prototype branch, taken before the ordinary client defaults so none of
69
+ * `ensureBuild`'s outDir/base/publicDir reasoning applies: there is no server
70
+ * to serve `public/`, no manifest to read, and the entry is an HTML shell.
71
+ */
72
+ function ensurePrototype(config, options) {
73
+ const root = resolveRoot(config.root);
74
+ const prototype = options.prototype ?? {};
75
+ ensureAliases(config, options, root);
76
+ ensureServer(config, options);
77
+ ensurePreview(config, options);
78
+ config.define ??= {};
79
+ config.define["import.meta.env.GUREN_PROTOTYPE"] ??= "true";
80
+ config.appType ??= "custom";
81
+ config.base ??= prototype.base ?? "/";
82
+ if (typeof config.publicDir !== "string") config.publicDir = path.resolve(root, "public");
83
+ const copiedBuildDir = relativeIfInside(path.resolve(root, config.publicDir), resolveBuildOutputDirectory(root, options.outDir));
84
+ config.build ??= {};
85
+ config.build.outDir ??= prototype.outDir ?? "dist/prototype";
86
+ config.build.emptyOutDir ??= true;
87
+ config.build.copyPublicDir = true;
88
+ config.build.manifest ??= false;
89
+ config.build.ssrManifest ??= false;
90
+ const shellPath = resolvePrototypeShell(root, prototype.shell, options.entry);
91
+ config.build.rollupOptions ??= {};
92
+ config.build.rollupOptions.input ??= shellPath;
93
+ const output = normalizeRollupOutput(config.build.rollupOptions.output);
94
+ output.entryFileNames ??= options.entryFileNames;
95
+ output.chunkFileNames ??= options.chunkFileNames;
96
+ output.assetFileNames ??= options.assetFileNames;
97
+ output.manualChunks ??= createDefaultManualChunks(root);
98
+ config.build.rollupOptions.output = output;
99
+ return {
100
+ root,
101
+ outDir: path.resolve(root, config.build.outDir),
102
+ shellPath,
103
+ copiedBuildDir
104
+ };
105
+ }
106
+ function resolvePrototypeShell(root, shell, entry) {
107
+ if (shell) return path.resolve(root, shell);
108
+ const override = path.resolve(root, PROTOTYPE_SHELL_OVERRIDE);
109
+ if (existsSync(override)) return override;
110
+ const generated = path.resolve(root, PROTOTYPE_SHELL_FILE);
111
+ const contents = renderPrototypeShell(entry);
112
+ if (readShell(generated) !== contents) {
113
+ mkdirSync(path.dirname(generated), { recursive: true });
114
+ writeFileSync(generated, contents);
115
+ }
116
+ return generated;
117
+ }
118
+ /** The shell on disk, or null when there is none; read directly so no check-then-read window exists. */
119
+ function readShell(file) {
120
+ try {
121
+ return readFileSync(file, "utf8");
122
+ } catch {
123
+ return null;
124
+ }
125
+ }
126
+ function renderPrototypeShell(entry) {
127
+ return `<!doctype html>
128
+ <html lang="en">
129
+ <head>
130
+ <meta charset="utf-8" />
131
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
132
+ <meta name="robots" content="noindex, nofollow" />
133
+ <title>Prototype</title>
134
+ </head>
135
+ <body>
136
+ <div id="app"></div>
137
+ <script type="module" src="${`/${entry.replace(/^\.?\//u, "")}`}"><\/script>
138
+ </body>
139
+ </html>
140
+ `;
141
+ }
142
+ /**
143
+ * Vite emits an HTML input at its path relative to the root, so the shell
144
+ * lands nested; move it to the top, then add the SPA fallbacks: `404.html`
145
+ * (GitHub Pages) and `_redirects` (Netlify, Cloudflare Pages).
146
+ */
147
+ function finishPrototypeBuild(prototype) {
148
+ const relative = path.relative(prototype.root, prototype.shellPath);
149
+ const nested = path.resolve(prototype.outDir, relative);
150
+ const top = path.resolve(prototype.outDir, "index.html");
151
+ if (nested !== top && existsSync(nested)) {
152
+ renameSync(nested, top);
153
+ const topLevelDir = relative.split(path.sep)[0];
154
+ if (topLevelDir && topLevelDir !== "." && topLevelDir !== "..") rmSync(path.resolve(prototype.outDir, topLevelDir), {
155
+ recursive: true,
156
+ force: true
157
+ });
158
+ }
159
+ if (!existsSync(top)) throw new Error(`Prototype build produced no index.html in ${prototype.outDir}`);
160
+ if (prototype.copiedBuildDir) rmSync(path.resolve(prototype.outDir, prototype.copiedBuildDir), {
161
+ recursive: true,
162
+ force: true
163
+ });
164
+ writeFileSync(path.resolve(prototype.outDir, "404.html"), readFileSync(top));
165
+ writeFileSync(path.resolve(prototype.outDir, "_redirects"), "/* /index.html 200\n");
166
+ }
31
167
  function ensureDefaults(config, options, env) {
32
168
  const root = resolveRoot(config.root);
169
+ config.define ??= {};
170
+ config.define["import.meta.env.GUREN_PROTOTYPE"] ??= "false";
33
171
  ensureAliases(config, options, root);
34
172
  ensureServer(config, options);
35
173
  ensurePreview(config, options);
@@ -88,10 +226,13 @@ function ensureBuild(config, options, root, env) {
88
226
  if (!isSsrBuild && output.manualChunks === void 0) output.manualChunks = createDefaultManualChunks(root);
89
227
  config.build.rollupOptions.output = output;
90
228
  }
229
+ /** `@guren/inertia-client`'s prototype entry (src or dist) and the Hono router it alone imports. */
230
+ const PROTOTYPE_RUNTIME_MODULE = /\/inertia-client\/(?:src|dist)\/prototype(?:-[^/]+)?\.[jt]sx?$|\/node_modules\/hono\/dist\/router\//u;
91
231
  function createDefaultManualChunks(root) {
92
232
  const normalizedRoot = root.replace(/\\/gu, "/");
93
233
  return (id) => {
94
234
  const normalizedId = id.replace(/\\/gu, "/");
235
+ if (PROTOTYPE_RUNTIME_MODULE.test(normalizedId)) return;
95
236
  if (normalizedId.includes("/packages/inertia-client/")) return "inertia-vendor";
96
237
  if (normalizedId.includes("/packages/core/") || normalizedId.includes("/packages/server/") || normalizedId.includes("/packages/orm/")) return "framework-vendor";
97
238
  if (!normalizedId.includes("/node_modules/")) {
@@ -108,6 +249,12 @@ function createDefaultManualChunks(root) {
108
249
  function resolveBuildOutputDirectory(root, outDir) {
109
250
  return path.isAbsolute(outDir) ? outDir : path.resolve(root, outDir);
110
251
  }
252
+ /** The path from `parent` down to `child`, or undefined when `child` is not below it. */
253
+ function relativeIfInside(parent, child) {
254
+ const relative = path.relative(parent, child);
255
+ if (relative === "" || relative.startsWith("..") || path.isAbsolute(relative)) return void 0;
256
+ return relative;
257
+ }
111
258
  function deriveHttpBaseFromOutDir(outDir) {
112
259
  const normalized = outDir.replace(/\\/gu, "/").replace(/^\.\//u, "");
113
260
  if (normalized === "public") return "/public/";