veryfront 0.0.86 → 0.0.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 (163) hide show
  1. package/esm/_dnt.shims.d.ts +14 -14
  2. package/esm/_dnt.shims.d.ts.map +1 -1
  3. package/esm/deno.d.ts +0 -1
  4. package/esm/deno.js +8 -9
  5. package/esm/proxy/main.d.ts +2 -0
  6. package/esm/proxy/main.d.ts.map +1 -0
  7. package/esm/proxy/main.js +400 -0
  8. package/esm/src/cli/commands/init/config-generator.js +1 -1
  9. package/esm/src/cli/index/arg-parser.d.ts.map +1 -1
  10. package/esm/src/cli/index/arg-parser.js +1 -0
  11. package/esm/src/cli/index/command-router.d.ts.map +1 -1
  12. package/esm/src/cli/index/command-router.js +54 -39
  13. package/esm/src/cli/index/types.d.ts +4 -0
  14. package/esm/src/cli/index/types.d.ts.map +1 -1
  15. package/esm/src/cli/mcp/advanced-tools.d.ts +2 -2
  16. package/esm/src/cli/templates/manifest.d.ts +448 -448
  17. package/esm/src/cli/templates/manifest.js +480 -480
  18. package/esm/src/config/loader.d.ts.map +1 -1
  19. package/esm/src/config/loader.js +5 -4
  20. package/esm/src/html/utils.js +2 -2
  21. package/esm/src/modules/import-map/default-import-map.d.ts +1 -11
  22. package/esm/src/modules/import-map/default-import-map.d.ts.map +1 -1
  23. package/esm/src/modules/import-map/default-import-map.js +3 -20
  24. package/esm/src/modules/import-map/loader.d.ts.map +1 -1
  25. package/esm/src/modules/import-map/loader.js +7 -22
  26. package/esm/src/modules/import-map/resolver.d.ts.map +1 -1
  27. package/esm/src/modules/import-map/resolver.js +12 -8
  28. package/esm/src/modules/react-loader/component-loader.d.ts.map +1 -1
  29. package/esm/src/modules/react-loader/component-loader.js +2 -0
  30. package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts +1 -6
  31. package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts.map +1 -1
  32. package/esm/src/modules/react-loader/ssr-module-loader/loader.js +40 -32
  33. package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts +2 -0
  34. package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts.map +1 -1
  35. package/esm/src/modules/react-loader/types.d.ts +2 -0
  36. package/esm/src/modules/react-loader/types.d.ts.map +1 -1
  37. package/esm/src/modules/react-loader/unified-loader.d.ts.map +1 -1
  38. package/esm/src/modules/react-loader/unified-loader.js +7 -4
  39. package/esm/src/modules/server/module-batch-handler.d.ts +2 -0
  40. package/esm/src/modules/server/module-batch-handler.d.ts.map +1 -1
  41. package/esm/src/modules/server/module-batch-handler.js +3 -1
  42. package/esm/src/modules/server/module-server.d.ts +2 -0
  43. package/esm/src/modules/server/module-server.d.ts.map +1 -1
  44. package/esm/src/modules/server/module-server.js +4 -2
  45. package/esm/src/modules/server/ssr-import-rewriter.d.ts.map +1 -1
  46. package/esm/src/modules/server/ssr-import-rewriter.js +9 -17
  47. package/esm/src/platform/compat/path-helper.d.ts +7 -7
  48. package/esm/src/platform/compat/path-helper.d.ts.map +1 -1
  49. package/esm/src/react/compat/ssr-adapter/string-renderer.js +1 -1
  50. package/esm/src/react/components/Head.d.ts.map +1 -1
  51. package/esm/src/react/components/Head.js +6 -2
  52. package/esm/src/react/components/ai/agent-card.d.ts +1 -1
  53. package/esm/src/react/components/ai/agent-card.d.ts.map +1 -1
  54. package/esm/src/react/components/ai/chat/composition/api.d.ts +5 -4
  55. package/esm/src/react/components/ai/chat/composition/api.d.ts.map +1 -1
  56. package/esm/src/react/components/ai/chat/index.d.ts +7 -2
  57. package/esm/src/react/components/ai/chat/index.d.ts.map +1 -1
  58. package/esm/src/react/components/ai/message.d.ts +2 -2
  59. package/esm/src/react/components/ai/message.d.ts.map +1 -1
  60. package/esm/src/react/primitives/agent-primitives.d.ts +3 -3
  61. package/esm/src/react/primitives/agent-primitives.d.ts.map +1 -1
  62. package/esm/src/react/primitives/chat-container.d.ts +1 -1
  63. package/esm/src/react/primitives/chat-container.d.ts.map +1 -1
  64. package/esm/src/react/primitives/input-box.d.ts +3 -3
  65. package/esm/src/react/primitives/input-box.d.ts.map +1 -1
  66. package/esm/src/react/primitives/input-box.js +6 -2
  67. package/esm/src/react/primitives/message-list.d.ts +4 -4
  68. package/esm/src/react/primitives/message-list.d.ts.map +1 -1
  69. package/esm/src/react/primitives/tool-primitives.d.ts +3 -3
  70. package/esm/src/react/primitives/tool-primitives.d.ts.map +1 -1
  71. package/esm/src/rendering/component-handling.d.ts +2 -0
  72. package/esm/src/rendering/component-handling.d.ts.map +1 -1
  73. package/esm/src/rendering/component-handling.js +4 -2
  74. package/esm/src/rendering/layouts/layout-applicator.d.ts.map +1 -1
  75. package/esm/src/rendering/layouts/layout-applicator.js +2 -0
  76. package/esm/src/rendering/orchestrator/module-loader/index.d.ts +3 -0
  77. package/esm/src/rendering/orchestrator/module-loader/index.d.ts.map +1 -1
  78. package/esm/src/rendering/orchestrator/module-loader/index.js +74 -19
  79. package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
  80. package/esm/src/rendering/orchestrator/pipeline.js +2 -0
  81. package/esm/src/rendering/rsc/server-renderer/tree-processor.d.ts.map +1 -1
  82. package/esm/src/rendering/rsc/server-renderer/tree-processor.js +3 -1
  83. package/esm/src/rendering/ssr-globals/context.d.ts +6 -1
  84. package/esm/src/rendering/ssr-globals/context.d.ts.map +1 -1
  85. package/esm/src/transforms/esm/http-bundler.d.ts +15 -4
  86. package/esm/src/transforms/esm/http-bundler.d.ts.map +1 -1
  87. package/esm/src/transforms/esm/http-bundler.js +105 -12
  88. package/esm/src/transforms/esm/http-cache.d.ts.map +1 -1
  89. package/esm/src/transforms/esm/http-cache.js +26 -27
  90. package/esm/src/transforms/esm/import-rewriter.d.ts.map +1 -1
  91. package/esm/src/transforms/esm/import-rewriter.js +3 -3
  92. package/esm/src/transforms/esm/package-registry.d.ts +15 -13
  93. package/esm/src/transforms/esm/package-registry.d.ts.map +1 -1
  94. package/esm/src/transforms/esm/package-registry.js +45 -32
  95. package/esm/src/transforms/esm/react-imports.d.ts.map +1 -1
  96. package/esm/src/transforms/esm/react-imports.js +3 -7
  97. package/esm/src/transforms/esm/types.d.ts +2 -0
  98. package/esm/src/transforms/esm/types.d.ts.map +1 -1
  99. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts +14 -0
  100. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
  101. package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +67 -0
  102. package/esm/src/transforms/mdx/esm-module-loader/loader.d.ts.map +1 -1
  103. package/esm/src/transforms/mdx/esm-module-loader/loader.js +1 -1
  104. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -0
  105. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
  106. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -0
  107. package/esm/src/transforms/mdx/esm-module-loader/types.d.ts +4 -0
  108. package/esm/src/transforms/mdx/esm-module-loader/types.d.ts.map +1 -1
  109. package/esm/src/transforms/pipeline/context.d.ts.map +1 -1
  110. package/esm/src/transforms/pipeline/context.js +7 -15
  111. package/esm/src/transforms/pipeline/stages/finalize.d.ts.map +1 -1
  112. package/esm/src/transforms/pipeline/stages/finalize.js +1 -1
  113. package/esm/src/utils/constants/cdn.d.ts.map +1 -1
  114. package/esm/src/utils/constants/cdn.js +22 -11
  115. package/esm/src/utils/hash-utils.d.ts +2 -0
  116. package/esm/src/utils/hash-utils.d.ts.map +1 -1
  117. package/esm/src/utils/hash-utils.js +4 -0
  118. package/package.json +1 -1
  119. package/src/deno.js +8 -9
  120. package/src/proxy/main.ts +471 -0
  121. package/src/src/cli/commands/init/config-generator.ts +1 -1
  122. package/src/src/cli/index/arg-parser.ts +1 -0
  123. package/src/src/cli/index/command-router.ts +57 -40
  124. package/src/src/cli/index/types.ts +5 -0
  125. package/src/src/cli/templates/manifest.js +480 -480
  126. package/src/src/config/loader.ts +5 -4
  127. package/src/src/html/utils.ts +2 -2
  128. package/src/src/modules/import-map/default-import-map.ts +3 -25
  129. package/src/src/modules/import-map/loader.ts +7 -23
  130. package/src/src/modules/import-map/resolver.ts +13 -8
  131. package/src/src/modules/react-loader/component-loader.ts +2 -0
  132. package/src/src/modules/react-loader/ssr-module-loader/loader.ts +51 -37
  133. package/src/src/modules/react-loader/ssr-module-loader/types.ts +2 -0
  134. package/src/src/modules/react-loader/types.ts +2 -0
  135. package/src/src/modules/react-loader/unified-loader.ts +7 -4
  136. package/src/src/modules/server/module-batch-handler.ts +7 -0
  137. package/src/src/modules/server/module-server.ts +6 -1
  138. package/src/src/modules/server/ssr-import-rewriter.ts +9 -17
  139. package/src/src/react/compat/ssr-adapter/stream-renderer.ts +1 -1
  140. package/src/src/react/compat/ssr-adapter/string-renderer.ts +2 -2
  141. package/src/src/react/components/Head.tsx +6 -2
  142. package/src/src/react/primitives/input-box.tsx +4 -2
  143. package/src/src/rendering/component-handling.ts +6 -0
  144. package/src/src/rendering/layouts/layout-applicator.ts +4 -5
  145. package/src/src/rendering/orchestrator/module-loader/index.ts +91 -20
  146. package/src/src/rendering/orchestrator/pipeline.ts +2 -0
  147. package/src/src/rendering/orchestrator/ssr-orchestrator.ts +1 -1
  148. package/src/src/rendering/rsc/server-renderer/tree-processor.ts +13 -3
  149. package/src/src/transforms/esm/http-bundler.ts +101 -11
  150. package/src/src/transforms/esm/http-cache.ts +27 -28
  151. package/src/src/transforms/esm/import-rewriter.ts +5 -3
  152. package/src/src/transforms/esm/package-registry.ts +46 -32
  153. package/src/src/transforms/esm/react-imports.ts +3 -7
  154. package/src/src/transforms/esm/types.ts +2 -0
  155. package/src/src/transforms/mdx/esm-module-loader/cache/index.ts +84 -0
  156. package/src/src/transforms/mdx/esm-module-loader/loader.ts +1 -0
  157. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +2 -1
  158. package/src/src/transforms/mdx/esm-module-loader/types.ts +4 -0
  159. package/src/src/transforms/pipeline/context.ts +7 -18
  160. package/src/src/transforms/pipeline/stages/finalize.ts +6 -1
  161. package/src/src/transforms/plugins/babel-node-positions.ts +2 -2
  162. package/src/src/utils/constants/cdn.ts +21 -12
  163. package/src/src/utils/hash-utils.ts +5 -0
