veryfront 0.1.738 → 0.1.742

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 (78) hide show
  1. package/esm/cli/templates/manifest.js +3 -3
  2. package/esm/deno.js +1 -1
  3. package/esm/src/agent/ag-ui/sse-parser.d.ts.map +1 -1
  4. package/esm/src/agent/ag-ui/sse-parser.js +20 -12
  5. package/esm/src/agent/hosted/child-tool-input.js +1 -1
  6. package/esm/src/agent/react/use-chat/streaming/handler.d.ts.map +1 -1
  7. package/esm/src/agent/react/use-chat/streaming/handler.js +53 -39
  8. package/esm/src/fs/index.d.ts +1 -1
  9. package/esm/src/fs/index.d.ts.map +1 -1
  10. package/esm/src/fs/index.js +1 -1
  11. package/esm/src/mcp/http-transport.js +1 -1
  12. package/esm/src/mcp/server.d.ts.map +1 -1
  13. package/esm/src/mcp/server.js +1 -4
  14. package/esm/src/mcp/session.d.ts +23 -0
  15. package/esm/src/mcp/session.d.ts.map +1 -1
  16. package/esm/src/mcp/session.js +46 -3
  17. package/esm/src/modules/manifest/route-module-manifest.d.ts.map +1 -1
  18. package/esm/src/modules/manifest/route-module-manifest.js +12 -4
  19. package/esm/src/modules/react-loader/ssr-module-loader/cross-project-import-loader.d.ts.map +1 -1
  20. package/esm/src/modules/react-loader/ssr-module-loader/cross-project-import-loader.js +2 -1
  21. package/esm/src/modules/server/cross-project-source-limit.d.ts +7 -0
  22. package/esm/src/modules/server/cross-project-source-limit.d.ts.map +1 -0
  23. package/esm/src/modules/server/cross-project-source-limit.js +46 -0
  24. package/esm/src/modules/server/module-batch-handler.d.ts.map +1 -1
  25. package/esm/src/modules/server/module-batch-handler.js +3 -4
  26. package/esm/src/modules/server/module-server.d.ts.map +1 -1
  27. package/esm/src/modules/server/module-server.js +11 -1
  28. package/esm/src/oauth/handlers/init-handler.js +6 -6
  29. package/esm/src/oauth/providers/base.d.ts +3 -0
  30. package/esm/src/oauth/providers/base.d.ts.map +1 -1
  31. package/esm/src/oauth/providers/base.js +24 -2
  32. package/esm/src/platform/compat/fs.d.ts +6 -0
  33. package/esm/src/platform/compat/fs.d.ts.map +1 -1
  34. package/esm/src/platform/compat/fs.js +12 -0
  35. package/esm/src/provider/runtime-loader/tool-input-status.d.ts.map +1 -1
  36. package/esm/src/provider/runtime-loader/tool-input-status.js +16 -8
  37. package/esm/src/rendering/orchestrator/module-loader/dependency-resolver.d.ts +2 -0
  38. package/esm/src/rendering/orchestrator/module-loader/dependency-resolver.d.ts.map +1 -1
  39. package/esm/src/rendering/orchestrator/module-loader/dependency-resolver.js +23 -10
  40. package/esm/src/rendering/renderer-concurrency.d.ts.map +1 -1
  41. package/esm/src/rendering/renderer-concurrency.js +9 -2
  42. package/esm/src/security/sandbox/worker-permissions.d.ts +10 -7
  43. package/esm/src/security/sandbox/worker-permissions.d.ts.map +1 -1
  44. package/esm/src/security/sandbox/worker-permissions.js +32 -12
  45. package/esm/src/security/utils/constant-time.d.ts.map +1 -1
  46. package/esm/src/security/utils/constant-time.js +4 -1
  47. package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
  48. package/esm/src/server/services/rendering/ssr.service.js +6 -3
  49. package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.d.ts +4 -0
  50. package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.d.ts.map +1 -1
  51. package/esm/src/transforms/mdx/esm-module-loader/loader-helpers.js +22 -18
  52. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/http-fetcher.d.ts.map +1 -1
  53. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/http-fetcher.js +27 -8
  54. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/import-rewriter.d.ts.map +1 -1
  55. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/import-rewriter.js +24 -14
  56. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -1
  57. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
  58. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -1
  59. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts +4 -0
  60. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts.map +1 -1
  61. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.js +45 -37
  62. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/path-cache-lookup.d.ts.map +1 -1
  63. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/path-cache-lookup.js +6 -1
  64. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts +5 -0
  65. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts.map +1 -1
  66. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.js +27 -2
  67. package/esm/src/transforms/mdx/esm-module-loader/types.d.ts +2 -0
  68. package/esm/src/transforms/mdx/esm-module-loader/types.d.ts.map +1 -1
  69. package/esm/src/transforms/mdx/esm-module-loader/utils/source-spans.d.ts +23 -0
  70. package/esm/src/transforms/mdx/esm-module-loader/utils/source-spans.d.ts.map +1 -0
  71. package/esm/src/transforms/mdx/esm-module-loader/utils/source-spans.js +188 -0
  72. package/esm/src/utils/version-constant.d.ts +1 -1
  73. package/esm/src/utils/version-constant.js +1 -1
  74. package/esm/src/workflow/executor/dag/index.d.ts.map +1 -1
  75. package/esm/src/workflow/executor/dag/index.js +9 -8
  76. package/esm/src/workflow/worker/workflow-worker.d.ts.map +1 -1
  77. package/esm/src/workflow/worker/workflow-worker.js +9 -1
  78. package/package.json +1 -1
