@guren/server 2.29.1 → 2.30.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-D1tF6Qwp.js} +3 -3
- 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/{default-application-DWwscxfW.js → default-application-s9SE-Er7.js} +1 -1
- package/dist/{dev-banner-wz0V_g0R.js → dev-banner-Cw8VnH6J.js} +1 -1
- 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.js +551 -534
- package/dist/internal/testing.js +1 -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/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-jvxB1MFh.js} +1 -1
- package/dist/runtime/index.js +1 -1
- package/package.json +1 -1
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-D1tF6Qwp.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,7 +12,7 @@ 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";
|
|
@@ -22,24 +22,24 @@ import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemorySt
|
|
|
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-jvxB1MFh.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-
|
|
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
43
|
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-IlUesK2t.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";
|
|
@@ -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. */
|
|
@@ -3276,7 +3563,7 @@ let devBanner;
|
|
|
3276
3563
|
*/
|
|
3277
3564
|
async function loadDevBanner() {
|
|
3278
3565
|
if (typeof process === "undefined") return devBanner;
|
|
3279
|
-
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-
|
|
3566
|
+
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-Cw8VnH6J.js").then((n) => n.n);
|
|
3280
3567
|
return devBanner;
|
|
3281
3568
|
}
|
|
3282
3569
|
/**
|
|
@@ -7023,536 +7310,266 @@ var ConsoleKernel = class {
|
|
|
7023
7310
|
this.output.info(`Command: ${commandName}`);
|
|
7024
7311
|
this.output.line("");
|
|
7025
7312
|
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;
|
|
7313
|
+
this.output.line("");
|
|
7314
|
+
this.output.line(`Usage: ${formatUsage(parsed)}`);
|
|
7315
|
+
const optionShortcut = (opt) => opt.shortcut ? `-${opt.shortcut}, ` : " ";
|
|
7316
|
+
const column = helpColumn([...parsed.arguments.map(argumentLabel), ...parsed.options.map((opt) => optionShortcut(opt) + optionLabel(opt))], 24);
|
|
7317
|
+
if (parsed.arguments.length > 0) {
|
|
7318
|
+
this.output.line("");
|
|
7319
|
+
this.output.line("Arguments:");
|
|
7320
|
+
for (const arg of parsed.arguments) helpRow(this.output, " ", argumentLabel(arg), column, [
|
|
7321
|
+
arg.description,
|
|
7322
|
+
arg.required ? "(required)" : "(optional)",
|
|
7323
|
+
arg.defaultValue ? `[default: ${arg.defaultValue}]` : void 0
|
|
7324
|
+
]);
|
|
7325
|
+
}
|
|
7326
|
+
if (parsed.options.length > 0) {
|
|
7327
|
+
this.output.line("");
|
|
7328
|
+
this.output.line("Options:");
|
|
7329
|
+
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]);
|
|
7330
|
+
}
|
|
7331
|
+
this.output.line("");
|
|
7263
7332
|
}
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7333
|
+
listCommands() {
|
|
7334
|
+
this.output.line("");
|
|
7335
|
+
this.output.info("Registered Commands:");
|
|
7336
|
+
this.output.line("");
|
|
7337
|
+
const rows = [];
|
|
7338
|
+
for (const [name, cmd] of this.commands) rows.push([name, cmd.description || ""]);
|
|
7339
|
+
if (rows.length > 0) this.output.table(["Command", "Description"], rows);
|
|
7340
|
+
else this.output.line(" No commands registered.");
|
|
7341
|
+
this.output.line("");
|
|
7268
7342
|
}
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
const
|
|
7272
|
-
|
|
7343
|
+
groupCommands() {
|
|
7344
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
7345
|
+
const sorted = Array.from(this.commands.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
7346
|
+
for (const [name, cmd] of sorted) {
|
|
7347
|
+
const colonIndex = name.indexOf(":");
|
|
7348
|
+
const namespace = colonIndex !== -1 ? name.slice(0, colonIndex) : "";
|
|
7349
|
+
if (!grouped.has(namespace)) grouped.set(namespace, /* @__PURE__ */ new Map());
|
|
7350
|
+
grouped.get(namespace).set(name, cmd);
|
|
7351
|
+
}
|
|
7352
|
+
return grouped;
|
|
7273
7353
|
}
|
|
7274
|
-
|
|
7275
|
-
|
|
7354
|
+
suggestCommands(input) {
|
|
7355
|
+
const similar = [];
|
|
7356
|
+
for (const name of this.commands.keys()) if (this.similarity(input, name) > .5) similar.push(name);
|
|
7357
|
+
if (similar.length > 0) {
|
|
7358
|
+
this.output.line("Did you mean one of these?");
|
|
7359
|
+
for (const name of similar.slice(0, 3)) this.output.line(` - ${name}`);
|
|
7360
|
+
}
|
|
7276
7361
|
}
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7362
|
+
/** Dice coefficient over bigrams. */
|
|
7363
|
+
similarity(a, b) {
|
|
7364
|
+
const aBigrams = /* @__PURE__ */ new Set();
|
|
7365
|
+
for (let i = 0; i < a.length - 1; i++) aBigrams.add(a.slice(i, i + 2));
|
|
7366
|
+
let matches = 0;
|
|
7367
|
+
for (let i = 0; i < b.length - 1; i++) if (aBigrams.has(b.slice(i, i + 2))) matches++;
|
|
7368
|
+
return 2 * matches / (a.length + b.length - 2);
|
|
7281
7369
|
}
|
|
7282
|
-
|
|
7283
|
-
|
|
7370
|
+
async call(commandName, args = [], silent = false) {
|
|
7371
|
+
const originalOutput = this.output;
|
|
7372
|
+
if (silent) this.output = new BufferedOutput();
|
|
7373
|
+
const result = await this.handle([commandName, ...args], { helpFlags: false });
|
|
7374
|
+
if (silent) this.output = originalOutput;
|
|
7375
|
+
return result;
|
|
7284
7376
|
}
|
|
7285
7377
|
};
|
|
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>`;
|
|
7378
|
+
function createConsoleKernel(options) {
|
|
7379
|
+
return new ConsoleKernel(options);
|
|
7408
7380
|
}
|
|
7381
|
+
//#endregion
|
|
7382
|
+
//#region src/facades/index.ts
|
|
7409
7383
|
/**
|
|
7410
|
-
*
|
|
7411
|
-
*
|
|
7384
|
+
* A proxy that re-resolves `key` from the container on every access, so
|
|
7385
|
+
* container fakes and flushes are respected.
|
|
7412
7386
|
*/
|
|
7413
|
-
function
|
|
7414
|
-
|
|
7387
|
+
function createFacade(container, key) {
|
|
7388
|
+
function resolveService() {
|
|
7415
7389
|
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
|
-
});
|
|
7390
|
+
return container.make(key);
|
|
7391
|
+
} catch (error) {
|
|
7392
|
+
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
7393
|
}
|
|
7427
|
-
}
|
|
7394
|
+
}
|
|
7395
|
+
return new Proxy(Object.create(null), {
|
|
7396
|
+
get(_target, prop, receiver) {
|
|
7397
|
+
const service = resolveService();
|
|
7398
|
+
const value = Reflect.get(service, prop, receiver);
|
|
7399
|
+
if (typeof value === "function") return value.bind(service);
|
|
7400
|
+
return value;
|
|
7401
|
+
},
|
|
7402
|
+
set(_target, prop, value, receiver) {
|
|
7403
|
+
const service = resolveService();
|
|
7404
|
+
return Reflect.set(service, prop, value, receiver);
|
|
7405
|
+
},
|
|
7406
|
+
has(_target, prop) {
|
|
7407
|
+
try {
|
|
7408
|
+
const service = resolveService();
|
|
7409
|
+
return Reflect.has(service, prop);
|
|
7410
|
+
} catch {
|
|
7411
|
+
return false;
|
|
7412
|
+
}
|
|
7413
|
+
},
|
|
7414
|
+
ownKeys(_target) {
|
|
7415
|
+
try {
|
|
7416
|
+
const service = resolveService();
|
|
7417
|
+
return Reflect.ownKeys(service);
|
|
7418
|
+
} catch {
|
|
7419
|
+
return [];
|
|
7420
|
+
}
|
|
7421
|
+
},
|
|
7422
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
7423
|
+
try {
|
|
7424
|
+
const service = resolveService();
|
|
7425
|
+
return Reflect.getOwnPropertyDescriptor(service, prop);
|
|
7426
|
+
} catch {
|
|
7427
|
+
return;
|
|
7428
|
+
}
|
|
7429
|
+
}
|
|
7430
|
+
});
|
|
7428
7431
|
}
|
|
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;
|
|
7432
|
+
function createFacades(container) {
|
|
7441
7433
|
return {
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7434
|
+
Cache: createFacade(container, "cache"),
|
|
7435
|
+
Events: createFacade(container, "events"),
|
|
7436
|
+
Queue: createFacade(container, "queue"),
|
|
7437
|
+
Mail: createFacade(container, "mail"),
|
|
7438
|
+
Log: createFacade(container, "log"),
|
|
7439
|
+
I18n: createFacade(container, "i18n"),
|
|
7440
|
+
Notifications: createFacade(container, "notifications"),
|
|
7441
|
+
Broadcast: createFacade(container, "broadcast"),
|
|
7442
|
+
Storage: createFacade(container, "storage"),
|
|
7443
|
+
Scheduler: createFacade(container, "scheduler")
|
|
7445
7444
|
};
|
|
7446
7445
|
}
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7446
|
+
//#endregion
|
|
7447
|
+
//#region src/discovery/AutoDiscovery.ts
|
|
7448
|
+
/**
|
|
7449
|
+
* Scans application directories for providers, listeners, jobs and events via
|
|
7450
|
+
* `Bun.Glob` and dynamic `import()`. Standalone by design: nothing in
|
|
7451
|
+
* `Application` runs it, so registration stays explicit — what `guren check`
|
|
7452
|
+
* verifies and what bundle-deploy targets (Workers, Vercel, Lambda) require,
|
|
7453
|
+
* since a runtime directory scan finds nothing in a bundle.
|
|
7454
|
+
*/
|
|
7455
|
+
var AutoDiscovery = class {
|
|
7456
|
+
basePath;
|
|
7457
|
+
options;
|
|
7458
|
+
constructor(options = {}) {
|
|
7459
|
+
this.basePath = options.basePath ?? process.cwd();
|
|
7460
|
+
this.options = {
|
|
7461
|
+
providers: options.providers ?? true,
|
|
7462
|
+
listeners: options.listeners ?? true,
|
|
7463
|
+
jobs: options.jobs ?? true,
|
|
7464
|
+
events: options.events ?? true
|
|
7465
|
+
};
|
|
7466
|
+
}
|
|
7467
|
+
async discover() {
|
|
7468
|
+
const [providers, listeners, jobs, events] = await Promise.all([
|
|
7469
|
+
this.options.providers ? this.discoverProviders() : Promise.resolve([]),
|
|
7470
|
+
this.options.listeners ? this.discoverListeners() : Promise.resolve([]),
|
|
7471
|
+
this.options.jobs ? this.discoverJobs() : Promise.resolve([]),
|
|
7472
|
+
this.options.events ? this.discoverEvents() : Promise.resolve([])
|
|
7473
|
+
]);
|
|
7474
|
+
return {
|
|
7475
|
+
providers,
|
|
7476
|
+
listeners,
|
|
7477
|
+
jobs,
|
|
7478
|
+
events
|
|
7479
|
+
};
|
|
7480
|
+
}
|
|
7481
|
+
/** `app/Providers/`: any exported class with a `register` method. */
|
|
7482
|
+
async discoverProviders() {
|
|
7483
|
+
const dir = join$1(this.basePath, "app", "Providers");
|
|
7484
|
+
const modules = await this.scanDirectory(dir);
|
|
7485
|
+
const providers = [];
|
|
7486
|
+
for (const mod of modules) {
|
|
7487
|
+
const classes = this.extractClasses(mod);
|
|
7488
|
+
for (const cls of classes) if (this.isProvider(cls)) providers.push(cls);
|
|
7489
|
+
}
|
|
7490
|
+
return providers;
|
|
7491
|
+
}
|
|
7492
|
+
/** `app/Listeners/`: classes with a string `static event` and a `handle` method. */
|
|
7493
|
+
async discoverListeners() {
|
|
7494
|
+
const dir = join$1(this.basePath, "app", "Listeners");
|
|
7495
|
+
const modules = await this.scanDirectory(dir);
|
|
7496
|
+
const listeners = [];
|
|
7497
|
+
for (const mod of modules) {
|
|
7498
|
+
const classes = this.extractClasses(mod);
|
|
7499
|
+
for (const cls of classes) {
|
|
7500
|
+
const eventName = this.getStaticEvent(cls);
|
|
7501
|
+
if (eventName && this.hasHandleMethod(cls)) listeners.push({
|
|
7502
|
+
event: eventName,
|
|
7503
|
+
listener: cls
|
|
7504
|
+
});
|
|
7460
7505
|
}
|
|
7461
7506
|
}
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7507
|
+
return listeners;
|
|
7508
|
+
}
|
|
7509
|
+
/** `app/Jobs/`: classes with a `handle` method. */
|
|
7510
|
+
async discoverJobs() {
|
|
7511
|
+
const dir = join$1(this.basePath, "app", "Jobs");
|
|
7512
|
+
const modules = await this.scanDirectory(dir);
|
|
7513
|
+
const jobs = [];
|
|
7514
|
+
for (const mod of modules) {
|
|
7515
|
+
const classes = this.extractClasses(mod);
|
|
7516
|
+
for (const cls of classes) if (this.hasHandleMethod(cls)) jobs.push(cls);
|
|
7517
|
+
}
|
|
7518
|
+
return jobs;
|
|
7519
|
+
}
|
|
7520
|
+
/** `app/Events/`: every exported class counts. */
|
|
7521
|
+
async discoverEvents() {
|
|
7522
|
+
const dir = join$1(this.basePath, "app", "Events");
|
|
7523
|
+
const modules = await this.scanDirectory(dir);
|
|
7524
|
+
const events = [];
|
|
7525
|
+
for (const mod of modules) {
|
|
7526
|
+
const classes = this.extractClasses(mod);
|
|
7527
|
+
for (const cls of classes) events.push(cls);
|
|
7528
|
+
}
|
|
7529
|
+
return events;
|
|
7530
|
+
}
|
|
7531
|
+
/** Imports every `.ts` file in the directory, skipping `index.ts` barrels. */
|
|
7532
|
+
async scanDirectory(dir) {
|
|
7533
|
+
const modules = [];
|
|
7534
|
+
try {
|
|
7535
|
+
const glob = new Bun.Glob("**/*.ts");
|
|
7536
|
+
for await (const file of glob.scan({
|
|
7537
|
+
cwd: dir,
|
|
7538
|
+
absolute: true
|
|
7539
|
+
})) {
|
|
7540
|
+
if (file.endsWith("/index.ts") || file.endsWith("\\index.ts")) continue;
|
|
7541
|
+
try {
|
|
7542
|
+
const mod = await import(file);
|
|
7543
|
+
modules.push(mod);
|
|
7544
|
+
} catch {
|
|
7545
|
+
continue;
|
|
7546
|
+
}
|
|
7547
|
+
}
|
|
7548
|
+
} catch {}
|
|
7549
|
+
return modules;
|
|
7550
|
+
}
|
|
7551
|
+
extractClasses(mod) {
|
|
7552
|
+
const classes = [];
|
|
7553
|
+
for (const exportValue of Object.values(mod)) if (this.isConstructor(exportValue)) classes.push(exportValue);
|
|
7554
|
+
return classes;
|
|
7555
|
+
}
|
|
7556
|
+
isConstructor(value) {
|
|
7557
|
+
if (typeof value !== "function") return false;
|
|
7558
|
+
const proto = value.prototype;
|
|
7559
|
+
return proto !== void 0 && proto.constructor === value;
|
|
7560
|
+
}
|
|
7561
|
+
isProvider(cls) {
|
|
7562
|
+
return typeof cls.prototype.register === "function";
|
|
7563
|
+
}
|
|
7564
|
+
getStaticEvent(cls) {
|
|
7565
|
+
const eventProp = cls.event;
|
|
7566
|
+
if (typeof eventProp === "string" && eventProp.length > 0) return eventProp;
|
|
7467
7567
|
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
|
-
}
|
|
7568
|
+
}
|
|
7569
|
+
hasHandleMethod(cls) {
|
|
7570
|
+
return typeof cls.prototype.handle === "function";
|
|
7571
|
+
}
|
|
7572
|
+
};
|
|
7556
7573
|
//#endregion
|
|
7557
7574
|
//#region src/config/env.ts
|
|
7558
7575
|
/**
|