@guren/server 2.29.1 → 2.31.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/{Gate-DFiuutZm.js → Gate-COWQbA96.js} +1 -1
- package/dist/{Job-DsFMcXVk.js → Job-0Prk8k0z.js} +1 -1
- package/dist/{Resource-ZMJH4lyD.js → Resource-CGGEbZfX.js} +6 -5
- package/dist/authorization/index.js +2 -2
- package/dist/{authorization-DUjeyGWh.js → authorization-DEHuBps5.js} +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-N4cRV42s.js → broadcasting-CcevVE5Y.js} +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/{cache-C2Im3l7t.js → cache-Bi5U8N5P.js} +1 -1
- package/dist/{default-application-DWwscxfW.js → default-application-s9SE-Er7.js} +1 -1
- package/dist/{dev-banner-wz0V_g0R.js → dev-banner-DPSpJwVz.js} +1 -1
- package/dist/{driver-map-CkQc52j-.js → driver-map-BhITaLcy.js} +8 -2
- package/dist/encryption/index.js +1 -1
- package/dist/{encryption-DF8lZkpj.js → encryption-BS-FGkqS.js} +1 -1
- package/dist/errors/debug-page.d.ts +4 -2
- package/dist/events/index.js +1 -1
- package/dist/{events-DQavGm8W.js → events-B6gfJkCH.js} +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/{i18n-DmMKcbqj.js → i18n-BShPpJZa.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +559 -540
- package/dist/initial-page-U637q3gO.js +46 -0
- package/dist/internal/inertia-page.d.ts +1 -0
- package/dist/internal/inertia-page.js +2 -0
- package/dist/internal/testing.js +1 -1
- package/dist/introspection/driver-map.d.ts +1 -1
- package/dist/introspection/types.d.ts +12 -1
- package/dist/lambda/index.js +1 -1
- package/dist/logging/index.js +1 -1
- package/dist/{logging-Ci0mBk5k.js → logging-Br9bZlaG.js} +1 -1
- package/dist/mail/index.js +1 -1
- package/dist/{mail-CI2Kfe8P.js → mail-BQ2y2U5c.js} +2 -2
- package/dist/mvc/inertia/initial-page.d.ts +16 -0
- package/dist/notifications/index.js +1 -1
- package/dist/{notifications-Bp2uamzD.js → notifications-R7Uj-aT7.js} +2 -2
- package/dist/queue/index.js +2 -2
- package/dist/{queue-C8s3buYz.js → queue-CO07wib_.js} +2 -2
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/serverless.d.ts +2 -1
- package/dist/storage/StorageManager.d.ts +10 -1
- package/dist/storage/index.js +1 -1
- package/dist/{storage-IlUesK2t.js → storage-YPbsV9ju.js} +12 -4
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as setInertiaSsrRenderer, D as isDeferredProp, E as isAlwaysProp, O as ensureErrorStackTracePolyfill, S as setInertiaDocument, T as defer, a as renderDocument, b as inertia, c as getRequestLocale, d as mountModuleRoutes, f as definePlugin, g as shareInertiaProps, h as setInertiaSharedProps, i as Controller, l as getRequestTranslator, m as resolveSharedInertiaProps, n as Resource, o as LOCALE_CONTEXT_KEY, p as getInertiaSharedPropsResolver, r as collect, s as detectLocaleMiddleware, t as JsonResource, u as defineModule, w as always } from "./Resource-
|
|
1
|
+
import { C as setInertiaSsrRenderer, D as isDeferredProp, E as isAlwaysProp, O as ensureErrorStackTracePolyfill, S as setInertiaDocument, T as defer, a as renderDocument, b as inertia, c as getRequestLocale, d as mountModuleRoutes, f as definePlugin, g as shareInertiaProps, h as setInertiaSharedProps, i as Controller, l as getRequestTranslator, m as resolveSharedInertiaProps, n as Resource, o as LOCALE_CONTEXT_KEY, p as getInertiaSharedPropsResolver, r as collect, s as detectLocaleMiddleware, t as JsonResource, u as defineModule, w as always } from "./Resource-CGGEbZfX.js";
|
|
2
2
|
import { a as parseRequestPayload, i as parseRequestBody, n as flattenRequestQueries, r as formatValidationErrors } from "./request-CLOYytGP.js";
|
|
3
3
|
import { i as setValidatedInput, n as getValidatedInput } from "./validated-input-D84J8wcC.js";
|
|
4
4
|
import { t as HttpException } from "./HttpException-BlQ2yEmT.js";
|
|
5
5
|
import { n as ValidationException } from "./errors-JpkcCjjn.js";
|
|
6
|
-
import { a as withAuthorization, c as capabilitiesOf, i as derivableAbility, l as mergeCapabilities, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware, u as stampCapabilities } from "./authorization-
|
|
6
|
+
import { a as withAuthorization, c as capabilitiesOf, i as derivableAbility, l as mergeCapabilities, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware, u as stampCapabilities } from "./authorization-DEHuBps5.js";
|
|
7
7
|
import { a as mapToolResponse, c as AGENT_PREFLIGHT_VERDICT_HEADER, i as describeBuildFailure, n as advertisesStructuredOutput, o as isDispatchedToolRequest, r as buildToolRequest, t as PREFLIGHT_ARGUMENT } from "./dispatch-ENWpBxbE.js";
|
|
8
8
|
import { i as trimSlashes } from "./contained-path-BkNSBljW.js";
|
|
9
9
|
import { PATH_PARAM_PATTERN, extractPathParamNames } from "./internal/route-path.js";
|
|
@@ -12,35 +12,35 @@ import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./
|
|
|
12
12
|
import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as normalizeRedirectTarget, G as installAgentPrincipal, H as NodeHasher, I as AuthManager, J as createSessionMiddleware, K as readAgentPrincipal, L as DEFAULT_PROVIDER, M as jsonResponse, N as hostMatchesAllowlist, O as parseOAuthRedirectUrl, P as isAppRelativePath, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, V as DefaultHasher, W as BaseUserProvider, X as getSessionFromContext, Y as defaultCookieSecure, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, j as defineMiddleware, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, q as MemorySessionStore, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as SessionGuard } from "./auth-DRMeSwev.js";
|
|
13
13
|
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
14
14
|
import { t as warnOnce } from "./warn-once-p-IlMjra.js";
|
|
15
|
-
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer,
|
|
15
|
+
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, g as warnDeprecatedSetter, h as warnDeprecatedGetter, i as bindAmbient, l as useAsDefaultApplication, m as warnDeprecated, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-s9SE-Er7.js";
|
|
16
16
|
import { n as ServiceProvider, t as ProviderManager } from "./ServiceProvider-G0YclITd.js";
|
|
17
17
|
import { o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context-af2n5abO.js";
|
|
18
18
|
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";
|
|
19
19
|
import { _ as verifyApiToken, a as getApiToken, c as hasBearerHeader, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAny, h as tokenCanAll, i as createBearerTokenMiddleware, l as parseApiToken, m as tokenCan, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken } from "./api-token-BbgDEd6j.js";
|
|
20
20
|
import { a as runInRequestScope, i as keepAlive, n as filterSensitiveData, t as Logger } from "./Logger-DWXdtLSJ.js";
|
|
21
|
-
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, s as resolveLazyRedisClient, t as CacheManager } from "./cache-
|
|
21
|
+
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, s as resolveLazyRedisClient, t as CacheManager } from "./cache-Bi5U8N5P.js";
|
|
22
22
|
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
23
23
|
import { i as loadRuntimeErrorsModule, r as captureRuntimeError, s as isMcpEndpointEnabled, t as RUNTIME_ERRORS_BINDING } from "./runtime-error-capture-BclelWhA.js";
|
|
24
24
|
import { n as isHotReloadRuntime, r as matchingOpenParen, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
25
|
-
import { a as setBroadcastManager, c as PresenceChannel, d as createWebSocketOriginGuard, 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-
|
|
26
|
-
import { c as tc, d as Translator, f as getPluralizationRule, i as getI18n, l as tryGetI18n, m as selectPluralForm, n as I18nManager, o as setI18n, p as pluralizationRules, r as createI18n, s as t, t as MemoryLoader, u as JsonLoader } from "./i18n-
|
|
25
|
+
import { a as setBroadcastManager, c as PresenceChannel, d as createWebSocketOriginGuard, 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-CcevVE5Y.js";
|
|
26
|
+
import { c as tc, d as Translator, f as getPluralizationRule, i as getI18n, l as tryGetI18n, m as selectPluralForm, n as I18nManager, o as setI18n, p as pluralizationRules, r as createI18n, s as t, t as MemoryLoader, u as JsonLoader } from "./i18n-BShPpJZa.js";
|
|
27
27
|
import { n as getRequestContainer, r as tryGetRequestContainer, t as CONTAINER_CONTEXT_KEY } from "./request-container-BbuH0JJy.js";
|
|
28
28
|
import { n as isAgentToolRequest } from "./agent-request-Caj6bnbj.js";
|
|
29
|
-
import { a as cannot, f as setGate, i as can, l as getGate, n as Response$1, o as createGate, p as AuthorizationException, r as authorize, s as defineGate, t as Gate } from "./Gate-
|
|
29
|
+
import { a as cannot, f as setGate, i as can, l as getGate, n as Response$1, o as createGate, p as AuthorizationException, r as authorize, s as defineGate, t as Gate } from "./Gate-COWQbA96.js";
|
|
30
30
|
import { r as isDocsViewerEnabled } from "./endpoint-CTIzcagh.js";
|
|
31
31
|
import { n as isWildcardHost, t as formatHostPort } from "./host-port-t6wQFaRu.js";
|
|
32
32
|
import { C as stopBunServerBounded, S as stopActiveViteDevServer, _ as registerBunTeardown, b as setActiveBunServer, c as isViteProduction, d as startViteDevServer, g as hotReloadStopBound, h as getGlobalState, i as clientManifestCandidates, l as loadViteManifest, m as closeOwnedViteDevServer, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, p as adoptViteDevServer, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl, v as releaseActiveBunServer, x as stopActiveBunServer, y as reusableActiveViteDevServer } from "./vite-manifest-DO0pU1vm.js";
|
|
33
33
|
import { readObjectSchema, toJsonSchema } from "./internal/zod-json-schema.js";
|
|
34
|
-
import { a as RequestFinished, c as UserLoggedOut, d as EventManager, f as createEventManager, i as JobProcessed, l as createQueueEventDispatcher, n as ApplicationStarted, o as RequestReceived, p as Event, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as Listener } from "./events-
|
|
35
|
-
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-
|
|
36
|
-
import { a as getJob, d as resolveQueueDriver, f as setQueueDriver, l as registerJob, n as clearJobRegistry, o as getQueueDriver, r as clearQueueDriver, s as getRegisteredJobs, t as Job, u as resolveJobName } from "./Job-
|
|
37
|
-
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-
|
|
38
|
-
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-
|
|
34
|
+
import { a as RequestFinished, c as UserLoggedOut, d as EventManager, f as createEventManager, i as JobProcessed, l as createQueueEventDispatcher, n as ApplicationStarted, o as RequestReceived, p as Event, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as Listener } from "./events-B6gfJkCH.js";
|
|
35
|
+
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-R7Uj-aT7.js";
|
|
36
|
+
import { a as getJob, d as resolveQueueDriver, f as setQueueDriver, l as registerJob, n as clearJobRegistry, o as getQueueDriver, r as clearQueueDriver, s as getRegisteredJobs, t as Job, u as resolveJobName } from "./Job-0Prk8k0z.js";
|
|
37
|
+
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-CO07wib_.js";
|
|
38
|
+
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-BQ2y2U5c.js";
|
|
39
39
|
import { a as LOG_LEVEL_PRIORITY, i as matchDailyFileDate, n as dailyFileDateStamp, r as dailyFilePath, t as DailyFileChannel } from "./DailyFileChannel-CTTPA0EF.js";
|
|
40
|
-
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "./logging-
|
|
40
|
+
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "./logging-Br9bZlaG.js";
|
|
41
41
|
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";
|
|
42
|
-
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-
|
|
43
|
-
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-
|
|
42
|
+
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-BS-FGkqS.js";
|
|
43
|
+
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-YPbsV9ju.js";
|
|
44
44
|
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-Bg0Xj3aD.js";
|
|
45
45
|
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, p as MemorySchedulerLock, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "./scheduling-DNV5tj44.js";
|
|
46
46
|
import { Hono } from "hono";
|
|
@@ -2211,6 +2211,291 @@ const STATUS_DESCRIPTIONS = {
|
|
|
2211
2211
|
504: "The server did not receive a timely response from an upstream server."
|
|
2212
2212
|
};
|
|
2213
2213
|
//#endregion
|
|
2214
|
+
//#region src/errors/debug-page.ts
|
|
2215
|
+
/** Development-only error page: exposes the stack trace and request details. */
|
|
2216
|
+
function renderDebugPage(error, request) {
|
|
2217
|
+
const errorName = error.name || "Error";
|
|
2218
|
+
const errorMessage = escapeHtml(error.message || "An unknown error occurred");
|
|
2219
|
+
const stackFrames = parseStackTrace(error.stack ?? "");
|
|
2220
|
+
const statusCode = getStatusCode(error);
|
|
2221
|
+
const requestSection = request ? renderRequestSection(request) : "";
|
|
2222
|
+
const stackSection = renderStackSection(stackFrames);
|
|
2223
|
+
const environmentSection = renderEnvironmentSection();
|
|
2224
|
+
return `<!DOCTYPE html>
|
|
2225
|
+
<html lang="en">
|
|
2226
|
+
<head>
|
|
2227
|
+
<meta charset="utf-8">
|
|
2228
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2229
|
+
<title>${escapeHtml(errorName)}: ${errorMessage}</title>
|
|
2230
|
+
<style>
|
|
2231
|
+
/* Guren UI's tokens (github.com/gurenjs/guren-ui), following the OS theme. */
|
|
2232
|
+
:root {
|
|
2233
|
+
color-scheme: light;
|
|
2234
|
+
--g-font-sans: 'Noto Sans JP', ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
2235
|
+
--g-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2236
|
+
--g-page: #ffffff; --g-panel: #ffffff; --g-raised: #fffafa; --g-line: #e5e7eb; --g-line-strong: #d1d5db;
|
|
2237
|
+
--g-heading: #111827; --g-text: #1f2937; --g-text-2: #4b5563; --g-muted: #9ca3af;
|
|
2238
|
+
--g-danger: #b91c1c; --g-danger-chip: #f23a3a; --g-danger-tint: #fff1f2; --g-accent: #db1b1b;
|
|
2239
|
+
--g-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
|
|
2240
|
+
}
|
|
2241
|
+
@media (prefers-color-scheme: dark) {
|
|
2242
|
+
:root {
|
|
2243
|
+
color-scheme: dark;
|
|
2244
|
+
--g-page: #1a1a2e; --g-panel: #1e1e34; --g-raised: #232340; --g-line: #2e2e4a; --g-line-strong: #3d3d5c;
|
|
2245
|
+
--g-heading: #e0def4; --g-text: #e0def4; --g-text-2: #908caa; --g-muted: #6e6a86;
|
|
2246
|
+
--g-danger: #ffa5a5; --g-danger-tint: rgba(242, 58, 58, 0.12);
|
|
2247
|
+
--g-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
2251
|
+
body { font-family: var(--g-font-sans); background: var(--g-page); color: var(--g-text); line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased; }
|
|
2252
|
+
code, .mono { font-family: var(--g-font-mono); }
|
|
2253
|
+
.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
|
|
2254
|
+
|
|
2255
|
+
.error-header { display: flex; align-items: flex-start; gap: 1.5rem; margin-bottom: 2rem; padding: 2rem; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 12px; border-left: 4px solid var(--g-danger-chip); box-shadow: var(--g-shadow-card); }
|
|
2256
|
+
.status-badge { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; background: var(--g-danger-tint); color: var(--g-danger); font: 700 1.25rem/1 var(--g-font-mono); border-radius: 12px; }
|
|
2257
|
+
.error-info { min-width: 0; }
|
|
2258
|
+
.error-class { font-size: 1.5rem; font-weight: 700; color: var(--g-danger); letter-spacing: -0.01em; margin-bottom: 0.25rem; word-break: break-word; }
|
|
2259
|
+
.error-message { font-size: 1.1rem; color: var(--g-heading); word-break: break-word; }
|
|
2260
|
+
|
|
2261
|
+
.section { margin-bottom: 1rem; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 12px; box-shadow: var(--g-shadow-card); overflow: hidden; }
|
|
2262
|
+
.section-toggle { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 1rem 1.25rem; background: none; border: none; cursor: pointer; color: var(--g-heading); text-align: left; font-family: inherit; }
|
|
2263
|
+
.section-toggle:hover { background: var(--g-raised); }
|
|
2264
|
+
.section-toggle:focus-visible { outline: 2px solid var(--g-accent); outline-offset: -2px; }
|
|
2265
|
+
.section-toggle h2 { font-size: 15px; font-weight: 700; }
|
|
2266
|
+
.toggle-icon { font-size: 0.7rem; color: var(--g-muted); flex-shrink: 0; width: 1rem; text-align: center; }
|
|
2267
|
+
.badge { font: 500 12px/1.6 var(--g-font-mono); color: var(--g-text-2); background: var(--g-raised); box-shadow: inset 0 0 0 1px var(--g-line); padding: 2px 9px; border-radius: 999px; margin-left: auto; }
|
|
2268
|
+
.section-content { padding: 0 1.25rem 1.25rem; }
|
|
2269
|
+
|
|
2270
|
+
.stack-frames { display: flex; flex-direction: column; gap: 2px; }
|
|
2271
|
+
.frame { padding: 0.6rem 0.75rem; border-radius: 8px; cursor: default; transition: background 0.15s; }
|
|
2272
|
+
.frame:hover { background: var(--g-raised); }
|
|
2273
|
+
.frame.vendor { opacity: 0.5; }
|
|
2274
|
+
.frame.vendor:hover { opacity: 0.75; }
|
|
2275
|
+
.frame-header { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
|
|
2276
|
+
.frame-index { color: var(--g-muted); font: 500 0.75rem var(--g-font-mono); min-width: 2rem; flex-shrink: 0; }
|
|
2277
|
+
.frame-method { color: var(--g-heading); font-family: var(--g-font-mono); font-weight: 500; }
|
|
2278
|
+
.frame-location { color: var(--g-text-2); font-family: var(--g-font-mono); font-size: 0.8rem; margin-left: auto; text-align: right; word-break: break-all; }
|
|
2279
|
+
|
|
2280
|
+
.request-summary { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
|
|
2281
|
+
.method-badge { display: inline-block; padding: 2px 9px; color: var(--g-text-2); background: var(--g-raised); box-shadow: inset 0 0 0 1px var(--g-line); font: 500 12px/1.6 var(--g-font-mono); border-radius: 999px; }
|
|
2282
|
+
.request-url { font-family: var(--g-font-mono); font-size: 0.9rem; word-break: break-all; }
|
|
2283
|
+
|
|
2284
|
+
.subsection { margin-top: 1rem; }
|
|
2285
|
+
.subsection h3 { font: 500 11.5px/1.6 var(--g-font-mono); color: var(--g-muted); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.06em; }
|
|
2286
|
+
|
|
2287
|
+
.details-table { width: 100%; border-collapse: collapse; }
|
|
2288
|
+
.details-table tr { border-bottom: 1px solid var(--g-line); }
|
|
2289
|
+
.details-table tr:last-child { border-bottom: none; }
|
|
2290
|
+
.details-table td { padding: 0.4rem 0; font-size: 0.85rem; vertical-align: top; }
|
|
2291
|
+
.details-table td.key { color: var(--g-text-2); font-weight: 500; width: 200px; padding-right: 1rem; font-family: var(--g-font-mono); font-size: 0.8rem; }
|
|
2292
|
+
.details-table td.value { color: var(--g-text); word-break: break-all; font-family: var(--g-font-mono); font-size: 0.8rem; }
|
|
2293
|
+
|
|
2294
|
+
.muted { color: var(--g-muted); font-style: italic; }
|
|
2295
|
+
.footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--g-line); text-align: center; color: var(--g-muted); font-size: 0.8rem; }
|
|
2296
|
+
</style>
|
|
2297
|
+
</head>
|
|
2298
|
+
<body>
|
|
2299
|
+
<div class="container">
|
|
2300
|
+
<header class="error-header">
|
|
2301
|
+
<div class="status-badge">${statusCode}</div>
|
|
2302
|
+
<div class="error-info">
|
|
2303
|
+
<h1 class="error-class">${escapeHtml(errorName)}</h1>
|
|
2304
|
+
<p class="error-message">${errorMessage}</p>
|
|
2305
|
+
</div>
|
|
2306
|
+
</header>
|
|
2307
|
+
|
|
2308
|
+
${stackSection}
|
|
2309
|
+
${requestSection}
|
|
2310
|
+
${environmentSection}
|
|
2311
|
+
|
|
2312
|
+
<footer class="footer">
|
|
2313
|
+
<p>Guren Framework — Debug Error Page</p>
|
|
2314
|
+
</footer>
|
|
2315
|
+
</div>
|
|
2316
|
+
|
|
2317
|
+
<script>
|
|
2318
|
+
function toggleSection(button) {
|
|
2319
|
+
var section = button.closest('.section');
|
|
2320
|
+
var content = section.querySelector('.section-content');
|
|
2321
|
+
var icon = button.querySelector('.toggle-icon');
|
|
2322
|
+
if (content.style.display === 'none') {
|
|
2323
|
+
content.style.display = 'block';
|
|
2324
|
+
icon.innerHTML = '\\u25BC';
|
|
2325
|
+
section.classList.remove('collapsed');
|
|
2326
|
+
} else {
|
|
2327
|
+
content.style.display = 'none';
|
|
2328
|
+
icon.innerHTML = '\\u25B6';
|
|
2329
|
+
section.classList.add('collapsed');
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
<\/script>
|
|
2333
|
+
</body>
|
|
2334
|
+
</html>`;
|
|
2335
|
+
}
|
|
2336
|
+
/**
|
|
2337
|
+
* @deprecated since 2.30.0, removed in 3.0.0. The ExceptionHandler renders this
|
|
2338
|
+
* page itself for a browser request while debug details are on. Hono hands a
|
|
2339
|
+
* handler's error to the app's `onError` where it is thrown, so this `catch`
|
|
2340
|
+
* never sees one in a Guren app.
|
|
2341
|
+
*/
|
|
2342
|
+
function debugErrorMiddleware() {
|
|
2343
|
+
warnDeprecated("debug-error-middleware", "debugErrorMiddleware", "Remove it: the ExceptionHandler renders the debug page for a browser request while debug details are on.", {
|
|
2344
|
+
since: "2.30.0",
|
|
2345
|
+
removedIn: "3.0.0"
|
|
2346
|
+
});
|
|
2347
|
+
return async (c, next) => {
|
|
2348
|
+
try {
|
|
2349
|
+
await next();
|
|
2350
|
+
} catch (err) {
|
|
2351
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV === "production") throw err;
|
|
2352
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
2353
|
+
const statusCode = getStatusCode(error);
|
|
2354
|
+
const html = renderDebugPage(error, c.req.raw);
|
|
2355
|
+
return new Response(html, {
|
|
2356
|
+
status: statusCode,
|
|
2357
|
+
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
};
|
|
2361
|
+
}
|
|
2362
|
+
/**
|
|
2363
|
+
* Split a `file:line:col` suffix off a location string, scanning from the
|
|
2364
|
+
* right so drive letters and URLs with colons stay part of the file path.
|
|
2365
|
+
*/
|
|
2366
|
+
function splitLocation(location) {
|
|
2367
|
+
const lastColon = location.lastIndexOf(":");
|
|
2368
|
+
if (lastColon <= 0) return null;
|
|
2369
|
+
const prevColon = location.lastIndexOf(":", lastColon - 1);
|
|
2370
|
+
if (prevColon <= 0) return null;
|
|
2371
|
+
const line = location.slice(prevColon + 1, lastColon);
|
|
2372
|
+
const col = location.slice(lastColon + 1);
|
|
2373
|
+
if (!/^\d+$/.test(line) || !/^\d+$/.test(col)) return null;
|
|
2374
|
+
return {
|
|
2375
|
+
file: location.slice(0, prevColon),
|
|
2376
|
+
line,
|
|
2377
|
+
col
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
function parseStackTrace(stack) {
|
|
2381
|
+
return stack.split("\n").slice(1).map((line) => {
|
|
2382
|
+
const trimmed = line.trim();
|
|
2383
|
+
if (!/^at\s/u.test(trimmed)) return null;
|
|
2384
|
+
const rest = trimmed.slice(2).trim();
|
|
2385
|
+
if (rest.endsWith(")")) {
|
|
2386
|
+
const open = matchingOpenParen(rest, rest.length - 1);
|
|
2387
|
+
if (open !== void 0 && open > 0) {
|
|
2388
|
+
const location = splitLocation(rest.slice(open + 1, -1));
|
|
2389
|
+
if (location) return {
|
|
2390
|
+
func: rest.slice(0, open).trim(),
|
|
2391
|
+
...location
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
const location = splitLocation(rest);
|
|
2396
|
+
if (location) return {
|
|
2397
|
+
func: "<anonymous>",
|
|
2398
|
+
...location
|
|
2399
|
+
};
|
|
2400
|
+
return null;
|
|
2401
|
+
}).filter((frame) => frame !== null);
|
|
2402
|
+
}
|
|
2403
|
+
function getStatusCode(error) {
|
|
2404
|
+
if ("statusCode" in error && typeof error.statusCode === "number") return error.statusCode;
|
|
2405
|
+
return 500;
|
|
2406
|
+
}
|
|
2407
|
+
function escapeHtml(text) {
|
|
2408
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2409
|
+
}
|
|
2410
|
+
function renderStackSection(frames) {
|
|
2411
|
+
if (frames.length === 0) return `
|
|
2412
|
+
<section class="section">
|
|
2413
|
+
<button class="section-toggle" onclick="toggleSection(this)">
|
|
2414
|
+
<span class="toggle-icon">▼</span>
|
|
2415
|
+
<h2>Stack Trace</h2>
|
|
2416
|
+
</button>
|
|
2417
|
+
<div class="section-content">
|
|
2418
|
+
<p class="muted">No stack trace available.</p>
|
|
2419
|
+
</div>
|
|
2420
|
+
</section>`;
|
|
2421
|
+
const frameRows = frames.map((frame, index) => {
|
|
2422
|
+
return `
|
|
2423
|
+
<div class="frame${frame.file.includes("node_modules") || frame.file.includes("bun:") ? " vendor" : ""}">
|
|
2424
|
+
<div class="frame-header">
|
|
2425
|
+
<span class="frame-index">#${index}</span>
|
|
2426
|
+
<span class="frame-method">${escapeHtml(frame.func)}</span>
|
|
2427
|
+
<span class="frame-location">${escapeHtml(frame.file)}:${frame.line}:${frame.col}</span>
|
|
2428
|
+
</div>
|
|
2429
|
+
</div>`;
|
|
2430
|
+
}).join("");
|
|
2431
|
+
return `
|
|
2432
|
+
<section class="section">
|
|
2433
|
+
<button class="section-toggle" onclick="toggleSection(this)">
|
|
2434
|
+
<span class="toggle-icon">▼</span>
|
|
2435
|
+
<h2>Stack Trace</h2>
|
|
2436
|
+
<span class="badge">${frames.length} frames</span>
|
|
2437
|
+
</button>
|
|
2438
|
+
<div class="section-content">
|
|
2439
|
+
<div class="stack-frames">
|
|
2440
|
+
${frameRows}
|
|
2441
|
+
</div>
|
|
2442
|
+
</div>
|
|
2443
|
+
</section>`;
|
|
2444
|
+
}
|
|
2445
|
+
const REDACTED_HEADERS = /* @__PURE__ */ new Set([
|
|
2446
|
+
"cookie",
|
|
2447
|
+
"authorization",
|
|
2448
|
+
"proxy-authorization",
|
|
2449
|
+
"x-xsrf-token",
|
|
2450
|
+
"x-csrf-token"
|
|
2451
|
+
]);
|
|
2452
|
+
const REDACTED_VALUE = "[redacted]";
|
|
2453
|
+
function renderRequestSection(request) {
|
|
2454
|
+
const url = new URL(request.url);
|
|
2455
|
+
const headers = [];
|
|
2456
|
+
request.headers.forEach((value, key) => {
|
|
2457
|
+
const shown = REDACTED_HEADERS.has(key.toLowerCase()) ? REDACTED_VALUE : value;
|
|
2458
|
+
headers.push(`<tr><td class="key">${escapeHtml(key)}</td><td class="value">${escapeHtml(shown)}</td></tr>`);
|
|
2459
|
+
});
|
|
2460
|
+
const headersTable = headers.length > 0 ? `<table class="details-table">${headers.join("\n")}</table>` : "<p class=\"muted\">No headers.</p>";
|
|
2461
|
+
return `
|
|
2462
|
+
<section class="section">
|
|
2463
|
+
<button class="section-toggle" onclick="toggleSection(this)">
|
|
2464
|
+
<span class="toggle-icon">▼</span>
|
|
2465
|
+
<h2>Request</h2>
|
|
2466
|
+
</button>
|
|
2467
|
+
<div class="section-content">
|
|
2468
|
+
<div class="request-summary">
|
|
2469
|
+
<span class="method-badge">${escapeHtml(request.method)}</span>
|
|
2470
|
+
<span class="request-url">${escapeHtml(url.pathname + url.search)}</span>
|
|
2471
|
+
</div>
|
|
2472
|
+
<div class="subsection">
|
|
2473
|
+
<h3>Headers</h3>
|
|
2474
|
+
${headersTable}
|
|
2475
|
+
</div>
|
|
2476
|
+
</div>
|
|
2477
|
+
</section>`;
|
|
2478
|
+
}
|
|
2479
|
+
function renderEnvironmentSection() {
|
|
2480
|
+
const nodeEnv = typeof process !== "undefined" ? process.env.NODE_ENV ?? "undefined" : "undefined";
|
|
2481
|
+
const bunVersion = typeof process !== "undefined" ? process.versions?.bun ?? "N/A" : "N/A";
|
|
2482
|
+
const platform = typeof process !== "undefined" ? process.platform ?? "unknown" : "unknown";
|
|
2483
|
+
return `
|
|
2484
|
+
<section class="section collapsed">
|
|
2485
|
+
<button class="section-toggle" onclick="toggleSection(this)">
|
|
2486
|
+
<span class="toggle-icon">▶</span>
|
|
2487
|
+
<h2>Environment</h2>
|
|
2488
|
+
</button>
|
|
2489
|
+
<div class="section-content" style="display:none;">
|
|
2490
|
+
<table class="details-table">
|
|
2491
|
+
<tr><td class="key">NODE_ENV</td><td class="value">${escapeHtml(nodeEnv)}</td></tr>
|
|
2492
|
+
<tr><td class="key">Bun Version</td><td class="value">${escapeHtml(bunVersion)}</td></tr>
|
|
2493
|
+
<tr><td class="key">Platform</td><td class="value">${escapeHtml(platform)}</td></tr>
|
|
2494
|
+
</table>
|
|
2495
|
+
</div>
|
|
2496
|
+
</section>`;
|
|
2497
|
+
}
|
|
2498
|
+
//#endregion
|
|
2214
2499
|
//#region src/errors/ExceptionHandler.ts
|
|
2215
2500
|
/** Centralized error handling: reporting, per-class renderers, middleware. */
|
|
2216
2501
|
var ExceptionHandler = class {
|
|
@@ -2272,17 +2557,19 @@ var ExceptionHandler = class {
|
|
|
2272
2557
|
renderDefaultException(error, ctx) {
|
|
2273
2558
|
const debug = this.shouldShowDetails();
|
|
2274
2559
|
const statusCode = resolveExceptionStatus(error);
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2560
|
+
let body;
|
|
2561
|
+
if (HttpException.isHttpException(error)) body = error.toResponse(debug).body;
|
|
2562
|
+
else {
|
|
2563
|
+
body = { message: statusCode < 500 || debug ? error.message : "Internal Server Error" };
|
|
2564
|
+
if (debug) {
|
|
2565
|
+
body.exception = error.name;
|
|
2566
|
+
body.stack = error.stack;
|
|
2567
|
+
}
|
|
2279
2568
|
}
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
body.stack = error.stack;
|
|
2569
|
+
if (this.wantsHtmlResponse(ctx)) {
|
|
2570
|
+
const html = debug && statusCode >= 500 ? renderDebugPage(error, ctx.req.raw) : renderErrorPage(statusCode, body.message);
|
|
2571
|
+
return ctx.html(html, statusCode);
|
|
2284
2572
|
}
|
|
2285
|
-
if (this.wantsHtmlResponse(ctx) && !debug) return ctx.html(renderErrorPage(statusCode, body.message), statusCode);
|
|
2286
2573
|
return ctx.json(body, statusCode);
|
|
2287
2574
|
}
|
|
2288
2575
|
/** False for Inertia, XHR and JSON callers, which need a JSON payload. */
|
|
@@ -3076,8 +3363,8 @@ function buildAppManifest(sources) {
|
|
|
3076
3363
|
agentTools: derived.tools,
|
|
3077
3364
|
warnings
|
|
3078
3365
|
};
|
|
3079
|
-
const section = (key) => {
|
|
3080
|
-
const read = readSection(sources, key, warnings);
|
|
3366
|
+
const section = (key, argument) => {
|
|
3367
|
+
const read = readSection(sources, key, warnings, argument);
|
|
3081
3368
|
return read.status === "described" ? read.value : void 0;
|
|
3082
3369
|
};
|
|
3083
3370
|
const session = describeSession(sources, warnings);
|
|
@@ -3092,6 +3379,8 @@ function buildAppManifest(sources) {
|
|
|
3092
3379
|
const entry = section(key);
|
|
3093
3380
|
if (entry) manifest[key] = entry;
|
|
3094
3381
|
}
|
|
3382
|
+
const database = section("database", sources.container.has("env") ? { env: sources.container.make("env") } : void 0);
|
|
3383
|
+
if (database) manifest.database = database;
|
|
3095
3384
|
const attachments = section("attachments");
|
|
3096
3385
|
if (attachments) {
|
|
3097
3386
|
const { delivery, ...rest } = attachments;
|
|
@@ -3191,7 +3480,7 @@ function perProcessOfStoreClass(storeClass) {
|
|
|
3191
3480
|
* One a deferred provider supplies, or whose manager throws on construction,
|
|
3192
3481
|
* is warned about and told apart from a plain absence.
|
|
3193
3482
|
*/
|
|
3194
|
-
function readSection(sources, key, warnings) {
|
|
3483
|
+
function readSection(sources, key, warnings, argument) {
|
|
3195
3484
|
const { container } = sources;
|
|
3196
3485
|
if (!container.has(key)) {
|
|
3197
3486
|
const deferred = sources.providers.find((provider) => provider.register === "skipped" && provider.provides.includes(key));
|
|
@@ -3215,7 +3504,7 @@ function readSection(sources, key, warnings) {
|
|
|
3215
3504
|
const service = container.make(key);
|
|
3216
3505
|
if (typeof service?.describe === "function") return {
|
|
3217
3506
|
status: "described",
|
|
3218
|
-
value: service.describe()
|
|
3507
|
+
value: service.describe(argument)
|
|
3219
3508
|
};
|
|
3220
3509
|
warnings.push({
|
|
3221
3510
|
code: "section-unverified",
|
|
@@ -3276,7 +3565,7 @@ let devBanner;
|
|
|
3276
3565
|
*/
|
|
3277
3566
|
async function loadDevBanner() {
|
|
3278
3567
|
if (typeof process === "undefined") return devBanner;
|
|
3279
|
-
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-
|
|
3568
|
+
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-DPSpJwVz.js").then((n) => n.n);
|
|
3280
3569
|
return devBanner;
|
|
3281
3570
|
}
|
|
3282
3571
|
/**
|
|
@@ -7023,536 +7312,266 @@ var ConsoleKernel = class {
|
|
|
7023
7312
|
this.output.info(`Command: ${commandName}`);
|
|
7024
7313
|
this.output.line("");
|
|
7025
7314
|
this.output.line(` ${CommandClass.description || "No description"}`);
|
|
7026
|
-
this.output.line("");
|
|
7027
|
-
this.output.line(`Usage: ${formatUsage(parsed)}`);
|
|
7028
|
-
const optionShortcut = (opt) => opt.shortcut ? `-${opt.shortcut}, ` : " ";
|
|
7029
|
-
const column = helpColumn([...parsed.arguments.map(argumentLabel), ...parsed.options.map((opt) => optionShortcut(opt) + optionLabel(opt))], 24);
|
|
7030
|
-
if (parsed.arguments.length > 0) {
|
|
7031
|
-
this.output.line("");
|
|
7032
|
-
this.output.line("Arguments:");
|
|
7033
|
-
for (const arg of parsed.arguments) helpRow(this.output, " ", argumentLabel(arg), column, [
|
|
7034
|
-
arg.description,
|
|
7035
|
-
arg.required ? "(required)" : "(optional)",
|
|
7036
|
-
arg.defaultValue ? `[default: ${arg.defaultValue}]` : void 0
|
|
7037
|
-
]);
|
|
7038
|
-
}
|
|
7039
|
-
if (parsed.options.length > 0) {
|
|
7040
|
-
this.output.line("");
|
|
7041
|
-
this.output.line("Options:");
|
|
7042
|
-
for (const opt of parsed.options) helpRow(this.output, " ", optionShortcut(opt) + optionLabel(opt), column, [opt.description, opt.defaultValue !== void 0 && opt.defaultValue !== false ? `[default: ${opt.defaultValue}]` : void 0]);
|
|
7043
|
-
}
|
|
7044
|
-
this.output.line("");
|
|
7045
|
-
}
|
|
7046
|
-
listCommands() {
|
|
7047
|
-
this.output.line("");
|
|
7048
|
-
this.output.info("Registered Commands:");
|
|
7049
|
-
this.output.line("");
|
|
7050
|
-
const rows = [];
|
|
7051
|
-
for (const [name, cmd] of this.commands) rows.push([name, cmd.description || ""]);
|
|
7052
|
-
if (rows.length > 0) this.output.table(["Command", "Description"], rows);
|
|
7053
|
-
else this.output.line(" No commands registered.");
|
|
7054
|
-
this.output.line("");
|
|
7055
|
-
}
|
|
7056
|
-
groupCommands() {
|
|
7057
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
7058
|
-
const sorted = Array.from(this.commands.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
7059
|
-
for (const [name, cmd] of sorted) {
|
|
7060
|
-
const colonIndex = name.indexOf(":");
|
|
7061
|
-
const namespace = colonIndex !== -1 ? name.slice(0, colonIndex) : "";
|
|
7062
|
-
if (!grouped.has(namespace)) grouped.set(namespace, /* @__PURE__ */ new Map());
|
|
7063
|
-
grouped.get(namespace).set(name, cmd);
|
|
7064
|
-
}
|
|
7065
|
-
return grouped;
|
|
7066
|
-
}
|
|
7067
|
-
suggestCommands(input) {
|
|
7068
|
-
const similar = [];
|
|
7069
|
-
for (const name of this.commands.keys()) if (this.similarity(input, name) > .5) similar.push(name);
|
|
7070
|
-
if (similar.length > 0) {
|
|
7071
|
-
this.output.line("Did you mean one of these?");
|
|
7072
|
-
for (const name of similar.slice(0, 3)) this.output.line(` - ${name}`);
|
|
7073
|
-
}
|
|
7074
|
-
}
|
|
7075
|
-
/** Dice coefficient over bigrams. */
|
|
7076
|
-
similarity(a, b) {
|
|
7077
|
-
const aBigrams = /* @__PURE__ */ new Set();
|
|
7078
|
-
for (let i = 0; i < a.length - 1; i++) aBigrams.add(a.slice(i, i + 2));
|
|
7079
|
-
let matches = 0;
|
|
7080
|
-
for (let i = 0; i < b.length - 1; i++) if (aBigrams.has(b.slice(i, i + 2))) matches++;
|
|
7081
|
-
return 2 * matches / (a.length + b.length - 2);
|
|
7082
|
-
}
|
|
7083
|
-
async call(commandName, args = [], silent = false) {
|
|
7084
|
-
const originalOutput = this.output;
|
|
7085
|
-
if (silent) this.output = new BufferedOutput();
|
|
7086
|
-
const result = await this.handle([commandName, ...args], { helpFlags: false });
|
|
7087
|
-
if (silent) this.output = originalOutput;
|
|
7088
|
-
return result;
|
|
7089
|
-
}
|
|
7090
|
-
};
|
|
7091
|
-
function createConsoleKernel(options) {
|
|
7092
|
-
return new ConsoleKernel(options);
|
|
7093
|
-
}
|
|
7094
|
-
//#endregion
|
|
7095
|
-
//#region src/facades/index.ts
|
|
7096
|
-
/**
|
|
7097
|
-
* A proxy that re-resolves `key` from the container on every access, so
|
|
7098
|
-
* container fakes and flushes are respected.
|
|
7099
|
-
*/
|
|
7100
|
-
function createFacade(container, key) {
|
|
7101
|
-
function resolveService() {
|
|
7102
|
-
try {
|
|
7103
|
-
return container.make(key);
|
|
7104
|
-
} catch (error) {
|
|
7105
|
-
throw new Error(`Facade "${key}" could not be resolved: ${error instanceof Error ? error.message : String(error)}. Ensure the "${key}" service is registered in the active application container.`);
|
|
7106
|
-
}
|
|
7107
|
-
}
|
|
7108
|
-
return new Proxy(Object.create(null), {
|
|
7109
|
-
get(_target, prop, receiver) {
|
|
7110
|
-
const service = resolveService();
|
|
7111
|
-
const value = Reflect.get(service, prop, receiver);
|
|
7112
|
-
if (typeof value === "function") return value.bind(service);
|
|
7113
|
-
return value;
|
|
7114
|
-
},
|
|
7115
|
-
set(_target, prop, value, receiver) {
|
|
7116
|
-
const service = resolveService();
|
|
7117
|
-
return Reflect.set(service, prop, value, receiver);
|
|
7118
|
-
},
|
|
7119
|
-
has(_target, prop) {
|
|
7120
|
-
try {
|
|
7121
|
-
const service = resolveService();
|
|
7122
|
-
return Reflect.has(service, prop);
|
|
7123
|
-
} catch {
|
|
7124
|
-
return false;
|
|
7125
|
-
}
|
|
7126
|
-
},
|
|
7127
|
-
ownKeys(_target) {
|
|
7128
|
-
try {
|
|
7129
|
-
const service = resolveService();
|
|
7130
|
-
return Reflect.ownKeys(service);
|
|
7131
|
-
} catch {
|
|
7132
|
-
return [];
|
|
7133
|
-
}
|
|
7134
|
-
},
|
|
7135
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
7136
|
-
try {
|
|
7137
|
-
const service = resolveService();
|
|
7138
|
-
return Reflect.getOwnPropertyDescriptor(service, prop);
|
|
7139
|
-
} catch {
|
|
7140
|
-
return;
|
|
7141
|
-
}
|
|
7142
|
-
}
|
|
7143
|
-
});
|
|
7144
|
-
}
|
|
7145
|
-
function createFacades(container) {
|
|
7146
|
-
return {
|
|
7147
|
-
Cache: createFacade(container, "cache"),
|
|
7148
|
-
Events: createFacade(container, "events"),
|
|
7149
|
-
Queue: createFacade(container, "queue"),
|
|
7150
|
-
Mail: createFacade(container, "mail"),
|
|
7151
|
-
Log: createFacade(container, "log"),
|
|
7152
|
-
I18n: createFacade(container, "i18n"),
|
|
7153
|
-
Notifications: createFacade(container, "notifications"),
|
|
7154
|
-
Broadcast: createFacade(container, "broadcast"),
|
|
7155
|
-
Storage: createFacade(container, "storage"),
|
|
7156
|
-
Scheduler: createFacade(container, "scheduler")
|
|
7157
|
-
};
|
|
7158
|
-
}
|
|
7159
|
-
//#endregion
|
|
7160
|
-
//#region src/discovery/AutoDiscovery.ts
|
|
7161
|
-
/**
|
|
7162
|
-
* Scans application directories for providers, listeners, jobs and events via
|
|
7163
|
-
* `Bun.Glob` and dynamic `import()`. Standalone by design: nothing in
|
|
7164
|
-
* `Application` runs it, so registration stays explicit — what `guren check`
|
|
7165
|
-
* verifies and what bundle-deploy targets (Workers, Vercel, Lambda) require,
|
|
7166
|
-
* since a runtime directory scan finds nothing in a bundle.
|
|
7167
|
-
*/
|
|
7168
|
-
var AutoDiscovery = class {
|
|
7169
|
-
basePath;
|
|
7170
|
-
options;
|
|
7171
|
-
constructor(options = {}) {
|
|
7172
|
-
this.basePath = options.basePath ?? process.cwd();
|
|
7173
|
-
this.options = {
|
|
7174
|
-
providers: options.providers ?? true,
|
|
7175
|
-
listeners: options.listeners ?? true,
|
|
7176
|
-
jobs: options.jobs ?? true,
|
|
7177
|
-
events: options.events ?? true
|
|
7178
|
-
};
|
|
7179
|
-
}
|
|
7180
|
-
async discover() {
|
|
7181
|
-
const [providers, listeners, jobs, events] = await Promise.all([
|
|
7182
|
-
this.options.providers ? this.discoverProviders() : Promise.resolve([]),
|
|
7183
|
-
this.options.listeners ? this.discoverListeners() : Promise.resolve([]),
|
|
7184
|
-
this.options.jobs ? this.discoverJobs() : Promise.resolve([]),
|
|
7185
|
-
this.options.events ? this.discoverEvents() : Promise.resolve([])
|
|
7186
|
-
]);
|
|
7187
|
-
return {
|
|
7188
|
-
providers,
|
|
7189
|
-
listeners,
|
|
7190
|
-
jobs,
|
|
7191
|
-
events
|
|
7192
|
-
};
|
|
7193
|
-
}
|
|
7194
|
-
/** `app/Providers/`: any exported class with a `register` method. */
|
|
7195
|
-
async discoverProviders() {
|
|
7196
|
-
const dir = join$1(this.basePath, "app", "Providers");
|
|
7197
|
-
const modules = await this.scanDirectory(dir);
|
|
7198
|
-
const providers = [];
|
|
7199
|
-
for (const mod of modules) {
|
|
7200
|
-
const classes = this.extractClasses(mod);
|
|
7201
|
-
for (const cls of classes) if (this.isProvider(cls)) providers.push(cls);
|
|
7202
|
-
}
|
|
7203
|
-
return providers;
|
|
7204
|
-
}
|
|
7205
|
-
/** `app/Listeners/`: classes with a string `static event` and a `handle` method. */
|
|
7206
|
-
async discoverListeners() {
|
|
7207
|
-
const dir = join$1(this.basePath, "app", "Listeners");
|
|
7208
|
-
const modules = await this.scanDirectory(dir);
|
|
7209
|
-
const listeners = [];
|
|
7210
|
-
for (const mod of modules) {
|
|
7211
|
-
const classes = this.extractClasses(mod);
|
|
7212
|
-
for (const cls of classes) {
|
|
7213
|
-
const eventName = this.getStaticEvent(cls);
|
|
7214
|
-
if (eventName && this.hasHandleMethod(cls)) listeners.push({
|
|
7215
|
-
event: eventName,
|
|
7216
|
-
listener: cls
|
|
7217
|
-
});
|
|
7218
|
-
}
|
|
7219
|
-
}
|
|
7220
|
-
return listeners;
|
|
7221
|
-
}
|
|
7222
|
-
/** `app/Jobs/`: classes with a `handle` method. */
|
|
7223
|
-
async discoverJobs() {
|
|
7224
|
-
const dir = join$1(this.basePath, "app", "Jobs");
|
|
7225
|
-
const modules = await this.scanDirectory(dir);
|
|
7226
|
-
const jobs = [];
|
|
7227
|
-
for (const mod of modules) {
|
|
7228
|
-
const classes = this.extractClasses(mod);
|
|
7229
|
-
for (const cls of classes) if (this.hasHandleMethod(cls)) jobs.push(cls);
|
|
7230
|
-
}
|
|
7231
|
-
return jobs;
|
|
7232
|
-
}
|
|
7233
|
-
/** `app/Events/`: every exported class counts. */
|
|
7234
|
-
async discoverEvents() {
|
|
7235
|
-
const dir = join$1(this.basePath, "app", "Events");
|
|
7236
|
-
const modules = await this.scanDirectory(dir);
|
|
7237
|
-
const events = [];
|
|
7238
|
-
for (const mod of modules) {
|
|
7239
|
-
const classes = this.extractClasses(mod);
|
|
7240
|
-
for (const cls of classes) events.push(cls);
|
|
7241
|
-
}
|
|
7242
|
-
return events;
|
|
7243
|
-
}
|
|
7244
|
-
/** Imports every `.ts` file in the directory, skipping `index.ts` barrels. */
|
|
7245
|
-
async scanDirectory(dir) {
|
|
7246
|
-
const modules = [];
|
|
7247
|
-
try {
|
|
7248
|
-
const glob = new Bun.Glob("**/*.ts");
|
|
7249
|
-
for await (const file of glob.scan({
|
|
7250
|
-
cwd: dir,
|
|
7251
|
-
absolute: true
|
|
7252
|
-
})) {
|
|
7253
|
-
if (file.endsWith("/index.ts") || file.endsWith("\\index.ts")) continue;
|
|
7254
|
-
try {
|
|
7255
|
-
const mod = await import(file);
|
|
7256
|
-
modules.push(mod);
|
|
7257
|
-
} catch {
|
|
7258
|
-
continue;
|
|
7259
|
-
}
|
|
7260
|
-
}
|
|
7261
|
-
} catch {}
|
|
7262
|
-
return modules;
|
|
7315
|
+
this.output.line("");
|
|
7316
|
+
this.output.line(`Usage: ${formatUsage(parsed)}`);
|
|
7317
|
+
const optionShortcut = (opt) => opt.shortcut ? `-${opt.shortcut}, ` : " ";
|
|
7318
|
+
const column = helpColumn([...parsed.arguments.map(argumentLabel), ...parsed.options.map((opt) => optionShortcut(opt) + optionLabel(opt))], 24);
|
|
7319
|
+
if (parsed.arguments.length > 0) {
|
|
7320
|
+
this.output.line("");
|
|
7321
|
+
this.output.line("Arguments:");
|
|
7322
|
+
for (const arg of parsed.arguments) helpRow(this.output, " ", argumentLabel(arg), column, [
|
|
7323
|
+
arg.description,
|
|
7324
|
+
arg.required ? "(required)" : "(optional)",
|
|
7325
|
+
arg.defaultValue ? `[default: ${arg.defaultValue}]` : void 0
|
|
7326
|
+
]);
|
|
7327
|
+
}
|
|
7328
|
+
if (parsed.options.length > 0) {
|
|
7329
|
+
this.output.line("");
|
|
7330
|
+
this.output.line("Options:");
|
|
7331
|
+
for (const opt of parsed.options) helpRow(this.output, " ", optionShortcut(opt) + optionLabel(opt), column, [opt.description, opt.defaultValue !== void 0 && opt.defaultValue !== false ? `[default: ${opt.defaultValue}]` : void 0]);
|
|
7332
|
+
}
|
|
7333
|
+
this.output.line("");
|
|
7263
7334
|
}
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7335
|
+
listCommands() {
|
|
7336
|
+
this.output.line("");
|
|
7337
|
+
this.output.info("Registered Commands:");
|
|
7338
|
+
this.output.line("");
|
|
7339
|
+
const rows = [];
|
|
7340
|
+
for (const [name, cmd] of this.commands) rows.push([name, cmd.description || ""]);
|
|
7341
|
+
if (rows.length > 0) this.output.table(["Command", "Description"], rows);
|
|
7342
|
+
else this.output.line(" No commands registered.");
|
|
7343
|
+
this.output.line("");
|
|
7268
7344
|
}
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
const
|
|
7272
|
-
|
|
7345
|
+
groupCommands() {
|
|
7346
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
7347
|
+
const sorted = Array.from(this.commands.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
7348
|
+
for (const [name, cmd] of sorted) {
|
|
7349
|
+
const colonIndex = name.indexOf(":");
|
|
7350
|
+
const namespace = colonIndex !== -1 ? name.slice(0, colonIndex) : "";
|
|
7351
|
+
if (!grouped.has(namespace)) grouped.set(namespace, /* @__PURE__ */ new Map());
|
|
7352
|
+
grouped.get(namespace).set(name, cmd);
|
|
7353
|
+
}
|
|
7354
|
+
return grouped;
|
|
7273
7355
|
}
|
|
7274
|
-
|
|
7275
|
-
|
|
7356
|
+
suggestCommands(input) {
|
|
7357
|
+
const similar = [];
|
|
7358
|
+
for (const name of this.commands.keys()) if (this.similarity(input, name) > .5) similar.push(name);
|
|
7359
|
+
if (similar.length > 0) {
|
|
7360
|
+
this.output.line("Did you mean one of these?");
|
|
7361
|
+
for (const name of similar.slice(0, 3)) this.output.line(` - ${name}`);
|
|
7362
|
+
}
|
|
7276
7363
|
}
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7364
|
+
/** Dice coefficient over bigrams. */
|
|
7365
|
+
similarity(a, b) {
|
|
7366
|
+
const aBigrams = /* @__PURE__ */ new Set();
|
|
7367
|
+
for (let i = 0; i < a.length - 1; i++) aBigrams.add(a.slice(i, i + 2));
|
|
7368
|
+
let matches = 0;
|
|
7369
|
+
for (let i = 0; i < b.length - 1; i++) if (aBigrams.has(b.slice(i, i + 2))) matches++;
|
|
7370
|
+
return 2 * matches / (a.length + b.length - 2);
|
|
7281
7371
|
}
|
|
7282
|
-
|
|
7283
|
-
|
|
7372
|
+
async call(commandName, args = [], silent = false) {
|
|
7373
|
+
const originalOutput = this.output;
|
|
7374
|
+
if (silent) this.output = new BufferedOutput();
|
|
7375
|
+
const result = await this.handle([commandName, ...args], { helpFlags: false });
|
|
7376
|
+
if (silent) this.output = originalOutput;
|
|
7377
|
+
return result;
|
|
7284
7378
|
}
|
|
7285
7379
|
};
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
/** Development-only error page: exposes the stack trace and request details. */
|
|
7289
|
-
function renderDebugPage(error, request) {
|
|
7290
|
-
const errorName = error.name || "Error";
|
|
7291
|
-
const errorMessage = escapeHtml(error.message || "An unknown error occurred");
|
|
7292
|
-
const stackFrames = parseStackTrace(error.stack ?? "");
|
|
7293
|
-
const statusCode = getStatusCode(error);
|
|
7294
|
-
const requestSection = request ? renderRequestSection(request) : "";
|
|
7295
|
-
const stackSection = renderStackSection(stackFrames);
|
|
7296
|
-
const environmentSection = renderEnvironmentSection();
|
|
7297
|
-
return `<!DOCTYPE html>
|
|
7298
|
-
<html lang="en">
|
|
7299
|
-
<head>
|
|
7300
|
-
<meta charset="utf-8">
|
|
7301
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7302
|
-
<title>${escapeHtml(errorName)}: ${errorMessage}</title>
|
|
7303
|
-
<style>
|
|
7304
|
-
/* Guren UI's tokens (github.com/gurenjs/guren-ui), following the OS theme. */
|
|
7305
|
-
:root {
|
|
7306
|
-
color-scheme: light;
|
|
7307
|
-
--g-font-sans: 'Noto Sans JP', ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
7308
|
-
--g-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
7309
|
-
--g-page: #ffffff; --g-panel: #ffffff; --g-raised: #fffafa; --g-line: #e5e7eb; --g-line-strong: #d1d5db;
|
|
7310
|
-
--g-heading: #111827; --g-text: #1f2937; --g-text-2: #4b5563; --g-muted: #9ca3af;
|
|
7311
|
-
--g-danger: #b91c1c; --g-danger-chip: #f23a3a; --g-danger-tint: #fff1f2; --g-accent: #db1b1b;
|
|
7312
|
-
--g-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
|
|
7313
|
-
}
|
|
7314
|
-
@media (prefers-color-scheme: dark) {
|
|
7315
|
-
:root {
|
|
7316
|
-
color-scheme: dark;
|
|
7317
|
-
--g-page: #1a1a2e; --g-panel: #1e1e34; --g-raised: #232340; --g-line: #2e2e4a; --g-line-strong: #3d3d5c;
|
|
7318
|
-
--g-heading: #e0def4; --g-text: #e0def4; --g-text-2: #908caa; --g-muted: #6e6a86;
|
|
7319
|
-
--g-danger: #ffa5a5; --g-danger-tint: rgba(242, 58, 58, 0.12);
|
|
7320
|
-
--g-shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
7321
|
-
}
|
|
7322
|
-
}
|
|
7323
|
-
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
7324
|
-
body { font-family: var(--g-font-sans); background: var(--g-page); color: var(--g-text); line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased; }
|
|
7325
|
-
code, .mono { font-family: var(--g-font-mono); }
|
|
7326
|
-
.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
|
|
7327
|
-
|
|
7328
|
-
.error-header { display: flex; align-items: flex-start; gap: 1.5rem; margin-bottom: 2rem; padding: 2rem; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 12px; border-left: 4px solid var(--g-danger-chip); box-shadow: var(--g-shadow-card); }
|
|
7329
|
-
.status-badge { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; background: var(--g-danger-tint); color: var(--g-danger); font: 700 1.25rem/1 var(--g-font-mono); border-radius: 12px; }
|
|
7330
|
-
.error-info { min-width: 0; }
|
|
7331
|
-
.error-class { font-size: 1.5rem; font-weight: 700; color: var(--g-danger); letter-spacing: -0.01em; margin-bottom: 0.25rem; word-break: break-word; }
|
|
7332
|
-
.error-message { font-size: 1.1rem; color: var(--g-heading); word-break: break-word; }
|
|
7333
|
-
|
|
7334
|
-
.section { margin-bottom: 1rem; background: var(--g-panel); border: 1px solid var(--g-line); border-radius: 12px; box-shadow: var(--g-shadow-card); overflow: hidden; }
|
|
7335
|
-
.section-toggle { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 1rem 1.25rem; background: none; border: none; cursor: pointer; color: var(--g-heading); text-align: left; font-family: inherit; }
|
|
7336
|
-
.section-toggle:hover { background: var(--g-raised); }
|
|
7337
|
-
.section-toggle:focus-visible { outline: 2px solid var(--g-accent); outline-offset: -2px; }
|
|
7338
|
-
.section-toggle h2 { font-size: 15px; font-weight: 700; }
|
|
7339
|
-
.toggle-icon { font-size: 0.7rem; color: var(--g-muted); flex-shrink: 0; width: 1rem; text-align: center; }
|
|
7340
|
-
.badge { font: 500 12px/1.6 var(--g-font-mono); color: var(--g-text-2); background: var(--g-raised); box-shadow: inset 0 0 0 1px var(--g-line); padding: 2px 9px; border-radius: 999px; margin-left: auto; }
|
|
7341
|
-
.section-content { padding: 0 1.25rem 1.25rem; }
|
|
7342
|
-
|
|
7343
|
-
.stack-frames { display: flex; flex-direction: column; gap: 2px; }
|
|
7344
|
-
.frame { padding: 0.6rem 0.75rem; border-radius: 8px; cursor: default; transition: background 0.15s; }
|
|
7345
|
-
.frame:hover { background: var(--g-raised); }
|
|
7346
|
-
.frame.vendor { opacity: 0.5; }
|
|
7347
|
-
.frame.vendor:hover { opacity: 0.75; }
|
|
7348
|
-
.frame-header { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
|
|
7349
|
-
.frame-index { color: var(--g-muted); font: 500 0.75rem var(--g-font-mono); min-width: 2rem; flex-shrink: 0; }
|
|
7350
|
-
.frame-method { color: var(--g-heading); font-family: var(--g-font-mono); font-weight: 500; }
|
|
7351
|
-
.frame-location { color: var(--g-text-2); font-family: var(--g-font-mono); font-size: 0.8rem; margin-left: auto; text-align: right; word-break: break-all; }
|
|
7352
|
-
|
|
7353
|
-
.request-summary { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
|
|
7354
|
-
.method-badge { display: inline-block; padding: 2px 9px; color: var(--g-text-2); background: var(--g-raised); box-shadow: inset 0 0 0 1px var(--g-line); font: 500 12px/1.6 var(--g-font-mono); border-radius: 999px; }
|
|
7355
|
-
.request-url { font-family: var(--g-font-mono); font-size: 0.9rem; word-break: break-all; }
|
|
7356
|
-
|
|
7357
|
-
.subsection { margin-top: 1rem; }
|
|
7358
|
-
.subsection h3 { font: 500 11.5px/1.6 var(--g-font-mono); color: var(--g-muted); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.06em; }
|
|
7359
|
-
|
|
7360
|
-
.details-table { width: 100%; border-collapse: collapse; }
|
|
7361
|
-
.details-table tr { border-bottom: 1px solid var(--g-line); }
|
|
7362
|
-
.details-table tr:last-child { border-bottom: none; }
|
|
7363
|
-
.details-table td { padding: 0.4rem 0; font-size: 0.85rem; vertical-align: top; }
|
|
7364
|
-
.details-table td.key { color: var(--g-text-2); font-weight: 500; width: 200px; padding-right: 1rem; font-family: var(--g-font-mono); font-size: 0.8rem; }
|
|
7365
|
-
.details-table td.value { color: var(--g-text); word-break: break-all; font-family: var(--g-font-mono); font-size: 0.8rem; }
|
|
7366
|
-
|
|
7367
|
-
.muted { color: var(--g-muted); font-style: italic; }
|
|
7368
|
-
.footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--g-line); text-align: center; color: var(--g-muted); font-size: 0.8rem; }
|
|
7369
|
-
</style>
|
|
7370
|
-
</head>
|
|
7371
|
-
<body>
|
|
7372
|
-
<div class="container">
|
|
7373
|
-
<header class="error-header">
|
|
7374
|
-
<div class="status-badge">${statusCode}</div>
|
|
7375
|
-
<div class="error-info">
|
|
7376
|
-
<h1 class="error-class">${escapeHtml(errorName)}</h1>
|
|
7377
|
-
<p class="error-message">${errorMessage}</p>
|
|
7378
|
-
</div>
|
|
7379
|
-
</header>
|
|
7380
|
-
|
|
7381
|
-
${stackSection}
|
|
7382
|
-
${requestSection}
|
|
7383
|
-
${environmentSection}
|
|
7384
|
-
|
|
7385
|
-
<footer class="footer">
|
|
7386
|
-
<p>Guren Framework — Debug Error Page</p>
|
|
7387
|
-
</footer>
|
|
7388
|
-
</div>
|
|
7389
|
-
|
|
7390
|
-
<script>
|
|
7391
|
-
function toggleSection(button) {
|
|
7392
|
-
var section = button.closest('.section');
|
|
7393
|
-
var content = section.querySelector('.section-content');
|
|
7394
|
-
var icon = button.querySelector('.toggle-icon');
|
|
7395
|
-
if (content.style.display === 'none') {
|
|
7396
|
-
content.style.display = 'block';
|
|
7397
|
-
icon.innerHTML = '\\u25BC';
|
|
7398
|
-
section.classList.remove('collapsed');
|
|
7399
|
-
} else {
|
|
7400
|
-
content.style.display = 'none';
|
|
7401
|
-
icon.innerHTML = '\\u25B6';
|
|
7402
|
-
section.classList.add('collapsed');
|
|
7403
|
-
}
|
|
7404
|
-
}
|
|
7405
|
-
<\/script>
|
|
7406
|
-
</body>
|
|
7407
|
-
</html>`;
|
|
7380
|
+
function createConsoleKernel(options) {
|
|
7381
|
+
return new ConsoleKernel(options);
|
|
7408
7382
|
}
|
|
7383
|
+
//#endregion
|
|
7384
|
+
//#region src/facades/index.ts
|
|
7409
7385
|
/**
|
|
7410
|
-
*
|
|
7411
|
-
*
|
|
7386
|
+
* A proxy that re-resolves `key` from the container on every access, so
|
|
7387
|
+
* container fakes and flushes are respected.
|
|
7412
7388
|
*/
|
|
7413
|
-
function
|
|
7414
|
-
|
|
7389
|
+
function createFacade(container, key) {
|
|
7390
|
+
function resolveService() {
|
|
7415
7391
|
try {
|
|
7416
|
-
|
|
7417
|
-
} catch (
|
|
7418
|
-
|
|
7419
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
7420
|
-
const statusCode = getStatusCode(error);
|
|
7421
|
-
const html = renderDebugPage(error, c.req.raw);
|
|
7422
|
-
return new Response(html, {
|
|
7423
|
-
status: statusCode,
|
|
7424
|
-
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
7425
|
-
});
|
|
7392
|
+
return container.make(key);
|
|
7393
|
+
} catch (error) {
|
|
7394
|
+
throw new Error(`Facade "${key}" could not be resolved: ${error instanceof Error ? error.message : String(error)}. Ensure the "${key}" service is registered in the active application container.`);
|
|
7426
7395
|
}
|
|
7427
|
-
}
|
|
7396
|
+
}
|
|
7397
|
+
return new Proxy(Object.create(null), {
|
|
7398
|
+
get(_target, prop, receiver) {
|
|
7399
|
+
const service = resolveService();
|
|
7400
|
+
const value = Reflect.get(service, prop, receiver);
|
|
7401
|
+
if (typeof value === "function") return value.bind(service);
|
|
7402
|
+
return value;
|
|
7403
|
+
},
|
|
7404
|
+
set(_target, prop, value, receiver) {
|
|
7405
|
+
const service = resolveService();
|
|
7406
|
+
return Reflect.set(service, prop, value, receiver);
|
|
7407
|
+
},
|
|
7408
|
+
has(_target, prop) {
|
|
7409
|
+
try {
|
|
7410
|
+
const service = resolveService();
|
|
7411
|
+
return Reflect.has(service, prop);
|
|
7412
|
+
} catch {
|
|
7413
|
+
return false;
|
|
7414
|
+
}
|
|
7415
|
+
},
|
|
7416
|
+
ownKeys(_target) {
|
|
7417
|
+
try {
|
|
7418
|
+
const service = resolveService();
|
|
7419
|
+
return Reflect.ownKeys(service);
|
|
7420
|
+
} catch {
|
|
7421
|
+
return [];
|
|
7422
|
+
}
|
|
7423
|
+
},
|
|
7424
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
7425
|
+
try {
|
|
7426
|
+
const service = resolveService();
|
|
7427
|
+
return Reflect.getOwnPropertyDescriptor(service, prop);
|
|
7428
|
+
} catch {
|
|
7429
|
+
return;
|
|
7430
|
+
}
|
|
7431
|
+
}
|
|
7432
|
+
});
|
|
7428
7433
|
}
|
|
7429
|
-
|
|
7430
|
-
* Split a `file:line:col` suffix off a location string, scanning from the
|
|
7431
|
-
* right so drive letters and URLs with colons stay part of the file path.
|
|
7432
|
-
*/
|
|
7433
|
-
function splitLocation(location) {
|
|
7434
|
-
const lastColon = location.lastIndexOf(":");
|
|
7435
|
-
if (lastColon <= 0) return null;
|
|
7436
|
-
const prevColon = location.lastIndexOf(":", lastColon - 1);
|
|
7437
|
-
if (prevColon <= 0) return null;
|
|
7438
|
-
const line = location.slice(prevColon + 1, lastColon);
|
|
7439
|
-
const col = location.slice(lastColon + 1);
|
|
7440
|
-
if (!/^\d+$/.test(line) || !/^\d+$/.test(col)) return null;
|
|
7434
|
+
function createFacades(container) {
|
|
7441
7435
|
return {
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7436
|
+
Cache: createFacade(container, "cache"),
|
|
7437
|
+
Events: createFacade(container, "events"),
|
|
7438
|
+
Queue: createFacade(container, "queue"),
|
|
7439
|
+
Mail: createFacade(container, "mail"),
|
|
7440
|
+
Log: createFacade(container, "log"),
|
|
7441
|
+
I18n: createFacade(container, "i18n"),
|
|
7442
|
+
Notifications: createFacade(container, "notifications"),
|
|
7443
|
+
Broadcast: createFacade(container, "broadcast"),
|
|
7444
|
+
Storage: createFacade(container, "storage"),
|
|
7445
|
+
Scheduler: createFacade(container, "scheduler")
|
|
7445
7446
|
};
|
|
7446
7447
|
}
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7448
|
+
//#endregion
|
|
7449
|
+
//#region src/discovery/AutoDiscovery.ts
|
|
7450
|
+
/**
|
|
7451
|
+
* Scans application directories for providers, listeners, jobs and events via
|
|
7452
|
+
* `Bun.Glob` and dynamic `import()`. Standalone by design: nothing in
|
|
7453
|
+
* `Application` runs it, so registration stays explicit — what `guren check`
|
|
7454
|
+
* verifies and what bundle-deploy targets (Workers, Vercel, Lambda) require,
|
|
7455
|
+
* since a runtime directory scan finds nothing in a bundle.
|
|
7456
|
+
*/
|
|
7457
|
+
var AutoDiscovery = class {
|
|
7458
|
+
basePath;
|
|
7459
|
+
options;
|
|
7460
|
+
constructor(options = {}) {
|
|
7461
|
+
this.basePath = options.basePath ?? process.cwd();
|
|
7462
|
+
this.options = {
|
|
7463
|
+
providers: options.providers ?? true,
|
|
7464
|
+
listeners: options.listeners ?? true,
|
|
7465
|
+
jobs: options.jobs ?? true,
|
|
7466
|
+
events: options.events ?? true
|
|
7467
|
+
};
|
|
7468
|
+
}
|
|
7469
|
+
async discover() {
|
|
7470
|
+
const [providers, listeners, jobs, events] = await Promise.all([
|
|
7471
|
+
this.options.providers ? this.discoverProviders() : Promise.resolve([]),
|
|
7472
|
+
this.options.listeners ? this.discoverListeners() : Promise.resolve([]),
|
|
7473
|
+
this.options.jobs ? this.discoverJobs() : Promise.resolve([]),
|
|
7474
|
+
this.options.events ? this.discoverEvents() : Promise.resolve([])
|
|
7475
|
+
]);
|
|
7476
|
+
return {
|
|
7477
|
+
providers,
|
|
7478
|
+
listeners,
|
|
7479
|
+
jobs,
|
|
7480
|
+
events
|
|
7481
|
+
};
|
|
7482
|
+
}
|
|
7483
|
+
/** `app/Providers/`: any exported class with a `register` method. */
|
|
7484
|
+
async discoverProviders() {
|
|
7485
|
+
const dir = join$1(this.basePath, "app", "Providers");
|
|
7486
|
+
const modules = await this.scanDirectory(dir);
|
|
7487
|
+
const providers = [];
|
|
7488
|
+
for (const mod of modules) {
|
|
7489
|
+
const classes = this.extractClasses(mod);
|
|
7490
|
+
for (const cls of classes) if (this.isProvider(cls)) providers.push(cls);
|
|
7491
|
+
}
|
|
7492
|
+
return providers;
|
|
7493
|
+
}
|
|
7494
|
+
/** `app/Listeners/`: classes with a string `static event` and a `handle` method. */
|
|
7495
|
+
async discoverListeners() {
|
|
7496
|
+
const dir = join$1(this.basePath, "app", "Listeners");
|
|
7497
|
+
const modules = await this.scanDirectory(dir);
|
|
7498
|
+
const listeners = [];
|
|
7499
|
+
for (const mod of modules) {
|
|
7500
|
+
const classes = this.extractClasses(mod);
|
|
7501
|
+
for (const cls of classes) {
|
|
7502
|
+
const eventName = this.getStaticEvent(cls);
|
|
7503
|
+
if (eventName && this.hasHandleMethod(cls)) listeners.push({
|
|
7504
|
+
event: eventName,
|
|
7505
|
+
listener: cls
|
|
7506
|
+
});
|
|
7460
7507
|
}
|
|
7461
7508
|
}
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7509
|
+
return listeners;
|
|
7510
|
+
}
|
|
7511
|
+
/** `app/Jobs/`: classes with a `handle` method. */
|
|
7512
|
+
async discoverJobs() {
|
|
7513
|
+
const dir = join$1(this.basePath, "app", "Jobs");
|
|
7514
|
+
const modules = await this.scanDirectory(dir);
|
|
7515
|
+
const jobs = [];
|
|
7516
|
+
for (const mod of modules) {
|
|
7517
|
+
const classes = this.extractClasses(mod);
|
|
7518
|
+
for (const cls of classes) if (this.hasHandleMethod(cls)) jobs.push(cls);
|
|
7519
|
+
}
|
|
7520
|
+
return jobs;
|
|
7521
|
+
}
|
|
7522
|
+
/** `app/Events/`: every exported class counts. */
|
|
7523
|
+
async discoverEvents() {
|
|
7524
|
+
const dir = join$1(this.basePath, "app", "Events");
|
|
7525
|
+
const modules = await this.scanDirectory(dir);
|
|
7526
|
+
const events = [];
|
|
7527
|
+
for (const mod of modules) {
|
|
7528
|
+
const classes = this.extractClasses(mod);
|
|
7529
|
+
for (const cls of classes) events.push(cls);
|
|
7530
|
+
}
|
|
7531
|
+
return events;
|
|
7532
|
+
}
|
|
7533
|
+
/** Imports every `.ts` file in the directory, skipping `index.ts` barrels. */
|
|
7534
|
+
async scanDirectory(dir) {
|
|
7535
|
+
const modules = [];
|
|
7536
|
+
try {
|
|
7537
|
+
const glob = new Bun.Glob("**/*.ts");
|
|
7538
|
+
for await (const file of glob.scan({
|
|
7539
|
+
cwd: dir,
|
|
7540
|
+
absolute: true
|
|
7541
|
+
})) {
|
|
7542
|
+
if (file.endsWith("/index.ts") || file.endsWith("\\index.ts")) continue;
|
|
7543
|
+
try {
|
|
7544
|
+
const mod = await import(file);
|
|
7545
|
+
modules.push(mod);
|
|
7546
|
+
} catch {
|
|
7547
|
+
continue;
|
|
7548
|
+
}
|
|
7549
|
+
}
|
|
7550
|
+
} catch {}
|
|
7551
|
+
return modules;
|
|
7552
|
+
}
|
|
7553
|
+
extractClasses(mod) {
|
|
7554
|
+
const classes = [];
|
|
7555
|
+
for (const exportValue of Object.values(mod)) if (this.isConstructor(exportValue)) classes.push(exportValue);
|
|
7556
|
+
return classes;
|
|
7557
|
+
}
|
|
7558
|
+
isConstructor(value) {
|
|
7559
|
+
if (typeof value !== "function") return false;
|
|
7560
|
+
const proto = value.prototype;
|
|
7561
|
+
return proto !== void 0 && proto.constructor === value;
|
|
7562
|
+
}
|
|
7563
|
+
isProvider(cls) {
|
|
7564
|
+
return typeof cls.prototype.register === "function";
|
|
7565
|
+
}
|
|
7566
|
+
getStaticEvent(cls) {
|
|
7567
|
+
const eventProp = cls.event;
|
|
7568
|
+
if (typeof eventProp === "string" && eventProp.length > 0) return eventProp;
|
|
7467
7569
|
return null;
|
|
7468
|
-
}
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
}
|
|
7474
|
-
function escapeHtml(text) {
|
|
7475
|
-
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7476
|
-
}
|
|
7477
|
-
function renderStackSection(frames) {
|
|
7478
|
-
if (frames.length === 0) return `
|
|
7479
|
-
<section class="section">
|
|
7480
|
-
<button class="section-toggle" onclick="toggleSection(this)">
|
|
7481
|
-
<span class="toggle-icon">▼</span>
|
|
7482
|
-
<h2>Stack Trace</h2>
|
|
7483
|
-
</button>
|
|
7484
|
-
<div class="section-content">
|
|
7485
|
-
<p class="muted">No stack trace available.</p>
|
|
7486
|
-
</div>
|
|
7487
|
-
</section>`;
|
|
7488
|
-
const frameRows = frames.map((frame, index) => {
|
|
7489
|
-
return `
|
|
7490
|
-
<div class="frame${frame.file.includes("node_modules") || frame.file.includes("bun:") ? " vendor" : ""}">
|
|
7491
|
-
<div class="frame-header">
|
|
7492
|
-
<span class="frame-index">#${index}</span>
|
|
7493
|
-
<span class="frame-method">${escapeHtml(frame.func)}</span>
|
|
7494
|
-
<span class="frame-location">${escapeHtml(frame.file)}:${frame.line}:${frame.col}</span>
|
|
7495
|
-
</div>
|
|
7496
|
-
</div>`;
|
|
7497
|
-
}).join("");
|
|
7498
|
-
return `
|
|
7499
|
-
<section class="section">
|
|
7500
|
-
<button class="section-toggle" onclick="toggleSection(this)">
|
|
7501
|
-
<span class="toggle-icon">▼</span>
|
|
7502
|
-
<h2>Stack Trace</h2>
|
|
7503
|
-
<span class="badge">${frames.length} frames</span>
|
|
7504
|
-
</button>
|
|
7505
|
-
<div class="section-content">
|
|
7506
|
-
<div class="stack-frames">
|
|
7507
|
-
${frameRows}
|
|
7508
|
-
</div>
|
|
7509
|
-
</div>
|
|
7510
|
-
</section>`;
|
|
7511
|
-
}
|
|
7512
|
-
function renderRequestSection(request) {
|
|
7513
|
-
const url = new URL(request.url);
|
|
7514
|
-
const headers = [];
|
|
7515
|
-
request.headers.forEach((value, key) => {
|
|
7516
|
-
headers.push(`<tr><td class="key">${escapeHtml(key)}</td><td class="value">${escapeHtml(value)}</td></tr>`);
|
|
7517
|
-
});
|
|
7518
|
-
const headersTable = headers.length > 0 ? `<table class="details-table">${headers.join("\n")}</table>` : "<p class=\"muted\">No headers.</p>";
|
|
7519
|
-
return `
|
|
7520
|
-
<section class="section">
|
|
7521
|
-
<button class="section-toggle" onclick="toggleSection(this)">
|
|
7522
|
-
<span class="toggle-icon">▼</span>
|
|
7523
|
-
<h2>Request</h2>
|
|
7524
|
-
</button>
|
|
7525
|
-
<div class="section-content">
|
|
7526
|
-
<div class="request-summary">
|
|
7527
|
-
<span class="method-badge">${escapeHtml(request.method)}</span>
|
|
7528
|
-
<span class="request-url">${escapeHtml(url.pathname + url.search)}</span>
|
|
7529
|
-
</div>
|
|
7530
|
-
<div class="subsection">
|
|
7531
|
-
<h3>Headers</h3>
|
|
7532
|
-
${headersTable}
|
|
7533
|
-
</div>
|
|
7534
|
-
</div>
|
|
7535
|
-
</section>`;
|
|
7536
|
-
}
|
|
7537
|
-
function renderEnvironmentSection() {
|
|
7538
|
-
const nodeEnv = typeof process !== "undefined" ? process.env.NODE_ENV ?? "undefined" : "undefined";
|
|
7539
|
-
const bunVersion = typeof process !== "undefined" ? process.versions?.bun ?? "N/A" : "N/A";
|
|
7540
|
-
const platform = typeof process !== "undefined" ? process.platform ?? "unknown" : "unknown";
|
|
7541
|
-
return `
|
|
7542
|
-
<section class="section collapsed">
|
|
7543
|
-
<button class="section-toggle" onclick="toggleSection(this)">
|
|
7544
|
-
<span class="toggle-icon">▶</span>
|
|
7545
|
-
<h2>Environment</h2>
|
|
7546
|
-
</button>
|
|
7547
|
-
<div class="section-content" style="display:none;">
|
|
7548
|
-
<table class="details-table">
|
|
7549
|
-
<tr><td class="key">NODE_ENV</td><td class="value">${escapeHtml(nodeEnv)}</td></tr>
|
|
7550
|
-
<tr><td class="key">Bun Version</td><td class="value">${escapeHtml(bunVersion)}</td></tr>
|
|
7551
|
-
<tr><td class="key">Platform</td><td class="value">${escapeHtml(platform)}</td></tr>
|
|
7552
|
-
</table>
|
|
7553
|
-
</div>
|
|
7554
|
-
</section>`;
|
|
7555
|
-
}
|
|
7570
|
+
}
|
|
7571
|
+
hasHandleMethod(cls) {
|
|
7572
|
+
return typeof cls.prototype.handle === "function";
|
|
7573
|
+
}
|
|
7574
|
+
};
|
|
7556
7575
|
//#endregion
|
|
7557
7576
|
//#region src/config/env.ts
|
|
7558
7577
|
/**
|