@guren/server 2.28.1 → 2.29.1
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/{DocsViewerServiceProvider-BMbcTYVw.js → DocsViewerServiceProvider-BVPZjwQp.js} +7 -1
- package/dist/{Gate-CYfoGQqh.js → Gate-DFiuutZm.js} +1 -25
- package/dist/{McpServiceProvider-PGFPlYTy.js → McpServiceProvider-CvFExxdJ.js} +45 -2
- package/dist/{MessageSigner-Bd25ZJAV.js → MessageSigner-DIUT1Yao.js} +4 -2
- package/dist/{Resource-BhOua2OB.js → Resource-ZMJH4lyD.js} +2 -1
- package/dist/auth/index.js +1 -1
- package/dist/{auth-DIugW0O-.js → auth-DRMeSwev.js} +1 -1
- package/dist/authorization/index.js +2 -2
- package/dist/{authorization-CKOLYWvi.js → authorization-DUjeyGWh.js} +2 -1
- package/dist/{dev-banner-DnaL8Ku6.js → dev-banner-wz0V_g0R.js} +1 -1
- package/dist/encryption/index.js +2 -2
- package/dist/{encryption-CWK5l22W.js → encryption-DF8lZkpj.js} +1 -1
- package/dist/http/Application.d.ts +10 -54
- package/dist/http/boot-sequence.d.ts +8 -0
- package/dist/http/server-lifecycle.d.ts +88 -0
- package/dist/index.js +171 -318
- package/dist/internal/testing.js +1 -1
- package/dist/introspection/types.d.ts +6 -0
- package/dist/mcp/McpServiceProvider.d.ts +7 -0
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/runtime-error-capture.d.ts +24 -0
- package/dist/mcp/runtime-errors.d.ts +59 -0
- package/dist/mvc/Router.d.ts +2 -0
- package/dist/request-container-BbuH0JJy.js +25 -0
- package/dist/runtime/index.js +2 -2
- package/dist/runtime-error-capture-BclelWhA.js +48 -0
- package/dist/runtime-errors-DOPBX0Ox.js +135 -0
- package/dist/vite-manifest-DO0pU1vm.js +391 -0
- package/package.json +3 -3
- package/dist/endpoint-Coq0K_6I.js +0 -26
- package/dist/vite-manifest-wPxfAzjW.js +0 -146
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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-ZMJH4lyD.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-DUjeyGWh.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";
|
|
10
|
-
import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-
|
|
10
|
+
import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-DIUT1Yao.js";
|
|
11
11
|
import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
|
|
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-
|
|
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
15
|
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, h as warnDeprecatedSetter, i as bindAmbient, l as useAsDefaultApplication, m as warnDeprecatedGetter, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-DWwscxfW.js";
|
|
@@ -20,15 +20,16 @@ import { _ as verifyApiToken, a as getApiToken, c as hasBearerHeader, d as revok
|
|
|
20
20
|
import { a as runInRequestScope, i as keepAlive, n as filterSensitiveData, t as Logger } from "./Logger-DWXdtLSJ.js";
|
|
21
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-C2Im3l7t.js";
|
|
22
22
|
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
23
|
-
import { r as isMcpEndpointEnabled } from "./
|
|
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
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-N4cRV42s.js";
|
|
26
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-DmMKcbqj.js";
|
|
27
|
-
import {
|
|
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-DFiuutZm.js";
|
|
29
30
|
import { r as isDocsViewerEnabled } from "./endpoint-CTIzcagh.js";
|
|
30
31
|
import { n as isWildcardHost, t as formatHostPort } from "./host-port-t6wQFaRu.js";
|
|
31
|
-
import { c as isViteProduction, d as startViteDevServer, i as clientManifestCandidates, l as loadViteManifest, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl } from "./vite-manifest-
|
|
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";
|
|
32
33
|
import { readObjectSchema, toJsonSchema } from "./internal/zod-json-schema.js";
|
|
33
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-DQavGm8W.js";
|
|
34
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-Bp2uamzD.js";
|
|
@@ -38,7 +39,7 @@ import { a as MailManager, c as MemoryTransport, i as setMailManager, l as Resen
|
|
|
38
39
|
import { a as LOG_LEVEL_PRIORITY, i as matchDailyFileDate, n as dailyFileDateStamp, r as dailyFilePath, t as DailyFileChannel } from "./DailyFileChannel-CTTPA0EF.js";
|
|
39
40
|
import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "./logging-Ci0mBk5k.js";
|
|
40
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";
|
|
41
|
-
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-DF8lZkpj.js";
|
|
42
43
|
import { a as LocalDriver, i as S3Driver, n as createStorageManager, r as MemoryDriver$2, t as StorageManager } from "./storage-IlUesK2t.js";
|
|
43
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";
|
|
44
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";
|
|
@@ -391,7 +392,7 @@ var Router = class {
|
|
|
391
392
|
return this;
|
|
392
393
|
}
|
|
393
394
|
mount(app, options = {}) {
|
|
394
|
-
|
|
395
|
+
const prepared = this.registry.map((route) => {
|
|
395
396
|
const resolvedMiddlewares = this.resolveMiddlewareNames(route.routeMiddlewareNames);
|
|
396
397
|
const handler = isPrototypeHandler(route.handler) ? createPrototypeRouteHandler(route, {
|
|
397
398
|
container: options.container,
|
|
@@ -404,8 +405,12 @@ var Router = class {
|
|
|
404
405
|
if (contractMiddleware) chain.push(contractMiddleware);
|
|
405
406
|
if (preflightMiddleware) chain.push(preflightMiddleware);
|
|
406
407
|
chain.push(handler);
|
|
407
|
-
|
|
408
|
-
|
|
408
|
+
return {
|
|
409
|
+
route,
|
|
410
|
+
chain
|
|
411
|
+
};
|
|
412
|
+
});
|
|
413
|
+
for (const { route, chain } of prepared) mountRoute(app, route.method, route.path, ...chain);
|
|
409
414
|
}
|
|
410
415
|
clear() {
|
|
411
416
|
this.registry.splice(0, this.registry.length);
|
|
@@ -464,6 +469,18 @@ var Router = class {
|
|
|
464
469
|
action: String(handler[1])
|
|
465
470
|
} : { index });
|
|
466
471
|
}
|
|
472
|
+
/** Model identities behind the serialized binding names, indexed like definitions (RFC 0032). */
|
|
473
|
+
registeredModelBindings() {
|
|
474
|
+
return this.registry.map(({ path, bindings }) => {
|
|
475
|
+
const result = Object.create(null);
|
|
476
|
+
for (const parameter of extractPathParamNames(path)) {
|
|
477
|
+
const model = this.modelBindings.get(parameter)?.model;
|
|
478
|
+
if (model) result[parameter] = model;
|
|
479
|
+
}
|
|
480
|
+
for (const [parameter, binding] of bindings ?? []) result[parameter] = binding.model;
|
|
481
|
+
return result;
|
|
482
|
+
});
|
|
483
|
+
}
|
|
467
484
|
/**
|
|
468
485
|
* Every alias and group resolved, and each route's chain in `mount()` order,
|
|
469
486
|
* index-aligned with {@link definitions} (RFC 0026 §3). Like `definitions()`,
|
|
@@ -965,6 +982,31 @@ function joinPaths(prefixStack, path) {
|
|
|
965
982
|
return "/" + segments.join("/").replace(/\/+/gu, "/");
|
|
966
983
|
}
|
|
967
984
|
//#endregion
|
|
985
|
+
//#region src/http/boot-sequence.ts
|
|
986
|
+
/** Successful steps stay complete; a rejected step must be safe for its owner to retry. */
|
|
987
|
+
var BootSequence = class {
|
|
988
|
+
steps;
|
|
989
|
+
next = 0;
|
|
990
|
+
pending;
|
|
991
|
+
constructor(steps) {
|
|
992
|
+
this.steps = steps;
|
|
993
|
+
}
|
|
994
|
+
run() {
|
|
995
|
+
this.pending ??= Promise.resolve().then(async () => {
|
|
996
|
+
try {
|
|
997
|
+
while (this.next < this.steps.length) {
|
|
998
|
+
await this.steps[this.next]();
|
|
999
|
+
this.next++;
|
|
1000
|
+
}
|
|
1001
|
+
} catch (error) {
|
|
1002
|
+
this.pending = void 0;
|
|
1003
|
+
throw error;
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
return this.pending;
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
//#endregion
|
|
968
1010
|
//#region src/http/middleware/cookie-session-store.ts
|
|
969
1011
|
const IV_BYTES = 12;
|
|
970
1012
|
const TAG_BYTES = 16;
|
|
@@ -1312,9 +1354,12 @@ function remember(ctx, token, boundId) {
|
|
|
1312
1354
|
return token;
|
|
1313
1355
|
}
|
|
1314
1356
|
function csrfField(ctx) {
|
|
1315
|
-
const token = getCsrfToken(ctx);
|
|
1357
|
+
const token = escapeAttribute(getCsrfToken(ctx));
|
|
1316
1358
|
return `<input type="hidden" name="${CSRF_FORM_FIELD}" value="${token}" />`;
|
|
1317
1359
|
}
|
|
1360
|
+
function escapeAttribute(value) {
|
|
1361
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1362
|
+
}
|
|
1318
1363
|
/**
|
|
1319
1364
|
* The token must carry a valid app-key signature, and be in the mode the
|
|
1320
1365
|
* *request* fixes: session-bound needs a matching `sid` (a sibling-subdomain
|
|
@@ -2093,26 +2138,37 @@ function renderErrorPage(statusCode, message) {
|
|
|
2093
2138
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2094
2139
|
<title>${statusCode} ${title}</title>
|
|
2095
2140
|
<style>
|
|
2141
|
+
/* Guren UI's tokens (github.com/gurenjs/guren-ui); the link home is the screen's one crimson fill. */
|
|
2142
|
+
:root {
|
|
2143
|
+
color-scheme: light;
|
|
2144
|
+
--g-page: #ffffff; --g-heading: #111827; --g-text-2: #4b5563; --g-line-strong: #d1d5db;
|
|
2145
|
+
--g-accent: #db1b1b; --g-accent-down: #b91c1c; --g-on-accent: #fff5f5;
|
|
2146
|
+
}
|
|
2147
|
+
@media (prefers-color-scheme: dark) {
|
|
2148
|
+
:root { color-scheme: dark; --g-page: #1a1a2e; --g-heading: #e0def4; --g-text-2: #908caa; --g-line-strong: #3d3d5c; }
|
|
2149
|
+
}
|
|
2096
2150
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
2097
2151
|
body {
|
|
2098
|
-
font-family: -
|
|
2152
|
+
font-family: 'Noto Sans JP', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
2099
2153
|
min-height: 100vh;
|
|
2100
2154
|
display: flex;
|
|
2101
2155
|
align-items: center;
|
|
2102
2156
|
justify-content: center;
|
|
2103
|
-
background:
|
|
2104
|
-
color:
|
|
2157
|
+
background: var(--g-page);
|
|
2158
|
+
color: var(--g-heading);
|
|
2159
|
+
-webkit-font-smoothing: antialiased;
|
|
2105
2160
|
}
|
|
2106
2161
|
.container { text-align: center; padding: 2rem; }
|
|
2107
|
-
.status { font
|
|
2108
|
-
.title { font-size: 1.5rem; font-weight:
|
|
2109
|
-
.description { color:
|
|
2162
|
+
.status { font: 700 6rem/1 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; color: var(--g-line-strong); }
|
|
2163
|
+
.title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin-top: 1rem; }
|
|
2164
|
+
.description { color: var(--g-text-2); margin-top: 0.5rem; max-width: 28rem; }
|
|
2110
2165
|
.home-link {
|
|
2111
|
-
display: inline-block; margin-top: 2rem; padding:
|
|
2112
|
-
background:
|
|
2113
|
-
text-decoration: none; font-size:
|
|
2166
|
+
display: inline-block; margin-top: 2rem; padding: 8px 16px;
|
|
2167
|
+
background: var(--g-accent); color: var(--g-on-accent); border-radius: 8px;
|
|
2168
|
+
text-decoration: none; font-size: 13.5px; font-weight: 700;
|
|
2114
2169
|
}
|
|
2115
|
-
.home-link:hover { background:
|
|
2170
|
+
.home-link:hover { background: var(--g-accent-down); }
|
|
2171
|
+
.home-link:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; }
|
|
2116
2172
|
</style>
|
|
2117
2173
|
</head>
|
|
2118
2174
|
<body>
|
|
@@ -2187,6 +2243,7 @@ var ExceptionHandler = class {
|
|
|
2187
2243
|
return process.env.NODE_ENV !== "production";
|
|
2188
2244
|
}
|
|
2189
2245
|
async handle(error, ctx) {
|
|
2246
|
+
if (!this.shouldNotReport(error)) captureRuntimeError(error, ctx, resolveExceptionStatus(error));
|
|
2190
2247
|
await this.reportException(error);
|
|
2191
2248
|
return this.renderException(error, ctx);
|
|
2192
2249
|
}
|
|
@@ -3175,8 +3232,6 @@ function readSection(sources, key, warnings) {
|
|
|
3175
3232
|
}
|
|
3176
3233
|
//#endregion
|
|
3177
3234
|
//#region src/http/Application.ts
|
|
3178
|
-
const MANAGED_VITE_ENV_FLAG = "GUREN_MANAGED_VITE_DEV_SERVER";
|
|
3179
|
-
const DEFAULT_DEV_ENTRY_PATH = "/resources/js/dev-entry.ts";
|
|
3180
3235
|
/**
|
|
3181
3236
|
* Opt-in strict port binding. The env var can only *subtract* the port walk,
|
|
3182
3237
|
* never switch it on, so an operator can pin a port from outside an app whose
|
|
@@ -3221,201 +3276,9 @@ let devBanner;
|
|
|
3221
3276
|
*/
|
|
3222
3277
|
async function loadDevBanner() {
|
|
3223
3278
|
if (typeof process === "undefined") return devBanner;
|
|
3224
|
-
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-
|
|
3279
|
+
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-wz0V_g0R.js").then((n) => n.n);
|
|
3225
3280
|
return devBanner;
|
|
3226
3281
|
}
|
|
3227
|
-
function clearManagedViteEnv() {
|
|
3228
|
-
if (typeof process === "undefined") return;
|
|
3229
|
-
if (process.env[MANAGED_VITE_ENV_FLAG] === "1") {
|
|
3230
|
-
delete process.env.VITE_DEV_SERVER_URL;
|
|
3231
|
-
if (process.env.GUREN_INERTIA_ENTRY?.endsWith(DEFAULT_DEV_ENTRY_PATH)) delete process.env.GUREN_INERTIA_ENTRY;
|
|
3232
|
-
}
|
|
3233
|
-
delete process.env[MANAGED_VITE_ENV_FLAG];
|
|
3234
|
-
}
|
|
3235
|
-
function normalizeDevEntryUrl(baseUrl) {
|
|
3236
|
-
return `${baseUrl.replace(/\/$/u, "")}${DEFAULT_DEV_ENTRY_PATH}`;
|
|
3237
|
-
}
|
|
3238
|
-
function syncManagedInertiaDevEntry(devServerUrl) {
|
|
3239
|
-
if (typeof process === "undefined") return;
|
|
3240
|
-
const nextEntry = normalizeDevEntryUrl(devServerUrl);
|
|
3241
|
-
const currentEntry = process.env.GUREN_INERTIA_ENTRY;
|
|
3242
|
-
if (!currentEntry || currentEntry.endsWith(DEFAULT_DEV_ENTRY_PATH)) process.env.GUREN_INERTIA_ENTRY = nextEntry;
|
|
3243
|
-
}
|
|
3244
|
-
function getGlobalState() {
|
|
3245
|
-
return globalThis;
|
|
3246
|
-
}
|
|
3247
|
-
/**
|
|
3248
|
-
* How long a server `stop()` may take before shutdown stops waiting. Abandoning
|
|
3249
|
-
* this wait is safe in a way abandoning a Vite close is not: the socket has
|
|
3250
|
-
* already stopped accepting connections, so what is left is a drain.
|
|
3251
|
-
*/
|
|
3252
|
-
function bunStopTimeoutMs() {
|
|
3253
|
-
return shutdownTimeoutMs("GUREN_BUN_STOP_TIMEOUT_MS");
|
|
3254
|
-
}
|
|
3255
|
-
/**
|
|
3256
|
-
* How long a `bun --hot` reload waits on the server it replaces. That stop is
|
|
3257
|
-
* forced, and the hot-reload teardown has already server-closed every broadcast
|
|
3258
|
-
* WebSocket, so nothing is draining; on Bun 1.3.x `stop()` then never resolves
|
|
3259
|
-
* (1.4.0 resolves at once). Quoted in docs/{en,ja}/guides/architecture.md.
|
|
3260
|
-
*/
|
|
3261
|
-
const HOT_RELOAD_STOP_TIMEOUT_MS = 250;
|
|
3262
|
-
function defaultStopBound() {
|
|
3263
|
-
return {
|
|
3264
|
-
timeoutMs: bunStopTimeoutMs(),
|
|
3265
|
-
warn: true
|
|
3266
|
-
};
|
|
3267
|
-
}
|
|
3268
|
-
/**
|
|
3269
|
-
* Silent: on Bun 1.3.x it is hit on every reload, and there is nothing to
|
|
3270
|
-
* report. `GUREN_BUN_STOP_TIMEOUT_MS` can only shorten it: it is set for a
|
|
3271
|
-
* production drain, which a reload never is.
|
|
3272
|
-
*/
|
|
3273
|
-
function hotReloadStopBound() {
|
|
3274
|
-
return {
|
|
3275
|
-
timeoutMs: Math.min(bunStopTimeoutMs(), HOT_RELOAD_STOP_TIMEOUT_MS),
|
|
3276
|
-
warn: false
|
|
3277
|
-
};
|
|
3278
|
-
}
|
|
3279
|
-
/**
|
|
3280
|
-
* A positive integer of milliseconds, or 5000 when unset or unparseable. One
|
|
3281
|
-
* parse for both bounds, so they cannot drift apart.
|
|
3282
|
-
*/
|
|
3283
|
-
function shutdownTimeoutMs(envName) {
|
|
3284
|
-
const parsed = typeof process !== "undefined" ? Number.parseInt(process.env[envName] ?? "", 10) : NaN;
|
|
3285
|
-
return Number.isInteger(parsed) && parsed > 0 ? parsed : 5e3;
|
|
3286
|
-
}
|
|
3287
|
-
/**
|
|
3288
|
-
* Awaits `work`, giving up after `timeoutMs`. Resolves either way: every caller
|
|
3289
|
-
* is a shutdown path, and one that hangs is worse than one that gives up.
|
|
3290
|
-
*/
|
|
3291
|
-
async function awaitBounded(work, timeoutMs, onTimeout) {
|
|
3292
|
-
let timer;
|
|
3293
|
-
try {
|
|
3294
|
-
if (await Promise.race([work.then(() => false), new Promise((resolve) => {
|
|
3295
|
-
timer = setTimeout(() => resolve(true), timeoutMs);
|
|
3296
|
-
})])) onTimeout(timeoutMs);
|
|
3297
|
-
} finally {
|
|
3298
|
-
clearTimeout(timer);
|
|
3299
|
-
}
|
|
3300
|
-
}
|
|
3301
|
-
/** `stop()` bounded by `bound` ({@link bunStopTimeoutMs} by default), warning rather than throwing. */
|
|
3302
|
-
async function stopBunServerBounded(server, closeActiveConnections, bound = defaultStopBound()) {
|
|
3303
|
-
await awaitBounded((async () => {
|
|
3304
|
-
try {
|
|
3305
|
-
await server.stop?.(closeActiveConnections);
|
|
3306
|
-
} catch (error) {
|
|
3307
|
-
console.warn("Failed to stop Bun server:", error);
|
|
3308
|
-
}
|
|
3309
|
-
})(), bound.timeoutMs, (timeoutMs) => {
|
|
3310
|
-
if (!bound.warn) return;
|
|
3311
|
-
console.warn(`Bun server did not stop within ${timeoutMs}ms — no longer waiting on it. In-flight requests may still be draining.`);
|
|
3312
|
-
});
|
|
3313
|
-
}
|
|
3314
|
-
async function stopActiveBunServer(closeActiveConnections = false, bound) {
|
|
3315
|
-
const state = getGlobalState();
|
|
3316
|
-
const previous = state.__gurenActiveServer;
|
|
3317
|
-
if (!previous?.stop) {
|
|
3318
|
-
state.__gurenActiveServer = void 0;
|
|
3319
|
-
return;
|
|
3320
|
-
}
|
|
3321
|
-
try {
|
|
3322
|
-
await stopBunServerBounded(previous, closeActiveConnections, bound);
|
|
3323
|
-
} finally {
|
|
3324
|
-
releaseActiveBunServer(previous);
|
|
3325
|
-
}
|
|
3326
|
-
}
|
|
3327
|
-
function setActiveBunServer(server) {
|
|
3328
|
-
getGlobalState().__gurenActiveServer = server;
|
|
3329
|
-
}
|
|
3330
|
-
/**
|
|
3331
|
-
* Gives up the process-wide slot, but only while it still holds `server`: a
|
|
3332
|
-
* `listen()` that completed inside the caller's await has repointed it at a
|
|
3333
|
-
* live server, which clearing would strip of its exit teardown.
|
|
3334
|
-
*/
|
|
3335
|
-
function releaseActiveBunServer(server) {
|
|
3336
|
-
if (getGlobalState().__gurenActiveServer === server) setActiveBunServer();
|
|
3337
|
-
}
|
|
3338
|
-
/**
|
|
3339
|
-
* Attaches one SIGINT/SIGTERM/exit trio and returns the disposer for it. A
|
|
3340
|
-
* boolean-guarded registrar would leave handlers attached and let the next
|
|
3341
|
-
* `listen()` stack a second set on top — and `process.once` fires in
|
|
3342
|
-
* registration order, so a stale handler's `process.exit()` can end the process
|
|
3343
|
-
* ahead of the live set's shutdown.
|
|
3344
|
-
*/
|
|
3345
|
-
function registerProcessTeardown(onSignal, onExit) {
|
|
3346
|
-
process.once("SIGINT", onSignal);
|
|
3347
|
-
process.once("SIGTERM", onSignal);
|
|
3348
|
-
process.on("exit", onExit);
|
|
3349
|
-
return () => {
|
|
3350
|
-
process.off("SIGINT", onSignal);
|
|
3351
|
-
process.off("SIGTERM", onSignal);
|
|
3352
|
-
process.off("exit", onExit);
|
|
3353
|
-
};
|
|
3354
|
-
}
|
|
3355
|
-
/**
|
|
3356
|
-
* How long a Vite `close()` may take before shutdown abandons it — a browser tab
|
|
3357
|
-
* holding its HMR socket can keep that wait alive indefinitely. A stranded asset
|
|
3358
|
-
* server is recoverable noise; a `listen()` that never returns is not.
|
|
3359
|
-
*/
|
|
3360
|
-
function viteCloseTimeoutMs() {
|
|
3361
|
-
return shutdownTimeoutMs("GUREN_VITE_CLOSE_TIMEOUT_MS");
|
|
3362
|
-
}
|
|
3363
|
-
/**
|
|
3364
|
-
* `close()` bounded by {@link viteCloseTimeoutMs}: resolves once the server
|
|
3365
|
-
* closed, failed (warned), or ran out the clock (warned, abandoned).
|
|
3366
|
-
*/
|
|
3367
|
-
async function closeViteDevServerBounded(server) {
|
|
3368
|
-
await awaitBounded((async () => {
|
|
3369
|
-
try {
|
|
3370
|
-
await server.close();
|
|
3371
|
-
} catch (error) {
|
|
3372
|
-
console.warn("Failed to stop Vite dev server:", error);
|
|
3373
|
-
}
|
|
3374
|
-
})(), viteCloseTimeoutMs(), (timeoutMs) => {
|
|
3375
|
-
console.warn(`Vite dev server did not close within ${timeoutMs}ms — abandoning it. A stale asset server may still hold its port.`);
|
|
3376
|
-
});
|
|
3377
|
-
}
|
|
3378
|
-
/**
|
|
3379
|
-
* Closes the managed Vite dev server whoever owns it. Only `listen()`'s restart
|
|
3380
|
-
* path calls this — the one case where an owner's claim does not survive.
|
|
3381
|
-
*/
|
|
3382
|
-
async function stopActiveViteDevServer() {
|
|
3383
|
-
const previous = getGlobalState().__gurenActiveViteDevServer;
|
|
3384
|
-
try {
|
|
3385
|
-
if (previous) await closeViteDevServerBounded(previous.server);
|
|
3386
|
-
} finally {
|
|
3387
|
-
previous?.disposeTeardown();
|
|
3388
|
-
if (getGlobalState().__gurenActiveViteDevServer === previous) setActiveViteDevServer();
|
|
3389
|
-
}
|
|
3390
|
-
}
|
|
3391
|
-
function publishManagedViteEnv(localUrl) {
|
|
3392
|
-
if (typeof process === "undefined") return;
|
|
3393
|
-
process.env.VITE_DEV_SERVER_URL = localUrl;
|
|
3394
|
-
process.env[MANAGED_VITE_ENV_FLAG] = "1";
|
|
3395
|
-
syncManagedInertiaDevEntry(localUrl);
|
|
3396
|
-
}
|
|
3397
|
-
/**
|
|
3398
|
-
* The one write point for the active-record slot. `VITE_DEV_SERVER_URL` and the
|
|
3399
|
-
* managed flag travel with it, so a stale close cannot unpublish an adopter's
|
|
3400
|
-
* URL while its record stays live, or the reverse.
|
|
3401
|
-
*/
|
|
3402
|
-
function setActiveViteDevServer(active) {
|
|
3403
|
-
getGlobalState().__gurenActiveViteDevServer = active;
|
|
3404
|
-
if (active) publishManagedViteEnv(active.localUrl);
|
|
3405
|
-
else clearManagedViteEnv();
|
|
3406
|
-
}
|
|
3407
|
-
/**
|
|
3408
|
-
* The managed Vite dev server a previous `listen()` left running. Reusing it
|
|
3409
|
-
* keeps the browser's HMR socket connected and skips the
|
|
3410
|
-
* {@link viteCloseTimeoutMs} wait. Explicit `vite` options veto reuse: the
|
|
3411
|
-
* running server was built from the *previous* call's options.
|
|
3412
|
-
*/
|
|
3413
|
-
function reusableActiveViteDevServer(viteOption) {
|
|
3414
|
-
if (typeof viteOption === "object") return;
|
|
3415
|
-
const active = getGlobalState().__gurenActiveViteDevServer;
|
|
3416
|
-
if (!active || !active.server.httpServer?.listening) return;
|
|
3417
|
-
return active;
|
|
3418
|
-
}
|
|
3419
3282
|
/**
|
|
3420
3283
|
* Wires an app-local router and a DI container into a running Hono instance.
|
|
3421
3284
|
*
|
|
@@ -3444,10 +3307,13 @@ var Application = class {
|
|
|
3444
3307
|
cookielessAuthPaths = /* @__PURE__ */ new Set();
|
|
3445
3308
|
/** {@link configDefinitions} with where each was listed, which ConfigServiceProvider's errors name. */
|
|
3446
3309
|
configEntries;
|
|
3447
|
-
|
|
3310
|
+
routeRegistration;
|
|
3311
|
+
bootSequence;
|
|
3448
3312
|
bootPromise;
|
|
3449
3313
|
manifestPromise;
|
|
3450
3314
|
bootAttempted = false;
|
|
3315
|
+
/** Settles once the dev-only runtime error buffer is bound; boot waits for it so McpServiceProvider sees the binding. */
|
|
3316
|
+
runtimeErrorsLoaded;
|
|
3451
3317
|
constructor(options = {}) {
|
|
3452
3318
|
this.options = options;
|
|
3453
3319
|
this.configEntries = [...(options.config ?? []).map((definition, index) => ({
|
|
@@ -3468,6 +3334,15 @@ var Application = class {
|
|
|
3468
3334
|
this.container.instance("hono", this.hono);
|
|
3469
3335
|
this.container.instance("auth", this.authManager);
|
|
3470
3336
|
this.container.instance("router", this.router);
|
|
3337
|
+
const runtimeErrors = loadRuntimeErrorsModule();
|
|
3338
|
+
if (runtimeErrors) {
|
|
3339
|
+
const root = process.cwd();
|
|
3340
|
+
this.runtimeErrorsLoaded = runtimeErrors.then(({ RuntimeErrorBuffer }) => {
|
|
3341
|
+
this.container.instance(RUNTIME_ERRORS_BINDING, new RuntimeErrorBuffer(root));
|
|
3342
|
+
}, (error) => {
|
|
3343
|
+
console.warn(`[guren] GUREN_MCP=1 but the runtime error collector could not load: ${error instanceof Error ? error.message : String(error)}`);
|
|
3344
|
+
});
|
|
3345
|
+
}
|
|
3471
3346
|
if (options.inertia?.document) this.container.instance("inertia.document", options.inertia.document);
|
|
3472
3347
|
if (options.inertia?.ssrRenderer) this.container.instance("inertia.ssrRenderer", options.inertia.ssrRenderer);
|
|
3473
3348
|
if (options.inertia?.share) shareInertiaProps(options.inertia.share, this.container);
|
|
@@ -3549,11 +3424,8 @@ var Application = class {
|
|
|
3549
3424
|
}
|
|
3550
3425
|
/** Runs the registrars once; `introspect()` stops here, since mounting refuses an unregistered alias it reports. */
|
|
3551
3426
|
async registerRoutes() {
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
for (const gurenModule of this.options.modules ?? []) await mountModuleRoutes(this.router, gurenModule);
|
|
3555
|
-
this.routesRegistered = true;
|
|
3556
|
-
}
|
|
3427
|
+
this.routeRegistration ??= new BootSequence([() => this.options.routes?.(this.router), ...(this.options.modules ?? []).map((gurenModule) => () => mountModuleRoutes(this.router, gurenModule))]);
|
|
3428
|
+
await this.routeRegistration.run();
|
|
3557
3429
|
}
|
|
3558
3430
|
/**
|
|
3559
3431
|
* Every failure here is one a request would otherwise surface as a 500:
|
|
@@ -3582,9 +3454,9 @@ var Application = class {
|
|
|
3582
3454
|
/**
|
|
3583
3455
|
* Registers providers, runs the boot callback, mounts routes, boots providers.
|
|
3584
3456
|
*
|
|
3585
|
-
*
|
|
3586
|
-
*
|
|
3587
|
-
*
|
|
3457
|
+
* Concurrent callers share a boot. On failure, a later call resumes at the
|
|
3458
|
+
* failed step; completed steps stay complete. A throwing hook must undo its
|
|
3459
|
+
* own partial effects or be safe to retry; otherwise construct a fresh app.
|
|
3588
3460
|
*/
|
|
3589
3461
|
async boot() {
|
|
3590
3462
|
if (isIntrospecting()) {
|
|
@@ -3592,11 +3464,11 @@ var Application = class {
|
|
|
3592
3464
|
return;
|
|
3593
3465
|
}
|
|
3594
3466
|
if (this.manifestPromise) throw new Error("[guren] This application was introspected: its providers may have run introspect() in place of register(), so it cannot boot. Construct a new application to serve it.");
|
|
3595
|
-
this.bootPromise ??= this.bootOnce();
|
|
3467
|
+
const attempt = this.bootPromise ??= this.bootOnce();
|
|
3596
3468
|
try {
|
|
3597
|
-
await
|
|
3469
|
+
await attempt;
|
|
3598
3470
|
} catch (error) {
|
|
3599
|
-
this.bootPromise = void 0;
|
|
3471
|
+
if (this.bootPromise === attempt) this.bootPromise = void 0;
|
|
3600
3472
|
throw error;
|
|
3601
3473
|
}
|
|
3602
3474
|
}
|
|
@@ -3634,14 +3506,18 @@ var Application = class {
|
|
|
3634
3506
|
}
|
|
3635
3507
|
async bootOnce() {
|
|
3636
3508
|
this.bootAttempted = true;
|
|
3509
|
+
if (this.runtimeErrorsLoaded) await this.runtimeErrorsLoaded;
|
|
3637
3510
|
if (this.options.hostAuthorization !== void 0 && this.hasHttpConfig()) throw new Error("[guren] Host authorization is configured twice: createApp({ hostAuthorization }) and config/http.ts. Keep one.");
|
|
3638
3511
|
await this.providerManager.registerAll();
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3512
|
+
this.bootSequence ??= new BootSequence([
|
|
3513
|
+
() => this.options.boot?.(this.hono),
|
|
3514
|
+
() => this.mountRoutes(),
|
|
3515
|
+
() => this.mountDevEndpoint(isMcpEndpointEnabled(), async () => (await import("./McpServiceProvider-CvFExxdJ.js").then((n) => n.n)).McpServiceProvider, "GUREN_MCP=1 but the MCP endpoint could not load — is @guren/cli installed?"),
|
|
3516
|
+
() => this.mountDevEndpoint(isDocsViewerEnabled(), async () => (await import("./DocsViewerServiceProvider-BVPZjwQp.js")).DocsViewerServiceProvider, "GUREN_DOCS=1 but the docs viewer could not load — is @guren/cli resolvable from this app?"),
|
|
3517
|
+
() => this.providerManager.bootAll(),
|
|
3518
|
+
() => this.warnOnUnconfiguredAuth()
|
|
3519
|
+
]);
|
|
3520
|
+
await this.bootSequence.run();
|
|
3645
3521
|
}
|
|
3646
3522
|
/**
|
|
3647
3523
|
* After every provider has booted: `auth` was asked for, yet the default
|
|
@@ -3724,28 +3600,18 @@ var Application = class {
|
|
|
3724
3600
|
const supersededServer = getGlobalState().__gurenActiveServer;
|
|
3725
3601
|
await stopActiveBunServer(true, isHotReloadRuntime() ? hotReloadStopBound() : void 0);
|
|
3726
3602
|
const { port = 3e3, hostname = "0.0.0.0", assetsUrl, vite, portFallback } = options;
|
|
3727
|
-
const externalAssetsUrl = typeof process !== "undefined" && process.env?.[
|
|
3603
|
+
const externalAssetsUrl = typeof process !== "undefined" && process.env?.["GUREN_MANAGED_VITE_DEV_SERVER"] !== "1" ? process.env?.VITE_DEV_SERVER_URL : void 0;
|
|
3728
3604
|
let resolvedAssetsUrl = assetsUrl ?? externalAssetsUrl;
|
|
3729
3605
|
const shouldLogBanner = typeof process === "undefined" || process.env.NODE_ENV !== "production" && process.env?.GUREN_DEV_BANNER !== "0";
|
|
3730
3606
|
if (shouldLogBanner) await loadDevBanner();
|
|
3731
3607
|
const { websocket } = await import("hono/bun");
|
|
3732
3608
|
const shouldStartVite = vite !== false && typeof process !== "undefined" && process.env.NODE_ENV !== "production" && !resolvedAssetsUrl && process.env?.GUREN_DEV_VITE !== "0";
|
|
3733
|
-
const adoptViteDevServer = (viteServer, localUrl) => {
|
|
3734
|
-
const displaced = getGlobalState().__gurenActiveViteDevServer;
|
|
3735
|
-
displaced?.disposeTeardown();
|
|
3736
|
-
if (displaced && displaced.server !== viteServer) closeViteDevServerBounded(displaced.server);
|
|
3737
|
-
setActiveViteDevServer({
|
|
3738
|
-
server: viteServer,
|
|
3739
|
-
localUrl,
|
|
3740
|
-
owner: this,
|
|
3741
|
-
disposeTeardown: this.registerViteTeardown()
|
|
3742
|
-
});
|
|
3743
|
-
resolvedAssetsUrl = localUrl;
|
|
3744
|
-
};
|
|
3745
3609
|
const reusableVite = shouldStartVite ? reusableActiveViteDevServer(vite) : void 0;
|
|
3746
3610
|
let startedViteHere = false;
|
|
3747
|
-
if (reusableVite)
|
|
3748
|
-
|
|
3611
|
+
if (reusableVite) {
|
|
3612
|
+
adoptViteDevServer(this, reusableVite.server, reusableVite.localUrl);
|
|
3613
|
+
resolvedAssetsUrl = reusableVite.localUrl;
|
|
3614
|
+
} else await stopActiveViteDevServer();
|
|
3749
3615
|
if (shouldStartVite && !reusableVite) {
|
|
3750
3616
|
const viteOptions = typeof vite === "object" ? vite : void 0;
|
|
3751
3617
|
try {
|
|
@@ -3755,11 +3621,11 @@ var Application = class {
|
|
|
3755
3621
|
host: viteOptions?.host,
|
|
3756
3622
|
port: viteOptions?.port
|
|
3757
3623
|
});
|
|
3758
|
-
adoptViteDevServer(server, localUrl);
|
|
3624
|
+
adoptViteDevServer(this, server, localUrl);
|
|
3625
|
+
resolvedAssetsUrl = localUrl;
|
|
3759
3626
|
startedViteHere = true;
|
|
3760
3627
|
} catch (error) {
|
|
3761
|
-
|
|
3762
|
-
process.exit(1);
|
|
3628
|
+
throw new Error(`Failed to start Vite dev server: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3763
3629
|
}
|
|
3764
3630
|
}
|
|
3765
3631
|
const attempts = resolvePortAttempts(portFallback, port);
|
|
@@ -3777,7 +3643,7 @@ var Application = class {
|
|
|
3777
3643
|
break;
|
|
3778
3644
|
} catch (error) {
|
|
3779
3645
|
if (offset === attempts - 1 || !isAddressInUse(error)) {
|
|
3780
|
-
if (startedViteHere) await this
|
|
3646
|
+
if (startedViteHere) await closeOwnedViteDevServer(this);
|
|
3781
3647
|
throw error;
|
|
3782
3648
|
}
|
|
3783
3649
|
console.warn(`[guren] Port ${attemptPort} is in use, trying ${attemptPort + 1}...`);
|
|
@@ -3828,7 +3694,7 @@ var Application = class {
|
|
|
3828
3694
|
* or when called twice. `closeActiveConnections` forces in-flight requests
|
|
3829
3695
|
* closed, matching Bun's own `stop()`. The managed Vite dev server goes too,
|
|
3830
3696
|
* unless a later `listen()` adopted it. Both closes are bounded
|
|
3831
|
-
* (
|
|
3697
|
+
* (GUREN_BUN_STOP_TIMEOUT_MS and GUREN_VITE_CLOSE_TIMEOUT_MS) and then abandoned.
|
|
3832
3698
|
*/
|
|
3833
3699
|
async stop(closeActiveConnections = false) {
|
|
3834
3700
|
const server = this.bunServer;
|
|
@@ -3842,7 +3708,8 @@ var Application = class {
|
|
|
3842
3708
|
this.boundAddress = void 0;
|
|
3843
3709
|
this.disposeBunTeardown?.();
|
|
3844
3710
|
this.disposeBunTeardown = void 0;
|
|
3845
|
-
await this
|
|
3711
|
+
await closeOwnedViteDevServer(this);
|
|
3712
|
+
if (!this.bunServer) this.container.makeOptional(RUNTIME_ERRORS_BINDING)?.reset();
|
|
3846
3713
|
}
|
|
3847
3714
|
register(provider) {
|
|
3848
3715
|
this.providerManager.register(provider);
|
|
@@ -3865,43 +3732,9 @@ var Application = class {
|
|
|
3865
3732
|
}
|
|
3866
3733
|
loadDevBanner().then((loaded) => loaded?.logDevServerBanner(options), (error) => console.error("Failed to load the dev server banner:", error));
|
|
3867
3734
|
}
|
|
3868
|
-
/**
|
|
3869
|
-
* Closes the managed Vite dev server, but only while this application still
|
|
3870
|
-
* owns it: another `listen()` may have adopted the same object, and closing it
|
|
3871
|
-
* then would take the asset server out from under an app serving from it. The
|
|
3872
|
-
* slot's record is the one place that distinction exists.
|
|
3873
|
-
*/
|
|
3874
|
-
async closeViteDevServer() {
|
|
3875
|
-
const active = getGlobalState().__gurenActiveViteDevServer;
|
|
3876
|
-
if (active?.owner !== this) return;
|
|
3877
|
-
try {
|
|
3878
|
-
await closeViteDevServerBounded(active.server);
|
|
3879
|
-
} finally {
|
|
3880
|
-
active.disposeTeardown();
|
|
3881
|
-
if (getGlobalState().__gurenActiveViteDevServer === active) setActiveViteDevServer();
|
|
3882
|
-
}
|
|
3883
|
-
}
|
|
3884
|
-
/**
|
|
3885
|
-
* Attaches this application's Vite teardown handlers and returns the disposer.
|
|
3886
|
-
* It is stored in the active-record slot, not on this instance, because
|
|
3887
|
-
* whoever takes ownership next is the one that has to call it.
|
|
3888
|
-
*/
|
|
3889
|
-
registerViteTeardown() {
|
|
3890
|
-
if (typeof process === "undefined") return () => {};
|
|
3891
|
-
return registerProcessTeardown(() => {
|
|
3892
|
-
this.closeViteDevServer().then(() => process.exit(0)).catch(() => process.exit(1));
|
|
3893
|
-
}, () => {
|
|
3894
|
-
const active = getGlobalState().__gurenActiveViteDevServer;
|
|
3895
|
-
if (active?.owner === this) active.server.close();
|
|
3896
|
-
});
|
|
3897
|
-
}
|
|
3898
3735
|
registerBunTeardown() {
|
|
3899
3736
|
if (this.disposeBunTeardown || typeof process === "undefined") return;
|
|
3900
|
-
this.disposeBunTeardown =
|
|
3901
|
-
stopActiveBunServer().then(() => process.exit(0)).catch(() => process.exit(1));
|
|
3902
|
-
}, () => {
|
|
3903
|
-
stopActiveBunServer();
|
|
3904
|
-
});
|
|
3737
|
+
this.disposeBunTeardown = registerBunTeardown();
|
|
3905
3738
|
}
|
|
3906
3739
|
};
|
|
3907
3740
|
function createApp(options = {}) {
|
|
@@ -7468,51 +7301,71 @@ function renderDebugPage(error, request) {
|
|
|
7468
7301
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7469
7302
|
<title>${escapeHtml(errorName)}: ${errorMessage}</title>
|
|
7470
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
|
+
}
|
|
7471
7323
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
7472
|
-
body { font-family: -
|
|
7473
|
-
code, .mono { font-family:
|
|
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); }
|
|
7474
7326
|
.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
|
|
7475
7327
|
|
|
7476
|
-
.error-header { display: flex; align-items: flex-start; gap: 1.5rem; margin-bottom: 2rem; padding: 2rem; background:
|
|
7477
|
-
.status-badge { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; background:
|
|
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; }
|
|
7478
7330
|
.error-info { min-width: 0; }
|
|
7479
|
-
.error-class { font-size: 1.5rem; font-weight: 700; color:
|
|
7480
|
-
.error-message { font-size: 1.1rem; color:
|
|
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; }
|
|
7481
7333
|
|
|
7482
|
-
.section { margin-bottom: 1rem; background:
|
|
7483
|
-
.section-toggle { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 1rem 1.25rem; background: none; border: none; cursor: pointer; color:
|
|
7484
|
-
.section-toggle:hover { background:
|
|
7485
|
-
.section-toggle
|
|
7486
|
-
.toggle
|
|
7487
|
-
.
|
|
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; }
|
|
7488
7341
|
.section-content { padding: 0 1.25rem 1.25rem; }
|
|
7489
7342
|
|
|
7490
7343
|
.stack-frames { display: flex; flex-direction: column; gap: 2px; }
|
|
7491
|
-
.frame { padding: 0.6rem 0.75rem; border-radius:
|
|
7492
|
-
.frame:hover { background:
|
|
7493
|
-
.frame.vendor { opacity: 0.
|
|
7494
|
-
.frame.vendor:hover { opacity: 0.
|
|
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; }
|
|
7495
7348
|
.frame-header { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
|
|
7496
|
-
.frame-index { color:
|
|
7497
|
-
.frame-method { color:
|
|
7498
|
-
.frame-location { color:
|
|
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; }
|
|
7499
7352
|
|
|
7500
7353
|
.request-summary { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
|
|
7501
|
-
.method-badge { display: inline-block; padding:
|
|
7502
|
-
.request-url { font-family:
|
|
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; }
|
|
7503
7356
|
|
|
7504
7357
|
.subsection { margin-top: 1rem; }
|
|
7505
|
-
.subsection h3 { font
|
|
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; }
|
|
7506
7359
|
|
|
7507
7360
|
.details-table { width: 100%; border-collapse: collapse; }
|
|
7508
|
-
.details-table tr { border-bottom: 1px solid
|
|
7361
|
+
.details-table tr { border-bottom: 1px solid var(--g-line); }
|
|
7509
7362
|
.details-table tr:last-child { border-bottom: none; }
|
|
7510
7363
|
.details-table td { padding: 0.4rem 0; font-size: 0.85rem; vertical-align: top; }
|
|
7511
|
-
.details-table td.key { color:
|
|
7512
|
-
.details-table td.value { color:
|
|
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; }
|
|
7513
7366
|
|
|
7514
|
-
.muted { color:
|
|
7515
|
-
.footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid
|
|
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; }
|
|
7516
7369
|
</style>
|
|
7517
7370
|
</head>
|
|
7518
7371
|
<body>
|