@jay-framework/dev-server 0.16.1 → 0.16.2

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 (2) hide show
  1. package/dist/index.js +40 -11
  2. package/package.json +14 -14
package/dist/index.js CHANGED
@@ -2173,8 +2173,10 @@ async function scanPluginRoutes(projectRoot, projectRoutes) {
2173
2173
  );
2174
2174
  continue;
2175
2175
  }
2176
- const compPath = route.component.startsWith(".") ? path__default.resolve(plugin.pluginPath, route.component) : resolvePluginModule(plugin);
2177
- pluginRoutes.push(createRoute(route.path, jayHtmlPath, compPath));
2176
+ const isLocalComponent = route.component.startsWith(".");
2177
+ const compPath = isLocalComponent ? path__default.resolve(plugin.pluginPath, route.component) : resolvePluginModule(plugin);
2178
+ const componentExport = isLocalComponent ? void 0 : route.component;
2179
+ pluginRoutes.push(createRoute(route.path, jayHtmlPath, compPath, componentExport));
2178
2180
  getLogger().info(`[Routes] Plugin "${plugin.name}" provides route ${route.path}`);
2179
2181
  }
2180
2182
  }
@@ -2339,7 +2341,11 @@ function mkRoute(route, vite, slowlyPhase, options, slowRenderCache, freezeStore
2339
2341
  query
2340
2342
  );
