veryfront 0.0.103 → 0.0.105

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 (44) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/src/cli/commands/init/config-generator.js +1 -1
  3. package/esm/src/modules/react-loader/component-loader.d.ts.map +1 -1
  4. package/esm/src/modules/react-loader/component-loader.js +1 -0
  5. package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts.map +1 -1
  6. package/esm/src/modules/react-loader/ssr-module-loader/loader.js +14 -7
  7. package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts +2 -0
  8. package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts.map +1 -1
  9. package/esm/src/modules/react-loader/types.d.ts +2 -0
  10. package/esm/src/modules/react-loader/types.d.ts.map +1 -1
  11. package/esm/src/rendering/layouts/layout-applicator.d.ts.map +1 -1
  12. package/esm/src/rendering/layouts/layout-applicator.js +4 -1
  13. package/esm/src/rendering/layouts/utils/app-resolver.d.ts.map +1 -1
  14. package/esm/src/rendering/layouts/utils/app-resolver.js +9 -0
  15. package/esm/src/rendering/layouts/utils/applicator.d.ts +1 -1
  16. package/esm/src/rendering/layouts/utils/applicator.d.ts.map +1 -1
  17. package/esm/src/rendering/layouts/utils/applicator.js +3 -3
  18. package/esm/src/rendering/layouts/utils/component-loader.d.ts +2 -2
  19. package/esm/src/rendering/layouts/utils/component-loader.d.ts.map +1 -1
  20. package/esm/src/rendering/layouts/utils/component-loader.js +9 -4
  21. package/esm/src/rendering/orchestrator/layout.d.ts.map +1 -1
  22. package/esm/src/rendering/orchestrator/layout.js +1 -1
  23. package/esm/src/transforms/esm/http-cache.d.ts.map +1 -1
  24. package/esm/src/transforms/esm/http-cache.js +34 -22
  25. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts +1 -1
  26. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
  27. package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +8 -11
  28. package/esm/src/transforms/mdx/esm-module-loader/loader.d.ts.map +1 -1
  29. package/esm/src/transforms/mdx/esm-module-loader/loader.js +1 -0
  30. package/package.json +1 -1
  31. package/src/deno.js +1 -1
  32. package/src/src/cli/commands/init/config-generator.ts +1 -1
  33. package/src/src/modules/react-loader/component-loader.ts +1 -0
  34. package/src/src/modules/react-loader/ssr-module-loader/loader.ts +14 -7
  35. package/src/src/modules/react-loader/ssr-module-loader/types.ts +2 -0
  36. package/src/src/modules/react-loader/types.ts +2 -0
  37. package/src/src/rendering/layouts/layout-applicator.ts +5 -1
  38. package/src/src/rendering/layouts/utils/app-resolver.ts +9 -0
  39. package/src/src/rendering/layouts/utils/applicator.ts +3 -1
  40. package/src/src/rendering/layouts/utils/component-loader.ts +9 -1
  41. package/src/src/rendering/orchestrator/layout.ts +1 -0
  42. package/src/src/transforms/esm/http-cache.ts +35 -24
  43. package/src/src/transforms/mdx/esm-module-loader/cache/index.ts +8 -13
  44. package/src/src/transforms/mdx/esm-module-loader/loader.ts +1 -0
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.0.103",
3
+ "version": "0.0.105",
4
4
  "nodeModulesDir": "auto",
