veryfront 0.1.128 → 0.1.129

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 (382) hide show
  1. package/esm/cli/router.d.ts +0 -5
  2. package/esm/cli/router.d.ts.map +1 -1
  3. package/esm/cli/router.js +30 -2
  4. package/esm/cli/shared/update-check.d.ts +4 -0
  5. package/esm/cli/shared/update-check.d.ts.map +1 -0
  6. package/esm/cli/shared/update-check.js +97 -0
  7. package/esm/deno.d.ts +5 -0
  8. package/esm/deno.js +13 -8
  9. package/esm/src/channels/control-plane.d.ts.map +1 -1
  10. package/esm/src/channels/control-plane.js +5 -5
  11. package/esm/src/channels/invoke.d.ts +1 -1
  12. package/esm/src/channels/invoke.d.ts.map +1 -1
  13. package/esm/src/channels/invoke.js +6 -6
  14. package/esm/src/chat/index.d.ts +12 -24
  15. package/esm/src/chat/index.d.ts.map +1 -1
  16. package/esm/src/chat/index.js +5 -25
  17. package/esm/src/config/env.d.ts.map +1 -1
  18. package/esm/src/config/env.js +18 -10
  19. package/esm/src/data/static-data-fetcher.d.ts +3 -0
  20. package/esm/src/data/static-data-fetcher.d.ts.map +1 -1
  21. package/esm/src/data/static-data-fetcher.js +29 -25
  22. package/esm/src/data/static-paths-fetcher.d.ts.map +1 -1
  23. package/esm/src/data/static-paths-fetcher.js +3 -2
  24. package/esm/src/errors/logging.d.ts.map +1 -1
  25. package/esm/src/errors/logging.js +16 -7
  26. package/esm/src/errors/user-friendly/error-formatter.d.ts.map +1 -1
  27. package/esm/src/errors/user-friendly/error-formatter.js +9 -25
  28. package/esm/src/fs/index.d.ts +11 -12
  29. package/esm/src/fs/index.d.ts.map +1 -1
  30. package/esm/src/fs/index.js +11 -24
  31. package/esm/src/html/dev-scripts.d.ts.map +1 -1
  32. package/esm/src/html/dev-scripts.js +5 -8
  33. package/esm/src/html/html-escape.d.ts +1 -0
  34. package/esm/src/html/html-escape.d.ts.map +1 -1
  35. package/esm/src/html/html-escape.js +3 -0
  36. package/esm/src/html/html-injection.js +2 -2
  37. package/esm/src/html/html-shell-generator.d.ts +5 -2
  38. package/esm/src/html/html-shell-generator.d.ts.map +1 -1
  39. package/esm/src/html/html-shell-generator.js +41 -30
  40. package/esm/src/html/hydration-script-builder/dev-client-renderer.js +2 -2
  41. package/esm/src/html/hydration-script-builder/dev-component-manifest.js +2 -2
  42. package/esm/src/html/hydration-script-builder/dev-error-logger.d.ts.map +1 -1
  43. package/esm/src/html/hydration-script-builder/dev-error-logger.js +2 -6
  44. package/esm/src/html/hydration-script-builder/dev-scripts.js +2 -2
  45. package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts +3 -1
  46. package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
  47. package/esm/src/html/hydration-script-builder/hydration-data-generator.js +2 -2
  48. package/esm/src/html/hydration-script-builder/index.d.ts +1 -1
  49. package/esm/src/html/hydration-script-builder/index.d.ts.map +1 -1
  50. package/esm/src/html/hydration-script-builder/index.js +1 -1
  51. package/esm/src/html/hydration-script-builder/prod-hydration.js +2 -2
  52. package/esm/src/html/hydration-script-builder/prod-scripts.d.ts +2 -0
  53. package/esm/src/html/hydration-script-builder/prod-scripts.d.ts.map +1 -1
  54. package/esm/src/html/hydration-script-builder/prod-scripts.js +14 -14
  55. package/esm/src/html/schemas/html.schema.d.ts +2 -0
  56. package/esm/src/html/schemas/html.schema.d.ts.map +1 -1
  57. package/esm/src/html/schemas/html.schema.js +2 -0
  58. package/esm/src/html/styles-builder/css-pregeneration.d.ts +17 -1
  59. package/esm/src/html/styles-builder/css-pregeneration.d.ts.map +1 -1
  60. package/esm/src/html/styles-builder/css-pregeneration.js +103 -1
  61. package/esm/src/html/styles-builder/dev-styles.js +2 -2
  62. package/esm/src/html/utils.d.ts +2 -0
  63. package/esm/src/html/utils.d.ts.map +1 -1
  64. package/esm/src/html/utils.js +49 -28
  65. package/esm/src/integrations/remote-tools.d.ts.map +1 -1
  66. package/esm/src/integrations/remote-tools.js +32 -39
  67. package/esm/src/internal-agents/ag-ui-sse.d.ts +0 -1
  68. package/esm/src/internal-agents/ag-ui-sse.d.ts.map +1 -1
  69. package/esm/src/internal-agents/ag-ui-sse.js +2 -16
  70. package/esm/src/internal-agents/control-plane-auth.d.ts.map +1 -1
  71. package/esm/src/internal-agents/control-plane-auth.js +5 -3
  72. package/esm/src/internal-agents/request-body.d.ts.map +1 -1
  73. package/esm/src/internal-agents/request-body.js +6 -3
  74. package/esm/src/internal-agents/session-manager.d.ts +1 -0
  75. package/esm/src/internal-agents/session-manager.d.ts.map +1 -1
  76. package/esm/src/internal-agents/session-manager.js +12 -18
  77. package/esm/src/issues/core.d.ts.map +1 -1
  78. package/esm/src/issues/core.js +24 -23
  79. package/esm/src/issues/schemas/issue.schema.d.ts.map +1 -1
  80. package/esm/src/issues/schemas/issue.schema.js +2 -1
  81. package/esm/src/jobs/runtime-env.d.ts.map +1 -1
  82. package/esm/src/jobs/runtime-env.js +21 -44
  83. package/esm/src/markdown/index.d.ts +1 -2
  84. package/esm/src/markdown/index.d.ts.map +1 -1
  85. package/esm/src/markdown/index.js +1 -6
  86. package/esm/src/mcp/server.d.ts +0 -1
  87. package/esm/src/mcp/server.d.ts.map +1 -1
  88. package/esm/src/mcp/server.js +40 -41
  89. package/esm/src/mdx/index.d.ts +3 -2
  90. package/esm/src/mdx/index.d.ts.map +1 -1
  91. package/esm/src/mdx/index.js +3 -5
  92. package/esm/src/middleware/builtin/logger.d.ts.map +1 -1
  93. package/esm/src/middleware/builtin/logger.js +31 -28
  94. package/esm/src/middleware/builtin/security/rate-limit.d.ts.map +1 -1
  95. package/esm/src/middleware/builtin/security/rate-limit.js +17 -12
  96. package/esm/src/middleware/builtin/timeout.d.ts.map +1 -1
  97. package/esm/src/middleware/builtin/timeout.js +17 -10
  98. package/esm/src/modules/import-map/default-import-map.d.ts.map +1 -1
  99. package/esm/src/modules/import-map/default-import-map.js +4 -3
  100. package/esm/src/oauth/handlers/callback-handler.d.ts +0 -5
  101. package/esm/src/oauth/handlers/callback-handler.d.ts.map +1 -1
  102. package/esm/src/oauth/handlers/callback-handler.js +9 -14
  103. package/esm/src/oauth/handlers/index.d.ts +1 -1
  104. package/esm/src/oauth/handlers/index.js +1 -1
  105. package/esm/src/oauth/handlers/init-handler.d.ts.map +1 -1
  106. package/esm/src/oauth/handlers/init-handler.js +32 -20
  107. package/esm/src/oauth/providers/index.d.ts +1 -1
  108. package/esm/src/oauth/providers/index.js +1 -1
  109. package/esm/src/oauth/schemas/index.d.ts +1 -1
  110. package/esm/src/oauth/schemas/index.js +1 -1
  111. package/esm/src/oauth/token-store/index.d.ts +1 -1
  112. package/esm/src/oauth/token-store/index.js +1 -1
  113. package/esm/src/oauth/token-store/memory.d.ts +1 -1
  114. package/esm/src/oauth/token-store/memory.d.ts.map +1 -1
  115. package/esm/src/oauth/token-store/memory.js +8 -8
  116. package/esm/src/observability/request-profiler.d.ts +31 -0
  117. package/esm/src/observability/request-profiler.d.ts.map +1 -0
  118. package/esm/src/observability/request-profiler.js +94 -0
  119. package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
  120. package/esm/src/observability/tracing/otlp-setup.js +16 -21
  121. package/esm/src/prompt/factory.d.ts.map +1 -1
  122. package/esm/src/prompt/factory.js +10 -12
  123. package/esm/src/prompt/registry.d.ts.map +1 -1
  124. package/esm/src/prompt/registry.js +12 -10
  125. package/esm/src/prompt/schemas/prompt.schema.d.ts.map +1 -1
  126. package/esm/src/prompt/schemas/prompt.schema.js +0 -2
  127. package/esm/src/prompt/types.d.ts +1 -1
  128. package/esm/src/prompt/types.d.ts.map +1 -1
  129. package/esm/src/provider/local/ai-sdk-adapter.d.ts.map +1 -1
  130. package/esm/src/provider/local/ai-sdk-adapter.js +3 -8
  131. package/esm/src/provider/local/env.d.ts +4 -6
  132. package/esm/src/provider/local/env.d.ts.map +1 -1
  133. package/esm/src/provider/local/env.js +14 -1
  134. package/esm/src/provider/local/local-engine.d.ts.map +1 -1
  135. package/esm/src/provider/local/local-engine.js +2 -7
  136. package/esm/src/provider/model-registry.d.ts.map +1 -1
  137. package/esm/src/provider/model-registry.js +2 -7
  138. package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
  139. package/esm/src/provider/veryfront-cloud/provider.js +1 -7
  140. package/esm/src/provider/veryfront-cloud/shared.d.ts.map +1 -1
  141. package/esm/src/provider/veryfront-cloud/shared.js +9 -11
  142. package/esm/src/proxy/handler.d.ts.map +1 -1
  143. package/esm/src/proxy/handler.js +56 -57
  144. package/esm/src/react/compat/hooks-adapter.d.ts +1 -7
  145. package/esm/src/react/compat/hooks-adapter.d.ts.map +1 -1
  146. package/esm/src/react/compat/hooks-adapter.js +35 -40
  147. package/esm/src/react/components/Head.d.ts +1 -26
  148. package/esm/src/react/components/Head.d.ts.map +1 -1
  149. package/esm/src/react/components/Head.js +1 -172
  150. package/esm/src/react/context/index.d.ts +2 -46
  151. package/esm/src/react/context/index.d.ts.map +1 -1
  152. package/esm/src/react/context/index.js +1 -44
  153. package/esm/src/react/head-collector.d.ts +1 -10
  154. package/esm/src/react/head-collector.d.ts.map +1 -1
  155. package/esm/src/react/head-collector.js +4 -0
  156. package/esm/src/react/router/index.d.ts +2 -45
  157. package/esm/src/react/router/index.d.ts.map +1 -1
  158. package/esm/src/react/router/index.js +1 -49
  159. package/esm/src/react/runtime/core.d.ts +49 -0
  160. package/esm/src/react/runtime/core.d.ts.map +1 -0
  161. package/esm/src/react/runtime/core.js +200 -0
  162. package/esm/src/rendering/orchestrator/html.d.ts +2 -0
  163. package/esm/src/rendering/orchestrator/html.d.ts.map +1 -1
  164. package/esm/src/rendering/orchestrator/html.js +69 -12
  165. package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts.map +1 -1
  166. package/esm/src/rendering/orchestrator/ssr-orchestrator.js +4 -0
  167. package/esm/src/rendering/orchestrator/types.d.ts +4 -0
  168. package/esm/src/rendering/orchestrator/types.d.ts.map +1 -1
  169. package/esm/src/repositories/types.d.ts.map +1 -1
  170. package/esm/src/resource/factory.d.ts.map +1 -1
  171. package/esm/src/resource/factory.js +12 -9
  172. package/esm/src/resource/registry.d.ts +3 -3
  173. package/esm/src/resource/registry.d.ts.map +1 -1
  174. package/esm/src/resource/registry.js +7 -7
  175. package/esm/src/schemas/common.d.ts.map +1 -1
  176. package/esm/src/schemas/common.js +7 -4
  177. package/esm/src/security/http/config.d.ts +0 -1
  178. package/esm/src/security/http/config.d.ts.map +1 -1
  179. package/esm/src/security/http/config.js +3 -16
  180. package/esm/src/security/http/response/security-handler.d.ts +1 -0
  181. package/esm/src/security/http/response/security-handler.d.ts.map +1 -1
  182. package/esm/src/security/http/response/security-handler.js +17 -12
  183. package/esm/src/security/index.d.ts +4 -2
  184. package/esm/src/security/index.d.ts.map +1 -1
  185. package/esm/src/security/index.js +3 -1
  186. package/esm/src/server/handlers/dev/styles-css.handler.d.ts.map +1 -1
  187. package/esm/src/server/handlers/dev/styles-css.handler.js +8 -7
  188. package/esm/src/server/handlers/monitoring/metrics.handler.d.ts.map +1 -1
  189. package/esm/src/server/handlers/monitoring/metrics.handler.js +3 -1
  190. package/esm/src/server/handlers/request/module/module-server-handler.d.ts.map +1 -1
  191. package/esm/src/server/handlers/request/module/module-server-handler.js +18 -15
  192. package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts +8 -0
  193. package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts.map +1 -0
  194. package/esm/src/server/handlers/request/prod-hydration-module.handler.js +41 -0
  195. package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
  196. package/esm/src/server/handlers/request/ssr/ssr.handler.js +3 -0
  197. package/esm/src/server/production-server.d.ts.map +1 -1
  198. package/esm/src/server/production-server.js +65 -0
  199. package/esm/src/server/runtime-handler/handler-context-builder.d.ts +1 -1
  200. package/esm/src/server/runtime-handler/handler-context-builder.d.ts.map +1 -1
  201. package/esm/src/server/runtime-handler/index.d.ts +1 -1
  202. package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
  203. package/esm/src/server/runtime-handler/index.js +36 -11
  204. package/esm/src/server/runtime-handler/request-utils.d.ts +7 -0
  205. package/esm/src/server/runtime-handler/request-utils.d.ts.map +1 -1
  206. package/esm/src/server/runtime-handler/request-utils.js +10 -0
  207. package/esm/src/server/services/rendering/ssr.service.d.ts +1 -0
  208. package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
  209. package/esm/src/server/services/rendering/ssr.service.js +12 -5
  210. package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
  211. package/esm/src/skill/allowed-tools.d.ts +3 -8
  212. package/esm/src/skill/allowed-tools.d.ts.map +1 -1
  213. package/esm/src/skill/executor.js +2 -2
  214. package/esm/src/skill/parser.d.ts.map +1 -1
  215. package/esm/src/skill/parser.js +12 -12
  216. package/esm/src/skill/path-safety.js +1 -1
  217. package/esm/src/skill/tools.d.ts.map +1 -1
  218. package/esm/src/skill/tools.js +18 -11
  219. package/esm/src/studio/bridge/bridge-bundle.generated.d.ts.map +1 -1
  220. package/esm/src/studio/bridge/bridge-bundle.generated.js +1 -1
  221. package/esm/src/task/discovery.d.ts.map +1 -1
  222. package/esm/src/task/discovery.js +73 -95
  223. package/esm/src/tool/executor.d.ts.map +1 -1
  224. package/esm/src/tool/executor.js +8 -7
  225. package/esm/src/tool/factory.d.ts.map +1 -1
  226. package/esm/src/tool/factory.js +13 -16
  227. package/esm/src/transforms/esm/package-registry.d.ts +4 -0
  228. package/esm/src/transforms/esm/package-registry.d.ts.map +1 -1
  229. package/esm/src/transforms/esm/package-registry.js +34 -17
  230. package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.d.ts.map +1 -1
  231. package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.js +2 -1
  232. package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts.map +1 -1
  233. package/esm/src/transforms/mdx/esm-module-loader/cache-format.js +26 -1
  234. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -1
  235. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
  236. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -1
  237. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts +1 -0
  238. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts.map +1 -1
  239. package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.js +3 -0
  240. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.d.ts +1 -1
  241. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.js +1 -1
  242. package/esm/src/transforms/veryfront-module-urls.d.ts.map +1 -1
  243. package/esm/src/transforms/veryfront-module-urls.js +7 -3
  244. package/esm/src/types/entities/getEntityInfo.d.ts.map +1 -1
  245. package/esm/src/types/entities/getEntityInfo.js +79 -127
  246. package/esm/src/utils/path-utils.d.ts +1 -1
  247. package/esm/src/utils/path-utils.d.ts.map +1 -1
  248. package/esm/src/utils/path-utils.js +16 -7
  249. package/esm/src/utils/version-constant.d.ts +1 -1
  250. package/esm/src/utils/version-constant.js +1 -1
  251. package/esm/src/utils/version.d.ts.map +1 -1
  252. package/esm/src/utils/version.js +0 -1
  253. package/esm/src/workflow/worker/dynamic-job-entrypoint.d.ts.map +1 -1
  254. package/esm/src/workflow/worker/dynamic-job-entrypoint.js +5 -72
  255. package/esm/src/workflow/worker/job-entrypoint.d.ts.map +1 -1
  256. package/esm/src/workflow/worker/job-entrypoint.js +5 -72
  257. package/esm/src/workflow/worker/shared.d.ts +18 -0
  258. package/esm/src/workflow/worker/shared.d.ts.map +1 -0
  259. package/esm/src/workflow/worker/shared.js +77 -0
  260. package/package.json +1 -1
  261. package/src/cli/router.ts +41 -2
  262. package/src/cli/shared/update-check.ts +110 -0
  263. package/src/deno.js +13 -8
  264. package/src/src/channels/control-plane.ts +6 -10
  265. package/src/src/channels/invoke.ts +7 -7
  266. package/src/src/chat/index.ts +96 -132
  267. package/src/src/config/env.ts +24 -11
  268. package/src/src/data/static-data-fetcher.ts +59 -34
  269. package/src/src/data/static-paths-fetcher.ts +4 -2
  270. package/src/src/errors/logging.ts +21 -7
  271. package/src/src/errors/user-friendly/error-formatter.ts +14 -29
  272. package/src/src/fs/index.ts +21 -30
  273. package/src/src/html/dev-scripts.ts +5 -9
  274. package/src/src/html/html-escape.ts +4 -0
  275. package/src/src/html/html-injection.ts +2 -2
  276. package/src/src/html/html-shell-generator.ts +60 -26
  277. package/src/src/html/hydration-script-builder/dev-client-renderer.ts +2 -2
  278. package/src/src/html/hydration-script-builder/dev-component-manifest.ts +2 -2
  279. package/src/src/html/hydration-script-builder/dev-error-logger.ts +2 -8
  280. package/src/src/html/hydration-script-builder/dev-scripts.ts +2 -2
  281. package/src/src/html/hydration-script-builder/hydration-data-generator.ts +2 -1
  282. package/src/src/html/hydration-script-builder/index.ts +5 -1
  283. package/src/src/html/hydration-script-builder/prod-hydration.ts +2 -2
  284. package/src/src/html/hydration-script-builder/prod-scripts.ts +16 -15
  285. package/src/src/html/schemas/html.schema.ts +2 -0
  286. package/src/src/html/styles-builder/css-pregeneration.ts +133 -1
  287. package/src/src/html/styles-builder/dev-styles.ts +2 -2
  288. package/src/src/html/utils.ts +62 -29
  289. package/src/src/integrations/remote-tools.ts +39 -37
  290. package/src/src/internal-agents/ag-ui-sse.ts +2 -17
  291. package/src/src/internal-agents/control-plane-auth.ts +8 -6
  292. package/src/src/internal-agents/request-body.ts +7 -5
  293. package/src/src/internal-agents/session-manager.ts +16 -20
  294. package/src/src/issues/core.ts +24 -27
  295. package/src/src/issues/schemas/issue.schema.ts +3 -1
  296. package/src/src/jobs/runtime-env.ts +24 -50
  297. package/src/src/markdown/index.ts +5 -8
  298. package/src/src/mcp/server.ts +50 -53
  299. package/src/src/mdx/index.ts +7 -8
  300. package/src/src/middleware/builtin/logger.ts +44 -29
  301. package/src/src/middleware/builtin/security/rate-limit.ts +20 -11
  302. package/src/src/middleware/builtin/timeout.ts +22 -13
  303. package/src/src/modules/import-map/default-import-map.ts +4 -3
  304. package/src/src/oauth/handlers/callback-handler.ts +9 -16
  305. package/src/src/oauth/handlers/index.ts +1 -1
  306. package/src/src/oauth/handlers/init-handler.ts +56 -27
  307. package/src/src/oauth/providers/index.ts +1 -1
  308. package/src/src/oauth/schemas/index.ts +1 -1
  309. package/src/src/oauth/token-store/index.ts +1 -1
  310. package/src/src/oauth/token-store/memory.ts +8 -8
  311. package/src/src/observability/request-profiler.ts +140 -0
  312. package/src/src/observability/tracing/otlp-setup.ts +16 -22
  313. package/src/src/prompt/factory.ts +16 -14
  314. package/src/src/prompt/registry.ts +14 -13
  315. package/src/src/prompt/schemas/prompt.schema.ts +0 -4
  316. package/src/src/prompt/types.ts +1 -2
  317. package/src/src/provider/local/ai-sdk-adapter.ts +3 -10
  318. package/src/src/provider/local/env.ts +22 -2
  319. package/src/src/provider/local/local-engine.ts +2 -9
  320. package/src/src/provider/model-registry.ts +2 -9
  321. package/src/src/provider/veryfront-cloud/provider.ts +1 -8
  322. package/src/src/provider/veryfront-cloud/shared.ts +12 -15
  323. package/src/src/proxy/handler.ts +90 -74
  324. package/src/src/react/compat/hooks-adapter.ts +43 -44
  325. package/src/src/react/components/Head.tsx +1 -181
  326. package/src/src/react/context/index.tsx +2 -83
  327. package/src/src/react/head-collector.ts +9 -0
  328. package/src/src/react/router/index.tsx +2 -100
  329. package/src/src/react/runtime/core.ts +303 -0
  330. package/src/src/rendering/orchestrator/html.ts +122 -18
  331. package/src/src/rendering/orchestrator/ssr-orchestrator.ts +8 -0
  332. package/src/src/rendering/orchestrator/types.ts +4 -0
  333. package/src/src/repositories/types.ts +0 -4
  334. package/src/src/resource/factory.ts +15 -11
  335. package/src/src/resource/registry.ts +7 -7
  336. package/src/src/schemas/common.ts +8 -5
  337. package/src/src/security/http/config.ts +3 -19
  338. package/src/src/security/http/response/security-handler.ts +22 -13
  339. package/src/src/security/index.ts +4 -7
  340. package/src/src/server/handlers/dev/styles-css.handler.ts +32 -14
  341. package/src/src/server/handlers/monitoring/metrics.handler.ts +3 -1
  342. package/src/src/server/handlers/request/module/module-server-handler.ts +24 -17
  343. package/src/src/server/handlers/request/prod-hydration-module.handler.ts +61 -0
  344. package/src/src/server/handlers/request/ssr/ssr.handler.ts +3 -0
  345. package/src/src/server/production-server.ts +84 -0
  346. package/src/src/server/runtime-handler/handler-context-builder.ts +1 -1
  347. package/src/src/server/runtime-handler/index.ts +44 -13
  348. package/src/src/server/runtime-handler/request-utils.ts +11 -0
  349. package/src/src/server/services/rendering/ssr.service.ts +31 -18
  350. package/src/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +1 -1
  351. package/src/src/skill/allowed-tools.ts +1 -8
  352. package/src/src/skill/executor.ts +2 -2
  353. package/src/src/skill/parser.ts +13 -20
  354. package/src/src/skill/path-safety.ts +1 -1
  355. package/src/src/skill/tools.ts +27 -20
  356. package/src/src/studio/bridge/bridge-bundle.generated.ts +1 -1
  357. package/src/src/task/discovery.ts +97 -97
  358. package/src/src/tool/executor.ts +10 -8
  359. package/src/src/tool/factory.ts +21 -22
  360. package/src/src/tool/types.ts +0 -17
  361. package/src/src/transforms/esm/package-registry.ts +52 -20
  362. package/src/src/transforms/import-rewriter/strategies/veryfront-strategy.ts +2 -1
  363. package/src/src/transforms/mdx/esm-module-loader/cache-format.ts +34 -1
  364. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +1 -1
  365. package/src/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.ts +4 -0
  366. package/src/src/transforms/pipeline/stages/ssr-vf-modules/index.ts +1 -1
  367. package/src/src/transforms/veryfront-module-urls.ts +6 -2
  368. package/src/src/types/entities/getEntityInfo.ts +131 -152
  369. package/src/src/utils/path-utils.ts +16 -7
  370. package/src/src/utils/version-constant.ts +1 -1
  371. package/src/src/utils/version.ts +0 -1
  372. package/src/src/workflow/worker/dynamic-job-entrypoint.ts +18 -84
  373. package/src/src/workflow/worker/job-entrypoint.ts +18 -85
  374. package/src/src/workflow/worker/shared.ts +127 -0
  375. package/esm/src/prompt/schemas/index.d.ts +0 -7
  376. package/esm/src/prompt/schemas/index.d.ts.map +0 -1
  377. package/esm/src/prompt/schemas/index.js +0 -6
  378. package/esm/src/security/http/handlers-index.d.ts +0 -5
  379. package/esm/src/security/http/handlers-index.d.ts.map +0 -1
  380. package/esm/src/security/http/handlers-index.js +0 -3
  381. package/src/src/prompt/schemas/index.ts +0 -7
  382. package/src/src/security/http/handlers-index.ts +0 -4
