@guren/server 0.1.1-alpha.5 → 0.2.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GDCUIM6V.js → chunk-FK2XQSBF.js} +50 -11
- package/dist/index.d.ts +205 -28
- package/dist/index.js +2613 -187
- package/dist/vite/index.d.ts +5 -1
- package/dist/vite/index.js +1 -1
- package/package.json +8 -2
|
@@ -6,7 +6,9 @@ var defaultOptions = {
|
|
|
6
6
|
resourcesAlias: "@resources",
|
|
7
7
|
resourcesDir: "resources/js",
|
|
8
8
|
entry: "resources/js/app.tsx",
|
|
9
|
+
ssrEntry: "resources/js/ssr.tsx",
|
|
9
10
|
outDir: "public/assets",
|
|
11
|
+
ssrOutDir: ".guren/ssr",
|
|
10
12
|
devPort: 5173,
|
|
11
13
|
previewPort: 4173,
|
|
12
14
|
entryFileNames: "[name]-[hash].js",
|
|
@@ -18,17 +20,17 @@ function gurenVitePlugin(options = {}) {
|
|
|
18
20
|
return {
|
|
19
21
|
name: "guren:vite-config",
|
|
20
22
|
enforce: "pre",
|
|
21
|
-
config(config,
|
|
22
|
-
ensureDefaults(config, resolved);
|
|
23
|
+
config(config, env) {
|
|
24
|
+
ensureDefaults(config, resolved, env);
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
|
-
function ensureDefaults(config, options) {
|
|
28
|
+
function ensureDefaults(config, options, env) {
|
|
27
29
|
const root = resolveRoot(config.root);
|
|
28
30
|
ensureAliases(config, options, root);
|
|
29
31
|
ensureServer(config, options);
|
|
30
32
|
ensurePreview(config, options);
|
|
31
|
-
ensureBuild(config, options, root);
|
|
33
|
+
ensureBuild(config, options, root, env);
|
|
32
34
|
}
|
|
33
35
|
function ensureAliases(config, options, root) {
|
|
34
36
|
config.resolve ??= {};
|
|
@@ -55,19 +57,44 @@ function ensurePreview(config, options) {
|
|
|
55
57
|
config.preview.port = options.previewPort;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
|
-
function ensureBuild(config, options, root) {
|
|
60
|
+
function ensureBuild(config, options, root, env) {
|
|
59
61
|
config.build ??= {};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
62
|
+
const isSsrBuild = Boolean(env?.ssrBuild ?? env?.isSsrBuild);
|
|
63
|
+
const isServeCommand = env?.command === "serve";
|
|
63
64
|
if (config.build.emptyOutDir === void 0) {
|
|
64
65
|
config.build.emptyOutDir = true;
|
|
65
66
|
}
|
|
66
|
-
if (
|
|
67
|
-
config.build.
|
|
67
|
+
if (isSsrBuild) {
|
|
68
|
+
if (config.build.outDir === void 0) {
|
|
69
|
+
config.build.outDir = options.ssrOutDir;
|
|
70
|
+
}
|
|
71
|
+
if (config.build.manifest === void 0) {
|
|
72
|
+
config.build.manifest = true;
|
|
73
|
+
}
|
|
74
|
+
if (config.build.ssr === void 0) {
|
|
75
|
+
config.build.ssr = path.resolve(root, options.ssrEntry);
|
|
76
|
+
}
|
|
77
|
+
config.build.rollupOptions ??= {};
|
|
78
|
+
config.build.rollupOptions.input = path.resolve(root, options.ssrEntry);
|
|
79
|
+
} else {
|
|
80
|
+
if (config.build.outDir === void 0) {
|
|
81
|
+
config.build.outDir = options.outDir;
|
|
82
|
+
}
|
|
83
|
+
if (config.build.manifest === void 0) {
|
|
84
|
+
config.build.manifest = true;
|
|
85
|
+
}
|
|
86
|
+
if (config.build.ssrManifest === void 0) {
|
|
87
|
+
config.build.ssrManifest = true;
|
|
88
|
+
}
|
|
89
|
+
if (!isServeCommand && config.base === void 0) {
|
|
90
|
+
const derivedBase = deriveHttpBaseFromOutDir(options.outDir);
|
|
91
|
+
if (derivedBase) {
|
|
92
|
+
config.base = derivedBase;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
68
95
|
}
|
|
69
96
|
config.build.rollupOptions ??= {};
|
|
70
|
-
if (config.build.rollupOptions.input === void 0) {
|
|
97
|
+
if (!isSsrBuild && config.build.rollupOptions.input === void 0) {
|
|
71
98
|
config.build.rollupOptions.input = path.resolve(root, options.entry);
|
|
72
99
|
}
|
|
73
100
|
const output = normalizeRollupOutput(config.build.rollupOptions.output);
|
|
@@ -82,6 +109,18 @@ function ensureBuild(config, options, root) {
|
|
|
82
109
|
}
|
|
83
110
|
config.build.rollupOptions.output = output;
|
|
84
111
|
}
|
|
112
|
+
function deriveHttpBaseFromOutDir(outDir) {
|
|
113
|
+
const normalized = outDir.replace(/\\/gu, "/").replace(/^\.\//u, "");
|
|
114
|
+
if (normalized === "public") {
|
|
115
|
+
return "/public/";
|
|
116
|
+
}
|
|
117
|
+
if (normalized.startsWith("public/")) {
|
|
118
|
+
const remainder = normalized.slice("public/".length);
|
|
119
|
+
const suffix = remainder.length > 0 ? `${remainder.replace(/\/$/u, "")}/` : "";
|
|
120
|
+
return `/public/${suffix}`;
|
|
121
|
+
}
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
85
124
|
function resolveRoot(root) {
|
|
86
125
|
if (!root) {
|
|
87
126
|
return process.cwd();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as hono from 'hono';
|
|
2
2
|
import { MiddlewareHandler, Context, Hono, ExecutionContext } from 'hono';
|
|
3
3
|
export { Context } from 'hono';
|
|
4
|
+
import { InlineConfig, ViteDevServer } from 'vite';
|
|
4
5
|
export { GurenVitePluginOptions, default as gurenVitePlugin } from './vite/index.js';
|
|
5
6
|
|
|
6
7
|
interface InertiaOptions {
|
|
@@ -13,6 +14,7 @@ interface InertiaOptions {
|
|
|
13
14
|
readonly entry?: string;
|
|
14
15
|
readonly importMap?: Record<string, string>;
|
|
15
16
|
readonly styles?: string[];
|
|
17
|
+
readonly ssr?: InertiaSsrOptions;
|
|
16
18
|
}
|
|
17
19
|
interface InertiaPagePayload {
|
|
18
20
|
component: string;
|
|
@@ -20,7 +22,23 @@ interface InertiaPagePayload {
|
|
|
20
22
|
url: string;
|
|
21
23
|
version?: string;
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
interface InertiaSsrContext {
|
|
26
|
+
page: InertiaPagePayload;
|
|
27
|
+
request?: Request;
|
|
28
|
+
manifest?: string;
|
|
29
|
+
}
|
|
30
|
+
interface InertiaSsrResult {
|
|
31
|
+
head: string[];
|
|
32
|
+
body: string;
|
|
33
|
+
}
|
|
34
|
+
type InertiaSsrRenderer = (context: InertiaSsrContext) => Promise<InertiaSsrResult> | InertiaSsrResult;
|
|
35
|
+
interface InertiaSsrOptions {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
entry?: string;
|
|
38
|
+
manifest?: string;
|
|
39
|
+
render?: InertiaSsrRenderer;
|
|
40
|
+
}
|
|
41
|
+
declare function inertia(component: string, props: Record<string, unknown>, options?: InertiaOptions): Promise<Response>;
|
|
24
42
|
|
|
25
43
|
type SessionData = Record<string, unknown>;
|
|
26
44
|
interface SessionStore {
|
|
@@ -195,35 +213,116 @@ declare abstract class BaseUserProvider<User extends Authenticatable = Authentic
|
|
|
195
213
|
}
|
|
196
214
|
|
|
197
215
|
type PlainObject = Record<string, unknown>;
|
|
198
|
-
type
|
|
216
|
+
type RelationShape = Record<string, unknown>;
|
|
217
|
+
type WhereValue<Value> = Value | readonly Value[] | null;
|
|
218
|
+
type WhereClause<TRecord extends PlainObject = PlainObject> = Partial<{
|
|
219
|
+
[K in keyof TRecord & string]?: WhereValue<TRecord[K]>;
|
|
220
|
+
}>;
|
|
221
|
+
type OrderDirection = 'asc' | 'desc';
|
|
222
|
+
type OrderDefinition<TRecord extends PlainObject = PlainObject> = {
|
|
223
|
+
column: keyof TRecord & string;
|
|
224
|
+
direction: OrderDirection;
|
|
225
|
+
};
|
|
226
|
+
type OrderExpression<TRecord extends PlainObject = PlainObject> = (keyof TRecord & string) | readonly [keyof TRecord & string, OrderDirection] | {
|
|
227
|
+
column: keyof TRecord & string;
|
|
228
|
+
direction?: OrderDirection;
|
|
229
|
+
};
|
|
230
|
+
type OrderByInput<TRecord extends PlainObject = PlainObject> = OrderExpression<TRecord> | readonly OrderExpression<TRecord>[];
|
|
231
|
+
type OrderByClause<TRecord extends PlainObject = PlainObject> = readonly OrderDefinition<TRecord>[];
|
|
232
|
+
interface FindManyOptions<TRecord extends PlainObject = PlainObject> {
|
|
233
|
+
where?: WhereClause<TRecord>;
|
|
234
|
+
orderBy?: OrderByClause<TRecord>;
|
|
235
|
+
limit?: number;
|
|
236
|
+
offset?: number;
|
|
237
|
+
}
|
|
238
|
+
interface PaginateOptions<TRecord extends PlainObject = PlainObject> {
|
|
239
|
+
page?: number;
|
|
240
|
+
perPage?: number;
|
|
241
|
+
where?: WhereClause<TRecord>;
|
|
242
|
+
orderBy?: OrderByInput<TRecord>;
|
|
243
|
+
}
|
|
244
|
+
interface PaginationMeta {
|
|
245
|
+
total: number;
|
|
246
|
+
perPage: number;
|
|
247
|
+
currentPage: number;
|
|
248
|
+
totalPages: number;
|
|
249
|
+
hasMore: boolean;
|
|
250
|
+
from: number;
|
|
251
|
+
to: number;
|
|
252
|
+
}
|
|
253
|
+
interface PaginatedResult<TRecord extends PlainObject = PlainObject> {
|
|
254
|
+
data: TRecord[];
|
|
255
|
+
meta: PaginationMeta;
|
|
256
|
+
}
|
|
199
257
|
interface ORMAdapter {
|
|
200
|
-
findMany<TRecord = PlainObject>(table: unknown,
|
|
201
|
-
findUnique<TRecord = PlainObject>(table: unknown, where: WhereClause): Promise<TRecord | null>;
|
|
202
|
-
create<TRecord = PlainObject>(table: unknown, data: PlainObject): Promise<TRecord>;
|
|
203
|
-
update?<TRecord = PlainObject>(table: unknown, where: WhereClause
|
|
204
|
-
delete?<TRecord = PlainObject>(table: unknown, where: WhereClause): Promise<number | PlainObject | void>;
|
|
258
|
+
findMany<TRecord extends PlainObject = PlainObject>(table: unknown, options?: FindManyOptions<TRecord>): Promise<TRecord[]>;
|
|
259
|
+
findUnique<TRecord extends PlainObject = PlainObject>(table: unknown, where: WhereClause<TRecord>): Promise<TRecord | null>;
|
|
260
|
+
create<TRecord extends PlainObject = PlainObject>(table: unknown, data: PlainObject): Promise<TRecord>;
|
|
261
|
+
update?<TRecord extends PlainObject = PlainObject>(table: unknown, where: WhereClause<TRecord>, data: PlainObject): Promise<TRecord>;
|
|
262
|
+
delete?<TRecord extends PlainObject = PlainObject>(table: unknown, where: WhereClause<TRecord>): Promise<number | PlainObject | void>;
|
|
263
|
+
count?<TRecord extends PlainObject = PlainObject>(table: unknown, where?: WhereClause<TRecord>): Promise<number>;
|
|
205
264
|
}
|
|
206
265
|
/**
|
|
207
266
|
* Minimal ActiveRecord-like wrapper around the configured ORM adapter. The API
|
|
208
267
|
* mirrors a subset of Laravel's Eloquent helpers and can be expanded over time.
|
|
209
268
|
*/
|
|
210
|
-
declare abstract class Model<TRecord extends
|
|
269
|
+
declare abstract class Model<TRecord extends PlainObject = PlainObject> {
|
|
211
270
|
protected static ormAdapter: ORMAdapter;
|
|
212
271
|
protected static table: unknown;
|
|
213
272
|
static readonly recordType: unknown;
|
|
273
|
+
protected static relationDefinitions?: Map<string, RelationDefinition>;
|
|
274
|
+
static relationTypes: RelationShape;
|
|
214
275
|
static useAdapter(adapter: ORMAdapter): void;
|
|
215
276
|
static getAdapter(): ORMAdapter;
|
|
277
|
+
protected static preparePersistencePayload(data: PlainObject): Promise<PlainObject>;
|
|
278
|
+
protected static getRelationDefinitions(): Map<string, RelationDefinition>;
|
|
279
|
+
protected static getRelationDefinition(name: string): RelationDefinition | undefined;
|
|
216
280
|
protected static resolveTable(): unknown;
|
|
217
281
|
static all<T extends typeof Model>(this: T): Promise<Array<TRecordFor<T>>>;
|
|
218
282
|
static find<T extends typeof Model>(this: T, id: unknown, key?: string): Promise<TRecordFor<T> | null>;
|
|
219
|
-
static where<T extends typeof Model>(this: T, where:
|
|
283
|
+
static where<T extends typeof Model>(this: T, where: WhereClauseFor<T>): Promise<TRecordFor<T>[]>;
|
|
284
|
+
static hasMany<This extends typeof Model, Related extends typeof Model, ForeignKey extends keyof TRecordFor<Related> & string, LocalKey extends keyof TRecordFor<This> & string, Name extends RelationKeyOrString<This>>(this: This, name: Name, related: Related, foreignKey: ForeignKey, localKey: LocalKey): void;
|
|
285
|
+
static belongsTo<This extends typeof Model, Related extends typeof Model, ForeignKey extends keyof TRecordFor<This> & string, OwnerKey extends keyof TRecordFor<Related> & string, Name extends RelationKeyOrString<This>>(this: This, name: Name, related: Related, foreignKey: ForeignKey, ownerKey: OwnerKey): void;
|
|
286
|
+
static orderBy<T extends typeof Model>(this: T, order: OrderByInput<TRecordFor<T>>, where?: WhereClauseFor<T>): Promise<TRecordFor<T>[]>;
|
|
287
|
+
static paginate<T extends typeof Model>(this: T, options?: PaginateOptions<TRecordFor<T>>): Promise<PaginatedResult<TRecordFor<T>>>;
|
|
288
|
+
static withPaginate<T extends typeof Model, K extends RelationKey<T>>(this: T, relations: K | readonly K[], options?: PaginateOptions<TRecordFor<T>>): Promise<PaginatedResult<TRecordFor<T> & RelationTypePick<T, K | readonly K[]>>>;
|
|
220
289
|
static create<T extends typeof Model>(this: T, data: PlainObject): Promise<TRecordFor<T>>;
|
|
221
|
-
static update<T extends typeof Model>(this: T, where:
|
|
222
|
-
static delete<T extends typeof Model>(this: T, where:
|
|
290
|
+
static update<T extends typeof Model>(this: T, where: WhereClauseFor<T>, data: PlainObject): Promise<TRecordFor<T>>;
|
|
291
|
+
static delete<T extends typeof Model>(this: T, where: WhereClauseFor<T>): Promise<number | PlainObject | void>;
|
|
292
|
+
static with<T extends typeof Model, K extends RelationKey<T>>(this: T, relations: K | readonly K[], where?: WhereClauseFor<T>): Promise<Array<TRecordFor<T> & RelationTypePick<T, K | readonly K[]>>>;
|
|
293
|
+
protected static loadRelationInto<T extends typeof Model>(this: T, records: Array<PlainObject>, relationName: string): Promise<void>;
|
|
294
|
+
protected static loadHasMany(records: Array<PlainObject>, definition: HasManyRelationDefinition): Promise<void>;
|
|
295
|
+
protected static loadBelongsTo(records: Array<PlainObject>, definition: BelongsToRelationDefinition): Promise<void>;
|
|
223
296
|
}
|
|
224
297
|
type TRecordFor<T extends typeof Model> = T extends {
|
|
225
298
|
recordType: infer R;
|
|
226
|
-
} ? R extends
|
|
299
|
+
} ? R extends PlainObject ? R : PlainObject : PlainObject;
|
|
300
|
+
type WhereClauseFor<T extends typeof Model> = WhereClause<TRecordFor<T>>;
|
|
301
|
+
type RelationTypesFor<T extends typeof Model> = T extends {
|
|
302
|
+
relationTypes: infer R;
|
|
303
|
+
} ? R extends RelationShape ? R : {} : {};
|
|
304
|
+
type RelationKey<T extends typeof Model> = keyof RelationTypesFor<T> & string;
|
|
305
|
+
type RelationKeyOrString<T extends typeof Model> = RelationKey<T> extends never ? string : RelationKey<T>;
|
|
306
|
+
type RelationNameUnion<Names> = Names extends readonly (infer Items)[] ? Items : Names;
|
|
307
|
+
type RelationTypePick<T extends typeof Model, Names> = RelationNameUnion<Names> extends infer Keys ? Keys extends string ? {
|
|
308
|
+
[K in Keys & keyof RelationTypesFor<T>]: RelationTypesFor<T>[K];
|
|
309
|
+
} : {} : {};
|
|
310
|
+
interface BaseRelationDefinition {
|
|
311
|
+
type: 'hasMany' | 'belongsTo';
|
|
312
|
+
name: string;
|
|
313
|
+
related: typeof Model;
|
|
314
|
+
}
|
|
315
|
+
interface HasManyRelationDefinition extends BaseRelationDefinition {
|
|
316
|
+
type: 'hasMany';
|
|
317
|
+
foreignKey: string;
|
|
318
|
+
localKey: string;
|
|
319
|
+
}
|
|
320
|
+
interface BelongsToRelationDefinition extends BaseRelationDefinition {
|
|
321
|
+
type: 'belongsTo';
|
|
322
|
+
foreignKey: string;
|
|
323
|
+
ownerKey: string;
|
|
324
|
+
}
|
|
325
|
+
type RelationDefinition = HasManyRelationDefinition | BelongsToRelationDefinition;
|
|
227
326
|
|
|
228
327
|
interface PasswordHasher {
|
|
229
328
|
hash(plain: string): Promise<string>;
|
|
@@ -282,6 +381,16 @@ declare class ScryptHasher implements PasswordHasher {
|
|
|
282
381
|
needsRehash(hashed: string): boolean;
|
|
283
382
|
}
|
|
284
383
|
|
|
384
|
+
declare abstract class AuthenticatableModel<TRecord extends PlainObject = PlainObject> extends Model<TRecord> {
|
|
385
|
+
protected static passwordField: string;
|
|
386
|
+
protected static passwordHashField: string;
|
|
387
|
+
protected static passwordHasher: PasswordHasher | null;
|
|
388
|
+
protected static resolvePasswordField(): string;
|
|
389
|
+
protected static resolvePasswordHashField(): string;
|
|
390
|
+
protected static resolvePasswordHasher(): PasswordHasher;
|
|
391
|
+
protected static preparePersistencePayload(data: PlainObject): Promise<PlainObject>;
|
|
392
|
+
}
|
|
393
|
+
|
|
285
394
|
type DefaultInertiaProps = Record<string, unknown>;
|
|
286
395
|
type InertiaResponseMarker<Component extends string, Props extends DefaultInertiaProps> = {
|
|
287
396
|
readonly __gurenInertia?: {
|
|
@@ -291,6 +400,7 @@ type InertiaResponseMarker<Component extends string, Props extends DefaultInerti
|
|
|
291
400
|
};
|
|
292
401
|
type InertiaResponse<Component extends string, Props extends DefaultInertiaProps> = Response & InertiaResponseMarker<Component, Props>;
|
|
293
402
|
type InferInertiaProps<T> = [T] extends [InertiaResponse<string, infer Props>] ? Props : [T] extends [Promise<infer Awaited>] ? InferInertiaProps<Awaited> : DefaultInertiaProps;
|
|
403
|
+
type ControllerInertiaProps<TController extends Controller, TAction extends keyof TController> = TController[TAction] extends (...args: any[]) => infer TResult ? InferInertiaProps<Awaited<TResult>> : DefaultInertiaProps;
|
|
294
404
|
interface RedirectOptions {
|
|
295
405
|
status?: number;
|
|
296
406
|
headers?: HeadersInit;
|
|
@@ -309,7 +419,7 @@ declare class Controller {
|
|
|
309
419
|
protected get ctx(): Context;
|
|
310
420
|
protected get request(): hono.HonoRequest<any, unknown>;
|
|
311
421
|
protected get auth(): AuthContext;
|
|
312
|
-
protected inertia<Component extends string, Props extends DefaultInertiaProps>(component: Component, props: Props, options?: InertiaResponseOptions): InertiaResponse<Component, Props
|
|
422
|
+
protected inertia<Component extends string, Props extends DefaultInertiaProps>(component: Component, props: Props, options?: InertiaResponseOptions): Promise<InertiaResponse<Component, Props>>;
|
|
313
423
|
protected json<T>(data: T, init?: ResponseInit): Response;
|
|
314
424
|
protected text(body: string, init?: ResponseInit): Response;
|
|
315
425
|
protected redirect(url: string, options?: RedirectOptions): Response;
|
|
@@ -319,9 +429,10 @@ type ControllerConstructor<T extends Controller = Controller> = new () => T;
|
|
|
319
429
|
type ControllerMethod<T extends Controller> = {
|
|
320
430
|
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
321
431
|
}[keyof T] & string;
|
|
322
|
-
type
|
|
432
|
+
type ControllerMethodFor<C extends ControllerConstructor> = ControllerMethod<InstanceType<C>>;
|
|
433
|
+
type ControllerAction<C extends ControllerConstructor = ControllerConstructor> = [C, ControllerMethodFor<C>];
|
|
323
434
|
type RouteResult = Response | string | number | boolean | Record<string, unknown> | Array<unknown> | null | void;
|
|
324
|
-
type RouteHandler<
|
|
435
|
+
type RouteHandler<C extends ControllerConstructor = ControllerConstructor> = ((c: Context) => RouteResult | Promise<RouteResult>) | ControllerAction<C>;
|
|
325
436
|
interface RouteDefinition {
|
|
326
437
|
method: string;
|
|
327
438
|
path: string;
|
|
@@ -335,19 +446,19 @@ declare class Route {
|
|
|
335
446
|
private static readonly registry;
|
|
336
447
|
private static readonly prefixStack;
|
|
337
448
|
private static add;
|
|
338
|
-
static on<
|
|
339
|
-
static get<
|
|
340
|
-
static post<
|
|
341
|
-
static put<
|
|
342
|
-
static patch<
|
|
343
|
-
static delete<
|
|
449
|
+
static on<C extends ControllerConstructor>(method: string, path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): typeof Route;
|
|
450
|
+
static get<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): typeof Route;
|
|
451
|
+
static post<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): typeof Route;
|
|
452
|
+
static put<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): typeof Route;
|
|
453
|
+
static patch<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): typeof Route;
|
|
454
|
+
static delete<C extends ControllerConstructor>(path: string, handler: RouteHandler<C>, ...middlewares: MiddlewareHandler[]): typeof Route;
|
|
344
455
|
static group(prefix: string, callback: () => void): typeof Route;
|
|
345
456
|
static mount(app: Hono): void;
|
|
346
457
|
static clear(): void;
|
|
347
458
|
static definitions(): RouteDefinition[];
|
|
348
459
|
}
|
|
349
460
|
|
|
350
|
-
type ViewRenderer = (template: string, props: Record<string, unknown>) => Response
|
|
461
|
+
type ViewRenderer = (template: string, props: Record<string, unknown>) => Response | Promise<Response>;
|
|
351
462
|
/**
|
|
352
463
|
* Registry for view renderers. Engines are typically registered via service
|
|
353
464
|
* providers so applications can opt into or replace implementations.
|
|
@@ -356,7 +467,7 @@ declare class ViewEngine {
|
|
|
356
467
|
private static readonly engines;
|
|
357
468
|
static register(name: string, renderer: ViewRenderer): void;
|
|
358
469
|
static has(name: string): boolean;
|
|
359
|
-
static render(name: string, template: string, props: Record<string, unknown>): Response
|
|
470
|
+
static render(name: string, template: string, props: Record<string, unknown>): Response | Promise<Response>;
|
|
360
471
|
}
|
|
361
472
|
|
|
362
473
|
declare class ApplicationContext {
|
|
@@ -376,11 +487,38 @@ interface Provider {
|
|
|
376
487
|
}
|
|
377
488
|
type ProviderConstructor<T extends Provider = Provider> = new () => T;
|
|
378
489
|
|
|
490
|
+
declare const GUREN_ASCII_ART: string;
|
|
491
|
+
interface DevBannerOptions {
|
|
492
|
+
hostname: string;
|
|
493
|
+
port: number;
|
|
494
|
+
assetsUrl?: string;
|
|
495
|
+
}
|
|
496
|
+
declare function logDevServerBanner({ hostname, port, assetsUrl, }: DevBannerOptions): void;
|
|
497
|
+
|
|
498
|
+
interface StartViteDevServerOptions {
|
|
499
|
+
root?: string;
|
|
500
|
+
config?: InlineConfig;
|
|
501
|
+
host?: boolean | string;
|
|
502
|
+
port?: number;
|
|
503
|
+
}
|
|
504
|
+
interface StartedViteDevServer {
|
|
505
|
+
server: ViteDevServer;
|
|
506
|
+
localUrl: string;
|
|
507
|
+
networkUrls: string[];
|
|
508
|
+
}
|
|
509
|
+
declare function startViteDevServer(options?: StartViteDevServerOptions): Promise<StartedViteDevServer>;
|
|
510
|
+
|
|
379
511
|
type BootCallback = (app: Hono) => void | Promise<void>;
|
|
380
512
|
interface ApplicationOptions {
|
|
381
513
|
readonly boot?: BootCallback;
|
|
382
514
|
readonly providers?: Array<Provider | ProviderConstructor>;
|
|
383
515
|
}
|
|
516
|
+
interface ApplicationListenOptions {
|
|
517
|
+
port?: number;
|
|
518
|
+
hostname?: string;
|
|
519
|
+
assetsUrl?: string;
|
|
520
|
+
vite?: StartViteDevServerOptions | false;
|
|
521
|
+
}
|
|
384
522
|
/**
|
|
385
523
|
* Application wires the Route registry into a running Hono instance.
|
|
386
524
|
* It offers a small convenience layer so users can bootstrap a Bun server
|
|
@@ -392,6 +530,9 @@ declare class Application {
|
|
|
392
530
|
private readonly plugins;
|
|
393
531
|
private context?;
|
|
394
532
|
private readonly authManager;
|
|
533
|
+
private viteDevServer?;
|
|
534
|
+
private bunServer?;
|
|
535
|
+
private viteTeardownRegistered;
|
|
395
536
|
constructor(options?: ApplicationOptions);
|
|
396
537
|
get auth(): AuthManager;
|
|
397
538
|
/**
|
|
@@ -413,14 +554,31 @@ declare class Application {
|
|
|
413
554
|
/**
|
|
414
555
|
* Convenience helper to start a Bun server when available.
|
|
415
556
|
*/
|
|
416
|
-
listen(options?:
|
|
417
|
-
port?: number;
|
|
418
|
-
hostname?: string;
|
|
419
|
-
}): void;
|
|
557
|
+
listen(options?: ApplicationListenOptions): Promise<void>;
|
|
420
558
|
register(provider: Provider | ProviderConstructor): this;
|
|
421
559
|
registerMany(providers: Array<Provider | ProviderConstructor>): this;
|
|
560
|
+
/**
|
|
561
|
+
* Logs the rich development server banner to the console.
|
|
562
|
+
*/
|
|
563
|
+
logDevServerBanner(options: DevBannerOptions): void;
|
|
422
564
|
private resolveContext;
|
|
423
565
|
private registerDefaultProviders;
|
|
566
|
+
private closeViteDevServer;
|
|
567
|
+
private registerViteTeardown;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
type RootPublicAssetsConfig = boolean | RootPublicAssetsOptions;
|
|
571
|
+
interface RootPublicAssetsOptions {
|
|
572
|
+
/** Enable or disable root-level public asset serving. Defaults to true. */
|
|
573
|
+
enabled?: boolean;
|
|
574
|
+
/** List of file extensions to expose from the public directory. */
|
|
575
|
+
extensions?: string[];
|
|
576
|
+
/** Cache-Control header applied to served files. */
|
|
577
|
+
cacheControlHeader?: string;
|
|
578
|
+
/** Optional prefix filter (e.g. `/assets`). Defaults to all paths. */
|
|
579
|
+
routePrefix?: string;
|
|
580
|
+
/** Override content types per extension. */
|
|
581
|
+
contentTypeMap?: Record<string, string>;
|
|
424
582
|
}
|
|
425
583
|
|
|
426
584
|
interface DevAssetsOptions {
|
|
@@ -432,6 +590,10 @@ interface DevAssetsOptions {
|
|
|
432
590
|
resourcesPath?: string;
|
|
433
591
|
/** Path prefix to mount transpiled JS assets. Defaults to `/resources/js`. */
|
|
434
592
|
prefix?: string;
|
|
593
|
+
/** Route pattern used to serve raw CSS assets. Defaults to `/resources/css/*`. */
|
|
594
|
+
cssRoute?: string;
|
|
595
|
+
/** Absolute path to the CSS directory. Defaults to `<resourcesDir>/../css`. */
|
|
596
|
+
cssDir?: string;
|
|
435
597
|
/** Enables serving the bundled inertia client. Defaults to true. */
|
|
436
598
|
inertiaClient?: boolean;
|
|
437
599
|
/** Path to the inertia client source. Defaults to the version bundled with Guren. */
|
|
@@ -448,6 +610,8 @@ interface DevAssetsOptions {
|
|
|
448
610
|
publicRoute?: string;
|
|
449
611
|
/** Whether to register a no-op favicon route. Defaults to true when static assets are served. */
|
|
450
612
|
favicon?: boolean;
|
|
613
|
+
/** Serve selected files from the public directory without the `/public` prefix. */
|
|
614
|
+
rootPublicAssets?: RootPublicAssetsConfig;
|
|
451
615
|
}
|
|
452
616
|
/**
|
|
453
617
|
* Registers development asset serving middleware.
|
|
@@ -461,8 +625,21 @@ interface InertiaAssetsOptions extends DevAssetsOptions {
|
|
|
461
625
|
stylesEntry?: string;
|
|
462
626
|
/** Default script entry embedded into Inertia responses (production). */
|
|
463
627
|
scriptEntry?: string;
|
|
628
|
+
/** Path to the SSR bundle entry consumed by the Inertia engine. */
|
|
629
|
+
ssrEntry?: string;
|
|
630
|
+
/** Path to the SSR manifest file generated by the build. */
|
|
631
|
+
ssrManifest?: string;
|
|
632
|
+
}
|
|
633
|
+
interface AutoConfigureInertiaOptions extends InertiaAssetsOptions {
|
|
634
|
+
/** Dev server URL used when NODE_ENV !== 'production'. */
|
|
635
|
+
devServerUrl?: string;
|
|
636
|
+
/** Output directory for Vite SSR bundles (relative to project root). */
|
|
637
|
+
ssrOutDir?: string;
|
|
638
|
+
/** Enables SSR auto-wiring (defaults to true). */
|
|
639
|
+
enableSsr?: boolean;
|
|
464
640
|
}
|
|
465
641
|
declare function configureInertiaAssets(app: Application, options: InertiaAssetsOptions): void;
|
|
642
|
+
declare function autoConfigureInertiaAssets(app: Application, options: AutoConfigureInertiaOptions): void;
|
|
466
643
|
|
|
467
644
|
/**
|
|
468
645
|
* Parses the incoming request payload supporting both JSON bodies and form submissions.
|
|
@@ -490,4 +667,4 @@ declare class AuthServiceProvider implements Provider {
|
|
|
490
667
|
boot(context: ApplicationContext): void;
|
|
491
668
|
}
|
|
492
669
|
|
|
493
|
-
export { Application, ApplicationContext, type AuthContext, type AuthCredentials, AuthManager, type AuthManagerOptions, type AuthContext as AuthRuntimeContext, AuthServiceProvider, type Authenticatable, BaseUserProvider, Controller, type Guard, type GuardContext, type GuardFactory, type InertiaOptions, type InertiaPagePayload, type InertiaResponse, InertiaViewProvider, type InferInertiaProps, MemorySessionStore, type Middleware, ModelUserProvider, type Provider, type ProviderConstructor, type ProviderFactory, type RequireAuthOptions, Route, type RouteDefinition, ScryptHasher, type Session, type SessionData, SessionGuard, type SessionStore, type UserProvider, ViewEngine, attachAuthContext, configureInertiaAssets, createSessionMiddleware, defineMiddleware, formatValidationErrors, getSessionFromContext, inertia, parseRequestPayload, registerDevAssets, requireAuthenticated, requireGuest };
|
|
670
|
+
export { Application, ApplicationContext, type ApplicationListenOptions, type AuthContext, type AuthCredentials, AuthManager, type AuthManagerOptions, type AuthContext as AuthRuntimeContext, AuthServiceProvider, type Authenticatable, AuthenticatableModel, type AutoConfigureInertiaOptions, BaseUserProvider, Controller, type ControllerInertiaProps, type DevBannerOptions, GUREN_ASCII_ART, type Guard, type GuardContext, type GuardFactory, type InertiaOptions, type InertiaPagePayload, type InertiaResponse, type InertiaSsrContext, type InertiaSsrOptions, type InertiaSsrRenderer, type InertiaSsrResult, InertiaViewProvider, type InferInertiaProps, MemorySessionStore, type Middleware, ModelUserProvider, type Provider, type ProviderConstructor, type ProviderFactory, type RequireAuthOptions, Route, type RouteDefinition, ScryptHasher, type Session, type SessionData, SessionGuard, type SessionStore, type StartViteDevServerOptions, type StartedViteDevServer, type UserProvider, ViewEngine, attachAuthContext, autoConfigureInertiaAssets, configureInertiaAssets, createSessionMiddleware, defineMiddleware, formatValidationErrors, getSessionFromContext, inertia, logDevServerBanner, parseRequestPayload, registerDevAssets, requireAuthenticated, requireGuest, startViteDevServer };
|