2341
2343
  } else {
2342
- const cachedEntry = await slowRenderCache.get(route.jayHtmlPath, pageParams);
2344
+ const cachedEntry = await slowRenderCache.get(
2345
+ route.jayHtmlPath,
2346
+ pageParams,
2347
+ getRouteDir(route)
2348
+ );
2343
2349
  if (cachedEntry) {
2344
2350
  await handleCachedRequest(
2345
2351
  vite,
@@ -2455,6 +2461,7 @@ async function handleCachedRequest(vite, route, options, cachedEntry, pageParams
2455
2461
  pluginsForPage,
2456
2462
  options,
2457
2463
  routeToExpressRoute(route),
2464
+ getRouteDir(route),
2458
2465
  cachedEntry.slowViewState,
2459
2466
  timing,
2460
2467
  cachedEntry.preRenderedContent,
@@ -2529,7 +2536,8 @@ async function handlePreRenderRequest(vite, route, options, slowlyPhase, slowRen
2529
2536
  pageParams,
2530
2537
  preRenderResult.preRenderedJayHtml,
2531
2538
  renderedSlowly.rendered,
2532
- carryForward
2539
+ carryForward,
2540
+ getRouteDir(route)
2533
2541
  );
2534
2542
  getLogger().info(`[SlowRender] Cached pre-rendered jay-html at ${cachedEntry.preRenderedPath}`);
2535
2543
  await handleCachedRequest(
@@ -2650,9 +2658,8 @@ async function handleClientOnlyRequest(vite, route, options, slowlyPhase, pagePa
2650
2658
  res.status(200).set({ "Content-Type": "text/html" }).send(compiledPageHtml);
2651
2659
  timing?.end();
2652
2660
  }
2653
- async function sendResponse(vite, res, url, jayHtmlPath, sourceJayHtmlPath, pageParts, viewState, carryForward, clientTrackByMap, projectInit, pluginsForPage, options, routePattern, slowViewState, timing, preLoadedContent, headTags) {
2661
+ async function sendResponse(vite, res, url, jayHtmlPath, sourceJayHtmlPath, pageParts, viewState, carryForward, clientTrackByMap, projectInit, pluginsForPage, options, routePattern, routeDir, slowViewState, timing, preLoadedContent, headTags) {
2654
2662
  let pageHtml;
2655
- const routeDir = path__default.dirname(path__default.relative(options.pagesRootFolder, sourceJayHtmlPath));
2656
2663
  try {
2657
2664
  let jayHtmlContent = preLoadedContent ?? await fs__default.readFile(jayHtmlPath, "utf-8");
2658
2665
  const jayHtmlFilename = path__default.basename(jayHtmlPath);
@@ -2726,13 +2733,13 @@ async function handleFrozenRequest(vite, route, options, freezeStore, slowRender
2726
2733
  const label = entry.name ? `"${entry.name}" (${freezeId})` : freezeId;
2727
2734
  getLogger().info(`[Freeze] Serving frozen page ${label} for ${route.rawRoute} [${format}]`);
2728
2735
  try {
2729
- const cachedEntry = await slowRenderCache.get(route.jayHtmlPath, pageParams);
2736
+ const routeDir = getRouteDir(route);
2737
+ const cachedEntry = await slowRenderCache.get(route.jayHtmlPath, pageParams, routeDir);
2730
2738
  const jayHtmlPath = cachedEntry?.preRenderedPath ?? route.jayHtmlPath;
2731
2739
  const jayHtmlContent = cachedEntry?.preRenderedContent ?? await fs__default.readFile(jayHtmlPath, "utf-8");
2732
2740
  const jayHtmlFilename = path__default.basename(jayHtmlPath);
2733
2741
  const jayHtmlDir = path__default.dirname(jayHtmlPath);
2734
2742
  const sourceDir = path__default.dirname(route.jayHtmlPath);
2735
- const routeDir = path__default.dirname(path__default.relative(options.pagesRootFolder, route.jayHtmlPath));
2736
2743
  const { injectHeadfullFSTemplates: injectHeadfullFSTemplates2 } = await import("@jay-framework/compiler-jay-html");
2737
2744
  const { JAY_IMPORT_RESOLVER: JAY_IMPORT_RESOLVER2 } = await import("@jay-framework/compiler-jay-html");
2738
2745
  const fullJayHtml = injectHeadfullFSTemplates2(
@@ -3053,6 +3060,28 @@ function setupFreezeEndpoint(vite, freezeStore) {
3053
3060
  });
3054
3061
  getLogger().info("[Freeze] Freeze endpoint mounted at /_jay/freeze");
3055
3062
  }
3063
+ function getRouteDir(route) {
3064
+ return route.rawRoute.replace(/^\//, "") || "index";
3065
+ }
3066
+ function getRoutePrefix(jayHtmlPath, pagesRootFolder) {
3067
+ const rel = path__default.relative(pagesRootFolder, path__default.dirname(jayHtmlPath));
3068
+ const segments = rel.split(path__default.sep).filter(Boolean);
3069
+ const staticSegments = [];
3070
+ for (const seg of segments) {
3071
+ if (seg.startsWith("["))
3072
+ break;
3073
+ staticSegments.push(seg);
3074
+ }
3075
+ return "/" + staticSegments.join("/");
3076
+ }
3077
+ function sendPageReload(vite, jayHtmlPath, pagesRootFolder) {
3078
+ const routePrefix = getRoutePrefix(jayHtmlPath, pagesRootFolder);
3079
+ vite.ws.send({
3080
+ type: "custom",
3081
+ event: "jay:page-reload",
3082
+ data: { routePrefix }
3083
+ });
3084
+ }
3056
3085
  function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder, projectRootFolder) {
3057
3086
  const watchedFiles = /* @__PURE__ */ new Set();
3058
3087
  const watchLinkedFiles = (files) => {
@@ -3079,7 +3108,7 @@ function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder, projectR
3079
3108
  clearServerElementCache();
3080
3109
  cache.clear().then(() => {
3081
3110
  getLogger().info(`[SlowRender] Cache cleared (jay-html changed: ${changedPath})`);
3082
- vite.ws.send({ type: "full-reload" });
3111
+ sendPageReload(vite, changedPath, pagesRootFolder);
3083
3112
  });
3084
3113
  return;
3085
3114
  }
@@ -3094,7 +3123,7 @@ function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder, projectR
3094
3123
  getLogger().info(
3095
3124
  `[SlowRender] Cache invalidated for ${jayHtmlPath} (page.ts changed)`
3096
3125
  );
3097
- vite.ws.send({ type: "full-reload" });
3126
+ sendPageReload(vite, jayHtmlPath, pagesRootFolder);
3098
3127
  });
3099
3128
  return;
3100
3129
  }
@@ -3105,7 +3134,7 @@ function setupSlowRenderCacheInvalidation(vite, cache, pagesRootFolder, projectR
3105
3134
  getLogger().info(
3106
3135
  `[SlowRender] Cache invalidated for ${jayHtmlPath} (contract changed)`
3107
3136
  );
3108
- vite.ws.send({ type: "full-reload" });
3137
+ sendPageReload(vite, jayHtmlPath, pagesRootFolder);
3109
3138
  });
3110
3139
  return;
3111
3140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/dev-server",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -23,23 +23,23 @@
23
23
  "test:watch": "vitest"
24
24
  },
25
25
  "dependencies": {
26
- "@jay-framework/compiler-jay-stack": "^0.16.1",
27
- "@jay-framework/compiler-shared": "^0.16.1",
28
- "@jay-framework/component": "^0.16.1",
29
- "@jay-framework/fullstack-component": "^0.16.1",
30
- "@jay-framework/logger": "^0.16.1",
31
- "@jay-framework/runtime": "^0.16.1",
32
- "@jay-framework/stack-client-runtime": "^0.16.1",
33
- "@jay-framework/stack-route-scanner": "^0.16.1",
34
- "@jay-framework/stack-server-runtime": "^0.16.1",
35
- "@jay-framework/view-state-merge": "^0.16.1",
26
+ "@jay-framework/compiler-jay-stack": "^0.16.2",
27
+ "@jay-framework/compiler-shared": "^0.16.2",
28
+ "@jay-framework/component": "^0.16.2",
29
+ "@jay-framework/fullstack-component": "^0.16.2",
30
+ "@jay-framework/logger": "^0.16.2",
31
+ "@jay-framework/runtime": "^0.16.2",
32
+ "@jay-framework/stack-client-runtime": "^0.16.2",
33
+ "@jay-framework/stack-route-scanner": "^0.16.2",
34
+ "@jay-framework/stack-server-runtime": "^0.16.2",
35
+ "@jay-framework/view-state-merge": "^0.16.2",
36
36
  "busboy": "^1.6.0",
37
37
  "vite": "^5.0.11"
38
38
  },
39
39
  "devDependencies": {
40
- "@jay-framework/dev-environment": "^0.16.1",
41
- "@jay-framework/jay-cli": "^0.16.1",
42
- "@jay-framework/stack-client-runtime": "^0.16.1",
40
+ "@jay-framework/dev-environment": "^0.16.2",
41
+ "@jay-framework/jay-cli": "^0.16.2",
42
+ "@jay-framework/stack-client-runtime": "^0.16.2",
43
43
  "@playwright/test": "^1.58.2",
44
44
  "@types/busboy": "^1.5.4",
45
45
  "@types/express": "^5.0.2",