@teamvelix/velix 5.0.3 → 5.0.4
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/build/index.js +4 -587
- package/dist/build/index.js.map +1 -1
- package/dist/chunk-7SGDYOVZ.js +136 -0
- package/dist/chunk-7SGDYOVZ.js.map +1 -0
- package/dist/chunk-F24Q2MX3.js +126 -0
- package/dist/chunk-F24Q2MX3.js.map +1 -0
- package/dist/chunk-INOZP2VD.js +165 -0
- package/dist/chunk-INOZP2VD.js.map +1 -0
- package/dist/chunk-NVTZ6HRX.js +2089 -0
- package/dist/chunk-NVTZ6HRX.js.map +1 -0
- package/dist/chunk-OIZNYND3.js +176 -0
- package/dist/chunk-OIZNYND3.js.map +1 -0
- package/dist/chunk-SPIGTNT7.js +406 -0
- package/dist/chunk-SPIGTNT7.js.map +1 -0
- package/dist/client/index.js +2 -147
- package/dist/client/index.js.map +1 -1
- package/dist/config.js +2 -128
- package/dist/config.js.map +1 -1
- package/dist/image-optimizer-I6TWWH6W.js +66 -0
- package/dist/image-optimizer-I6TWWH6W.js.map +1 -0
- package/dist/{index-l0dwPa62.d.ts → index-DYgxL3mE.d.ts} +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -3318
- package/dist/index.js.map +1 -1
- package/dist/islands/index.js +2 -181
- package/dist/islands/index.js.map +1 -1
- package/dist/runtime/start-dev.js +12 -2395
- package/dist/runtime/start-dev.js.map +1 -1
- package/dist/runtime/start-prod.js +5 -2387
- package/dist/runtime/start-prod.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +5 -2491
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/build/index.js
CHANGED
|
@@ -1,588 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// config.ts
|
|
7
|
-
import fs from "fs";
|
|
8
|
-
import path from "path";
|
|
9
|
-
import { pathToFileURL } from "url";
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
import pc from "picocolors";
|
|
12
|
-
var AppConfigSchema = z.object({
|
|
13
|
-
name: z.string().default("Velix App"),
|
|
14
|
-
url: z.string().url().optional()
|
|
15
|
-
}).default({});
|
|
16
|
-
var ServerConfigSchema = z.object({
|
|
17
|
-
port: z.number().min(1).max(65535).default(3e3),
|
|
18
|
-
host: z.string().default("localhost")
|
|
19
|
-
}).default({});
|
|
20
|
-
var RoutingConfigSchema = z.object({
|
|
21
|
-
trailingSlash: z.boolean().default(false)
|
|
22
|
-
}).default({});
|
|
23
|
-
var SEOConfigSchema = z.object({
|
|
24
|
-
sitemap: z.boolean().default(true),
|
|
25
|
-
robots: z.boolean().default(true),
|
|
26
|
-
openGraph: z.boolean().default(true)
|
|
27
|
-
}).default({});
|
|
28
|
-
var BuildConfigSchema = z.object({
|
|
29
|
-
target: z.string().default("es2022"),
|
|
30
|
-
minify: z.boolean().default(true),
|
|
31
|
-
sourcemap: z.boolean().default(true),
|
|
32
|
-
splitting: z.boolean().default(true),
|
|
33
|
-
outDir: z.string().default(".velix")
|
|
34
|
-
}).default({});
|
|
35
|
-
var ExperimentalConfigSchema = z.object({
|
|
36
|
-
islands: z.boolean().default(true),
|
|
37
|
-
streaming: z.boolean().default(true)
|
|
38
|
-
}).default({});
|
|
39
|
-
var PluginSchema = z.union([
|
|
40
|
-
z.string(),
|
|
41
|
-
z.object({
|
|
42
|
-
name: z.string()
|
|
43
|
-
}).passthrough()
|
|
44
|
-
]);
|
|
45
|
-
var VelixConfigSchema = z.object({
|
|
46
|
-
// App identity
|
|
47
|
-
app: AppConfigSchema,
|
|
48
|
-
// DevTools toggle
|
|
49
|
-
devtools: z.boolean().default(true),
|
|
50
|
-
// Server options
|
|
51
|
-
server: ServerConfigSchema,
|
|
52
|
-
// Routing options
|
|
53
|
-
routing: RoutingConfigSchema,
|
|
54
|
-
// SEO configuration
|
|
55
|
-
seo: SEOConfigSchema,
|
|
56
|
-
// Build options
|
|
57
|
-
build: BuildConfigSchema,
|
|
58
|
-
// Experimental features
|
|
59
|
-
experimental: ExperimentalConfigSchema,
|
|
60
|
-
// Plugins
|
|
61
|
-
plugins: z.array(PluginSchema).default([]),
|
|
62
|
-
// Directories (resolved automatically)
|
|
63
|
-
appDir: z.string().default("app"),
|
|
64
|
-
publicDir: z.string().default("public"),
|
|
65
|
-
// Stylesheets
|
|
66
|
-
styles: z.array(z.string()).default([]),
|
|
67
|
-
// Favicon
|
|
68
|
-
favicon: z.string().nullable().default(null)
|
|
69
|
-
});
|
|
70
|
-
var defaultConfig = VelixConfigSchema.parse({});
|
|
71
|
-
async function loadConfig(projectRoot) {
|
|
72
|
-
const configPathTs = path.join(projectRoot, "velix.config.ts");
|
|
73
|
-
const configPathJs = path.join(projectRoot, "velix.config.js");
|
|
74
|
-
const configPathLegacyTs = path.join(projectRoot, "flexireact.config.ts");
|
|
75
|
-
const configPathLegacyJs = path.join(projectRoot, "flexireact.config.js");
|
|
76
|
-
let configPath = null;
|
|
77
|
-
if (fs.existsSync(configPathTs)) configPath = configPathTs;
|
|
78
|
-
else if (fs.existsSync(configPathJs)) configPath = configPathJs;
|
|
79
|
-
else if (fs.existsSync(configPathLegacyTs)) configPath = configPathLegacyTs;
|
|
80
|
-
else if (fs.existsSync(configPathLegacyJs)) configPath = configPathLegacyJs;
|
|
81
|
-
let userConfig = {};
|
|
82
|
-
if (configPath) {
|
|
83
|
-
try {
|
|
84
|
-
const configUrl = pathToFileURL(configPath).href;
|
|
85
|
-
const module = await import(`${configUrl}?t=${Date.now()}`);
|
|
86
|
-
userConfig = module.default || module;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.warn(pc.yellow(`\u26A0 Failed to load config: ${error.message}`));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const merged = deepMerge(defaultConfig, userConfig);
|
|
92
|
-
try {
|
|
93
|
-
return VelixConfigSchema.parse(merged);
|
|
94
|
-
} catch (err) {
|
|
95
|
-
if (err instanceof z.ZodError) {
|
|
96
|
-
console.error(pc.red("\u2716 Configuration validation failed:"));
|
|
97
|
-
for (const issue of err.issues) {
|
|
98
|
-
console.error(pc.dim(` - ${issue.path.join(".")}: ${issue.message}`));
|
|
99
|
-
}
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function resolvePaths(config, projectRoot) {
|
|
106
|
-
return {
|
|
107
|
-
...config,
|
|
108
|
-
resolvedAppDir: path.resolve(projectRoot, config.appDir),
|
|
109
|
-
resolvedPublicDir: path.resolve(projectRoot, config.publicDir),
|
|
110
|
-
resolvedOutDir: path.resolve(projectRoot, config.build.outDir)
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function deepMerge(target, source) {
|
|
114
|
-
const result = { ...target };
|
|
115
|
-
for (const key in source) {
|
|
116
|
-
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
117
|
-
result[key] = deepMerge(target[key] || {}, source[key]);
|
|
118
|
-
} else {
|
|
119
|
-
result[key] = source[key];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// router/index.ts
|
|
126
|
-
import fs3 from "fs";
|
|
127
|
-
import path3 from "path";
|
|
128
|
-
|
|
129
|
-
// utils.ts
|
|
130
|
-
import fs2 from "fs";
|
|
131
|
-
import path2 from "path";
|
|
132
|
-
function findFiles(dir, pattern, files = []) {
|
|
133
|
-
if (!fs2.existsSync(dir)) return files;
|
|
134
|
-
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
135
|
-
for (const entry of entries) {
|
|
136
|
-
const fullPath = path2.join(dir, entry.name);
|
|
137
|
-
if (entry.isDirectory()) findFiles(fullPath, pattern, files);
|
|
138
|
-
else if (pattern.test(entry.name)) files.push(fullPath);
|
|
139
|
-
}
|
|
140
|
-
return files;
|
|
141
|
-
}
|
|
142
|
-
function ensureDir(dir) {
|
|
143
|
-
if (!fs2.existsSync(dir)) fs2.mkdirSync(dir, { recursive: true });
|
|
144
|
-
}
|
|
145
|
-
function cleanDir(dir) {
|
|
146
|
-
if (fs2.existsSync(dir)) fs2.rmSync(dir, { recursive: true, force: true });
|
|
147
|
-
fs2.mkdirSync(dir, { recursive: true });
|
|
148
|
-
}
|
|
149
|
-
function formatBytes(bytes) {
|
|
150
|
-
if (bytes === 0) return "0 B";
|
|
151
|
-
const k = 1024;
|
|
152
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
153
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
154
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
|
155
|
-
}
|
|
156
|
-
function isServerComponent(filePath) {
|
|
157
|
-
try {
|
|
158
|
-
const content = fs2.readFileSync(filePath, "utf-8");
|
|
159
|
-
const firstLine = content.split("\n")[0].trim();
|
|
160
|
-
return firstLine === "'use server'" || firstLine === '"use server"';
|
|
161
|
-
} catch {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function isClientComponent(filePath) {
|
|
166
|
-
try {
|
|
167
|
-
const content = fs2.readFileSync(filePath, "utf-8");
|
|
168
|
-
const firstLine = content.split("\n")[0].trim();
|
|
169
|
-
return firstLine === "'use client'" || firstLine === '"use client"';
|
|
170
|
-
} catch {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function isIsland(filePath) {
|
|
175
|
-
try {
|
|
176
|
-
const content = fs2.readFileSync(filePath, "utf-8");
|
|
177
|
-
const firstLine = content.split("\n")[0].trim();
|
|
178
|
-
return firstLine === "'use island'" || firstLine === '"use island"';
|
|
179
|
-
} catch {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// router/index.ts
|
|
185
|
-
var RouteType = {
|
|
186
|
-
PAGE: "page",
|
|
187
|
-
API: "api",
|
|
188
|
-
LAYOUT: "layout",
|
|
189
|
-
LOADING: "loading",
|
|
190
|
-
ERROR: "error",
|
|
191
|
-
NOT_FOUND: "not-found"
|
|
192
|
-
};
|
|
193
|
-
function buildRouteTree(appDir) {
|
|
194
|
-
const projectRoot = path3.dirname(appDir);
|
|
195
|
-
const routes = {
|
|
196
|
-
pages: [],
|
|
197
|
-
api: [],
|
|
198
|
-
layouts: /* @__PURE__ */ new Map(),
|
|
199
|
-
tree: {},
|
|
200
|
-
appRoutes: []
|
|
201
|
-
};
|
|
202
|
-
if (fs3.existsSync(appDir)) {
|
|
203
|
-
scanAppDirectory(appDir, appDir, routes);
|
|
204
|
-
}
|
|
205
|
-
const serverApiDir = path3.join(projectRoot, "server", "api");
|
|
206
|
-
if (fs3.existsSync(serverApiDir)) {
|
|
207
|
-
scanApiDirectory(serverApiDir, serverApiDir, routes);
|
|
208
|
-
}
|
|
209
|
-
const rootLayoutTsx = path3.join(appDir, "layout.tsx");
|
|
210
|
-
const rootLayoutJsx = path3.join(appDir, "layout.jsx");
|
|
211
|
-
if (fs3.existsSync(rootLayoutTsx)) routes.rootLayout = rootLayoutTsx;
|
|
212
|
-
else if (fs3.existsSync(rootLayoutJsx)) routes.rootLayout = rootLayoutJsx;
|
|
213
|
-
routes.tree = buildTree(routes.appRoutes);
|
|
214
|
-
return routes;
|
|
215
|
-
}
|
|
216
|
-
function scanAppDirectory(baseDir, currentDir, routes, parentSegments = [], parentLayout = null, parentMiddleware = null) {
|
|
217
|
-
const entries = fs3.readdirSync(currentDir, { withFileTypes: true });
|
|
218
|
-
const specialFiles = {
|
|
219
|
-
page: null,
|
|
220
|
-
layout: null,
|
|
221
|
-
loading: null,
|
|
222
|
-
error: null,
|
|
223
|
-
notFound: null,
|
|
224
|
-
template: null,
|
|
225
|
-
middleware: null
|
|
226
|
-
};
|
|
227
|
-
for (const entry of entries) {
|
|
228
|
-
if (entry.isFile()) {
|
|
229
|
-
const name = entry.name.replace(/\.(jsx|js|tsx|ts)$/, "");
|
|
230
|
-
const fullPath = path3.join(currentDir, entry.name);
|
|
231
|
-
const ext = path3.extname(entry.name);
|
|
232
|
-
if (![".tsx", ".jsx", ".ts", ".js"].includes(ext)) continue;
|
|
233
|
-
if (name === "page") specialFiles.page = fullPath;
|
|
234
|
-
if (name === "layout") specialFiles.layout = fullPath;
|
|
235
|
-
if (name === "loading") specialFiles.loading = fullPath;
|
|
236
|
-
if (name === "error") specialFiles.error = fullPath;
|
|
237
|
-
if (name === "not-found") specialFiles.notFound = fullPath;
|
|
238
|
-
if (name === "template") specialFiles.template = fullPath;
|
|
239
|
-
if (name === "middleware" || name === "_middleware") specialFiles.middleware = fullPath;
|
|
240
|
-
if (name.startsWith("[") && name.endsWith("]") && [".tsx", ".jsx"].includes(ext)) {
|
|
241
|
-
const paramName = name.slice(1, -1);
|
|
242
|
-
let segmentName;
|
|
243
|
-
if (paramName.startsWith("...")) {
|
|
244
|
-
segmentName = "*" + paramName.slice(3);
|
|
245
|
-
} else {
|
|
246
|
-
segmentName = ":" + paramName;
|
|
247
|
-
}
|
|
248
|
-
const routePath = "/" + [...parentSegments, segmentName].join("/");
|
|
249
|
-
routes.appRoutes.push({
|
|
250
|
-
type: RouteType.PAGE,
|
|
251
|
-
path: routePath.replace(/\/+/g, "/"),
|
|
252
|
-
filePath: fullPath,
|
|
253
|
-
pattern: createRoutePattern(routePath),
|
|
254
|
-
segments: [...parentSegments, segmentName],
|
|
255
|
-
layout: specialFiles.layout || parentLayout,
|
|
256
|
-
loading: specialFiles.loading,
|
|
257
|
-
error: specialFiles.error,
|
|
258
|
-
notFound: specialFiles.notFound,
|
|
259
|
-
template: specialFiles.template,
|
|
260
|
-
middleware: specialFiles.middleware || parentMiddleware,
|
|
261
|
-
isServerComponent: isServerComponent(fullPath),
|
|
262
|
-
isClientComponent: isClientComponent(fullPath),
|
|
263
|
-
isIsland: isIsland(fullPath)
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (specialFiles.page) {
|
|
269
|
-
const routePath = "/" + parentSegments.join("/") || "/";
|
|
270
|
-
routes.appRoutes.push({
|
|
271
|
-
type: RouteType.PAGE,
|
|
272
|
-
path: routePath.replace(/\/+/g, "/") || "/",
|
|
273
|
-
filePath: specialFiles.page,
|
|
274
|
-
pattern: createRoutePattern(routePath || "/"),
|
|
275
|
-
segments: parentSegments,
|
|
276
|
-
layout: specialFiles.layout || parentLayout,
|
|
277
|
-
loading: specialFiles.loading,
|
|
278
|
-
error: specialFiles.error,
|
|
279
|
-
notFound: specialFiles.notFound,
|
|
280
|
-
template: specialFiles.template,
|
|
281
|
-
middleware: specialFiles.middleware || parentMiddleware,
|
|
282
|
-
isServerComponent: isServerComponent(specialFiles.page),
|
|
283
|
-
isClientComponent: isClientComponent(specialFiles.page),
|
|
284
|
-
isIsland: isIsland(specialFiles.page)
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
for (const entry of entries) {
|
|
288
|
-
if (entry.isDirectory()) {
|
|
289
|
-
const fullPath = path3.join(currentDir, entry.name);
|
|
290
|
-
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
291
|
-
const isGroup = entry.name.startsWith("(") && entry.name.endsWith(")");
|
|
292
|
-
let segmentName = entry.name;
|
|
293
|
-
if (entry.name.startsWith("[") && entry.name.endsWith("]")) {
|
|
294
|
-
segmentName = ":" + entry.name.slice(1, -1);
|
|
295
|
-
if (entry.name.startsWith("[...")) {
|
|
296
|
-
segmentName = "*" + entry.name.slice(4, -1);
|
|
297
|
-
}
|
|
298
|
-
if (entry.name.startsWith("[[...")) {
|
|
299
|
-
segmentName = "*" + entry.name.slice(5, -2);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
const newSegments = isGroup ? parentSegments : [...parentSegments, segmentName];
|
|
303
|
-
const newLayout = specialFiles.layout || parentLayout;
|
|
304
|
-
const newMiddleware = specialFiles.middleware || parentMiddleware;
|
|
305
|
-
scanAppDirectory(baseDir, fullPath, routes, newSegments, newLayout, newMiddleware);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
function scanApiDirectory(baseDir, currentDir, routes, parentSegments = []) {
|
|
310
|
-
const entries = fs3.readdirSync(currentDir, { withFileTypes: true });
|
|
311
|
-
for (const entry of entries) {
|
|
312
|
-
const fullPath = path3.join(currentDir, entry.name);
|
|
313
|
-
if (entry.isDirectory()) {
|
|
314
|
-
scanApiDirectory(baseDir, fullPath, routes, [...parentSegments, entry.name]);
|
|
315
|
-
} else if (entry.isFile()) {
|
|
316
|
-
const ext = path3.extname(entry.name);
|
|
317
|
-
if (![".ts", ".js"].includes(ext)) continue;
|
|
318
|
-
const baseName = path3.basename(entry.name, ext);
|
|
319
|
-
const apiSegments = baseName === "route" || baseName === "index" ? parentSegments : [...parentSegments, baseName];
|
|
320
|
-
const apiPath = "/api/" + apiSegments.join("/");
|
|
321
|
-
routes.api.push({
|
|
322
|
-
type: RouteType.API,
|
|
323
|
-
path: apiPath.replace(/\/+/g, "/") || "/api",
|
|
324
|
-
filePath: fullPath,
|
|
325
|
-
pattern: createRoutePattern(apiPath),
|
|
326
|
-
segments: ["api", ...apiSegments].filter(Boolean)
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function createRoutePattern(routePath) {
|
|
332
|
-
let pattern = routePath.replace(/\*[^/]*/g, "(.*)").replace(/:[^/]+/g, "([^/]+)").replace(/\//g, "\\/");
|
|
333
|
-
return new RegExp(`^${pattern}$`);
|
|
334
|
-
}
|
|
335
|
-
function buildTree(routes) {
|
|
336
|
-
const tree = { children: {}, routes: [] };
|
|
337
|
-
for (const route of routes) {
|
|
338
|
-
let current = tree;
|
|
339
|
-
for (const segment of route.segments) {
|
|
340
|
-
if (!current.children[segment]) {
|
|
341
|
-
current.children[segment] = { children: {}, routes: [] };
|
|
342
|
-
}
|
|
343
|
-
current = current.children[segment];
|
|
344
|
-
}
|
|
345
|
-
current.routes.push(route);
|
|
346
|
-
}
|
|
347
|
-
return tree;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// logger.ts
|
|
351
|
-
var colors = {
|
|
352
|
-
reset: "\x1B[0m",
|
|
353
|
-
bold: "\x1B[1m",
|
|
354
|
-
dim: "\x1B[2m",
|
|
355
|
-
red: "\x1B[31m",
|
|
356
|
-
green: "\x1B[32m",
|
|
357
|
-
yellow: "\x1B[33m",
|
|
358
|
-
blue: "\x1B[34m",
|
|
359
|
-
magenta: "\x1B[35m",
|
|
360
|
-
cyan: "\x1B[36m",
|
|
361
|
-
white: "\x1B[37m",
|
|
362
|
-
gray: "\x1B[90m"
|
|
363
|
-
};
|
|
364
|
-
var c = colors;
|
|
365
|
-
function getStatusColor(status) {
|
|
366
|
-
if (status >= 500) return c.red;
|
|
367
|
-
if (status >= 400) return c.yellow;
|
|
368
|
-
if (status >= 300) return c.cyan;
|
|
369
|
-
if (status >= 200) return c.green;
|
|
370
|
-
return c.white;
|
|
371
|
-
}
|
|
372
|
-
function fmtTime(ms) {
|
|
373
|
-
if (ms < 1) return `${c.gray}<1ms${c.reset}`;
|
|
374
|
-
if (ms < 100) return `${c.green}${ms}ms${c.reset}`;
|
|
375
|
-
if (ms < 500) return `${c.yellow}${ms}ms${c.reset}`;
|
|
376
|
-
return `${c.red}${ms}ms${c.reset}`;
|
|
377
|
-
}
|
|
378
|
-
var VERSION = "5.0.0";
|
|
379
|
-
var LOGO = `
|
|
380
|
-
${c.cyan}\u25B2${c.reset} ${c.bold}Velix${c.reset} ${c.dim}v${VERSION}${c.reset}
|
|
381
|
-
`;
|
|
382
|
-
var logger = {
|
|
383
|
-
logo() {
|
|
384
|
-
console.log(LOGO);
|
|
385
|
-
console.log(`${c.dim} \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${c.reset}`);
|
|
386
|
-
console.log("");
|
|
387
|
-
},
|
|
388
|
-
serverStart(config, startTime = Date.now()) {
|
|
389
|
-
const { port, host, mode, pagesDir } = config;
|
|
390
|
-
const elapsed = Date.now() - startTime;
|
|
391
|
-
console.log(LOGO);
|
|
392
|
-
console.log(` ${c.green}\u2714${c.reset} ${c.bold}Ready${c.reset} in ${elapsed}ms`);
|
|
393
|
-
console.log("");
|
|
394
|
-
console.log(` ${c.bold}Local:${c.reset} ${c.cyan}http://${host}:${port}${c.reset}`);
|
|
395
|
-
console.log(` ${c.bold}Mode:${c.reset} ${mode === "development" ? c.yellow : c.green}${mode}${c.reset}`);
|
|
396
|
-
if (pagesDir) console.log(` ${c.bold}App:${c.reset} ${c.dim}${pagesDir}${c.reset}`);
|
|
397
|
-
console.log("");
|
|
398
|
-
},
|
|
399
|
-
request(method, path5, status, time, extra = {}) {
|
|
400
|
-
const statusColor = getStatusColor(status);
|
|
401
|
-
const timeStr = fmtTime(time);
|
|
402
|
-
let badge = `${c.dim}\u25CB${c.reset}`;
|
|
403
|
-
if (extra.type === "dynamic" || extra.type === "ssr") badge = `${c.white}\u0192${c.reset}`;
|
|
404
|
-
else if (extra.type === "api") badge = `${c.cyan}\u03BB${c.reset}`;
|
|
405
|
-
const statusStr = `${statusColor}${status}${c.reset}`;
|
|
406
|
-
console.log(` ${badge} ${c.white}${method}${c.reset} ${path5} ${statusStr} ${c.dim}${timeStr}${c.reset}`);
|
|
407
|
-
},
|
|
408
|
-
info(msg) {
|
|
409
|
-
console.log(` ${c.cyan}\u2139${c.reset} ${msg}`);
|
|
410
|
-
},
|
|
411
|
-
success(msg) {
|
|
412
|
-
console.log(` ${c.green}\u2714${c.reset} ${msg}`);
|
|
413
|
-
},
|
|
414
|
-
warn(msg) {
|
|
415
|
-
console.log(` ${c.yellow}\u26A0${c.reset} ${c.yellow}${msg}${c.reset}`);
|
|
416
|
-
},
|
|
417
|
-
error(msg, err = null) {
|
|
418
|
-
console.log(` ${c.red}\u2716${c.reset} ${c.red}${msg}${c.reset}`);
|
|
419
|
-
if (err?.stack) {
|
|
420
|
-
console.log("");
|
|
421
|
-
console.log(`${c.dim}${err.stack.split("\n").slice(1, 4).join("\n")}${c.reset}`);
|
|
422
|
-
console.log("");
|
|
423
|
-
}
|
|
424
|
-
},
|
|
425
|
-
compile(file, time) {
|
|
426
|
-
console.log(` ${c.white}\u25CF${c.reset} Compiling ${c.dim}${file}${c.reset} ${c.dim}(${time}ms)${c.reset}`);
|
|
427
|
-
},
|
|
428
|
-
hmr(file) {
|
|
429
|
-
console.log(` ${c.green}\u21BB${c.reset} Fast Refresh ${c.dim}${file}${c.reset}`);
|
|
430
|
-
},
|
|
431
|
-
plugin(name) {
|
|
432
|
-
console.log(` ${c.cyan}\u25C6${c.reset} Plugin ${c.dim}${name}${c.reset}`);
|
|
433
|
-
},
|
|
434
|
-
route(path5, type) {
|
|
435
|
-
const typeLabel = type === "api" ? "\u03BB" : type === "dynamic" ? "\u0192" : "\u25CB";
|
|
436
|
-
const color = type === "api" ? c.cyan : type === "dynamic" ? c.white : c.dim;
|
|
437
|
-
console.log(` ${color}${typeLabel}${c.reset} ${path5}`);
|
|
438
|
-
},
|
|
439
|
-
divider() {
|
|
440
|
-
console.log(`${c.dim} \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${c.reset}`);
|
|
441
|
-
},
|
|
442
|
-
blank() {
|
|
443
|
-
console.log("");
|
|
444
|
-
},
|
|
445
|
-
portInUse(port) {
|
|
446
|
-
this.error(`Port ${port} is already in use.`);
|
|
447
|
-
this.blank();
|
|
448
|
-
console.log(` ${c.dim}Try:${c.reset}`);
|
|
449
|
-
console.log(` 1. Kill the process on port ${port}`);
|
|
450
|
-
console.log(` 2. Use a different port via PORT env var`);
|
|
451
|
-
this.blank();
|
|
452
|
-
},
|
|
453
|
-
build(stats) {
|
|
454
|
-
this.blank();
|
|
455
|
-
console.log(` ${c.green}\u2714${c.reset} Build completed`);
|
|
456
|
-
this.blank();
|
|
457
|
-
console.log(` ${c.dim}Total time:${c.reset} ${c.white}${stats.time}ms${c.reset}`);
|
|
458
|
-
this.blank();
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
var logger_default = logger;
|
|
462
|
-
|
|
463
|
-
// build/index.ts
|
|
464
|
-
async function build(options = {}) {
|
|
465
|
-
const projectRoot = options.projectRoot || process.cwd();
|
|
466
|
-
const config = await loadConfig(projectRoot);
|
|
467
|
-
const resolved = resolvePaths(config, projectRoot);
|
|
468
|
-
const outDir = options.outDir || resolved.resolvedOutDir;
|
|
469
|
-
const startTime = Date.now();
|
|
470
|
-
logger_default.logo();
|
|
471
|
-
logger_default.info("Building for production...");
|
|
472
|
-
logger_default.blank();
|
|
473
|
-
cleanDir(outDir);
|
|
474
|
-
const appDir = resolved.resolvedAppDir;
|
|
475
|
-
const routes = buildRouteTree(appDir);
|
|
476
|
-
const sourceFiles = findFiles(appDir, /\.(tsx?|jsx?)$/);
|
|
477
|
-
if (sourceFiles.length === 0) {
|
|
478
|
-
logger_default.warn("No source files found in app/ directory");
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
try {
|
|
482
|
-
const serverOutDir = path4.join(outDir, "server");
|
|
483
|
-
ensureDir(serverOutDir);
|
|
484
|
-
await esbuild.build({
|
|
485
|
-
entryPoints: sourceFiles,
|
|
486
|
-
outdir: serverOutDir,
|
|
487
|
-
bundle: false,
|
|
488
|
-
format: "esm",
|
|
489
|
-
platform: "node",
|
|
490
|
-
target: config.build.target,
|
|
491
|
-
minify: options.minify ?? config.build.minify,
|
|
492
|
-
sourcemap: options.sourcemap ?? config.build.sourcemap,
|
|
493
|
-
jsx: "automatic",
|
|
494
|
-
logLevel: "silent"
|
|
495
|
-
});
|
|
496
|
-
logger_default.success("Server bundle built");
|
|
497
|
-
} catch (err) {
|
|
498
|
-
logger_default.error("Server build failed", err);
|
|
499
|
-
process.exit(1);
|
|
500
|
-
}
|
|
501
|
-
try {
|
|
502
|
-
const clientOutDir = path4.join(outDir, "client");
|
|
503
|
-
ensureDir(clientOutDir);
|
|
504
|
-
const clientFiles = sourceFiles.filter((f) => {
|
|
505
|
-
const content = fs4.readFileSync(f, "utf-8");
|
|
506
|
-
const firstLine = content.split("\n")[0]?.trim();
|
|
507
|
-
return firstLine === "'use client'" || firstLine === '"use client"' || firstLine === "'use island'" || firstLine === '"use island"';
|
|
508
|
-
});
|
|
509
|
-
if (clientFiles.length > 0) {
|
|
510
|
-
await esbuild.build({
|
|
511
|
-
entryPoints: clientFiles,
|
|
512
|
-
outdir: clientOutDir,
|
|
513
|
-
bundle: true,
|
|
514
|
-
format: "esm",
|
|
515
|
-
platform: "browser",
|
|
516
|
-
target: ["es2022"],
|
|
517
|
-
minify: options.minify ?? config.build.minify,
|
|
518
|
-
sourcemap: options.sourcemap ?? config.build.sourcemap,
|
|
519
|
-
splitting: config.build.splitting,
|
|
520
|
-
jsx: "automatic",
|
|
521
|
-
logLevel: "silent",
|
|
522
|
-
external: ["react", "react-dom"]
|
|
523
|
-
});
|
|
524
|
-
logger_default.success(`Client bundle built (${clientFiles.length} components)`);
|
|
525
|
-
}
|
|
526
|
-
} catch (err) {
|
|
527
|
-
logger_default.error("Client build failed", err);
|
|
528
|
-
process.exit(1);
|
|
529
|
-
}
|
|
530
|
-
const publicDir = resolved.resolvedPublicDir;
|
|
531
|
-
if (fs4.existsSync(publicDir)) {
|
|
532
|
-
const publicOutDir = path4.join(outDir, "public");
|
|
533
|
-
ensureDir(publicOutDir);
|
|
534
|
-
copyDirRecursive(publicDir, publicOutDir);
|
|
535
|
-
logger_default.success("Static assets copied");
|
|
536
|
-
}
|
|
537
|
-
const manifest = {
|
|
538
|
-
version: "5.0.0",
|
|
539
|
-
buildTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
540
|
-
routes: routes.appRoutes.map((r) => ({
|
|
541
|
-
path: r.path,
|
|
542
|
-
type: r.path.includes(":") ? "dynamic" : "static"
|
|
543
|
-
})),
|
|
544
|
-
api: routes.api.map((r) => ({ path: r.path }))
|
|
545
|
-
};
|
|
546
|
-
fs4.writeFileSync(path4.join(outDir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
547
|
-
const elapsed = Date.now() - startTime;
|
|
548
|
-
const totalSize = getDirSize(outDir);
|
|
549
|
-
logger_default.blank();
|
|
550
|
-
logger_default.divider();
|
|
551
|
-
logger_default.blank();
|
|
552
|
-
routes.appRoutes.forEach((r) => {
|
|
553
|
-
const type = r.path.includes(":") || r.path.includes("*") ? "dynamic" : "static";
|
|
554
|
-
logger_default.route(r.path, type);
|
|
555
|
-
});
|
|
556
|
-
routes.api.forEach((r) => logger_default.route(r.path, "api"));
|
|
557
|
-
logger_default.blank();
|
|
558
|
-
logger_default.build({ time: elapsed });
|
|
559
|
-
logger_default.info(`Output: ${outDir} (${formatBytes(totalSize)})`);
|
|
560
|
-
logger_default.blank();
|
|
561
|
-
}
|
|
562
|
-
function copyDirRecursive(src, dest) {
|
|
563
|
-
ensureDir(dest);
|
|
564
|
-
const entries = fs4.readdirSync(src, { withFileTypes: true });
|
|
565
|
-
for (const entry of entries) {
|
|
566
|
-
const srcPath = path4.join(src, entry.name);
|
|
567
|
-
const destPath = path4.join(dest, entry.name);
|
|
568
|
-
if (entry.isDirectory()) copyDirRecursive(srcPath, destPath);
|
|
569
|
-
else fs4.copyFileSync(srcPath, destPath);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
function getDirSize(dir) {
|
|
573
|
-
let size = 0;
|
|
574
|
-
if (!fs4.existsSync(dir)) return size;
|
|
575
|
-
const entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
576
|
-
for (const entry of entries) {
|
|
577
|
-
const fullPath = path4.join(dir, entry.name);
|
|
578
|
-
if (entry.isDirectory()) size += getDirSize(fullPath);
|
|
579
|
-
else size += fs4.statSync(fullPath).size;
|
|
580
|
-
}
|
|
581
|
-
return size;
|
|
582
|
-
}
|
|
583
|
-
var build_default = { build };
|
|
584
|
-
export {
|
|
585
|
-
build,
|
|
586
|
-
build_default as default
|
|
587
|
-
};
|
|
1
|
+
export { build, build_default as default } from '../chunk-7SGDYOVZ.js';
|
|
2
|
+
import '../chunk-SPIGTNT7.js';
|
|
3
|
+
import '../chunk-F24Q2MX3.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
588
5
|
//# sourceMappingURL=index.js.map
|