@jay-framework/stack-server-runtime 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.
package/dist/index.d.ts CHANGED
@@ -897,17 +897,17 @@ declare class SlowRenderCache {
897
897
  * Get a cached pre-rendered jay-html entry by reading from disk.
898
898
  * Returns undefined if the cache file doesn't exist or has no metadata tag.
899
899
  */
900
- get(jayHtmlPath: string, params: Record<string, string>): Promise<SlowRenderCacheEntry | undefined>;
900
+ get(jayHtmlPath: string, params: Record<string, string>, routeDir?: string): Promise<SlowRenderCacheEntry | undefined>;
901
901
  /**
902
902
  * Store a pre-rendered jay-html entry.
903
903
  * Embeds metadata as a <script> tag and writes to disk.
904
904
  * Returns the full cache entry with stripped content.
905
905
  */
906
- set(jayHtmlPath: string, params: Record<string, string>, preRenderedJayHtml: string, slowViewState: object, carryForward: object): Promise<SlowRenderCacheEntry>;
906
+ set(jayHtmlPath: string, params: Record<string, string>, preRenderedJayHtml: string, slowViewState: object, carryForward: object, routeDir?: string): Promise<SlowRenderCacheEntry>;
907
907
  /**
908
908
  * Check if a pre-rendered entry exists for the given path and params
909
909
  */
910
- has(jayHtmlPath: string, params: Record<string, string>): Promise<boolean>;
910
+ has(jayHtmlPath: string, params: Record<string, string>, routeDir?: string): Promise<boolean>;
911
911
  /**
912
912
  * Invalidate all cached entries for a given jay-html source path.
913
913
  * Deletes cached files from disk.
package/dist/index.js CHANGED
@@ -653,6 +653,17 @@ function buildFreezeScript(routePattern) {
653
653
  __jayDoFreeze();
654
654
  }
655
655
  });
656
+ }
657
+
658
+ // Targeted page reload: only reload if this page matches the changed route prefix
659
+ if (import.meta.hot) {
660
+ import.meta.hot.on('jay:page-reload', (data) => {
661
+ const prefix = data.routePrefix;
662
+ const pathname = window.location.pathname;
663
+ if (pathname === prefix || pathname.startsWith(prefix + '/')) {
664
+ window.location.reload();
665
+ }
666
+ });
656
667
  }`;
657
668
  }
658
669
  function buildAutomationWrap(options, mode) {
@@ -1118,11 +1129,12 @@ async function loadPageParts(vite, route, pagesBase, projectBase, jayRollupConfi
1118
1129
  const exists = await fs$2.access(route.compPath, fs$2.constants.F_OK).then(() => true).catch(() => false);
1119
1130
  const parts = [];
1120
1131
  if (exists) {
1121
- const pageComponent = (await vite.ssrLoadModule(route.compPath)).page;
1132
+ const exportName = route.componentExport || "page";
1133
+ const pageComponent = (await vite.ssrLoadModule(route.compPath))[exportName];
1122
1134
  parts.push({
1123
1135
  compDefinition: pageComponent,
1124
- clientImport: `import {page} from '${route.compPath}'`,
1125
- clientPart: `{comp: page.comp, contextMarkers: page.contexts || []}`
1136
+ clientImport: `import {${exportName}} from '${route.compPath}'`,
1137
+ clientPart: `{comp: ${exportName}.comp, contextMarkers: ${exportName}.contexts || []}`
1126
1138
  });
1127
1139
  }
1128
1140
  const jayHtmlFilePath = options?.preRenderedPath ?? route.jayHtmlPath;
@@ -2198,8 +2210,8 @@ class SlowRenderCache {
2198
2210
  * Get a cached pre-rendered jay-html entry by reading from disk.
2199
2211
  * Returns undefined if the cache file doesn't exist or has no metadata tag.
2200
2212
  */
2201
- async get(jayHtmlPath, params) {
2202
- const preRenderedPath = this.computeCachePath(jayHtmlPath, params);
2213
+ async get(jayHtmlPath, params, routeDir) {
2214
+ const preRenderedPath = this.computeCachePath(jayHtmlPath, params, routeDir);
2203
2215
  let fileContent;
2204
2216
  try {
2205
2217
  fileContent = await fs$2.readFile(preRenderedPath, "utf-8");
@@ -2223,8 +2235,8 @@ class SlowRenderCache {
2223
2235
  * Embeds metadata as a <script> tag and writes to disk.
2224
2236
  * Returns the full cache entry with stripped content.
2225
2237
  */
2226
- async set(jayHtmlPath, params, preRenderedJayHtml, slowViewState, carryForward) {
2227
- const preRenderedPath = this.computeCachePath(jayHtmlPath, params);
2238
+ async set(jayHtmlPath, params, preRenderedJayHtml, slowViewState, carryForward, routeDir) {
2239
+ const preRenderedPath = this.computeCachePath(jayHtmlPath, params, routeDir);
2228
2240
  const fileContent = embedCacheMetadata(
2229
2241
  preRenderedJayHtml,
2230
2242
  slowViewState,
@@ -2245,8 +2257,8 @@ class SlowRenderCache {
2245
2257
  /**
2246
2258
  * Check if a pre-rendered entry exists for the given path and params
2247
2259
  */
2248
- async has(jayHtmlPath, params) {
2249
- const preRenderedPath = this.computeCachePath(jayHtmlPath, params);
2260
+ async has(jayHtmlPath, params, routeDir) {
2261
+ const preRenderedPath = this.computeCachePath(jayHtmlPath, params, routeDir);
2250
2262
  try {
2251
2263
  await fs$2.access(preRenderedPath);
2252
2264
  return true;
@@ -2320,10 +2332,18 @@ class SlowRenderCache {
2320
2332
  /**
2321
2333
  * Compute the cache file path for a given jay-html path and params.
2322
2334
  */
2323
- computeCachePath(jayHtmlPath, params) {
2324
- const relativePath = path__default.relative(this.pagesRoot, jayHtmlPath);
2325
- const dir = path__default.dirname(relativePath);
2326
- const basename = path__default.basename(relativePath, ".jay-html");
2335
+ computeCachePath(jayHtmlPath, params, routeDir) {
2336
+ let dir;
2337
+ if (routeDir) {
2338
+ dir = routeDir;
2339
+ } else {
2340
+ const relativePath = path__default.relative(this.pagesRoot, jayHtmlPath);
2341
+ dir = relativePath.startsWith("..") ? path__default.join(
2342
+ "_plugins",
2343
+ crypto.createHash("md5").update(jayHtmlPath).digest("hex").slice(0, 12)
2344
+ ) : path__default.dirname(relativePath);
2345
+ }
2346
+ const basename = path__default.basename(jayHtmlPath, ".jay-html");
2327
2347
  const paramsHash = hashParams(params);
2328
2348
  const cacheFileName = `${basename}${paramsHash}.jay-html`;
2329
2349
  return path__default.join(this.cacheDir, dir, cacheFileName);
@@ -2343,8 +2363,11 @@ class SlowRenderCache {
2343
2363
  */
2344
2364
  async scanAndDeleteCacheFiles(jayHtmlPath) {
2345
2365
  const relativePath = path__default.relative(this.pagesRoot, jayHtmlPath);
2346
- const dir = path__default.dirname(relativePath);
2347
- const basename = path__default.basename(relativePath, ".jay-html");
2366
+ const dir = relativePath.startsWith("..") ? path__default.join(
2367
+ "_plugins",
2368
+ crypto.createHash("md5").update(jayHtmlPath).digest("hex").slice(0, 12)
2369
+ ) : path__default.dirname(relativePath);
2370
+ const basename = path__default.basename(jayHtmlPath, ".jay-html");
2348
2371
  const cacheSubDir = path__default.join(this.cacheDir, dir);
2349
2372
  try {
2350
2373
  const files = await fs$2.readdir(cacheSubDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/stack-server-runtime",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.mts",
@@ -26,21 +26,21 @@
26
26
  "test:watch": "vitest"
27
27
  },
28
28
  "dependencies": {
29
- "@jay-framework/compiler-jay-html": "^0.16.1",
30
- "@jay-framework/compiler-shared": "^0.16.1",
31
- "@jay-framework/component": "^0.16.1",
32
- "@jay-framework/fullstack-component": "^0.16.1",
33
- "@jay-framework/logger": "^0.16.1",
34
- "@jay-framework/runtime": "^0.16.1",
35
- "@jay-framework/ssr-runtime": "^0.16.1",
36
- "@jay-framework/stack-route-scanner": "^0.16.1",
37
- "@jay-framework/view-state-merge": "^0.16.1",
29
+ "@jay-framework/compiler-jay-html": "^0.16.2",
30
+ "@jay-framework/compiler-shared": "^0.16.2",
31
+ "@jay-framework/component": "^0.16.2",
32
+ "@jay-framework/fullstack-component": "^0.16.2",
33
+ "@jay-framework/logger": "^0.16.2",
34
+ "@jay-framework/runtime": "^0.16.2",
35
+ "@jay-framework/ssr-runtime": "^0.16.2",
36
+ "@jay-framework/stack-route-scanner": "^0.16.2",
37
+ "@jay-framework/view-state-merge": "^0.16.2",
38
38
  "yaml": "^2.3.4"
39
39
  },
40
40
  "devDependencies": {
41
- "@jay-framework/dev-environment": "^0.16.1",
42
- "@jay-framework/jay-cli": "^0.16.1",
43
- "@jay-framework/stack-client-runtime": "^0.16.1",
41
+ "@jay-framework/dev-environment": "^0.16.2",
42
+ "@jay-framework/jay-cli": "^0.16.2",
43
+ "@jay-framework/stack-client-runtime": "^0.16.2",
44
44
  "@types/express": "^5.0.2",
45
45
  "@types/node": "^22.15.21",
46
46
  "nodemon": "^3.0.3",