veryfront 0.0.84 → 0.0.88

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 (442) hide show
  1. package/README.md +18 -44
  2. package/esm/deno.d.ts +0 -1
  3. package/esm/deno.js +8 -9
  4. package/esm/deps/esm.sh/react-dom@19.1.1/client.d.ts +2 -0
  5. package/esm/deps/esm.sh/react-dom@19.1.1/client.d.ts.map +1 -0
  6. package/esm/deps/esm.sh/react-dom@19.1.1/client.js +5 -0
  7. package/esm/deps/esm.sh/react-dom@19.1.1/server.d.ts +2 -0
  8. package/esm/deps/esm.sh/react-dom@19.1.1/server.d.ts.map +1 -0
  9. package/esm/deps/esm.sh/react-dom@19.1.1/server.js +5 -0
  10. package/esm/deps/esm.sh/react@19.1.1/jsx-runtime.d.ts +2 -0
  11. package/esm/deps/esm.sh/react@19.1.1/jsx-runtime.d.ts.map +1 -0
  12. package/esm/deps/esm.sh/react@19.1.1/jsx-runtime.js +3 -0
  13. package/esm/deps/esm.sh/react@19.1.1.d.ts +2 -0
  14. package/esm/deps/esm.sh/react@19.1.1.d.ts.map +1 -0
  15. package/esm/deps/esm.sh/react@19.1.1.js +3 -0
  16. package/esm/deps/esm.sh/scheduler@^0.26.0.d.ts +2 -0
  17. package/esm/deps/esm.sh/scheduler@^0.26.0.d.ts.map +1 -0
  18. package/esm/deps/esm.sh/scheduler@^0.26.0.js +3 -0
  19. package/esm/proxy/main.d.ts +2 -0
  20. package/esm/proxy/main.d.ts.map +1 -0
  21. package/esm/proxy/main.js +400 -0
  22. package/esm/src/agent/react/use-agent.js +1 -1
  23. package/esm/src/agent/react/use-chat/use-chat.js +1 -1
  24. package/esm/src/agent/react/use-completion.js +1 -1
  25. package/esm/src/agent/react/use-streaming.js +1 -1
  26. package/esm/src/agent/react/use-voice-input.js +1 -1
  27. package/esm/src/cli/app/components/list-select.js +2 -2
  28. package/esm/src/cli/app/index.d.ts +1 -1
  29. package/esm/src/cli/app/index.d.ts.map +1 -1
  30. package/esm/src/cli/app/index.js +26 -33
  31. package/esm/src/cli/app/state.d.ts +3 -0
  32. package/esm/src/cli/app/state.d.ts.map +1 -1
  33. package/esm/src/cli/app/state.js +4 -0
  34. package/esm/src/cli/app/views/dashboard.d.ts.map +1 -1
  35. package/esm/src/cli/app/views/dashboard.js +45 -57
  36. package/esm/src/cli/app/views/startup.d.ts +39 -0
  37. package/esm/src/cli/app/views/startup.d.ts.map +1 -0
  38. package/esm/src/cli/app/views/startup.js +103 -0
  39. package/esm/src/cli/commands/init/config-generator.js +1 -1
  40. package/esm/src/cli/index/arg-parser.d.ts.map +1 -1
  41. package/esm/src/cli/index/arg-parser.js +1 -0
  42. package/esm/src/cli/index/command-router.d.ts.map +1 -1
  43. package/esm/src/cli/index/command-router.js +54 -39
  44. package/esm/src/cli/index/types.d.ts +4 -0
  45. package/esm/src/cli/index/types.d.ts.map +1 -1
  46. package/esm/src/cli/mcp/advanced-tools.d.ts +2 -2
  47. package/esm/src/cli/ui/colors.d.ts +8 -0
  48. package/esm/src/cli/ui/colors.d.ts.map +1 -1
  49. package/esm/src/cli/ui/colors.js +34 -0
  50. package/esm/src/cli/ui/dot-matrix.d.ts +8 -0
  51. package/esm/src/cli/ui/dot-matrix.d.ts.map +1 -1
  52. package/esm/src/cli/ui/dot-matrix.js +67 -2
  53. package/esm/src/config/loader.d.ts.map +1 -1
  54. package/esm/src/config/loader.js +5 -4
  55. package/esm/src/html/utils.js +2 -2
  56. package/esm/src/modules/component-registry/registry.d.ts +1 -1
  57. package/esm/src/modules/component-registry/registry.d.ts.map +1 -1
  58. package/esm/src/modules/import-map/default-import-map.d.ts +1 -11
  59. package/esm/src/modules/import-map/default-import-map.d.ts.map +1 -1
  60. package/esm/src/modules/import-map/default-import-map.js +3 -20
  61. package/esm/src/modules/import-map/loader.d.ts.map +1 -1
  62. package/esm/src/modules/import-map/loader.js +7 -22
  63. package/esm/src/modules/import-map/resolver.d.ts.map +1 -1
  64. package/esm/src/modules/import-map/resolver.js +12 -8
  65. package/esm/src/modules/react-loader/component-loader.d.ts +1 -1
  66. package/esm/src/modules/react-loader/component-loader.d.ts.map +1 -1
  67. package/esm/src/modules/react-loader/component-loader.js +2 -0
  68. package/esm/src/modules/react-loader/extract-component.d.ts +1 -1
  69. package/esm/src/modules/react-loader/extract-component.d.ts.map +1 -1
  70. package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts +2 -7
  71. package/esm/src/modules/react-loader/ssr-module-loader/loader.d.ts.map +1 -1
  72. package/esm/src/modules/react-loader/ssr-module-loader/loader.js +68 -38
  73. package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts +2 -0
  74. package/esm/src/modules/react-loader/ssr-module-loader/types.d.ts.map +1 -1
  75. package/esm/src/modules/react-loader/types.d.ts +3 -1
  76. package/esm/src/modules/react-loader/types.d.ts.map +1 -1
  77. package/esm/src/modules/react-loader/unified-loader.d.ts.map +1 -1
  78. package/esm/src/modules/react-loader/unified-loader.js +7 -4
  79. package/esm/src/modules/server/module-batch-handler.d.ts +2 -0
  80. package/esm/src/modules/server/module-batch-handler.d.ts.map +1 -1
  81. package/esm/src/modules/server/module-batch-handler.js +3 -1
  82. package/esm/src/modules/server/module-server.d.ts +2 -0
  83. package/esm/src/modules/server/module-server.d.ts.map +1 -1
  84. package/esm/src/modules/server/module-server.js +4 -2
  85. package/esm/src/modules/server/ssr-import-rewriter.d.ts.map +1 -1
  86. package/esm/src/modules/server/ssr-import-rewriter.js +9 -17
  87. package/esm/src/react/compat/hooks-adapter.d.ts +1 -1
  88. package/esm/src/react/compat/hooks-adapter.d.ts.map +1 -1
  89. package/esm/src/react/compat/hooks-adapter.js +1 -1
  90. package/esm/src/react/compat/ssr-adapter/response-builder.d.ts +1 -1
  91. package/esm/src/react/compat/ssr-adapter/response-builder.d.ts.map +1 -1
  92. package/esm/src/react/compat/ssr-adapter/server-loader.d.ts +5 -5
  93. package/esm/src/react/compat/ssr-adapter/server-loader.d.ts.map +1 -1
  94. package/esm/src/react/compat/ssr-adapter/server-loader.js +2 -2
  95. package/esm/src/react/compat/ssr-adapter/stream-renderer.d.ts +1 -1
  96. package/esm/src/react/compat/ssr-adapter/stream-renderer.d.ts.map +1 -1
  97. package/esm/src/react/compat/ssr-adapter/string-renderer.d.ts +1 -1
  98. package/esm/src/react/compat/ssr-adapter/string-renderer.d.ts.map +1 -1
  99. package/esm/src/react/compat/ssr-adapter/string-renderer.js +1 -1
  100. package/esm/src/react/compat/version-detector/feature-detector.js +1 -1
  101. package/esm/src/react/components/AppWrapper.d.ts +1 -1
  102. package/esm/src/react/components/AppWrapper.d.ts.map +1 -1
  103. package/esm/src/react/components/AppWrapper.js +1 -1
  104. package/esm/src/react/components/Head.d.ts +1 -1
  105. package/esm/src/react/components/Head.d.ts.map +1 -1
  106. package/esm/src/react/components/Head.js +7 -3
  107. package/esm/src/react/components/LayoutComponent.d.ts +1 -1
  108. package/esm/src/react/components/LayoutComponent.d.ts.map +1 -1
  109. package/esm/src/react/components/LayoutComponent.js +1 -1
  110. package/esm/src/react/components/Link.d.ts +1 -1
  111. package/esm/src/react/components/Link.d.ts.map +1 -1
  112. package/esm/src/react/components/Link.js +1 -1
  113. package/esm/src/react/components/MDXProvider.d.ts +1 -1
  114. package/esm/src/react/components/MDXProvider.d.ts.map +1 -1
  115. package/esm/src/react/components/MDXProvider.js +2 -2
  116. package/esm/src/react/components/ProviderComponent.d.ts +1 -1
  117. package/esm/src/react/components/ProviderComponent.d.ts.map +1 -1
  118. package/esm/src/react/components/ProviderComponent.js +1 -1
  119. package/esm/src/react/components/ai/agent-card.d.ts +2 -2
  120. package/esm/src/react/components/ai/agent-card.d.ts.map +1 -1
  121. package/esm/src/react/components/ai/agent-card.js +1 -1
  122. package/esm/src/react/components/ai/chat/components/animations.d.ts +1 -1
  123. package/esm/src/react/components/ai/chat/components/animations.d.ts.map +1 -1
  124. package/esm/src/react/components/ai/chat/components/animations.js +1 -1
  125. package/esm/src/react/components/ai/chat/components/empty-state.d.ts +1 -1
  126. package/esm/src/react/components/ai/chat/components/empty-state.d.ts.map +1 -1
  127. package/esm/src/react/components/ai/chat/components/empty-state.js +1 -1
  128. package/esm/src/react/components/ai/chat/components/message-actions.d.ts +1 -1
  129. package/esm/src/react/components/ai/chat/components/message-actions.d.ts.map +1 -1
  130. package/esm/src/react/components/ai/chat/components/message-actions.js +1 -1
  131. package/esm/src/react/components/ai/chat/components/reasoning.d.ts +1 -1
  132. package/esm/src/react/components/ai/chat/components/reasoning.d.ts.map +1 -1
  133. package/esm/src/react/components/ai/chat/components/reasoning.js +1 -1
  134. package/esm/src/react/components/ai/chat/components/tool-ui.d.ts +1 -1
  135. package/esm/src/react/components/ai/chat/components/tool-ui.d.ts.map +1 -1
  136. package/esm/src/react/components/ai/chat/components/tool-ui.js +1 -1
  137. package/esm/src/react/components/ai/chat/composition/api.d.ts +5 -4
  138. package/esm/src/react/components/ai/chat/composition/api.d.ts.map +1 -1
  139. package/esm/src/react/components/ai/chat/composition/api.js +1 -1
  140. package/esm/src/react/components/ai/chat/index.d.ts +8 -3
  141. package/esm/src/react/components/ai/chat/index.d.ts.map +1 -1
  142. package/esm/src/react/components/ai/chat/index.js +1 -1
  143. package/esm/src/react/components/ai/error-boundary.d.ts +1 -1
  144. package/esm/src/react/components/ai/error-boundary.d.ts.map +1 -1
  145. package/esm/src/react/components/ai/error-boundary.js +1 -1
  146. package/esm/src/react/components/ai/icons/index.d.ts +1 -1
  147. package/esm/src/react/components/ai/icons/index.d.ts.map +1 -1
  148. package/esm/src/react/components/ai/icons/index.js +1 -1
  149. package/esm/src/react/components/ai/markdown.d.ts +1 -1
  150. package/esm/src/react/components/ai/markdown.d.ts.map +1 -1
  151. package/esm/src/react/components/ai/markdown.js +1 -1
  152. package/esm/src/react/components/ai/message.d.ts +3 -3
  153. package/esm/src/react/components/ai/message.d.ts.map +1 -1
  154. package/esm/src/react/components/ai/message.js +1 -1
  155. package/esm/src/react/components/optimized-image/OptimizedBackgroundImage.d.ts +1 -1
  156. package/esm/src/react/components/optimized-image/OptimizedBackgroundImage.d.ts.map +1 -1
  157. package/esm/src/react/components/optimized-image/OptimizedBackgroundImage.js +1 -1
  158. package/esm/src/react/components/optimized-image/OptimizedImage.d.ts +1 -1
  159. package/esm/src/react/components/optimized-image/OptimizedImage.d.ts.map +1 -1
  160. package/esm/src/react/components/optimized-image/OptimizedImage.js +1 -1
  161. package/esm/src/react/components/optimized-image/SimpleOptimizedImage.d.ts +1 -1
  162. package/esm/src/react/components/optimized-image/SimpleOptimizedImage.d.ts.map +1 -1
  163. package/esm/src/react/components/optimized-image/utils.d.ts +1 -1
  164. package/esm/src/react/components/optimized-image/utils.d.ts.map +1 -1
  165. package/esm/src/react/components/optimized-image/utils.js +1 -1
  166. package/esm/src/react/context/index.d.ts +1 -1
  167. package/esm/src/react/context/index.d.ts.map +1 -1
  168. package/esm/src/react/context/index.js +1 -1
  169. package/esm/src/react/fonts/index.d.ts +1 -1
  170. package/esm/src/react/fonts/index.d.ts.map +1 -1
  171. package/esm/src/react/fonts/index.js +1 -1
  172. package/esm/src/react/primitives/agent-primitives.d.ts +4 -4
  173. package/esm/src/react/primitives/agent-primitives.d.ts.map +1 -1
  174. package/esm/src/react/primitives/agent-primitives.js +1 -1
  175. package/esm/src/react/primitives/chat-container.d.ts +2 -2
  176. package/esm/src/react/primitives/chat-container.d.ts.map +1 -1
  177. package/esm/src/react/primitives/chat-container.js +1 -1
  178. package/esm/src/react/primitives/input-box.d.ts +4 -4
  179. package/esm/src/react/primitives/input-box.d.ts.map +1 -1
  180. package/esm/src/react/primitives/input-box.js +7 -3
  181. package/esm/src/react/primitives/message-list.d.ts +5 -5
  182. package/esm/src/react/primitives/message-list.d.ts.map +1 -1
  183. package/esm/src/react/primitives/message-list.js +1 -1
  184. package/esm/src/react/primitives/tool-primitives.d.ts +4 -4
  185. package/esm/src/react/primitives/tool-primitives.d.ts.map +1 -1
  186. package/esm/src/react/primitives/tool-primitives.js +1 -1
  187. package/esm/src/react/router/index.d.ts +1 -1
  188. package/esm/src/react/router/index.d.ts.map +1 -1
  189. package/esm/src/react/router/index.js +1 -1
  190. package/esm/src/rendering/app-reserved.d.ts +1 -1
  191. package/esm/src/rendering/app-reserved.d.ts.map +1 -1
  192. package/esm/src/rendering/app-reserved.js +1 -1
  193. package/esm/src/rendering/client/router.js +1 -1
  194. package/esm/src/rendering/client/state-bridge.d.ts +1 -1
  195. package/esm/src/rendering/client/state-bridge.d.ts.map +1 -1
  196. package/esm/src/rendering/client/state-bridge.js +1 -1
  197. package/esm/src/rendering/component-handling.d.ts +3 -1
  198. package/esm/src/rendering/component-handling.d.ts.map +1 -1
  199. package/esm/src/rendering/component-handling.js +4 -2
  200. package/esm/src/rendering/element-validator/element-normalizer.d.ts +1 -1
  201. package/esm/src/rendering/element-validator/element-normalizer.d.ts.map +1 -1
  202. package/esm/src/rendering/element-validator/element-normalizer.js +1 -1
  203. package/esm/src/rendering/element-validator/primitive-checks.d.ts +1 -1
  204. package/esm/src/rendering/element-validator/primitive-checks.d.ts.map +1 -1
  205. package/esm/src/rendering/element-validator/primitive-checks.js +1 -1
  206. package/esm/src/rendering/element-validator/validator-core.d.ts +1 -1
  207. package/esm/src/rendering/element-validator/validator-core.d.ts.map +1 -1
  208. package/esm/src/rendering/layouts/layout-applicator.d.ts +1 -1
  209. package/esm/src/rendering/layouts/layout-applicator.d.ts.map +1 -1
  210. package/esm/src/rendering/layouts/layout-applicator.js +2 -0
  211. package/esm/src/rendering/layouts/utils/applicator.d.ts +1 -1
  212. package/esm/src/rendering/layouts/utils/applicator.d.ts.map +1 -1
  213. package/esm/src/rendering/layouts/utils/component-loader.d.ts +1 -1
  214. package/esm/src/rendering/layouts/utils/component-loader.d.ts.map +1 -1
  215. package/esm/src/rendering/layouts/utils/ensure-valid-child.d.ts +1 -1
  216. package/esm/src/rendering/layouts/utils/ensure-valid-child.d.ts.map +1 -1
  217. package/esm/src/rendering/orchestrator/layout.d.ts +1 -1
  218. package/esm/src/rendering/orchestrator/layout.d.ts.map +1 -1
  219. package/esm/src/rendering/orchestrator/module-loader/index.d.ts +3 -0
  220. package/esm/src/rendering/orchestrator/module-loader/index.d.ts.map +1 -1
  221. package/esm/src/rendering/orchestrator/module-loader/index.js +74 -19
  222. package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
  223. package/esm/src/rendering/orchestrator/pipeline.js +2 -0
  224. package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts +1 -1
  225. package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts.map +1 -1
  226. package/esm/src/rendering/page-renderer.d.ts +1 -1
  227. package/esm/src/rendering/page-renderer.d.ts.map +1 -1
  228. package/esm/src/rendering/page-rendering.d.ts +1 -1
  229. package/esm/src/rendering/page-rendering.d.ts.map +1 -1
  230. package/esm/src/rendering/rsc/server-renderer/component-detector.d.ts +1 -1
  231. package/esm/src/rendering/rsc/server-renderer/component-detector.d.ts.map +1 -1
  232. package/esm/src/rendering/rsc/server-renderer/rsc-renderer.d.ts +1 -1
  233. package/esm/src/rendering/rsc/server-renderer/rsc-renderer.d.ts.map +1 -1
  234. package/esm/src/rendering/rsc/server-renderer/tree-processor.d.ts +1 -1
  235. package/esm/src/rendering/rsc/server-renderer/tree-processor.d.ts.map +1 -1
  236. package/esm/src/rendering/rsc/server-renderer/tree-processor.js +4 -2
  237. package/esm/src/rendering/snippet-renderer.js +2 -2
  238. package/esm/src/rendering/ssr/component-registry.d.ts +1 -1
  239. package/esm/src/rendering/ssr/component-registry.d.ts.map +1 -1
  240. package/esm/src/rendering/ssr/component-registry.js +1 -1
  241. package/esm/src/rendering/ssr-renderer.d.ts +1 -1
  242. package/esm/src/rendering/ssr-renderer.d.ts.map +1 -1
  243. package/esm/src/rendering/utils/react-helpers.d.ts +1 -1
  244. package/esm/src/rendering/utils/react-helpers.d.ts.map +1 -1
  245. package/esm/src/rendering/utils/react-helpers.js +1 -1
  246. package/esm/src/server/handlers/request/ssr/error-page-fallback.js +1 -1
  247. package/esm/src/server/handlers/request/ssr/not-found-fallback.js +1 -1
  248. package/esm/src/transforms/esm/http-bundler.d.ts +15 -4
  249. package/esm/src/transforms/esm/http-bundler.d.ts.map +1 -1
  250. package/esm/src/transforms/esm/http-bundler.js +105 -12
  251. package/esm/src/transforms/esm/http-cache.d.ts.map +1 -1
  252. package/esm/src/transforms/esm/http-cache.js +51 -44
  253. package/esm/src/transforms/esm/import-rewriter.d.ts.map +1 -1
  254. package/esm/src/transforms/esm/import-rewriter.js +3 -3
  255. package/esm/src/transforms/esm/package-registry.d.ts +15 -13
  256. package/esm/src/transforms/esm/package-registry.d.ts.map +1 -1
  257. package/esm/src/transforms/esm/package-registry.js +45 -32
  258. package/esm/src/transforms/esm/react-imports.d.ts.map +1 -1
  259. package/esm/src/transforms/esm/react-imports.js +3 -7
  260. package/esm/src/transforms/esm/types.d.ts +2 -0
  261. package/esm/src/transforms/esm/types.d.ts.map +1 -1
  262. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts +14 -0
  263. package/esm/src/transforms/mdx/esm-module-loader/cache/index.d.ts.map +1 -1
  264. package/esm/src/transforms/mdx/esm-module-loader/cache/index.js +67 -0
  265. package/esm/src/transforms/mdx/esm-module-loader/loader.d.ts.map +1 -1
  266. package/esm/src/transforms/mdx/esm-module-loader/loader.js +1 -1
  267. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -0
  268. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
  269. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -0
  270. package/esm/src/transforms/mdx/esm-module-loader/types.d.ts +4 -0
  271. package/esm/src/transforms/mdx/esm-module-loader/types.d.ts.map +1 -1
  272. package/esm/src/transforms/mdx/index.d.ts +1 -1
  273. package/esm/src/transforms/mdx/index.d.ts.map +1 -1
  274. package/esm/src/transforms/mdx/index.js +1 -1
  275. package/esm/src/transforms/mdx/mdx-cache-adapter.js +1 -1
  276. package/esm/src/transforms/mdx/module-loader/types.d.ts +1 -1
  277. package/esm/src/transforms/mdx/module-loader/types.d.ts.map +1 -1
  278. package/esm/src/transforms/mdx/types.d.ts +2 -2
  279. package/esm/src/transforms/mdx/types.d.ts.map +1 -1
  280. package/esm/src/transforms/pipeline/context.d.ts.map +1 -1
  281. package/esm/src/transforms/pipeline/context.js +7 -15
  282. package/esm/src/transforms/pipeline/stages/finalize.d.ts.map +1 -1
  283. package/esm/src/transforms/pipeline/stages/finalize.js +1 -1
  284. package/esm/src/types/app.d.ts +1 -1
  285. package/esm/src/types/app.d.ts.map +1 -1
  286. package/esm/src/types/global-guards.d.ts +1 -1
  287. package/esm/src/types/global-guards.d.ts.map +1 -1
  288. package/esm/src/types/index.d.ts +1 -1
  289. package/esm/src/types/index.d.ts.map +1 -1
  290. package/esm/src/utils/constants/cdn.d.ts.map +1 -1
  291. package/esm/src/utils/constants/cdn.js +22 -11
  292. package/esm/src/utils/hash-utils.d.ts +2 -0
  293. package/esm/src/utils/hash-utils.d.ts.map +1 -1
  294. package/esm/src/utils/hash-utils.js +4 -0
  295. package/esm/src/workflow/react/use-approval.js +1 -1
  296. package/esm/src/workflow/react/use-workflow-list.js +1 -1
  297. package/esm/src/workflow/react/use-workflow-start.js +1 -1
  298. package/esm/src/workflow/react/use-workflow.js +1 -1
  299. package/package.json +2 -1
  300. package/src/deno.js +8 -9
  301. package/src/deps/esm.sh/@types/react-dom@19.1.11/X-ZGNzc3R5cGVAMy4yLjMKZXJlYWN0/client.d.ts +105 -0
  302. package/src/deps/esm.sh/@types/react-dom@19.1.11/X-ZGNzc3R5cGVAMy4yLjMKZXJlYWN0/server.d.ts +162 -0
  303. package/src/deps/esm.sh/@types/react@19.1.17/X-ZGNzc3R5cGVAMy4yLjM/global.d.ts +165 -0
  304. package/src/deps/esm.sh/@types/react@19.1.17/X-ZGNzc3R5cGVAMy4yLjM/index.d.ts +4267 -0
  305. package/src/deps/esm.sh/@types/react@19.1.17/X-ZGNzc3R5cGVAMy4yLjMKZXJlYWN0/global.d.ts +165 -0
  306. package/src/deps/esm.sh/@types/react@19.1.17/X-ZGNzc3R5cGVAMy4yLjMKZXJlYWN0/index.d.ts +4267 -0
  307. package/src/deps/esm.sh/@types/react@19.1.17/X-ZGNzc3R5cGVAMy4yLjMKZXJlYWN0/jsx-runtime.d.ts +36 -0
  308. package/src/deps/esm.sh/@types/scheduler@0.26.0/index.d.ts +30 -0
  309. package/src/deps/esm.sh/csstype@3.2.3/index.d.ts +22569 -0
  310. package/src/deps/esm.sh/react-dom@19.1.1/client.d.ts +105 -0
  311. package/src/deps/esm.sh/react-dom@19.1.1/client.js +5 -0
  312. package/src/deps/esm.sh/react-dom@19.1.1/server.d.ts +162 -0
  313. package/src/deps/esm.sh/react-dom@19.1.1/server.js +5 -0
  314. package/src/deps/esm.sh/react@19.1.1/jsx-runtime.d.ts +36 -0
  315. package/src/deps/esm.sh/react@19.1.1/jsx-runtime.js +3 -0
  316. package/src/deps/esm.sh/react@19.1.1.d.ts +4267 -0
  317. package/src/deps/esm.sh/react@19.1.1.js +3 -0
  318. package/src/deps/esm.sh/scheduler@^0.26.0.d.ts +30 -0
  319. package/src/deps/esm.sh/scheduler@^0.26.0.js +3 -0
  320. package/src/proxy/main.ts +471 -0
  321. package/src/src/agent/react/use-agent.ts +1 -1
  322. package/src/src/agent/react/use-chat/use-chat.ts +1 -1
  323. package/src/src/agent/react/use-completion.ts +1 -1
  324. package/src/src/agent/react/use-streaming.ts +1 -1
  325. package/src/src/agent/react/use-voice-input.ts +1 -1
  326. package/src/src/cli/app/components/list-select.ts +2 -2
  327. package/src/src/cli/app/index.ts +34 -35
  328. package/src/src/cli/app/state.ts +7 -0
  329. package/src/src/cli/app/views/dashboard.ts +46 -60
  330. package/src/src/cli/app/views/startup.ts +132 -0
  331. package/src/src/cli/commands/init/config-generator.ts +1 -1
  332. package/src/src/cli/index/arg-parser.ts +1 -0
  333. package/src/src/cli/index/command-router.ts +57 -40
  334. package/src/src/cli/index/types.ts +5 -0
  335. package/src/src/cli/ui/colors.ts +37 -0
  336. package/src/src/cli/ui/dot-matrix.ts +77 -1
  337. package/src/src/config/loader.ts +5 -4
  338. package/src/src/html/utils.ts +2 -2
  339. package/src/src/modules/component-registry/registry.ts +1 -1
  340. package/src/src/modules/import-map/default-import-map.ts +3 -25
  341. package/src/src/modules/import-map/loader.ts +7 -23
  342. package/src/src/modules/import-map/resolver.ts +13 -8
  343. package/src/src/modules/react-loader/component-loader.ts +3 -1
  344. package/src/src/modules/react-loader/extract-component.ts +1 -1
  345. package/src/src/modules/react-loader/ssr-module-loader/loader.ts +95 -68
  346. package/src/src/modules/react-loader/ssr-module-loader/types.ts +2 -0
  347. package/src/src/modules/react-loader/types.ts +3 -1
  348. package/src/src/modules/react-loader/unified-loader.ts +7 -4
  349. package/src/src/modules/server/module-batch-handler.ts +7 -0
  350. package/src/src/modules/server/module-server.ts +6 -1
  351. package/src/src/modules/server/ssr-import-rewriter.ts +9 -17
  352. package/src/src/react/compat/hooks-adapter.ts +1 -1
  353. package/src/src/react/compat/ssr-adapter/response-builder.ts +1 -1
  354. package/src/src/react/compat/ssr-adapter/server-loader.ts +10 -10
  355. package/src/src/react/compat/ssr-adapter/stream-renderer.ts +2 -2
  356. package/src/src/react/compat/ssr-adapter/string-renderer.ts +3 -3
  357. package/src/src/react/compat/version-detector/feature-detector.ts +1 -1
  358. package/src/src/react/components/AppWrapper.tsx +1 -1
  359. package/src/src/react/components/Head.tsx +7 -3
  360. package/src/src/react/components/LayoutComponent.tsx +2 -2
  361. package/src/src/react/components/Link.tsx +1 -1
  362. package/src/src/react/components/MDXProvider.tsx +2 -2
  363. package/src/src/react/components/ProviderComponent.tsx +2 -2
  364. package/src/src/react/components/ai/agent-card.tsx +1 -1
  365. package/src/src/react/components/ai/chat/components/animations.tsx +1 -1
  366. package/src/src/react/components/ai/chat/components/empty-state.tsx +1 -1
  367. package/src/src/react/components/ai/chat/components/message-actions.tsx +1 -1
  368. package/src/src/react/components/ai/chat/components/reasoning.tsx +1 -1
  369. package/src/src/react/components/ai/chat/components/tool-ui.tsx +1 -1
  370. package/src/src/react/components/ai/chat/composition/api.tsx +1 -1
  371. package/src/src/react/components/ai/chat/index.tsx +1 -1
  372. package/src/src/react/components/ai/error-boundary.tsx +1 -1
  373. package/src/src/react/components/ai/icons/index.ts +1 -1
  374. package/src/src/react/components/ai/markdown.tsx +1 -1
  375. package/src/src/react/components/ai/message.tsx +1 -1
  376. package/src/src/react/components/optimized-image/OptimizedBackgroundImage.tsx +1 -1
  377. package/src/src/react/components/optimized-image/OptimizedImage.tsx +1 -1
  378. package/src/src/react/components/optimized-image/SimpleOptimizedImage.tsx +1 -1
  379. package/src/src/react/components/optimized-image/utils.tsx +1 -1
  380. package/src/src/react/context/index.ts +1 -1
  381. package/src/src/react/fonts/index.ts +1 -1
  382. package/src/src/react/primitives/agent-primitives.tsx +1 -1
  383. package/src/src/react/primitives/chat-container.tsx +1 -1
  384. package/src/src/react/primitives/input-box.tsx +5 -3
  385. package/src/src/react/primitives/message-list.tsx +1 -1
  386. package/src/src/react/primitives/tool-primitives.tsx +1 -1
  387. package/src/src/react/router/index.ts +1 -1
  388. package/src/src/rendering/app-reserved.ts +1 -1
  389. package/src/src/rendering/client/router.ts +2 -2
  390. package/src/src/rendering/client/state-bridge.ts +2 -2
  391. package/src/src/rendering/component-handling.ts +7 -1
  392. package/src/src/rendering/element-validator/element-inspector.ts +1 -1
  393. package/src/src/rendering/element-validator/element-normalizer.ts +1 -1
  394. package/src/src/rendering/element-validator/primitive-checks.ts +1 -1
  395. package/src/src/rendering/element-validator/validator-core.ts +1 -1
  396. package/src/src/rendering/layouts/layout-applicator.ts +5 -6
  397. package/src/src/rendering/layouts/utils/applicator.ts +1 -1
  398. package/src/src/rendering/layouts/utils/component-loader.ts +1 -1
  399. package/src/src/rendering/layouts/utils/ensure-valid-child.ts +1 -1
  400. package/src/src/rendering/orchestrator/layout.ts +1 -1
  401. package/src/src/rendering/orchestrator/module-loader/index.ts +91 -20
  402. package/src/src/rendering/orchestrator/pipeline.ts +2 -0
  403. package/src/src/rendering/orchestrator/ssr-orchestrator.ts +2 -2
  404. package/src/src/rendering/page-renderer.ts +1 -1
  405. package/src/src/rendering/page-rendering.ts +1 -1
  406. package/src/src/rendering/rsc/server-renderer/component-detector.ts +1 -1
  407. package/src/src/rendering/rsc/server-renderer/rsc-renderer.ts +1 -1
  408. package/src/src/rendering/rsc/server-renderer/tree-processor.ts +14 -4
  409. package/src/src/rendering/snippet-renderer.ts +2 -2
  410. package/src/src/rendering/ssr/component-registry.ts +1 -1
  411. package/src/src/rendering/ssr-renderer.ts +1 -1
  412. package/src/src/rendering/utils/react-helpers.ts +1 -1
  413. package/src/src/server/build-app-route-renderer.ts +2 -2
  414. package/src/src/server/handlers/request/rsc/handlers/render-handler.ts +1 -1
  415. package/src/src/server/handlers/request/ssr/error-page-fallback.ts +2 -2
  416. package/src/src/server/handlers/request/ssr/not-found-fallback.ts +1 -1
  417. package/src/src/transforms/esm/http-bundler.ts +101 -11
  418. package/src/src/transforms/esm/http-cache.ts +53 -45
  419. package/src/src/transforms/esm/import-rewriter.ts +5 -3
  420. package/src/src/transforms/esm/package-registry.ts +46 -32
  421. package/src/src/transforms/esm/react-imports.ts +3 -7
  422. package/src/src/transforms/esm/types.ts +2 -0
  423. package/src/src/transforms/mdx/esm-module-loader/cache/index.ts +84 -0
  424. package/src/src/transforms/mdx/esm-module-loader/loader.ts +2 -1
  425. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +2 -1
  426. package/src/src/transforms/mdx/esm-module-loader/types.ts +4 -0
  427. package/src/src/transforms/mdx/index.ts +1 -1
  428. package/src/src/transforms/mdx/mdx-cache-adapter.ts +1 -1
  429. package/src/src/transforms/mdx/module-loader/types.ts +1 -1
  430. package/src/src/transforms/mdx/types.ts +2 -2
  431. package/src/src/transforms/pipeline/context.ts +7 -18
  432. package/src/src/transforms/pipeline/stages/finalize.ts +6 -1
  433. package/src/src/transforms/plugins/babel-node-positions.ts +2 -2
  434. package/src/src/types/app.ts +1 -1
  435. package/src/src/types/global-guards.ts +1 -1
  436. package/src/src/types/index.ts +1 -1
  437. package/src/src/utils/constants/cdn.ts +21 -12
  438. package/src/src/utils/hash-utils.ts +5 -0
  439. package/src/src/workflow/react/use-approval.ts +1 -1
  440. package/src/src/workflow/react/use-workflow-list.ts +1 -1
  441. package/src/src/workflow/react/use-workflow-start.ts +1 -1
  442. package/src/src/workflow/react/use-workflow.ts +1 -1
