@teamvelix/velix 5.1.7 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/build/index.js +3 -2
  2. package/dist/chunk-4S5YQJHB.js +11 -0
  3. package/dist/chunk-4S5YQJHB.js.map +1 -0
  4. package/dist/{chunk-CFDPNOWM.js → chunk-DTF3KTLR.js} +82 -31
  5. package/dist/chunk-DTF3KTLR.js.map +1 -0
  6. package/dist/{chunk-OIZNYND3.js → chunk-JI2HJFUT.js} +2 -2
  7. package/dist/chunk-JI2HJFUT.js.map +1 -0
  8. package/dist/{chunk-X2EZAAQS.js → chunk-QIPVMOXL.js} +4 -4
  9. package/dist/chunk-QIPVMOXL.js.map +1 -0
  10. package/dist/{chunk-INOZP2VD.js → chunk-QLFG6PW3.js} +3 -2
  11. package/dist/chunk-QLFG6PW3.js.map +1 -0
  12. package/dist/{chunk-SB5DCDTH.js → chunk-XXPHGRLC.js} +3 -3
  13. package/dist/{chunk-SB5DCDTH.js.map → chunk-XXPHGRLC.js.map} +1 -1
  14. package/dist/client/index.d.ts +2 -1
  15. package/dist/client/index.js +2 -1
  16. package/dist/config.js +1 -0
  17. package/dist/{image-optimizer-I6TWWH6W.js → image-optimizer-KPRXE5VI.js} +3 -3
  18. package/dist/image-optimizer-KPRXE5VI.js.map +1 -0
  19. package/dist/index-8CqitL9K.d.ts +300 -0
  20. package/dist/{index-C4udNtpZ.d.ts → index-ChyKLf1W.d.ts} +18 -3
  21. package/dist/index.d.ts +53 -176
  22. package/dist/index.js +12 -6
  23. package/dist/index.js.map +1 -1
  24. package/dist/islands/index.d.ts +22 -10
  25. package/dist/islands/index.js +2 -1
  26. package/dist/runtime/start-build.js +2 -2
  27. package/dist/runtime/start-build.js.map +1 -1
  28. package/dist/runtime/start-dev.js +81 -22
  29. package/dist/runtime/start-dev.js.map +1 -1
  30. package/dist/runtime/start-prod.js +81 -22
  31. package/dist/runtime/start-prod.js.map +1 -1
  32. package/dist/server/index.d.ts +3 -1
  33. package/dist/server/index.js +4 -3
  34. package/package.json +60 -58
  35. package/dist/chunk-CFDPNOWM.js.map +0 -1
  36. package/dist/chunk-INOZP2VD.js.map +0 -1
  37. package/dist/chunk-OIZNYND3.js.map +0 -1
  38. package/dist/chunk-X2EZAAQS.js.map +0 -1
  39. package/dist/image-optimizer-I6TWWH6W.js.map +0 -1
  40. package/dist/index-DYgxL3mE.d.ts +0 -107
@@ -1,5 +1,6 @@
1
- export { build, build_default as default } from '../chunk-SB5DCDTH.js';
2
- import '../chunk-X2EZAAQS.js';
1
+ export { build, build_default as default } from '../chunk-XXPHGRLC.js';
2
+ import '../chunk-QIPVMOXL.js';
3
3
  import '../chunk-F24Q2MX3.js';
4
+ import '../chunk-4S5YQJHB.js';
4
5
  //# sourceMappingURL=index.js.map
5
6
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+
4
+ // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postc_36112cdf9ab6125b194fc7941daee874/node_modules/tsup/assets/esm_shims.js
5
+ var getFilename = () => fileURLToPath(import.meta.url);
6
+ var getDirname = () => path.dirname(getFilename());
7
+ var __dirname$1 = /* @__PURE__ */ getDirname();
8
+
9
+ export { __dirname$1 as __dirname };
10
+ //# sourceMappingURL=chunk-4S5YQJHB.js.map
11
+ //# sourceMappingURL=chunk-4S5YQJHB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postc_36112cdf9ab6125b194fc7941daee874/node_modules/tsup/assets/esm_shims.js"],"names":["__dirname"],"mappings":";;;;AAIA,IAAM,WAAA,GAAc,MAAM,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AACvD,IAAM,UAAA,GAAa,MAAM,IAAA,CAAK,OAAA,CAAQ,aAAa,CAAA;AAE5C,IAAMA,8BAA4B,UAAA","file":"chunk-4S5YQJHB.js","sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"]}
@@ -1,6 +1,7 @@
1
- import { logger_default, buildRouteTree, matchRoute, VERSION } from './chunk-X2EZAAQS.js';
1
+ import { logger_default, buildRouteTree, matchRoute, VERSION } from './chunk-QIPVMOXL.js';
2
2
  import { loadConfig, resolvePaths } from './chunk-F24Q2MX3.js';