@@ -11,6 +11,7 @@ import { SpanNames } from "../../../../observability/tracing/span-names.js";
11
11
  import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
12
12
  import { rewriteVeryfrontImports } from "./import-rewriter.js";
13
13
  import { findNestedImports } from "./nested-imports.js";
14
+ import { replaceSourceSpans } from "../utils/source-spans.js";
14
15
  /**
15
16
  * Fetch module via HTTP as a fallback (local development only).
16
17
  *
@@ -38,20 +39,38 @@ export async function fetchModuleViaHTTP(normalizedPath, adapter, fetchAndCacheM
38
39
  log.warn(`${LOG_PREFIX_MDX_LOADER} HTTP fetch also failed: ${moduleUrl} (${response.status})`);
39
40
  return null;
40
41
  }
41
- let moduleCode = rewriteVeryfrontImports(await response.text());
42
+ const moduleCode = rewriteVeryfrontImports(await response.text());
42
43
  const { vfModules, relative } = findNestedImports(moduleCode);
43
44
  const allImports = [
44
- ...vfModules.map(({ original, path }) => ({ original, path, key: "nestedPath" })),
45
- ...relative.map(({ original, path }) => ({ original, path, key: "relativePath" })),
45
+ ...vfModules.map(({ original, path, start, end }) => ({
46
+ original,
47
+ path,
48
+ start,
49
+ end,
50
+ key: "nestedPath",
51
+ })),
52
+ ...relative.map(({ original, path, start, end }) => ({
53
+ original,
54
+ path,
55
+ start,
56
+ end,
57
+ key: "relativePath",
58
+ })),
46
59
  ];
47
- const results = await Promise.all(allImports.map(async ({ original, path, key }) => {
60
+ const results = await Promise.all(allImports.map(async ({ original, path, start, end, key }) => {
48
61
  const nestedFilePath = await fetchAndCacheModuleFn(path, normalizedPath);
49
- return { original, nestedFilePath, [key]: path };
62
+ return { original, start, end, nestedFilePath, [key]: path };
50
63
  }));
51
- for (const { original, nestedFilePath } of results) {
64
+ const replacements = [];
65
+ for (const { original, start, end, nestedFilePath } of results) {
52
66
  if (nestedFilePath) {
53
- moduleCode = moduleCode.replace(original, `from "file://${nestedFilePath}"`);
67
+ replacements.push({
68
+ start,
69
+ end,
70
+ expected: original,
71
+ replacement: `from "file://${nestedFilePath}"`,
72
+ });
54
73
  }
55
74
  }
56
- return moduleCode;
75
+ return replaceSourceSpans(moduleCode, replacements);
57
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/import-rewriter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5D;AAwCD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8C7F"}
1
+ {"version":3,"file":"import-rewriter.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/import-rewriter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB5D;AAwCD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0D7F"}
@@ -7,17 +7,24 @@ import { dirname, join, resolve } from "../../../../platform/compat/path/index.j
7
7
  import { FRAMEWORK_ROOT } from "../constants.js";
8
8
  import { resolveVeryfrontModuleUrl } from "../../../veryfront-module-urls.js";
9
9
  import { getLocalFs } from "../cache/index.js";
10
+ import { findStaticImportFromSpans, findStaticSideEffectImportSpans, replaceSourceSpans, } from "../utils/source-spans.js";
10
11
  /**
11
12
  * Rewrite veryfront/* imports to /_vf_modules/_veryfront/ paths for MDX module loading.
12
13
  * Uses deno.json exports/imports as the source of truth and appends ?ssr=true.
13
14
  */
