veryfront 0.1.87 → 0.1.89

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 (46) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/src/cache/distributed-cache-init.d.ts +9 -0
  3. package/esm/src/cache/distributed-cache-init.d.ts.map +1 -1
  4. package/esm/src/cache/distributed-cache-init.js +70 -52
  5. package/esm/src/cache/module-cache.d.ts +6 -2
  6. package/esm/src/cache/module-cache.d.ts.map +1 -1
  7. package/esm/src/cache/module-cache.js +73 -56
  8. package/esm/src/rendering/orchestrator/module-loader/index.js +2 -2
  9. package/esm/src/transforms/esm/http-cache-wrapper.d.ts +3 -0
  10. package/esm/src/transforms/esm/http-cache-wrapper.d.ts.map +1 -1
  11. package/esm/src/transforms/esm/http-cache-wrapper.js +21 -7
  12. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
  13. package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +6 -7
  14. package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts +10 -0
  15. package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts.map +1 -0
  16. package/esm/src/transforms/mdx/esm-module-loader/cache-format.js +61 -0
  17. package/esm/src/transforms/mdx/esm-module-loader/import-transformer.d.ts.map +1 -1
  18. package/esm/src/transforms/mdx/esm-module-loader/import-transformer.js +2 -3
  19. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/cache-keys.js +3 -3
  20. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.d.ts.map +1 -1
  21. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.js +2 -1
  22. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/module-cache.d.ts.map +1 -1
  23. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/module-cache.js +5 -5
  24. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts +2 -2
  25. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts.map +1 -1
  26. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.js +4 -4
  27. package/esm/src/utils/cache-namespace.d.ts +11 -0
  28. package/esm/src/utils/cache-namespace.d.ts.map +1 -0
  29. package/esm/src/utils/cache-namespace.js +24 -0
  30. package/esm/src/utils/version.d.ts +1 -1
  31. package/esm/src/utils/version.js +1 -1
  32. package/package.json +1 -1
  33. package/src/deno.js +1 -1
  34. package/src/src/cache/distributed-cache-init.ts +95 -59
  35. package/src/src/cache/module-cache.ts +95 -57
  36. package/src/src/rendering/orchestrator/module-loader/index.ts +2 -2
  37. package/src/src/transforms/esm/http-cache-wrapper.ts +28 -7
  38. package/src/src/transforms/mdx/esm-module-loader/cache/index.ts +6 -8
  39. package/src/src/transforms/mdx/esm-module-loader/cache-format.ts +121 -0
  40. package/src/src/transforms/mdx/esm-module-loader/import-transformer.ts +2 -3
  41. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/cache-keys.ts +3 -3
  42. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/framework-validator.ts +2 -1
  43. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/module-cache.ts +5 -5
  44. package/src/src/transforms/pipeline/stages/ssr-vf-modules/transform.ts +4 -4
  45. package/src/src/utils/cache-namespace.ts +42 -0
  46. package/src/src/utils/version.ts +1 -1
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.87",
3
+ "version": "0.1.89",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -4,7 +4,16 @@ interface DistributedCacheStatus {
4
4
  ssrModuleCache: boolean;
5
5
  fileCache: boolean;
6
6
  projectCSSCache: boolean;
7
+ httpModuleCache: boolean;
7
8
  }
9
+ type DistributedCacheInitializers = {
10
+ transformCache: () => Promise<boolean>;
11
+ ssrModuleCache: () => Promise<boolean>;
12
+ fileCache: () => Promise<boolean>;
13
+ projectCSSCache: () => Promise<boolean>;
14
+ httpModuleCache: () => Promise<boolean>;
15
+ };
16
+ export declare function __runDistributedCacheInitializationForTests(backend: DistributedCacheStatus["backend"], initializers: DistributedCacheInitializers): Promise<DistributedCacheStatus>;
8
17
  export declare function initializeDistributedCaches(): Promise<DistributedCacheStatus>;
9
18
  export {};
10
19
  //# sourceMappingURL=distributed-cache-init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"distributed-cache-init.d.ts","sourceRoot":"","sources":["../../../src/src/cache/distributed-cache-init.ts"],"names":[],"mappings":"AAYA,UAAU,sBAAsB;IAC9B,OAAO,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC7C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAaD,wBAAgB,2BAA2B,IAAI,OAAO,CAAC,sBAAsB,CAAC,CA4E7E"}
