@teamvelix/velix 5.1.4 → 5.1.5

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { build } from './chunk-BXDKUP2L.js';
2
2
  export { LayoutContext, Link, RequestContext, RouteContext, createRequestContext, hydrate, router, useParams, usePathname, useQuery, useRequest, useRouter } from './chunk-INOZP2VD.js';
3
- export { NotFoundError, PluginHooks, PluginManager, RedirectError, bindArgs, callServerAction, composeMiddleware, cookies, createServer, definePlugin, deserializeArgs, executeAction, formAction, generateJsonLd, generateMetadataTags, generateRobotsTxt, generateSitemap, getAction, getMethod, getPathname, headers, html, isMethod, json, jsonLd, loadMiddleware, loadPlugins, mergeMetadata, middlewares, notFound, parseFormData, parseJson, parseSearchParams, pluginManager, redirect, registerAction, runMiddleware, serverAction, tailwindPlugin, text, useActionContext, useActionState, useFormStatus, useOptimistic, useVelixAction } from './chunk-PB3226UC.js';
3
+ export { NotFoundError, PluginHooks, PluginManager, RedirectError, bindArgs, callServerAction, composeMiddleware, cookies, createServer, definePlugin, deserializeArgs, executeAction, formAction, generateJsonLd, generateMetadataTags, generateRobotsTxt, generateSitemap, getAction, getMethod, getPathname, headers, html, isMethod, json, jsonLd, loadMiddleware, loadPlugins, mergeMetadata, middlewares, notFound, parseFormData, parseJson, parseSearchParams, pluginManager, redirect, registerAction, runMiddleware, serverAction, tailwindPlugin, text, useActionContext, useActionState, useFormStatus, useOptimistic, useVelixAction } from './chunk-TGNK4MY5.js';
4
4
  export { buildRouteTree, cleanDir, copyDir, debounce, ensureDir, escapeHtml, findFiles, findRouteLayouts, formatBytes, formatTime, generateHash, isClientComponent, isIsland as isIslandComponent, isServerComponent, logger, matchRoute, sleep } from './chunk-RFWV4CDG.js';
5
5
  export { VelixConfigSchema, defaultConfig, defineConfig, loadConfig, resolvePaths } from './chunk-F24Q2MX3.js';
6
6
  export { Island, LoadStrategy, createIsland, createLazyIsland, generateAdvancedHydrationScript, generateHydrationScript, getRegisteredIslands } from './chunk-OIZNYND3.js';
@@ -98,6 +98,7 @@ import http from "http";
98
98
  import fs7 from "fs";
99
99
  import path7 from "path";
100
100
  import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL3 } from "url";
101
+ import { createRequire } from "module";
101
102
  import React2 from "react";
102
103
  import { renderToString } from "react-dom/server";
103
104
 
@@ -1281,14 +1282,16 @@ var ICON_GEAR = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" str
1281
1282
  var ICON_MON = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>`;
1282
1283
  var ICON_TS = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 7 4 4 20 4 20 7"/><line x1="9" y1="20" x2="15" y2="20"/><line x1="12" y1="4" x2="12" y2="20"/></svg>`;