14
15
  export function rewriteVeryfrontImports(code) {
15
- return code.replace(/from\s*["'](veryfront\/[^"']+)["']/g, (_match, specifier) => {
16
- const mapped = resolveVeryfrontModuleUrl(specifier);
16
+ const replacements = findStaticImportFromSpans(code, (specifier) => specifier.startsWith("veryfront/") ? specifier : null).flatMap(({ original, path, start, end }) => {
17
+ const mapped = resolveVeryfrontModuleUrl(path);
17
18
  if (!mapped)
18
- return `from "${specifier}"`;
19
- return `from "${mapped}?ssr=true"`;
19
+ return [];
20
+ return [{
21
+ start,
22
+ end,
23
+ expected: original,
24
+ replacement: `from "${mapped}?ssr=true"`,
25
+ }];
20
26
  });
27
+ return replaceSourceSpans(code, replacements);
21
28
  }
22
29
  /**
23
30
  * Rewrite relative imports in framework files to absolute file:// paths.
@@ -72,27 +79,30 @@ export async function rewriteDntImports(code, sourceFilePath) {
72
79
  let rewritten = code;
73
80
  const patterns = [
74
81
  {
75
- regex: /from\s*["'](\.\.?\/[^"']+)["']/g,
82
+ findMatches: (source) => findStaticImportFromSpans(source, (specifier) => specifier.match(/^(\.\.?\/[^?]+)(?:\?.*)?$/)?.[1]),
76
83
  buildReplacement: (path) => `from "file://${path}"`,
77
84
  },
78
85
  {
79
- regex: /import\s*["'](\.\.?\/[^"']+)["']/g,
86
+ findMatches: (source) => findStaticSideEffectImportSpans(source, (specifier) => specifier.match(/^(\.\.?\/[^?]+)(?:\?.*)?$/)?.[1]),
80
87
  buildReplacement: (path) => `import "file://${path}"`,
81
88
  },
82
89
  ];
83
- for (const { regex, buildReplacement } of patterns) {
84
- const matches = [...rewritten.matchAll(regex)];
85
- for (const match of matches) {
86
- const original = match[0];
87
- const relativePath = match[1];
88
- if (!relativePath)
89
- continue;
90
+ for (const { findMatches, buildReplacement } of patterns) {
91
+ const matches = findMatches(rewritten);
92
+ const replacements = [];
93
+ for (const { original, path: relativePath, start, end } of matches) {
90
94
  const absolutePath = resolve(sourceDir, relativePath);
91
95
  const resolvedPath = needsFrameworkSourceFallback
92
96
  ? await findExistingFrameworkRelativeTarget(absolutePath) ?? absolutePath
93
97
  : absolutePath;
94
- rewritten = rewritten.replace(original, buildReplacement(resolvedPath));
98
+ replacements.push({
99
+ start,
100
+ end,
101
+ expected: original,
102
+ replacement: buildReplacement(resolvedPath),
103
+ });
95
104
  }
105
+ rewritten = replaceSourceSpans(rewritten, replacements);
96
106
  }
97
107
  return rewritten;
98
108
  }
@@ -15,7 +15,7 @@ import type { Logger } from "../../../../utils/logger/logger.js";
15
15
  import type { RuntimeAdapter } from "../../../../platform/adapters/base.js";
16
16
  import type { ModuleFetcherContext } from "../types.js";
17
17
  export { rewriteDntImports } from "./import-rewriter.js";
18
- export { endRenderSession, hasRenderSession, startRenderSession } from "./render-sessions.js";
18
+ export { endRenderSession, hasRenderSession, runInRenderSession, startRenderSession, } from "./render-sessions.js";
19
19
  /**
20
20
  * Error thrown when transform tree exceeds the timeout.
21
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAG5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAcxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAS9F;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAOtD;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,SAAS,EAAE,MAAM;CAI9B;AAcD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwFxB;AA6KD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GACA,oBAAoB,CAUtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAG5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAcxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAS9B;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAOtD;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,SAAS,EAAE,MAAM;CAI9B;AAcD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EACzB,OAAO,GAAE,GAAG,CAAC,MAAM,CAAa,GAC/B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwFxB;AA6KD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,GACA,oBAAoB,CAUtB"}
@@ -27,7 +27,7 @@ import { readValidCachedModulePath } from "./path-cache-lookup.js";
27
27
  import { transformResolvedModuleSource } from "./source-transform.js";
28
28
  // Re-export extracted modules for backward compatibility
29
29
  export { rewriteDntImports } from "./import-rewriter.js";
30
- export { endRenderSession, hasRenderSession, startRenderSession } from "./render-sessions.js";
30
+ export { endRenderSession, hasRenderSession, runInRenderSession, startRenderSession, } from "./render-sessions.js";
31
31
  /**
32
32
  * Maximum time allowed for the entire transform tree (recursive module resolution).
33
33
  * If the cumulative time exceeds this, we fail fast instead of hanging indefinitely.
@@ -13,10 +13,14 @@ export declare function findNestedImports(moduleCode: string): {
13
13
  vfModules: Array<{
14
14
  original: string;
15
15
  path: string;
16
+ start: number;
17
+ end: number;
16
18
  }>;
17
19
  relative: Array<{
18
20
  original: string;
19
21
  path: string;
22
+ start: number;
23
+ end: number;
20
24
  }>;
21
25
  };
22
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nested-imports.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GACjB;IACD,SAAS,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,QAAQ,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD,CAqBA;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAO3F;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,EAAE,EAC7B,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,CAAC,EAAE,MAAM,EACzB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,+BAA+B,GACrC,OAAO,CAAC,MAAM,CAAC,CAwEjB"}
1
+ {"version":3,"file":"nested-imports.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAQtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAA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4
  * @module transforms/mdx/esm-module-loader/module-fetcher/nested-imports
5
5
  */
6
- import { LOG_PREFIX_MDX_LOADER, RELATIVE_IMPORT_PATTERN, UNRESOLVED_VF_MODULES_PATTERN, VF_MODULE_IMPORT_PATTERN, } from "../constants.js";
6
+ import { LOG_PREFIX_MDX_LOADER, UNRESOLVED_VF_MODULES_PATTERN } from "../constants.js";
7
7
  import { createStubModule } from "../utils/stub-module.js";
8
+ import { findStaticImportFromSpans, replaceSourceSpans, } from "../utils/source-spans.js";
8
9
  import { buildMissingModuleError } from "../missing-module.js";
9
10
  /**
10
11
  * Find nested module imports in code.
@@ -13,20 +14,22 @@ import { buildMissingModuleError } from "../missing-module.js";
13
14
  export function findNestedImports(moduleCode) {
14
15
  const vfModules = [];
15
16
  const relative = [];
16
- const vfPattern = new RegExp(VF_MODULE_IMPORT_PATTERN.source, "g");
17
- let match;
18
- while ((match = vfPattern.exec(moduleCode)) !== null) {
19
- const rawPath = match[1];
17
+ for (const { original, path: rawPath, start, end } of findStaticImportFromSpans(moduleCode, (specifier) => specifier.match(/^((?:file:\/\/)?\/?\/?_vf_modules\/[^?]+)(?:\?.*)?$/)?.[1])) {
20
18
  // Strip file:// prefix and leading slashes to get clean _vf_modules/... path
21
- if (rawPath) {
22
- vfModules.push({ original: match[0], path: rawPath.replace(/^(?:file:\/\/)?\/+/, "") });
23
- }
19
+ vfModules.push({
20
+ original,
21
+ path: rawPath.replace(/^(?:file:\/\/)?\/+/, ""),
22
+ start,
23
+ end,
24
+ });
24
25
  }
25
- const relativePattern = new RegExp(RELATIVE_IMPORT_PATTERN.source, "g");
26
- while ((match = relativePattern.exec(moduleCode)) !== null) {
27
- const path = match[1];
28
- if (path)
29
- relative.push({ original: match[0], path });
26
+ for (const { original, path, start, end } of findStaticImportFromSpans(moduleCode, (specifier) => specifier.match(/^(\.\.?\/[^?]+)(?:\?.*)?$/)?.[1])) {
27
+ relative.push({
28
+ original,
29
+ path,
30
+ start,
31
+ end,
32
+ });
30
33
  }
31
34
  return { vfModules, relative };
32
35
  }
@@ -45,10 +48,15 @@ export function hasUnresolvedImports(moduleCode) {
45
48
  * Process nested imports by replacing them with file:// paths or stub modules.
46
49
  */
47
50
  export async function processNestedImports(moduleCode, results, esmCacheDir, strictMissingModules, parentModulePath, projectSlug) {
48
- let result = moduleCode;
49
- for (const { original, nestedFilePath, nestedPath, relativePath } of results) {
51
+ const replacements = [];
52
+ for (const { original, start, end, nestedFilePath, nestedPath, relativePath } of results) {
50
53
  if (nestedFilePath) {
51
- result = result.replace(original, `from "file://${nestedFilePath}"`);
54
+ replacements.push({
55
+ start,
56
+ end,
57
+ expected: original,
58
+ replacement: `from "file://${nestedFilePath}"`,
59
+ });
52
60
  continue;
53
61
  }
54
62
  const modulePath = nestedPath || relativePath || "";
@@ -61,17 +69,23 @@ export async function processNestedImports(moduleCode, results, esmCacheDir, str
61
69
  projectSlug,
62
70
  });
63
71
  }
64
- const stubPath = await createStubModule(modulePath, result, original, esmCacheDir);
65
- if (stubPath)
66
- result = result.replace(original, `from "file://${stubPath}"`);
72
+ const stubPath = await createStubModule(modulePath, moduleCode, original, esmCacheDir);
73
+ if (stubPath) {
74
+ replacements.push({
75
+ start,
76
+ end,
77
+ expected: original,
78
+ replacement: `from "file://${stubPath}"`,
79
+ });
80
+ }
67
81
  }
68
- return result;
82
+ return replaceSourceSpans(moduleCode, replacements);
69
83
  }
70
84
  /**
71
85
  * Resolve nested /_vf_modules and relative imports into local file:// cache paths.
72
86
  */
73
87
  export async function resolveNestedModuleImports(input) {
74
- let moduleCode = input.moduleCode;
88
+ const moduleCode = input.moduleCode;
75
89
  const { vfModules, relative } = findNestedImports(moduleCode);
76
90
  input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] found nested imports`, {
77
91
  projectSlug: input.projectSlug,
@@ -87,32 +101,26 @@ export async function resolveNestedModuleImports(input) {
87
101
  count: vfModules.length,
88
102
  });
89
103
  const vfStart = performance.now();
90
- const nestedResults = await Promise.all(vfModules.map(async ({ original, path }) => ({
104
+ const allImports = [
105
+ ...vfModules.map((module) => ({ ...module, key: "nestedPath" })),
106
+ ...relative.map((module) => ({ ...module, key: "relativePath" })),
107
+ ];
108
+ const nestedResults = await Promise.all(allImports.map(async ({ original, path, start, end, key }) => ({
91
109
  original,
110
+ start,
111
+ end,
92
112
  nestedFilePath: await input.fetchAndCacheModule(path, input.normalizedPath),
93
- nestedPath: path,
113
+ [key]: path,
94
114
  })));
95
115
  input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing vfModules DONE`, {
96
116
  projectSlug: input.projectSlug,
97
117
  normalizedPath: input.normalizedPath,
98
118
  vfMs: (performance.now() - vfStart).toFixed(1),
99
119
  });