1
+ {"version":3,"file":"distributed-cache-init.d.ts","sourceRoot":"","sources":["../../../src/src/cache/distributed-cache-init.ts"],"names":[],"mappings":"AAaA,UAAU,sBAAsB;IAC9B,OAAO,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC7C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,KAAK,4BAA4B,GAAG;IAClC,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC,CAAC;AAyFF,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,YAAY,EAAE,4BAA4B,GACzC,OAAO,CAAC,sBAAsB,CAAC,CAEjC;AAED,wBAAgB,2BAA2B,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAmB7E"}
@@ -1,6 +1,7 @@
1
1
  import { initializeFileCacheBackend } from "../platform/adapters/fs/cache/file-cache.js";
2
2
  import { initializeSSRDistributedCache } from "../modules/react-loader/ssr-module-loader/index.js";
3
3
  import { initializeTransformCache } from "../transforms/esm/transform-cache.js";
4
+ import { initializeHttpModuleDistributedCache } from "../transforms/esm/http-cache-wrapper.js";
4
5
  import { SpanNames } from "../observability/tracing/span-names.js";
5
6
  import { withSpan } from "../observability/tracing/otlp-setup.js";
6
7
  import { initializeProjectCSSCache } from "../html/styles-builder/tailwind-compiler.js";
@@ -8,6 +9,13 @@ import { logger as baseLogger } from "../utils/logger/logger.js";
8
9
  import { isRedisConfigured } from "../utils/redis-client.js";
9
10
  import { isApiCacheAvailable, isDiskCacheConfigured } from "./backend.js";
10
11
  const logger = baseLogger.component("distributed-cache");
