@cfdez11/vex 0.9.0 → 0.9.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.
package/dist/bin/vex.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{spawn}from"child_process";import{fileURLToPath}from"url";import path from"path";const __dirname=path.dirname(fileURLToPath(import.meta.url)),serverDir=path.resolve(__dirname,"..","server"),[command]=process.argv.slice(2),commands={dev:()=>spawn("node",["--watch",path.join(serverDir,"index.js")],{stdio:"inherit"}),build:()=>spawn("node",[path.join(serverDir,"prebuild.js")],{stdio:"inherit"}),start:()=>spawn("node",[path.join(serverDir,"index.js")],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}}),"build:static":()=>spawn("node",[path.join(serverDir,"build-static.js")],{stdio:"inherit"})};commands[command]||(console.error(`Unknown command: "${command}"
2
+ import{spawn}from"child_process";import{fileURLToPath}from"url";import path from"path";const __dirname=path.dirname(fileURLToPath(import.meta.url)),serverDir=path.resolve(__dirname,"..","server"),[command]=process.argv.slice(2),commands={dev:()=>spawn("node",["--watch",path.join(serverDir,"index.js")],{stdio:"inherit"}),build:()=>spawn("node",[path.join(serverDir,"prebuild.js")],{stdio:"inherit"}),start:()=>spawn("node",[path.join(serverDir,"index.js")],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}}),"build:static":()=>spawn("node",[path.join(serverDir,"build-static.js")],{stdio:"inherit",env:{...process.env,NODE_ENV:"production"}})};commands[command]||(console.error(`Unknown command: "${command}"
3
3
  Available: dev, build, build:static, start`),process.exit(1));const child=commands[command]();child.on("exit",code=>process.exit(code??0));
@@ -1 +1 @@
1
- import{findRouteWithParams}from"./router.js";import{updateRouteParams}from"./use-route-params.js";import{renderPage}from"./render-page.js";import{renderSSRPage}from"./render-ssr.js";async function navigateInternal({path,addToHistory,controller,layoutRenderer,onFinish}){updateRouteParams(path);const routePath=path.split("?")[0],{route}=findRouteWithParams(routePath);addToHistory&&history.pushState({},"",path);try{if(route?.meta?.ssr){layoutRenderer.reset(),await renderSSRPage(path,controller.signal);return}if(route?.meta?.requiresAuth&&!app.Store?.loggedIn){location.href="/account/login";return}if(route?.meta?.guestOnly&&app.Store?.loggedIn){location.href="/account";return}await renderPage({route,layoutRenderer})}finally{onFinish()}}export{navigateInternal};
1
+ import{findRouteWithParams}from"./router.js";import{routes}from"../_routes.js";import{updateRouteParams}from"./use-route-params.js";import{renderPage}from"./render-page.js";import{renderSSRPage}from"./render-ssr.js";async function navigateInternal({path,addToHistory,controller,layoutRenderer,onFinish}){updateRouteParams(path);const routePath=path.split("?")[0],{route:matchedRoute}=findRouteWithParams(routePath),route=matchedRoute??routes.find(r=>r.isNotFound)??null;addToHistory&&history.pushState({},"",path);try{if(route?.meta?.ssr){layoutRenderer.reset(),await renderSSRPage(path,controller.signal);return}if(route?.meta?.requiresAuth&&!app.Store?.loggedIn){location.href="/account/login";return}if(route?.meta?.guestOnly&&app.Store?.loggedIn){location.href="/account";return}await renderPage({route,layoutRenderer})}finally{onFinish()}}export{navigateInternal};
@@ -3,4 +3,4 @@ import"dotenv/config";import fs from"fs/promises";import path from"path";import{
3
3
  </head>`),await fs.writeFile(path.join(DIST_DIR,"index.html"),shell,"utf-8"),console.log("\u{1F4E6} Copying framework assets...");for(const asset of["favicon.ico","app.webmanifest"])try{await fs.copyFile(path.join(CLIENT_DIR,asset),path.join(DIST_DIR,"_vexjs",asset))}catch{}console.log("\u{1F4E6} Copying services..."),await fs.cp(path.join(GENERATED_DIR,"services"),path.join(DIST_DIR,"_vexjs","services"),{recursive:!0}),console.log("\u{1F4E6} Copying component bundles..."),await fs.cp(path.join(GENERATED_DIR,"_components"),path.join(DIST_DIR,"_vexjs","_components"),{recursive:!0}),console.log("\u{1F4E6} Copying pre-bundled user JS files...");try{await fs.cp(USER_GENERATED_DIR,path.join(DIST_DIR,"_vexjs","user"),{recursive:!0})}catch{}console.log("\u{1F4E6} Copying public assets...");const publicDir=path.join(PROJECT_ROOT,"public");try{await fs.cp(publicDir,DIST_DIR,{recursive:!0})}catch{}const CACHE_DIR=path.join(GENERATED_DIR,"_cache"),ssgRoutes=serverRoutes.filter(r=>r.meta.revalidate==="never"||r.meta.revalidate===!1);if(ssgRoutes.length>0){console.log("\u{1F4C4} Copying pre-rendered SSG pages...");for(const route of ssgRoutes){const cacheFile=path.join(CACHE_DIR,`${generateComponentId(route.serverPath)}.html`);try{const html=await fs.readFile(cacheFile,"utf-8"),routeSegment=route.serverPath==="/"?"":route.serverPath,destPath=path.join(DIST_DIR,routeSegment,"index.html");await fs.mkdir(path.dirname(destPath),{recursive:!0}),await fs.writeFile(destPath,html,"utf-8"),console.log(` \u2713 ${route.serverPath}`)}catch{console.warn(` \u2717 ${route.serverPath} (no cached HTML found)`)}}}const ssrOnlyRoutes=serverRoutes.filter(r=>r.meta.ssr);if(ssrOnlyRoutes.length>0){console.warn(`
4
4
  \u26A0\uFE0F The following routes require a server and were NOT included in the static build:`);for(const r of ssrOnlyRoutes)console.warn(` ${r.path} (SSR)`);console.warn(` These routes will show a 404 in the static build.
5
5
  `)}console.log("\u2705 Static build complete! Output: dist/"),console.log(`
6
- To serve locally: npx serve dist`),console.log("Static host note: configure your host to serve dist/index.html for all 404s (SPA fallback).");
6
+ To serve locally: npx serve dist`),console.log("Static host note: configure your host to serve dist/index.html for all 404s (SPA fallback)."),process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfdez11/vex",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "A vanilla JavaScript meta-framework with file-based routing, SSR/CSR/SSG/ISR and Vue-like reactivity",
5
5
  "type": "module",
6
6
  "main": "./dist/server/index.js",