@mandujs/core 0.53.0 → 0.53.2
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/package.json +38 -2
- package/src/a11y/run-audit.ts +6 -6
- package/src/brain/adapters/oauth-flow.ts +1 -1
- package/src/brain/architecture/analyzer.ts +0 -2
- package/src/brain/credentials.ts +2 -2
- package/src/bundler/__tests__/build-runner.ts +13 -1
- package/src/bundler/__tests__/extended-watch.test.ts +3 -2
- package/src/bundler/__tests__/fast-refresh.test.ts +10 -12
- package/src/bundler/build.test.ts +30 -33
- package/src/bundler/build.ts +56 -27
- package/src/bundler/dev.ts +44 -39
- package/src/bundler/prerender.ts +63 -0
- package/src/bundler/safe-build.test.ts +2 -1
- package/src/bundler/types.ts +13 -6
- package/src/change/history.ts +1 -1
- package/src/change/snapshot.ts +18 -9
- package/src/client/Link.tsx +9 -9
- package/src/client/globals.ts +3 -2
- package/src/client/hooks.ts +0 -4
- package/src/client/hydrate.ts +1 -1
- package/src/client/router.ts +12 -12
- package/src/client/rpc.ts +1 -1
- package/src/client/use-fetch.ts +6 -6
- package/src/client/use-sse.ts +5 -5
- package/src/config/mcp-status.ts +0 -1
- package/src/config/validate.ts +4 -4
- package/src/config/watcher.ts +1 -1
- package/src/content/collection.ts +8 -12
- package/src/content/content-layer.ts +5 -5
- package/src/content/data-store.ts +2 -2
- package/src/content/loader-context.ts +0 -1
- package/src/content/loaders/file.ts +1 -1
- package/src/content/loaders/glob.ts +4 -4
- package/src/content/loaders/types.ts +1 -1
- package/src/content/meta-store.ts +1 -1
- package/src/content/types.ts +1 -1
- package/src/contract/define.ts +11 -12
- package/src/contract/index.ts +3 -3
- package/src/contract/protection.ts +2 -2
- package/src/contract/types.ts +1 -1
- package/src/contract/validator.ts +0 -1
- package/src/db/__tests__/db.test.ts +4 -7
- package/src/db/index.ts +138 -51
- package/src/db/migrations/index.ts +3 -0
- package/src/db/migrations/lock.ts +78 -23
- package/src/db/migrations/runner.ts +118 -101
- package/src/deploy/cache.ts +1 -0
- package/src/design/extract.ts +2 -1
- package/src/design/patch.ts +0 -1
- package/src/devtools/ai/mcp-connector.ts +24 -24
- package/src/devtools/client/components/kitchen-root.tsx +1 -1
- package/src/devtools/client/components/panel/errors-panel.tsx +1 -1
- package/src/devtools/client/state-manager.ts +1 -1
- package/src/devtools/init.ts +2 -3
- package/src/devtools/server/source-context.ts +1 -1
- package/src/devtools/worker/redaction-worker.ts +8 -4
- package/src/devtools/worker/worker-manager.ts +4 -3
- package/src/error/classifier.ts +1 -1
- package/src/error/domains.ts +1 -1
- package/src/filling/sse.ts +5 -5
- package/src/generator/generate.ts +2 -2
- package/src/guard/analyzer.ts +1 -1
- package/src/guard/ast-analyzer.ts +7 -7
- package/src/guard/auto-correct.ts +2 -2
- package/src/guard/config-guard.ts +0 -2
- package/src/guard/contract-guard.ts +1 -1
- package/src/guard/decision-memory.ts +2 -2
- package/src/guard/design-inline-class.ts +2 -1
- package/src/guard/graph.ts +1 -1
- package/src/guard/healing.ts +36 -41
- package/src/guard/negotiation.ts +3 -3
- package/src/guard/reporter.ts +1 -4
- package/src/guard/semantic-slots.ts +2 -2
- package/src/guard/suggestions.ts +2 -2
- package/src/guard/watcher.ts +5 -4
- package/src/index.ts +5 -5
- package/src/intent/index.ts +1 -1
- package/src/kitchen/api/agent-devtools-api.ts +544 -0
- package/src/kitchen/api/contract-api.ts +1 -1
- package/src/kitchen/api/file-api.ts +3 -3
- package/src/kitchen/kitchen-handler.ts +63 -38
- package/src/kitchen/kitchen-ui.ts +346 -62
- package/src/lockfile/validate.ts +0 -1
- package/src/openapi/generator.ts +2 -1
- package/src/openapi/openapi.test.ts +43 -14
- package/src/perf/user-marks.ts +1 -1
- package/src/plugins/registry.ts +1 -2
- package/src/plugins/types.ts +1 -1
- package/src/resource/__tests__/generator.test.ts +32 -15
- package/src/resource/ddl/__tests__/emit.test.ts +24 -0
- package/src/resource/ddl/diff.ts +0 -1
- package/src/resource/ddl/emit.ts +12 -1
- package/src/resource/generator-repo.ts +40 -20
- package/src/resource/generator.ts +1 -1
- package/src/resource/generators/contract.ts +1 -1
- package/src/resource/schema.ts +2 -1
- package/src/router/fs-routes.ts +6 -6
- package/src/router/fs-scanner.ts +1 -1
- package/src/runtime/env.ts +1 -1
- package/src/runtime/image-handler.ts +2 -1
- package/src/runtime/middleware.ts +2 -1
- package/src/runtime/server.ts +67 -60
- package/src/runtime/ssr.ts +3 -3
- package/src/runtime/streaming-ssr.ts +25 -27
- package/src/scheduler/validate.ts +1 -1
- package/src/seo/integration/ssr.ts +2 -3
- package/src/seo/render/opengraph.ts +1 -1
- package/src/seo/resolve/index.ts +0 -4
- package/src/slot/corrector.ts +1 -1
- package/src/slot/validator.ts +4 -4
- package/src/watcher/reporter.ts +1 -1
- package/src/watcher/watcher.ts +19 -19
package/src/runtime/server.ts
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import type { Server, ServerWebSocket } from "bun";
|
|
1
|
+
import type { BunFile, Server, ServerWebSocket } from "bun";
|
|
2
2
|
import type { RoutesManifest, RouteSpec, HydrationConfig, StaticParamSetSchema } from "../spec/schema";
|
|
3
3
|
import type { BundleManifest } from "../bundler/types";
|
|
4
4
|
import type { ManduFilling, RenderMode } from "../filling/filling";
|
|
5
5
|
import { ManduContext, CookieManager } from "../filling/context";
|
|
6
6
|
import { Router } from "./router";
|
|
7
7
|
import { renderSSR, renderStreamingResponse, resolveAsyncElement } from "./ssr";
|
|
8
|
-
import {
|
|
9
|
-
resolveMetadata,
|
|
10
|
-
renderMetadata,
|
|
11
|
-
renderTitle,
|
|
12
|
-
type Metadata,
|
|
8
|
+
import {
|
|
9
|
+
resolveMetadata,
|
|
10
|
+
renderMetadata,
|
|
11
|
+
renderTitle,
|
|
12
|
+
type Metadata,
|
|
13
13
|
type MetadataItem,
|
|
14
|
-
type GenerateMetadata,
|
|
15
|
-
} from "../seo";
|
|
16
|
-
import { type ErrorFallbackProps } from "./boundary";
|
|
17
|
-
import React
|
|
14
|
+
type GenerateMetadata,
|
|
15
|
+
} from "../seo";
|
|
16
|
+
import { type ErrorFallbackProps } from "./boundary";
|
|
17
|
+
import React from "react";
|
|
18
18
|
import path from "path";
|
|
19
19
|
import fs from "fs/promises";
|
|
20
20
|
import { PORTS } from "../constants";
|
|
21
21
|
import {
|
|
22
|
-
type CacheStore,
|
|
23
|
-
type CacheStoreStats,
|
|
24
|
-
type
|
|
25
|
-
|
|
26
|
-
MemoryCacheStore,
|
|
27
|
-
lookupCache,
|
|
22
|
+
type CacheStore,
|
|
23
|
+
type CacheStoreStats,
|
|
24
|
+
type CacheConfig,
|
|
25
|
+
lookupCache,
|
|
28
26
|
createCacheEntry,
|
|
29
27
|
createCachedResponse,
|
|
30
28
|
computeCacheControl,
|
|
@@ -53,7 +51,12 @@ import {
|
|
|
53
51
|
} from "./cors";
|
|
54
52
|
import { validateImportPath } from "./security";
|
|
55
53
|
import { KITCHEN_PREFIX, KitchenHandler, recordRequest } from "../kitchen/kitchen-handler";
|
|
56
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
eventBus,
|
|
56
|
+
type EventType,
|
|
57
|
+
type ObservabilityEvent,
|
|
58
|
+
type ObservabilitySeverity,
|
|
59
|
+
} from "../observability/event-bus";
|
|
57
60
|
import {
|
|
58
61
|
HEAP_ENDPOINT,
|
|
59
62
|
METRICS_ENDPOINT,
|
|
@@ -62,11 +65,12 @@ import {
|
|
|
62
65
|
isObservabilityExposed,
|
|
63
66
|
recordHttpRequest,
|
|
64
67
|
} from "../observability/metrics";
|
|
65
|
-
import {
|
|
66
|
-
handleOpenAPIRequest,
|
|
67
|
-
isOpenAPIEndpointEnabled,
|
|
68
|
-
resolveOpenAPIEndpointSettings,
|
|
69
|
-
|
|
68
|
+
import {
|
|
69
|
+
handleOpenAPIRequest,
|
|
70
|
+
isOpenAPIEndpointEnabled,
|
|
71
|
+
resolveOpenAPIEndpointSettings,
|
|
72
|
+
type OpenAPIEndpointSettings,
|
|
73
|
+
} from "./openapi-endpoint";
|
|
70
74
|
// Phase 18.ψ — user-facing perf marks dashboard append. We include a
|
|
71
75
|
// `perf` block on the `/_mandu/heap` payload when the feature is active
|
|
72
76
|
// so operators see a unified view (heap + caches + perf histogram).
|
|
@@ -77,8 +81,7 @@ import { collectPerfSnapshot } from "../perf/user-marks";
|
|
|
77
81
|
// `startServer()`; `runWithSpan` is used at the absolute TOP of the
|
|
78
82
|
// request handler so every downstream await (middleware, filling
|
|
79
83
|
// loader, SSR render) inherits the active span via AsyncLocalStorage.
|
|
80
|
-
import type {
|
|
81
|
-
Tracer} from "../observability/tracing";
|
|
84
|
+
import type { Tracer } from "../observability/tracing";
|
|
82
85
|
import {
|
|
83
86
|
createTracerFromConfig,
|
|
84
87
|
runWithSpan,
|
|
@@ -99,10 +102,10 @@ import type { Middleware } from "../middleware/define";
|
|
|
99
102
|
// Phase 18.λ — scheduler wiring (statically imported so `startServer` stays
|
|
100
103
|
// synchronous; the cost of unused code is trivial — `defineCron` is a thin
|
|
101
104
|
// wrapper around `Bun.cron`).
|
|
102
|
-
import { defineCron as schedulerDefineCron } from "../scheduler";
|
|
105
|
+
import { defineCron as schedulerDefineCron, type CronDef, type CronRegistration } from "../scheduler";
|
|
103
106
|
import { setActiveSchedulerRegistration } from "../middleware/scheduler-cron";
|
|
104
107
|
import { createFetchHandler } from "./handler";
|
|
105
|
-
import { wrapBunWebSocket, type WSUpgradeData } from "../filling/ws";
|
|
108
|
+
import { wrapBunWebSocket, type WSHandlers, type WSUpgradeData } from "../filling/ws";
|
|
106
109
|
import { handleImageRequest } from "./image-handler";
|
|
107
110
|
import { extractShellHtml, createPPRResponse } from "./ppr";
|
|
108
111
|
import { isRedirectResponse } from "./redirect";
|
|
@@ -110,12 +113,16 @@ import { isNotFoundResponse } from "./not-found";
|
|
|
110
113
|
import { newId } from "../id";
|
|
111
114
|
// Phase 18.κ — typed RPC dispatch (tRPC-like). See
|
|
112
115
|
// `packages/core/src/contract/rpc.ts` + `docs/architect/typed-rpc.md`.
|
|
113
|
-
import {
|
|
114
|
-
matchRpcPath,
|
|
115
|
-
dispatchRpc,
|
|
116
|
-
registerRpc,
|
|
117
|
-
clearRpcRegistry,
|
|
118
|
-
|
|
116
|
+
import {
|
|
117
|
+
matchRpcPath,
|
|
118
|
+
dispatchRpc,
|
|
119
|
+
registerRpc,
|
|
120
|
+
clearRpcRegistry,
|
|
121
|
+
type RpcDefinition,
|
|
122
|
+
type RpcProcedureRecord,
|
|
123
|
+
} from "../contract/rpc";
|
|
124
|
+
import type { GuardConfig } from "../guard/types";
|
|
125
|
+
import type { ManduHooks, ManduPlugin } from "../plugins/hooks";
|
|
119
126
|
import { handleMetadataRoute as dispatchMetadataRoute } from "../routes/metadata-routes";
|
|
120
127
|
import {
|
|
121
128
|
DEFAULT_PRERENDER_DIR,
|
|
@@ -419,7 +426,7 @@ export interface ServerOptions {
|
|
|
419
426
|
/**
|
|
420
427
|
* Guard config for Kitchen dev dashboard (dev mode only)
|
|
421
428
|
*/
|
|
422
|
-
guardConfig?:
|
|
429
|
+
guardConfig?: GuardConfig | null;
|
|
423
430
|
/**
|
|
424
431
|
* SSR 캐시 설정 (ISR/SWR 용).
|
|
425
432
|
*
|
|
@@ -575,8 +582,8 @@ export interface ServerOptions {
|
|
|
575
582
|
* `options.middleware` so they run BEFORE user-declared layers. Both
|
|
576
583
|
* fields are optional; omission is a zero-overhead passthrough.
|
|
577
584
|
*/
|
|
578
|
-
plugins?: readonly
|
|
579
|
-
configHooks?: Partial<
|
|
585
|
+
plugins?: readonly ManduPlugin[];
|
|
586
|
+
configHooks?: Partial<ManduHooks>;
|
|
580
587
|
/**
|
|
581
588
|
* Phase 18.κ — tRPC-like typed RPC endpoints.
|
|
582
589
|
*
|
|
@@ -589,7 +596,7 @@ export interface ServerOptions {
|
|
|
589
596
|
* Typically threaded from `ManduConfig.rpc.endpoints`.
|
|
590
597
|
*/
|
|
591
598
|
rpc?: {
|
|
592
|
-
endpoints?: Record<string,
|
|
599
|
+
endpoints?: Record<string, RpcDefinition<RpcProcedureRecord>>;
|
|
593
600
|
};
|
|
594
601
|
/**
|
|
595
602
|
* Phase 18.λ — declarative cron scheduler.
|
|
@@ -605,7 +612,7 @@ export interface ServerOptions {
|
|
|
605
612
|
* Typically threaded from `ManduConfig.scheduler`.
|
|
606
613
|
*/
|
|
607
614
|
scheduler?: {
|
|
608
|
-
jobs?:
|
|
615
|
+
jobs?: CronDef[];
|
|
609
616
|
disabled?: boolean;
|
|
610
617
|
};
|
|
611
618
|
/**
|
|
@@ -816,7 +823,7 @@ export interface ServerRegistrySettings {
|
|
|
816
823
|
* tracing is disabled (the hot path is branch-free). When set, every
|
|
817
824
|
* request opens a root span via `tracer.startSpanFromRequest()`.
|
|
818
825
|
*/
|
|
819
|
-
tracer?:
|
|
826
|
+
tracer?: Tracer;
|
|
820
827
|
/**
|
|
821
828
|
* Production OpenAPI endpoint — resolved from `ServerOptions.openapi`.
|
|
822
829
|
* `undefined` means the endpoint is disabled (hot path branch-free).
|
|
@@ -824,7 +831,7 @@ export interface ServerRegistrySettings {
|
|
|
824
831
|
* `<basePath>.json` / `<basePath>.yaml` short-circuits before route
|
|
825
832
|
* dispatch to serve the cached spec body.
|
|
826
833
|
*/
|
|
827
|
-
openapi?:
|
|
834
|
+
openapi?: OpenAPIEndpointSettings;
|
|
828
835
|
/**
|
|
829
836
|
* Phase 18 — resolved prerender pass-through state. `undefined`
|
|
830
837
|
* means the feature is disabled for this server instance.
|
|
@@ -910,7 +917,7 @@ export class ServerRegistry {
|
|
|
910
917
|
/** Layout slot 파일 경로 캐시 (모듈 경로 → slot 경로 | null) */
|
|
911
918
|
readonly layoutSlotPaths: Map<string, string | null> = new Map();
|
|
912
919
|
/** WebSocket 핸들러 (라우트 ID → WSHandlers) */
|
|
913
|
-
readonly wsHandlers: Map<string,
|
|
920
|
+
readonly wsHandlers: Map<string, WSHandlers> = new Map();
|
|
914
921
|
/**
|
|
915
922
|
* Metadata API 캐시 (#186)
|
|
916
923
|
* - pageMetadata: routeId → page 모듈의 static `metadata` export
|
|
@@ -918,10 +925,10 @@ export class ServerRegistry {
|
|
|
918
925
|
* - layoutMetadata: layout 모듈 경로 → static `metadata` export (null = 시도했지만 없음)
|
|
919
926
|
* - layoutGenerateMetadata: layout 모듈 경로 → `generateMetadata` 함수
|
|
920
927
|
*/
|
|
921
|
-
readonly pageMetadata: Map<string,
|
|
922
|
-
readonly pageGenerateMetadata: Map<string,
|
|
923
|
-
readonly layoutMetadata: Map<string,
|
|
924
|
-
readonly layoutGenerateMetadata: Map<string,
|
|
928
|
+
readonly pageMetadata: Map<string, Metadata> = new Map();
|
|
929
|
+
readonly pageGenerateMetadata: Map<string, GenerateMetadata> = new Map();
|
|
930
|
+
readonly layoutMetadata: Map<string, Metadata | null> = new Map();
|
|
931
|
+
readonly layoutGenerateMetadata: Map<string, GenerateMetadata> = new Map();
|
|
925
932
|
settings: ServerRegistrySettings = {
|
|
926
933
|
isDev: false,
|
|
927
934
|
rootDir: process.cwd(),
|
|
@@ -1270,7 +1277,7 @@ export function registerNotFoundHandler(handler: PageHandler): void {
|
|
|
1270
1277
|
defaultRegistry.registerNotFoundHandler(handler);
|
|
1271
1278
|
}
|
|
1272
1279
|
|
|
1273
|
-
export function registerWSHandler(routeId: string, handlers:
|
|
1280
|
+
export function registerWSHandler(routeId: string, handlers: WSHandlers): void {
|
|
1274
1281
|
defaultRegistry.wsHandlers.set(routeId, handlers);
|
|
1275
1282
|
}
|
|
1276
1283
|
|
|
@@ -1356,7 +1363,7 @@ function handleEventsStreamRequest(req: Request): Response {
|
|
|
1356
1363
|
const filterSource = url.searchParams.get("source") || undefined;
|
|
1357
1364
|
const filterTrace = url.searchParams.get("trace") || undefined;
|
|
1358
1365
|
|
|
1359
|
-
const matches = (e:
|
|
1366
|
+
const matches = (e: ObservabilityEvent): boolean => {
|
|
1360
1367
|
if (filterType && e.type !== filterType) return false;
|
|
1361
1368
|
if (filterSeverity && e.severity !== filterSeverity) return false;
|
|
1362
1369
|
if (filterSource && e.source !== filterSource) return false;
|
|
@@ -1437,8 +1444,8 @@ function handleEventsRecentRequest(req: Request): Response {
|
|
|
1437
1444
|
const events = eventBus.getRecent(
|
|
1438
1445
|
count ? Number(count) : undefined,
|
|
1439
1446
|
{
|
|
1440
|
-
type: type as
|
|
1441
|
-
severity: severity as
|
|
1447
|
+
type: type as EventType | undefined,
|
|
1448
|
+
severity: severity as ObservabilitySeverity | undefined,
|
|
1442
1449
|
},
|
|
1443
1450
|
);
|
|
1444
1451
|
const stats = eventBus.getStats(windowMs);
|
|
@@ -1544,7 +1551,7 @@ function evictEtagCacheIfNeeded(): void {
|
|
|
1544
1551
|
*/
|
|
1545
1552
|
async function computeStrongEtag(
|
|
1546
1553
|
filePath: string,
|
|
1547
|
-
file:
|
|
1554
|
+
file: BunFile,
|
|
1548
1555
|
): Promise<string> {
|
|
1549
1556
|
const size = file.size;
|
|
1550
1557
|
const mtime = file.lastModified;
|
|
@@ -4675,12 +4682,12 @@ export function startServer(manifest: RoutesManifest, options: ServerOptions = {
|
|
|
4675
4682
|
}
|
|
4676
4683
|
// ─── End Phase 18.ζ ────────────────────────────────────────────────────
|
|
4677
4684
|
|
|
4678
|
-
// Kitchen dev dashboard (dev mode only)
|
|
4679
|
-
if (isDev) {
|
|
4680
|
-
const kitchen = new KitchenHandler({ rootDir, manifest, guardConfig });
|
|
4681
|
-
kitchen.start();
|
|
4682
|
-
registry.kitchen = kitchen;
|
|
4683
|
-
}
|
|
4685
|
+
// Kitchen dev dashboard (dev mode only)
|
|
4686
|
+
if (isDev) {
|
|
4687
|
+
const kitchen = new KitchenHandler({ rootDir, manifest, guardConfig });
|
|
4688
|
+
void kitchen.start();
|
|
4689
|
+
registry.kitchen = kitchen;
|
|
4690
|
+
}
|
|
4684
4691
|
|
|
4685
4692
|
const router = new Router(manifest.routes);
|
|
4686
4693
|
|
|
@@ -4862,7 +4869,7 @@ export function startServer(manifest: RoutesManifest, options: ServerOptions = {
|
|
|
4862
4869
|
// other boot errors rather than aborting the server. `startServer` is
|
|
4863
4870
|
// synchronous by contract, so we use the already-imported scheduler
|
|
4864
4871
|
// module rather than `await import`.
|
|
4865
|
-
let schedulerRegistration:
|
|
4872
|
+
let schedulerRegistration: CronRegistration | null = null;
|
|
4866
4873
|
const jobDefs = schedulerOption?.jobs ?? [];
|
|
4867
4874
|
const schedulerDisabled = schedulerOption?.disabled === true;
|
|
4868
4875
|
if (jobDefs.length > 0 && !schedulerDisabled) {
|
|
@@ -4914,10 +4921,10 @@ export function startServer(manifest: RoutesManifest, options: ServerOptions = {
|
|
|
4914
4921
|
console.error("[scheduler] shutdown error:", err);
|
|
4915
4922
|
});
|
|
4916
4923
|
}
|
|
4917
|
-
server.stop();
|
|
4918
|
-
},
|
|
4919
|
-
};
|
|
4920
|
-
}
|
|
4924
|
+
void server.stop();
|
|
4925
|
+
},
|
|
4926
|
+
};
|
|
4927
|
+
}
|
|
4921
4928
|
|
|
4922
4929
|
// Clear registries (useful for testing) - deprecated, use clearDefaultRegistry()
|
|
4923
4930
|
export function clearRegistry(): void {
|
package/src/runtime/ssr.ts
CHANGED
|
@@ -165,7 +165,7 @@ export interface SSROptions {
|
|
|
165
165
|
|
|
166
166
|
let projectRenderToString: ((element: ReactElement) => string) | null | undefined;
|
|
167
167
|
|
|
168
|
-
function
|
|
168
|
+
function _loadProjectRenderToString(): ((element: ReactElement) => string) | null {
|
|
169
169
|
if (projectRenderToString !== undefined) {
|
|
170
170
|
return projectRenderToString;
|
|
171
171
|
}
|
|
@@ -851,7 +851,7 @@ export function renderToHTML(element: ReactElement, options: SSROptions = {}): s
|
|
|
851
851
|
function generateRouteScript(
|
|
852
852
|
routeId: string,
|
|
853
853
|
pattern: string,
|
|
854
|
-
|
|
854
|
+
_serverData?: Record<string, unknown>
|
|
855
855
|
): string {
|
|
856
856
|
const routeInfo = {
|
|
857
857
|
id: routeId,
|
|
@@ -867,7 +867,7 @@ function generateRouteScript(
|
|
|
867
867
|
/**
|
|
868
868
|
* URL 패턴에서 파라미터 추출 (클라이언트에서 사용)
|
|
869
869
|
*/
|
|
870
|
-
function extractParamsFromUrl(
|
|
870
|
+
function extractParamsFromUrl(_pattern: string): Record<string, string> {
|
|
871
871
|
// 서버에서는 실제 params를 전달받으므로 빈 객체 반환
|
|
872
872
|
// 실제 params는 serverData나 별도 전달
|
|
873
873
|
return {};
|
|
@@ -80,10 +80,10 @@ export interface StreamingError {
|
|
|
80
80
|
export interface StreamingMetrics {
|
|
81
81
|
/** Shell ready까지 걸린 시간 (ms) */
|
|
82
82
|
shellReadyTime: number;
|
|
83
|
-
/** All ready까지 걸린 시간 (ms) */
|
|
84
|
-
allReadyTime: number;
|
|
85
|
-
/** Deferred chunk 개수 */
|
|
86
|
-
deferredChunkCount: number;
|
|
83
|
+
/** All ready까지 걸린 시간 (ms) */
|
|
84
|
+
allReadyTime: number;
|
|
85
|
+
/** Deferred chunk 개수 */
|
|
86
|
+
deferredChunkCount: number;
|
|
87
87
|
/** 에러 발생 여부 */
|
|
88
88
|
hasError: boolean;
|
|
89
89
|
/** 시작 시간 */
|
|
@@ -1001,9 +1001,9 @@ export async function renderToStream(
|
|
|
1001
1001
|
|
|
1002
1002
|
// 메트릭 수집
|
|
1003
1003
|
const metrics: StreamingMetrics = {
|
|
1004
|
-
shellReadyTime: 0,
|
|
1005
|
-
allReadyTime: 0,
|
|
1006
|
-
deferredChunkCount: 0,
|
|
1004
|
+
shellReadyTime: 0,
|
|
1005
|
+
allReadyTime: 0,
|
|
1006
|
+
deferredChunkCount: 0,
|
|
1007
1007
|
hasError: false,
|
|
1008
1008
|
startTime: Date.now(),
|
|
1009
1009
|
};
|
|
@@ -1379,10 +1379,9 @@ export async function renderWithDeferredData(
|
|
|
1379
1379
|
const encoder = new TextEncoder();
|
|
1380
1380
|
const startTime = Date.now();
|
|
1381
1381
|
|
|
1382
|
-
// 준비된 deferred 스크립트를 담을 배열 (mutable)
|
|
1383
|
-
const readyScripts: string[] = [];
|
|
1384
|
-
let
|
|
1385
|
-
let allDeferredSettled = false;
|
|
1382
|
+
// 준비된 deferred 스크립트를 담을 배열 (mutable)
|
|
1383
|
+
const readyScripts: string[] = [];
|
|
1384
|
+
let allDeferredSettled = false;
|
|
1386
1385
|
|
|
1387
1386
|
// 1. Deferred promises 병렬 시작 (막지 않음!)
|
|
1388
1387
|
const deferredEntries = Object.entries(deferredPromises);
|
|
@@ -1396,12 +1395,11 @@ export async function renderWithDeferredData(
|
|
|
1396
1395
|
);
|
|
1397
1396
|
const data = await Promise.race([promise, timeoutPromise]);
|
|
1398
1397
|
|
|
1399
|
-
// 스크립트 생성 및 추가
|
|
1400
|
-
const script = generateDeferredDataScript(routeId, key, data);
|
|
1401
|
-
readyScripts.push(script);
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
if (isDev) {
|
|
1398
|
+
// 스크립트 생성 및 추가
|
|
1399
|
+
const script = generateDeferredDataScript(routeId, key, data);
|
|
1400
|
+
readyScripts.push(script);
|
|
1401
|
+
|
|
1402
|
+
if (isDev) {
|
|
1405
1403
|
console.log(`[Mandu Streaming] Deferred ready: ${key} (${Date.now() - startTime}ms)`);
|
|
1406
1404
|
}
|
|
1407
1405
|
} catch (error) {
|
|
@@ -1475,22 +1473,22 @@ export async function renderWithDeferredData(
|
|
|
1475
1473
|
|
|
1476
1474
|
// 최종 메트릭 보고 (injectedCount가 실제 메트릭)
|
|
1477
1475
|
if (onMetrics && baseMetrics) {
|
|
1478
|
-
onMetrics({
|
|
1479
|
-
...baseMetrics,
|
|
1480
|
-
deferredChunkCount: injectedCount,
|
|
1481
|
-
allReadyTime: Date.now() - startTime,
|
|
1482
|
-
});
|
|
1476
|
+
onMetrics({
|
|
1477
|
+
...baseMetrics,
|
|
1478
|
+
deferredChunkCount: injectedCount,
|
|
1479
|
+
allReadyTime: Date.now() - startTime,
|
|
1480
|
+
});
|
|
1483
1481
|
}
|
|
1484
1482
|
|
|
1485
1483
|
controller.close();
|
|
1486
1484
|
} catch (error) {
|
|
1487
1485
|
controller.error(error);
|
|
1488
1486
|
}
|
|
1489
|
-
},
|
|
1490
|
-
cancel() {
|
|
1491
|
-
reader.cancel();
|
|
1492
|
-
},
|
|
1493
|
-
});
|
|
1487
|
+
},
|
|
1488
|
+
cancel() {
|
|
1489
|
+
void reader.cancel();
|
|
1490
|
+
},
|
|
1491
|
+
});
|
|
1494
1492
|
|
|
1495
1493
|
// Phase 7.2 R1 Agent C (H1): if the base stream produced a CSP
|
|
1496
1494
|
// nonce during shell emission, forward the matching header on the
|
|
@@ -159,7 +159,7 @@ export function validateTimezone(tz: string): void {
|
|
|
159
159
|
}
|
|
160
160
|
try {
|
|
161
161
|
// `Intl.DateTimeFormat` throws `RangeError` for unknown zones.
|
|
162
|
-
|
|
162
|
+
Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
163
163
|
} catch {
|
|
164
164
|
throw new Error(
|
|
165
165
|
`[@mandujs/core/scheduler] unknown IANA timezone "${tz}". ` +
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import type { ReactElement } from 'react'
|
|
31
30
|
import type { Metadata, MetadataItem, ResolvedMetadata } from '../types'
|
|
32
31
|
import { resolveMetadata, createDefaultMetadata } from '../resolve'
|
|
33
32
|
import { renderMetadata } from '../render'
|
|
@@ -88,7 +87,7 @@ export async function resolveSEO(options: SEOOptions = {}): Promise<SEOResult> {
|
|
|
88
87
|
resolved = await resolveMetadata(metadata, routeParams, searchParams)
|
|
89
88
|
} else if (staticMetadata) {
|
|
90
89
|
// 단일 정적 메타데이터
|
|
91
|
-
const
|
|
90
|
+
const _base = createDefaultMetadata()
|
|
92
91
|
resolved = await resolveMetadata([staticMetadata], routeParams, searchParams)
|
|
93
92
|
} else {
|
|
94
93
|
// 기본 메타데이터
|
|
@@ -186,7 +185,7 @@ export async function injectSEOIntoOptions<T extends { title?: string; headTags?
|
|
|
186
185
|
options: T,
|
|
187
186
|
seoOptions: SEOOptions
|
|
188
187
|
): Promise<T & { title: string; headTags: string }> {
|
|
189
|
-
const { resolved, html, title } = await resolveSEO(seoOptions)
|
|
188
|
+
const { resolved: _resolved, html, title } = await resolveSEO(seoOptions)
|
|
190
189
|
|
|
191
190
|
// 기존 headTags와 병합
|
|
192
191
|
const existingHeadTags = options.headTags || ''
|
package/src/seo/resolve/index.ts
CHANGED
|
@@ -17,10 +17,6 @@ import type {
|
|
|
17
17
|
ResolvedVerification,
|
|
18
18
|
JsonLd,
|
|
19
19
|
ThemeColor,
|
|
20
|
-
ResourceHint,
|
|
21
|
-
FormatDetection,
|
|
22
|
-
GoogleMeta,
|
|
23
|
-
AppLinks,
|
|
24
20
|
} from '../types'
|
|
25
21
|
import { resolveTitle, extractTitleTemplate } from './title'
|
|
26
22
|
import { normalizeMetadataBase, resolveUrl } from './url'
|
package/src/slot/corrector.ts
CHANGED
|
@@ -111,7 +111,7 @@ function fixForbiddenImport(
|
|
|
111
111
|
|
|
112
112
|
// 어떤 금지된 모듈인지 찾기
|
|
113
113
|
let forbiddenModule = "";
|
|
114
|
-
for (const [module,
|
|
114
|
+
for (const [module, _alternative] of Object.entries(SAFE_ALTERNATIVES)) {
|
|
115
115
|
if (originalLine.includes(`'${module}'`) || originalLine.includes(`"${module}"`)) {
|
|
116
116
|
forbiddenModule = module;
|
|
117
117
|
break;
|
package/src/slot/validator.ts
CHANGED
|
@@ -125,14 +125,14 @@ function stripComments(content: string): string {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// 올바른 응답 패턴 (ctx 메서드 호출)
|
|
128
|
-
const
|
|
128
|
+
const _VALID_RESPONSE_PATTERNS = [
|
|
129
129
|
/return\s+ctx\s*\.\s*(ok|json|created|noContent|notFound|badRequest|error|html|redirect|stream)\s*\(/,
|
|
130
130
|
/return\s+new\s+Response\s*\(/,
|
|
131
131
|
/return\s+Response\s*\.\s*(json|redirect)\s*\(/,
|
|
132
132
|
];
|
|
133
133
|
|
|
134
134
|
// 잘못된 반환 패턴 (일반 객체 직접 반환)
|
|
135
|
-
const
|
|
135
|
+
const _INVALID_RETURN_PATTERNS = [
|
|
136
136
|
/return\s+\{\s*[^}]*\}\s*;?\s*$/m, // return { ... }; (Response가 아닌 객체)
|
|
137
137
|
];
|
|
138
138
|
|
|
@@ -337,7 +337,7 @@ function checkBasicSyntax(
|
|
|
337
337
|
/**
|
|
338
338
|
* HTTP 메서드 핸들러 검사
|
|
339
339
|
*/
|
|
340
|
-
function checkHttpMethods(content: string,
|
|
340
|
+
function checkHttpMethods(content: string, _lines: string[]): SlotValidationIssue[] {
|
|
341
341
|
const issues: SlotValidationIssue[] = [];
|
|
342
342
|
|
|
343
343
|
// .get(), .post() 등의 핸들러가 있는지 확인
|
|
@@ -404,7 +404,7 @@ function checkHandlerReturns(content: string, lines: string[]): SlotValidationIs
|
|
|
404
404
|
const isStringReturn = /return\s+['"`]/.test(returnStmt) && !isValidReturn;
|
|
405
405
|
|
|
406
406
|
// throw 문자열 감지 (Error 객체가 아닌 문자열)
|
|
407
|
-
const
|
|
407
|
+
const _throwStringPattern = /throw\s+['"`][^'"`]+['"`]/;
|
|
408
408
|
|
|
409
409
|
if (isObjectReturn) {
|
|
410
410
|
// return 문이 있는 라인 번호 찾기
|
package/src/watcher/reporter.ts
CHANGED
package/src/watcher/watcher.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
WatchWarning,
|
|
11
11
|
WatchEventHandler,
|
|
12
12
|
} from "../brain/types";
|
|
13
|
-
import { validateFile
|
|
13
|
+
import { validateFile } from "./rules";
|
|
14
14
|
import path from "path";
|
|
15
15
|
import fs from "fs";
|
|
16
16
|
import { spawn, type ChildProcess } from "child_process";
|
|
@@ -156,20 +156,20 @@ export class FileWatcher {
|
|
|
156
156
|
this._fileCount = count;
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
// Handle events (v5 passes absolute paths when watching absolute rootDir)
|
|
160
|
-
this.chokidarWatcher.on("change", (filePath) => {
|
|
161
|
-
this.processFileEvent("modify", filePath);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
this.chokidarWatcher.on("add", (filePath) => {
|
|
165
|
-
this._fileCount++;
|
|
166
|
-
this.processFileEvent("create", filePath);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
this.chokidarWatcher.on("unlink", (filePath) => {
|
|
170
|
-
this._fileCount = Math.max(0, this._fileCount - 1);
|
|
171
|
-
this.processFileEvent("delete", filePath);
|
|
172
|
-
});
|
|
159
|
+
// Handle events (v5 passes absolute paths when watching absolute rootDir)
|
|
160
|
+
this.chokidarWatcher.on("change", (filePath) => {
|
|
161
|
+
void this.processFileEvent("modify", filePath);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
this.chokidarWatcher.on("add", (filePath) => {
|
|
165
|
+
this._fileCount++;
|
|
166
|
+
void this.processFileEvent("create", filePath);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
this.chokidarWatcher.on("unlink", (filePath) => {
|
|
170
|
+
this._fileCount = Math.max(0, this._fileCount - 1);
|
|
171
|
+
void this.processFileEvent("delete", filePath);
|
|
172
|
+
});
|
|
173
173
|
|
|
174
174
|
this.chokidarWatcher.on("error", (error: unknown) => {
|
|
175
175
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -406,10 +406,10 @@ export function getWatcher(config?: WatcherConfig): FileWatcher | null {
|
|
|
406
406
|
/**
|
|
407
407
|
* Start the global watcher
|
|
408
408
|
*/
|
|
409
|
-
export async function startWatcher(config: WatcherConfig): Promise<FileWatcher> {
|
|
410
|
-
if (globalWatcher) {
|
|
411
|
-
globalWatcher.stop();
|
|
412
|
-
}
|
|
409
|
+
export async function startWatcher(config: WatcherConfig): Promise<FileWatcher> {
|
|
410
|
+
if (globalWatcher) {
|
|
411
|
+
await globalWatcher.stop();
|
|
412
|
+
}
|
|
413
413
|
|
|
414
414
|
globalWatcher = createWatcher(config);
|
|
415
415
|
await globalWatcher.start();
|