12
+ const defaultInitializers = {
13
+ transformCache: initializeTransformCache,
14
+ ssrModuleCache: initializeSSRDistributedCache,
15
+ fileCache: initializeFileCacheBackend,
16
+ projectCSSCache: initializeProjectCSSCache,
17
+ httpModuleCache: initializeHttpModuleDistributedCache,
18
+ };
11
19
  function determineBackend() {
12
20
  if (isApiCacheAvailable())
13
21
  return "api";
@@ -20,6 +28,66 @@ function determineBackend() {
20
28
  function wasSuccessful(result) {
21
29
  return result.status === "fulfilled" && result.value;
22
30
  }
31
+ async function initializeDistributedCachesWithInitializers(backend, initializers) {
32
+ logger.info("Initializing caches...", { backend });
33
+ const cacheNames = [
34
+ "transformCache",
35
+ "ssrModuleCache",
36
+ "fileCache",
37
+ "projectCSSCache",
38
+ "httpModuleCache",
39
+ ];
40
+ const results = await Promise.allSettled([
41
+ initializers.transformCache(),
42
+ initializers.ssrModuleCache(),
43
+ initializers.fileCache(),
44
+ initializers.projectCSSCache(),
45
+ initializers.httpModuleCache(),
46
+ ]);
47
+ for (let i = 0; i < results.length; i++) {
48
+ const result = results[i];
49
+ if (result && result.status === "rejected") {
50
+ logger.error(`Cache initialization failed: ${cacheNames[i]}`, {
51
+ backend,
52
+ error: result.reason instanceof Error ? result.reason.message : String(result.reason),
53
+ });
54
+ }
55
+ }
56
+ const status = {
57
+ backend,
58
+ transformCache: wasSuccessful(results[0]),
59
+ ssrModuleCache: wasSuccessful(results[1]),
60
+ fileCache: wasSuccessful(results[2]),
61
+ projectCSSCache: wasSuccessful(results[3]),
62
+ httpModuleCache: wasSuccessful(results[4]),
63
+ };
64
+ const enabled = [
65
+ status.transformCache,
66
+ status.ssrModuleCache,
67
+ status.fileCache,
68
+ status.projectCSSCache,
69
+ status.httpModuleCache,
70
+ ].filter(Boolean).length;
71
+ if (enabled === 0) {
72
+ logger.warn("No caches enabled despite backend being available", {
73
+ backend,
74
+ });
75
+ return status;
76
+ }
77
+ logger.info("Initialization complete", {
78
+ backend,
79
+ enabled,
80
+ transform: status.transformCache,
81
+ ssrModule: status.ssrModuleCache,
82
+ file: status.fileCache,
83
+ projectCSS: status.projectCSSCache,
84
+ httpModule: status.httpModuleCache,
85
+ });
86
+ return status;
87
+ }
88
+ export function __runDistributedCacheInitializationForTests(backend, initializers) {
89
+ return initializeDistributedCachesWithInitializers(backend, initializers);
90
+ }
23
91
  export function initializeDistributedCaches() {
24
92
  const backend = determineBackend();
25
93
  if (backend === "memory") {
@@ -29,58 +97,8 @@ export function initializeDistributedCaches() {
29
97
  ssrModuleCache: false,
30
98
  fileCache: false,
31
99
  projectCSSCache: false,
100
+ httpModuleCache: false,
32
101
  });
33
102
  }
34
- return withSpan(SpanNames.CACHE_DISTRIBUTED_INIT, async () => {
35
- logger.info("Initializing caches...", { backend });
36
- const cacheNames = [
37
- "transformCache",
38
- "ssrModuleCache",
39
- "fileCache",
40
- "projectCSSCache",
41
- ];
42
- const results = await Promise.allSettled([
43
- initializeTransformCache(),
44
- initializeSSRDistributedCache(),
45
- initializeFileCacheBackend(),
46
- initializeProjectCSSCache(),
47
- ]);
48
- for (let i = 0; i < results.length; i++) {
49
- const result = results[i];
50
- if (result && result.status === "rejected") {
51
- logger.error(`Cache initialization failed: ${cacheNames[i]}`, {
52
- backend,
53
- error: result.reason instanceof Error ? result.reason.message : String(result.reason),
54
- });
55
- }
56
- }
57
- const status = {
58
- backend,
59
- transformCache: wasSuccessful(results[0]),
60
- ssrModuleCache: wasSuccessful(results[1]),
61
- fileCache: wasSuccessful(results[2]),
62
- projectCSSCache: wasSuccessful(results[3]),
63
- };
64
- const enabled = [
65
- status.transformCache,
66
- status.ssrModuleCache,
67
- status.fileCache,
68
- status.projectCSSCache,
69
- ].filter(Boolean).length;
70
- if (enabled === 0) {
71
- logger.warn("No caches enabled despite backend being available", {
72
- backend,
73
- });
74
- return status;
75
- }
76
- logger.info("Initialization complete", {
77
- backend,
78
- enabled,
79
- transform: status.transformCache,
80
- ssrModule: status.ssrModuleCache,
81
- file: status.fileCache,
82
- projectCSS: status.projectCSSCache,
83
- });
84
- return status;
85
- }, { "cache.backend": backend });
103
+ return withSpan(SpanNames.CACHE_DISTRIBUTED_INIT, () => initializeDistributedCachesWithInitializers(backend, defaultInitializers), { "cache.backend": backend });
86
104
  }
@@ -2,6 +2,10 @@
2
2
  * Pod-Level Module Cache Singleton
3
3
  **************************/
4
4
  import { LRUCache } from "../utils/lru-wrapper.js";
5
+ export interface ModuleCacheMap extends Map<string, string> {
6
+ getOrInsert(key: string, value: string): string;
7
+ getOrInsertComputed(key: string, callback: (key: string) => string): string;
8
+ }
5
9
  interface ModuleCacheStats {
6
10
  moduleCache: {
7
11
  size: number;
@@ -16,8 +20,8 @@ interface ModuleCacheStats {
16
20
  }
17
21
  export declare function getModuleCache(): LRUCache<string, string>;
18
22
  export declare function getEsmCache(): LRUCache<string, string>;
19
- export declare function createModuleCache(): Map<string, string>;
20
- export declare function createEsmCache(): Map<string, string>;
23
+ export declare function createModuleCache(): ModuleCacheMap;
24
+ export declare function createEsmCache(): ModuleCacheMap;
21
25
  export declare function getModuleCacheStats(): ModuleCacheStats;
22
26
  export declare function clearModuleCaches(): void;
23
27
  export declare function clearModuleCacheForProject(projectId: string): number;
@@ -1 +1 @@
1
- {"version":3,"file":"module-cache.d.ts","sourceRoot":"","sources":["../../../src/src/cache/module-cache.ts"],"names":[],"mappings":"AAAA;;4BAE4B;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAenD,UAAU,gBAAgB;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAqDD,wBAAgB,cAAc,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAEtD;AAED,wBAAgB,iBAAiB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEvD;AAED,wBAAgB,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpD;AA6DD,wBAAgB,mBAAmB,IAAI,gBAAgB,CAatD;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAgBpE;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C"}
1
+ {"version":3,"file":"module-cache.d.ts","sourceRoot":"","sources":["../../../src/src/cache/module-cache.ts"],"names":[],"mappings":"AAAA;;4BAE4B;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAenD,MAAM,WAAW,cAAe,SAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IACzD,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC;CAC7E;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAqDD,wBAAgB,cAAc,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAEtD;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAElD;AAED,wBAAgB,cAAc,IAAI,cAAc,CAE/C;AA8FD,wBAAgB,mBAAmB,IAAI,gBAAgB,CAatD;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAgBpE;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C"}
@@ -57,64 +57,81 @@ export function createEsmCache() {
57
57
  return createMapInterface(getEsmCache());
58
58
  }
59
59
  function createMapInterface(cache) {
60
- const map = {
61
- get(key) {
62
- return cache.get(key);
63
- },
64
- set(key, value) {
65
- cache.set(key, value);
66
- return map;
67
- },
68
- has(key) {
69
- return cache.has(key);
70
- },
71
- delete(key) {
72
- return cache.delete(key);
73
- },
74
- clear() {
75
- cache.clear();
76
- },
77
- get size() {
78
- return cache.size;
79
- },
80
- keys() {
81
- return cache.keys();
82
- },
83
- values() {
84
- const keysIter = cache.keys();
85
- const cacheRef = cache;
86
- return (function* () {
87
- for (const key of keysIter) {
88
- const value = cacheRef.get(key);
89
- if (value !== undefined)
90
- yield value;
91
- }
92
- })();
93
- },
94
- entries() {
95
- const keysIter = cache.keys();
96
- const cacheRef = cache;
97
- return (function* () {
98
- for (const key of keysIter) {
99
- const value = cacheRef.get(key);
100
- if (value !== undefined)
101
- yield [key, value];
102
- }
103
- })();
104
- },
105
- forEach(callback) {
106
- for (const key of cache.keys()) {
107
- const value = cache.get(key);
60
+ return new LRUBackedMap(cache);
61
+ }
62
+ class LRUBackedMap {
63
+ cache;
64
+ [Symbol.toStringTag] = "Map";
65
+ constructor(cache) {
66
+ this.cache = cache;
67
+ }
68
+ get(key) {
69
+ return this.cache.get(key);
70
+ }
71
+ set(key, value) {
72
+ this.cache.set(key, value);
73
+ return this;
74
+ }
75
+ has(key) {
76
+ return this.cache.has(key);
77
+ }
78
+ delete(key) {
79
+ return this.cache.delete(key);
80
+ }
81
+ clear() {
82
+ this.cache.clear();
83
+ }
84
+ getOrInsert(key, value) {
85
+ const existing = this.cache.get(key);
86
+ if (existing !== undefined)
87
+ return existing;
88
+ this.cache.set(key, value);
89
+ return value;
90
+ }
91
+ getOrInsertComputed(key, callback) {
92
+ const existing = this.cache.get(key);
93
+ if (existing !== undefined)
94
+ return existing;
95
+ const value = callback(key);
96
+ this.cache.set(key, value);
97
+ return value;
98
+ }
99
+ get size() {
100
+ return this.cache.size;
101
+ }
102
+ keys() {
103
+ return this.cache.keys();
104
+ }
105
+ values() {
106
+ const keysIter = this.cache.keys();
107
+ const cacheRef = this.cache;
108
+ return (function* () {
109
+ for (const key of keysIter) {
110
+ const value = cacheRef.get(key);
108
111
  if (value !== undefined)
109
- callback(value, key, map);
112
+ yield value;
110
113
  }
111
- },
112
- [Symbol.iterator]() {
113
- return map.entries();
114
- },
115
- [Symbol.toStringTag]: "Map",
116
- };
117
- return map;
114
+ })();
115
+ }
116
+ entries() {
117
+ const keysIter = this.cache.keys();
118
+ const cacheRef = this.cache;
119
+ return (function* () {
120
+ for (const key of keysIter) {
121
+ const value = cacheRef.get(key);
122
+ if (value !== undefined)
123
+ yield [key, value];
124
+ }
125
+ })();
126
+ }
127
+ forEach(callback, thisArg) {
128
+ for (const [key, value] of this.entries()) {
129
+ callback.call(thisArg, value, key, this);
130
+ }
131
+ }
132
+ [Symbol.iterator]() {
133
+ return this.entries();
134
+ }
118
135
  }
119
136
  export function getModuleCacheStats() {
120
137
  return {
@@ -18,8 +18,8 @@ import { validateCachedBundlesByManifestOrCode } from "../../../transforms/esm/c
18
18
  import { getHttpBundleCacheDir, getMdxEsmCacheDir } from "../../../utils/cache-dir.js";
19
19
  import { dirname, join, normalize } from "../../../platform/compat/path/index.js";
20
20
  import { hashCodeHex } from "../../../utils/hash-utils.js";
21
- import { VERSION } from "../../../utils/version.js";
22
21
  import { getModulePathCache, lookupMdxEsmCache, saveModulePathCache, } from "../../../transforms/mdx/esm-module-loader/cache/index.js";
22
+ import { buildMdxEsmPathCacheKey } from "../../../transforms/mdx/esm-module-loader/cache-format.js";
23
23
  const logger = rendererLogger.component("module-loader");
24
24
  // Re-export utilities
25
25
  export { createEsmCache, createModuleCache, generateHash } from "./cache.js";
@@ -327,7 +327,7 @@ export async function transformModuleWithDeps(filePath, tmpDir, localAdapter, co
327
327
  }
328
328
  if (contentSourceId) {
329
329
  const normalizedPath = `_vf_modules/${relativePath.replace(/\.(tsx?|jsx|mdx)$/, ".js")}`;
330
- const mdxCacheKey = `v${VERSION}:${normalizedPath}`;
330
+ const mdxCacheKey = buildMdxEsmPathCacheKey(normalizedPath);
331
331
  const cache = await getModulePathCache(tmpDir);
332
332
  cache.set(mdxCacheKey, tempFilePath);
333
333
  saveModulePathCache(tmpDir).catch((err) => {
@@ -10,8 +10,11 @@
10
10
  *
11
11
  * @module transforms/esm/http-cache-wrapper
12
12
  */
13
+ import type { CacheBackend } from "../../cache/types.js";
13
14
  import type { BundleHash, LocalModuleCode, NormalizedUrl, PortableModuleCode } from "./http-cache-types.js";
14
15
  import { asBundleHash } from "./http-cache-invariants.js";
16
+ export declare function __setDistributedCacheAccessorForTests(accessor: (() => Promise<CacheBackend | null>) | null): void;
17
+ export declare function initializeHttpModuleDistributedCache(): Promise<boolean>;
15
18
  /**
16
19
  * Tokenize local code paths to portable format.
17
20
  * Replaces absolute cache directory paths with __VF_CACHE_DIR__ tokens.
@@ -1 +1 @@
1
- {"version":3,"file":"http-cache-wrapper.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/http-cache-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,OAAO,KAAK,EACV,UAAU,EAEV,eAAe,EACf,aAAa,EACb,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,YAAY,EAKb,MAAM,4BAA4B,CAAC;AAuBpC;;;;;;GAMG;AACH,iBAAS,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,kBAAkB,CAoB3D;AAED;;;GAGG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,GAAG,eAAe,CAMtE;AAmCD;;GAEG;AACH,UAAU,aAAa;IACrB,wEAAwE;IACxE,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7B,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,WAAW,GAAG,oBAAoB,GAAG,cAAc,GAAG,OAAO,CAAC;CAC5E;AAED;;;;;;;;;GASG;AACH,cAAM,eAAe;IACnB;;;;;;OAMG;IACG,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAiDtE;;;;;;OAMG;IACG,YAAY,CAAC,IAAI,EAAE,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OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAItC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,iBAAwB,CAAC;AAErD;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC"}
@@ -23,6 +23,20 @@ const logger = rendererLogger.component("http-cache-wrapper");
23
23
  const BATCH_FETCH_CHUNK_SIZE = 100;
24
24
  /** Lazy-loaded distributed cache backend for cross-pod sharing */
25
25
  const getDistributedCache = createDistributedCacheAccessor(() => CacheBackends.httpModule(), "HTTP-CACHE-WRAPPER");
26
+ let testDistributedCacheAccessor = null;
27
+ function resolveDistributedCache() {
28
+ return testDistributedCacheAccessor ? testDistributedCacheAccessor() : getDistributedCache();
29
+ }
30
+ export function __setDistributedCacheAccessorForTests(accessor) {
31
+ testDistributedCacheAccessor = accessor;
32
+ }
33
+ export async function initializeHttpModuleDistributedCache() {
34
+ const distributed = await resolveDistributedCache();
35
+ if (!distributed)
36
+ return false;
37
+ logger.info("Initialized distributed cache backend", { backend: distributed.type });
38
+ return true;
39
+ }
26
40
  /**
27
41
  * Generate versioned cache key for HTTP bundles.
28
42
  * Format: {VERSION}:{prefix}:{hash}
@@ -110,7 +124,7 @@ class HttpBundleCache {
110
124
  * @returns Result containing local code or failure reason
111
125
  */
112
126
  async getCodeByHash(hash) {
113
- const distributed = await getDistributedCache();
127
+ const distributed = await resolveDistributedCache();
114
128
  if (!distributed) {
115
129
  return { code: null, wasGzipped: false, failReason: "not_found" };
116
130
  }
@@ -160,7 +174,7 @@ class HttpBundleCache {
160
174
  * @returns Result containing local code or failure reason
161
175
  */
162
176
  async getCodeByUrl(hash) {
163
- const distributed = await getDistributedCache();
177
+ const distributed = await resolveDistributedCache();
164
178
  if (!distributed) {
165
179
  return { code: null, wasGzipped: false, failReason: "not_found" };
166
180
  }
@@ -200,7 +214,7 @@ class HttpBundleCache {
200
214
  * @param ttl - TTL in seconds (defaults to HTTP_MODULE_DISTRIBUTED_TTL_SEC)
201
215
  */
202
216
  async setCode(hash, code, url, ttl = HTTP_MODULE_DISTRIBUTED_TTL_SEC) {
203
- const distributed = await getDistributedCache();
217
+ const distributed = await resolveDistributedCache();
204
218
  if (!distributed)
205
219
  return;
206
220
  const hashStr = typeof hash === "string" ? hash : hash;
@@ -233,7 +247,7 @@ class HttpBundleCache {
233
247
  * @returns Map of hash -> local code (missing/failed hashes not included)
234
248
  */
235
249
  async getBatchCodes(hashes) {
236
- const distributed = await getDistributedCache();
250
+ const distributed = await resolveDistributedCache();
237
251
  if (!distributed)
238
252
  return new Map();
239
253
  const results = new Map();
@@ -278,7 +292,7 @@ class HttpBundleCache {
278
292
  * @returns Original URL or null
279
293
  */
280
294
  async getOriginalUrl(hash) {
281
- const distributed = await getDistributedCache();
295
+ const distributed = await resolveDistributedCache();
282
296
  if (!distributed)
283
297
  return null;
284
298
  const hashStr = typeof hash === "string" ? hash : hash;
@@ -298,7 +312,7 @@ class HttpBundleCache {
298
312
  * @returns true if deletion was attempted, false if cache unavailable
299
313
  */
300
314
  async deleteCode(hash) {
301
- const distributed = await getDistributedCache();
315
+ const distributed = await resolveDistributedCache();
302
316
  if (!distributed)
303
317
  return false;
304
318
  const hashStr = typeof hash === "string" ? hash : hash;
@@ -321,7 +335,7 @@ class HttpBundleCache {
321
335
  * Check if distributed cache is available.
322
336
  */
323
337
  async isAvailable() {
324
- const distributed = await getDistributedCache();
338
+ const distributed = await resolveDistributedCache();
325
339
  return distributed !== null;
326
340
  }
327
341
  }
@@ -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;AASH,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EA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AAQ,EAAE,MAAM,kCAAkC,CAAC;AAG5D,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAI9D,eAAO,MAAM,kBAAkB,wBAE7B,CAAC;AA0GH,wBAAgB,UAAU,IAAI,UAAU,CAGvC;AAKD,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsBvF;AAED,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAezE;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C;AAQD,2DAA2D;AAC3D,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,CA0ElE;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAevD;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAc1D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIzD;AAeD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAyG5B"}
@@ -9,14 +9,13 @@ import { join } from "../../../../platform/compat/path/index.js";
9
9
  import { rendererLogger as logger } from "../../../../utils/index.js";
10
10
  import { getCacheBaseDir, getHttpBundleCacheDir, getMdxEsmCacheDir, } from "../../../../utils/cache-dir.js";
11
11
  import { createFileSystem, isNotFoundError, } from "../../../../platform/compat/fs.js";
12
- import { VERSION } from "../../../../utils/version.js";
13
12
  import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
14
13
  import { LRUCache } from "../../../../utils/lru-wrapper.js";
14
+ import { buildMdxEsmPathCacheKey, MDX_ESM_ALL_FILE_URL_PATTERN_SOURCE } from "../cache-format.js";
15
15
  const MAX_VERIFIED_MODULE_DEPS = 2_000;
16
16
  export const verifiedModuleDeps = new LRUCache({
17
17
  maxEntries: MAX_VERIFIED_MODULE_DEPS,
18
18
  });
19
- const FILE_PATH_PATTERN = /file:\/\/([^"'\s]+)/gi;
20
19
  /**
21
20
  * Check if cached code has file:// paths from a different environment.
22
21
  * Checks both HTTP bundle paths and MDX ESM cache paths.
@@ -25,7 +24,7 @@ function hasIncompatibleCachePaths(code) {
25
24
  const localCacheBaseDir = getCacheBaseDir();
26
25
  const localHttpCacheDir = getHttpBundleCacheDir();
27
26
  const localMdxCacheDir = getMdxEsmCacheDir();
28
- const pattern = new RegExp(FILE_PATH_PATTERN.source, "gi");
27
+ const pattern = new RegExp(MDX_ESM_ALL_FILE_URL_PATTERN_SOURCE, "gi");
29
28
  let match;
30
29
  while ((match = pattern.exec(code)) !== null) {
31
30
  const path = match[1];
@@ -64,7 +63,7 @@ function hasIncompatibleCachePaths(code) {
64
63
  */
65
64
  async function findMissingFileDependencies(code) {
66
65
  const localFs = getLocalFs();
67
- const pattern = new RegExp(FILE_PATH_PATTERN.source, "gi");
66
+ const pattern = new RegExp(MDX_ESM_ALL_FILE_URL_PATTERN_SOURCE, "gi");
68
67
  const missing = [];
69
68
  let match;
70
69
  while ((match = pattern.exec(code)) !== null) {
@@ -284,7 +283,7 @@ function toMdxEsmCacheKey(filePath, projectDir) {
284
283
  }
285
284
  relativePath = relativePath.replace(/^\/+/, "");
286
285
  const jsPath = relativePath.replace(/\.(tsx?|jsx|mdx)$/, ".js");
287
- return `v${VERSION}:_vf_modules/${jsPath}`;
286
+ return buildMdxEsmPathCacheKey(`_vf_modules/${jsPath}`);
288
287
  }
289
288
  export async function lookupMdxEsmCache(filePath, cacheDir, projectDir, _contentHash) {
290
289
  const cache = await getModulePathCache(cacheDir);
@@ -356,9 +355,9 @@ export async function lookupMdxEsmCache(filePath, cacheDir, projectDir, _content
356
355
  };
357
356
  }
358
357
  // Note: We intentionally skip contentHash validation for MDX-ESM cached files.
359
- // The MDX-ESM cache uses transformed-code hashes in filenames (vfmod-v{VERSION}-{hash}.mjs),
358
+ // The MDX-ESM cache uses transformed-code hashes in namespaced filenames,
360
359
  // while the SSR loader provides source-code hashes. These will never match.
361
- // The cache version in the key (v{VERSION}:) provides sufficient staleness protection,
360
+ // The cache namespace in the key provides sufficient staleness protection,
362
361
  // and the file's existence confirms it's a valid transform for this codebase.
363
362
  // This allows both loaders to share the same module instance, preventing
364
363
  // duplicate React contexts which break hooks like useContext.
@@ -0,0 +1,10 @@
1
+ export declare const MDX_ESM_ALL_FILE_URL_PATTERN_SOURCE: string;
2
+ export declare const MDX_ESM_MJS_FILE_URL_PATTERN_SOURCE: string;
3
+ export declare const MDX_ESM_CACHE_NAMESPACE: string;
4
+ export declare const FRAMEWORK_VF_MODULE_CACHE_NAMESPACE: string;
5
+ export declare function buildMdxEsmTransformCacheKey(projectId: string, normalizedPath: string, contentHash: string): string;
6
+ export declare function buildMdxEsmPathCacheKey(normalizedPath: string): string;
7
+ export declare function buildMdxEsmModuleFileName(contentHash: string): string;
8
+ export declare function buildMdxJsxCacheFileName(filePath: string): string;
9
+ export declare function buildFrameworkVfModuleCacheFileName(pathHash: string, envKey: string, contentHash: string): string;
10
+ //# sourceMappingURL=cache-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-format.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/cache-format.ts"],"names":[],"mappings":"AAuEA,eAAO,MAAM,mCAAmC,QAA8B,CAAC;AAC/E,eAAO,MAAM,mCAAmC,QAA8B,CAAC;AAE/E,eAAO,MAAM,uBAAuB,QAGnC,CAAC;AAEF,eAAO,MAAM,mCAAmC,QAG/C,CAAC;AAEF,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,GAClB,MAAM,CAOR;AAED,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,CAOR"}
@@ -0,0 +1,61 @@
1
+ import { hashCodeHex } from "../../../utils/hash-utils.js";
2
+ import { createCacheNamespace } from "../../../utils/cache-namespace.js";
3
+ import { UNRESOLVED_VF_MODULES_PATTERN } from "./constants.js";
4
+ import { hashString } from "./utils/hash.js";
5
+ const ALL_FILE_URL_PATTERN_SOURCE = /file:\/\/([^"'\s]+)/.source;
6
+ const MJS_FILE_URL_PATTERN_SOURCE = /file:\/\/([^"'\s]+\.mjs)/.source;
7
+ const CACHE_NAMESPACE_SENTINEL = "__vf_cache_namespace__";
8
+ function formatMdxEsmTransformCacheKey(namespace, projectId, normalizedPath, contentHash) {
9
+ return `${namespace}:${projectId}:${normalizedPath}:${contentHash}:ssr`;
10
+ }
11
+ function formatMdxEsmPathCacheKey(namespace, normalizedPath) {
12
+ return `${namespace}:${normalizedPath}`;
13
+ }
14
+ function formatMdxEsmModuleFileName(namespace, contentHash) {
15
+ return `vfmod-${namespace}-${contentHash}.mjs`;
16
+ }
17
+ function formatMdxJsxCacheFileName(namespace, filePath) {
18
+ return `jsx-${namespace}-${hashString(filePath)}.mjs`;
19
+ }
20
+ function formatFrameworkVfModuleCacheFileName(namespace, pathHash, envKey, contentHash) {
21
+ return `vfmod-${namespace}-${pathHash}-${envKey}-${contentHash}.mjs`;
22
+ }
23
+ function buildMdxEsmCacheSchemaSample() {
24
+ return {
25
+ transformKey: formatMdxEsmTransformCacheKey(CACHE_NAMESPACE_SENTINEL, "__vf_project__", "_vf_modules/pages/index.js", "deadbeef"),
26
+ pathKey: formatMdxEsmPathCacheKey(CACHE_NAMESPACE_SENTINEL, "_vf_modules/pages/index.js"),
27
+ moduleFile: formatMdxEsmModuleFileName(CACHE_NAMESPACE_SENTINEL, "deadbeef"),
28
+ jsxFile: formatMdxJsxCacheFileName(CACHE_NAMESPACE_SENTINEL, "/tmp/project/Button.tsx"),
29
+ unresolvedVfModulesPattern: UNRESOLVED_VF_MODULES_PATTERN.source,
30
+ allFileUrlPattern: ALL_FILE_URL_PATTERN_SOURCE,
31
+ mjsFileUrlPattern: MJS_FILE_URL_PATTERN_SOURCE,
32
+ sourceHashing: [
33
+ hashString("_vf_modules/pages/index.jsexport default 1;"),
34
+ hashString("/tmp/project/Button.tsx"),
35
+ ],
36
+ };
37
+ }
38
+ function buildFrameworkVfModuleCacheSchemaSample() {
39
+ return {
40
+ moduleFile: formatFrameworkVfModuleCacheFileName(CACHE_NAMESPACE_SENTINEL, hashCodeHex("_vf_modules/_veryfront/react/components/Head.js"), hashCodeHex("/app/.cache/veryfront-mdx-esm").slice(0, 8), hashCodeHex("export default function Head() {}")),
41
+ };
42
+ }
43
+ export const MDX_ESM_ALL_FILE_URL_PATTERN_SOURCE = ALL_FILE_URL_PATTERN_SOURCE;
44
+ export const MDX_ESM_MJS_FILE_URL_PATTERN_SOURCE = MJS_FILE_URL_PATTERN_SOURCE;
45
+ export const MDX_ESM_CACHE_NAMESPACE = createCacheNamespace("mdx-esm", buildMdxEsmCacheSchemaSample());
46
+ export const FRAMEWORK_VF_MODULE_CACHE_NAMESPACE = createCacheNamespace("vf-framework", buildFrameworkVfModuleCacheSchemaSample());
47
+ export function buildMdxEsmTransformCacheKey(projectId, normalizedPath, contentHash) {
48
+ return formatMdxEsmTransformCacheKey(MDX_ESM_CACHE_NAMESPACE, projectId, normalizedPath, contentHash);
49
+ }
50
+ export function buildMdxEsmPathCacheKey(normalizedPath) {
51
+ return formatMdxEsmPathCacheKey(MDX_ESM_CACHE_NAMESPACE, normalizedPath);
52
+ }
53
+ export function buildMdxEsmModuleFileName(contentHash) {
54
+ return formatMdxEsmModuleFileName(MDX_ESM_CACHE_NAMESPACE, contentHash);
55
+ }
56
+ export function buildMdxJsxCacheFileName(filePath) {
57
+ return formatMdxJsxCacheFileName(MDX_ESM_CACHE_NAMESPACE, filePath);
58
+ }
59
+ export function buildFrameworkVfModuleCacheFileName(pathHash, envKey, contentHash) {
60
+ return formatFrameworkVfModuleCacheFileName(FRAMEWORK_VF_MODULE_CACHE_NAMESPACE, pathHash, envKey, contentHash);
61
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"import-transformer.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/import-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAgB5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9E;AAyBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,GAAG,MAAM,CAIjF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA0HjB"}
1
+ {"version":3,"file":"import-transformer.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/import-transformer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAe5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9E;AAyBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,GAAG,MAAM,CAIjF;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACpC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CA0HjB"}