@@ -22,6 +22,24 @@ export interface ErrorLogEntry {
22
22
  context?: Record<string, unknown>;
23
23
  }
24
24
 
25
+ function toContextRecord(value: unknown): Record<string, unknown> | undefined {
26
+ return value && typeof value === "object" && !Array.isArray(value)
27
+ ? value as Record<string, unknown>
28
+ : undefined;
29
+ }
30
+
31
+ function mergeContext(
32
+ errorContext: unknown,
33
+ extraContext?: Record<string, unknown>,
34
+ ): Record<string, unknown> | undefined {
35
+ const baseContext = toContextRecord(errorContext);
36
+
37
+ if (!baseContext) return extraContext;
38
+ if (!extraContext) return baseContext;
39
+
40
+ return { ...baseContext, ...extraContext };
41
+ }
42
+
25
43
  /**
26
44
  * Log a VeryfrontError with structured formatting
27
45
  *
@@ -35,6 +53,7 @@ export function logError(
35
53
  error: VeryfrontError,
36
54
  context?: Record<string, unknown>,
37
55
  ): void {
56
+ const mergedContext = mergeContext(error.context, context);
38
57
  const entry: ErrorLogEntry = {
39
58
  level: "error",
40
59
  slug: error.slug,
@@ -43,11 +62,9 @@ export function logError(
43
62
  detail: error.detail,
44
63
  suggestion: error.suggestion,
45
64
  status: error.status,
46
- docs: `https://veryfront.com/docs/errors/${error.slug}`,
65
+ docs: error.getDocsUrl(),
47
66
  timestamp: new Date().toISOString(),
48
- context: context
49
- ? { ...(error.context as Record<string, unknown> ?? {}), ...context }
50
- : error.context as Record<string, unknown> | undefined,
67
+ context: mergedContext,
51
68
  };
52
69
 
53
70
  if (isProduction()) {
@@ -64,9 +81,6 @@ export function logError(
64
81
  serverLogger.error(` 💡 Suggestion: ${error.suggestion}`);
65
82
  }
66
83
  serverLogger.error(` 📚 Docs: ${entry.docs}`);
67
- const mergedContext = context
68
- ? { ...(error.context as Record<string, unknown> ?? {}), ...context }
69
- : error.context;
70
84
  if (mergedContext) {
71
85
  serverLogger.error(` Context: ${JSON.stringify(mergedContext, null, 2)}`);
72
86
  }
@@ -5,31 +5,30 @@ import { identifyError } from "./error-identifier.js";
5
5
 
6
6
  const errorColor = "\x1b[38;2;239;68;68m"; // Red
7
7
 
8
- function buildSolutionLines(solution: (typeof ERROR_SOLUTIONS)[string]): string[] {
8
+ function buildSolutionDetailsLines(
9
+ solution: (typeof ERROR_SOLUTIONS)[string],
10
+ options?: {
11
+ exampleLabel?: string;
12
+ },
13
+ ): string[] {
9
14
  const lines: string[] = [];
10
15
 
11
- if (solution.message) {
12
- lines.push(yellow("Problem: ") + solution.message, "");
13
- }
14
-
15
16
  if (solution.steps?.length) {
16
- lines.push(cyan("How to fix:"));
17
+ lines.push("", cyan("How to fix:"));
17
18
  for (const [i, step] of solution.steps.entries()) {
18
19
  lines.push(` ${dim(`${i + 1}.`)} ${step}`);
19
20
  }
20
- lines.push("");
21
21
  }
22
22
 
23
23
  if (solution.example) {
24
- lines.push(cyan("Example:"), "");
24
+ lines.push("", options?.exampleLabel ?? cyan("Example:"));
25
25
  for (const line of solution.example.split("\n")) {
26
26
  lines.push(` ${dim(line)}`);
27
27
  }
28
- lines.push("");
29
28
  }
30
29
 
31
30
  if (solution.docs) {
32
- lines.push(dim("Learn more: ") + cyan(solution.docs), "");
31
+ lines.push("", dim("Learn more: ") + cyan(solution.docs));
33
32
  }
34
33
 
35
34
  return lines;
@@ -50,24 +49,7 @@ export function formatErrorBox(error: Error): string {
50
49
  if (solution.message) {
51
50
  content.push("", dim(solution.message));
52
51
  }
53
-
54
- if (solution.steps?.length) {
55
- content.push("", cyan("How to fix:"));
56
- for (const [i, step] of solution.steps.entries()) {
57
- content.push(` ${dim(`${i + 1}.`)} ${step}`);
58
- }
59
- }
60
-
61
- if (solution.example) {
62
- content.push("", dim("Example:"));
63
- for (const line of solution.example.split("\n")) {
64
- content.push(` ${dim(line)}`);
65
- }
66
- }
67
-
68
- if (solution.docs) {
69
- content.push("", dim("Learn more: ") + cyan(solution.docs));
70
- }
52
+ content.push(...buildSolutionDetailsLines(solution, { exampleLabel: dim("Example:") }));
71
53
  }
72
54
 
73
55
  return box(content.join("\n"), {
@@ -90,7 +72,10 @@ export function formatUserError(error: Error): string {
90
72
  const solution = ERROR_SOLUTIONS[errorKey];
91
73
 
92
74
  if (solution) {
93
- output.push(...buildSolutionLines(solution));
75
+ if (solution.message) {
76
+ output.push(yellow("Problem: ") + solution.message);
77
+ }
78
+ output.push(...buildSolutionDetailsLines(solution), "");
94
79
  return output.join("\n");
95
80
  }
96
81
 
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Filesystem operations and path utilities.
2
+ * Public filesystem, path, and cwd utilities.
3
3
  *
4
4
  * @module fs
5
5
  *
6
6
  * @example File operations
7
7
  * ```ts
8
- * import { readTextFile, writeTextFile, mkdir, exists } from "veryfront/fs";
8
+ * import { exists, mkdir, readTextFile, writeTextFile } from "veryfront/fs";
9
9
  *
10
10
  * const content = await readTextFile("./data/config.json");
11
11
  * await writeTextFile("./output/result.json", JSON.stringify(data));
@@ -19,42 +19,33 @@
19
19
  * const filePath = join("src", "pages", "index.tsx");
20
20
  * const dir = dirname(filePath); // "src/pages"
21
21
  * ```
22
+ *
23
+ * @example Working directory
24
+ * ```ts
25
+ * import { cwd, resolve } from "veryfront/fs";
26
+ *
27
+ * const configPath = resolve(cwd(), "veryfront.config.ts");
28
+ * ```
22
29
  */