100
- moduleCode = await processNestedImports(moduleCode, nestedResults, input.esmCacheDir, input.strictMissingModules, input.normalizedPath, input.projectSlug);
101
- input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing relative imports START`, {
120
+ input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing relative imports`, {
102
121
  projectSlug: input.projectSlug,
103
122
  normalizedPath: input.normalizedPath,
104
123
  count: relative.length,
105
124
  });
106
- const relStart = performance.now();
107
- const relativeResults = await Promise.all(relative.map(async ({ original, path }) => ({
108
- original,
109
- nestedFilePath: await input.fetchAndCacheModule(path, input.normalizedPath),
110
- relativePath: path,
111
- })));
112
- input.log?.debug(`${LOG_PREFIX_MDX_LOADER} [fetchAndCacheModule] processing relative imports DONE`, {
113
- projectSlug: input.projectSlug,
114
- normalizedPath: input.normalizedPath,
115
- relMs: (performance.now() - relStart).toFixed(1),
116
- });
117
- return await processNestedImports(moduleCode, relativeResults, input.esmCacheDir, input.strictMissingModules, input.normalizedPath, input.projectSlug);
125
+ return await processNestedImports(moduleCode, nestedResults, input.esmCacheDir, input.strictMissingModules, input.normalizedPath, input.projectSlug);
118
126
  }
