@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.
- package/dist/Logger-DFifRAtc.js +114 -0
- package/dist/auth/index.js +1 -1
- package/dist/auth/password/DefaultHasher.d.ts +1 -0
- package/dist/{auth-DrbFuxoW.js → auth-CjE2oO50.js} +114 -40
- package/dist/cache/index.js +1 -1
- package/dist/cache/types.d.ts +5 -1
- package/dist/{cache-BOOIr324.js → cache-thXRnaju.js} +19 -4
- package/dist/http/Application.d.ts +15 -0
- package/dist/http/middleware/cookie-session-store.d.ts +38 -0
- package/dist/http/middleware/index.d.ts +5 -3
- package/dist/http/middleware/session-manager.d.ts +16 -0
- package/dist/http/middleware/session.d.ts +22 -0
- package/dist/i18n/index.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +719 -432
- package/dist/lambda/index.js +4 -4
- package/dist/logging/index.js +2 -1
- package/dist/{logging-DcvkE5Dh.js → logging-DXmqqUl4.js} +2 -114
- package/dist/mvc/Router.d.ts +18 -15
- package/dist/mvc/prototype.d.ts +105 -0
- package/dist/redis/lazy-client.d.ts +8 -0
- package/dist/runtime/index.js +4 -4
- package/dist/storage/index.js +1 -1
- package/dist/vite/index.js +147 -0
- package/dist/vite/plugin.d.ts +39 -0
- package/dist/{vite-manifest-C57vi7J9.js → vite-manifest-CdfPfQdj.js} +2 -2
- package/package.json +4 -4
- package/dist/{DocsViewerServiceProvider-D2cuVgtN.js → DocsViewerServiceProvider-DWnlXx_y.js} +1 -1
- package/dist/{i18n-Cg1aajRP.js → i18n-BZ2VrSud.js} +1 -1
- package/dist/{storage-BB59f07j.js → storage-D_yNe54O.js} +1 -1
package/dist/index.js
CHANGED
|
@@ -5,40 +5,42 @@ import { _ as setGate, a as withAuthorization, b as mergeCapabilities, c as Gate
|
|
|
5
5
|
import { a as mapToolResponse, i as describeBuildFailure, n as advertisesStructuredOutput, r as buildToolRequest, s as AGENT_PREFLIGHT_VERDICT_HEADER, t as PREFLIGHT_ARGUMENT } from "./dispatch-BAwzftws.js";
|
|
6
6
|
import { t as trimSlashes } from "./trim-slashes-BLY9hKAa.js";
|
|
7
7
|
import { PATH_PARAM_PATTERN, extractPathParamNames } from "./internal/route-path.js";
|
|
8
|
-
import { a as getRegisteredJobs, c as setQueueDriver, d as getContainer, f as resolve, i as getQueueDriver, l as Container, n as clearJobRegistry, o as registerJob, p as setContainer, r as getJob, s as resolveJobName, t as Job, u as createContainer } from "./Job-CvDwk2Gj.js";
|
|
9
|
-
import { n as ProviderManager, r as ServiceProvider } from "./loopback-guard-DT9gHF0F.js";
|
|
10
8
|
import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-Bd25ZJAV.js";
|
|
11
9
|
import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
|
|
12
|
-
import { A as verifyOAuthState, B as getApiToken, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as TokenGuard, G as readBearerToken, H as getUserApiTokens, I as API_TOKEN_KEY, J as tokenCan, K as revokeAllApiTokens, L as MemoryApiTokenStore, M as isAppRelativePath, N as normalizeRedirectTarget, O as parseOAuthRedirectUrl, P as AuthManager, Q as SessionGuard, R as createApiToken, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as hasBearerHeader, V as getApiTokenOrFail, W as parseApiToken, X as tokenCanAny, Y as tokenCanAll, Z as verifyApiToken, _ as OAUTH_SESSION_BINDING_KEY, _t as getSessionFromContext, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, ct as NodeHasher, d as completePasswordReset, dt as BaseUserProvider, f as createPasswordResetToken, ft as installAgentPrincipal, g as MemoryOAuthStateStore, gt as defaultCookieSecure, h as AuthenticatableModel, ht as createSessionMiddleware, i as createEmailVerificationToken, j as hostMatchesAllowlist, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, lt as ScryptHasher, m as verifyPasswordResetToken, mt as MemorySessionStore, n as buildVerificationUrl, o as parseVerificationUrl, ot as ModelUserProvider, p as parsePasswordResetUrl, pt as readAgentPrincipal, q as revokeApiToken, r as completeEmailVerification, s as requireVerifiedEmail, st as DefaultHasher, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, ut as AuthenticationException, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as createBearerTokenMiddleware } from "./auth-
|
|
10
|
+
import { A as verifyOAuthState, B as getApiToken, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as TokenGuard, G as readBearerToken, H as getUserApiTokens, I as API_TOKEN_KEY, J as tokenCan, K as revokeAllApiTokens, L as MemoryApiTokenStore, M as isAppRelativePath, N as normalizeRedirectTarget, O as parseOAuthRedirectUrl, P as AuthManager, Q as SessionGuard, R as createApiToken, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as hasBearerHeader, V as getApiTokenOrFail, W as parseApiToken, X as tokenCanAny, Y as tokenCanAll, Z as verifyApiToken, _ as OAUTH_SESSION_BINDING_KEY, _t as getSessionFromContext, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, ct as NodeHasher, d as completePasswordReset, dt as BaseUserProvider, f as createPasswordResetToken, ft as installAgentPrincipal, g as MemoryOAuthStateStore, gt as defaultCookieSecure, h as AuthenticatableModel, ht as createSessionMiddleware, i as createEmailVerificationToken, j as hostMatchesAllowlist, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, lt as ScryptHasher, m as verifyPasswordResetToken, mt as MemorySessionStore, n as buildVerificationUrl, o as parseVerificationUrl, ot as ModelUserProvider, p as parsePasswordResetUrl, pt as readAgentPrincipal, q as revokeApiToken, r as completeEmailVerification, s as requireVerifiedEmail, st as DefaultHasher, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, ut as AuthenticationException, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as createBearerTokenMiddleware } from "./auth-CjE2oO50.js";
|
|
11
|
+
import { _ as parseImportMap, c as isViteProduction, d as startViteDevServer, g as DEFAULT_DEV_STYLES_ENTRY, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, m as isWildcardHost, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, p as formatHostPort, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl } from "./vite-manifest-CdfPfQdj.js";
|
|
12
|
+
import { a as getRegisteredJobs, c as setQueueDriver, d as getContainer, f as resolve, i as getQueueDriver, l as Container, n as clearJobRegistry, o as registerJob, p as setContainer, r as getJob, s as resolveJobName, t as Job, u as createContainer } from "./Job-CvDwk2Gj.js";
|
|
13
|
+
import { n as ProviderManager, r as ServiceProvider } from "./loopback-guard-DT9gHF0F.js";
|
|
13
14
|
import { a as md5, c as sha256, d as verifyPassword, i as hmac, l as sha512, n as hash, o as needsRehash, r as hashPassword, s as secureCompare, t as check, u as verifyHmac } from "./Hash-D2DFd8xX.js";
|
|
14
15
|
import { n as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context-CXk_umpT.js";
|
|
15
|
-
import {
|
|
16
|
+
import { n as filterSensitiveData, t as Logger } from "./Logger-DFifRAtc.js";
|
|
17
|
+
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, s as resolveLazyRedisClient, t as CacheManager } from "./cache-thXRnaju.js";
|
|
16
18
|
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
17
19
|
import { r as isMcpEndpointEnabled } from "./endpoint-Dsw3Acvq.js";
|
|
18
20
|
import { n as isHotReloadRuntime, r as matchingOpenParen, t as claimHotDisposable } from "./hot-disposables-B5BXqaIH.js";
|
|
19
|
-
import { a as setI18n, c as tryGetI18n, d as getPluralizationRule, f as pluralizationRules, i as getI18n, l as JsonLoader, n as I18nManager, o as t, p as selectPluralForm, r as createI18n, s as tc, t as MemoryLoader, u as Translator } from "./i18n-
|
|
20
|
-
import { _ as parseImportMap, c as isViteProduction, d as startViteDevServer, g as DEFAULT_DEV_STYLES_ENTRY, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, m as isWildcardHost, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, p as formatHostPort, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl } from "./vite-manifest-C57vi7J9.js";
|
|
21
|
+
import { a as setI18n, c as tryGetI18n, d as getPluralizationRule, f as pluralizationRules, i as getI18n, l as JsonLoader, n as I18nManager, o as t, p as selectPluralForm, r as createI18n, s as tc, t as MemoryLoader, u as Translator } from "./i18n-BZ2VrSud.js";
|
|
21
22
|
import { r as isDocsViewerEnabled } from "./endpoint-BXipU2Jj.js";
|
|
22
23
|
import { t as jsx_runtime_exports } from "./jsx-runtime.js";
|
|
23
24
|
import { readObjectSchema, toJsonSchema } from "./internal/zod-json-schema.js";
|
|
24
25
|
import { a as RequestFinished, c as UserLoggedOut, d as createEventManager, f as Event, i as JobProcessed, l as Listener, n as ApplicationStarted, o as RequestReceived, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as EventManager } from "./events-DOmAHDeP.js";
|
|
25
26
|
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "./notifications-D0VXkFLF.js";
|
|
26
|
-
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, t as CacheManager } from "./cache-BOOIr324.js";
|
|
27
27
|
import { a as processJob, c as RedisDriver$1, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver$1 } from "./queue-zPPYZdif.js";
|
|
28
28
|
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "./mail-9CrvJyBZ.js";
|
|
29
|
+
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";
|
|
29
30
|
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "./broadcasting-B5RzB0A2.js";
|
|
30
31
|
import { a as random, c as randomHex, d as sample, f as shuffle, i as pick, l as randomInt, m as uuid, n as generatePassword, o as randomBase64, p as urlSafeToken, r as generateSlug, s as randomBase64Url, t as generateOtp, u as randomString } from "./Random-S0OvCuR8.js";
|
|
31
32
|
import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "./encryption-uwP3Di4D.js";
|
|
32
|
-
import { a as LocalDriver, i as S3Driver, n as createStorageManager, o as warnOnce, r as MemoryDriver$2, t as StorageManager } from "./storage-
|
|
33
|
+
import { a as LocalDriver, i as S3Driver, n as createStorageManager, o as warnOnce, r as MemoryDriver$2, t as StorageManager } from "./storage-D_yNe54O.js";
|
|
33
34
|
import { a as CacheCheck, c as HealthManager, i as StorageCheck, l as createHealthManager, n as customCheck, o as RedisCheck, r as MemoryCheck, s as DatabaseCheck, t as CustomCheck, u as HealthCheck } from "./health-DQSvUplL.js";
|
|
34
35
|
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "./scheduling-C6tcOtUl.js";
|
|
35
36
|
import { Hono } from "hono";
|
|
36
37
|
import { deleteCookie, getCookie } from "hono/cookie";
|
|
38
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
39
|
+
import { isAbsolute, join, resolve as resolve$1 } from "node:path";
|
|
40
|
+
import { pathToFileURL } from "node:url";
|
|
37
41
|
import { cors } from "hono/cors";
|
|
38
42
|
import { createMiddleware } from "hono/factory";
|
|
39
43
|
import { parseAccept } from "hono/utils/accept";
|
|
40
|
-
import { isAbsolute, join, resolve as resolve$1 } from "node:path";
|
|
41
|
-
import { pathToFileURL } from "node:url";
|
|
42
44
|
import { serialize } from "hono/utils/cookie";
|
|
43
45
|
import { existsSync } from "node:fs";
|
|
44
46
|
import * as readline from "readline";
|
|
@@ -46,62 +48,562 @@ import { join as join$1 } from "path";
|
|
|
46
48
|
//#region src/support/error-polyfill.ts
|
|
47
49
|
let patched = false;
|
|
48
50
|
/**
|
|
49
|
-
* Bun 1.x throws from Error.captureStackTrace unless the first argument is a
|
|
50
|
-
* real Error. Packages that pass plain objects (notably follow-redirects, which
|
|
51
|
-
* Node tolerates) then crash SSR boot before Inertia can import the SSR entry.
|
|
52
|
-
* This mirrors Node by copying a real Error's stack onto whatever it is given.
|
|
51
|
+
* Bun 1.x throws from Error.captureStackTrace unless the first argument is a
|
|
52
|
+
* real Error. Packages that pass plain objects (notably follow-redirects, which
|
|
53
|
+
* Node tolerates) then crash SSR boot before Inertia can import the SSR entry.
|
|
54
|
+
* This mirrors Node by copying a real Error's stack onto whatever it is given.
|
|
55
|
+
*/
|
|
56
|
+
function ensureErrorStackTracePolyfill() {
|
|
57
|
+
if (patched) return;
|
|
58
|
+
const capture = Error.captureStackTrace;
|
|
59
|
+
if (typeof capture !== "function") {
|
|
60
|
+
Error.captureStackTrace = (target) => copyStackFromNewError(target);
|
|
61
|
+
patched = true;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
Error.captureStackTrace = (target, constructorOpt) => {
|
|
65
|
+
if (target instanceof Error) try {
|
|
66
|
+
return capture(target, constructorOpt);
|
|
67
|
+
} catch {}
|
|
68
|
+
const placeholder = /* @__PURE__ */ new Error();
|
|
69
|
+
capture(placeholder, constructorOpt);
|
|
70
|
+
copyStackFromError(target, placeholder);
|
|
71
|
+
return target;
|
|
72
|
+
};
|
|
73
|
+
patched = true;
|
|
74
|
+
}
|
|
75
|
+
function copyStackFromNewError(target) {
|
|
76
|
+
copyStackFromError(target, /* @__PURE__ */ new Error());
|
|
77
|
+
}
|
|
78
|
+
function copyStackFromError(target, source) {
|
|
79
|
+
if (!target || typeof target !== "object") return;
|
|
80
|
+
if (source.stack) Object.defineProperty(target, "stack", {
|
|
81
|
+
configurable: true,
|
|
82
|
+
enumerable: false,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: source.stack
|
|
85
|
+
});
|
|
86
|
+
if (source.name && !("name" in target)) Object.defineProperty(target, "name", {
|
|
87
|
+
configurable: true,
|
|
88
|
+
enumerable: false,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: source.name
|
|
91
|
+
});
|
|
92
|
+
if (source.message && !("message" in target)) Object.defineProperty(target, "message", {
|
|
93
|
+
configurable: true,
|
|
94
|
+
enumerable: false,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: source.message
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/mvc/mount-route.ts
|
|
101
|
+
/**
|
|
102
|
+
* Mounts a route with a dynamic HTTP method string. Hono's `app.on()` overloads
|
|
103
|
+
* expect literal method types, so this helper holds the one narrowing cast.
|
|
104
|
+
*/
|
|
105
|
+
function mountRoute(app, method, path, ...handlers) {
|
|
106
|
+
app.on(method, path, ...handlers);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/mvc/inertia/InertiaEngine.ts
|
|
110
|
+
ensureErrorStackTracePolyfill();
|
|
111
|
+
let documentOptions;
|
|
112
|
+
/**
|
|
113
|
+
* Register app-wide document defaults for server-rendered Inertia responses;
|
|
114
|
+
* call it at module scope in the app entry so every runtime picks it up.
|
|
115
|
+
* Process-wide, not request-scoped: calling it mid-flight leaks the policy into
|
|
116
|
+
* in-flight requests — use the {@link InertiaOptions} fields per response.
|
|
117
|
+
* Values are emitted verbatim, so never pass user input. `undefined` clears.
|
|
118
|
+
*/
|
|
119
|
+
function setInertiaDocument(options) {
|
|
120
|
+
documentOptions = options;
|
|
121
|
+
}
|
|
122
|
+
let defaultSsrRenderer;
|
|
123
|
+
/**
|
|
124
|
+
* Register a process-wide default SSR renderer, for adapters whose bundler
|
|
125
|
+
* cannot resolve a runtime path (Workers has no filesystem for
|
|
126
|
+
* `GUREN_INERTIA_SSR_ENTRY`'s dynamic import). Per-call `ssr.render` still
|
|
127
|
+
* wins; `undefined` clears (test isolation).
|
|
128
|
+
*/
|
|
129
|
+
function setInertiaSsrRenderer(renderer) {
|
|
130
|
+
defaultSsrRenderer = renderer;
|
|
131
|
+
}
|
|
132
|
+
const DEFAULT_TITLE = "Guren";
|
|
133
|
+
const DEV_FALLBACK_IMPORT_MAP = {
|
|
134
|
+
react: "https://esm.sh/react@19.0.0?dev",
|
|
135
|
+
"react/jsx-runtime": "https://esm.sh/react@19.0.0/jsx-runtime?dev",
|
|
136
|
+
"react/jsx-dev-runtime": "https://esm.sh/react@19.0.0/jsx-dev-runtime?dev",
|
|
137
|
+
"react-dom/client": "https://esm.sh/react-dom@19.0.0/client?dev",
|
|
138
|
+
"@guren/inertia-client": "/vendor/inertia-client.tsx",
|
|
139
|
+
"@inertiajs/react": "https://esm.sh/@inertiajs/react@2.2.15?dev&external=react,react-dom/client"
|
|
140
|
+
};
|
|
141
|
+
async function inertia(component, props, options = {}) {
|
|
142
|
+
const resolvedVersion = options.version ?? process.env.GUREN_INERTIA_VERSION ?? void 0;
|
|
143
|
+
const page = {
|
|
144
|
+
component,
|
|
145
|
+
props,
|
|
146
|
+
url: options.url ?? inertiaPageUrl(options.request) ?? "",
|
|
147
|
+
version: resolvedVersion
|
|
148
|
+
};
|
|
149
|
+
const request = options.request;
|
|
150
|
+
const isInertiaVisit = Boolean(request?.headers.get("X-Inertia"));
|
|
151
|
+
const prefersJson = request ? acceptsJson(request) : false;
|
|
152
|
+
const versionHeader = resolvedVersion ? { "X-Inertia-Version": resolvedVersion } : {};
|
|
153
|
+
if (request && resolvedVersion && isInertiaVisit && request.method === "GET") {
|
|
154
|
+
if (request.headers.get("X-Inertia-Version") !== resolvedVersion) return new Response(null, {
|
|
155
|
+
status: 409,
|
|
156
|
+
headers: {
|
|
157
|
+
"X-Inertia-Location": options.url ?? request.url,
|
|
158
|
+
Vary: "Accept"
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (isInertiaVisit || prefersJson) return new Response(serializePage(page), {
|
|
163
|
+
status: options.status ?? 200,
|
|
164
|
+
headers: {
|
|
165
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
166
|
+
"X-Inertia": "true",
|
|
167
|
+
Vary: "Accept",
|
|
168
|
+
...versionHeader,
|
|
169
|
+
...options.headers
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const html = await renderDocument$1(page, options);
|
|
173
|
+
return new Response(html, {
|
|
174
|
+
status: options.status ?? 200,
|
|
175
|
+
headers: {
|
|
176
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
177
|
+
"X-Inertia": "true",
|
|
178
|
+
Vary: "Accept",
|
|
179
|
+
...versionHeader,
|
|
180
|
+
...options.headers
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The Inertia protocol's page `url` is the request path plus query string, kept
|
|
186
|
+
* relative. Derived from the request when the caller does not override it.
|
|
187
|
+
*/
|
|
188
|
+
function inertiaPageUrl(request) {
|
|
189
|
+
if (!request) return;
|
|
190
|
+
const { pathname, search } = new URL(request.url);
|
|
191
|
+
return `${pathname}${search}`;
|
|
192
|
+
}
|
|
193
|
+
async function renderDocument$1(page, options) {
|
|
194
|
+
const defaultEntry = process.env.GUREN_INERTIA_ENTRY || "/resources/js/app.tsx";
|
|
195
|
+
const entry = options.entry ?? defaultEntry;
|
|
196
|
+
const title = escapeHtml$2(options.title ?? DEFAULT_TITLE);
|
|
197
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
198
|
+
const configuredStyles = options.styles ?? parseStylesEnv(process.env.GUREN_INERTIA_STYLES);
|
|
199
|
+
const styles = !isProduction && options.styles === void 0 && isDevServerEntry(entry) ? configuredStyles.filter((href) => href !== DEFAULT_DEV_STYLES_ENTRY) : configuredStyles;
|
|
200
|
+
const envImportMap = parseImportMap(process.env.GUREN_INERTIA_IMPORT_MAP, { context: "GUREN_INERTIA_IMPORT_MAP" });
|
|
201
|
+
const importMapEntries = {
|
|
202
|
+
...isProduction ? {} : DEV_FALLBACK_IMPORT_MAP,
|
|
203
|
+
...envImportMap,
|
|
204
|
+
...options.importMap
|
|
205
|
+
};
|
|
206
|
+
const importMap = JSON.stringify({ imports: importMapEntries }, null, 2);
|
|
207
|
+
const serializedPage = serializePage(page);
|
|
208
|
+
const stylesheetLinks = renderStyles(styles);
|
|
209
|
+
const criticalCss = resolveDocumentValue("criticalCss", options, page.component);
|
|
210
|
+
const prepaintScript = resolveDocumentValue("prepaintScript", options, page.component);
|
|
211
|
+
const headMarkup = resolveDocumentValue("head", options, page.component);
|
|
212
|
+
const ssrResult = await tryRenderSsr(page, options);
|
|
213
|
+
const headElements = (ssrResult?.head ?? []).map(normalizeHeadElement);
|
|
214
|
+
const headSegments = [
|
|
215
|
+
"<meta charset=\"utf-8\" />",
|
|
216
|
+
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />",
|
|
217
|
+
headElements.some((element) => /<title\b[^>]*>/iu.test(element)) ? "" : `<title>${title}</title>`,
|
|
218
|
+
headMarkup ?? "",
|
|
219
|
+
criticalCss ? `<style id="guren-critical">${criticalCss}</style>` : "",
|
|
220
|
+
prepaintScript ? `<script>${prepaintScript}<\/script>` : "",
|
|
221
|
+
stylesheetLinks,
|
|
222
|
+
...headElements,
|
|
223
|
+
Object.keys(importMapEntries).length > 0 ? `<script type="importmap">${importMap}<\/script>` : "",
|
|
224
|
+
`<script>window.__INERTIA_PAGE__ = ${serializedPage};<\/script>`
|
|
225
|
+
].filter((segment) => segment && segment.length > 0);
|
|
226
|
+
const appMarkup = ssrResult?.body ?? `<script data-page="app" type="application/json">${serializedPage}<\/script><div id="app"></div>`;
|
|
227
|
+
const bodyClass = resolveDocumentValue("bodyClass", options, page.component);
|
|
228
|
+
const bodyAttributes = bodyClass ? ` class="${escapeAttribute(bodyClass)}"` : "";
|
|
229
|
+
return `<!DOCTYPE html>
|
|
230
|
+
<html lang="${escapeAttribute(options.lang ?? "en")}">
|
|
231
|
+
<head>
|
|
232
|
+
${headSegments.join("\n ")}
|
|
233
|
+
</head>
|
|
234
|
+
<body${bodyAttributes}>
|
|
235
|
+
${appMarkup}
|
|
236
|
+
<script type="module" src="${entry}"><\/script>
|
|
237
|
+
</body>
|
|
238
|
+
</html>`;
|
|
239
|
+
}
|
|
240
|
+
async function tryRenderSsr(page, options) {
|
|
241
|
+
const ssrOptions = options.ssr;
|
|
242
|
+
if (ssrOptions?.enabled === false) return;
|
|
243
|
+
const manifest = (ssrOptions?.manifest ?? process.env.GUREN_INERTIA_SSR_MANIFEST)?.trim() || void 0;
|
|
244
|
+
const renderer = ssrOptions?.render ?? defaultSsrRenderer ?? await loadSsrRenderer(ssrOptions?.entry ?? process.env.GUREN_INERTIA_SSR_ENTRY);
|
|
245
|
+
if (!renderer) return;
|
|
246
|
+
try {
|
|
247
|
+
const result = await renderer({
|
|
248
|
+
page,
|
|
249
|
+
request: options.request,
|
|
250
|
+
manifest
|
|
251
|
+
});
|
|
252
|
+
if (!result || typeof result.body !== "string") return;
|
|
253
|
+
return {
|
|
254
|
+
body: result.body,
|
|
255
|
+
head: Array.isArray(result.head) ? result.head : []
|
|
256
|
+
};
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error("Inertia SSR renderer failed; falling back to client rendering.", error);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async function loadSsrRenderer(entry) {
|
|
263
|
+
const specifier = entry?.trim();
|
|
264
|
+
if (!specifier) return;
|
|
265
|
+
const normalized = normalizeSsrSpecifier(specifier);
|
|
266
|
+
try {
|
|
267
|
+
const renderCandidate = extractSsrRenderer(await import(normalized));
|
|
268
|
+
if (!renderCandidate) {
|
|
269
|
+
console.warn(`Inertia SSR entry "${specifier}" does not export a renderer. Expected a default export or a named "render" function.`);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
return renderCandidate;
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error(`Failed to import Inertia SSR entry "${specifier}".`, error);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function extractSsrRenderer(module) {
|
|
279
|
+
if (!module || typeof module !== "object") return;
|
|
280
|
+
const candidate = typeof module.render === "function" ? module.render : typeof module.default === "function" ? module.default : void 0;
|
|
281
|
+
if (!candidate) return;
|
|
282
|
+
return (context) => Promise.resolve(candidate(context));
|
|
283
|
+
}
|
|
284
|
+
function normalizeSsrSpecifier(specifier) {
|
|
285
|
+
if (specifier.startsWith("file://") || isUrlLike(specifier)) return specifier;
|
|
286
|
+
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
287
|
+
const absolute = resolve$1(process.cwd(), specifier);
|
|
288
|
+
return pathToFileURL(absolute).href;
|
|
289
|
+
}
|
|
290
|
+
if (isAbsolute(specifier)) return pathToFileURL(specifier).href;
|
|
291
|
+
return specifier;
|
|
292
|
+
}
|
|
293
|
+
function isUrlLike(specifier) {
|
|
294
|
+
return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(specifier);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* An absolute http(s) entry means an asset dev server (Vite) is serving the
|
|
298
|
+
* module graph; a same-origin path means source files are served directly,
|
|
299
|
+
* where the raw stylesheet link is the only styling.
|
|
300
|
+
*/
|
|
301
|
+
function isDevServerEntry(entry) {
|
|
302
|
+
return /^https?:\/\//iu.test(entry);
|
|
303
|
+
}
|
|
304
|
+
function renderStyles(styles) {
|
|
305
|
+
if (!styles.length) return "";
|
|
306
|
+
return styles.map((href) => `<link rel="stylesheet" href="${escapeAttribute(href)}" />`).join("\n ");
|
|
307
|
+
}
|
|
308
|
+
function normalizeHeadElement(element) {
|
|
309
|
+
return (typeof element === "string" ? element : String(element ?? "")).replace(/href="\/(?!public\/)([^"?]+\.(?:js|css))(\?[^"']*)?"/g, (_match, file, query = "") => `href="/public/assets/${file}${query}"`);
|
|
310
|
+
}
|
|
311
|
+
/** One document field: per-response override, then app-wide default, then "". */
|
|
312
|
+
function resolveDocumentValue(key, options, componentName) {
|
|
313
|
+
const override = options[key];
|
|
314
|
+
if (override !== void 0) return override;
|
|
315
|
+
const value = documentOptions?.[key];
|
|
316
|
+
return (typeof value === "function" ? value({ component: componentName }) : value) ?? "";
|
|
317
|
+
}
|
|
318
|
+
function serializePage(page) {
|
|
319
|
+
return JSON.stringify(page).replace(/[<\u2028\u2029]/gu, (char) => {
|
|
320
|
+
switch (char) {
|
|
321
|
+
case "<": return "\\u003c";
|
|
322
|
+
case "\u2028": return "\\u2028";
|
|
323
|
+
case "\u2029": return "\\u2029";
|
|
324
|
+
default: return char;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function acceptsJson(request) {
|
|
329
|
+
const accept = request.headers.get("accept")?.toLowerCase() ?? "";
|
|
330
|
+
if (!accept || accept === "*/*") return false;
|
|
331
|
+
if (accept.includes("text/html")) return false;
|
|
332
|
+
return accept.includes("application/json") || accept.includes("json");
|
|
333
|
+
}
|
|
334
|
+
function escapeHtml$2(value) {
|
|
335
|
+
return value.replace(/[&<>"']/gu, (char) => {
|
|
336
|
+
switch (char) {
|
|
337
|
+
case "&": return "&";
|
|
338
|
+
case "<": return "<";
|
|
339
|
+
case ">": return ">";
|
|
340
|
+
case "\"": return """;
|
|
341
|
+
case "'": return "'";
|
|
342
|
+
default: return char;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function escapeAttribute(value) {
|
|
347
|
+
return value.replace(/[&"]/gu, (char) => {
|
|
348
|
+
if (char === "&") return "&";
|
|
349
|
+
return """;
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function parseStylesEnv(value) {
|
|
353
|
+
if (!value) return [];
|
|
354
|
+
return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/mvc/inertia/shared.ts
|
|
358
|
+
/** Container binding key for the scoped {@link SharedInertiaPropsRegistry}. */
|
|
359
|
+
const INERTIA_SHARED_PROPS_BINDING = "inertia.sharedProps";
|
|
360
|
+
/**
|
|
361
|
+
* Registrations are numbered from one process-wide counter so that props keep
|
|
362
|
+
* resolving in registration order — later registrations win on conflicting
|
|
363
|
+
* keys — no matter which registry each one landed in.
|
|
364
|
+
*/
|
|
365
|
+
let registrationSequence = 0;
|
|
366
|
+
/**
|
|
367
|
+
* Holds the shared-props resolvers for one scope: either a single
|
|
368
|
+
* Application's container or the module-global fallback for bare-Hono apps.
|
|
369
|
+
*/
|
|
370
|
+
var SharedInertiaPropsRegistry = class {
|
|
371
|
+
resolvers = [];
|
|
372
|
+
/** Replace every resolver registered in this scope. */
|
|
373
|
+
set(resolverFn) {
|
|
374
|
+
this.resolvers = resolverFn ? [orderedResolver(resolverFn)] : [];
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Register additional shared props without replacing resolvers registered
|
|
378
|
+
* earlier — the new resolver's props are merged over the previous ones.
|
|
379
|
+
*/
|
|
380
|
+
share(resolverFn) {
|
|
381
|
+
this.resolvers.push(orderedResolver(resolverFn));
|
|
382
|
+
}
|
|
383
|
+
/** The resolvers registered in this scope, ordered by registration. */
|
|
384
|
+
entries() {
|
|
385
|
+
return this.resolvers;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* The scope's registrations composed into one resolver, or null when empty.
|
|
389
|
+
* The composition is a snapshot: resolvers registered later are not picked up.
|
|
390
|
+
*/
|
|
391
|
+
get() {
|
|
392
|
+
if (this.resolvers.length === 0) return null;
|
|
393
|
+
if (this.resolvers.length === 1) return this.resolvers[0].resolve;
|
|
394
|
+
const snapshot = [...this.resolvers];
|
|
395
|
+
return (ctx) => applyResolvers(snapshot, ctx);
|
|
396
|
+
}
|
|
397
|
+
async resolve(ctx) {
|
|
398
|
+
return applyResolvers(this.resolvers, ctx);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
function orderedResolver(resolverFn) {
|
|
402
|
+
return {
|
|
403
|
+
seq: registrationSequence++,
|
|
404
|
+
resolve: resolverFn
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
async function applyResolvers(entries, ctx) {
|
|
408
|
+
const merged = {};
|
|
409
|
+
for (const entry of entries) {
|
|
410
|
+
const props = await entry.resolve(ctx);
|
|
411
|
+
if (props && typeof props === "object") Object.assign(merged, props);
|
|
412
|
+
}
|
|
413
|
+
return merged;
|
|
414
|
+
}
|
|
415
|
+
const globalRegistry = new SharedInertiaPropsRegistry();
|
|
416
|
+
/** The registry bound to `container`, or null when it owns none yet. */
|
|
417
|
+
function scopedRegistry(container) {
|
|
418
|
+
if (!container?.has?.("inertia.sharedProps")) return null;
|
|
419
|
+
return container.make(INERTIA_SHARED_PROPS_BINDING);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* The shared-props registry scoped to `container`, binding a fresh one on
|
|
423
|
+
* first use.
|
|
424
|
+
*/
|
|
425
|
+
function ensureSharedInertiaPropsRegistry(container) {
|
|
426
|
+
const existing = scopedRegistry(container);
|
|
427
|
+
if (existing) return existing;
|
|
428
|
+
const registry = new SharedInertiaPropsRegistry();
|
|
429
|
+
container.instance(INERTIA_SHARED_PROPS_BINDING, registry);
|
|
430
|
+
return registry;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Replace the module-global shared props resolver. Props registered on an
|
|
434
|
+
* application's container (see {@link shareInertiaProps}) are unaffected.
|
|
435
|
+
*/
|
|
436
|
+
function setInertiaSharedProps(resolverFn) {
|
|
437
|
+
globalRegistry.set(resolverFn);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* The module-global registrations composed into one resolver, for manual
|
|
441
|
+
* composition. Container-scoped props are not included — get those from
|
|
442
|
+
* `ensureSharedInertiaPropsRegistry(container).get()`.
|
|
53
443
|
*/
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
const capture = Error.captureStackTrace;
|
|
57
|
-
if (typeof capture !== "function") {
|
|
58
|
-
Error.captureStackTrace = (target) => copyStackFromNewError(target);
|
|
59
|
-
patched = true;
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
Error.captureStackTrace = (target, constructorOpt) => {
|
|
63
|
-
if (target instanceof Error) try {
|
|
64
|
-
return capture(target, constructorOpt);
|
|
65
|
-
} catch {}
|
|
66
|
-
const placeholder = /* @__PURE__ */ new Error();
|
|
67
|
-
capture(placeholder, constructorOpt);
|
|
68
|
-
copyStackFromError(target, placeholder);
|
|
69
|
-
return target;
|
|
70
|
-
};
|
|
71
|
-
patched = true;
|
|
444
|
+
function getInertiaSharedPropsResolver() {
|
|
445
|
+
return globalRegistry.get();
|
|
72
446
|
}
|
|
73
|
-
|
|
74
|
-
|
|
447
|
+
/**
|
|
448
|
+
* Register additional shared props without replacing earlier resolvers, so
|
|
449
|
+
* several providers can each contribute (`setInertiaSharedProps` replaces
|
|
450
|
+
* wholesale). Pass the provider's `this.container` to scope them; without it
|
|
451
|
+
* they are module-global and a second Application in the process shares them.
|
|
452
|
+
*/
|
|
453
|
+
function shareInertiaProps(resolverFn, container) {
|
|
454
|
+
(container ? ensureSharedInertiaPropsRegistry(container) : globalRegistry).share(resolverFn);
|
|
75
455
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
enumerable: false,
|
|
87
|
-
writable: true,
|
|
88
|
-
value: source.name
|
|
89
|
-
});
|
|
90
|
-
if (source.message && !("message" in target)) Object.defineProperty(target, "message", {
|
|
91
|
-
configurable: true,
|
|
92
|
-
enumerable: false,
|
|
93
|
-
writable: true,
|
|
94
|
-
value: source.message
|
|
95
|
-
});
|
|
456
|
+
/**
|
|
457
|
+
* Resolve shared props for a request, merging the module-global registrations
|
|
458
|
+
* with those scoped to `container` in registration order.
|
|
459
|
+
*/
|
|
460
|
+
async function resolveSharedInertiaProps(ctx, container) {
|
|
461
|
+
const scoped = scopedRegistry(container);
|
|
462
|
+
if (!scoped) return globalRegistry.resolve(ctx);
|
|
463
|
+
const globalEntries = globalRegistry.entries();
|
|
464
|
+
if (globalEntries.length === 0) return scoped.resolve(ctx);
|
|
465
|
+
return applyResolvers([...globalEntries, ...scoped.entries()].sort((a, b) => a.seq - b.seq), ctx);
|
|
96
466
|
}
|
|
97
467
|
//#endregion
|
|
98
|
-
//#region src/mvc/
|
|
468
|
+
//#region src/mvc/prototype.ts
|
|
469
|
+
const PROTOTYPE_HANDLER = Symbol.for("guren.prototype.handler");
|
|
470
|
+
const prototype = Object.freeze({ [PROTOTYPE_HANDLER]: true });
|
|
471
|
+
function isPrototypeHandler(value) {
|
|
472
|
+
return typeof value === "object" && value !== null && value[PROTOTYPE_HANDLER] === true;
|
|
473
|
+
}
|
|
474
|
+
/** Container key the loaded fixture is bound under once `Application` has validated the prototype routes. */
|
|
475
|
+
const PROTOTYPE_FIXTURE_BINDING = "prototype.fixture";
|
|
476
|
+
function isFixture(value) {
|
|
477
|
+
return typeof value === "object" && value !== null && typeof value.routes === "object" && value.routes !== null;
|
|
478
|
+
}
|
|
479
|
+
async function loadPrototypeFixture(loader) {
|
|
480
|
+
const loaded = await loader();
|
|
481
|
+
const fixture = isFixture(loaded) ? loaded : loaded.default;
|
|
482
|
+
if (!isFixture(fixture)) throw new Error("createApp({ prototype }) loaded a module that does not export a definePrototype() result as its default export.");
|
|
483
|
+
return fixture;
|
|
484
|
+
}
|
|
485
|
+
/** One `state()` per fixture per process: shared by every request, reset by a restart. */
|
|
486
|
+
const processState = /* @__PURE__ */ new WeakMap();
|
|
487
|
+
function stateOf(fixture) {
|
|
488
|
+
if (!processState.has(fixture)) processState.set(fixture, fixture.state?.() ?? {});
|
|
489
|
+
return processState.get(fixture);
|
|
490
|
+
}
|
|
491
|
+
function enforce(schema, data) {
|
|
492
|
+
if (!schema) return;
|
|
493
|
+
const result = schema.safeParse(data);
|
|
494
|
+
if (!result.success) throw ValidationException.withMessages(formatValidationErrors(result.error));
|
|
495
|
+
}
|
|
496
|
+
const BODYLESS_METHODS = /* @__PURE__ */ new Set([
|
|
497
|
+
"GET",
|
|
498
|
+
"HEAD",
|
|
499
|
+
"OPTIONS"
|
|
500
|
+
]);
|
|
99
501
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
502
|
+
* The route's handler: the fixture entry for the route name, run against the
|
|
503
|
+
* same context shape the browser client builds. The route contract is enforced
|
|
504
|
+
* first (`params`, `query`, `body`; not `output`, which only a response has), so `guren
|
|
505
|
+
* audit`'s "runtime-enforced" verdict stays true here.
|
|
506
|
+
*/
|
|
507
|
+
function createPrototypeRouteHandler(route, deps) {
|
|
508
|
+
return async (c) => {
|
|
509
|
+
const fixture = resolveFixture(deps.container);
|
|
510
|
+
const name = route.name;
|
|
511
|
+
const handler = name ? fixture.routes[name] : void 0;
|
|
512
|
+
if (!name || !handler) throw new Error(`Prototype route ${route.method} ${route.path} has no fixture entry${name ? ` for "${name}"` : ""}.`);
|
|
513
|
+
const params = c.req.param();
|
|
514
|
+
const query = flattenRequestQueries(c);
|
|
515
|
+
enforce(route.schemas?.params, params);
|
|
516
|
+
enforce(route.schemas?.query, query);
|
|
517
|
+
const method = c.req.method.toUpperCase();
|
|
518
|
+
const body = BODYLESS_METHODS.has(method) ? void 0 : await parseRequestBody(c);
|
|
519
|
+
enforce(route.schemas?.body, body);
|
|
520
|
+
const session = getSessionFromContext(c);
|
|
521
|
+
const shared = {
|
|
522
|
+
...fixture.shared,
|
|
523
|
+
...await resolveSharedInertiaProps(c, deps.container)
|
|
524
|
+
};
|
|
525
|
+
const url = new URL(c.req.url);
|
|
526
|
+
const result = await handler({
|
|
527
|
+
method,
|
|
528
|
+
url: `${url.pathname}${url.search}`,
|
|
529
|
+
params,
|
|
530
|
+
query,
|
|
531
|
+
body,
|
|
532
|
+
state: stateOf(fixture),
|
|
533
|
+
shared,
|
|
534
|
+
page: (contract, props) => ({
|
|
535
|
+
kind: "page",
|
|
536
|
+
component: componentOf(contract),
|
|
537
|
+
props
|
|
538
|
+
}),
|
|
539
|
+
redirect: (to, redirectParams) => ({
|
|
540
|
+
kind: "redirect",
|
|
541
|
+
to,
|
|
542
|
+
params: redirectParams
|
|
543
|
+
}),
|
|
544
|
+
location: (target) => ({
|
|
545
|
+
kind: "location",
|
|
546
|
+
url: target
|
|
547
|
+
}),
|
|
548
|
+
errors: (errors) => ({
|
|
549
|
+
kind: "errors",
|
|
550
|
+
errors
|
|
551
|
+
}),
|
|
552
|
+
notFound: () => ({ kind: "not-found" }),
|
|
553
|
+
flash: (key, value) => session?.flash(key, value)
|
|
554
|
+
});
|
|
555
|
+
if (!isResult(result)) throw new Error(`Prototype entry "${name}" returned something other than page()/redirect()/errors()/location()/notFound().`);
|
|
556
|
+
return answer(result, c, fixture, shared, deps);
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
const RESULT_KINDS = /* @__PURE__ */ new Set([
|
|
560
|
+
"page",
|
|
561
|
+
"redirect",
|
|
562
|
+
"location",
|
|
563
|
+
"errors",
|
|
564
|
+
"not-found"
|
|
565
|
+
]);
|
|
566
|
+
function componentOf(contract) {
|
|
567
|
+
return contract.component ?? contract.id;
|
|
568
|
+
}
|
|
569
|
+
function isResult(value) {
|
|
570
|
+
return typeof value === "object" && value !== null && RESULT_KINDS.has(String(value.kind));
|
|
571
|
+
}
|
|
572
|
+
function resolveFixture(container) {
|
|
573
|
+
let fixture;
|
|
574
|
+
try {
|
|
575
|
+
fixture = container?.make(PROTOTYPE_FIXTURE_BINDING);
|
|
576
|
+
} catch {
|
|
577
|
+
fixture = void 0;
|
|
578
|
+
}
|
|
579
|
+
if (!isFixture(fixture)) throw new Error("A prototype route was dispatched before its fixture was loaded. Pass `prototype: () => import(...)` to createApp() and mount routes through the application, which validates and loads it at boot.");
|
|
580
|
+
return fixture;
|
|
581
|
+
}
|
|
582
|
+
async function answer(result, c, fixture, shared, deps) {
|
|
583
|
+
switch (result.kind) {
|
|
584
|
+
case "page": return inertia(result.component, {
|
|
585
|
+
...shared,
|
|
586
|
+
...result.props
|
|
587
|
+
}, { request: c.req.raw });
|
|
588
|
+
case "redirect": return c.redirect(deps.routeUrl(result.to, result.params), 303);
|
|
589
|
+
case "location":
|
|
590
|
+
if (c.req.header("X-Inertia")) return new Response(null, {
|
|
591
|
+
status: 409,
|
|
592
|
+
headers: { "X-Inertia-Location": result.url }
|
|
593
|
+
});
|
|
594
|
+
return c.redirect(result.url, 302);
|
|
595
|
+
case "errors": throw ValidationException.withMessages(result.errors);
|
|
596
|
+
case "not-found":
|
|
597
|
+
if (fixture.notFoundPage) return inertia(componentOf(fixture.notFoundPage), {
|
|
598
|
+
...shared,
|
|
599
|
+
status: 404,
|
|
600
|
+
message: "Not Found"
|
|
601
|
+
}, {
|
|
602
|
+
request: c.req.raw,
|
|
603
|
+
status: 404
|
|
604
|
+
});
|
|
605
|
+
throw HttpException.notFound();
|
|
606
|
+
}
|
|
105
607
|
}
|
|
106
608
|
//#endregion
|
|
107
609
|
//#region src/mvc/Router.ts
|
|
@@ -285,7 +787,10 @@ var Router = class {
|
|
|
285
787
|
mount(app, options = {}) {
|
|
286
788
|
for (const route of this.registry) {
|
|
287
789
|
const resolvedMiddlewares = this.resolveMiddlewareNames(route.routeMiddlewareNames);
|
|
288
|
-
const handler =
|
|
790
|
+
const handler = isPrototypeHandler(route.handler) ? createPrototypeRouteHandler(route, {
|
|
791
|
+
container: options.container,
|
|
792
|
+
routeUrl: (name, params) => this.route(name, params)
|
|
793
|
+
}) : resolveHandler(route.handler, this.modelBindings, options.container, route.bindings, route.path);
|
|
289
794
|
const contractMiddleware = createContractValidationMiddleware(route);
|
|
290
795
|
const inlineMiddlewares = [...route.scopedMiddlewares, ...route.middlewares];
|
|
291
796
|
const preflightMiddleware = createAgentPreflightMiddleware(route, () => this.aggregateCapabilities(route.routeMiddlewareNames, inlineMiddlewares));
|
|
@@ -308,11 +813,12 @@ var Router = class {
|
|
|
308
813
|
this.modelBindings.clear();
|
|
309
814
|
}
|
|
310
815
|
definitions() {
|
|
311
|
-
return this.registry.map(({ method, path, name, schemas, resource, openapi, routeMiddlewareNames, middlewares, scopedMiddlewares, handler, bindings, agent }) => ({
|
|
816
|
+
return this.registry.map(({ method, path, name, schemas, resource, openapi, routeMiddlewareNames, middlewares, scopedMiddlewares, handler, bindings, agent, prototype }) => ({
|
|
312
817
|
method,
|
|
313
818
|
path,
|
|
314
819
|
name,
|
|
315
820
|
schemas,
|
|
821
|
+
prototype,
|
|
316
822
|
resource: serializeResourceHint(resource),
|
|
317
823
|
agent: agent ? cloneAgentMetadata(agent) : void 0,
|
|
318
824
|
middlewareNames: [...routeMiddlewareNames],
|
|
@@ -345,6 +851,13 @@ var Router = class {
|
|
|
345
851
|
applyRouteContract(route, options);
|
|
346
852
|
return builder;
|
|
347
853
|
}
|
|
854
|
+
if (isPrototypeHandler(handlerOrAction)) {
|
|
855
|
+
const builder = this.add(method, path, handlerOrAction, options.middlewares ?? []);
|
|
856
|
+
if (options.name) builder.name(options.name);
|
|
857
|
+
const route = this.registry[this.registry.length - 1];
|
|
858
|
+
applyRouteContract(route, options);
|
|
859
|
+
return builder;
|
|
860
|
+
}
|
|
348
861
|
const contractHandler = handlerOrAction;
|
|
349
862
|
if (typeof contractHandler !== "function") throw new Error(`Router.${method.toLowerCase()} requires a handler function when route contract options are provided.`);
|
|
350
863
|
const wrappedHandler = createContractHandler(path, options, contractHandler);
|
|
@@ -367,6 +880,7 @@ var Router = class {
|
|
|
367
880
|
scopedMiddlewares: scope.handlers,
|
|
368
881
|
routeMiddlewareNames: scope.names
|
|
369
882
|
};
|
|
883
|
+
if (isPrototypeHandler(handler)) route.prototype = true;
|
|
370
884
|
this.registry.push(route);
|
|
371
885
|
return createRouteBuilder(route, this.namedRoutes);
|
|
372
886
|
}
|
|
@@ -816,10 +1330,116 @@ async function mountModuleRoutes(router, gurenModule) {
|
|
|
816
1330
|
await pending;
|
|
817
1331
|
}
|
|
818
1332
|
//#endregion
|
|
1333
|
+
//#region src/http/middleware/cookie-session-store.ts
|
|
1334
|
+
const IV_BYTES = 12;
|
|
1335
|
+
const TAG_BYTES = 16;
|
|
1336
|
+
function isPlainObject(value) {
|
|
1337
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* The whole session, encrypted inside the cookie under the app key: the one
|
|
1341
|
+
* store needing no server-side resource (RFC 0020 §3). Two limits the docs
|
|
1342
|
+
* state outright — everything in the session travels in the cookie, so the
|
|
1343
|
+
* middleware caps it; and a logout cannot revoke a copy the client already
|
|
1344
|
+
* has, so anything revocable belongs in the database with only its id here.
|
|
1345
|
+
*/
|
|
1346
|
+
var CookieSessionStore = class {
|
|
1347
|
+
keyring;
|
|
1348
|
+
now;
|
|
1349
|
+
constructor(options = {}) {
|
|
1350
|
+
this.keyring = options.keyring ?? deriveAppKeyring(getAppKeyringFromEnv(), "cookie-session");
|
|
1351
|
+
this.now = options.now ?? (() => Date.now());
|
|
1352
|
+
}
|
|
1353
|
+
inline = {
|
|
1354
|
+
/**
|
|
1355
|
+
* `base64url(iv ‖ tag ‖ ciphertext)` rather than `Encrypter`'s envelope,
|
|
1356
|
+
* which base64s the ciphertext into JSON and base64s that again: measured
|
|
1357
|
+
* 2.27x the plaintext against 1.52x here, and a cookie's budget is this
|
|
1358
|
+
* store's whole constraint. Same primitives, same 12-byte IV and 16-byte tag.
|
|
1359
|
+
*/
|
|
1360
|
+
encode: (id, data, ttlSeconds) => {
|
|
1361
|
+
const payload = {
|
|
1362
|
+
id,
|
|
1363
|
+
data,
|
|
1364
|
+
expiresAt: this.now() + ttlSeconds * 1e3
|
|
1365
|
+
};
|
|
1366
|
+
const iv = randomBytes(IV_BYTES);
|
|
1367
|
+
const cipher = createCipheriv("aes-256-gcm", this.keyring.current, iv, { authTagLength: TAG_BYTES });
|
|
1368
|
+
const ciphertext = Buffer.concat([cipher.update(JSON.stringify(payload), "utf8"), cipher.final()]);
|
|
1369
|
+
return Buffer.concat([
|
|
1370
|
+
iv,
|
|
1371
|
+
cipher.getAuthTag(),
|
|
1372
|
+
ciphertext
|
|
1373
|
+
]).toString("base64url");
|
|
1374
|
+
},
|
|
1375
|
+
decode: (cookieValue) => {
|
|
1376
|
+
if (!cookieValue) return null;
|
|
1377
|
+
const raw = Buffer.from(cookieValue, "base64url");
|
|
1378
|
+
if (raw.length <= 28) return null;
|
|
1379
|
+
const iv = raw.subarray(0, IV_BYTES);
|
|
1380
|
+
const tag = raw.subarray(IV_BYTES, 28);
|
|
1381
|
+
const ciphertext = raw.subarray(28);
|
|
1382
|
+
for (const key of [this.keyring.current, ...this.keyring.previous]) {
|
|
1383
|
+
const payload = this.open(key, iv, tag, ciphertext);
|
|
1384
|
+
if (payload) return payload;
|
|
1385
|
+
}
|
|
1386
|
+
return null;
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
open(key, iv, tag, ciphertext) {
|
|
1390
|
+
let plaintext;
|
|
1391
|
+
try {
|
|
1392
|
+
const decipher = createDecipheriv("aes-256-gcm", key, iv, { authTagLength: TAG_BYTES });
|
|
1393
|
+
decipher.setAuthTag(tag);
|
|
1394
|
+
plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
1395
|
+
} catch {
|
|
1396
|
+
return null;
|
|
1397
|
+
}
|
|
1398
|
+
let payload;
|
|
1399
|
+
try {
|
|
1400
|
+
payload = JSON.parse(plaintext);
|
|
1401
|
+
} catch {
|
|
1402
|
+
return null;
|
|
1403
|
+
}
|
|
1404
|
+
if (!isPlainObject(payload)) return null;
|
|
1405
|
+
const { id, data, expiresAt } = payload;
|
|
1406
|
+
if (typeof id !== "string" || typeof expiresAt !== "number" || !isPlainObject(data)) return null;
|
|
1407
|
+
if (expiresAt <= this.now()) return null;
|
|
1408
|
+
return {
|
|
1409
|
+
id,
|
|
1410
|
+
data
|
|
1411
|
+
};
|
|
1412
|
+
}
|
|
1413
|
+
async read() {
|
|
1414
|
+
throw new Error(this.keyedStoreError("read"));
|
|
1415
|
+
}
|
|
1416
|
+
async write() {
|
|
1417
|
+
throw new Error(this.keyedStoreError("write"));
|
|
1418
|
+
}
|
|
1419
|
+
async destroy() {
|
|
1420
|
+
throw new Error(this.keyedStoreError("destroy"));
|
|
1421
|
+
}
|
|
1422
|
+
keyedStoreError(method) {
|
|
1423
|
+
return `CookieSessionStore has no keyed store to ${method}: the session lives in the cookie, which the session middleware reads and writes through \`inline\`. Use a database- or Redis-backed store to look a session up by id.`;
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
//#endregion
|
|
819
1427
|
//#region src/http/middleware/session-manager.ts
|
|
820
1428
|
/** The store `SessionConfig.default` names when it names none, and the one driver that shares no state between requests. */
|
|
821
1429
|
const DEFAULT_SESSION_STORE_NAME = "memory";
|
|
822
1430
|
const PER_PROCESS_SESSION_DRIVERS = /* @__PURE__ */ new Set([DEFAULT_SESSION_STORE_NAME]);
|
|
1431
|
+
/**
|
|
1432
|
+
* Every driver the framework itself registers, and whether it survives a
|
|
1433
|
+
* runtime that shares no memory between requests. Read by static checks that
|
|
1434
|
+
* cannot boot the app; a plugin's driver is declared in its `gurenPlugin`
|
|
1435
|
+
* manifest instead, and a name in neither is unverifiable, not absent.
|
|
1436
|
+
*/
|
|
1437
|
+
const BUILT_IN_SESSION_DRIVERS = /* @__PURE__ */ new Map([
|
|
1438
|
+
["memory", false],
|
|
1439
|
+
["cookie", true],
|
|
1440
|
+
["database", true],
|
|
1441
|
+
["redis", true]
|
|
1442
|
+
]);
|
|
823
1443
|
function isPrunable(store) {
|
|
824
1444
|
return typeof store.deleteExpired === "function";
|
|
825
1445
|
}
|
|
@@ -842,9 +1462,9 @@ var SessionManager = class {
|
|
|
842
1462
|
this.options = options;
|
|
843
1463
|
this.defaultStoreName = defaultName;
|
|
844
1464
|
this.registerDriver("memory", ({ now }) => new MemorySessionStore(now));
|
|
1465
|
+
this.registerDriver("cookie", () => new CookieSessionStore());
|
|
845
1466
|
this.registerDriver("redis", ({ client, prefix }) => {
|
|
846
|
-
const redis =
|
|
847
|
-
if (isPromiseLike(redis)) throw new Error("Session store \"redis\": `client` returned a Promise. Return the ioredis client synchronously; it connects lazily on first use.");
|
|
1467
|
+
const redis = resolveLazyRedisClient(client, "Session store \"redis\"");
|
|
848
1468
|
return new RedisSessionStore(redis, { prefix });
|
|
849
1469
|
});
|
|
850
1470
|
this.configs.set(DEFAULT_SESSION_STORE_NAME, { driver: "memory" });
|
|
@@ -1920,7 +2540,7 @@ function createDefaultGuardFactory(providerName) {
|
|
|
1920
2540
|
}
|
|
1921
2541
|
//#endregion
|
|
1922
2542
|
//#region src/errors/error-page.ts
|
|
1923
|
-
function escapeHtml$
|
|
2543
|
+
function escapeHtml$1(value) {
|
|
1924
2544
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1925
2545
|
}
|
|
1926
2546
|
/** Production error page: no stack traces or internal details are exposed. */
|
|
@@ -1959,7 +2579,7 @@ function renderErrorPage(statusCode, message) {
|
|
|
1959
2579
|
<div class="container">
|
|
1960
2580
|
<div class="status">${statusCode}</div>
|
|
1961
2581
|
<h1 class="title">${title}</h1>
|
|
1962
|
-
<p class="description">${escapeHtml$
|
|
2582
|
+
<p class="description">${escapeHtml$1(message ?? STATUS_DESCRIPTIONS[statusCode] ?? "An unexpected error occurred.")}</p>
|
|
1963
2583
|
<a href="/" class="home-link">Go Home</a>
|
|
1964
2584
|
</div>
|
|
1965
2585
|
</body>
|
|
@@ -2180,122 +2800,11 @@ var ErrorServiceProvider = class extends ServiceProvider {
|
|
|
2180
2800
|
this.container.singleton("exception.handler", () => createExceptionHandler());
|
|
2181
2801
|
}
|
|
2182
2802
|
boot() {
|
|
2183
|
-
const hono = this.container.make("hono");
|
|
2184
|
-
const handler = this.container.make("exception.handler");
|
|
2185
|
-
hono.onError((error, ctx) => handler.handle(error, ctx));
|
|
2186
|
-
}
|
|
2187
|
-
};
|
|
2188
|
-
//#endregion
|
|
2189
|
-
//#region src/mvc/inertia/shared.ts
|
|
2190
|
-
/** Container binding key for the scoped {@link SharedInertiaPropsRegistry}. */
|
|
2191
|
-
const INERTIA_SHARED_PROPS_BINDING = "inertia.sharedProps";
|
|
2192
|
-
/**
|
|
2193
|
-
* Registrations are numbered from one process-wide counter so that props keep
|
|
2194
|
-
* resolving in registration order — later registrations win on conflicting
|
|
2195
|
-
* keys — no matter which registry each one landed in.
|
|
2196
|
-
*/
|
|
2197
|
-
let registrationSequence = 0;
|
|
2198
|
-
/**
|
|
2199
|
-
* Holds the shared-props resolvers for one scope: either a single
|
|
2200
|
-
* Application's container or the module-global fallback for bare-Hono apps.
|
|
2201
|
-
*/
|
|
2202
|
-
var SharedInertiaPropsRegistry = class {
|
|
2203
|
-
resolvers = [];
|
|
2204
|
-
/** Replace every resolver registered in this scope. */
|
|
2205
|
-
set(resolverFn) {
|
|
2206
|
-
this.resolvers = resolverFn ? [orderedResolver(resolverFn)] : [];
|
|
2207
|
-
}
|
|
2208
|
-
/**
|
|
2209
|
-
* Register additional shared props without replacing resolvers registered
|
|
2210
|
-
* earlier — the new resolver's props are merged over the previous ones.
|
|
2211
|
-
*/
|
|
2212
|
-
share(resolverFn) {
|
|
2213
|
-
this.resolvers.push(orderedResolver(resolverFn));
|
|
2214
|
-
}
|
|
2215
|
-
/** The resolvers registered in this scope, ordered by registration. */
|
|
2216
|
-
entries() {
|
|
2217
|
-
return this.resolvers;
|
|
2218
|
-
}
|
|
2219
|
-
/**
|
|
2220
|
-
* The scope's registrations composed into one resolver, or null when empty.
|
|
2221
|
-
* The composition is a snapshot: resolvers registered later are not picked up.
|
|
2222
|
-
*/
|
|
2223
|
-
get() {
|
|
2224
|
-
if (this.resolvers.length === 0) return null;
|
|
2225
|
-
if (this.resolvers.length === 1) return this.resolvers[0].resolve;
|
|
2226
|
-
const snapshot = [...this.resolvers];
|
|
2227
|
-
return (ctx) => applyResolvers(snapshot, ctx);
|
|
2228
|
-
}
|
|
2229
|
-
async resolve(ctx) {
|
|
2230
|
-
return applyResolvers(this.resolvers, ctx);
|
|
2231
|
-
}
|
|
2232
|
-
};
|
|
2233
|
-
function orderedResolver(resolverFn) {
|
|
2234
|
-
return {
|
|
2235
|
-
seq: registrationSequence++,
|
|
2236
|
-
resolve: resolverFn
|
|
2237
|
-
};
|
|
2238
|
-
}
|
|
2239
|
-
async function applyResolvers(entries, ctx) {
|
|
2240
|
-
const merged = {};
|
|
2241
|
-
for (const entry of entries) {
|
|
2242
|
-
const props = await entry.resolve(ctx);
|
|
2243
|
-
if (props && typeof props === "object") Object.assign(merged, props);
|
|
2244
|
-
}
|
|
2245
|
-
return merged;
|
|
2246
|
-
}
|
|
2247
|
-
const globalRegistry = new SharedInertiaPropsRegistry();
|
|
2248
|
-
/** The registry bound to `container`, or null when it owns none yet. */
|
|
2249
|
-
function scopedRegistry(container) {
|
|
2250
|
-
if (!container?.has?.("inertia.sharedProps")) return null;
|
|
2251
|
-
return container.make(INERTIA_SHARED_PROPS_BINDING);
|
|
2252
|
-
}
|
|
2253
|
-
/**
|
|
2254
|
-
* The shared-props registry scoped to `container`, binding a fresh one on
|
|
2255
|
-
* first use.
|
|
2256
|
-
*/
|
|
2257
|
-
function ensureSharedInertiaPropsRegistry(container) {
|
|
2258
|
-
const existing = scopedRegistry(container);
|
|
2259
|
-
if (existing) return existing;
|
|
2260
|
-
const registry = new SharedInertiaPropsRegistry();
|
|
2261
|
-
container.instance(INERTIA_SHARED_PROPS_BINDING, registry);
|
|
2262
|
-
return registry;
|
|
2263
|
-
}
|
|
2264
|
-
/**
|
|
2265
|
-
* Replace the module-global shared props resolver. Props registered on an
|
|
2266
|
-
* application's container (see {@link shareInertiaProps}) are unaffected.
|
|
2267
|
-
*/
|
|
2268
|
-
function setInertiaSharedProps(resolverFn) {
|
|
2269
|
-
globalRegistry.set(resolverFn);
|
|
2270
|
-
}
|
|
2271
|
-
/**
|
|
2272
|
-
* The module-global registrations composed into one resolver, for manual
|
|
2273
|
-
* composition. Container-scoped props are not included — get those from
|
|
2274
|
-
* `ensureSharedInertiaPropsRegistry(container).get()`.
|
|
2275
|
-
*/
|
|
2276
|
-
function getInertiaSharedPropsResolver() {
|
|
2277
|
-
return globalRegistry.get();
|
|
2278
|
-
}
|
|
2279
|
-
/**
|
|
2280
|
-
* Register additional shared props without replacing earlier resolvers, so
|
|
2281
|
-
* several providers can each contribute (`setInertiaSharedProps` replaces
|
|
2282
|
-
* wholesale). Pass the provider's `this.container` to scope them; without it
|
|
2283
|
-
* they are module-global and a second Application in the process shares them.
|
|
2284
|
-
*/
|
|
2285
|
-
function shareInertiaProps(resolverFn, container) {
|
|
2286
|
-
(container ? ensureSharedInertiaPropsRegistry(container) : globalRegistry).share(resolverFn);
|
|
2287
|
-
}
|
|
2288
|
-
/**
|
|
2289
|
-
* Resolve shared props for a request, merging the module-global registrations
|
|
2290
|
-
* with those scoped to `container` in registration order.
|
|
2291
|
-
*/
|
|
2292
|
-
async function resolveSharedInertiaProps(ctx, container) {
|
|
2293
|
-
const scoped = scopedRegistry(container);
|
|
2294
|
-
if (!scoped) return globalRegistry.resolve(ctx);
|
|
2295
|
-
const globalEntries = globalRegistry.entries();
|
|
2296
|
-
if (globalEntries.length === 0) return scoped.resolve(ctx);
|
|
2297
|
-
return applyResolvers([...globalEntries, ...scoped.entries()].sort((a, b) => a.seq - b.seq), ctx);
|
|
2298
|
-
}
|
|
2803
|
+
const hono = this.container.make("hono");
|
|
2804
|
+
const handler = this.container.make("exception.handler");
|
|
2805
|
+
hono.onError((error, ctx) => handler.handle(error, ctx));
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2299
2808
|
//#endregion
|
|
2300
2809
|
//#region src/providers/I18nServiceProvider.ts
|
|
2301
2810
|
/**
|
|
@@ -2363,254 +2872,6 @@ var I18nServiceProvider = class extends ServiceProvider {
|
|
|
2363
2872
|
}
|
|
2364
2873
|
};
|
|
2365
2874
|
//#endregion
|
|
2366
|
-
//#region src/mvc/inertia/InertiaEngine.ts
|
|
2367
|
-
ensureErrorStackTracePolyfill();
|
|
2368
|
-
let documentOptions;
|
|
2369
|
-
/**
|
|
2370
|
-
* Register app-wide document defaults for server-rendered Inertia responses;
|
|
2371
|
-
* call it at module scope in the app entry so every runtime picks it up.
|
|
2372
|
-
* Process-wide, not request-scoped: calling it mid-flight leaks the policy into
|
|
2373
|
-
* in-flight requests — use the {@link InertiaOptions} fields per response.
|
|
2374
|
-
* Values are emitted verbatim, so never pass user input. `undefined` clears.
|
|
2375
|
-
*/
|
|
2376
|
-
function setInertiaDocument(options) {
|
|
2377
|
-
documentOptions = options;
|
|
2378
|
-
}
|
|
2379
|
-
let defaultSsrRenderer;
|
|
2380
|
-
/**
|
|
2381
|
-
* Register a process-wide default SSR renderer, for adapters whose bundler
|
|
2382
|
-
* cannot resolve a runtime path (Workers has no filesystem for
|
|
2383
|
-
* `GUREN_INERTIA_SSR_ENTRY`'s dynamic import). Per-call `ssr.render` still
|
|
2384
|
-
* wins; `undefined` clears (test isolation).
|
|
2385
|
-
*/
|
|
2386
|
-
function setInertiaSsrRenderer(renderer) {
|
|
2387
|
-
defaultSsrRenderer = renderer;
|
|
2388
|
-
}
|
|
2389
|
-
const DEFAULT_TITLE = "Guren";
|
|
2390
|
-
const DEV_FALLBACK_IMPORT_MAP = {
|
|
2391
|
-
react: "https://esm.sh/react@19.0.0?dev",
|
|
2392
|
-
"react/jsx-runtime": "https://esm.sh/react@19.0.0/jsx-runtime?dev",
|
|
2393
|
-
"react/jsx-dev-runtime": "https://esm.sh/react@19.0.0/jsx-dev-runtime?dev",
|
|
2394
|
-
"react-dom/client": "https://esm.sh/react-dom@19.0.0/client?dev",
|
|
2395
|
-
"@guren/inertia-client": "/vendor/inertia-client.tsx",
|
|
2396
|
-
"@inertiajs/react": "https://esm.sh/@inertiajs/react@2.2.15?dev&external=react,react-dom/client"
|
|
2397
|
-
};
|
|
2398
|
-
async function inertia(component, props, options = {}) {
|
|
2399
|
-
const resolvedVersion = options.version ?? process.env.GUREN_INERTIA_VERSION ?? void 0;
|
|
2400
|
-
const page = {
|
|
2401
|
-
component,
|
|
2402
|
-
props,
|
|
2403
|
-
url: options.url ?? inertiaPageUrl(options.request) ?? "",
|
|
2404
|
-
version: resolvedVersion
|
|
2405
|
-
};
|
|
2406
|
-
const request = options.request;
|
|
2407
|
-
const isInertiaVisit = Boolean(request?.headers.get("X-Inertia"));
|
|
2408
|
-
const prefersJson = request ? acceptsJson(request) : false;
|
|
2409
|
-
const versionHeader = resolvedVersion ? { "X-Inertia-Version": resolvedVersion } : {};
|
|
2410
|
-
if (request && resolvedVersion && isInertiaVisit && request.method === "GET") {
|
|
2411
|
-
if (request.headers.get("X-Inertia-Version") !== resolvedVersion) return new Response(null, {
|
|
2412
|
-
status: 409,
|
|
2413
|
-
headers: {
|
|
2414
|
-
"X-Inertia-Location": options.url ?? request.url,
|
|
2415
|
-
Vary: "Accept"
|
|
2416
|
-
}
|
|
2417
|
-
});
|
|
2418
|
-
}
|
|
2419
|
-
if (isInertiaVisit || prefersJson) return new Response(serializePage(page), {
|
|
2420
|
-
status: options.status ?? 200,
|
|
2421
|
-
headers: {
|
|
2422
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
2423
|
-
"X-Inertia": "true",
|
|
2424
|
-
Vary: "Accept",
|
|
2425
|
-
...versionHeader,
|
|
2426
|
-
...options.headers
|
|
2427
|
-
}
|
|
2428
|
-
});
|
|
2429
|
-
const html = await renderDocument$1(page, options);
|
|
2430
|
-
return new Response(html, {
|
|
2431
|
-
status: options.status ?? 200,
|
|
2432
|
-
headers: {
|
|
2433
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
2434
|
-
"X-Inertia": "true",
|
|
2435
|
-
Vary: "Accept",
|
|
2436
|
-
...versionHeader,
|
|
2437
|
-
...options.headers
|
|
2438
|
-
}
|
|
2439
|
-
});
|
|
2440
|
-
}
|
|
2441
|
-
/**
|
|
2442
|
-
* The Inertia protocol's page `url` is the request path plus query string, kept
|
|
2443
|
-
* relative. Derived from the request when the caller does not override it.
|
|
2444
|
-
*/
|
|
2445
|
-
function inertiaPageUrl(request) {
|
|
2446
|
-
if (!request) return;
|
|
2447
|
-
const { pathname, search } = new URL(request.url);
|
|
2448
|
-
return `${pathname}${search}`;
|
|
2449
|
-
}
|
|
2450
|
-
async function renderDocument$1(page, options) {
|
|
2451
|
-
const defaultEntry = process.env.GUREN_INERTIA_ENTRY ?? "/resources/js/app.tsx";
|
|
2452
|
-
const entry = options.entry ?? defaultEntry;
|
|
2453
|
-
const title = escapeHtml$1(options.title ?? DEFAULT_TITLE);
|
|
2454
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
2455
|
-
const configuredStyles = options.styles ?? parseStylesEnv(process.env.GUREN_INERTIA_STYLES);
|
|
2456
|
-
const styles = !isProduction && options.styles === void 0 && isDevServerEntry(entry) ? configuredStyles.filter((href) => href !== DEFAULT_DEV_STYLES_ENTRY) : configuredStyles;
|
|
2457
|
-
const envImportMap = parseImportMap(process.env.GUREN_INERTIA_IMPORT_MAP, { context: "GUREN_INERTIA_IMPORT_MAP" });
|
|
2458
|
-
const importMapEntries = {
|
|
2459
|
-
...isProduction ? {} : DEV_FALLBACK_IMPORT_MAP,
|
|
2460
|
-
...envImportMap,
|
|
2461
|
-
...options.importMap
|
|
2462
|
-
};
|
|
2463
|
-
const importMap = JSON.stringify({ imports: importMapEntries }, null, 2);
|
|
2464
|
-
const serializedPage = serializePage(page);
|
|
2465
|
-
const stylesheetLinks = renderStyles(styles);
|
|
2466
|
-
const criticalCss = resolveDocumentValue("criticalCss", options, page.component);
|
|
2467
|
-
const prepaintScript = resolveDocumentValue("prepaintScript", options, page.component);
|
|
2468
|
-
const headMarkup = resolveDocumentValue("head", options, page.component);
|
|
2469
|
-
const ssrResult = await tryRenderSsr(page, options);
|
|
2470
|
-
const headElements = (ssrResult?.head ?? []).map(normalizeHeadElement);
|
|
2471
|
-
const headSegments = [
|
|
2472
|
-
"<meta charset=\"utf-8\" />",
|
|
2473
|
-
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />",
|
|
2474
|
-
headElements.some((element) => /<title\b[^>]*>/iu.test(element)) ? "" : `<title>${title}</title>`,
|
|
2475
|
-
headMarkup ?? "",
|
|
2476
|
-
criticalCss ? `<style id="guren-critical">${criticalCss}</style>` : "",
|
|
2477
|
-
prepaintScript ? `<script>${prepaintScript}<\/script>` : "",
|
|
2478
|
-
stylesheetLinks,
|
|
2479
|
-
...headElements,
|
|
2480
|
-
Object.keys(importMapEntries).length > 0 ? `<script type="importmap">${importMap}<\/script>` : "",
|
|
2481
|
-
`<script>window.__INERTIA_PAGE__ = ${serializedPage};<\/script>`
|
|
2482
|
-
].filter((segment) => segment && segment.length > 0);
|
|
2483
|
-
const appMarkup = ssrResult?.body ?? `<script data-page="app" type="application/json">${serializedPage}<\/script><div id="app"></div>`;
|
|
2484
|
-
const bodyClass = resolveDocumentValue("bodyClass", options, page.component);
|
|
2485
|
-
const bodyAttributes = bodyClass ? ` class="${escapeAttribute(bodyClass)}"` : "";
|
|
2486
|
-
return `<!DOCTYPE html>
|
|
2487
|
-
<html lang="${escapeAttribute(options.lang ?? "en")}">
|
|
2488
|
-
<head>
|
|
2489
|
-
${headSegments.join("\n ")}
|
|
2490
|
-
</head>
|
|
2491
|
-
<body${bodyAttributes}>
|
|
2492
|
-
${appMarkup}
|
|
2493
|
-
<script type="module" src="${entry}"><\/script>
|
|
2494
|
-
</body>
|
|
2495
|
-
</html>`;
|
|
2496
|
-
}
|
|
2497
|
-
async function tryRenderSsr(page, options) {
|
|
2498
|
-
const ssrOptions = options.ssr;
|
|
2499
|
-
if (ssrOptions?.enabled === false) return;
|
|
2500
|
-
const manifest = (ssrOptions?.manifest ?? process.env.GUREN_INERTIA_SSR_MANIFEST)?.trim() || void 0;
|
|
2501
|
-
const renderer = ssrOptions?.render ?? defaultSsrRenderer ?? await loadSsrRenderer(ssrOptions?.entry ?? process.env.GUREN_INERTIA_SSR_ENTRY);
|
|
2502
|
-
if (!renderer) return;
|
|
2503
|
-
try {
|
|
2504
|
-
const result = await renderer({
|
|
2505
|
-
page,
|
|
2506
|
-
request: options.request,
|
|
2507
|
-
manifest
|
|
2508
|
-
});
|
|
2509
|
-
if (!result || typeof result.body !== "string") return;
|
|
2510
|
-
return {
|
|
2511
|
-
body: result.body,
|
|
2512
|
-
head: Array.isArray(result.head) ? result.head : []
|
|
2513
|
-
};
|
|
2514
|
-
} catch (error) {
|
|
2515
|
-
console.error("Inertia SSR renderer failed; falling back to client rendering.", error);
|
|
2516
|
-
return;
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
async function loadSsrRenderer(entry) {
|
|
2520
|
-
const specifier = entry?.trim();
|
|
2521
|
-
if (!specifier) return;
|
|
2522
|
-
const normalized = normalizeSsrSpecifier(specifier);
|
|
2523
|
-
try {
|
|
2524
|
-
const renderCandidate = extractSsrRenderer(await import(normalized));
|
|
2525
|
-
if (!renderCandidate) {
|
|
2526
|
-
console.warn(`Inertia SSR entry "${specifier}" does not export a renderer. Expected a default export or a named "render" function.`);
|
|
2527
|
-
return;
|
|
2528
|
-
}
|
|
2529
|
-
return renderCandidate;
|
|
2530
|
-
} catch (error) {
|
|
2531
|
-
console.error(`Failed to import Inertia SSR entry "${specifier}".`, error);
|
|
2532
|
-
return;
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2535
|
-
function extractSsrRenderer(module) {
|
|
2536
|
-
if (!module || typeof module !== "object") return;
|
|
2537
|
-
const candidate = typeof module.render === "function" ? module.render : typeof module.default === "function" ? module.default : void 0;
|
|
2538
|
-
if (!candidate) return;
|
|
2539
|
-
return (context) => Promise.resolve(candidate(context));
|
|
2540
|
-
}
|
|
2541
|
-
function normalizeSsrSpecifier(specifier) {
|
|
2542
|
-
if (specifier.startsWith("file://") || isUrlLike(specifier)) return specifier;
|
|
2543
|
-
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
2544
|
-
const absolute = resolve$1(process.cwd(), specifier);
|
|
2545
|
-
return pathToFileURL(absolute).href;
|
|
2546
|
-
}
|
|
2547
|
-
if (isAbsolute(specifier)) return pathToFileURL(specifier).href;
|
|
2548
|
-
return specifier;
|
|
2549
|
-
}
|
|
2550
|
-
function isUrlLike(specifier) {
|
|
2551
|
-
return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(specifier);
|
|
2552
|
-
}
|
|
2553
|
-
/**
|
|
2554
|
-
* An absolute http(s) entry means an asset dev server (Vite) is serving the
|
|
2555
|
-
* module graph; a same-origin path means source files are served directly,
|
|
2556
|
-
* where the raw stylesheet link is the only styling.
|
|
2557
|
-
*/
|
|
2558
|
-
function isDevServerEntry(entry) {
|
|
2559
|
-
return /^https?:\/\//iu.test(entry);
|
|
2560
|
-
}
|
|
2561
|
-
function renderStyles(styles) {
|
|
2562
|
-
if (!styles.length) return "";
|
|
2563
|
-
return styles.map((href) => `<link rel="stylesheet" href="${escapeAttribute(href)}" />`).join("\n ");
|
|
2564
|
-
}
|
|
2565
|
-
function normalizeHeadElement(element) {
|
|
2566
|
-
return (typeof element === "string" ? element : String(element ?? "")).replace(/href="\/(?!public\/)([^"?]+\.(?:js|css))(\?[^"']*)?"/g, (_match, file, query = "") => `href="/public/assets/${file}${query}"`);
|
|
2567
|
-
}
|
|
2568
|
-
/** One document field: per-response override, then app-wide default, then "". */
|
|
2569
|
-
function resolveDocumentValue(key, options, componentName) {
|
|
2570
|
-
const override = options[key];
|
|
2571
|
-
if (override !== void 0) return override;
|
|
2572
|
-
const value = documentOptions?.[key];
|
|
2573
|
-
return (typeof value === "function" ? value({ component: componentName }) : value) ?? "";
|
|
2574
|
-
}
|
|
2575
|
-
function serializePage(page) {
|
|
2576
|
-
return JSON.stringify(page).replace(/[<\u2028\u2029]/gu, (char) => {
|
|
2577
|
-
switch (char) {
|
|
2578
|
-
case "<": return "\\u003c";
|
|
2579
|
-
case "\u2028": return "\\u2028";
|
|
2580
|
-
case "\u2029": return "\\u2029";
|
|
2581
|
-
default: return char;
|
|
2582
|
-
}
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
function acceptsJson(request) {
|
|
2586
|
-
const accept = request.headers.get("accept")?.toLowerCase() ?? "";
|
|
2587
|
-
if (!accept || accept === "*/*") return false;
|
|
2588
|
-
if (accept.includes("text/html")) return false;
|
|
2589
|
-
return accept.includes("application/json") || accept.includes("json");
|
|
2590
|
-
}
|
|
2591
|
-
function escapeHtml$1(value) {
|
|
2592
|
-
return value.replace(/[&<>"']/gu, (char) => {
|
|
2593
|
-
switch (char) {
|
|
2594
|
-
case "&": return "&";
|
|
2595
|
-
case "<": return "<";
|
|
2596
|
-
case ">": return ">";
|
|
2597
|
-
case "\"": return """;
|
|
2598
|
-
case "'": return "'";
|
|
2599
|
-
default: return char;
|
|
2600
|
-
}
|
|
2601
|
-
});
|
|
2602
|
-
}
|
|
2603
|
-
function escapeAttribute(value) {
|
|
2604
|
-
return value.replace(/[&"]/gu, (char) => {
|
|
2605
|
-
if (char === "&") return "&";
|
|
2606
|
-
return """;
|
|
2607
|
-
});
|
|
2608
|
-
}
|
|
2609
|
-
function parseStylesEnv(value) {
|
|
2610
|
-
if (!value) return [];
|
|
2611
|
-
return value.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
2612
|
-
}
|
|
2613
|
-
//#endregion
|
|
2614
2875
|
//#region src/mvc/ViewEngine.ts
|
|
2615
2876
|
/**
|
|
2616
2877
|
* Registry for view renderers. Engines are typically registered via service
|
|
@@ -3087,8 +3348,30 @@ var Application = class {
|
|
|
3087
3348
|
for (const gurenModule of this.options.modules ?? []) await mountModuleRoutes(this.router, gurenModule);
|
|
3088
3349
|
this.routesRegistered = true;
|
|
3089
3350
|
}
|
|
3351
|
+
await this.preparePrototypeRoutes();
|
|
3090
3352
|
this.router.mount(this.hono, { container: this.container });
|
|
3091
3353
|
}
|
|
3354
|
+
/**
|
|
3355
|
+
* Every failure here is one a request would otherwise surface as a 500:
|
|
3356
|
+
* an unnamed prototype route cannot be looked up, a named one the fixture
|
|
3357
|
+
* does not answer, no loader to answer from at all. Process-shared fixture
|
|
3358
|
+
* state is a developer's own `bun run dev`, not a deployment, hence the
|
|
3359
|
+
* production refusal; `GUREN_PROTOTYPE_ROUTES=1` overrides it deliberately.
|
|
3360
|
+
*/
|
|
3361
|
+
async preparePrototypeRoutes() {
|
|
3362
|
+
if (this.container.has("prototype.fixture")) return;
|
|
3363
|
+
const routes = this.router.definitions().filter((route) => route.prototype);
|
|
3364
|
+
if (routes.length === 0) return;
|
|
3365
|
+
const describe = (route) => `${route.method} ${route.path}${route.name ? ` (${route.name})` : ""}`;
|
|
3366
|
+
const unnamed = routes.find((route) => !route.name);
|
|
3367
|
+
if (unnamed) throw new Error(`Route ${describe(unnamed)} uses the prototype handler but has no name; the fixture is keyed by route name. Chain .name() on it or pass { name } in its options.`);
|
|
3368
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "production" && process.env.GUREN_PROTOTYPE_ROUTES !== "1") throw new Error(`${routes.length} route(s) still answer from the prototype fixture (${routes.map(describe).join(", ")}), whose state is shared by every request of this process. Replace them with controllers before deploying, or set GUREN_PROTOTYPE_ROUTES=1 to run a deliberately fixture-backed server.`);
|
|
3369
|
+
if (!this.options.prototype) throw new Error(`Route ${describe(routes[0])} uses the prototype handler, but createApp() has no \`prototype\` option. Pass \`prototype: () => import('../resources/js/prototype/index.js')\`.`);
|
|
3370
|
+
const fixture = await loadPrototypeFixture(this.options.prototype);
|
|
3371
|
+
const missing = routes.filter((route) => typeof fixture.routes[route.name] !== "function");
|
|
3372
|
+
if (missing.length > 0) throw new Error(`The prototype fixture has no entry for ${missing.map(describe).join(", ")}. Add the route name to \`routes\` in resources/js/prototype/index.ts, or replace the handler with a controller.`);
|
|
3373
|
+
this.container.instance(PROTOTYPE_FIXTURE_BINDING, fixture);
|
|
3374
|
+
}
|
|
3092
3375
|
use(path, ...middleware) {
|
|
3093
3376
|
this.hono.use(path, ...middleware);
|
|
3094
3377
|
}
|
|
@@ -3122,7 +3405,7 @@ var Application = class {
|
|
|
3122
3405
|
await this.options.boot?.(this.hono);
|
|
3123
3406
|
await this.mountRoutes();
|
|
3124
3407
|
await this.mountDevEndpoint(isMcpEndpointEnabled(), async () => (await import("./McpServiceProvider-BvJRcDOm.js").then((n) => n.n)).McpServiceProvider, "GUREN_MCP=1 but the MCP endpoint could not load — is @modelcontextprotocol/sdk installed?");
|
|
3125
|
-
await this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-
|
|
3408
|
+
await this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-DWnlXx_y.js")).DocsViewerServiceProvider, "GUREN_DOCS=1 but the docs viewer could not load — is @guren/cli resolvable from this app?");
|
|
3126
3409
|
await this.providerManager.bootAll();
|
|
3127
3410
|
}
|
|
3128
3411
|
/** Called once, from the constructor — see the note there for why. */
|
|
@@ -3759,6 +4042,10 @@ function deriveAgentTools(definitions) {
|
|
|
3759
4042
|
if (!agent) continue;
|
|
3760
4043
|
const method = definition.method.toUpperCase();
|
|
3761
4044
|
const where = `${method} ${definition.path}`;
|
|
4045
|
+
if (definition.prototype) {
|
|
4046
|
+
warnings.push(`${where}: declares agent metadata while still on its prototype fixture, so it is not exposed as a tool.`);
|
|
4047
|
+
continue;
|
|
4048
|
+
}
|
|
3762
4049
|
if (!definition.name) {
|
|
3763
4050
|
warnings.push(`${where}: declares agent metadata but has no route name, so it is not exposed as a tool. Chain .name() on the route — the tool name is its identity.`);
|
|
3764
4051
|
continue;
|
|
@@ -7620,4 +7907,4 @@ function renderEnvironmentSection() {
|
|
|
7620
7907
|
//#region src/index.ts
|
|
7621
7908
|
ensureErrorStackTracePolyfill();
|
|
7622
7909
|
//#endregion
|
|
7623
|
-
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DEFAULT_SESSION_STORE_NAME, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PER_PROCESS_SESSION_DRIVERS, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, SERVERLESS_RUNTIME_LABELS, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, ScryptHasher, SeederRunner, ServiceProvider, SessionGuard, SessionManager, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defineFactory, defineGate, defineMiddleware, defineModule, definePlugin, definePolicy, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, detectServerlessRuntime, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isDue, isDueInTimezone, isEmailVerified, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetRateLimit, resolve, resolveJobName, resolveNotifiableType, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, unique, url as urlRule, urlSafeToken, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|
|
7910
|
+
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BUILT_IN_SESSION_DRIVERS, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CookieSessionStore, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DEFAULT_SESSION_STORE_NAME, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PER_PROCESS_SESSION_DRIVERS, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, SERVERLESS_RUNTIME_LABELS, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, ScryptHasher, SeederRunner, ServiceProvider, SessionGuard, SessionManager, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defineFactory, defineGate, defineMiddleware, defineModule, definePlugin, definePolicy, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, detectServerlessRuntime, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isDue, isDueInTimezone, isEmailVerified, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, prototype, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetRateLimit, resolve, resolveJobName, resolveNotifiableType, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, unique, url as urlRule, urlSafeToken, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|