23
-
24
- // veryfront/fs — Filesystem operations + path utilities
25
- //
26
- // Slim public surface for file I/O, path manipulation, and
27
- // project context (cwd). Re-exports from the platform compat layer.
28
-
29
- // ---------------------------------------------------------------------------
30
- // Filesystem
31
- // ---------------------------------------------------------------------------
32
30
  import "../../_dnt.polyfills.js";
33
31
 
34
32
 
35
- export { createFileSystem } from "../platform/compat/fs.js";
36
- export { readTextFile } from "../platform/compat/fs.js";
37
- export { writeTextFile } from "../platform/compat/fs.js";
38
- export { mkdir } from "../platform/compat/fs.js";
39
- export { exists } from "../platform/compat/fs.js";
40
- export { remove } from "../platform/compat/fs.js";
41
- export { readDir } from "../platform/compat/fs.js";
42
- export type { FileSystem } from "../platform/compat/fs.js";
43
-
44
- // ---------------------------------------------------------------------------
45
- // Path utilities
46
- // ---------------------------------------------------------------------------
47
-
33
+ export {
34
+ createFileSystem,
35
+ exists,
36
+ type FileSystem,
37
+ mkdir,
38
+ readDir,
39
+ readTextFile,
40
+ remove,
41
+ writeTextFile,
42
+ } from "../platform/compat/fs.js";
48
43
  export {
49
44
  basename,
50
45
  dirname,
51
46
  extname,
52
47
  join,
53
- } from "../platform/compat/path/basic-operations.js";
54
- export { resolve } from "../platform/compat/path/resolution.js";
55
-
56
- // ---------------------------------------------------------------------------
57
- // Project context
58
- // ---------------------------------------------------------------------------
48
+ resolve,
49
+ } from "../platform/compat/path/index.js";
59
50
 
