@moonsjs/vite 0.3.0 → 0.4.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/{index-0agjty3z.js → index-df6b8rqt.js} +364 -62
- package/dist/index-df6b8rqt.js.map +18 -0
- package/dist/index.js +4 -4
- package/dist/index.js.map +3 -3
- package/dist/server/bun-server.d.ts +18 -0
- package/dist/server/bun-server.d.ts.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +317 -275
- package/dist/server/index.js.map +6 -6
- package/dist/server/node-server.d.ts +2 -11
- package/dist/server/node-server.d.ts.map +1 -1
- package/dist/server/node.d.ts +3 -19
- package/dist/server/node.d.ts.map +1 -1
- package/dist/server/server-select.d.ts +9 -0
- package/dist/server/server-select.d.ts.map +1 -0
- package/dist/server/transport.d.ts +82 -0
- package/dist/server/transport.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/plugin.ts +2 -2
- package/src/server/bun-server.ts +385 -0
- package/src/server/index.ts +2 -0
- package/src/server/node-server.ts +31 -259
- package/src/server/node.ts +24 -92
- package/src/server/server-select.ts +27 -0
- package/src/server/transport.ts +414 -0
- package/dist/index-0agjty3z.js.map +0 -15
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { extname, join, resolve, sep } from "node:path";
|
|
3
|
+
import { gzipSync } from "node:zlib";
|
|
4
|
+
import { MoonsError, type PrerenderStorage } from "@moonsjs/core";
|
|
5
|
+
import { revalidatePrerendered, shouldRevalidate } from "./isr";
|
|
6
|
+
import type { Logger } from "./logger";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Addendum Q (3B): bagian transport yang tidak bergantung runtime — dipakai
|
|
10
|
+
* `node-server` dan `bun-server` agar paritas bukan duplikasi.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Batas transport default (Addendum J.2); RPC punya batas lebih kecil dari config. */
|
|
14
|
+
export const MAX_TRANSPORT_BODY_BYTES = 32 * 1024 * 1024;
|
|
15
|
+
|
|
16
|
+
/** Request tidak valid (Host/URL malformed) → dipetakan ke 400 oleh server. */
|
|
17
|
+
export class InvalidRequestError extends Error {
|
|
18
|
+
constructor(message: string) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "InvalidRequestError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Body melebihi batas → dipetakan ke 413; pembacaan dihentikan saat melewati. */
|
|
25
|
+
export class BodyLimitError extends Error {
|
|
26
|
+
readonly limit: number;
|
|
27
|
+
constructor(limit: number) {
|
|
28
|
+
super(`request body exceeds the ${limit} byte limit`);
|
|
29
|
+
this.name = "BodyLimitError";
|
|
30
|
+
this.limit = limit;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ToWebRequestOptions {
|
|
35
|
+
/** Addendum J.1: percayai `x-forwarded-proto`/`x-forwarded-host` (default false). */
|
|
36
|
+
trustProxy?: boolean;
|
|
37
|
+
/** Batas pembacaan body (byte). Default: `MAX_TRANSPORT_BODY_BYTES`. */
|
|
38
|
+
maxBodyBytes?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Addendum J.7: default aman runtime; `config.headers` tetap menang (cek `has`). */
|
|
42
|
+
export const DEFAULT_SECURITY_HEADERS: Record<string, string> = {
|
|
43
|
+
"x-content-type-options": "nosniff",
|
|
44
|
+
"referrer-policy": "strict-origin-when-cross-origin",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export function firstHeaderValue(value: string | string[] | undefined): string | null {
|
|
48
|
+
if (value === undefined) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const raw = Array.isArray(value) ? value[0] : value;
|
|
52
|
+
if (raw === undefined) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const first = raw.split(",")[0]?.trim() ?? "";
|
|
56
|
+
return first.length === 0 ? null : first;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function forwardedProtocol(
|
|
60
|
+
value: string | string[] | undefined,
|
|
61
|
+
): "http" | "https" | null {
|
|
62
|
+
const first = firstHeaderValue(value)?.toLowerCase() ?? null;
|
|
63
|
+
if (first === "https") {
|
|
64
|
+
return "https";
|
|
65
|
+
}
|
|
66
|
+
if (first === "http") {
|
|
67
|
+
return "http";
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function forwardedHost(value: string | string[] | undefined): string | null {
|
|
73
|
+
const first = firstHeaderValue(value);
|
|
74
|
+
if (first === null || first.length === 0 || first.length > 255) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
// hostname[:port] — tolak karakter di luar himpunan aman (spasi, CRLF, /, @, ?).
|
|
78
|
+
if (!/^[A-Za-z0-9.\-[\]:]+$/.test(first)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return first;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function isPlausibleIp(value: string): boolean {
|
|
85
|
+
return value.length <= 64 && /^[0-9a-fA-F:.]+$/.test(value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function stripZoneId(value: string): string {
|
|
89
|
+
const index = value.indexOf("%");
|
|
90
|
+
return index === -1 ? value : value.slice(0, index);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** `::ffff:127.0.0.1` → `127.0.0.1`; buang zone id (`%eth0`). */
|
|
94
|
+
function normalizeIp(value: string): string {
|
|
95
|
+
const withoutZone = stripZoneId(value);
|
|
96
|
+
return withoutZone.startsWith("::ffff:") ? withoutZone.slice(7) : withoutZone;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* IP klien tepercaya (Addendum J.1) dari nilai header mentah — inti yang sama
|
|
101
|
+
* untuk Node (`IncomingMessage`) dan Bun (`Request` + `server.requestIP`).
|
|
102
|
+
*/
|
|
103
|
+
export function resolveClientIpValues(
|
|
104
|
+
forwardedFor: string | string[] | undefined,
|
|
105
|
+
remoteAddress: string | null,
|
|
106
|
+
trustProxy: boolean,
|
|
107
|
+
): string | null {
|
|
108
|
+
if (trustProxy) {
|
|
109
|
+
const forwarded = firstHeaderValue(forwardedFor);
|
|
110
|
+
if (forwarded !== null && isPlausibleIp(forwarded)) {
|
|
111
|
+
return normalizeIp(forwarded);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return remoteAddress === null ? null : normalizeIp(remoteAddress);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const MIME_TYPES: Record<string, string> = {
|
|
118
|
+
".js": "text/javascript; charset=utf-8",
|
|
119
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
120
|
+
".css": "text/css; charset=utf-8",
|
|
121
|
+
".html": "text/html; charset=utf-8",
|
|
122
|
+
".json": "application/json; charset=utf-8",
|
|
123
|
+
".map": "application/json; charset=utf-8",
|
|
124
|
+
".ico": "image/x-icon",
|
|
125
|
+
".png": "image/png",
|
|
126
|
+
".jpg": "image/jpeg",
|
|
127
|
+
".jpeg": "image/jpeg",
|
|
128
|
+
".gif": "image/gif",
|
|
129
|
+
".svg": "image/svg+xml",
|
|
130
|
+
".webp": "image/webp",
|
|
131
|
+
".avif": "image/avif",
|
|
132
|
+
".woff": "font/woff",
|
|
133
|
+
".woff2": "font/woff2",
|
|
134
|
+
".ttf": "font/ttf",
|
|
135
|
+
".txt": "text/plain; charset=utf-8",
|
|
136
|
+
".wasm": "application/wasm",
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const COMPRESSIBLE_FILE = /\.(js|mjs|css|html|json|svg|txt|map|xml)$/i;
|
|
140
|
+
export const GZIP_MIN_BYTES = 1024;
|
|
141
|
+
const GZIP_CACHE_MAX = 64;
|
|
142
|
+
const gzipCache = new Map<string, { mtimeMs: number; gzip: Buffer }>();
|
|
143
|
+
|
|
144
|
+
/** Varian gzip ter-cache per file+mtime (bounded FIFO) — Addendum K.5. */
|
|
145
|
+
export function gzipCached(file: string, mtimeMs: number, body: Buffer): Buffer {
|
|
146
|
+
const cached = gzipCache.get(file);
|
|
147
|
+
if (cached !== undefined && cached.mtimeMs === mtimeMs) {
|
|
148
|
+
return cached.gzip;
|
|
149
|
+
}
|
|
150
|
+
const gzip = gzipSync(body);
|
|
151
|
+
if (gzipCache.size >= GZIP_CACHE_MAX) {
|
|
152
|
+
const oldest = gzipCache.keys().next().value;
|
|
153
|
+
if (oldest !== undefined) {
|
|
154
|
+
gzipCache.delete(oldest);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
gzipCache.set(file, { mtimeMs, gzip });
|
|
158
|
+
return gzip;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function acceptsGzipHeader(value: string | null): boolean {
|
|
162
|
+
if (value === null) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return value
|
|
166
|
+
.toLowerCase()
|
|
167
|
+
.split(",")
|
|
168
|
+
.map((part) => part.trim())
|
|
169
|
+
.some((part) => part === "gzip" || part === "*" || part.startsWith("gzip;"));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** 413 transport dengan format §15 yang sama seperti `rpc.ts` (Addendum J.2). */
|
|
173
|
+
export function rpcBodyTooLargeText(limit: number, size: number | null): string {
|
|
174
|
+
const megabytes = (bytes: number): string => (bytes / 1_000_000).toFixed(1);
|
|
175
|
+
return new MoonsError({
|
|
176
|
+
code: "E_RPC_BODY_TOO_LARGE",
|
|
177
|
+
message:
|
|
178
|
+
size === null
|
|
179
|
+
? `body exceeds the ${megabytes(limit)} MB limit`
|
|
180
|
+
: `body ${megabytes(size)} MB exceeds the ${megabytes(limit)} MB limit`,
|
|
181
|
+
details:
|
|
182
|
+
"Body exceeds `security.bodyLimitBytes`; reading stops at the transport before the body is fully buffered.",
|
|
183
|
+
suggestions: [
|
|
184
|
+
"Reduce the payload size, or",
|
|
185
|
+
"Increase security.bodyLimitBytes if you really need to",
|
|
186
|
+
],
|
|
187
|
+
}).format();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Target header minimal yang dipenuhi `ServerResponse` dan `Headers`. */
|
|
191
|
+
export interface HeaderTarget {
|
|
192
|
+
has(name: string): boolean;
|
|
193
|
+
set(name: string, value: string): void;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Addendum J.7: header konfigurasi (menang), default aman, dan
|
|
198
|
+
* `Cache-Control: immutable` untuk aset ber-hash di `/assets/*`.
|
|
199
|
+
*/
|
|
200
|
+
export function applyStaticHeaders(
|
|
201
|
+
target: HeaderTarget,
|
|
202
|
+
pathname: string,
|
|
203
|
+
configured: Record<string, string> | undefined,
|
|
204
|
+
): void {
|
|
205
|
+
for (const [name, value] of Object.entries(configured ?? {})) {
|
|
206
|
+
if (!target.has(name)) {
|
|
207
|
+
target.set(name, value);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
for (const [name, value] of Object.entries(DEFAULT_SECURITY_HEADERS)) {
|
|
211
|
+
if (!target.has(name)) {
|
|
212
|
+
target.set(name, value);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (pathname.startsWith("/assets/") && !target.has("cache-control")) {
|
|
216
|
+
target.set("cache-control", "public, max-age=31536000, immutable");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Baca body Web stream dengan batas tegas (Addendum J.2): begitu melewati
|
|
222
|
+
* `maxBytes`, pembacaan dihentikan dan `BodyLimitError` dilempar.
|
|
223
|
+
*/
|
|
224
|
+
export async function readBodyWithLimit(
|
|
225
|
+
stream: ReadableStream<Uint8Array> | null,
|
|
226
|
+
maxBytes: number,
|
|
227
|
+
): Promise<Uint8Array> {
|
|
228
|
+
if (stream === null) {
|
|
229
|
+
return new Uint8Array(0);
|
|
230
|
+
}
|
|
231
|
+
const reader = stream.getReader();
|
|
232
|
+
const chunks: Uint8Array[] = [];
|
|
233
|
+
let size = 0;
|
|
234
|
+
try {
|
|
235
|
+
for (;;) {
|
|
236
|
+
const { done, value } = await reader.read();
|
|
237
|
+
if (done) {
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
if (value !== undefined) {
|
|
241
|
+
size += value.byteLength;
|
|
242
|
+
if (size > maxBytes) {
|
|
243
|
+
throw new BodyLimitError(maxBytes);
|
|
244
|
+
}
|
|
245
|
+
chunks.push(value);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
} finally {
|
|
249
|
+
try {
|
|
250
|
+
await reader.cancel();
|
|
251
|
+
} catch {
|
|
252
|
+
// stream sudah selesai/tertutup — abaikan
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const output = new Uint8Array(size);
|
|
256
|
+
let offset = 0;
|
|
257
|
+
for (const chunk of chunks) {
|
|
258
|
+
output.set(chunk, offset);
|
|
259
|
+
offset += chunk.byteLength;
|
|
260
|
+
}
|
|
261
|
+
return output;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Resolve file static dengan proteksi path traversal (+ manifest prerender D.5). */
|
|
265
|
+
export function resolveStaticFile(clientDir: string, pathname: string): string | null {
|
|
266
|
+
const target = staticFileTarget(clientDir, pathname);
|
|
267
|
+
return target !== null && isFile(target) ? target : null;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Target file untuk `pathname` (tanpa cek keberadaan) — dipakai penyajian,
|
|
272
|
+
* `createFileStorage().write`, dan test. Proteksi path traversal tetap.
|
|
273
|
+
*/
|
|
274
|
+
export function staticFileTarget(clientDir: string, pathname: string): string | null {
|
|
275
|
+
let decoded: string;
|
|
276
|
+
try {
|
|
277
|
+
decoded = decodeURIComponent(pathname);
|
|
278
|
+
} catch {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// 1) File persis (aset: js/css/png/…, atau HTML yang diminta eksplisit).
|
|
283
|
+
const exact = safeWithin(clientDir, `.${decoded}`);
|
|
284
|
+
if (exact !== null && isFile(exact)) {
|
|
285
|
+
return exact;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 2) Hasil prerender: hanya path yang tercatat di manifest yang dilayani
|
|
289
|
+
// statis — bukan shell `index.html` biasa (yang berarti bypass SSR).
|
|
290
|
+
const normalized = decoded.length > 1 ? decoded.replace(/\/+$/, "") : decoded;
|
|
291
|
+
const manifest = readPrerenderManifest(clientDir);
|
|
292
|
+
if (manifest.paths.has(normalized)) {
|
|
293
|
+
const target = normalized === "/" ? "index.html" : `${normalized.slice(1)}/index.html`;
|
|
294
|
+
return safeWithin(clientDir, `./${target}`);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function safeWithin(clientDir: string, relative: string): string | null {
|
|
301
|
+
const candidate = resolve(clientDir, relative);
|
|
302
|
+
if (candidate !== clientDir && !candidate.startsWith(clientDir + sep)) {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
return candidate;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function isFile(path: string): boolean {
|
|
309
|
+
return existsSync(path) && statSync(path).isFile();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface PrerenderManifestInfo {
|
|
313
|
+
paths: Set<string>;
|
|
314
|
+
revalidate: Map<string, number>;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let prerenderManifestCache:
|
|
318
|
+
| { file: string; mtimeMs: number; info: PrerenderManifestInfo }
|
|
319
|
+
| null = null;
|
|
320
|
+
|
|
321
|
+
export function readPrerenderManifest(clientDir: string): PrerenderManifestInfo {
|
|
322
|
+
const file = join(clientDir, "_moons_prerender.json");
|
|
323
|
+
const empty: PrerenderManifestInfo = { paths: new Set(), revalidate: new Map() };
|
|
324
|
+
try {
|
|
325
|
+
const mtimeMs = statSync(file).mtimeMs;
|
|
326
|
+
if (
|
|
327
|
+
prerenderManifestCache !== null &&
|
|
328
|
+
prerenderManifestCache.file === file &&
|
|
329
|
+
prerenderManifestCache.mtimeMs === mtimeMs
|
|
330
|
+
) {
|
|
331
|
+
return prerenderManifestCache.info;
|
|
332
|
+
}
|
|
333
|
+
const json = JSON.parse(readFileSync(file, "utf8")) as {
|
|
334
|
+
paths?: unknown;
|
|
335
|
+
version?: unknown;
|
|
336
|
+
entries?: unknown;
|
|
337
|
+
};
|
|
338
|
+
const paths = new Set<string>();
|
|
339
|
+
const revalidate = new Map<string, number>();
|
|
340
|
+
if (Array.isArray(json.paths)) {
|
|
341
|
+
// Manifest v1 (D.5) — tanpa revalidate.
|
|
342
|
+
for (const path of json.paths) {
|
|
343
|
+
if (typeof path === "string") {
|
|
344
|
+
paths.add(path);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (Array.isArray(json.entries)) {
|
|
349
|
+
// Manifest v2 (E.1).
|
|
350
|
+
for (const entry of json.entries as Array<Record<string, unknown>>) {
|
|
351
|
+
if (entry === null || typeof entry !== "object" || typeof entry["path"] !== "string") {
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const path = entry["path"] as string;
|
|
355
|
+
paths.add(path);
|
|
356
|
+
const seconds = entry["revalidate"];
|
|
357
|
+
if (typeof seconds === "number" && Number.isFinite(seconds) && seconds >= 0) {
|
|
358
|
+
revalidate.set(path, seconds);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const info = { paths, revalidate };
|
|
363
|
+
prerenderManifestCache = { file, mtimeMs, info };
|
|
364
|
+
return info;
|
|
365
|
+
} catch {
|
|
366
|
+
return empty;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** ISR: jika file prerender kedaluwarsa, regenerasi background (SWR). */
|
|
371
|
+
export function scheduleRevalidation(input: {
|
|
372
|
+
pathname: string;
|
|
373
|
+
mtimeMs: number;
|
|
374
|
+
file?: string;
|
|
375
|
+
storage?: PrerenderStorage;
|
|
376
|
+
handler: (request: Request) => Promise<Response>;
|
|
377
|
+
options: { canary?: string };
|
|
378
|
+
clientDir: string;
|
|
379
|
+
logger?: Logger | null;
|
|
380
|
+
}): void {
|
|
381
|
+
const normalized = input.pathname.length > 1 ? input.pathname.replace(/\/+$/, "") : input.pathname;
|
|
382
|
+
const seconds = readPrerenderManifest(input.clientDir).revalidate.get(normalized);
|
|
383
|
+
if (seconds === undefined || seconds < 0) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (!shouldRevalidate({ mtimeMs: input.mtimeMs, revalidateSeconds: seconds })) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const regeneratedAt = performance.now();
|
|
390
|
+
const logger = input.logger ?? null;
|
|
391
|
+
void revalidatePrerendered({
|
|
392
|
+
pathname: normalized,
|
|
393
|
+
...(input.file === undefined ? {} : { file: input.file }),
|
|
394
|
+
...(input.storage === undefined ? {} : { storage: input.storage }),
|
|
395
|
+
handler: input.handler,
|
|
396
|
+
...(input.options.canary === undefined ? {} : { canary: input.options.canary }),
|
|
397
|
+
env: process.env,
|
|
398
|
+
})
|
|
399
|
+
.then(() => {
|
|
400
|
+
logger?.({
|
|
401
|
+
msg: "isr:regenerated",
|
|
402
|
+
path: normalized,
|
|
403
|
+
durationMs: Math.round(performance.now() - regeneratedAt),
|
|
404
|
+
});
|
|
405
|
+
})
|
|
406
|
+
.catch((error: unknown) => {
|
|
407
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
408
|
+
if (logger !== null) {
|
|
409
|
+
logger({ msg: "isr:revalidate-failed", level: "warn", path: normalized, error: message });
|
|
410
|
+
} else {
|
|
411
|
+
console.error(`[moons] isr regeneration failed (${normalized}): ${message}`);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/server/shell.ts", "../src/server/node.ts", "../src/virtual-modules.ts", "../src/server/dev.ts", "../src/devtools.ts", "../src/manifest.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { MoonsError } from \"@moonsjs/core\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type { ViteDevServer } from \"vite\";\n\nexport type Shell = (\n markup: string,\n payload: string,\n url: string,\n meta?: Record<string, unknown>,\n) => string | Promise<string>;\n\nexport const ROOT_PLACEHOLDER = '<div id=\"root\"></div>';\n\nexport const DEFAULT_TEMPLATE = [\n \"<!doctype html>\",\n '<html lang=\"en\">',\n \"<head>\",\n ' <meta charset=\"utf-8\" />',\n ' <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />',\n \" <title>Moons</title>\",\n \"</head>\",\n \"<body>\",\n ` ${ROOT_PLACEHOLDER}`,\n ' <script type=\"module\" src=\"/src/client/main.tsx\"></script>',\n \"</body>\",\n \"</html>\",\n \"\",\n].join(\"\\n\");\n\n/** Inject markup SSR + payload devalue ke shell HTML (PRD §8.2, §17, Addendum B.1). */\nexport function injectShell(\n template: string,\n markup: string,\n payload: string,\n meta?: Record<string, unknown>,\n): string {\n if (!template.includes(ROOT_PLACEHOLDER)) {\n throw new MoonsError({\n code: \"E_INTERNAL\",\n message: `shell HTML does not contain \\`${ROOT_PLACEHOLDER}\\``,\n details: \"The app's index.html must contain that root element so SSR can inject markup.\",\n suggestions: [\n `Add ${ROOT_PLACEHOLDER} to index.html`,\n \"Or remove index.html to use the built-in shell\",\n ],\n });\n }\n const dataScript = `<script id=\"__moons_data\" type=\"application/x-moons\">${payload}</script>`;\n const withRoot = template.replace(ROOT_PLACEHOLDER, `<div id=\"root\">${markup}</div>${dataScript}`);\n return applyMeta(withRoot, meta);\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\")\n .replaceAll('\"', \""\");\n}\n\n/**\n * Terapkan meta route ke `<head>` (Addendum B.1): `<title>` + description/og.\n * Tag yang sudah ada (mis. di index.html) ditimpa; yang belum ada disisipkan\n * sebelum `</head>`.\n */\nfunction applyMeta(html: string, meta: Record<string, unknown> | undefined): string {\n if (meta === undefined) {\n return html;\n }\n let out = html;\n if (typeof meta.title === \"string\") {\n const title = `<title>${escapeHtml(meta.title)}</title>`;\n out = /<title>[\\s\\S]*?<\\/title>/.test(out)\n ? out.replace(/<title>[\\s\\S]*?<\\/title>/, title)\n : out.replace(\"</head>\", ` ${title}\\n</head>`);\n }\n\n const tags: Array<{ attr: \"name\" | \"property\"; key: string; value: unknown }> = [\n { attr: \"name\", key: \"description\", value: meta.description },\n { attr: \"property\", key: \"og:title\", value: meta.title },\n { attr: \"property\", key: \"og:description\", value: meta.description },\n ];\n for (const tag of tags) {\n if (typeof tag.value !== \"string\") {\n continue;\n }\n const rendered = `<meta ${tag.attr}=\"${tag.key}\" content=\"${escapeHtml(tag.value)}\" />`;\n const pattern = new RegExp(`<meta[^>]*${tag.attr}=\"${tag.key}\"[^>]*>`);\n out = pattern.test(out)\n ? out.replace(pattern, rendered)\n : out.replace(\"</head>\", ` ${rendered}\\n</head>`);\n }\n return out;\n}\n\n/**\n * Shell untuk dev: baca `index.html` dari disk setiap request (selalu segar)\n * lalu lewatkan ke Vite `transformIndexHtml` (inject `/@vite/client`, dsb).\n */\nexport function createDevShell(server: ViteDevServer, options: { templatePath: string }): Shell {\n return async (markup, payload, url, meta) => {\n const template = existsSync(options.templatePath)\n ? readFileSync(options.templatePath, \"utf8\")\n : DEFAULT_TEMPLATE;\n const html = injectShell(template, markup, payload, meta);\n return await server.transformIndexHtml(url, html);\n };\n}\n\n/** Shell untuk produksi: baca `dist/client/index.html` sekali dari cwd. */\nexport function createFileShell(options: { clientDir?: string } = {}): Shell {\n let cached: string | null = null;\n return async (markup, payload, _url, meta) => {\n if (cached === null) {\n const clientDir = resolve(options.clientDir ?? process.cwd(), \"dist/client\");\n const file = join(clientDir, \"index.html\");\n if (!existsSync(file)) {\n throw new MoonsError({\n code: \"E_INTERNAL\",\n file,\n message: \"`dist/client/index.html` not found\",\n details: \"The client build must run before starting the production server.\",\n suggestions: [\"Run `bun run build` first\"],\n });\n }\n cached = readFileSync(file, \"utf8\");\n }\n return injectShell(cached, markup, payload, meta);\n };\n}\n",
|
|
6
|
-
"import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport { Readable } from \"node:stream\";\nimport { pipeline } from \"node:stream/promises\";\nimport { CLIENT_IP_HEADER } from \"@moonsjs/core\";\n\n/** Batas transport default (Addendum J.2); RPC punya batas lebih kecil dari config. */\nexport const MAX_TRANSPORT_BODY_BYTES = 32 * 1024 * 1024;\n\n/** Request tidak valid (Host/URL malformed) → dipetakan ke 400 oleh server. */\nexport class InvalidRequestError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"InvalidRequestError\";\n }\n}\n\n/** Body melebihi batas → dipetakan ke 413; pembacaan dihentikan saat melewati. */\nexport class BodyLimitError extends Error {\n readonly limit: number;\n constructor(limit: number) {\n super(`request body exceeds the ${limit} byte limit`);\n this.name = \"BodyLimitError\";\n this.limit = limit;\n }\n}\n\nexport interface ToWebRequestOptions {\n /** Addendum J.1: percayai `x-forwarded-proto`/`x-forwarded-host` (default false). */\n trustProxy?: boolean;\n /** Batas pembacaan body (byte). Default: `MAX_TRANSPORT_BODY_BYTES`. */\n maxBodyBytes?: number;\n}\n\n/**\n * Rekonstruksi URL request (Addendum J.1). Tanpa `trustProxy`, origin/host\n * murni dari header `Host` (perilaku lama, kebal spoofing `x-forwarded-*`).\n * Malformed → `InvalidRequestError` (server memetakan ke 400).\n */\nexport function resolveRequestUrl(\n req: IncomingMessage,\n options: ToWebRequestOptions = {},\n): URL {\n const hostHeader = req.headers.host ?? \"localhost\";\n const trustProxy = options.trustProxy === true;\n const proto = trustProxy ? forwardedProtocol(req.headers[\"x-forwarded-proto\"]) : null;\n const forwardedHostValue = trustProxy ? forwardedHost(req.headers[\"x-forwarded-host\"]) : null;\n const host = forwardedHostValue ?? hostHeader;\n try {\n return new URL(`${proto ?? \"http\"}://${host}${req.url ?? \"/\"}`);\n } catch {\n throw new InvalidRequestError(`invalid Host header: ${JSON.stringify(hostHeader)}`);\n }\n}\n\n/** IP klien tepercaya (Addendum J.1): XFF (hanya bila trustProxy) → socket. */\nexport function resolveClientIp(req: IncomingMessage, trustProxy: boolean): string | null {\n if (trustProxy) {\n const forwarded = firstHeaderValue(req.headers[\"x-forwarded-for\"]);\n if (forwarded !== null && isPlausibleIp(forwarded)) {\n return normalizeIp(forwarded);\n }\n }\n const remote = req.socket?.remoteAddress ?? null;\n return remote === null ? null : normalizeIp(remote);\n}\n\n/** `::ffff:127.0.0.1` → `127.0.0.1`; buang zone id (`%eth0`). */\nfunction normalizeIp(value: string): string {\n const withoutZone = stripZoneId(value);\n return withoutZone.startsWith(\"::ffff:\") ? withoutZone.slice(7) : withoutZone;\n}\n\n/** Konversi request Node → Web `Request` (body diteruskan untuk non-GET/HEAD, §7.3 + J.1/J.2). */\nexport async function toWebRequest(\n req: IncomingMessage,\n options: ToWebRequestOptions = {},\n): Promise<Request> {\n const url = resolveRequestUrl(req, options);\n const method = req.method ?? \"GET\";\n\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (value === undefined || key === \"content-length\" || key === CLIENT_IP_HEADER) {\n // content-length tidak disalin; fetch menghitung ulang dari body.\n // x-moons-client-ip selalu ditimpa nilai tepercaya di bawah.\n continue;\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(key, item);\n }\n } else {\n headers.set(key, value);\n }\n }\n\n const clientIp = resolveClientIp(req, options.trustProxy === true);\n if (clientIp !== null) {\n headers.set(CLIENT_IP_HEADER, clientIp);\n }\n\n if (method === \"GET\" || method === \"HEAD\") {\n return new Request(url, { method, headers });\n }\n\n const body = await readBody(req, options.maxBodyBytes ?? MAX_TRANSPORT_BODY_BYTES);\n // View zero-copy (bukan salinan) — Buffer selalu di atas ArrayBuffer biasa.\n const view = new Uint8Array(body.buffer as ArrayBuffer, body.byteOffset, body.byteLength);\n return new Request(url, { method, headers, body: view });\n}\n\n/**\n * Baca body dengan batas tegas (Addendum J.2): begitu melewati `maxBytes`,\n * pembacaan dihentikan (pause) dan `BodyLimitError` dilempar — tidak pernah\n * seluruh body besar masuk memori, dan hanya satu salinan buffer dibuat.\n */\nexport function readBody(req: IncomingMessage, maxBytes: number): Promise<Buffer> {\n return new Promise((resolvePromise, reject) => {\n const chunks: Buffer[] = [];\n let size = 0;\n let settled = false;\n\n const fail = (error: Error): void => {\n if (settled) {\n return;\n }\n settled = true;\n req.pause();\n reject(error);\n };\n\n req.on(\"data\", (chunk: Buffer) => {\n if (settled) {\n return;\n }\n size += chunk.length;\n if (size > maxBytes) {\n fail(new BodyLimitError(maxBytes));\n return;\n }\n chunks.push(chunk);\n });\n req.on(\"end\", () => {\n if (!settled) {\n settled = true;\n resolvePromise(Buffer.concat(chunks));\n }\n });\n req.on(\"error\", (error) => fail(error));\n });\n}\n\n/** Addendum J.7: default aman runtime; `config.headers` tetap menang (cek hasHeader). */\nexport const DEFAULT_SECURITY_HEADERS: Record<string, string> = {\n \"x-content-type-options\": \"nosniff\",\n \"referrer-policy\": \"strict-origin-when-cross-origin\",\n};\n\n/** Tulis Web `Response` ke `ServerResponse` Node (streaming bila ada body). */\nexport async function sendNodeResponse(res: ServerResponse, response: Response): Promise<void> {\n res.statusCode = response.status;\n response.headers.forEach((value, key) => {\n // `set-cookie` ditangani terpisah: forEach menggabungkan nilai ganda\n // menjadi satu string (cookie kedua hilang — D.2).\n if (key === \"set-cookie\") {\n return;\n }\n res.setHeader(key, value);\n });\n const getSetCookie = (response.headers as { getSetCookie?: () => string[] }).getSetCookie;\n if (typeof getSetCookie === \"function\") {\n const cookies = getSetCookie.call(response.headers);\n if (cookies.length > 0) {\n res.setHeader(\"set-cookie\", cookies);\n }\n } else {\n const single = response.headers.get(\"set-cookie\");\n if (single !== null) {\n res.setHeader(\"set-cookie\", single);\n }\n }\n\n for (const [name, value] of Object.entries(DEFAULT_SECURITY_HEADERS)) {\n if (!res.hasHeader(name)) {\n res.setHeader(name, value);\n }\n }\n\n if (response.body === null || res.req?.method === \"HEAD\") {\n res.end();\n return;\n }\n\n // Addendum J.2: stream langsung — tidak ada `arrayBuffer()` penuh di memori.\n await pipeline(\n Readable.fromWeb(response.body as unknown as import(\"node:stream/web\").ReadableStream),\n res,\n );\n}\n\nfunction firstHeaderValue(value: string | string[] | undefined): string | null {\n if (value === undefined) {\n return null;\n }\n const raw = Array.isArray(value) ? value[0] : value;\n if (raw === undefined) {\n return null;\n }\n const first = raw.split(\",\")[0]?.trim() ?? \"\";\n return first.length === 0 ? null : first;\n}\n\nfunction forwardedProtocol(value: string | string[] | undefined): \"http\" | \"https\" | null {\n const first = firstHeaderValue(value)?.toLowerCase() ?? null;\n if (first === \"https\") {\n return \"https\";\n }\n if (first === \"http\") {\n return \"http\";\n }\n return null;\n}\n\nfunction forwardedHost(value: string | string[] | undefined): string | null {\n const first = firstHeaderValue(value);\n if (first === null || first.length === 0 || first.length > 255) {\n return null;\n }\n // hostname[:port] — tolak karakter di luar himpunan aman (spasi, CRLF, /, @, ?).\n if (!/^[A-Za-z0-9.\\-[\\]:]+$/.test(first)) {\n return null;\n }\n return first;\n}\n\nfunction isPlausibleIp(value: string): boolean {\n return value.length <= 64 && /^[0-9a-fA-F:.]+$/.test(value);\n}\n\nfunction stripZoneId(value: string): string {\n const index = value.indexOf(\"%\");\n return index === -1 ? value : value.slice(0, index);\n}\n",
|
|
7
|
-
"/** Nama virtual module PRD §9.4. Semua di-resolve ke id `\\0`-prefix. */\nexport const VIRTUAL_MODULES = {\n routes: \"virtual:moons/routes\",\n api: \"virtual:moons/api\",\n config: \"virtual:moons/config\",\n clientEntry: \"virtual:moons/client-entry\",\n serverEntry: \"virtual:moons/server-entry\",\n} as const;\n\nexport type VirtualModuleName = (typeof VIRTUAL_MODULES)[keyof typeof VIRTUAL_MODULES];\n\nexport function isVirtualModuleId(id: string): id is VirtualModuleName {\n const clean = id.startsWith(\"\\0\") ? id.slice(1) : id;\n return (Object.values(VIRTUAL_MODULES) as string[]).includes(clean);\n}\n\nexport function toNullPrefixed(id: VirtualModuleName): `\\0${string}` {\n return `\\0${id}`;\n}\n\nexport function fromNullPrefixed(id: string): VirtualModuleName | null {\n const clean = id.startsWith(\"\\0\") ? id.slice(1) : id;\n return isVirtualModuleId(clean) ? (clean as VirtualModuleName) : null;\n}\n",
|
|
8
|
-
"import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport type { ViteDevServer } from \"vite\";\nimport { VIRTUAL_MODULES } from \"../virtual-modules\";\nimport type { PayloadScanOptions } from \"../payload-scan\";\nimport type { PluginRuntime } from \"./plugins\";\nimport type { Shell } from \"./shell\";\nimport { createDevShell } from \"./shell\";\nimport {\n BodyLimitError,\n InvalidRequestError,\n resolveRequestUrl,\n sendNodeResponse,\n toWebRequest,\n} from \"./node\";\nimport { DEFAULT_BODY_LIMIT_BYTES } from \"@moonsjs/core\";\nimport { emptyDevtoolsData, renderDevtoolsHtml, type DevtoolsData } from \"../devtools\";\n\ninterface DevApp {\n handler: (request: Request) => Promise<Response>;\n plugins: PluginRuntime;\n}\n\ntype DevServerEntry = {\n createDevApp: (\n shell: Shell,\n payloadScan?: import(\"../payload-scan\").PayloadScanOptions,\n ) => DevApp;\n};\n\n/**\n * Middleware SSR dev: dipasang sebelum middleware internal Vite, menangani\n * request HTML dan RPC serverFn (`/_moons/fn/*`) — modul/aset tetap Vite.\n * Handler + lifecycle plugin (Addendum B.4) diinisialisasi sekali.\n */\nexport function installDevMiddleware(\n server: ViteDevServer,\n options: {\n templatePath: string;\n payloadScan?: PayloadScanOptions;\n apiPrefix?: string;\n /** Addendum J.1: paritas dev dengan produksi (trustProxy/bodyLimitBytes). */\n trustProxy?: boolean;\n bodyLimitBytes?: number;\n /** Addendum I.4: datasource devtools overlay (dipanggil per request). */\n devtools?: () => DevtoolsData;\n },\n): void {\n let appPromise: Promise<DevApp> | null = null;\n\n const getApp = (): Promise<DevApp> => {\n if (appPromise === null) {\n appPromise = (async () => {\n const entry = (await server.ssrLoadModule(VIRTUAL_MODULES.serverEntry)) as DevServerEntry;\n const app = entry.createDevApp(createDevShell(server, options), options.payloadScan);\n await app.plugins.start();\n await app.plugins.ready();\n return app;\n })();\n }\n return appPromise;\n };\n\n server.httpServer?.once(\"close\", () => {\n void appPromise?.then((app) => app.plugins.shutdown());\n });\n\n server.middlewares.use((req, res, next) => {\n // Addendum I.4 (W4): overlay dev-only — selalu data segar per request.\n if (\n (req.method === \"GET\" || req.method === \"HEAD\") &&\n new URL(req.url ?? \"/\", \"http://localhost\").pathname === \"/__moons/devtools\"\n ) {\n try {\n const data = options.devtools?.() ?? emptyDevtoolsData();\n res.statusCode = 200;\n res.setHeader(\"content-type\", \"text/html; charset=utf-8\");\n res.end(req.method === \"HEAD\" ? undefined : renderDevtoolsHtml(data));\n } catch (error) {\n res.statusCode = 500;\n res.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n res.end(`[moons] devtools failed to render: ${String(error)}`);\n }\n return;\n }\n\n if (!shouldHandle(req, options.apiPrefix)) {\n next();\n return;\n }\n void handleRequest(getApp, req, res, options).catch((error: unknown) => {\n if (error instanceof InvalidRequestError) {\n res.statusCode = 400;\n res.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n res.end(\"Bad Request\");\n return;\n }\n if (error instanceof BodyLimitError) {\n res.statusCode = 413;\n res.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n res.end(\"Payload Too Large\");\n res.once(\"finish\", () => req.destroy());\n return;\n }\n next(error as Error);\n });\n });\n}\n\nasync function handleRequest(\n getApp: () => Promise<DevApp>,\n req: IncomingMessage,\n res: ServerResponse,\n options: { trustProxy?: boolean; bodyLimitBytes?: number },\n): Promise<void> {\n const app = await getApp();\n const url = resolveRequestUrl(req, { trustProxy: options.trustProxy === true });\n const isRpc = url.pathname.startsWith(\"/_moons/fn/\");\n const request = await toWebRequest(req, {\n trustProxy: options.trustProxy === true,\n ...(isRpc ? { maxBodyBytes: options.bodyLimitBytes ?? DEFAULT_BODY_LIMIT_BYTES } : {}),\n });\n const response = await app.handler(request);\n await sendNodeResponse(res, response);\n}\n\nfunction shouldHandle(req: IncomingMessage, apiPrefix: string | undefined): boolean {\n const path = new URL(req.url ?? \"/\", \"http://localhost\").pathname;\n\n // RPC serverFn (semua method): dulu hanya GET/HEAD HTML yang dirutekan,\n // sehingga `POST /_moons/fn/<hash>` jatuh ke Vite (\"Cannot POST\", 404) dan\n // serverFn tidak bisa dipakai di dev (temuan eval T2 ronde 2; decisions/0016).\n if (path.startsWith(\"/_moons/fn/\")) {\n return true;\n }\n\n // Addendum O: health check (semua method) — paritas 405 dengan produksi.\n if (path === \"/_moons/health\") {\n return true;\n }\n\n // Addendum D.1: endpoint `src/api` (semua method) dirutekan ke runtime.\n if (apiPrefix !== undefined && (path === apiPrefix || path.startsWith(`${apiPrefix}/`))) {\n return true;\n }\n\n if (req.method !== \"GET\" && req.method !== \"HEAD\") {\n return false;\n }\n if (path.startsWith(\"/@\") || path.startsWith(\"/node_modules/\") || path.startsWith(\"/__\")) {\n return false;\n }\n const lastSegment = path.split(\"/\").pop() ?? \"\";\n if (lastSegment.includes(\".\")) {\n return false;\n }\n const accept = req.headers.accept ?? \"\";\n return accept.includes(\"text/html\") || accept.includes(\"*/*\");\n}\n",
|
|
9
|
-
"/**\n * Addendum I.4 (W4): devtools overlay dev-only — tabel route, registry\n * serverFn (hash §12), endpoint `src/api`, dan status payload-scan.\n * Renderer murni (tanpa I/O) supaya bisa diuji unit; middleware dev yang\n * menyajikannya di `/__moons/devtools`.\n */\n\nexport interface DevtoolsRoute {\n /** Path URL (bentuk PRD §6.1), mis. \"/users/:id\". */\n path: string;\n /** \"page\" | \"layout\" | \"error\" | \"404\" | \"middleware\" | \"api\". */\n kind: string;\n /** Path relatif terhadap root app (posix). */\n file: string;\n}\n\nexport interface DevtoolsFn {\n file: string;\n name: string;\n hash: string;\n}\n\nexport interface DevtoolsData {\n routes: DevtoolsRoute[];\n apiRoutes: DevtoolsRoute[];\n serverFns: DevtoolsFn[];\n /** Canary `leakTest` terpasang → payload-scan aktif (A1). */\n canary: boolean;\n version: string;\n}\n\nexport function emptyDevtoolsData(): DevtoolsData {\n return { routes: [], apiRoutes: [], serverFns: [], canary: false, version: \"\" };\n}\n\nexport function renderDevtoolsHtml(data: DevtoolsData): string {\n const rows = (items: DevtoolsRoute[]): string =>\n items.length === 0\n ? '<tr><td colspan=\"3\" class=\"muted\">(empty)</td></tr>'\n : items\n .map(\n (item) =>\n `<tr><td><code>${esc(item.path)}</code></td><td><span class=\"kind k-${esc(item.kind)}\">${esc(item.kind)}</span></td><td class=\"muted\">${esc(item.file)}</td></tr>`,\n )\n .join(\"\\n\");\n\n const fnRows =\n data.serverFns.length === 0\n ? '<tr><td colspan=\"3\" class=\"muted\">(no serverFn)</td></tr>'\n : data.serverFns\n .map(\n (fn) =>\n `<tr><td><code>${esc(fn.hash)}</code></td><td><code>${esc(fn.name)}</code></td><td class=\"muted\">${esc(fn.file)}</td></tr>`,\n )\n .join(\"\\n\");\n\n const canary = data.canary\n ? '<span class=\"ok\">enabled</span> (canary installed)'\n : '<span class=\"muted\">disabled</span> (no canary)';\n\n return `<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>moons devtools</title>\n<style>\n :root { color-scheme: dark; }\n body { margin: 0; padding: 2rem; background: #101418; color: #e6edf3;\n font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }\n h1 { font-size: 1.1rem; margin: 0 0 .25rem; }\n h2 { font-size: .95rem; margin: 2rem 0 .5rem; color: #9fb0c0; }\n .muted { color: #8b98a5; }\n .ok { color: #3fb950; font-weight: 600; }\n .meta { margin-bottom: 1.5rem; }\n table { border-collapse: collapse; width: 100%; max-width: 1100px; }\n th, td { text-align: left; padding: .35rem .75rem .35rem 0; border-bottom: 1px solid #1f2630; }\n th { color: #8b98a5; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }\n code { color: #79c0ff; }\n .kind { border: 1px solid #30363d; border-radius: 4px; padding: 0 .35rem; font-size: .8rem; }\n .k-page { color: #d2a8ff; } .k-layout { color: #7ee787; }\n .k-error { color: #ff7b72; } .k-404 { color: #ff7b72; }\n .k-middleware { color: #e3b341; } .k-api { color: #79c0ff; }\n</style>\n</head>\n<body>\n<h1>moons devtools</h1>\n<div class=\"meta muted\">@moonsjs/vite ${esc(data.version)} · dev-only · payload-scan: ${canary}</div>\n\n<h2>Routes (${data.routes.length})</h2>\n<table><thead><tr><th>path</th><th>kind</th><th>file</th></tr></thead>\n<tbody>\n${rows(data.routes)}\n</tbody></table>\n\n<h2>API (${data.apiRoutes.length})</h2>\n<table><thead><tr><th>path</th><th>kind</th><th>file</th></tr></thead>\n<tbody>\n${rows(data.apiRoutes)}\n</tbody></table>\n\n<h2>serverFn registry (${data.serverFns.length})</h2>\n<table><thead><tr><th>hash</th><th>export</th><th>file</th></tr></thead>\n<tbody>\n${fnRows}\n</tbody></table>\n</body>\n</html>\n`;\n}\n\nfunction esc(value: string): string {\n return value.replace(/[&<>\"']/g, (char) => {\n switch (char) {\n case \"&\":\n return \"&\";\n case \"<\":\n return \"<\";\n case \">\":\n return \">\";\n case '\"':\n return \""\";\n default:\n return \"'\";\n }\n });\n}\n",
|
|
10
|
-
"import { findLayouts, routeKeyFromFile, type ApiRouteDefinition, type RouteDefinition } from \"@moonsjs/core\";\nimport { relative, sep } from \"node:path\";\n\nexport interface ClientManifestEntry {\n page: string;\n layouts: string[];\n}\n\n/** Key manifest untuk halaman kustom `_404` dan `_error` (§11.2). */\nexport const NOT_FOUND_ROUTE_KEY = \"__moons/404\";\nexport const ERROR_ROUTE_KEY = \"__moons/error\";\n\n/**\n * Manifest route untuk client (PRD §8.2): key = key route file\n * (routeKeyFromFile), nilai = page + layout chain dari root ke leaf.\n */\nexport function buildClientManifest(\n routes: RouteDefinition[],\n routesDir: string,\n): Record<string, ClientManifestEntry> {\n const manifest: Record<string, ClientManifestEntry> = {};\n for (const route of routes) {\n if (route.kind !== \"page\") {\n continue;\n }\n const key = routeKeyFromFile(routesDir, route.file);\n manifest[key] = {\n page: key,\n layouts: findLayouts(route, routes).map((layout) => routeKeyFromFile(routesDir, layout.file)),\n };\n }\n\n const notFound = routes.find((route) => route.kind === \"404\");\n if (notFound !== undefined) {\n manifest[NOT_FOUND_ROUTE_KEY] = { page: routeKeyFromFile(routesDir, notFound.file), layouts: [] };\n }\n const errorRoute = routes.find((route) => route.kind === \"error\");\n if (errorRoute !== undefined) {\n manifest[ERROR_ROUTE_KEY] = { page: routeKeyFromFile(routesDir, errorRoute.file), layouts: [] };\n }\n // D.3: semua boundary `_error` (termasuk bersarang) ikut manifest — payload\n // memakai key file boundary yang dipilih runtime.\n for (const route of routes) {\n if (route.kind !== \"error\") {\n continue;\n }\n const key = routeKeyFromFile(routesDir, route.file);\n manifest[key] = { page: key, layouts: [] };\n }\n\n return manifest;\n}\n\n/** `virtual:moons/api` (Addendum D.1 + D.3): tabel API + middleware + peta import(). */\nexport function renderApiModule(\n apiRoutes: ApiRouteDefinition[],\n apiMiddlewares: ReadonlyArray<{ file: string; dir: string }>,\n projectRoot: string,\n): string {\n const loadEntries = apiRoutes\n .map(\n (route) =>\n ` ${JSON.stringify(route.path)}: () => import(${JSON.stringify(rootSpecifier(projectRoot, route.file))}),`,\n )\n .join(\"\\n\");\n const middlewareEntries = apiMiddlewares\n .map(\n (middleware) =>\n ` ${JSON.stringify(middleware.file)}: () => import(${JSON.stringify(rootSpecifier(projectRoot, middleware.file))}),`,\n )\n .join(\"\\n\");\n return [\n \"// Generated by @moons. Do not edit manually.\",\n `export const apiRoutes = ${JSON.stringify(apiRoutes, null, 2)};`,\n `export const apiMiddlewares = ${JSON.stringify(apiMiddlewares, null, 2)};`,\n \"export const loadApi = {\",\n loadEntries,\n \"};\",\n \"export const loadApiMiddleware = {\",\n middlewareEntries,\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\n/**\n * Isi `virtual:moons/routes`: daftar RouteDefinition, manifest client, dan\n * peta import() dinamis per file route (specifier root-relative).\n */\nexport function renderRoutesModule(\n routes: RouteDefinition[],\n routesDir: string,\n projectRoot: string,\n): string {\n const manifest = buildClientManifest(routes, routesDir);\n\n const loadEntries = routes.map((route) => {\n const key = routeKeyFromFile(routesDir, route.file);\n return ` ${JSON.stringify(key)}: () => import(${JSON.stringify(rootSpecifier(projectRoot, route.file))}),`;\n });\n\n return [\n \"// Generated by @moons. Do not edit manually.\",\n `export const routes = ${JSON.stringify(routes, null, 2)};`,\n \"\",\n `export const clientManifest = ${JSON.stringify(manifest, null, 2)};`,\n \"\",\n \"export const loadRoute = {\",\n ...loadEntries,\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\n/** Path file absolut project → specifier root-relative yang bisa di-resolve Vite. */\nexport function rootSpecifier(projectRoot: string, file: string): string {\n let rel = relative(projectRoot, file);\n rel = sep === \"/\" ? rel : rel.split(sep).join(\"/\");\n return rel.startsWith(\"/\") ? rel : `/${rel}`;\n}\n"
|
|
11
|
-
],
|
|
12
|
-
"mappings": ";AAAA;AACA;AACA;AAUO,IAAM,oBAAmB;AAEzB,IAAM,oBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,KAAK;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK;AAAA,CAAI;AAGJ,SAAS,YAAW,CACzB,UACA,QACA,SACA,MACQ;AAAA,EACR,IAAI,CAAC,SAAS,SAAS,iBAAgB,GAAG;AAAA,IACxC,MAAM,IAAI,WAAW;AAAA,MACnB,MAAM;AAAA,MACN,SAA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