@teamvelix/velix 5.2.1 → 5.2.3
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 +2 -2
- package/dist/{chunk-XXPHGRLC.js → chunk-3LWUS6AC.js} +3 -3
- package/dist/{chunk-XXPHGRLC.js.map → chunk-3LWUS6AC.js.map} +1 -1
- package/dist/{chunk-DTF3KTLR.js → chunk-65A3SPZE.js} +81 -36
- package/dist/chunk-65A3SPZE.js.map +1 -0
- package/dist/{chunk-QIPVMOXL.js → chunk-MLLSS7Y5.js} +3 -3
- package/dist/{chunk-QIPVMOXL.js.map → chunk-MLLSS7Y5.js.map} +1 -1
- package/dist/index.d.ts +4 -7
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime/start-build.js +1 -1
- package/dist/runtime/start-build.js.map +1 -1
- package/dist/runtime/start-dev.js +80 -32
- package/dist/runtime/start-dev.js.map +1 -1
- package/dist/runtime/start-prod.js +79 -31
- package/dist/runtime/start-prod.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-DTF3KTLR.js.map +0 -1
|
@@ -701,7 +701,7 @@ init_esm_shims();
|
|
|
701
701
|
|
|
702
702
|
// version.ts
|
|
703
703
|
init_esm_shims();
|
|
704
|
-
var VERSION = "5.
|
|
704
|
+
var VERSION = "5.2.3";
|
|
705
705
|
|
|
706
706
|
// logger.ts
|
|
707
707
|
var colors = {
|
|
@@ -1065,6 +1065,8 @@ import { useFormStatus } from "react-dom";
|
|
|
1065
1065
|
|
|
1066
1066
|
// helpers.ts
|
|
1067
1067
|
init_esm_shims();
|
|
1068
|
+
import { NotFoundError as CoreNotFoundError } from "@teamvelix/velix-core";
|
|
1069
|
+
import { NotFoundError } from "@teamvelix/velix-core";
|
|
1068
1070
|
var RedirectError = class extends Error {
|
|
1069
1071
|
url;
|
|
1070
1072
|
statusCode;
|
|
@@ -1076,19 +1078,12 @@ var RedirectError = class extends Error {
|
|
|
1076
1078
|
this.statusCode = statusCode;
|
|
1077
1079
|
}
|
|
1078
1080
|
};
|
|
1079
|
-
var NotFoundError = class extends Error {
|
|
1080
|
-
type = "notFound";
|
|
1081
|
-
constructor(message = "Page not found") {
|
|
1082
|
-
super(message);
|
|
1083
|
-
this.name = "NotFoundError";
|
|
1084
|
-
}
|
|
1085
|
-
};
|
|
1086
1081
|
function redirect(url, type = "replace") {
|
|
1087
1082
|
const statusCode = type === "permanent" ? 308 : 307;
|
|
1088
1083
|
throw new RedirectError(url, statusCode);
|
|
1089
1084
|
}
|
|
1090
1085
|
function notFound(message) {
|
|
1091
|
-
throw new
|
|
1086
|
+
throw new CoreNotFoundError(message);
|
|
1092
1087
|
}
|
|
1093
1088
|
var cookies = {
|
|
1094
1089
|
parse(cookieHeader) {
|
|
@@ -1297,7 +1292,7 @@ var ICON_TERM = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" str
|
|
|
1297
1292
|
var ICON_LOGO = `<img src="/__velix/logo.webp" alt="Velix Logo" width="14" height="14" style="border-radius:2px; object-fit:cover;" onerror="this.style.display='none'" />`;
|
|
1298
1293
|
function generateDevToolsHtml(isDev, ctx = {}) {
|
|
1299
1294
|
if (!isDev) return "";
|
|
1300
|
-
const version = ctx.version ??
|
|
1295
|
+
const version = ctx.version ?? VERSION;
|
|
1301
1296
|
const port = ctx.port ?? 3e3;
|
|
1302
1297
|
const host = ctx.host ?? "localhost";
|
|
1303
1298
|
const nodeVersion = ctx.nodeVersion ?? process.version.replace("v", "");
|
|
@@ -1582,33 +1577,41 @@ function generateDevToolsHtml(isDev, ctx = {}) {
|
|
|
1582
1577
|
if(connText) connText.style.color = ok ? '#10b981' : '#ef4444';
|
|
1583
1578
|
}
|
|
1584
1579
|
|
|
1585
|
-
var
|
|
1580
|
+
var ws = new WebSocket('ws://' + window.location.host + '/__velix_hmr');
|
|
1581
|
+
|
|
1582
|
+
ws.onopen = function(){ setConn(true); };
|
|
1586
1583
|
|
|
1587
|
-
|
|
1584
|
+
ws.onmessage = function(e){
|
|
1585
|
+
var data;
|
|
1586
|
+
try {
|
|
1587
|
+
data = JSON.parse(e.data);
|
|
1588
|
+
} catch(err) { return; }
|
|
1588
1589
|
|
|
1589
|
-
|
|
1590
|
-
var data = e.data;
|
|
1591
|
-
if(data === 'reload'){
|
|
1590
|
+
if(data.type === 'full-reload'){
|
|
1592
1591
|
setStatus('navigating');
|
|
1593
1592
|
setTimeout(function(){ location.reload(); }, 120);
|
|
1594
|
-
} else if(data === '
|
|
1593
|
+
} else if(data.type === 'compile-start'){
|
|
1595
1594
|
setStatus('compiling');
|
|
1596
|
-
} else if(data === '
|
|
1595
|
+
} else if(data.type === 'compile-done'){
|
|
1597
1596
|
setStatus('idle');
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
} else if(data.startsWith('error:')){
|
|
1597
|
+
var btel = document.getElementById('__vdt-build-time');
|
|
1598
|
+
if(btel) btel.textContent = data.duration + 'ms';
|
|
1599
|
+
} else if(data.type === 'compile-error'){
|
|
1602
1600
|
setStatus('error');
|
|
1603
1601
|
}
|
|
1604
1602
|
};
|
|
1605
1603
|
|
|
1606
|
-
|
|
1607
|
-
if(
|
|
1604
|
+
ws.onerror = function(){
|
|
1605
|
+
if(ws.readyState === 2 || ws.readyState === 3){
|
|
1608
1606
|
setStatus('error');
|
|
1609
1607
|
setConn(false);
|
|
1610
1608
|
}
|
|
1611
1609
|
};
|
|
1610
|
+
|
|
1611
|
+
ws.onclose = function(){
|
|
1612
|
+
setStatus('error');
|
|
1613
|
+
setConn(false);
|
|
1614
|
+
};
|
|
1612
1615
|
|
|
1613
1616
|
setStatus('idle');
|
|
1614
1617
|
})();
|
|
@@ -2260,13 +2263,13 @@ async function createServer(options = {}) {
|
|
|
2260
2263
|
}
|
|
2261
2264
|
}
|
|
2262
2265
|
});
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
}
|
|
2266
|
+
if (isDev) {
|
|
2267
|
+
const { createHMRServer } = await import("@teamvelix/velix-core");
|
|
2268
|
+
const hmr = createHMRServer(server, projectRoot);
|
|
2269
|
+
server.broadcastHMR = (msg) => {
|
|
2270
|
+
hmr.broadcast(msg);
|
|
2271
|
+
};
|
|
2272
|
+
}
|
|
2270
2273
|
const port = config.server.port;
|
|
2271
2274
|
const host = config.server.host;
|
|
2272
2275
|
server.listen(port, host, () => {
|
|
@@ -2477,8 +2480,53 @@ async function handlePageRoute(route, routes, req, res, url, config, isDev, proj
|
|
|
2477
2480
|
${config.favicon ? `<link rel="icon" href="${config.favicon}">` : ""}
|
|
2478
2481
|
${config.styles.map((s) => `<link rel="stylesheet" href="${s}">`).join("\n ")}
|
|
2479
2482
|
`;
|
|
2483
|
+
const { resolveErrorBoundary, getErrorBoundaryType } = await import("@teamvelix/velix-core");
|
|
2484
|
+
const { VelixErrorBoundary, VelixDefaultErrorPage } = await import("@teamvelix/velix-react");
|
|
2485
|
+
const errorBoundary = resolveErrorBoundary(route.filePath, appDir, "error");
|
|
2486
|
+
const notFoundBoundary = resolveErrorBoundary(route.filePath, appDir, "not-found");
|
|
2487
|
+
let ErrorComponent = null;
|
|
2488
|
+
let NotFoundComponent = null;
|
|
2489
|
+
if (errorBoundary) {
|
|
2490
|
+
try {
|
|
2491
|
+
const mod2 = await import(`${pathToFileURL3(errorBoundary.filePath).href}?t=${Date.now()}`);
|
|
2492
|
+
ErrorComponent = mod2.default;
|
|
2493
|
+
} catch (e) {
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
if (notFoundBoundary) {
|
|
2497
|
+
try {
|
|
2498
|
+
const mod2 = await import(`${pathToFileURL3(notFoundBoundary.filePath).href}?t=${Date.now()}`);
|
|
2499
|
+
NotFoundComponent = mod2.default;
|
|
2500
|
+
} catch (e) {
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2480
2503
|
const searchParams = Object.fromEntries(url.searchParams.entries());
|
|
2481
|
-
let pageElement
|
|
2504
|
+
let pageElement;
|
|
2505
|
+
try {
|
|
2506
|
+
pageElement = await renderComponentAsync(PageComponent, { params: route.params, searchParams, query: searchParams });
|
|
2507
|
+
} catch (ssrError) {
|
|
2508
|
+
const err = ssrError;
|
|
2509
|
+
const errorType = getErrorBoundaryType(err);
|
|
2510
|
+
res.statusCode = err.status || (errorType === "not-found" ? 404 : 500);
|
|
2511
|
+
if (errorType === "not-found" && NotFoundComponent) {
|
|
2512
|
+
pageElement = React2.createElement(NotFoundComponent);
|
|
2513
|
+
} else if (ErrorComponent) {
|
|
2514
|
+
pageElement = React2.createElement(ErrorComponent, { error: err, reset: () => {
|
|
2515
|
+
} });
|
|
2516
|
+
} else {
|
|
2517
|
+
pageElement = React2.createElement(VelixDefaultErrorPage, { error: err, reset: () => {
|
|
2518
|
+
} });
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
pageElement = React2.createElement(
|
|
2522
|
+
VelixErrorBoundary,
|
|
2523
|
+
{
|
|
2524
|
+
errorComponent: ErrorComponent,
|
|
2525
|
+
notFoundComponent: NotFoundComponent,
|
|
2526
|
+
routePath: route.filePath
|
|
2527
|
+
},
|
|
2528
|
+
pageElement
|
|
2529
|
+
);
|
|
2482
2530
|
let layoutElement = pageElement;
|
|
2483
2531
|
for (let i = layoutModules.length - 1; i >= 0; i--) {
|
|
2484
2532
|
const layoutMod = layoutModules[i];
|