5
5
  "exclude": [
6
6
  "npm/",
@@ -14,7 +14,7 @@ export async function createPackageJson(projectDir, projectName) {
14
14
  dependencies: {
15
15
  react: "^19.0.0",
16
16
  "react-dom": "^19.0.0",
17
- veryfront: "^0.0.97",
17
+ veryfront: "^0.0.104",
18
18
  zod: "^3.24.0",
19
19
  },
20
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"component-loader.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/component-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAKtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CA0DvD"}
1
+ {"version":3,"file":"component-loader.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/component-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAKtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMvD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CA2DvD"}
@@ -16,6 +16,7 @@ export function loadComponentFromSource(source, filePath, projectDir, adapter, o
16
16
  const loader = new SSRModuleLoader({
17
17
  projectDir,
18
18
  projectId,
19
+ projectSlug: options?.projectSlug,
19
20
  adapter,
20
21
  dev,
21
22
  contentSourceId: options?.contentSourceId,
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/loader.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAuCpC,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAiC3E;;;;;GAKG;AACH,qBAAa,eAAe;IAId,OAAO,CAAC,OAA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ACH,UAAU,CACR,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAsGxD,OAAO,CAAC,mBAAmB;IAiC3B,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,yBAAyB;IAuBjC,OAAO,CAAC,kBAAkB;IAK1B;;OAEG;YACW,2BAA2B;IAmGzC,OAAO,CAAC,yBAAyB;YAiBnB,2BAA2B;IAgUzC;;;OAGG;YACW,mBAAmB;IA2CjC,OAAO,CAAC,yBAAyB;IAYjC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,wBAAwB;IAehC,OAAO,CAAC,2BAA2B;IAiBnC,OAAO,CAAC,2BAA2B;IAWnC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;OAEG;IACH,OAAO,CAAC,aAAa;YAIP,uBAAuB;IAyCrC;;;OAGG;YACW,gBAAgB;YAgBhB,WAAW;YAeX,YAAY;CA6B3B"}
@@ -385,13 +385,18 @@ export class SSRModuleLoader {
385
385
  }
386
386
  }
387
387
  if (httpBundlesOk) {
388
- const tempPath = await this.getTempPath(filePath, contentHash);
388
+ // CRITICAL: Use transformedHash (hash of the transformed code) for temp path,
389
+ // NOT contentHash (hash of source). Other modules importing this file use
390
+ // transformedHash in their import paths (set during fresh transform at line 703).
391
+ // Using contentHash here would create a path mismatch and "Module not found" errors.
392
+ const transformedHash = await this.hashContentAsync(redisCode);
393
+ const tempPath = await this.getTempPath(filePath, transformedHash);
389
394
  await this.fs.mkdir(tempPath.substring(0, tempPath.lastIndexOf("/")), {
390
395
  recursive: true,
391
396
  });
392
397
  await this.fs.writeTextFile(tempPath, redisCode);
393
- verifiedHttpBundlePaths.set(`${tempPath}:${contentHash}`, true);
394
- const entry = { tempPath, contentHash };
398
+ verifiedHttpBundlePaths.set(`${tempPath}:${transformedHash}`, true);
399
+ const entry = { tempPath, contentHash: transformedHash };
395
400
  globalModuleCache.set(contentCacheKey, entry);
396
401
  globalModuleCache.set(filePathCacheKey, entry);
397
402
  logger.debug("[SSR-MODULE-LOADER] Redis cache hit", { file: filePath.slice(-40) });
@@ -404,8 +409,9 @@ export class SSRModuleLoader {
404
409
  // Check MDX-ESM cache to share modules with MDX loader and avoid duplicate React contexts
405
410
  if (this.options.projectId && this.options.contentSourceId) {
406
411
  const baseCacheDir = getMdxEsmCacheDir();
407
- const projectKey = hashCodeHex(this.options.projectId);
408
- const sourceKey = hashCodeHex(this.options.contentSourceId);
412
+ // Use projectId consistently for stable cache keys (matches MDX loader)
413
+ const projectKey = encodeURIComponent(this.options.projectId);
414
+ const sourceKey = this.options.contentSourceId;
409
415
  const mdxCacheDir = join(baseCacheDir, projectKey, sourceKey);
410
416
  const mdxCachedPath = await lookupMdxEsmCache(filePath, mdxCacheDir, this.options.projectDir, contentHash);
411
417
  if (mdxCachedPath) {
@@ -750,8 +756,9 @@ export class SSRModuleLoader {
750
756
  // Use the same cache directory as MDX-ESM loader to share module instances.
751
757
  // This prevents issues like React context being created twice in separate files.
752
758
  const baseCacheDir = getMdxEsmCacheDir();
753
- const projectKey = hashCodeHex(projectId);
754
- const sourceKey = hashCodeHex(contentSourceId);
759
+ // Use projectId consistently for stable cache keys (matches MDX loader)
760
+ const projectKey = encodeURIComponent(projectId);
761
+ const sourceKey = contentSourceId;
755
762
  const cacheKey = `${baseCacheDir}|${projectKey}|${sourceKey}`;
756
763
  const existingDir = globalTmpDirs.get(cacheKey);
757
764
  if (existingDir)
@@ -9,6 +9,8 @@ import type { RuntimeAdapter } from "../../../platform/adapters/base.js";
9
9
  export interface SSRModuleLoaderOptions {
10
10
  projectDir: string;
11
11
  projectId: string;
12
+ /** Project slug for cache directory (human-readable name) */
13
+ projectSlug?: string;
12
14
  adapter: RuntimeAdapter;
13
15
  dev: boolean;
14
16
  apiBaseUrl?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,cAAc,CAAC;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/src/modules/react-loader/ssr-module-loader/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,cAAc,CAAC;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;CACvB"}
@@ -1,6 +1,8 @@
1
1
  import type * as React from "react";
2
2
  export interface LoadComponentOptions {
3
3
  projectId?: string;
4
+ /** Project slug for cache directory (human-readable name) */
5
+ projectSlug?: string;
4
6
  dev?: boolean;
5
7
  moduleServerUrl?: string;
6
8
  vendorBundleHash?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/react-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAEpC,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"layout-applicator.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/layouts/layout-applicator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,YAAY,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAs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,15 @@ export class LayoutApplicator {
135
135
  const { loadComponentFromSource } = await import("../../modules/react-loader/index.js");
136
136
  App = await loadComponentFromSource(appSource, appPath, this.projectDir, this.adapter, {
137
137
  projectId: this.projectId ?? this.projectDir,
138
+ projectSlug: this.projectSlug,
138
139
  dev: this.mode === "development",
139
140
  moduleServerUrl: this.config?.dev?.moduleServerUrl,
140
141
  contentSourceId: this.contentSourceId,
141
142
  });
142
143
  }
143
- if (!App)
144
+ if (!App) {
144
145
  return pageElement;
146
+ }
145
147
  const React = await getProjectReact();
146
148
  logger.debug("Wrapped page with App component");
147
149
  return React.createElement(App, { children: pageElement });
@@ -178,6 +180,7 @@ export class LayoutApplicator {
178
180
  const { loadComponentFromSource } = await import("../../modules/react-loader/index.js");
179
181
  return await loadComponentFromSource(String(compiled), appPath.replace(/\.mdx?$/, ".jsx"), this.projectDir, this.adapter, {
180
182
  projectId: this.projectId ?? this.projectDir,
183
+ projectSlug: this.projectSlug,
181
184
  dev: this.mode === "development",
182
185
  moduleServerUrl: this.config?.dev?.moduleServerUrl,
183
186
  contentSourceId: this.contentSourceId,
@@ -1 +1 @@
1
- {"version":3,"file":"app-resolver.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/layouts/utils/app-resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAUhE,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmDxB"}
1
+ {"version":3,"file":"app-resolver.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/layouts/utils/app-resolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAUhE,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA4DxB"}
@@ -6,6 +6,12 @@ function isValidComponentPath(path) {
6
6
  return VALID_EXTENSIONS.includes(ext);
7
7
  }
8
8
  export async function resolveAppComponentPath(projectDir, adapter, config) {
9
+ console.log("[AppResolver] Starting resolution", {
10
+ projectDir,
11
+ hasAdapter: !!adapter,
12
+ hasConfig: !!config,
13
+ configApp: config?.app,
14
+ });
9
15
  logger.debug("[AppResolver] Starting resolution", {
10
16
  projectDir,
11
17
  hasAdapter: !!adapter,
@@ -35,12 +41,15 @@ export async function resolveAppComponentPath(projectDir, adapter, config) {
35
41
  for (const ext of VALID_EXTENSIONS) {
36
42
  const appPath = join(projectDir, `components/app.${ext}`);
37
43
  const exists = await adapter.fs.exists(appPath);
44
+ console.log("[AppResolver] Checking default path", { appPath, exists });
38
45
  logger.debug("[AppResolver] Checking default path", { appPath, exists });
39
46
  if (exists) {
47
+ console.log("[AppResolver] Found app component via discovery", { path: appPath });
40
48
  logger.debug("[AppResolver] Found app component via discovery", { path: appPath });
41
49
  return appPath;
42
50
  }
43
51
  }
52
+ console.log("[AppResolver] No app component found");
44
53
  logger.debug("[AppResolver] No app component found");
45
54
  return null;
46
55
  }
@@ -4,5 +4,5 @@ import type { LayoutItem, MdxBundle, MDXComponents } from "../../../types/index.
4
4
  import type { ImportMapConfig } from "../../../modules/import-map/types.js";
5
5
  import type { LayoutComponentCache } from "./component-loader.js";
6
6
  export declare function applyLayoutsESM(pageElement: BundledReact.ReactElement, layoutBundle: MdxBundle | undefined, nestedLayouts: LayoutItem[], projectDir: string, mergedComponents: MDXComponents, tsxLayoutModuleCache: LayoutComponentCache, adapter: RuntimeAdapter, layoutDataMap: Map<string, Record<string, unknown>> | undefined, projectId: string, projectSlug: string, contentSourceId: string, preloadedImportMap?: ImportMapConfig): Promise<BundledReact.ReactElement>;
7
- export declare function applyLayoutsFunctionBody(pageElement: BundledReact.ReactElement, layoutBundle: MdxBundle | undefined, nestedLayouts: LayoutItem[], mergedComponents: MDXComponents, tsxLayoutModuleCache: LayoutComponentCache, projectDir: string, adapter: RuntimeAdapter, layoutDataMap: Map<string, Record<string, unknown>> | undefined, projectId: string, _projectSlug: string, contentSourceId: string): Promise<BundledReact.ReactElement>;
7
+ export declare function applyLayoutsFunctionBody(pageElement: BundledReact.ReactElement, layoutBundle: MdxBundle | undefined, nestedLayouts: LayoutItem[], mergedComponents: MDXComponents, tsxLayoutModuleCache: LayoutComponentCache, projectDir: string, adapter: RuntimeAdapter, layoutDataMap: Map<string, Record<string, unknown>> | undefined, projectId: string, projectSlug: string, contentSourceId: string): Promise<BundledReact.ReactElement>;
8
8
  //# sourceMappingURL=applicator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"applicator.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/layouts/utils/applicator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAG5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAOlE,wBAAgB,eAAe,CAC7B,WAAW,EAAE,YAAY,CAAC,YAAY,EACtC,YAAY,EAAE,SAAS,GAAG,SAAS,EACnC,aAAa,EAAE,UAAU,EAAE,EAC3B,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,aAAa,EAC/B,oBAAoB,EAAE,oBAAoB,EAC1C,OAAO,EAAE,cAAc,EACvB,aAAa,EAAE,GAAG,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,EAAE,aAAa,EAC/B,oBAAoB,EAAE,oBAAoB,EAC1C,OAAO,EAAE,cAAc,EACvB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,EAC/D,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,kBAAkB,CAAC,EAAE,eAAe,GACnC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAgHpC;AAED,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,YAAY,CAAC,YAAY,EACtC,YAAY,EAAE,SAAS,GAAG,SAAS,EACnC,aAAa,EAAE,UAAU,EAAE,EAC3B,gBAAgB,EAAE,aAAa,EAC/B,oBAAoB,EAAE,oBAAoB,EAC1C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,EAC/D,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CA0EpC"}
@@ -36,7 +36,7 @@ export function applyLayoutsESM(pageElement, layoutBundle, nestedLayouts, projec
36
36
  }
37
37
  if (item.kind === "tsx") {
38
38
  const props = item.componentPath ? layoutDataMap?.get(item.componentPath) : undefined;
39
- element = await withSpan(SpanNames.LAYOUT_APPLY_TSX, () => applyTSXLayout(element, item, tsxLayoutModuleCache, projectDir, adapter, props, projectId, contentSourceId), {
39
+ element = await withSpan(SpanNames.LAYOUT_APPLY_TSX, () => applyTSXLayout(element, item, tsxLayoutModuleCache, projectDir, adapter, props, projectId, projectSlug, contentSourceId), {
40
40
  "layout.index": i,
41
41
  "layout.kind": "tsx",
42
42
  "layout.path": item.componentPath || item.path || "",
@@ -63,7 +63,7 @@ export function applyLayoutsESM(pageElement, layoutBundle, nestedLayouts, projec
63
63
  "layout.project_slug": projectSlug || "",
64
64
  });
65
65
  }
66
- export async function applyLayoutsFunctionBody(pageElement, layoutBundle, nestedLayouts, mergedComponents, tsxLayoutModuleCache, projectDir, adapter, layoutDataMap, projectId, _projectSlug, contentSourceId) {
66
+ export async function applyLayoutsFunctionBody(pageElement, layoutBundle, nestedLayouts, mergedComponents, tsxLayoutModuleCache, projectDir, adapter, layoutDataMap, projectId, projectSlug, contentSourceId) {
67
67
  const React = await getProjectReact();
68
68
  let element = pageElement;
69
69
  logger.debug("Using function-body wrapping for layouts");
@@ -93,7 +93,7 @@ export async function applyLayoutsFunctionBody(pageElement, layoutBundle, nested
93
93
  if (item.kind !== "tsx" || !item.componentPath)
94
94
  continue;
95
95
  try {
96
- const LayoutComponent = await loadTSXComponent(item.componentPath, projectDir, tsxLayoutModuleCache, adapter, projectId, contentSourceId);
96
+ const LayoutComponent = await loadTSXComponent(item.componentPath, projectDir, tsxLayoutModuleCache, adapter, projectId, projectSlug, contentSourceId);
97
97
  const child = ensureValidChild(element, React);
98
98
  logger.debug("Applying TSX layout:", {
99
99
  layoutName: LayoutComponent.name || "Anonymous",
@@ -9,13 +9,13 @@ export interface LayoutComponentCache {
9
9
  clear(): void;
10
10
  }
11
11
  export declare function createLayoutComponentCache(maxEntries?: number): LayoutComponentCache;
12
- export declare function loadTSXComponent(componentPath: string, projectDir: string, cache: LayoutComponentCache, adapter: RuntimeAdapter, projectId: string, contentSourceId: string): Promise<BundledReact.ComponentType>;
12
+ export declare function loadTSXComponent(componentPath: string, projectDir: string, cache: LayoutComponentCache, adapter: RuntimeAdapter, projectId: string, projectSlug: string, contentSourceId: string): Promise<BundledReact.ComponentType>;
13
13
  /** Load an MDX layout module from a bundle. */
14
14
  export declare function loadMDXLayout(bundle: MdxBundle, projectDir: string, adapter: RuntimeAdapter, projectId: string, projectSlug: string, contentSourceId: string, preloadedImportMap?: ImportMapConfig): Promise<BundledReact.ComponentType<{
15
15
  components?: MDXComponents;
16
16
  }> | undefined>;
17
17
  /** Preload an MDX layout module into cache for faster subsequent loads. */
18
18
  export declare function preloadMDXLayoutModule(bundle: MdxBundle, projectDir: string, adapter: RuntimeAdapter, projectId: string, projectSlug: string, contentSourceId: string): Promise<void>;
19
- export declare function applyTSXLayout(element: BundledReact.ReactElement, item: LayoutItem, tsxLayoutModuleCache: LayoutComponentCache, projectDir: string, adapter: RuntimeAdapter, props: Record<string, unknown> | undefined, projectId: string, contentSourceId: string): Promise<BundledReact.ReactElement>;
19
+ export declare function applyTSXLayout(element: BundledReact.ReactElement, item: LayoutItem, tsxLayoutModuleCache: LayoutComponentCache, projectDir: string, adapter: RuntimeAdapter, props: Record<string, unknown> | undefined, projectId: string, projectSlug: string, contentSourceId: string): Promise<BundledReact.ReactElement>;
20
20
  export declare function applyMDXLayout(element: BundledReact.ReactElement, bundle: MdxBundle, projectDir: string, mergedComponents: MDXComponents, adapter: RuntimeAdapter, projectId: string, projectSlug: string, contentSourceId: string, preloadedImportMap?: ImportMapConfig): Promise<BundledReact.ReactElement>;
21
21
  //# sourceMappingURL=component-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/layouts/utils/component-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAa,MAAM,yBAAyB,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAW5E,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC;IACzD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,aAAa,GAAG,IAAI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AC,YAAY,CAAC,CAwCpC;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,YAAY,CAAC,YAAY,EAClC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,aAAa,EAC/B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,kBAAkB,CAAC,EAAE,eAAe,GACnC,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAuBpC"}
1
+ {"version":3,"file":"component-loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/layouts/utils/component-loader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,YAAY,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAa,MAAM,yBAAyB,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAW5E,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC;IACzD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,aAAa,GAAG,IAAI,CAAC;IAC1D,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf;AAwCD,wBAAgB,0BAA0B,CACxC,UAAU,SAAyB,GAClC,oBAAoB,CAEtB;AAED,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,YA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BpC"}
@@ -45,7 +45,7 @@ class InMemoryLayoutComponentCache {
45
45
  export function createLayoutComponentCache(maxEntries = TSX_LAYOUT_MAX_ENTRIES) {
46
46
  return new InMemoryLayoutComponentCache(maxEntries);
47
47
  }
48
- export async function loadTSXComponent(componentPath, projectDir, cache, adapter, projectId, contentSourceId) {
48
+ export async function loadTSXComponent(componentPath, projectDir, cache, adapter, projectId, projectSlug, contentSourceId) {
49
49
  const source = await adapter.fs.readFile(componentPath);
50
50
  const hash = await computeHash(source);
51
51
  const cacheKey = buildLayoutComponentCacheKey(projectId, componentPath, hash, contentSourceId);
@@ -55,6 +55,7 @@ export async function loadTSXComponent(componentPath, projectDir, cache, adapter
55
55
  const loaded = await loadComponentFromSource(source, componentPath, projectDir, adapter, {
56
56
  dev: true,
57
57
  projectId,
58
+ projectSlug,
58
59
  ssr: true,
59
60
  contentSourceId,
60
61
  });
@@ -107,14 +108,18 @@ export async function preloadMDXLayoutModule(bundle, projectDir, adapter, projec
107
108
  // Just call loadMDXLayout - the module loader will cache the result
108
109
  await loadMDXLayout(bundle, projectDir, adapter, projectId, projectSlug, contentSourceId);
109
110
  }
110
- export async function applyTSXLayout(element, item, tsxLayoutModuleCache, projectDir, adapter, props, projectId, contentSourceId) {
111
+ export async function applyTSXLayout(element, item, tsxLayoutModuleCache, projectDir, adapter, props, projectId, projectSlug, contentSourceId) {
111
112
  const start = performance.now();
112
- logger.debug("[applyTSXLayout] START", { componentPath: item.componentPath, projectId });
113
+ logger.debug("[applyTSXLayout] START", {
114
+ componentPath: item.componentPath,
115
+ projectId,
116
+ projectSlug,
117
+ });
113
118
  const React = await getProjectReact();
114
119
  try {
115
120
  logger.debug("[applyTSXLayout] loadTSXComponent START", { componentPath: item.componentPath });
116
121
  const loadStart = performance.now();
117
- const LayoutComponent = await loadTSXComponent(item.componentPath, projectDir, tsxLayoutModuleCache, adapter, projectId, contentSourceId);
122
+ const LayoutComponent = await loadTSXComponent(item.componentPath, projectDir, tsxLayoutModuleCache, adapter, projectId, projectSlug, contentSourceId);
118
123
  logger.debug("[applyTSXLayout] loadTSXComponent DONE", {
119
124
  componentPath: item.componentPath,
120
125
  duration: `${(performance.now() - loadStart).toFixed(2)}ms`,
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGzE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAOjF,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,WAAW,EAAE,oBAAoB,CAAC;IAClC,iBAAiB,EAAE,aAAa,CAAC;CAClC;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,SAAS,GAAG,SAAS,CAAC;IACpC,aAAa,EAAE,UAAU,EAAE,CAAC;CAC7B;AAED,qBAAa,kBAAkB;IAC7B,OAAO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AAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpD,UAAU,CAAC,EAAE,GAAG,EAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EAC7D,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC;CAkD/B"}
@@ -64,7 +64,7 @@ export class LayoutOrchestrator {
64
64
  // 2. Preload TSX layouts
65
65
  for (const layout of tsxLayouts) {
66
66
  const componentPath = layout.componentPath;
67
- preloadPromises.push(loadTSXComponent(componentPath, this.config.projectDir, this.config.layoutCache, this.config.adapter, this.config.projectId, this.config.contentSourceId)
67
+ preloadPromises.push(loadTSXComponent(componentPath, this.config.projectDir, this.config.layoutCache, this.config.adapter, this.config.projectId, this.config.projectSlug, this.config.contentSourceId)
68
68
  .then(() => ({ type: "tsx", path: componentPath, success: true }))
69
69
  .catch((error) => {
70
70
  logger.warn("[LayoutOrchestrator] Failed to preload TSX layout (will retry during apply)", {
@@ -1 +1 @@
1
- {"version":3,"file":"http-cache.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/http-cache.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAezE,KAAK,YAAY,GAAG;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;IAC3B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAoWF;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;;;;;;GAQG;AAC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AAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAClD,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,EAAE,CAAC,CAiInB"}
@@ -368,31 +368,43 @@ export async function recoverHttpBundleByHash(hash, cacheDir) {
368
368
  // Strategy 1: Direct code lookup by hash (preferred - no URL needed)
369
369
  const cachedCode = await distributed.get(`code:${hash}`);
370
370
  if (cachedCode) {
371
- logger.info("[HTTP-CACHE] Recovering bundle via direct code lookup", { hash });
372
- await fs.mkdir(absoluteCacheDir, { recursive: true });
373
- await fs.writeTextFile(cachePath, cachedCode);
374
- logger.info("[HTTP-CACHE] Bundle recovery successful (direct)", { hash, path: cachePath });
375
- // Proactively recover transitive deps so the import retry doesn't
376
- // fail again with a different missing bundle.
377
- const BUNDLE_RE = /file:\/\/([^"'\s]+veryfront-http-bundle\/http-([a-f0-9]+)\.mjs)/gi;
378
- const transitiveDeps = [];
379
- let m;
380
- while ((m = BUNDLE_RE.exec(cachedCode)) !== null) {
381
- const tHash = m[2];
382
- if (tHash !== hash) {
383
- transitiveDeps.push({
384
- path: join(absoluteCacheDir, `http-${tHash}.mjs`),
385
- hash: tHash,
371
+ // Validate that the cached content is valid JavaScript, not compressed/gzipped.
372
+ // esm.sh sometimes stores gzip-encoded bundles with "gz:" prefix that need
373
+ // special decoding. If we see such content in the cache, skip it and re-fetch.
374
+ if (cachedCode.startsWith("gz:") || cachedCode.startsWith("gzip:")) {
375
+ logger.warn("[HTTP-CACHE] Cached code is gzip-encoded, skipping and will re-fetch", {
376
+ hash,
377
+ preview: cachedCode.substring(0, 50),
378
+ });
379
+ // Fall through to Strategy 2 (URL re-fetch)
380
+ }
381
+ else {
382
+ logger.info("[HTTP-CACHE] Recovering bundle via direct code lookup", { hash });
383
+ await fs.mkdir(absoluteCacheDir, { recursive: true });
384
+ await fs.writeTextFile(cachePath, cachedCode);
385
+ logger.info("[HTTP-CACHE] Bundle recovery successful (direct)", { hash, path: cachePath });
386
+ // Proactively recover transitive deps so the import retry doesn't
387
+ // fail again with a different missing bundle.
388
+ const BUNDLE_RE = /file:\/\/([^"'\s]+veryfront-http-bundle\/http-([a-f0-9]+)\.mjs)/gi;
389
+ const transitiveDeps = [];
390
+ let m;
391
+ while ((m = BUNDLE_RE.exec(cachedCode)) !== null) {
392
+ const tHash = m[2];
393
+ if (tHash !== hash) {
394
+ transitiveDeps.push({
395
+ path: join(absoluteCacheDir, `http-${tHash}.mjs`),
396
+ hash: tHash,
397
+ });
398
+ }
399
+ }
400
+ if (transitiveDeps.length > 0) {
401
+ logger.info("[HTTP-CACHE] Recovering transitive deps from last-resort recovery", {
402
+ count: transitiveDeps.length,
386
403
  });
404
+ await ensureHttpBundlesExist(transitiveDeps, cacheDir);
387
405
  }
406
+ return true;
388
407
  }
389
- if (transitiveDeps.length > 0) {
390
- logger.info("[HTTP-CACHE] Recovering transitive deps from last-resort recovery", {
391
- count: transitiveDeps.length,
392
- });
393
- await ensureHttpBundlesExist(transitiveDeps, cacheDir);
394
- }
395
- return true;
396
408
  }
397
409
  // Strategy 2: URL lookup then re-fetch (fallback for bundles cached before code:{hash} was added)
398
410
  const originalUrl = await distributed.get(`hash:${hash}`);
@@ -48,5 +48,5 @@ export declare function clearESMDiskCache(): Promise<void>;
48
48
  * @param contentHash - Optional content hash to validate cached file freshness
49
49
  * @returns The cached file path if found and valid, null otherwise
50
50
  */
51
- export declare function lookupMdxEsmCache(filePath: string, cacheDir: string, projectDir?: string, contentHash?: string): Promise<string | null>;
51
+ export declare function lookupMdxEsmCache(filePath: string, cacheDir: string, projectDir?: string, _contentHash?: string): Promise<string | null>;
52
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/cache/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,mCAAmC,CAAC;AAQ3C;;GAEG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAGvC;AAOD;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsBvF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAezE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,CAgClE;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAevD;AAyBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwCxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/cache/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,mCAAmC,CAAC;AAQ3C;;GAEG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAGvC;AAOD;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsBvF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAezE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,CAgClE;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAevD;AAyBD;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmCxB"}
@@ -162,7 +162,7 @@ function toMdxEsmCacheKey(filePath, projectDir) {
162
162
  * @param contentHash - Optional content hash to validate cached file freshness
163
163
  * @returns The cached file path if found and valid, null otherwise
164
164
  */
165
- export async function lookupMdxEsmCache(filePath, cacheDir, projectDir, contentHash) {
165
+ export async function lookupMdxEsmCache(filePath, cacheDir, projectDir, _contentHash) {
166
166
  const cache = await getModulePathCache(cacheDir);
167
167
  const cacheKey = toMdxEsmCacheKey(filePath, projectDir);
168
168
  const cachedPath = cache.get(cacheKey);
@@ -176,16 +176,13 @@ export async function lookupMdxEsmCache(filePath, cacheDir, projectDir, contentH
176
176
  cache.delete(cacheKey);
177
177
  return null;
178
178
  }
179
- // If contentHash provided, validate the cached file contains matching hash
180
- // The cached filename includes the content hash (e.g., module.abc123.js)
181
- if (contentHash) {
182
- const filename = cachedPath.split("/").pop() ?? "";
183
- if (!filename.includes(contentHash.slice(0, 8))) {
184
- logger.debug(`${LOG_PREFIX_MDX_LOADER} Cache hash mismatch, invalidating: ${filePath}`);
185
- cache.delete(cacheKey);
186
- return null;
187
- }
188
- }
179
+ // Note: We intentionally skip contentHash validation for MDX-ESM cached files.
180
+ // The MDX-ESM cache uses transformed-code hashes in filenames (vfmod-v13-{hash}.mjs),
181
+ // while the SSR loader provides source-code hashes. These will never match.
182
+ // The cache version in the key (v13:) provides sufficient staleness protection,
183
+ // and the file's existence confirms it's a valid transform for this codebase.
184
+ // This allows both loaders to share the same module instance, preventing
185
+ // duplicate React contexts which break hooks like useContext.
189
186
  logger.debug(`${LOG_PREFIX_MDX_LOADER} SSR reusing MDX-ESM cache: ${filePath} -> ${cachedPath}`);
190
187
  return cachedPath;
191
188
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAmYnD,wBAAsB,aAAa,CACjC,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,CAAC,CAWpB"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoYnD,wBAAsB,aAAa,CACjC,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,CAAC,CAWpB"}
@@ -50,6 +50,7 @@ async function initializeCacheDir(context) {
50
50
  }
51
51
  const localFs = getLocalFs();
52
52
  const baseCacheDir = getMdxEsmCacheDir();
53
+ // Use projectId consistently for stable cache keys (won't change if slug is renamed)
53
54
  const projectKey = encodeURIComponent(context.projectId);
54
55
  const sourceKey = encodeURIComponent(context.contentSourceId);
55
56
  const persistentCacheDir = join(baseCacheDir, projectKey, sourceKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.0.103",
3
+ "version": "0.0.105",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.0.103",
3
+ "version": "0.0.105",
4
4
  "nodeModulesDir": "auto",
5
5
  "exclude": [
6
6
  "npm/",
@@ -18,7 +18,7 @@ export async function createPackageJson(
18
18
  dependencies: {
19
19
  react: "^19.0.0",
20
20
  "react-dom": "^19.0.0",
21
- veryfront: "^0.0.97",
21
+ veryfront: "^0.0.104",
22
22
  zod: "^3.24.0",
23
23
  },
24
24
  };
@@ -31,6 +31,7 @@ export function loadComponentFromSource(
31
31
  const loader = new SSRModuleLoader({
32
32
  projectDir,
33
33
  projectId,
34
+ projectSlug: options?.projectSlug,
34
35
  adapter,
35
36
  dev,
36
37
  contentSourceId: options?.contentSourceId,
@@ -516,14 +516,19 @@ export class SSRModuleLoader {
516
516
  }
517
517
 
518
518
  if (httpBundlesOk) {
519
- const tempPath = await this.getTempPath(filePath, contentHash);
519
+ // CRITICAL: Use transformedHash (hash of the transformed code) for temp path,
520
+ // NOT contentHash (hash of source). Other modules importing this file use
521
+ // transformedHash in their import paths (set during fresh transform at line 703).
522
+ // Using contentHash here would create a path mismatch and "Module not found" errors.
523
+ const transformedHash = await this.hashContentAsync(redisCode);
524
+ const tempPath = await this.getTempPath(filePath, transformedHash);
520
525
  await this.fs.mkdir(tempPath.substring(0, tempPath.lastIndexOf("/")), {
521
526
  recursive: true,
522
527
  });
523
528
  await this.fs.writeTextFile(tempPath, redisCode);
524
- verifiedHttpBundlePaths.set(`${tempPath}:${contentHash}`, true);
529
+ verifiedHttpBundlePaths.set(`${tempPath}:${transformedHash}`, true);
525
530
 
526
- const entry: ModuleCacheEntry = { tempPath, contentHash };
531
+ const entry: ModuleCacheEntry = { tempPath, contentHash: transformedHash };
527
532
  globalModuleCache.set(contentCacheKey, entry);
528
533
  globalModuleCache.set(filePathCacheKey, entry);
529
534
 
@@ -539,8 +544,9 @@ export class SSRModuleLoader {
539
544
  // Check MDX-ESM cache to share modules with MDX loader and avoid duplicate React contexts
540
545
  if (this.options.projectId && this.options.contentSourceId) {
541
546
  const baseCacheDir = getMdxEsmCacheDir();
542
- const projectKey = hashCodeHex(this.options.projectId);
543
- const sourceKey = hashCodeHex(this.options.contentSourceId);
547
+ // Use projectId consistently for stable cache keys (matches MDX loader)
548
+ const projectKey = encodeURIComponent(this.options.projectId);
549
+ const sourceKey = this.options.contentSourceId;
544
550
  const mdxCacheDir = join(baseCacheDir, projectKey, sourceKey);
545
551
 
546
552
  const mdxCachedPath = await lookupMdxEsmCache(
@@ -1023,8 +1029,9 @@ export class SSRModuleLoader {
1023
1029
  // Use the same cache directory as MDX-ESM loader to share module instances.
1024
1030
  // This prevents issues like React context being created twice in separate files.
1025
1031
  const baseCacheDir = getMdxEsmCacheDir();
1026
- const projectKey = hashCodeHex(projectId);
1027
- const sourceKey = hashCodeHex(contentSourceId);
1032
+ // Use projectId consistently for stable cache keys (matches MDX loader)
1033
+ const projectKey = encodeURIComponent(projectId);
1034
+ const sourceKey = contentSourceId;
1028
1035
  const cacheKey = `${baseCacheDir}|${projectKey}|${sourceKey}`;
1029
1036
 
1030
1037
  const existingDir = globalTmpDirs.get(cacheKey);
@@ -11,6 +11,8 @@ import type { RuntimeAdapter } from "../../../platform/adapters/base.js";
11
11
  export interface SSRModuleLoaderOptions {
12
12
  projectDir: string;
13
13
  projectId: string;
14
+ /** Project slug for cache directory (human-readable name) */
15
+ projectSlug?: string;
14
16
  adapter: RuntimeAdapter;
15
17
  dev: boolean;
16
18
  apiBaseUrl?: string;
@@ -2,6 +2,8 @@ import type * as React from "react";
2
2
 
3
3
  export interface LoadComponentOptions {
4
4
  projectId?: string;
5
+ /** Project slug for cache directory (human-readable name) */
6
+ projectSlug?: string;
5
7
  dev?: boolean;
6
8
  moduleServerUrl?: string;
7
9
  vendorBundleHash?: string;
@@ -246,6 +246,7 @@ export class LayoutApplicator {
246
246
  this.adapter,
247
247
  {
248
248
  projectId: this.projectId ?? this.projectDir,
249
+ projectSlug: this.projectSlug,
249
250
  dev: this.mode === "development",
250
251
  moduleServerUrl: this.config?.dev?.moduleServerUrl,
251
252
  contentSourceId: this.contentSourceId,
@@ -253,7 +254,9 @@ export class LayoutApplicator {
253
254
  );
254
255
  }
255
256
 
256
- if (!App) return pageElement;
257
+ if (!App) {
258
+ return pageElement;
259
+ }
257
260
 
258
261
  const React = await getProjectReact();
259
262
  logger.debug("Wrapped page with App component");
@@ -307,6 +310,7 @@ export class LayoutApplicator {
307
310
  this.adapter,
308
311
  {
309
312
  projectId: this.projectId ?? this.projectDir,
313
+ projectSlug: this.projectSlug,
310
314
  dev: this.mode === "development",
311
315
  moduleServerUrl: this.config?.dev?.moduleServerUrl,
312
316
  contentSourceId: this.contentSourceId,
@@ -15,6 +15,12 @@ export async function resolveAppComponentPath(
15
15
  adapter: RuntimeAdapter,
16
16
  config?: VeryfrontConfig,
17
17
  ): Promise<string | null> {
18
+ console.log("[AppResolver] Starting resolution", {
19
+ projectDir,
20
+ hasAdapter: !!adapter,
21
+ hasConfig: !!config,
22
+ configApp: config?.app,
23
+ });
18
24
  logger.debug("[AppResolver] Starting resolution", {
19
25
  projectDir,
20
26
  hasAdapter: !!adapter,
@@ -55,14 +61,17 @@ export async function resolveAppComponentPath(
55
61
  for (const ext of VALID_EXTENSIONS) {
56
62
  const appPath = join(projectDir, `components/app.${ext}`);
57
63
  const exists = await adapter.fs.exists(appPath);
64
+ console.log("[AppResolver] Checking default path", { appPath, exists });
58
65
  logger.debug("[AppResolver] Checking default path", { appPath, exists });
59
66
 
60
67
  if (exists) {
68
+ console.log("[AppResolver] Found app component via discovery", { path: appPath });
61
69
  logger.debug("[AppResolver] Found app component via discovery", { path: appPath });
62
70
  return appPath;
63
71
  }
64
72
  }
65
73
 
74
+ console.log("[AppResolver] No app component found");
66
75
  logger.debug("[AppResolver] No app component found");
67
76
  return null;
68
77
  }
@@ -87,6 +87,7 @@ export function applyLayoutsESM(
87
87
  adapter,
88
88
  props,
89
89
  projectId,
90
+ projectSlug,
90
91
  contentSourceId,
91
92
  ),
92
93
  {
@@ -148,7 +149,7 @@ export async function applyLayoutsFunctionBody(
148
149
  adapter: RuntimeAdapter,
149
150
  layoutDataMap: Map<string, Record<string, unknown>> | undefined,
150
151
  projectId: string,
151
- _projectSlug: string,
152
+ projectSlug: string,
152
153
  contentSourceId: string,
153
154
  ): Promise<BundledReact.ReactElement> {
154
155
  const React = await getProjectReact();
@@ -190,6 +191,7 @@ export async function applyLayoutsFunctionBody(
190
191
  tsxLayoutModuleCache,
191
192
  adapter,
192
193
  projectId,
194
+ projectSlug,
193
195
  contentSourceId,
194
196
  );
195
197
 
@@ -70,6 +70,7 @@ export async function loadTSXComponent(
70
70
  cache: LayoutComponentCache,
71
71
  adapter: RuntimeAdapter,
72
72
  projectId: string,
73
+ projectSlug: string,
73
74
  contentSourceId: string,
74
75
  ): Promise<BundledReact.ComponentType> {
75
76
  const source = await adapter.fs.readFile(componentPath);
@@ -87,6 +88,7 @@ export async function loadTSXComponent(
87
88
  const loaded = await loadComponentFromSource(source, componentPath, projectDir, adapter, {
88
89
  dev: true,
89
90
  projectId,
91
+ projectSlug,
90
92
  ssr: true,
91
93
  contentSourceId,
92
94
  });
@@ -184,10 +186,15 @@ export async function applyTSXLayout(
184
186
  adapter: RuntimeAdapter,
185
187
  props: Record<string, unknown> | undefined,
186
188
  projectId: string,
189
+ projectSlug: string,
187
190
  contentSourceId: string,
188
191
  ): Promise<BundledReact.ReactElement> {
189
192
  const start = performance.now();
190
- logger.debug("[applyTSXLayout] START", { componentPath: item.componentPath, projectId });
193
+ logger.debug("[applyTSXLayout] START", {
194
+ componentPath: item.componentPath,
195
+ projectId,
196
+ projectSlug,
197
+ });
191
198
 
192
199
  const React = await getProjectReact();
193
200
 
@@ -201,6 +208,7 @@ export async function applyTSXLayout(
201
208
  tsxLayoutModuleCache,
202
209
  adapter,
203
210
  projectId,
211
+ projectSlug,
204
212
  contentSourceId,
205
213
  );
206
214
 
@@ -123,6 +123,7 @@ export class LayoutOrchestrator {
123
123
  this.config.layoutCache,
124
124
  this.config.adapter,
125
125
  this.config.projectId,
126
+ this.config.projectSlug,
126
127
  this.config.contentSourceId,
127
128
  )
128
129
  .then(() => ({ type: "tsx", path: componentPath, success: true }))
@@ -456,33 +456,44 @@ export async function recoverHttpBundleByHash(hash: string, cacheDir: string): P
456
456
  // Strategy 1: Direct code lookup by hash (preferred - no URL needed)
457
457
  const cachedCode = await distributed.get(`code:${hash}`);
458
458
  if (cachedCode) {
459
- logger.info("[HTTP-CACHE] Recovering bundle via direct code lookup", { hash });
460
- await fs.mkdir(absoluteCacheDir, { recursive: true });
461
- await fs.writeTextFile(cachePath, cachedCode);
462
- logger.info("[HTTP-CACHE] Bundle recovery successful (direct)", { hash, path: cachePath });
463
-
464
- // Proactively recover transitive deps so the import retry doesn't
465
- // fail again with a different missing bundle.
466
- const BUNDLE_RE = /file:\/\/([^"'\s]+veryfront-http-bundle\/http-([a-f0-9]+)\.mjs)/gi;
467
- const transitiveDeps: Array<{ path: string; hash: string }> = [];
468
- let m;
469
- while ((m = BUNDLE_RE.exec(cachedCode)) !== null) {
470
- const tHash = m[2]!;
471
- if (tHash !== hash) {
472
- transitiveDeps.push({
473
- path: join(absoluteCacheDir, `http-${tHash}.mjs`),
474
- hash: tHash,
459
+ // Validate that the cached content is valid JavaScript, not compressed/gzipped.
460
+ // esm.sh sometimes stores gzip-encoded bundles with "gz:" prefix that need
461
+ // special decoding. If we see such content in the cache, skip it and re-fetch.
462
+ if (cachedCode.startsWith("gz:") || cachedCode.startsWith("gzip:")) {
463
+ logger.warn("[HTTP-CACHE] Cached code is gzip-encoded, skipping and will re-fetch", {
464
+ hash,
465
+ preview: cachedCode.substring(0, 50),
466
+ });
467
+ // Fall through to Strategy 2 (URL re-fetch)
468
+ } else {
469
+ logger.info("[HTTP-CACHE] Recovering bundle via direct code lookup", { hash });
470
+ await fs.mkdir(absoluteCacheDir, { recursive: true });
471
+ await fs.writeTextFile(cachePath, cachedCode);
472
+ logger.info("[HTTP-CACHE] Bundle recovery successful (direct)", { hash, path: cachePath });
473
+
474
+ // Proactively recover transitive deps so the import retry doesn't
475
+ // fail again with a different missing bundle.
476
+ const BUNDLE_RE = /file:\/\/([^"'\s]+veryfront-http-bundle\/http-([a-f0-9]+)\.mjs)/gi;
477
+ const transitiveDeps: Array<{ path: string; hash: string }> = [];
478
+ let m;
479
+ while ((m = BUNDLE_RE.exec(cachedCode)) !== null) {
480
+ const tHash = m[2]!;
481
+ if (tHash !== hash) {
482
+ transitiveDeps.push({
483
+ path: join(absoluteCacheDir, `http-${tHash}.mjs`),
484
+ hash: tHash,
485
+ });
486
+ }
487
+ }
488
+ if (transitiveDeps.length > 0) {
489
+ logger.info("[HTTP-CACHE] Recovering transitive deps from last-resort recovery", {
490
+ count: transitiveDeps.length,
475
491
  });
492
+ await ensureHttpBundlesExist(transitiveDeps, cacheDir);
476
493
  }
477
- }
478
- if (transitiveDeps.length > 0) {
479
- logger.info("[HTTP-CACHE] Recovering transitive deps from last-resort recovery", {
480
- count: transitiveDeps.length,
481
- });
482
- await ensureHttpBundlesExist(transitiveDeps, cacheDir);
483
- }
484
494
 
485
- return true;
495
+ return true;
496
+ }
486
497
  }
487
498
 
488
499
  // Strategy 2: URL lookup then re-fetch (fallback for bundles cached before code:{hash} was added)
@@ -192,7 +192,7 @@ export async function lookupMdxEsmCache(
192
192
  filePath: string,
193
193
  cacheDir: string,
194
194
  projectDir?: string,
195
- contentHash?: string,
195
+ _contentHash?: string, // Intentionally unused - kept for API compatibility
196
196
  ): Promise<string | null> {
197
197
  const cache = await getModulePathCache(cacheDir);
198
198
  const cacheKey = toMdxEsmCacheKey(filePath, projectDir);
@@ -210,18 +210,13 @@ export async function lookupMdxEsmCache(
210
210
  return null;
211
211
  }
212
212
 
213
- // If contentHash provided, validate the cached file contains matching hash
214
- // The cached filename includes the content hash (e.g., module.abc123.js)
215
- if (contentHash) {
216
- const filename = cachedPath.split("/").pop() ?? "";
217
- if (!filename.includes(contentHash.slice(0, 8))) {
218
- logger.debug(
219
- `${LOG_PREFIX_MDX_LOADER} Cache hash mismatch, invalidating: ${filePath}`,
220
- );
221
- cache.delete(cacheKey);
222
- return null;
223
- }
224
- }
213
+ // Note: We intentionally skip contentHash validation for MDX-ESM cached files.
214
+ // The MDX-ESM cache uses transformed-code hashes in filenames (vfmod-v13-{hash}.mjs),
215
+ // while the SSR loader provides source-code hashes. These will never match.
216
+ // The cache version in the key (v13:) provides sufficient staleness protection,
217
+ // and the file's existence confirms it's a valid transform for this codebase.
218
+ // This allows both loaders to share the same module instance, preventing
219
+ // duplicate React contexts which break hooks like useContext.
225
220
 
226
221
  logger.debug(
227
222
  `${LOG_PREFIX_MDX_LOADER} SSR reusing MDX-ESM cache: ${filePath} -> ${cachedPath}`,
@@ -74,6 +74,7 @@ async function initializeCacheDir(context: ESMLoaderContext): Promise<string> {
74
74
 
75
75
  const localFs = getLocalFs();
76
76
  const baseCacheDir = getMdxEsmCacheDir();
77
+ // Use projectId consistently for stable cache keys (won't change if slug is renamed)
77
78
  const projectKey = encodeURIComponent(context.projectId);
78
79
  const sourceKey = encodeURIComponent(context.contentSourceId);
79
80
  const persistentCacheDir = join(baseCacheDir, projectKey, sourceKey);