3
- import { getRegisteredIslands, generateAdvancedHydrationScript } from './chunk-OIZNYND3.js';
3
+ import { getRegisteredIslands, generateAdvancedHydrationScript } from './chunk-JI2HJFUT.js';
4
+ import { __dirname as __dirname$1 } from './chunk-4S5YQJHB.js';
4
5
  import http from 'http';
5
6
  import fs4 from 'fs';
6
7
  import path4 from 'path';
@@ -12,6 +13,7 @@ import { renderToString } from 'react-dom/server';
12
13
  import { spawnSync, spawn } from 'child_process';
13
14
  export { useFormStatus } from 'react-dom';
14
15
  import esbuild from 'esbuild';
16
+ export { VelixHttpError, buildApiManifest, defineLoader, defineRoute, handleApiRequest, serverAction as serverAction2 } from '@teamvelix/velix-core';
15
17
 
16
18
  var middlewares = {
17
19
  cors(options = {}) {
@@ -82,7 +84,8 @@ async function loadMiddleware(projectRoot) {
82
84
  break;
83
85
  }
84
86
  } catch (err) {
85
- console.warn(`\u26A0 Failed to load proxy ${file}: ${err.message}`);
87
+ const error = err;
88
+ console.warn(`\u26A0 Failed to load proxy ${file}: ${error.message}`);
86
89
  }
87
90
  }
88
91
  return fns;
@@ -267,11 +270,12 @@ async function loadPlugins(projectRoot, config) {
267
270
  console.warn(`\u26A0 Plugin not found: ${entry}`);
268
271
  }
269
272
  }
270
- } else if (typeof entry === "object" && entry.name) {
273
+ } else if (typeof entry === "object" && entry !== null && "name" in entry) {
271
274
  pluginManager.register(entry);
272
275
  }
273
276
  } catch (err) {
274
- console.warn(`\u26A0 Failed to load plugin: ${err.message}`);
277
+ const error = err;
278
+ console.warn(`\u26A0 Failed to load plugin: ${error?.message || String(error)}`);
275
279
  }
276
280
  }
277
281
  }
