@jay-framework/stack-server-runtime 0.16.1 → 0.16.3

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,13 @@ 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];
1134
+ const clientImportPath = route.componentExport ? route.compPath.replace(/index\.js$/, "index.client.js") : route.compPath;
1122
1135
  parts.push({
1123
1136
  compDefinition: pageComponent,
1124
- clientImport: `import {page} from '${route.compPath}'`,
1125
- clientPart: `{comp: page.comp, contextMarkers: page.contexts || []}`
1137
+ clientImport: `import {${exportName}} from '${clientImportPath}'`,
1138
+ clientPart: `{comp: ${exportName}.comp, contextMarkers: ${exportName}.contexts || []}`
1126
1139
  });
1127
1140
  }
1128
1141
  const jayHtmlFilePath = options?.preRenderedPath ?? route.jayHtmlPath;
@@ -2198,8 +2211,8 @@ class SlowRenderCache {
2198
2211
  * Get a cached pre-rendered jay-html entry by reading from disk.
2199
2212
  * Returns undefined if the cache file doesn't exist or has no metadata tag.
2200
2213
  */
2201
- async get(jayHtmlPath, params) {
2202
- const preRenderedPath = this.computeCachePath(jayHtmlPath, params);
2214
+ async get(jayHtmlPath, params, routeDir) {
2215
+ const preRenderedPath = this.computeCachePath(jayHtmlPath, params, routeDir);
2203
2216
  let fileContent;
2204
2217
  try {
2205
2218
  fileContent = await fs$2.readFile(preRenderedPath, "utf-8");
@@ -2223,8 +2236,8 @@ class SlowRenderCache {
2223
2236
  * Embeds metadata as a <script> tag and writes to disk.
2224
2237
  * Returns the full cache entry with stripped content.
2225
2238
  */
2226
- async set(jayHtmlPath, params, preRenderedJayHtml, slowViewState, carryForward) {
2227
- const preRenderedPath = this.computeCachePath(jayHtmlPath, params);
2239
+ async set(jayHtmlPath, params, preRenderedJayHtml, slowViewState, carryForward, routeDir) {
2240
+ const preRenderedPath = this.computeCachePath(jayHtmlPath, params, routeDir);
2228
2241
  const fileContent = embedCacheMetadata(
2229
2242
  preRenderedJayHtml,
2230
2243
  slowViewState,
@@ -2245,8 +2258,8 @@ class SlowRenderCache {
2245
2258
  /**
2246
2259
  * Check if a pre-rendered entry exists for the given path and params
2247
2260
  */
2248
- async has(jayHtmlPath, params) {
2249
- const preRenderedPath = this.computeCachePath(jayHtmlPath, params);
2261
+ async has(jayHtmlPath, params, routeDir) {
2262
+ const preRenderedPath = this.computeCachePath(jayHtmlPath, params, routeDir);
2250
2263
  try {
2251
2264
  await fs$2.access(preRenderedPath);
2252
2265
  return true;
@@ -2320,10 +2333,18 @@ class SlowRenderCache {
2320
2333
  /**
2321
2334
  * Compute the cache file path for a given jay-html path and params.
2322
2335
  */
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");
2336
+ computeCachePath(jayHtmlPath, params, routeDir) {
2337
+ let dir;
2338
+ if (routeDir) {
2339
+ dir = routeDir;
2340
+ } else {
2341
+ const relativePath = path__default.relative(this.pagesRoot, jayHtmlPath);
2342
+ dir = relativePath.startsWith("..") ? path__default.join(
2343
+ "_plugins",
2344
+ crypto.createHash("md5").update(jayHtmlPath).digest("hex").slice(0, 12)
2345
+ ) : path__default.dirname(relativePath);
2346
+ }
2347
+ const basename = path__default.basename(jayHtmlPath, ".jay-html");
2327
2348
  const paramsHash = hashParams(params);
2328
2349
  const cacheFileName = `${basename}${paramsHash}.jay-html`;
2329
2350
  return path__default.join(this.cacheDir, dir, cacheFileName);
@@ -2343,8 +2364,11 @@ class SlowRenderCache {
2343
2364
  */
2344
2365
  async scanAndDeleteCacheFiles(jayHtmlPath) {
2345
2366
  const relativePath = path__default.relative(this.pagesRoot, jayHtmlPath);
2346
- const dir = path__default.dirname(relativePath);
2347
- const basename = path__default.basename(relativePath, ".jay-html");
2367
+ const dir = relativePath.startsWith("..") ? path__default.join(
2368
+ "_plugins",
2369
+ crypto.createHash("md5").update(jayHtmlPath).digest("hex").slice(0, 12)
2370
+ ) : path__default.dirname(relativePath);
2371
+ const basename = path__default.basename(jayHtmlPath, ".jay-html");
2348
2372
  const cacheSubDir = path__default.join(this.cacheDir, dir);
2349
2373
  try {
2350
2374
  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.3",
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.3",
30
+ "@jay-framework/compiler-shared": "^0.16.3",
31
+ "@jay-framework/component": "^0.16.3",
32
+ "@jay-framework/fullstack-component": "^0.16.3",
33
+ "@jay-framework/logger": "^0.16.3",
34
+ "@jay-framework/runtime": "^0.16.3",
35
+ "@jay-framework/ssr-runtime": "^0.16.3",
36
+ "@jay-framework/stack-route-scanner": "^0.16.3",
37
+ "@jay-framework/view-state-merge": "^0.16.3",
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.3",
42
+ "@jay-framework/jay-cli": "^0.16.3",
43
+ "@jay-framework/stack-client-runtime": "^0.16.3",
44
44
  "@types/express": "^5.0.2",
45
45
  "@types/node": "^22.15.21",
46
46
  "nodemon": "^3.0.3",