1283
1284
  var ICON_CLOCK = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>`;
1284
- var ICON_TRI = `<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2L2 19h20L12 2z"/></svg>`;
1285
1285
  var ICON_TERM = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/></svg>`;
1286
+ 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'" />`;
1286
1287
  function generateDevToolsHtml(isDev, ctx = {}) {
1287
1288
  if (!isDev) return "";
1288
1289
  const version = ctx.version ?? "5.1.0";
1289
1290
  const port = ctx.port ?? 3e3;
1290
1291
  const host = ctx.host ?? "localhost";
1291
1292
  const nodeVersion = ctx.nodeVersion ?? process.version.replace("v", "");
1293
+ const reactVersion = ctx.reactVersion ?? "\u2014";
1294
+ const tsVersion = ctx.tsVersion ?? "\u2014";
1292
1295
  return `
1293
1296
  <style>
1294
1297
  /* \u2500\u2500 Velix DevTools v5.1 \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 */
@@ -1357,7 +1360,7 @@ function generateDevToolsHtml(isDev, ctx = {}) {
1357
1360
 
1358
1361
  <!-- \u2500\u2500 Floating button \u2500\u2500 -->
1359
1362
  <button id="__vdt-btn" class="vdt-idle" onclick="__vdtOpen()" title="Velix DevTools (${version})">
1360
- ${ICON_TRI}
1363
+ ${ICON_LOGO}
1361
1364
  <div id="__vdt-dot" class="idle"></div>
1362
1365
  </button>
1363
1366
 
@@ -1366,7 +1369,7 @@ function generateDevToolsHtml(isDev, ctx = {}) {
1366
1369
  <!-- Header -->
1367
1370
  <div class="__vdt-header">
1368
1371
  <div class="__vdt-brand">
1369
- ${ICON_TRI}
1372
+ ${ICON_LOGO}
1370
1373
  Velix
1371
1374
  <span class="__vdt-badge">${version}</span>
1372
1375
  </div>
@@ -1432,12 +1435,12 @@ function generateDevToolsHtml(isDev, ctx = {}) {
1432
1435
  <!-- Tab: Info -->
1433
1436
  <div class="__vdt-body" id="__vtab-info" style="display:none;">
1434
1437
  <div class="__vdt-info-row">
1435
- <div class="__vdt-info-left">${ICON_TRI} <span>Velix</span></div>
1438
+ <div class="__vdt-info-left">${ICON_LOGO} <span>Velix</span></div>
1436
1439
  <span class="__vdt-info-val">${version}</span>
1437
1440
  </div>
1438
1441
  <div class="__vdt-info-row">
1439
1442
  <div class="__vdt-info-left">${ICON_GEAR} <span>React</span></div>
1440
- <span class="__vdt-info-val" id="__vdt-react-ver">\u2014</span>
1443
+ <span class="__vdt-info-val" id="__vdt-react-ver">${reactVersion}</span>
1441
1444
  </div>
1442
1445
  <div class="__vdt-info-row">
1443
1446
  <div class="__vdt-info-left">${ICON_MON} <span>Node.js</span></div>
@@ -1445,7 +1448,7 @@ function generateDevToolsHtml(isDev, ctx = {}) {
1445
1448
  </div>
1446
1449
  <div class="__vdt-info-row">
1447
1450
  <div class="__vdt-info-left">${ICON_TS} <span>TypeScript</span></div>
1448
- <span class="__vdt-info-val" id="__vdt-ts-ver">\u2014</span>
1451
+ <span class="__vdt-info-val" id="__vdt-ts-ver">${tsVersion}</span>
1449
1452
  </div>
1450
1453
  <div class="__vdt-dev-badge">
1451
1454
  ${ICON_TERM} Development mode active
@@ -1543,13 +1546,13 @@ function generateDevToolsHtml(isDev, ctx = {}) {
1543
1546
  var btel = document.getElementById('__vdt-build-time');
1544
1547
  if(btel) btel.textContent = bt ? bt + 'ms' : '\u2014';
1545
1548
 
1546
- /* React version from window.React */
1549
+ /* React version from window.React or server injection */
1547
1550
  var rv = document.getElementById('__vdt-react-ver');
1548
- if(rv && window.React) rv.textContent = window.React.version;
1551
+ if(rv && rv.textContent === '\u2014' && window.React) rv.textContent = window.React.version;
1549
1552
 
1550
1553
  /* TypeScript version (injected by server if available) */
1551
1554
  var tsv = document.getElementById('__vdt-ts-ver');
1552
- if(tsv) tsv.textContent = window.__VELIX_TS_VERSION__ || '\u2014';
1555
+ if(tsv && tsv.textContent === '\u2014') tsv.textContent = window.__VELIX_TS_VERSION__ || '\u2014';
1553
1556
 
1554
1557
  /* \u2500\u2500 HMR + Status \u2500\u2500 */
1555
1558
  var btn = document.getElementById('__vdt-btn');
@@ -2113,6 +2116,19 @@ function generate500Page(options) {
2113
2116
  }
2114
2117
 
2115
2118
  // server/index.ts
2119
+ function getProjectVersion(dep, projectRoot) {
2120
+ try {
2121
+ const projectRequire = createRequire(pathToFileURL3(path7.join(projectRoot, "package.json")).href);
2122
+ return projectRequire(`${dep}/package.json`).version;
2123
+ } catch (e) {
2124
+ try {
2125
+ const selfRequire = createRequire(import.meta.url);
2126
+ return selfRequire(`${dep}/package.json`).version;
2127
+ } catch (e2) {
2128
+ return "\u2014";
2129
+ }
2130
+ }
2131
+ }
2116
2132
  var MIME_TYPES = {
2117
2133
  ".html": "text/html; charset=utf-8",
2118
2134
  ".css": "text/css; charset=utf-8",
@@ -2423,11 +2439,15 @@ async function handlePageRoute(route, routes, req, res, url, config, isDev, proj
2423
2439
  }, baseUrl);
2424
2440
  const islands = getRegisteredIslands();
2425
2441
  const hydrationScript = generateAdvancedHydrationScript(islands);
2442
+ const reactVersion = getProjectVersion("react", projectRoot);
2443
+ const tsVersion = getProjectVersion("typescript", projectRoot);
2426
2444
  const devToolsHtml = generateDevToolsHtml(isDev, {
2427
2445
  version: VERSION,
2428
2446
  port: config.server.port,
2429
2447
  host: config.server.host,
2430
- nodeVersion: process.version.replace("v", "")
2448
+ nodeVersion: process.version.replace("v", ""),
2449
+ reactVersion,
2450
+ tsVersion
2431
2451
  });
2432
2452
  const headInjections = `
2433
2453
  <meta charset="utf-8">