@@ -286,10 +290,11 @@ function definePlugin(definition) {
286
290
  name: "velix:security",
287
291
  hooks: {
288
292
  [PluginHooks.RESPONSE]: (_req, res) => {
289
- if (!res.headersSent) {
290
- res.setHeader("X-Content-Type-Options", "nosniff");
291
- res.setHeader("X-Frame-Options", "DENY");
292
- res.setHeader("X-XSS-Protection", "1; mode=block");
293
+ const response = res;
294
+ if (!response.headersSent) {
295
+ response.setHeader("X-Content-Type-Options", "nosniff");
296
+ response.setHeader("X-Frame-Options", "DENY");
297
+ response.setHeader("X-XSS-Protection", "1; mode=block");
293
298
  }
294
299
  }
295
300
  }
@@ -301,7 +306,8 @@ function definePlugin(definition) {
301
306
  name: "velix:logger",
302
307
  hooks: {
303
308
  [PluginHooks.RESPONSE]: (req, _res, duration) => {
304
- console.log(` ${req.method} ${req.url} ${duration}ms`);
309
+ const request = req;
310
+ console.log(` ${request.method} ${request.url} ${duration}ms`);
305
311
  }
306
312
  }
307
313
  })
@@ -327,7 +333,8 @@ function tailwindPlugin(options = {}) {
327
333
  return definePlugin({
328
334
  name: "velix:tailwind",
329
335
  hooks: {
330
- [PluginHooks.CONFIG]: (config) => {
336
+ [PluginHooks.CONFIG]: (configArg) => {
337
+ const config = configArg;
331
338
  const relativeOutput = output.startsWith("./") ? output.substring(1) : output;
332
339
  const stylePath = relativeOutput.startsWith("/public") ? relativeOutput.substring(7) : relativeOutput;
333
340
  if (!config.styles) config.styles = [];
@@ -351,7 +358,8 @@ function tailwindPlugin(options = {}) {
351
358
  logger_default.error("Tailwind build failed", err);
352
359
  }
353
360
  },
354
- [PluginHooks.SERVER_START]: async (server, isDev) => {
361
+ [PluginHooks.SERVER_START]: async (server, isDevArg) => {
362
+ const isDev = isDevArg;
355
363
  if (!isDev) return;
356
364
  if (!fs4.existsSync(input)) {
357
365
  logger_default.warn(`Tailwind input file not found: ${input}`);
@@ -858,7 +866,8 @@ async function executeAction(actionId, args, context) {
858
866
  try {
859
867
  const result = await action(...args);
860
868
  return { success: true, data: result };
861
- } catch (error) {
869
+ } catch (err) {
870
+ const error = err;
862
871
  if (error instanceof RedirectError) return { success: true, redirect: error.url };
863
872
  if (error instanceof NotFoundError) return { success: false, error: "Not found" };
864
873
  return { success: false, error: error.message || "Action failed" };
@@ -880,7 +889,8 @@ async function callServerAction(actionId, args) {
880
889
  window.location.href = result.redirect;
881
890
  }
882
891
  return result;
883
- } catch (error) {
892
+ } catch (err) {
893
+ const error = err;
884
894
  return { success: false, error: error.message || "Network error" };
885
895
  }
886
896
  }
@@ -953,7 +963,8 @@ function formAction(action) {
953
963
  try {
954
964
  const result = await action(formData);
955
965
  return { success: true, data: result };
956
- } catch (error) {
966
+ } catch (err) {
967
+ const error = err;
957
968
  if (error instanceof RedirectError) return { success: true, redirect: error.url };
958
969
  return { success: false, error: error.message };
959
970
  }
@@ -1810,8 +1821,6 @@ function generate500Page(options) {
1810
1821
  </body>
1811
1822
  </html>`;
1812
1823
  }
1813
-
1814
- // server/index.ts
1815
1824
  function getProjectVersion(dep, projectRoot) {
1816
1825
  try {
1817
1826
  const projectRequire = createRequire(pathToFileURL(path4.join(projectRoot, "package.json")).href);
@@ -1893,7 +1902,7 @@ async function createServer(options = {}) {
1893
1902
  return;
1894
1903
  }
1895
1904
  if (pathname === "/__velix/image") {
1896
- const { handleImageOptimization } = await import('./image-optimizer-I6TWWH6W.js');
1905
+ const { handleImageOptimization } = await import('./image-optimizer-KPRXE5VI.js');
1897
1906
  await handleImageOptimization(req, res, projectRoot);
1898
1907
  return;
1899
1908
  }
@@ -1922,13 +1931,14 @@ async function createServer(options = {}) {
1922
1931
  res.end(generate404Page(pathname));
1923
1932
  if (isDev) logger_default.request(req.method || "GET", pathname, 404, Date.now() - requestStart);
1924
1933
  } catch (error) {
1934
+ const err = error;
1925
1935
  console.error("Server error:", error);
1926
1936
  if (!res.headersSent) {
1927
1937
  res.writeHead(500, { "Content-Type": "text/html; charset=utf-8" });
1928
1938
  res.end(generate500Page({
1929
1939
  title: "Server Error",
1930
- message: error.message || "An unexpected error occurred",
1931
- stack: isDev ? error.stack : void 0,
1940
+ message: err.message || "An unexpected error occurred",
1941
+ stack: isDev ? err.stack : void 0,
1932
1942
  isDev,
1933
1943
  pathname
1934
1944
  }));
@@ -2085,8 +2095,9 @@ async function handleApiRoute(route, req, res, url) {
2085
2095
  res.end(String(response));
2086
2096
  }
2087
2097
  } catch (err) {
2098
+ const error = err;
2088
2099
  res.writeHead(500, { "Content-Type": "application/json" });
2089
- res.end(JSON.stringify({ error: err.message }));
2100
+ res.end(JSON.stringify({ error: error.message }));
2090
2101
  }
2091
2102
  }
2092
2103
  async function handleServerAction(req, res) {
@@ -2102,8 +2113,9 @@ async function handleServerAction(req, res) {
2102
2113
  res.writeHead(200, { "Content-Type": "application/json" });
2103
2114
  res.end(JSON.stringify(result));
2104
2115
  } catch (err) {
2116
+ const error = err;
2105
2117
  res.writeHead(500, { "Content-Type": "application/json" });
2106
- res.end(JSON.stringify({ success: false, error: err.message }));
2118
+ res.end(JSON.stringify({ success: false, error: error.message }));
2107
2119
  }
2108
2120
  }
2109
2121
  async function handlePageRoute(route, routes, req, res, url, config, isDev, projectRoot) {
@@ -2168,9 +2180,14 @@ async function handlePageRoute(route, routes, req, res, url, config, isDev, proj
2168
2180
  const headInjectionsHtml = `
2169
2181
  ${headInjections}
2170
2182
  `;
2183
+ const hmrScript = isDev ? `
2184
+ <script type="module">
2185
+ import { initHMRClient, VelixDevOverlay } from '/__velix/hmr-client.js';
2186
+ initHMRClient();
2187
+ </script>` : "";
2171
2188
  const bodyInjectionsHtml = `
2172
2189
  <div id="__velix-islands"></div>
2173
- ${hydrationScript}${devToolsHtml}
2190
+ ${hydrationScript}${devToolsHtml}${hmrScript}
2174
2191
  `;
2175
2192
  if (finalHtml.includes("<html")) {
2176
2193
  const headEnd = finalHtml.lastIndexOf("</head>");
@@ -2206,12 +2223,13 @@ async function handlePageRoute(route, routes, req, res, url, config, isDev, proj
2206
2223
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
2207
2224
  res.end(finalHtml);
2208
2225
  } catch (err) {
2209
- logger_default.error(`Render error: ${route.path}`, err);
2226
+ const error = err;
2227
+ logger_default.error(`Render error: ${route.path}`, error);
2210
2228
  res.writeHead(500, { "Content-Type": "text/html; charset=utf-8" });
2211
2229
  res.end(generate500Page({
2212
2230
  title: "Render Error",
2213
- message: err.message || "Failed to render page",
2214
- stack: isDev ? err.stack : void 0,
2231
+ message: error.message || "Failed to render page",
2232
+ stack: isDev ? error.stack : void 0,
2215
2233
  isDev,
2216
2234
  pathname: route.path
2217
2235
  }));
@@ -2254,6 +2272,38 @@ async function serveVelixInternal(pathname, req, res, projectRoot) {
2254
2272
  }
2255
2273
  return;
2256
2274
  }
2275
+ if (pathname === "/__velix/hmr-client.js") {
2276
+ try {
2277
+ const candidates = [
2278
+ path4.join(process.cwd(), "packages", "velix-react", "src", "hmr", "hmr-client.ts"),
2279
+ path4.join(process.cwd(), "node_modules", "@teamvelix", "velix-react", "src", "hmr", "hmr-client.ts"),
2280
+ path4.join(__dirname$1, "..", "..", "velix-react", "src", "hmr", "hmr-client.ts")
2281
+ ];
2282
+ const hmrClientSrc = candidates.find((p) => fs4.existsSync(p));
2283
+ if (!hmrClientSrc) {
2284
+ res.writeHead(404);
2285
+ res.end();
2286
+ return;
2287
+ }
2288
+ const result = await esbuild.build({
2289
+ entryPoints: [hmrClientSrc],
2290
+ bundle: true,
2291
+ format: "esm",
2292
+ platform: "browser",
2293
+ target: ["es2022"],
2294
+ minify: true,
2295
+ write: false
2296
+ });
2297
+ res.writeHead(200, { "Content-Type": "application/javascript", "Cache-Control": "no-cache" });
2298
+ res.end(result.outputFiles[0].text);
2299
+ return;
2300
+ } catch (err) {
2301
+ console.error("HMR Client build failed", err);
2302
+ res.writeHead(500);
2303
+ res.end();
2304
+ return;
2305
+ }
2306
+ }
2257
2307
  if (pathname.startsWith("/__velix/islands/") && pathname.endsWith(".js")) {
2258
2308
  const componentName = pathname.replace("/__velix/islands/", "").replace(".js", "");
2259
2309
  try {
@@ -2294,9 +2344,10 @@ async function serveVelixInternal(pathname, req, res, projectRoot) {
2294
2344
  res.end(result.outputFiles[0].text);
2295
2345
  return;
2296
2346
  } catch (err) {
2297
- logger_default.error(`Island bundling failed: ${componentName}`, err);
2347
+ const error = err;
2348
+ logger_default.error(`Island bundling failed: ${componentName}`, error);
2298
2349
  res.writeHead(500);
2299
- res.end(`console.error("Island bundling failed: ${err.message}");`);
2350
+ res.end(`console.error("Island bundling failed: ${error.message}");`);
2300
2351
  return;
2301
2352
  }
2302
2353
  }
@@ -2321,7 +2372,7 @@ async function serveVelixInternal(pathname, req, res, projectRoot) {
2321
2372
  return;
2322
2373
  }
2323
2374
  }
2324
- res.writeHead(404);
2375
+ res.writeHead(404, { "Content-Type": "text/plain" });
2325
2376
  res.end("Not found");
2326
2377
  }
2327
2378
  function parseRequestBody(req) {
@@ -2355,5 +2406,5 @@ function parseRawBody(req) {
2355
2406
  var server_default = { createServer, tailwindPlugin };
2356
2407
 
2357
2408
  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, server_default, tailwindPlugin, text, useActionContext, useVelixAction };
2358
- //# sourceMappingURL=chunk-CFDPNOWM.js.map
2359
- //# sourceMappingURL=chunk-CFDPNOWM.js.map
2409
+ //# sourceMappingURL=chunk-DTF3KTLR.js.map
2410
+ //# sourceMappingURL=chunk-DTF3KTLR.js.map