@@ -156,47 +156,137 @@ export function createHTTPPlugin(): Plugin {
156
156
  }
157
157
 
158
158
  /**
159
- * Ensure esm.sh URLs have ?external=react for SSR.
160
- * This makes them import React as a bare specifier, which deno.json resolves.
159
+ * Ensure esm.sh URLs have external=react,react-dom for SSR.
160
+ * This makes them import React as bare specifiers, which the import map resolves.
161
161
  *
162
162
  * Uses two esm.sh features:
163
- * - `external=react` - Don't bundle React, let import map resolve it
163
+ * - `external=react,react-dom` - Don't bundle React/ReactDOM, let import map resolve them
164
164
  * - `deps=react@X,react-dom@X` - Pin dependency versions to prevent mismatches
165
+ *
166
+ * Logic for external handling:
167
+ * 1. If no `external=` param → add `external=react,react-dom`
168
+ * 2. If `external=X` exists but no `react` → append `,react,react-dom`
169
+ * 3. If has `react` but no `react-dom` → append `,react-dom`
170
+ * 4. If has both `react` AND `react-dom` → leave alone
171
+ *
172
+ * @param code - Source code to process
173
+ * @param _cacheDir - Unused (kept for API compatibility)
174
+ * @param hash - Hash for logging
175
+ * @param reactVersion - React version for deps param (defaults to REACT_VERSION)
165
176
  */