@@ -1 +1 @@
1
- {"version":3,"file":"path-cache-lookup.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/path-cache-lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAKjE,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,kBAAkB,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6BxB"}
1
+ {"version":3,"file":"path-cache-lookup.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/path-cache-lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAKjE,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,8BAA8B;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,kBAAkB,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmCxB"}
@@ -16,8 +16,13 @@ export async function readValidCachedModulePath(input) {
16
16
  return null;
17
17
  try {
18
18
  const stat = await getLocalFs().stat(cachedPath);
19
- if (!stat?.isFile)
19
+ if (!stat?.isFile) {
20
+ // The cached path exists but is no longer a regular file (e.g. replaced
21
+ // by a directory). Drop the stale entry so we don't re-stat it on every
22
+ // future lookup.
23
+ input.pathCache.delete(input.versionedKey);
20
24
  return null;
25
+ }
21
26
  const cachedCode = await getLocalFs().readTextFile(cachedPath);
22
27
  if (await validateCachedModule(input.normalizedPath, cachedPath, cachedCode, input.log, input.pathCache, input.versionedKey, input.recoveryOptions)) {
23
28
  recordModuleToSession(input.normalizedPath);
@@ -5,6 +5,11 @@
5
5
  *
6
6
  * @module transforms/mdx/esm-module-loader/module-fetcher/render-sessions
7
7
  */
8
+ /**
9
+ * Run `fn` with `sessionId` bound as the active render session for all async
10
+ * work it spawns. Modules fetched inside are attributed to this session.
11
+ */
12
+ export declare function runInRenderSession<T>(sessionId: string, fn: () => T): T;
8
13
  /**
9
14
  * Start a render session to track module loading.
10
15
  * Call this before rendering a page.
@@ -1 +1 @@
1
- {"version":3,"file":"render-sessions.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAOhG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAiCxD;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D;AAWD,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAQlE"}
1
+ {"version":3,"file":"render-sessions.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6BH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEvE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAOhG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAiCxD;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE3D;AAuBD,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAQlE"}
@@ -5,6 +5,7 @@
5
5
  *
6
6
  * @module transforms/mdx/esm-module-loader/module-fetcher/render-sessions
7
7
  */
8
+ import { AsyncLocalStorage } from "node:async_hooks";
8
9
  import { rendererLogger as globalLogger } from "../../../../utils/index.js";
9
10
  import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
10
11
  import { recordSSRModules } from "../../../../modules/manifest/route-module-manifest.js";
@@ -13,6 +14,19 @@ import { recordSSRModules } from "../../../../modules/manifest/route-module-mani
13
14
  * Key: renderSessionId, Value: RenderSession
14
15
  */
15
16
  const renderSessions = new Map();
17
+ /**
18
+ * The render session id active on the current async execution context.
19
+ * Set via {@link runInRenderSession} so concurrent SSR renders each resolve
20
+ * their own session instead of sharing whichever one started first.
21
+ */
22
+ const currentSessionIdStorage = new AsyncLocalStorage();
23
+ /**
24
+ * Run `fn` with `sessionId` bound as the active render session for all async
25
+ * work it spawns. Modules fetched inside are attributed to this session.
26
+ */
27
+ export function runInRenderSession(sessionId, fn) {
28
+ return currentSessionIdStorage.run(sessionId, fn);
29
+ }
16
30
  /**
17
31
  * Start a render session to track module loading.
18
32
  * Call this before rendering a page.
@@ -66,8 +80,19 @@ export function hasRenderSession(sessionId) {
66
80
  * Used to record modules during fetch and for per-session in-flight deduplication.
67
81
  */
68
82
  function getCurrentSession() {
69
- const firstSession = renderSessions.values().next();
70
- return firstSession.done ? null : firstSession.value;
83
+ const activeId = currentSessionIdStorage.getStore();
84
+ if (activeId !== undefined) {
85
+ return renderSessions.get(activeId) ?? null;
86
+ }
87
+ // No session bound on the async context (caller not wrapped in
88
+ // runInRenderSession). Fall back to the single-session heuristic only when
89
+ // it is unambiguous; with multiple concurrent sessions, decline rather than
90
+ // mis-attribute modules to the wrong render.
91
+ if (renderSessions.size === 1) {
92
+ const firstSession = renderSessions.values().next();
93
+ return firstSession.done ? null : firstSession.value;
94
+ }
95
+ return null;
71
96
  }
72
97
  export function recordModuleToSession(normalizedPath) {
73
98
  const session = getCurrentSession();
@@ -31,6 +31,8 @@ export interface FSAdapter {
31
31
  }
32
32
  export interface NestedImportResult {
33
33
  original: string;
34
+ start: number;
35
+ end: number;
34
36
  nestedFilePath: string | null;
35
37
  nestedPath?: string;
36
38
  relativePath?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAA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
+ export interface SourceSpanReplacement {
7
+ start: number;
8
+ end: number;
9
+ replacement: string;
10
+ expected?: string;
11
+ }
12
+ export interface StaticImportSpan {
13
+ original: string;
14
+ path: string;
15
+ start: number;
16
+ end: number;
17
+ }
18
+ type SpecifierMatcher = (specifier: string) => string | null | undefined;
19
+ export declare function replaceSourceSpans(source: string, replacements: SourceSpanReplacement[]): string;
20
+ export declare function findStaticImportFromSpans(source: string, matcher: SpecifierMatcher): StaticImportSpan[];
21
+ export declare function findStaticSideEffectImportSpans(source: string, matcher: SpecifierMatcher): StaticImportSpan[];
22
+ export {};
23
+ //# sourceMappingURL=source-spans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-spans.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/utils/source-spans.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,KAAK,gBAAgB,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEzE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,qBAAqB,EAAE,GACpC,MAAM,CAiBR;AAqID,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,GACxB,gBAAgB,EAAE,CAoCpB;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,GACxB,gBAAgB,EAAE,CAqCpB"}