@@ -7,21 +7,33 @@
7
7
  /** Default React version - used when not specified in project config */
8
8
  export const DEFAULT_REACT_VERSION = "19.1.1";
9
9
  export const TAILWIND_VERSION = "4.1.8";
10
- /** Cached React version from project config */
11
- let configuredReactVersion = null;
12
10
  /**
13
- * Set the React version from project configuration.
14
- * Call this during project initialization if a custom version is specified.
11
+ * Validate React version format (semver: X.Y.Z).
12
+ * Returns true if valid, false otherwise.
15
13
  */
16
- export function setReactVersion(version) {
17
- configuredReactVersion = version;
14
+ export function isValidReactVersion(version) {
15
+ return /^\d+\.\d+\.\d+$/.test(version);
18
16
  }
19
17
  /**
20
- * Get the current React version.
21
- * Returns configured version if set, otherwise the default.
18
+ * Validate and normalize React version.
19
+ * Returns the version if valid, or DEFAULT_REACT_VERSION if invalid.
20
+ * Logs a warning if the version is invalid.
21
+ */
22
+ export function normalizeReactVersion(version) {
23
+ if (!version)
24
+ return DEFAULT_REACT_VERSION;
25
+ if (isValidReactVersion(version))
26
+ return version;
27
+ console.warn(`[VERYFRONT] Invalid React version format "${version}" (expected X.Y.Z). Using default: ${DEFAULT_REACT_VERSION}`);
28
+ return DEFAULT_REACT_VERSION;
29
+ }
30
+ /**
31
+ * @deprecated Global React version is no longer supported.
32
+ * Use config.react.version passed through TransformOptions instead.
33
+ * This function now always returns DEFAULT_REACT_VERSION.
22
34
  */
23
35
  export function getReactVersion() {
24
- return configuredReactVersion ?? DEFAULT_REACT_VERSION;
36
+ return DEFAULT_REACT_VERSION;
25
37
  }
26
38
  /** @deprecated Use DEFAULT_REACT_VERSION or getReactVersion() */
27
39
  export const REACT_VERSION = DEFAULT_REACT_VERSION;
@@ -43,8 +55,14 @@ export const REACT_VERSION = DEFAULT_REACT_VERSION;
43
55
  * v12: Store HTTP bundle code by hash for direct recovery (code:{hash})
44
56
  */
45
57
  export const TRANSFORM_CACHE_VERSION = 12;
46
- function esmSh(pkg, version, path = "", query = "target=es2022") {
47
- return `https://esm.sh/${pkg}@${version}${path}?${query}`;
58
+ /** csstype version - must match deno.json for type consistency */
59
+ const CSSTYPE_VERSION = "3.2.3";
60
+ /** Build esm.sh URL with deps=csstype for React packages (ensures type consistency) */
61
+ function esmShReact(pkg, version, path = "", external = false) {
62
+ const params = external
63
+ ? [`external=react`, `target=es2022`, `deps=csstype@${CSSTYPE_VERSION}`]
64
+ : [`target=es2022`, `deps=csstype@${CSSTYPE_VERSION}`];
65
+ return `https://esm.sh/${pkg}@${version}${path}?${params.join("&")}`;
48
66
  }
49
67
  /**
50
68
  * Generate esm.sh URL for browser.
@@ -70,12 +88,12 @@ export function getEsmShUrl(pkg, version, external) {
70
88
  export function getReactUrls(version) {
71
89
  const v = version ?? getReactVersion();
72
90
  return {
73
- react: esmSh("react", v),
74
- "react-dom": esmSh("react-dom", v, "", "external=react&target=es2022"),
75
- "react-dom/client": esmSh("react-dom", v, "/client", "external=react&target=es2022"),
76
- "react-dom/server": esmSh("react-dom", v, "/server", "external=react&target=es2022"),
77
- "react/jsx-runtime": esmSh("react", v, "/jsx-runtime", "external=react&target=es2022"),
78
- "react/jsx-dev-runtime": esmSh("react", v, "/jsx-dev-runtime", "external=react&target=es2022"),
91
+ react: esmShReact("react", v),
92
+ "react-dom": esmShReact("react-dom", v, "", true),
93
+ "react-dom/client": esmShReact("react-dom", v, "/client", true),
94
+ "react-dom/server": esmShReact("react-dom", v, "/server", true),
95
+ "react/jsx-runtime": esmShReact("react", v, "/jsx-runtime", true),
96
+ "react/jsx-dev-runtime": esmShReact("react", v, "/jsx-dev-runtime", true),
79
97
  };
80
98
  }
81
99
  /**
@@ -93,29 +111,24 @@ export function getReactImportMap(version) {
93
111
  return {
94
112
  ...getReactUrls(v),
95
113
  // Prefix match for any react/* subpath imports
96
- "react/": esmSh("react", v, "/", "external=react&target=es2022"),
114
+ "react/": esmShReact("react", v, "/", true),
97
115
  };
98
116
  }
99
117
  /**
100
- * Get React npm specifiers for Deno SSR.
101
- * Uses npm: protocol which Deno handles natively with automatic deduplication.
102
- * See: https://deno.com/blog/not-using-npm-specifiers-doing-it-wrong
103
- *
104
- * Benefits over esm.sh:
105
- * - Automatic semantic version deduplication (like Node's node_modules)
106
- * - No manual external= flags or shared-*.ts wrapper files needed
107
- * - Native support in Deno 2+
118
+ * Get React esm.sh URLs for Deno SSR.
119
+ * Uses esm.sh for both SSR and browser to ensure identical React instances.
120
+ * All sub-packages use external=react to share the same React instance.
108
121
  *
109
122
  * @param version - React version to use (defaults to REACT_VERSION)
110
123
  */
111
124
  export function getDenoNpmReactMap(version) {
112
125
  const v = version ?? getReactVersion();
113
126
  return {
114
- "react": `npm:react@${v}`,
115
- "react-dom": `npm:react-dom@${v}`,
116
- "react-dom/client": `npm:react-dom@${v}/client`,
117
- "react-dom/server": `npm:react-dom@${v}/server`,
118
- "react/jsx-runtime": `npm:react@${v}/jsx-runtime`,
119
- "react/jsx-dev-runtime": `npm:react@${v}/jsx-dev-runtime`,
127
+ "react": esmShReact("react", v),
128
+ "react-dom": esmShReact("react-dom", v, "", true),
129
+ "react-dom/client": esmShReact("react-dom", v, "/client", true),
130
+ "react-dom/server": esmShReact("react-dom", v, "/server", true),
131
+ "react/jsx-runtime": esmShReact("react", v, "/jsx-runtime", true),
132
+ "react/jsx-dev-runtime": esmShReact("react", v, "/jsx-dev-runtime", true),
120
133
  };
121
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"react-imports.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/react-imports.ts"],"names":[],"mappings":"AAmBA,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,OAAe,EACvB,YAAY,GAAE,MAAsB,GACnC,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAsB,GACnC,OAAO,CAAC,MAAM,CAAC,CASjB"}
1
+ {"version":3,"file":"react-imports.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/react-imports.ts"],"names":[],"mappings":"AAiBA,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,OAAe,EACvB,YAAY,GAAE,MAAsB,GACnC,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,OAAe,EACxB,YAAY,GAAE,MAAsB,GACnC,OAAO,CAAC,MAAM,CAAC,CASjB"}
@@ -1,7 +1,5 @@
1
1
  import { replaceSpecifiers } from "./lexer.js";