166
177
  export function bundleHttpImports(
167
178
  code: string,
168
179
  _cacheDir: string,
169
180
  hash: string,
181
+ reactVersion?: string,
170
182
  ): string | Promise<string> {
171
183
  const has = hasHttpImports(code);
172
184
  logger.debug(`${LOG_PREFIX} Check: hasHttp=${has}, hash=${hash.slice(0, 8)}`);
173
185
  if (!has) return code;
174
186
 
187
+ const version = reactVersion ?? REACT_VERSION;
188
+
175
189
  return replaceSpecifiers(code, (specifier) => {
190
+ // Handle relative esm.sh paths like "/react-dom?target=es2022" or "/hoist-non-react-statics@..."
191
+ // These are returned by esm.sh stub modules and need to be converted to full URLs
192
+ if (specifier.startsWith("/") && !specifier.startsWith("//")) {
193
+ const fullUrl = `https://esm.sh${specifier}`;
194
+ // Recursively process as full URL (will add external params if needed)
195
+ const isReactPackage = /^\/react(-dom)?(@|\/|\?|$)/.test(specifier);
196
+ if (isReactPackage) {
197
+ // React packages - just ensure target and return full URL
198
+ if (!specifier.includes("target=")) {
199
+ const joiner = specifier.includes("?") ? "&" : "?";
200
+ return `${fullUrl}${joiner}target=es2022`;
201
+ }
202
+ return fullUrl;
203
+ }
204
+ // Non-React packages - add external params
205
+ const params: string[] = [];
206
+ if (!specifier.includes("target=")) params.push("target=es2022");
207
+ if (!specifier.includes("external=")) params.push("external=react,react-dom");
208
+ if (!specifier.includes("deps=")) params.push(`deps=react@${version},react-dom@${version}`);
209
+ if (params.length === 0) return fullUrl;
210
+ const joiner = specifier.includes("?") ? "&" : "?";
211
+ return `${fullUrl}${joiner}${params.join("&")}`;
212
+ }
213
+
176
214
  const isEsmSh = specifier.startsWith("https://esm.sh/") ||
177
215
  specifier.startsWith("http://esm.sh/");
178
216
  const isVfEsm = specifier.startsWith("https://esm.veryfront.com/");
179
217
  if (!isEsmSh && !isVfEsm) return null;
180
218
 
219
+ // Don't modify React/ReactDOM package URLs themselves
181
220
  const isReactPackage = /\/react(-dom)?(@|\/|$)/.test(specifier);
221
+ if (isReactPackage) {
222
+ // Just ensure target is set for React packages
223
+ if (!specifier.includes("target=")) {
224
+ const joiner = specifier.includes("?") ? "&" : "?";
225
+ return `${specifier}${joiner}target=es2022`;
226
+ }
227
+ return null;
228
+ }
182
229
 
230
+ // For non-React packages: ensure external=react,react-dom and deps
183
231
  const params: string[] = [];
184
232
 
185
233
  if (!specifier.includes("target=")) {
186
234
  params.push("target=es2022");
187
235
  }
188
236
 
189
- // Only add external and deps to non-React packages
190
- // Use external=react to not bundle React (let import map resolve it)
191
- // Use deps=react@X,react-dom@X to pin dependency versions
192
- if (!isReactPackage) {
193
- if (!specifier.includes("external=react")) {
194
- params.push("external=react");
237
+ // Handle external param - ensure both react AND react-dom are externalized
238
+ const hasExternal = specifier.includes("external=");
239
+ const hasReactExternal = specifier.includes("external=react") ||
240
+ /external=[^&]*\breact\b/.test(specifier);
241
+ const hasReactDomExternal = /external=[^&]*react-dom/.test(specifier);
242
+
243
+ if (!hasExternal) {
244
+ // No external param - add both
245
+ params.push("external=react,react-dom");
246
+ } else if (!hasReactExternal) {
247
+ // Has external but no react - append react,react-dom
248
+ // This requires modifying existing param, so we'll use URL parsing
249
+ try {
250
+ const url = new URL(specifier);
251
+ const existing = url.searchParams.get("external") || "";
252
+ url.searchParams.set("external", `${existing},react,react-dom`);
253
+ // Return full modified URL and skip other param additions
254
+ if (!specifier.includes("target=")) {
255
+ url.searchParams.set("target", "es2022");
256
+ }
257
+ if (!specifier.includes("deps=")) {
258
+ url.searchParams.set("deps", `react@${version},react-dom@${version}`);
259
+ }
260
+ logger.debug(`${LOG_PREFIX} ${specifier} -> ${url.toString()}`);
261
+ return url.toString();
262
+ } catch {
263
+ // Fallback: just add as new param (may create duplicate)
264
+ params.push("external=react,react-dom");
195
265
  }
196
- if (!specifier.includes("deps=")) {
197
- params.push(`deps=react@${REACT_VERSION},react-dom@${REACT_VERSION}`);
266
+ } else if (!hasReactDomExternal) {
267
+ // Has react but not react-dom - append react-dom
268
+ try {
269
+ const url = new URL(specifier);
270
+ const existing = url.searchParams.get("external") || "";
271
+ url.searchParams.set("external", `${existing},react-dom`);
272
+ if (!specifier.includes("target=")) {
273
+ url.searchParams.set("target", "es2022");
274
+ }
275
+ if (!specifier.includes("deps=")) {
276
+ url.searchParams.set("deps", `react@${version},react-dom@${version}`);
277
+ }
278
+ logger.debug(`${LOG_PREFIX} ${specifier} -> ${url.toString()}`);
279
+ return url.toString();
280
+ } catch {
281
+ // Fallback
282
+ params.push("external=react-dom");
198
283
  }
199
284
  }
285
+ // else: has both react and react-dom - no external changes needed
286
+
287
+ if (!specifier.includes("deps=")) {
288
+ params.push(`deps=react@${version},react-dom@${version}`);
289
+ }
200
290
 
201
291
  if (params.length === 0) return null;
202
292
 
@@ -12,6 +12,7 @@ import * as dntShim from "../../../_dnt.shims.js";
12
12
  import { createFileSystem, exists } from "../../platform/compat/fs.js";
13
13
  import { isAbsolute, join } from "../../platform/compat/path/index.js";
14
14
  import { cwd } from "../../platform/compat/process.js";
15
+ import { isDeno } from "../../platform/compat/runtime.js";
15
16
  import { rendererLogger as logger } from "../../utils/index.js";
16
17
  import { simpleHash } from "../../utils/hash-utils.js";
17
18
  import { LRUCache } from "../../utils/lru-wrapper.js";
@@ -19,8 +20,7 @@ import { withSpan } from "../../observability/tracing/otlp-setup.js";
19
20
  import { SpanNames } from "../../observability/tracing/span-names.js";
20
21
  import { resolveImport } from "../../modules/import-map/resolver.js";
21
22
  import type { ImportMapConfig } from "../../modules/import-map/types.js";
22
- import { isDeno } from "../../platform/compat/runtime.js";
23
- import { getDenoNpmReactMap, getReactImportMap, REACT_VERSION } from "./package-registry.js";
23
+ import { getReactImportMap, REACT_VERSION } from "./package-registry.js";
24
24
  import { parseImports, replaceSpecifiers } from "./lexer.js";
25
25
  import { CacheBackends, createDistributedCacheAccessor } from "../../cache/backend.js";
26
26
  import {
@@ -34,9 +34,6 @@ const getDistributedCache = createDistributedCacheAccessor(
34
34
  "HTTP-CACHE",
35
35
  );
36
36
 
37
- /** TTL for cached modules in distributed cache (uses centralized config) */
38
- const DISTRIBUTED_CACHE_TTL_SECONDS = HTTP_MODULE_DISTRIBUTED_TTL_SEC;
39
-
40
37
  type CacheOptions = {
41
38
  cacheDir: string;
42
39
  importMap: ImportMapConfig;
@@ -47,6 +44,12 @@ type CacheOptions = {
47
44
  const cachedPaths = new LRUCache<string, string>({ maxEntries: HTTP_MODULE_CACHE_MAX_ENTRIES });
48
45
  const processingStack = new Set<string>();
49
46
 
47
+ /** Tracks last TTL refresh per hash. Refresh every 4h to keep 20h+ remaining (24h total). */
48
+ const lastDistributedRefresh = new LRUCache<string, number>({
49
+ maxEntries: HTTP_MODULE_CACHE_MAX_ENTRIES,
50
+ });
51
+ const DISTRIBUTED_REFRESH_INTERVAL_MS = 4 * 60 * 60 * 1000;
52
+
50
53
  function ensureAbsoluteDir(path: string): string {
51
54
  return isAbsolute(path) ? path : join(cwd(), path);
52
55
  }
@@ -58,13 +61,23 @@ function isHttpUrl(specifier: string): boolean {
58
61
  /**
59
62
  * Check if a URL is for React core packages.
60
63
  *
61
- * Previously, React modules were NOT cached to prevent multiple React instances.
62
- * Now with npm: specifiers for Deno (which auto-deduplicate) and consistent
63
- * esm.sh URLs with external=react for other runtimes, all code uses the same
64
- * React instance.
64
+ * React core modules (react, react-dom) must NOT be cached/bundled.
65
+ * Instead, all packages use external=react and import from the same esm.sh URL.
66
+ * This prevents multiple React instances which causes "useContext is null" errors.
65
67
  */
66
- function isReactCoreUrl(_url: string): boolean {
67
- return false;
68
+ function isReactCoreUrl(url: string): boolean {
69
+ try {
70
+ const parsed = new URL(url);
71
+ if (!parsed.hostname.includes("esm.sh")) return false;
72
+
73
+ // Extract package name from esm.sh pathname
74
+ // Formats: /react@version, /v150/react@version, /stable/react@version
75
+ const pathname = parsed.pathname.replace(/^\/(v\d+|stable)\//, "/");
76
+ const match = pathname.match(/^\/(react|react-dom)(@[\d.]+)?(?:\/|$|\?)/);
77
+ return match !== null;
78
+ } catch {
79
+ return false;
80
+ }
68
81
  }
69
82
 
70
83
  function isExternalScheme(specifier: string): boolean {
@@ -132,26 +145,8 @@ function resolveBareSpecifier(
132
145
  importMap: ImportMapConfig,
133
146
  reactVersion: string = REACT_VERSION,
134
147
  ): string {
135
- // For Deno SSR: Resolve React to npm: specifiers for automatic deduplication.
136
- // Deno's native npm resolution ensures all modules share the same React instance.
137
- // See: https://deno.com/blog/not-using-npm-specifiers-doing-it-wrong
138
- if (isDeno) {
139
- const denoReactMap = getDenoNpmReactMap(reactVersion);
140
- const denoMatch = denoReactMap[specifier];
141
- if (denoMatch) return denoMatch;
142
-
143
- // For unknown react/* or react-dom/* subpaths, construct npm: specifiers
144
- if (specifier.startsWith("react/") && !specifier.startsWith("react-dom")) {
145
- const subpath = specifier.slice("react/".length);
146
- return `npm:react@${reactVersion}/${subpath}`;
147
- }
148
- if (specifier.startsWith("react-dom/")) {
149
- const subpath = specifier.slice("react-dom/".length);
150
- return `npm:react-dom@${reactVersion}/${subpath}`;
151
- }
152
- }
153
-
154
- // For non-Deno runtimes: Use esm.sh URLs with consistent versioning.
148
+ // Use esm.sh URLs for React - NO npm: specifiers per plan requirements.
149
+ // All packages use external=react to share the same React instance.
155
150
  const reactMap = getReactImportMap(reactVersion);
156
151
  const reactMapped = reactMap[specifier];
157
152
  if (reactMapped) return reactMapped;
@@ -194,22 +189,28 @@ async function cacheHttpModule(url: string, options: CacheOptions): Promise<stri
194
189
  if (await exists(cachePath)) {
195
190
  cachedPaths.set(cacheKey, cachePath);
196
191
 
197
- // Synchronously ensure code:{hash} exists in distributed cache for cross-pod recovery
198
- // This backfills bundles created before code:{hash} storage was added
199
- // Synchronous to guarantee data is stored before other pods need it
192
+ // Refresh distributed cache TTL so bundles outlive transforms that reference them.
193
+ // Without this, bundles expire (24h) while SSR transforms (6h) are still valid.
200
194
  const distributed = await getDistributedCache();
201
195
  if (distributed) {
202
196
  const hash = simpleHash(normalizedUrl);
203
- try {
204
- const hasCode = await distributed.get(`code:${hash}`);
205
- if (!hasCode) {
197
+ const hashStr = String(hash);
198
+ const now = Date.now();
199
+ const lastRefresh = lastDistributedRefresh.get(hashStr);
200
+ const needsRefresh = !lastRefresh || (now - lastRefresh > DISTRIBUTED_REFRESH_INTERVAL_MS);
201
+
202
+ if (needsRefresh) {
203
+ try {
206
204
  const code = await fs.readTextFile(cachePath);
207
- await distributed.set(`code:${hash}`, code, DISTRIBUTED_CACHE_TTL_SECONDS);
208
- logger.info("[HTTP-CACHE] Backfilled code:{hash} for existing bundle", { hash });
205
+ await Promise.all([
206
+ distributed.set(`code:${hash}`, code, HTTP_MODULE_DISTRIBUTED_TTL_SEC),
207
+ distributed.set(`hash:${hash}`, normalizedUrl, HTTP_MODULE_DISTRIBUTED_TTL_SEC),
208
+ ]);
209
+ lastDistributedRefresh.set(hashStr, now);
210
+ logger.debug("[HTTP-CACHE] Refreshed distributed cache TTL", { hash });
211
+ } catch (error) {
212
+ logger.debug("[HTTP-CACHE] Distributed cache refresh failed", { hash, error });
209
213
  }
210
- } catch (error) {
211
- // Log but don't fail - backfill is best-effort
212
- logger.debug("[HTTP-CACHE] Backfill failed, continuing", { hash, error });
213
214
  }
214
215
  }
215
216
 
@@ -288,9 +289,9 @@ async function cacheHttpModule(url: string, options: CacheOptions): Promise<stri
288
289
  const hash = simpleHash(normalizedUrl);
289
290
  try {
290
291
  await Promise.all([
291
- distributed.set(normalizedUrl, code, DISTRIBUTED_CACHE_TTL_SECONDS),
292
- distributed.set(`code:${hash}`, code, DISTRIBUTED_CACHE_TTL_SECONDS),
293
- distributed.set(`hash:${hash}`, normalizedUrl, DISTRIBUTED_CACHE_TTL_SECONDS),
292
+ distributed.set(normalizedUrl, code, HTTP_MODULE_DISTRIBUTED_TTL_SEC),
293
+ distributed.set(`code:${hash}`, code, HTTP_MODULE_DISTRIBUTED_TTL_SEC),
294
+ distributed.set(`hash:${hash}`, normalizedUrl, HTTP_MODULE_DISTRIBUTED_TTL_SEC),
294
295
  ]);
295
296
  } catch (error) {
296
297
  logger.debug("[HTTP-CACHE] Distributed cache set failed", { url: normalizedUrl, error });
@@ -327,6 +328,13 @@ async function resolveSpecifier(
327
328
  if (!baseUrl || !isHttpUrl(baseUrl)) return null;
328
329
 
329
330
  const resolved = new URL(specifier, baseUrl).toString();
331
+
332
+ // For React core URLs: return the full esm.sh URL (not cached, to prevent multiple instances)
333
+ // This transforms relative paths like "/react-dom?..." to "https://esm.sh/react-dom?..."
334
+ if (isReactCoreUrl(resolved)) {
335
+ return normalizeHttpUrl(resolved);
336
+ }
337
+
330
338
  const cached = await cacheHttpModule(resolved, options);
331
339
  return cached ? `file://${cached}` : null;
332
340
  }
@@ -51,9 +51,11 @@ function normalizeVersionedSpecifier(specifier: string): string {
51
51
 
52
52
  const REACT_IMPORT_MAP: Record<string, string> = {
53
53
  react: `https://esm.sh/react@${REACT_DEFAULT_VERSION}?target=es2022`,
54
- "react-dom": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}?target=es2022`,
55
- "react-dom/client": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/client?target=es2022`,
56
- "react-dom/server": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/server?target=es2022`,
54
+ "react-dom": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}?external=react&target=es2022`,
55
+ "react-dom/client":
56
+ `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/client?external=react&target=es2022`,
57
+ "react-dom/server":
58
+ `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/server?external=react&target=es2022`,
57
59
  "react/jsx-runtime": `https://esm.sh/react@${REACT_DEFAULT_VERSION}/jsx-runtime?target=es2022`,
58
60
  "react/jsx-dev-runtime":
59
61
  `https://esm.sh/react@${REACT_DEFAULT_VERSION}/jsx-dev-runtime?target=es2022`,
@@ -9,23 +9,35 @@
9
9
  export const DEFAULT_REACT_VERSION = "19.1.1";
10
10
  export const TAILWIND_VERSION = "4.1.8";
11
11
 
12
- /** Cached React version from project config */
13
- let configuredReactVersion: string | null = null;
12
+ /**
13
+ * Validate React version format (semver: X.Y.Z).
14
+ * Returns true if valid, false otherwise.
15
+ */
16
+ export function isValidReactVersion(version: string): boolean {
17
+ return /^\d+\.\d+\.\d+$/.test(version);
18
+ }
14
19
 
15
20
  /**
16
- * Set the React version from project configuration.
17
- * Call this during project initialization if a custom version is specified.
21
+ * Validate and normalize React version.
22
+ * Returns the version if valid, or DEFAULT_REACT_VERSION if invalid.
23
+ * Logs a warning if the version is invalid.
18
24
  */
19
- export function setReactVersion(version: string): void {
20
- configuredReactVersion = version;
25
+ export function normalizeReactVersion(version: string | undefined): string {
26
+ if (!version) return DEFAULT_REACT_VERSION;
27
+ if (isValidReactVersion(version)) return version;
28
+ console.warn(
29
+ `[VERYFRONT] Invalid React version format "${version}" (expected X.Y.Z). Using default: ${DEFAULT_REACT_VERSION}`,
30
+ );
31
+ return DEFAULT_REACT_VERSION;
21
32
  }
22
33
 
23
34
  /**
24
- * Get the current React version.
25
- * Returns configured version if set, otherwise the default.
35
+ * @deprecated Global React version is no longer supported.
36
+ * Use config.react.version passed through TransformOptions instead.
37
+ * This function now always returns DEFAULT_REACT_VERSION.
26
38
  */
27
39
  export function getReactVersion(): string {
28
- return configuredReactVersion ?? DEFAULT_REACT_VERSION;
40
+ return DEFAULT_REACT_VERSION;
29
41
  }
30
42
 
31
43
  /** @deprecated Use DEFAULT_REACT_VERSION or getReactVersion() */
@@ -50,8 +62,15 @@ export const REACT_VERSION = DEFAULT_REACT_VERSION;
50
62
  */
51
63
  export const TRANSFORM_CACHE_VERSION = 12;
52
64
 
53
- function esmSh(pkg: string, version: string, path = "", query = "target=es2022"): string {
54
- return `https://esm.sh/${pkg}@${version}${path}?${query}`;
65
+ /** csstype version - must match deno.json for type consistency */
66
+ const CSSTYPE_VERSION = "3.2.3";
67
+
68
+ /** Build esm.sh URL with deps=csstype for React packages (ensures type consistency) */
69
+ function esmShReact(pkg: string, version: string, path = "", external = false): string {
70
+ const params = external
71
+ ? [`external=react`, `target=es2022`, `deps=csstype@${CSSTYPE_VERSION}`]
72
+ : [`target=es2022`, `deps=csstype@${CSSTYPE_VERSION}`];
73
+ return `https://esm.sh/${pkg}@${version}${path}?${params.join("&")}`;
55
74
  }
56
75
 
57
76
  /**
@@ -78,12 +97,12 @@ export function getEsmShUrl(pkg: string, version: string, external?: readonly st
78
97
  export function getReactUrls(version?: string): Record<string, string> {
79
98
  const v = version ?? getReactVersion();
80
99
  return {
81
- react: esmSh("react", v),
82
- "react-dom": esmSh("react-dom", v, "", "external=react&target=es2022"),
83
- "react-dom/client": esmSh("react-dom", v, "/client", "external=react&target=es2022"),
84
- "react-dom/server": esmSh("react-dom", v, "/server", "external=react&target=es2022"),
85
- "react/jsx-runtime": esmSh("react", v, "/jsx-runtime", "external=react&target=es2022"),
86
- "react/jsx-dev-runtime": esmSh("react", v, "/jsx-dev-runtime", "external=react&target=es2022"),
100
+ react: esmShReact("react", v),
101
+ "react-dom": esmShReact("react-dom", v, "", true),
102
+ "react-dom/client": esmShReact("react-dom", v, "/client", true),
103
+ "react-dom/server": esmShReact("react-dom", v, "/server", true),
104
+ "react/jsx-runtime": esmShReact("react", v, "/jsx-runtime", true),
105
+ "react/jsx-dev-runtime": esmShReact("react", v, "/jsx-dev-runtime", true),
87
106
  };
88
107
  }
89
108
 
@@ -102,30 +121,25 @@ export function getReactImportMap(version?: string): Record<string, string> {
102
121
  return {
103
122
  ...getReactUrls(v),
104
123
  // Prefix match for any react/* subpath imports
105
- "react/": esmSh("react", v, "/", "external=react&target=es2022"),
124
+ "react/": esmShReact("react", v, "/", true),
106
125
  };
107
126
  }
108
127
 
109
128
  /**
110
- * Get React npm specifiers for Deno SSR.
111
- * Uses npm: protocol which Deno handles natively with automatic deduplication.
112
- * See: https://deno.com/blog/not-using-npm-specifiers-doing-it-wrong
113
- *
114
- * Benefits over esm.sh:
115
- * - Automatic semantic version deduplication (like Node's node_modules)
116
- * - No manual external= flags or shared-*.ts wrapper files needed
117
- * - Native support in Deno 2+
129
+ * Get React esm.sh URLs for Deno SSR.
130
+ * Uses esm.sh for both SSR and browser to ensure identical React instances.
131
+ * All sub-packages use external=react to share the same React instance.
118
132
  *
119
133
  * @param version - React version to use (defaults to REACT_VERSION)
120
134
  */
121
135
  export function getDenoNpmReactMap(version?: string): Record<string, string> {
122
136
  const v = version ?? getReactVersion();
123
137
  return {
124
- "react": `npm:react@${v}`,
125
- "react-dom": `npm:react-dom@${v}`,
126
- "react-dom/client": `npm:react-dom@${v}/client`,
127
- "react-dom/server": `npm:react-dom@${v}/server`,
128
- "react/jsx-runtime": `npm:react@${v}/jsx-runtime`,
129
- "react/jsx-dev-runtime": `npm:react@${v}/jsx-dev-runtime`,
138
+ "react": esmShReact("react", v),
139
+ "react-dom": esmShReact("react-dom", v, "", true),
140
+ "react-dom/client": esmShReact("react-dom", v, "/client", true),
141
+ "react-dom/server": esmShReact("react-dom", v, "/server", true),
142
+ "react/jsx-runtime": esmShReact("react", v, "/jsx-runtime", true),
143
+ "react/jsx-dev-runtime": esmShReact("react", v, "/jsx-dev-runtime", true),
130
144
  };
131
145
  }
@@ -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
 
6
4
  const srcDir = new URL(".", import.meta.url).pathname.replace(
7
5
  /\/(build|src)\/transforms\/esm\/?$/,
@@ -28,12 +26,10 @@ export async function resolveReactImports(
28
26
  return replaceSpecifiers(code, (specifier) => reactImports[specifier] ?? null);
29
27
  }
30
28
 
31
- // For Deno SSR: Use npm: specifiers (auto-deduplicated by Deno's npm cache)
32
- // For Node/Bun SSR: Use local node_modules paths (auto-deduplicated by Node)
33
- // See: https://deno.com/blog/not-using-npm-specifiers-doing-it-wrong
29
+ // For SSR: Use esm.sh URLs consistently (NO npm: specifiers per plan requirements)
34
30
  const ssrImports: Record<string, string> = {
35
31
  ...getVeryfrontModulePaths(),
36
- ...(isDeno ? getDenoNpmReactMap(reactVersion) : getLocalReactPaths()),
32
+ ...reactImports,
37
33
  };
38
34
 
39
35
  return replaceSpecifiers(code, (specifier) => ssrImports[specifier] ?? null);
@@ -9,6 +9,8 @@ export interface TransformOptions {
9
9
  ssr?: boolean;
10
10
  apiBaseUrl?: string;
11
11
  studioEmbed?: boolean;
12
+ /** React version for transforms (from project config, defaults to DEFAULT_REACT_VERSION) */
13
+ reactVersion?: string;
12
14
  }
13
15
 
14
16
  export interface TransformContext {
@@ -14,6 +14,7 @@ import {
14
14
  type FileSystem,
15
15
  isNotFoundError,
16
16
  } from "../../../../platform/compat/fs.js";
17
+ import { TRANSFORM_CACHE_VERSION } from "../../../esm/package-registry.js";
17
18
  import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
18
19
 
19
20
  // Local filesystem for cache operations (not project's FSAdapter which may be remote/read-only)
@@ -150,3 +151,86 @@ export async function clearESMDiskCache(): Promise<void> {
150
151
  }
151
152
  }
152
153
  }
154
+
155
+ /**
156
+ * Convert a project-relative file path to MDX-ESM cache key format.
157
+ *
158
+ * @param filePath - Project-relative path like "lib/ChatContext.tsx" or absolute path
159
+ * @param projectDir - Project directory to strip from absolute paths
160
+ * @returns Cache key like "v10:_vf_modules/lib/ChatContext.js"
161
+ */
162
+ function toMdxEsmCacheKey(filePath: string, projectDir?: string): string {
163
+ // Strip project directory prefix if present
164
+ let relativePath = filePath;
165
+ if (projectDir && filePath.startsWith(projectDir)) {
166
+ relativePath = filePath.slice(projectDir.length).replace(/^\/+/, "");
167
+ }
168
+ // Strip leading slashes
169
+ relativePath = relativePath.replace(/^\/+/, "");
170
+
171
+ // Convert extension to .js
172
+ const jsPath = relativePath.replace(/\.(tsx?|jsx|mdx)$/, ".js");
173
+
174
+ // Build the versioned key in MDX-ESM format
175
+ return `v${TRANSFORM_CACHE_VERSION}:_vf_modules/${jsPath}`;
176
+ }
177
+
178
+ /**
179
+ * Look up a module in the MDX-ESM cache.
180
+ *
181
+ * This allows other loaders (like SSR loader) to reuse modules that
182
+ * MDX-ESM has already transformed and cached, preventing duplicate
183
+ * module instances (which breaks React context, etc.).
184
+ *
185
+ * @param filePath - Project-relative file path like "lib/ChatContext.tsx"
186
+ * @param cacheDir - The MDX-ESM cache directory for this project/contentSource
187
+ * @param projectDir - Project directory to strip from absolute paths
188
+ * @param contentHash - Optional content hash to validate cached file freshness
189
+ * @returns The cached file path if found and valid, null otherwise
190
+ */
191
+ export async function lookupMdxEsmCache(
192
+ filePath: string,
193
+ cacheDir: string,
194
+ projectDir?: string,
195
+ contentHash?: string,
196
+ ): Promise<string | null> {
197
+ const cache = await getModulePathCache(cacheDir);
198
+ const cacheKey = toMdxEsmCacheKey(filePath, projectDir);
199
+
200
+ const cachedPath = cache.get(cacheKey);
201
+ if (!cachedPath) {
202
+ return null;
203
+ }
204
+
205
+ // Verify the cached file still exists
206
+ try {
207
+ const stat = await getLocalFs().stat(cachedPath);
208
+ if (!stat?.isFile) {
209
+ cache.delete(cacheKey);
210
+ return null;
211
+ }
212
+
213
+ // If contentHash provided, validate the cached file contains matching hash
214
+ // The cached filename includes the content hash (e.g., module.abc123.js)
215
+ if (contentHash) {
216
+ const filename = cachedPath.split("/").pop() ?? "";
217
+ if (!filename.includes(contentHash.slice(0, 8))) {
218
+ logger.debug(
219
+ `${LOG_PREFIX_MDX_LOADER} Cache hash mismatch, invalidating: ${filePath}`,
220
+ );
221
+ cache.delete(cacheKey);
222
+ return null;
223
+ }
224
+ }
225
+
226
+ logger.debug(
227
+ `${LOG_PREFIX_MDX_LOADER} SSR reusing MDX-ESM cache: ${filePath} -> ${cachedPath}`,
228
+ );
229
+ return cachedPath;
230
+ } catch {
231
+ // File no longer exists, remove stale entry
232
+ cache.delete(cacheKey);
233
+ }
234
+
235
+ return null;
236
+ }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { join } from "../../../../deps/deno.land/std@0.220.0/path/mod.js";
11
- import React from "react";
11
+ import React from "../../../../deps/esm.sh/react@19.1.1.js";
12
12
  import { rendererLogger as logger } from "../../../utils/index.js";
13
13
  import { withSpan } from "../../../observability/tracing/otlp-setup.js";
14
14
  import { SpanNames } from "../../../observability/tracing/span-names.js";
@@ -201,6 +201,7 @@ async function processVfModuleImports(
201
201
  adapter,
202
202
  projectDir,
203
203
  context.projectId,
204
+ { reactVersion: context.reactVersion },
204
205
  );
205
206
 
206
207
  const fetchStart = performance.now();
@@ -568,6 +568,7 @@ async function doFetchAndCacheModule(
568
568
  projectId,
569
569
  dev: true,
570
570
  ssr: true,
571
+ reactVersion: context.reactVersion,
571
572
  });
572
573
  } catch (transformError) {
573
574
  logger.error(`${LOG_PREFIX_MDX_LOADER} Transform failed for module`, {
@@ -685,7 +686,7 @@ export function createModuleFetcherContext(
685
686
  adapter: RuntimeAdapter,
686
687
  projectDir: string,
687
688
  projectId: string,
688
- options?: { isLocalDev?: boolean; projectSlug?: string },
689
+ options?: { isLocalDev?: boolean; projectSlug?: string; reactVersion?: string },
689
690
  ): ModuleFetcherContext {
690
691
  return {
691
692
  esmCacheDir,
@@ -10,6 +10,8 @@ export interface ESMLoaderContext {
10
10
  projectDir?: string;
11
11
  projectSlug?: string;
12
12
  contentSourceId?: string;
13
+ /** React version for transforms (from project config) */
14
+ reactVersion?: string;
13
15
  }
14
16
 
15
17
  export interface FSAdapter {
@@ -51,6 +53,8 @@ export interface ModuleFetcherContext {
51
53
  * This prevents infinite recursion when A imports B which imports A.
52
54
  */
53
55
  inFlightModules?: Map<string, Promise<string | null>>;
56
+ /** React version for transforms (from project config) */
57
+ reactVersion?: string;
54
58
  }
55
59
 
56
60
  export interface JSXTransform {
@@ -1,7 +1,7 @@
1
1
  import { rendererLogger as logger } from "../../utils/index.js";
2
2
  import { LRUCache } from "../../utils/lru-wrapper.js";
3
3
  import { MDX_RENDERER_MAX_ENTRIES, MDX_RENDERER_TTL_MS } from "../../utils/constants/cache.js";
4
- import React from "react";
4
+ import React from "../../../deps/esm.sh/react@19.1.1.js";
5
5
  import { type ESMLoaderContext, loadModuleESM } from "./esm-module-loader/index.js";
6
6
  import { type ParsedMDX, parseMDXCode } from "./parser.js";
7
7
  import type { MDXComponents, MDXFrontmatter, MDXGlobals, MDXModule } from "./types.js";