60
51
  export { cwd } from "../platform/compat/process.js";
@@ -1,11 +1,11 @@
1
- import { escapeHtml } from "./html-escape.js";
1
+ import { buildNonceAttribute } from "./html-escape.js";
2
2
 
3
3
  export function getPreviewStylesheetLink(): string {
4
4
  return `<link id="vf-tailwind-css" rel="stylesheet" href="/_vf_styles/styles.css?t=${Date.now()}">`;
5
5
  }
6
6
 
7
7
  export function getDevStyles(nonce?: string): string {
8
- const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
8
+ const nonceAttr = buildNonceAttribute(nonce);
9
9
 
10
10
  return `
11
11
  <style${nonceAttr}>
@@ -37,12 +37,8 @@ export function getDevStyles(nonce?: string): string {
37
37
  </style>`;
38
38
  }
39
39
 
40
- function getNonceAttr(nonce?: string): string {
41
- return nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
42
- }
43
-
44
40
  export function getDevScripts(_hmrPort?: number, nonce?: string): string {
45
- const nonceAttr = getNonceAttr(nonce);
41
+ const nonceAttr = buildNonceAttribute(nonce);
46
42
 
47
43
  return `
48
44
  <script type="module" src="/_veryfront/rsc/client.js"${nonceAttr}></script>
@@ -50,7 +46,7 @@ export function getDevScripts(_hmrPort?: number, nonce?: string): string {
50
46
  }
51
47
 
52
48
  export function getProdScripts(slug: string, nonce?: string): string {
53
- const nonceAttr = getNonceAttr(nonce);
49
+ const nonceAttr = buildNonceAttribute(nonce);
54
50
  const encodedSlug = encodeURIComponent(slug);
55
51
 
56
52
  return `
@@ -72,7 +68,7 @@ interface StudioScriptOptions {
72
68
  }
73
69
 
74
70
  export function getStudioScripts(options: StudioScriptOptions): string {
75
- const nonceAttr = getNonceAttr(options.nonce);
71
+ const nonceAttr = buildNonceAttribute(options.nonce);
76
72
 
77
73
  const bridgeConfig: Record<string, unknown> = {
78
74
  projectId: options.projectId,
@@ -14,3 +14,7 @@ export function buildAttributes(attrs: Record<string, string>): string {
14
14
  .map(([key, value]) => `${key}="${escapeHTML(value)}"`)
15
15
  .join(" ");
16
16
  }
17
+
18
+ export function buildNonceAttribute(nonce?: string): string {
19
+ return nonce ? ` nonce="${escapeHTML(nonce)}"` : "";
20
+ }
@@ -7,7 +7,7 @@ import {
7
7
  generateScriptTags,
8
8
  generateStyleTags,
9
9
  } from "./tag-generators.js";
10
- import { escapeHtml } from "./html-escape.js";
10
+ import { buildNonceAttribute } from "./html-escape.js";
11
11
  import {
12
12
  getDevScripts,
13
13
  getDevStyles,
@@ -90,7 +90,7 @@ export function injectHTMLContent(
90
90
 
91
91
  // Inject import map into <head> for ESM module resolution (must be before any module scripts)
92
92
  if (options.importMapJson && /<\/head>/i.test(html)) {
93
- const nonceAttr = options.nonce ? ` nonce="${escapeHtml(options.nonce)}"` : "";
93
+ const nonceAttr = buildNonceAttribute(options.nonce);
94
94
  const importMapTag =
95
95
  `<script type="importmap"${nonceAttr}>\n${options.importMapJson}\n</script>`;
96
96
  html = html.replace(/<\/head>/i, `${importMapTag}\n</head>`);
@@ -2,21 +2,27 @@ import type { ComponentProps, RenderMetadata } from "../types/index.js";
2
2
  import { resolveRelativePath } from "../modules/react-loader/path-resolver.js";
3
3
  import { withSpan } from "../observability/tracing/otlp-setup.js";
4
4
  import { SpanNames } from "../observability/tracing/span-names.js";
5
+ import { profilePhase } from "../observability/request-profiler.js";
5
6
  import { serverLogger } from "../utils/logger/logger.js";
6
7
  import { isMarkdownPreview as checkMarkdownPreview } from "../transforms/md/utils.js";
7
8
  import {
8
9
  generateModulePreloadHintsFromManifest,
9
10
  getRouteManifest,
10
11
  } from "../modules/manifest/route-module-manifest.js";
11
- import { escapeHTML } from "./html-escape.js";
12
+ import { buildNonceAttribute, escapeHTML } from "./html-escape.js";
12
13
  import {
13
14
  generateHydrationData,
14
15
  getDevScripts,
15
16
  getProdScripts,
17
+ PROD_HYDRATION_MODULE_PATH,
16
18
  } from "./hydration-script-builder/index.js";
17
19
  import { getPreviewStylesheetLink, getStudioScripts } from "./dev-scripts.js";
18
20
  import { processMetadata } from "./metadata-builder.js";
19
- import { extractCandidates, getDevStyles, getProjectCSS } from "./styles-builder/index.js";
21
+ import {
22
+ extractCandidates,
23
+ getDevStyles as getErrorOverlayStyles,
24
+ getProjectCSS,
25
+ } from "./styles-builder/index.js";
20
26
  import type { HTMLGenerationOptions } from "./types.js";
21
27
  import { buildImportMapJson, buildRootAttributes, shouldDisableLayout } from "./utils.js";
22
28
 
@@ -43,6 +49,15 @@ function getRelativePagePath(
43
49
  return resolveRelativePath(normalized, projectDir);
44
50
  }
45
51
 
52
+ type ProjectCSSResult = Awaited<ReturnType<typeof getProjectCSS>> | null;
53
+
54
+ function resolveProjectCSSScope(
55
+ options: HTMLGenerationOptions,
56
+ metaSlug?: string,
57
+ ): string {
58
+ return options.projectSlug || options.projectId || metaSlug || "default";
59
+ }
60
+
46
61
  function generateModulePreloadHints(options: HTMLGenerationOptions): string {
47
62
  const hints: string[] = [];
48
63
  const addedUrls = new Set<string>();
@@ -75,7 +90,7 @@ function generateModulePreloadHints(options: HTMLGenerationOptions): string {
75
90
  return hints.join("\n ");
76
91
  }
77
92
 
78
- const projectSlug = options.projectId;
93
+ const projectSlug = options.projectSlug ?? options.projectId;
79
94
  const route = options.pagePath
80
95
  ? getRelativePagePath(options.pagePath, projectDir)
81
96
  .replace(/\.(tsx|ts|jsx|mdx)$/, "")
@@ -102,10 +117,19 @@ export function generateHTMLShellParts(
102
117
  params?: Record<string, string | string[]>,
103
118
  props?: ComponentProps,
104
119
  contentForTailwind?: string,
120
+ projectCSSPromise?: Promise<ProjectCSSResult>,
105
121
  ): Promise<{ start: string; end: string }> {
106
122
  return withSpan(
107
123
  SpanNames.HTML_GENERATE_SHELL_PARTS,
108
- () => generateHTMLShellPartsImpl(meta, options, params, props, contentForTailwind),
124
+ () =>
125
+ generateHTMLShellPartsImpl(
126
+ meta,
127
+ options,
128
+ params,
129
+ props,
130
+ contentForTailwind,
131
+ projectCSSPromise,
132
+ ),
109
133
  {
110
134
  "html.slug": meta.slug || "",
111
135
  "html.has_content": !!contentForTailwind,
@@ -121,6 +145,7 @@ async function generateHTMLShellPartsImpl(
121
145
  params?: Record<string, string | string[]>,
122
146
  props?: ComponentProps,
123
147
  contentForTailwind?: string,
148
+ prefetchedProjectCSSPromise?: Promise<ProjectCSSResult>,
124
149
  ): Promise<{ start: string; end: string }> {
125
150
  const stylesheetContent = options.globalCSS;
126
151
 
@@ -134,18 +159,15 @@ async function generateHTMLShellPartsImpl(
134
159
  for (const cls of extractCandidates(contentForTailwind)) candidates.add(cls);
135
160
  }
136
161
 
137
- const projectSlug = options.projectId || meta.slug || "default";
138
- let cssHash = "";
139
-
140
- // Only generate CSS for production mode (dev/preview uses link tag to StylesCSSHandler)
141
- if (useProductionCSS && projectSlug !== "default") {
142
- const projectCSS = await getProjectCSS(projectSlug, stylesheetContent, candidates, {
143
- minify: true,
144
- environment: options.environment,
145
- buildMode: options.mode,
146
- });
147
- cssHash = projectCSS.hash;
148
- }
162
+ const projectSlug = resolveProjectCSSScope(options, meta.slug);
163
+ const projectCSSPromise = prefetchedProjectCSSPromise ??
164
+ (useProductionCSS && projectSlug !== "default"
165
+ ? getProjectCSS(projectSlug, stylesheetContent, candidates, {
166
+ minify: true,
167
+ environment: options.environment,
168
+ buildMode: options.mode,
169
+ })
170
+ : Promise.resolve(null));
149
171
 
150
172
  const {
151
173
  effectiveTitle,
@@ -166,10 +188,18 @@ async function generateHTMLShellPartsImpl(
166
188
  meta.ssrHash,
167
189
  );
168
190
 
169
- const importMapJson = await buildImportMapJson({
191
+ const skipDevHMR = isPreviewMode || options.noHmr;
192
+ // Error logger endpoint only enabled in local dev (returns 404 in preview/prod)
193
+ const skipErrorLogger = isPreviewMode;
194
+ // Enable dev scripts for local dev OR preview mode (for HMR support in Studio),
195
+ // unless a caller explicitly forces production client scripts for fair benchmarking.
196
+ const useDevScripts = !options.forceProductionScripts && (isLocalProject || isPreviewMode);
197
+
198
+ const importMapJsonPromise = buildImportMapJson({
170
199
  projectDir: options.projectDir,
171
200
  config: options.config,
172
201
  customImports: options.importMap,
202
+ pretty: useDevScripts,
173
203
  });
174
204
 
175
205
  const hydrationDataJson = generateHydrationData(
@@ -177,16 +207,11 @@ async function generateHTMLShellPartsImpl(
177
207
  params ?? {},
178
208
  props ?? {},
179
209
  options,
210
+ { pretty: useDevScripts },
180
211
  );
181
212
 
182
213
  const nonce = options.nonce ?? "";
183
214
 
184
- const skipDevHMR = isPreviewMode || options.noHmr;
185
- // Error logger endpoint only enabled in local dev (returns 404 in preview/prod)
186
- const skipErrorLogger = isPreviewMode;
187
- // Enable dev scripts for local dev OR preview mode (for HMR support in Studio)
188
- const useDevScripts = isLocalProject || isPreviewMode;
189
-
190
215
  const modeScripts = useDevScripts
191
216
  ? getDevScripts(meta.slug || "", options.config, params, props, nonce, {
192
217
  skipDevHMR,
@@ -194,9 +219,10 @@ async function generateHTMLShellPartsImpl(
194
219
  })
195
220
  : getProdScripts(meta.slug || "", params, props, nonce);
196
221
 
197
- const modeStyles = useDevScripts ? getDevStyles(nonce) : "";
222
+ const modeStyles = useDevScripts ? getErrorOverlayStyles(nonce) : "";
198
223
 
199
224
  const modulePreloadHints = generateModulePreloadHints(options);
225
+ const importMapJson = await profilePhase("html.import_map", () => importMapJsonPromise);
200
226
 
201
227
  // Preload critical React dependencies to avoid waterfall delays.
202
228
  // jsx-runtime is discovered late (only when modules execute), adding ~500ms latency.
@@ -205,8 +231,11 @@ async function generateHTMLShellPartsImpl(
205
231
  const criticalDepsPreload = jsxRuntimeUrl
206
232
  ? `<link rel="modulepreload" href="${jsxRuntimeUrl}">`
207
233
  : "";
234
+ const prodHydrationModulePreload = useDevScripts
235
+ ? ""
236
+ : `<link rel="modulepreload" href="${PROD_HYDRATION_MODULE_PATH}">`;
208
237
 
209
- const nonceAttr = nonce ? ` nonce="${escapeHTML(nonce)}"` : "";
238
+ const nonceAttr = buildNonceAttribute(nonce);
210
239
 
211
240
  // Expose project slug for runtime error overlay "Fix in Veryfront" button
212
241
  const overlaySlug = options.projectId || meta.slug;
@@ -256,6 +285,8 @@ async function generateHTMLShellPartsImpl(
256
285
 
257
286
  let tailwindCSSBlock = "";
258
287
  if (useProductionCSS) {
288
+ const projectCSS = await profilePhase("html.project_css", () => projectCSSPromise);
289
+ const cssHash = projectCSS?.hash ?? "";
259
290
  if (cssHash) {
260
291
  tailwindCSSBlock = `<link rel="stylesheet" href="/_vf/css/${cssHash}.css">`;
261
292
  } else {
@@ -300,6 +331,7 @@ async function generateHTMLShellPartsImpl(
300
331
  <!-- Modulepreload hints for faster cold start -->
301
332
  ${modulePreloadHints}
302
333
  ${criticalDepsPreload}
334
+ ${prodHydrationModulePreload}
303
335
 
304
336
  <!-- Tailwind CSS: Server-side JIT compiled -->
305
337
  ${tailwindCSSBlock}
@@ -324,7 +356,7 @@ async function generateHTMLShellPartsImpl(
324
356
  })
325
357
  : "";
326
358
 
327
- const previewHMRScript = isPreviewMode
359
+ const previewHMRScript = isPreviewMode && !options.forceProductionScripts
328
360
  ? `<script src="/_veryfront/preview-hmr.js"${nonceAttr}></script>`
329
361
  : "";
330
362
 
@@ -371,6 +403,7 @@ export function wrapInHTMLShell(
371
403
  options: HTMLGenerationOptions,
372
404
  params?: Record<string, string | string[]>,
373
405
  props?: ComponentProps,
406
+ projectCSSPromise?: Promise<ProjectCSSResult>,
374
407
  ): Promise<string> {
375
408
  return withSpan(
376
409
  SpanNames.HTML_WRAP_IN_SHELL,
@@ -382,6 +415,7 @@ export function wrapInHTMLShell(
382
415
  params,
383
416
  props,
384
417
  cleanedContent,
418
+ projectCSSPromise,
385
419
  );
386
420
  return `${start}${cleanedContent}${end}`;
387
421
  },
@@ -1,8 +1,8 @@
1
1
  import { getLoaderScript, getRendererScript, getRouterScript } from "./templates/index.js";
2
- import { escapeHtml } from "../html-escape.js";
2
+ import { buildNonceAttribute } from "../html-escape.js";
3
3
 
4
4
  export function generateDevClientRendererScript(nonce?: string): string {
5
- const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
5
+ const nonceAttr = buildNonceAttribute(nonce);
6
6
 
7
7
  return `
8
8
  <script type="module"${nonceAttr}>
@@ -1,11 +1,11 @@
1
1
  import type { VeryfrontConfig } from "../../config/index.js";
2
- import { escapeHtml } from "../html-escape.js";
2
+ import { buildNonceAttribute } from "../html-escape.js";
3
3
 
4
4
  export function generateDevComponentManifestScript(
5
5
  config: VeryfrontConfig,
6
6
  nonce?: string,
7
7
  ): string {
8
- const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
8
+ const nonceAttr = buildNonceAttribute(nonce);
9
9
  const components = config.dev?.components ?? [];
10
10
 
11
11
  return `
@@ -1,15 +1,9 @@
1
- import { escapeHtml } from "../html-escape.js";
2
-
3
- function getOpenScriptTag(nonce?: string): string {
4
- return nonce ? `<script nonce="${escapeHtml(nonce)}">` : "<script>";
5
- }
1
+ import { buildNonceAttribute } from "../html-escape.js";
6
2
 
7
3
  export function generateDevErrorLoggerScript(nonce?: string): string {
8
- const openScriptTag = getOpenScriptTag(nonce);
9
-
10
4
  return `
11
5
  <!-- Client-side error logger -->
12
- ${openScriptTag}
6
+ <script${buildNonceAttribute(nonce)}>
13
7
  (function() {
14
8
  const logToServer = (level, message, details) => {
15
9
  try {
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps } from "../../types/index.js";
2
2
  import type { VeryfrontConfig } from "../../config/index.js";
3
- import { escapeHtml } from "../html-escape.js";
3
+ import { buildNonceAttribute } from "../html-escape.js";
4
4
  import { generateDevErrorLoggerScript } from "./dev-error-logger.js";
5
5
  import { generateDevComponentManifestScript } from "./dev-component-manifest.js";
6
6
  import { generateDevClientRendererScript } from "./dev-client-renderer.js";
@@ -13,7 +13,7 @@ function generateHMRScript(
13
13
  // Skip dev HMR script when preview-hmr.js will be used instead
14
14
  if (skipDevHMR || !config.dev?.hmr) return "";
15
15
 
16
- const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
16
+ const nonceAttr = buildNonceAttribute(nonce);
17
17
  return `<script type="module" src="/_veryfront/hmr.js"${nonceAttr}></script>`;
18
18
  }
19
19
 
@@ -32,6 +32,7 @@ export function generateHydrationData(
32
32
  params: Record<string, string | string[]>,
33
33
  props: ComponentProps,
34
34
  options: HTMLGenerationOptions,
35
+ serializeOptions?: { pretty?: boolean },
35
36
  ): string {
36
37
  const layouts = (options.nestedLayouts ?? [])
37
38
  .map((layout) => {
@@ -74,5 +75,5 @@ export function generateHydrationData(
74
75
  studioEmbed: options.studioEmbed,
75
76
  };
76
77
 
77
- return JSON.stringify(data, null, 2);
78
+ return JSON.stringify(data, null, serializeOptions?.pretty ?? true ? 2 : undefined);
78
79
  }
@@ -13,5 +13,9 @@ export { generateDevErrorLoggerScript } from "./dev-error-logger.js";
13
13
  export { generateDevComponentManifestScript } from "./dev-component-manifest.js";
14
14
  export { generateDevClientRendererScript } from "./dev-client-renderer.js";
15
15
 
16
- export { getProdScripts } from "./prod-scripts.js";
16
+ export {
17
+ generateProdHydrationModule,
18
+ getProdScripts,
19
+ PROD_HYDRATION_MODULE_PATH,
20
+ } from "./prod-scripts.js";
17
21
  export { generateProdHydrationScript } from "./prod-hydration.js";
@@ -1,5 +1,5 @@
1
1
  import type { ComponentProps } from "../../types/index.js";
2
- import { escapeHtml } from "../html-escape.js";
2
+ import { buildNonceAttribute } from "../html-escape.js";
3
3
 
4
4
  export function generateProdHydrationScript(
5
5
  slug: string,
@@ -7,7 +7,7 @@ export function generateProdHydrationScript(
7
7
  props?: ComponentProps,
8
8
  nonce?: string,
9
9
  ): string {
10
- const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
10
+ const nonceAttr = buildNonceAttribute(nonce);
11
11
  const pageProps = JSON.stringify(props ?? {});
12
12
 
13
13
  return `
@@ -1,5 +1,18 @@
1
1
  import { getLoaderScript, getRendererScript, getRouterScript } from "./templates/index.js";
2
- import { escapeHtml } from "../html-escape.js";
2
+ import { buildNonceAttribute } from "../html-escape.js";
3
+
4
+ export const PROD_HYDRATION_MODULE_PATH = "/_veryfront/hydration-runtime.js";
5
+
6
+ export function generateProdHydrationModule(): string {
7
+ return [
8
+ `import * as React from 'react';`,
9
+ `import { RouterProvider, useRouter as useRouterFromModule } from 'veryfront/router';`,
10
+ `import { PageContextProvider } from 'veryfront/context';`,
11
+ getRouterScript().trim(),
12
+ getLoaderScript().trim(),
13
+ getRendererScript().trim(),
14
+ ].join("\n\n");
15
+ }
3
16
 
4
17
  export function getProdScripts(
5
18
  _slug: string,
@@ -7,18 +20,6 @@ export function getProdScripts(
7
20
  _props?: Record<string, unknown>,
8
21
  nonce?: string,
9
22
  ): string {
10
- const nonceAttr = nonce ? ` nonce="${escapeHtml(nonce)}"` : "";
11
-
12
- return `
13
- <script type="module"${nonceAttr}>
14
- import * as React from 'react';
15
- import { RouterProvider, useRouter as useRouterFromModule } from 'veryfront/router';
16
- import { PageContextProvider } from 'veryfront/context';
17
-
18
- ${getRouterScript()}
19
-
20
- ${getLoaderScript()}
21
-
22
- ${getRendererScript()}
23
- </script>`;
23
+ const nonceAttr = buildNonceAttribute(nonce);
24
+ return `\n <script type="module" src="${PROD_HYDRATION_MODULE_PATH}"${nonceAttr}></script>`;
24
25
  }
@@ -30,6 +30,7 @@ export const HTMLGenerationOptionsSchema = z.object({
30
30
  layoutProps: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),
31
31
  studioEmbed: z.boolean().optional(),
32
32
  projectId: z.string().optional(),
33
+ projectSlug: z.string().optional(),
33
34
  pageId: z.string().optional(),
34
35
  sourceHash: z.string().optional(),
35
36
  colorScheme: colorSchemeSchema.optional(),
@@ -48,6 +49,7 @@ export const HTMLGenerationOptionsSchema = z.object({
48
49
  projectClasses: z.set(z.string()).optional(),
49
50
  isLocalProject: z.boolean().optional(),
50
51
  noHmr: z.boolean().optional(),
52
+ forceProductionScripts: z.boolean().optional(),
51
53
  });
52
54
 
53
55
  export const HydrationDataSchema = z.object({