2
- import { getDenoNpmReactMap, getReactImportMap, REACT_VERSION } from "./package-registry.js";
3
- import { isDeno } from "../../platform/compat/runtime.js";
4
- import { getLocalReactPaths } from "../../platform/compat/react-paths.js";
2
+ import { getReactImportMap, REACT_VERSION } from "./package-registry.js";
5
3
  const srcDir = new URL(".", globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url).pathname.replace(/\/(build|src)\/transforms\/esm\/?$/, "");
6
4
  function getVeryfrontModulePaths() {
7
5
  return {
@@ -16,12 +14,10 @@ export async function resolveReactImports(code, forSSR = false, reactVersion = R
16
14
  if (!forSSR) {
17
15
  return replaceSpecifiers(code, (specifier) => reactImports[specifier] ?? null);
18
16
  }
19
- // For Deno SSR: Use npm: specifiers (auto-deduplicated by Deno's npm cache)
20
- // For Node/Bun SSR: Use local node_modules paths (auto-deduplicated by Node)
21
- // See: https://deno.com/blog/not-using-npm-specifiers-doing-it-wrong
17
+ // For SSR: Use esm.sh URLs consistently (NO npm: specifiers per plan requirements)
22
18
  const ssrImports = {
23
19
  ...getVeryfrontModulePaths(),
24
- ...(isDeno ? getDenoNpmReactMap(reactVersion) : getLocalReactPaths()),
20
+ ...reactImports,
25
21
  };
26
22
  return replaceSpecifiers(code, (specifier) => ssrImports[specifier] ?? null);
27
23
  }
@@ -8,6 +8,8 @@ export interface TransformOptions {
8
8
  ssr?: boolean;
9
9
  apiBaseUrl?: string;
10
10
  studioEmbed?: boolean;
11
+ /** React version for transforms (from project config, defaults to DEFAULT_REACT_VERSION) */
12
+ reactVersion?: string;
11
13
  }
12
14
  export interface TransformContext {
13
15
  source: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,gBAAgB,CAAC;CAC3B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/esm/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4FAA4F;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,gBAAgB,CAAC;CAC3B"}
@@ -35,4 +35,18 @@ export declare function invalidateModulePaths(changedPaths: string[]): void;
35
35
  * Called when files are updated via Studio to ensure fresh content is served.
36
36
  */
37
37
  export declare function clearESMDiskCache(): Promise<void>;
38
+ /**
39
+ * Look up a module in the MDX-ESM cache.
40
+ *
41
+ * This allows other loaders (like SSR loader) to reuse modules that
42
+ * MDX-ESM has already transformed and cached, preventing duplicate
43
+ * module instances (which breaks React context, etc.).
44
+ *
45
+ * @param filePath - Project-relative file path like "lib/ChatContext.tsx"
46
+ * @param cacheDir - The MDX-ESM cache directory for this project/contentSource
47
+ * @param projectDir - Project directory to strip from absolute paths
48
+ * @param contentHash - Optional content hash to validate cached file freshness
49
+ * @returns The cached file path if found and valid, null otherwise
50
+ */
51
+ export declare function lookupMdxEsmCache(filePath: string, cacheDir: string, projectDir?: string, contentHash?: string): Promise<string | null>;
38
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;AAO3C;;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"}
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"}
@@ -9,6 +9,7 @@ import { join } from "../../../../../deps/deno.land/std@0.220.0/path/mod.js";
9
9
  import { rendererLogger as logger } from "../../../../utils/index.js";
10
10
  import { getMdxEsmCacheDir } from "../../../../utils/cache-dir.js";
11
11
  import { createFileSystem, isNotFoundError, } from "../../../../platform/compat/fs.js";
12
+ import { TRANSFORM_CACHE_VERSION } from "../../../esm/package-registry.js";
12
13
  import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
13
14
  // Local filesystem for cache operations (not project's FSAdapter which may be remote/read-only)
14
15
  // This uses the platform's native fs (Deno, Node, Bun) for local cache writes
@@ -128,3 +129,69 @@ export async function clearESMDiskCache() {
128
129
  }
129
130
  }
130
131
  }
132
+ /**
133
+ * Convert a project-relative file path to MDX-ESM cache key format.
134
+ *
135
+ * @param filePath - Project-relative path like "lib/ChatContext.tsx" or absolute path
136
+ * @param projectDir - Project directory to strip from absolute paths
137
+ * @returns Cache key like "v10:_vf_modules/lib/ChatContext.js"
138
+ */
139
+ function toMdxEsmCacheKey(filePath, projectDir) {
140
+ // Strip project directory prefix if present
141
+ let relativePath = filePath;
142
+ if (projectDir && filePath.startsWith(projectDir)) {
143
+ relativePath = filePath.slice(projectDir.length).replace(/^\/+/, "");
144
+ }
145
+ // Strip leading slashes
146
+ relativePath = relativePath.replace(/^\/+/, "");
147
+ // Convert extension to .js
148
+ const jsPath = relativePath.replace(/\.(tsx?|jsx|mdx)$/, ".js");
149
+ // Build the versioned key in MDX-ESM format
150
+ return `v${TRANSFORM_CACHE_VERSION}:_vf_modules/${jsPath}`;
151
+ }
152
+ /**
153
+ * Look up a module in the MDX-ESM cache.
154
+ *
155
+ * This allows other loaders (like SSR loader) to reuse modules that
156
+ * MDX-ESM has already transformed and cached, preventing duplicate
157
+ * module instances (which breaks React context, etc.).
158
+ *
159
+ * @param filePath - Project-relative file path like "lib/ChatContext.tsx"
160
+ * @param cacheDir - The MDX-ESM cache directory for this project/contentSource
161
+ * @param projectDir - Project directory to strip from absolute paths
162
+ * @param contentHash - Optional content hash to validate cached file freshness
163
+ * @returns The cached file path if found and valid, null otherwise
164
+ */
165
+ export async function lookupMdxEsmCache(filePath, cacheDir, projectDir, contentHash) {
166
+ const cache = await getModulePathCache(cacheDir);
167
+ const cacheKey = toMdxEsmCacheKey(filePath, projectDir);
168
+ const cachedPath = cache.get(cacheKey);
169
+ if (!cachedPath) {
170
+ return null;
171
+ }
172
+ // Verify the cached file still exists
173
+ try {
174
+ const stat = await getLocalFs().stat(cachedPath);
175
+ if (!stat?.isFile) {
176
+ cache.delete(cacheKey);
177
+ return null;
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
+ }
189
+ logger.debug(`${LOG_PREFIX_MDX_LOADER} SSR reusing MDX-ESM cache: ${filePath} -> ${cachedPath}`);
190
+ return cachedPath;
191
+ }
192
+ catch {
193
+ // File no longer exists, remove stale entry
194
+ cache.delete(cacheKey);
195
+ }
196
+ return null;
197
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/mdx/esm-module-loader/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAeH,OAAO,KAAK,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAkYnD,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;AAeH,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"}
@@ -151,7 +151,7 @@ async function processVfModuleImports(code, imports, context, projectDir) {
151
151
  if (!context.projectId) {
152
152
  throw new Error(`Missing projectId for module fetching (projectSlug: ${context.projectSlug})`);
153
153
  }
154
- const fetcherContext = createModuleFetcherContext(context.esmCacheDir, adapter, projectDir, context.projectId);
154
+ const fetcherContext = createModuleFetcherContext(context.esmCacheDir, adapter, projectDir, context.projectId, { reactVersion: context.reactVersion });
155
155
  const fetchStart = performance.now();
156
156
  const results = await Promise.all(imports.map(async ({ original, path }, index) => {
157
157
  return await withSpan(SpanNames.MDX_FETCH_MODULE, async () => {
@@ -20,5 +20,6 @@ export declare function fetchAndCacheModule(modulePath: string, context: ModuleF
20
20
  export declare function createModuleFetcherContext(esmCacheDir: string, adapter: RuntimeAdapter, projectDir: string, projectId: string, options?: {
21
21
  isLocalDev?: boolean;
22
22
  projectSlug?: string;
23
+ reactVersion?: string;
23
24
  }): ModuleFetcherContext;
24
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAW5E,OAAO,KAAK,EAAE,oBAAoB,EAAsB,MAAM,aAAa,CAAC;AA4F5E;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAON;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAiCxD;AAsND;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6CxB;AA4OD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACvD,oBAAoB,CAUtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAW5E,OAAO,KAAK,EAAE,oBAAoB,EAAsB,MAAM,aAAa,CAAC;AA4F5E;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,CAON;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAiCxD;AAsND;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6CxB;AA6OD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9E,oBAAoB,CAUtB"}
@@ -430,6 +430,7 @@ async function doFetchAndCacheModule(normalizedPath, context, fetchAndCacheModul
430
430
  projectId,
431
431
  dev: true,
432
432
  ssr: true,
433
+ reactVersion: context.reactVersion,
433
434
  });
434
435
  }
435
436
  catch (transformError) {
@@ -9,6 +9,8 @@ export interface ESMLoaderContext {
9
9
  projectDir?: string;
10
10
  projectSlug?: string;
11
11
  contentSourceId?: string;
12
+ /** React version for transforms (from project config) */
13
+ reactVersion?: string;
12
14
  }
13
15
  export interface FSAdapter {
14
16
  readFile(path: string): Promise<string | Uint8Array>;
@@ -49,6 +51,8 @@ export interface ModuleFetcherContext {
49
51
  * This prevents infinite recursion when A imports B which imports A.
50
52
  */
51
53
  inFlightModules?: Map<string, Promise<string | null>>;
54
+ /** React version for transforms (from project config) */
55
+ reactVersion?: string;
52
56
  }
53
57
  export interface JSXTransform {
54
58
  original: 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,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,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AAC,CAAC;IACrE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACzD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACtD,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/src/transforms/pipeline/context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB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EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAO3B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,gBAAgB,GACxB,gBAAgB,CASlB;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,MAAM,GAChB,IAAI,CAEN;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAE5D;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwB7E;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAEpD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAExD;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAEpD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAE3D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAG1D"}
@@ -1,17 +1,11 @@
1
- import * as dntShim from "../../../_dnt.shims.js";
2
1
  import { computeShortContentHash } from "../esm/transform-utils.js";
3
2
  import { REACT_VERSION } from "../esm/package-registry.js";
4
- async function detectProjectReactVersion(projectDir) {
5
- try {
6
- const content = await dntShim.Deno.readTextFile(`${projectDir}/package.json`);
7
- const pkg = JSON.parse(content);
8
- const reactVersion = { ...pkg.dependencies, ...pkg.devDependencies }?.react;
9
- if (reactVersion)
10
- return reactVersion.replace(/^[\^~]/, "");
11
- }
12
- catch {
13
- // Project doesn't have package.json or no React dependency
14
- }
3
+ /**
4
+ * Get React version for transforms.
5
+ * Uses REACT_VERSION constant - the centralized version from package-registry.
6
+ * Prefer passing reactVersion through TransformOptions for per-project versions.
7
+ */
8
+ function getDefaultReactVersion() {
15
9
  return REACT_VERSION;
16
10
  }
17
11
  function buildContext(source, filePath, projectDir, contentHash, options, reactVersion) {
@@ -39,9 +33,7 @@ function buildContext(source, filePath, projectDir, contentHash, options, reactV
39
33
  export async function createTransformContext(source, filePath, projectDir, options) {
40
34
  const [contentHash, reactVersion] = await Promise.all([
41
35
  computeShortContentHash(source),
42
- options.reactVersion
43
- ? Promise.resolve(options.reactVersion)
44
- : detectProjectReactVersion(projectDir),
36
+ Promise.resolve(options.reactVersion ?? getDefaultReactVersion()),
45
37
  ]);
46
38
  return buildContext(source, filePath, projectDir, contentHash, options, reactVersion);
47
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"finalize.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/pipeline/stages/finalize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,eAAe,EAAkB,MAAM,aAAa,CAAC;AAE1F,eAAO,MAAM,cAAc,EAAE,eAU5B,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"finalize.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/pipeline/stages/finalize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,KAAK,eAAe,EAAkB,MAAM,aAAa,CAAC;AAE1F,eAAO,MAAM,cAAc,EAAE,eAe5B,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -8,7 +8,7 @@ export const finalizePlugin = {
8
8
  async transform(ctx) {
9
9
  if (!isSSR(ctx))
10
10
  return ctx.code;
11
- const result = bundleHttpImports(ctx.code, getHttpBundleCacheDir(), ctx.contentHash);
11
+ const result = bundleHttpImports(ctx.code, getHttpBundleCacheDir(), ctx.contentHash, ctx.reactVersion);
12
12
  return result instanceof Promise ? await result : result;
13
13
  },
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/constants/cdn.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAC7C,eAAO,MAAM,iBAAiB,6BAA6B,CAAC;AAC5D,eAAO,MAAM,aAAa,sBAAsB,CAAC;AAEjD,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AACjD,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAEzC,eAAO,MAAM,qBAAqB,WAAmB,CAAC;AAUtD,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAA8B,GAAG,MAAM,CAE9E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,MAA8B,GAAG,MAAM,CAEjF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,MAA8B,GAAG,MAAM,CAEvF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,MAA8B,GAAG,MAAM,CAEvF;AAED,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,MAA8B,GAAG,MAAM,CAExF;AAED,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,MAA8B,GAAG,MAAM,CAE3F;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,MAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASjG;AAED,eAAO,MAAM,yBAAyB,UAAgC,CAAC;AAEvE,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/constants/cdn.ts"],"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ERSION_19 = "19.1.1";
9
9
  export const REACT_DEFAULT_VERSION = REACT_VERSION_19;
10
- function getReactBase(version = REACT_DEFAULT_VERSION) {
11
- return `${ESM_CDN_BASE}/react@${version}`;
12
- }
13
- function getReactDOMBase(version = REACT_DEFAULT_VERSION) {
14
- return `${ESM_CDN_BASE}/react-dom@${version}`;
10
+ /**
11
+ * esm.sh URL builder with consistent query params.
12
+ *
13
+ * For React packages (react-dom, jsx-runtime), we only need external=react:
14
+ * - react-dom depends on react → external=react makes it import "react" as bare specifier
15
+ * - react-dom doesn't need external=react-dom because it IS react-dom
16
+ * - jsx-runtime depends on react core → external=react
17
+ *
18
+ * Third-party packages (e.g., @tanstack/react-query) need external=react,react-dom
19
+ * because they may depend on BOTH. That's handled by bundleHttpImports() separately.
20
+ */
21
+ function esmSh(pkg, version, path = "", external = false) {
22
+ const params = ["target=es2022"];
23
+ if (external)
24
+ params.push("external=react");
25
+ return `${ESM_CDN_BASE}/${pkg}@${version}${path}?${params.join("&")}`;
15
26
  }
16
27
  export function getReactCDNUrl(version = REACT_DEFAULT_VERSION) {
17
- return getReactBase(version);
28
+ return esmSh("react", version);
18
29
  }
19
30
  export function getReactDOMCDNUrl(version = REACT_DEFAULT_VERSION) {
20
- return getReactDOMBase(version);
31
+ return esmSh("react-dom", version, "", true);
21
32
  }
22
33
  export function getReactDOMClientCDNUrl(version = REACT_DEFAULT_VERSION) {
23
- return `${getReactDOMBase(version)}/client`;
34
+ return esmSh("react-dom", version, "/client", true);
24
35
  }
25
36
  export function getReactDOMServerCDNUrl(version = REACT_DEFAULT_VERSION) {
26
- return `${getReactDOMBase(version)}/server`;
37
+ return esmSh("react-dom", version, "/server", true);
27
38
  }
28
39
  export function getReactJSXRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {
29
- return `${getReactBase(version)}/jsx-runtime`;
40
+ return esmSh("react", version, "/jsx-runtime", true);
30
41
  }
31
42
  export function getReactJSXDevRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {
32
- return `${getReactBase(version)}/jsx-dev-runtime`;
43
+ return esmSh("react", version, "/jsx-dev-runtime", true);
33
44
  }
34
45
  export function getReactImportMap(version = REACT_DEFAULT_VERSION) {
35
46
  return {
@@ -10,5 +10,7 @@ export interface BundleCode {
10
10
  }
11
11
  export declare function computeCodeHash(code: BundleCode): Promise<string>;
12
12
  export declare function simpleHash(str: string): number;
13
+ /** Hash string to hex (base 16) - used for module filenames */
14
+ export declare function hashCodeHex(str: string): string;
13
15
  export declare function shortHash(content: string): Promise<string>;
14
16
  //# sourceMappingURL=hash-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hash-utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/hash-utils.ts"],"names":[],"mappings":"AACA,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMlE;AAED,2CAA2C;AAC3C,eAAO,MAAM,cAAc,oBAAc,CAAC;AAE1C,2CAA2C;AAC3C,eAAO,MAAM,kBAAkB,oBAAc,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAEjE;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE"}
1
+ {"version":3,"file":"hash-utils.d.ts","sourceRoot":"","sources":["../../../src/src/utils/hash-utils.ts"],"names":[],"mappings":"AACA,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMlE;AAED,2CAA2C;AAC3C,eAAO,MAAM,cAAc,oBAAc,CAAC;AAE1C,2CAA2C;AAC3C,eAAO,MAAM,kBAAkB,oBAAc,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAEjE;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE"}
@@ -21,6 +21,10 @@ export function simpleHash(str) {
21
21
  }
22
22
  return Math.abs(hash);
23
23
  }
24
+ /** Hash string to hex (base 16) - used for module filenames */
25
+ export function hashCodeHex(str) {
26
+ return simpleHash(str).toString(16);
27
+ }
24
28
  export async function shortHash(content) {
25
29
  const fullHash = await computeHash(content);
26
30
  return fullHash.slice(0, 8);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.0.86",
3
+ "version": "0.0.89",
4
4
  "description": "Zero-config React meta-framework for building agentic AI applications",
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.86",
3
+ "version": "0.0.89",
4
4
  "nodeModulesDir": "auto",
5
5
  "exclude": [
6
6
  "npm/",
@@ -195,12 +195,12 @@ export default {
195
195
  "csstype": "https://esm.sh/csstype@3.2.3",
196
196
  "@types/react": "https://esm.sh/@types/react@18.3.27?deps=csstype@3.2.3",
197
197
  "@types/react-dom": "https://esm.sh/@types/react-dom@18.3.7?deps=csstype@3.2.3",
198
- "react": "npm:react@19.1.1",
199
- "react-dom": "npm:react-dom@19.1.1",
200
- "react-dom/server": "npm:react-dom@19.1.1/server",
201
- "react-dom/client": "npm:react-dom@19.1.1/client",
202
- "react/jsx-runtime": "npm:react@19.1.1/jsx-runtime",
203
- "react/jsx-dev-runtime": "npm:react@19.1.1/jsx-dev-runtime",
198
+ "react": "https://esm.sh/react@19.1.1?target=es2022&deps=csstype@3.2.3",
199
+ "react-dom": "https://esm.sh/react-dom@19.1.1?external=react&target=es2022&deps=csstype@3.2.3",
200
+ "react-dom/server": "https://esm.sh/react-dom@19.1.1/server?external=react&target=es2022&deps=csstype@3.2.3",
201
+ "react-dom/client": "https://esm.sh/react-dom@19.1.1/client?external=react&target=es2022&deps=csstype@3.2.3",
202
+ "react/jsx-runtime": "https://esm.sh/react@19.1.1/jsx-runtime?external=react&target=es2022&deps=csstype@3.2.3",
203
+ "react/jsx-dev-runtime": "https://esm.sh/react@19.1.1/jsx-dev-runtime?external=react&target=es2022&deps=csstype@3.2.3",
204
204
  "@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.0",
205
205
  "@mdx-js/react": "npm:@mdx-js/react@3.0.0",
206
206
  "unist-util-visit": "npm:unist-util-visit@5.0.0",
@@ -264,8 +264,7 @@ export default {
264
264
  },
265
265
  "tasks": {
266
266
  "setup": "deno run --allow-all scripts/setup.ts",
267
- "start": "deno run --allow-all scripts/server.ts",
268
- "start:clean": "rm -rf .cache/ && deno run --allow-all scripts/server.ts",
267
+ "start": "rm -rf .cache/ && deno run --allow-all scripts/server.ts",
269
268
  "start:headless": "deno run --allow-all scripts/server.ts --headless",
270
269
  "proxy": "deno run --allow-net --allow-env --allow-read proxy/main.ts",
271
270
  "renderer": "deno run --allow-all --unstable-net --unstable-worker-options src/cli/main.ts dev",