@mandujs/core 0.5.0 → 0.5.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/package.json +1 -1
- package/src/runtime/server.ts +9 -3
package/package.json
CHANGED
package/src/runtime/server.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Server } from "bun";
|
|
2
2
|
import type { RoutesManifest } from "../spec/schema";
|
|
3
|
+
import type { BundleManifest } from "../bundler/types";
|
|
3
4
|
import { Router } from "./router";
|
|
4
5
|
import { renderSSR } from "./ssr";
|
|
5
6
|
import React from "react";
|
|
@@ -18,6 +19,8 @@ export interface ServerOptions {
|
|
|
18
19
|
isDev?: boolean;
|
|
19
20
|
/** HMR 포트 (개발 모드에서 사용) */
|
|
20
21
|
hmrPort?: number;
|
|
22
|
+
/** 번들 매니페스트 (Island hydration용) */
|
|
23
|
+
bundleManifest?: BundleManifest;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export interface ManduServer {
|
|
@@ -45,7 +48,7 @@ const routeComponents: Map<string, RouteComponent> = new Map();
|
|
|
45
48
|
let createAppFn: CreateAppFn | null = null;
|
|
46
49
|
|
|
47
50
|
// Dev mode settings (module-level for handleRequest access)
|
|
48
|
-
let devModeSettings: { isDev: boolean; hmrPort?: number } = { isDev: false };
|
|
51
|
+
let devModeSettings: { isDev: boolean; hmrPort?: number; bundleManifest?: BundleManifest } = { isDev: false };
|
|
49
52
|
|
|
50
53
|
export function registerApiHandler(routeId: string, handler: ApiHandler): void {
|
|
51
54
|
apiHandlers.set(routeId, handler);
|
|
@@ -137,6 +140,9 @@ async function handleRequest(req: Request, router: Router): Promise<Response> {
|
|
|
137
140
|
title: `${route.id} - Mandu`,
|
|
138
141
|
isDev: devModeSettings.isDev,
|
|
139
142
|
hmrPort: devModeSettings.hmrPort,
|
|
143
|
+
routeId: route.id,
|
|
144
|
+
hydration: route.hydration,
|
|
145
|
+
bundleManifest: devModeSettings.bundleManifest,
|
|
140
146
|
});
|
|
141
147
|
} catch (err) {
|
|
142
148
|
const ssrError = createSSRErrorResponse(
|
|
@@ -170,10 +176,10 @@ async function handleRequest(req: Request, router: Router): Promise<Response> {
|
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
export function startServer(manifest: RoutesManifest, options: ServerOptions = {}): ManduServer {
|
|
173
|
-
const { port = 3000, hostname = "localhost", isDev = false, hmrPort } = options;
|
|
179
|
+
const { port = 3000, hostname = "localhost", isDev = false, hmrPort, bundleManifest } = options;
|
|
174
180
|
|
|
175
181
|
// Dev mode settings 저장
|
|
176
|
-
devModeSettings = { isDev, hmrPort };
|
|
182
|
+
devModeSettings = { isDev, hmrPort, bundleManifest };
|
|
177
183
|
|
|
178
184
|
const router = new Router(manifest.routes);
|
|
179
185
|
|