veryfront 0.1.129 → 0.1.131

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 (112) hide show
  1. package/esm/cli/auth/login.d.ts.map +1 -1
  2. package/esm/cli/auth/login.js +11 -0
  3. package/esm/cli/auth/provider-store.d.ts +20 -0
  4. package/esm/cli/auth/provider-store.d.ts.map +1 -0
  5. package/esm/cli/auth/provider-store.js +62 -0
  6. package/esm/cli/auth/providers/anthropic.d.ts +2 -0
  7. package/esm/cli/auth/providers/anthropic.d.ts.map +1 -0
  8. package/esm/cli/auth/providers/anthropic.js +37 -0
  9. package/esm/cli/auth/providers/openai.d.ts +2 -0
  10. package/esm/cli/auth/providers/openai.d.ts.map +1 -0
  11. package/esm/cli/auth/providers/openai.js +35 -0
  12. package/esm/cli/auth/utils.d.ts +5 -0
  13. package/esm/cli/auth/utils.d.ts.map +1 -1
  14. package/esm/cli/auth/utils.js +9 -0
  15. package/esm/cli/commands/config/command-help.d.ts +3 -0
  16. package/esm/cli/commands/config/command-help.d.ts.map +1 -0
  17. package/esm/cli/commands/config/command-help.js +13 -0
  18. package/esm/cli/commands/config/handler.d.ts +5 -0
  19. package/esm/cli/commands/config/handler.d.ts.map +1 -0
  20. package/esm/cli/commands/config/handler.js +70 -0
  21. package/esm/cli/commands/open/command-help.d.ts +3 -0
  22. package/esm/cli/commands/open/command-help.d.ts.map +1 -0
  23. package/esm/cli/commands/open/command-help.js +17 -0
  24. package/esm/cli/commands/open/command.d.ts +14 -0
  25. package/esm/cli/commands/open/command.d.ts.map +1 -0
  26. package/esm/cli/commands/open/command.js +22 -0
  27. package/esm/cli/commands/open/handler.d.ts +3 -0
  28. package/esm/cli/commands/open/handler.d.ts.map +1 -0
  29. package/esm/cli/commands/open/handler.js +29 -0
  30. package/esm/cli/help/command-definitions.d.ts.map +1 -1
  31. package/esm/cli/help/command-definitions.js +4 -0
  32. package/esm/cli/router.d.ts.map +1 -1
  33. package/esm/cli/router.js +26 -1
  34. package/esm/deno.js +1 -1
  35. package/esm/src/channels/control-plane.js +6 -6
  36. package/esm/src/discovery/handlers/agent-handler.d.ts.map +1 -1
  37. package/esm/src/discovery/handlers/agent-handler.js +10 -1
  38. package/esm/src/platform/compat/framework-source-resolver.d.ts +8 -0
  39. package/esm/src/platform/compat/framework-source-resolver.d.ts.map +1 -1
  40. package/esm/src/platform/compat/framework-source-resolver.js +77 -1
  41. package/esm/src/rendering/rsc/client-boot.ts +18 -1
  42. package/esm/src/server/handlers/preview/markdown-html-generator.d.ts +2 -0
  43. package/esm/src/server/handlers/preview/markdown-html-generator.d.ts.map +1 -1
  44. package/esm/src/server/handlers/preview/markdown-html-generator.js +10 -7
  45. package/esm/src/server/handlers/preview/markdown-preview.handler.d.ts.map +1 -1
  46. package/esm/src/server/handlers/preview/markdown-preview.handler.js +6 -3
  47. package/esm/src/server/handlers/request/api/project-discovery.d.ts.map +1 -1
  48. package/esm/src/server/handlers/request/api/project-discovery.js +16 -5
  49. package/esm/src/server/handlers/request/api/security-headers.d.ts +1 -0
  50. package/esm/src/server/handlers/request/api/security-headers.d.ts.map +1 -1
  51. package/esm/src/server/handlers/request/api/security-headers.js +4 -1
  52. package/esm/src/server/handlers/request/openapi-docs.handler.d.ts.map +1 -1
  53. package/esm/src/server/handlers/request/openapi-docs.handler.js +10 -6
  54. package/esm/src/server/handlers/request/rsc/index.d.ts.map +1 -1
  55. package/esm/src/server/handlers/request/rsc/index.js +5 -2
  56. package/esm/src/server/handlers/request/ssr/ssr-response-builder.d.ts.map +1 -1
  57. package/esm/src/server/handlers/request/ssr/ssr-response-builder.js +12 -2
  58. package/esm/src/server/handlers/response/not-found.d.ts.map +1 -1
  59. package/esm/src/server/handlers/response/not-found.js +14 -15
  60. package/esm/src/server/services/rsc/endpoints/endpoint-router.d.ts +1 -1
  61. package/esm/src/server/services/rsc/endpoints/endpoint-router.d.ts.map +1 -1
  62. package/esm/src/server/services/rsc/endpoints/endpoint-router.js +3 -3
  63. package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.d.ts.map +1 -1
  64. package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
  65. package/esm/src/server/services/rsc/endpoints/types.d.ts +1 -0
  66. package/esm/src/server/services/rsc/endpoints/types.d.ts.map +1 -1
  67. package/esm/src/server/services/rsc/orchestrators/handler.d.ts +1 -1
  68. package/esm/src/server/services/rsc/orchestrators/handler.d.ts.map +1 -1
  69. package/esm/src/server/services/rsc/orchestrators/handler.js +2 -2
  70. package/esm/src/server/services/rsc/orchestrators/page-handler.d.ts +1 -1
  71. package/esm/src/server/services/rsc/orchestrators/page-handler.d.ts.map +1 -1
  72. package/esm/src/server/services/rsc/orchestrators/page-handler.js +7 -5
  73. package/esm/src/transforms/esm/import-parser.d.ts.map +1 -1
  74. package/esm/src/transforms/esm/import-parser.js +6 -0
  75. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.d.ts +1 -1
  76. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.d.ts.map +1 -1
  77. package/esm/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.js +10 -66
  78. package/esm/src/utils/version-constant.d.ts +1 -1
  79. package/esm/src/utils/version-constant.js +1 -1
  80. package/package.json +1 -1
  81. package/src/cli/auth/login.ts +12 -0
  82. package/src/cli/auth/provider-store.ts +82 -0
  83. package/src/cli/auth/providers/anthropic.ts +46 -0
  84. package/src/cli/auth/providers/openai.ts +45 -0
  85. package/src/cli/auth/utils.ts +10 -0
  86. package/src/cli/commands/config/command-help.ts +15 -0
  87. package/src/cli/commands/config/handler.ts +90 -0
  88. package/src/cli/commands/open/command-help.ts +19 -0
  89. package/src/cli/commands/open/command.ts +28 -0
  90. package/src/cli/commands/open/handler.ts +38 -0
  91. package/src/cli/help/command-definitions.ts +4 -0
  92. package/src/cli/router.ts +28 -1
  93. package/src/deno.js +1 -1
  94. package/src/src/channels/control-plane.ts +6 -6
  95. package/src/src/discovery/handlers/agent-handler.ts +10 -1
  96. package/src/src/platform/compat/framework-source-resolver.ts +101 -1
  97. package/src/src/server/handlers/preview/markdown-html-generator.ts +12 -6
  98. package/src/src/server/handlers/preview/markdown-preview.handler.ts +6 -3
  99. package/src/src/server/handlers/request/api/project-discovery.ts +18 -5
  100. package/src/src/server/handlers/request/api/security-headers.ts +10 -1
  101. package/src/src/server/handlers/request/openapi-docs.handler.ts +10 -6
  102. package/src/src/server/handlers/request/rsc/index.ts +5 -2
  103. package/src/src/server/handlers/request/ssr/ssr-response-builder.ts +16 -2
  104. package/src/src/server/handlers/response/not-found.ts +14 -15
  105. package/src/src/server/services/rsc/endpoints/endpoint-router.ts +3 -3
  106. package/src/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +1 -1
  107. package/src/src/server/services/rsc/endpoints/types.ts +1 -0
  108. package/src/src/server/services/rsc/orchestrators/handler.ts +2 -2
  109. package/src/src/server/services/rsc/orchestrators/page-handler.ts +8 -5
  110. package/src/src/transforms/esm/import-parser.ts +12 -0
  111. package/src/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.ts +10 -69
  112. package/src/src/utils/version-constant.ts +1 -1
@@ -12,7 +12,7 @@ import * as dntShim from "../../../../_dnt.shims.js";
12
12
  import { BaseHandler } from "../response/base.js";
13
13
  import type { HandlerContext, HandlerMetadata, HandlerPriority, HandlerResult } from "../types.js";
14
14
  import { HTTP_OK, PRIORITY_HIGH_DEV } from "../../../utils/constants/index.js";
15
- import { escapeHtml } from "../../../html/html-escape.js";
15
+ import { buildNonceAttribute, escapeHtml } from "../../../html/html-escape.js";
16
16
 
17
17
  /** Default paths */
18
18
  const DEFAULT_DOCS_PATH = "/_docs";
@@ -38,20 +38,23 @@ export class OpenAPIDocsHandler extends BaseHandler {
38
38
  handle(req: dntShim.Request, ctx: HandlerContext): Promise<HandlerResult> {
39
39
  if (!this.shouldHandle(req, ctx)) return Promise.resolve(this.continue());
40
40
 
41
- const html = this.generateDocsPage(ctx);
42
41
  const isDev = !!ctx.isLocalProject;
42
+ const builder = this.createResponseBuilder(ctx);
43
+ const html = this.generateDocsPage(ctx, builder.nonce);
43
44
 
44
- const response = this.createResponseBuilder(ctx)
45
+ const response = builder
45
46
  .withCache(isDev ? "no-cache" : { maxAge: DOCS_CACHE_MAX_AGE_SECONDS, public: true })
47
+ .withSecurity(ctx.securityConfig ?? undefined, req)
46
48
  .withContentType("text/html; charset=utf-8", html, HTTP_OK);
47
49
 
48
50
  return Promise.resolve(this.respond(response));
49
51
  }
50
52
 
51
- private generateDocsPage(ctx: HandlerContext): string {
53
+ private generateDocsPage(ctx: HandlerContext, nonce?: string): string {
52
54
  const specUrl = ctx.config?.openapi?.paths?.json ?? DEFAULT_JSON_PATH;
53
55
  const title = escapeHtml(ctx.config?.openapi?.title ?? "API Documentation");
54
56
  const description = escapeHtml(ctx.config?.openapi?.description ?? "");
57
+ const nonceAttr = buildNonceAttribute(nonce);
55
58
 
56
59
  const configuration = JSON.stringify({
57
60
  theme: "purple",
@@ -69,7 +72,7 @@ export class OpenAPIDocsHandler extends BaseHandler {
69
72
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
70
73
  <title>${title}</title>
71
74
  ${description ? `<meta name="description" content="${description}"/>` : ""}
72
- <style>
75
+ <style${nonceAttr}>
73
76
  body {
74
77
  margin: 0;
75
78
  padding: 0;
@@ -81,8 +84,9 @@ export class OpenAPIDocsHandler extends BaseHandler {
81
84
  id="api-reference"
82
85
  data-url="${specUrl}"
83
86
  data-configuration='${configuration}'
87
+ ${nonce ? `nonce="${escapeHtml(nonce)}"` : ""}
84
88
  ></script>
85
- <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
89
+ <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"${nonceAttr}></script>
86
90
  </body>
87
91
  </html>`;
88
92
  }
@@ -15,10 +15,11 @@ import type {
15
15
  } from "../../types.js";
16
16
  import { isRSCEnabled } from "../../../../utils/index.js";
17
17
  import { handleRSCEndpoint } from "../../../services/rsc/endpoints/index.js";
18
- import { applySecurityHeaders } from "../api/security-headers.js";
18
+ import { applySecurityHeadersWithNonce } from "../api/security-headers.js";
19
19
  import { applyCORSHeaders } from "../../../../security/index.js";
20
20
  import { HTTP_NOT_FOUND, PRIORITY_MEDIUM } from "../../../../utils/constants/index.js";
21
21
  import { withSpan } from "../../../../observability/tracing/otlp-setup.js";
22
+ import { generateNonce } from "../../../../security/http/response/security-handler.js";
22
23
 
23
24
  export class RSCHandler extends BaseHandler {
24
25
  metadata: HandlerMetadata = {
@@ -46,6 +47,7 @@ export class RSCHandler extends BaseHandler {
46
47
  return this.respond(new dntShim.Response("Not Found", { status: HTTP_NOT_FOUND }));
47
48
  }
48
49
 
50
+ const nonce = generateNonce();
49
51
  const res = await handleRSCEndpoint({
50
52
  req,
51
53
  pathname,
@@ -53,6 +55,7 @@ export class RSCHandler extends BaseHandler {
53
55
  projectId: ctx.projectId,
54
56
  adapter: ctx.adapter,
55
57
  config: ctx.config,
58
+ nonce,
56
59
  });
57
60
 
58
61
  if (!res) {
@@ -65,7 +68,7 @@ export class RSCHandler extends BaseHandler {
65
68
  headers,
66
69
  config: ctx.securityConfig?.cors,
67
70
  });
68
- applySecurityHeaders(headers, ctx, req);
71
+ applySecurityHeadersWithNonce(headers, ctx, nonce, req);
69
72
 
70
73
  return this.respond(
71
74
  new dntShim.Response(res.body, {
@@ -15,6 +15,15 @@ import { getContentType } from "../../utils/content-types.js";
15
15
  import type { SSRRenderResult } from "../../../services/rendering/ssr.service.js";
16
16
  import { ErrorPages } from "../../../utils/error-html.js";
17
17
  import type { ResponseBuilder } from "../../../../security/http/response/builder.js";
18
+ import { escapeHtml } from "../../../../html/html-escape.js";
19
+
20
+ function addNonceToInlineTags(html: string, nonce: string): string {
21
+ const escapedNonce = escapeHtml(nonce);
22
+ return html.replace(
23
+ /<(script|style)\b(?![^>]*\bnonce\s*=)([^>]*)>/giu,
24
+ `<$1$2 nonce="${escapedNonce}">`,
25
+ );
26
+ }
18
27
 
19
28
  /**
20
29
  * Build an HTTP response from an SSR render result.
@@ -56,8 +65,13 @@ export async function buildSSRResponse(
56
65
  }
57
66
 
58
67
  // Buffered response path
59
- const content = result.html || result.stream || ErrorPages.serverError();
60
- const body = isHeadRequest ? null : content;
68
+ const content = typeof result.html === "string"
69
+ ? result.html
70
+ : typeof result.stream === "string"
71
+ ? result.stream
72
+ : ErrorPages.serverError();
73
+ const html = addNonceToInlineTags(content, builder.nonce);
74
+ const body = isHeadRequest ? null : html;
61
75
 
62
76
  let response = builder
63
77
  .withCORS(req, ctx.securityConfig?.cors)
@@ -7,7 +7,7 @@ import {
7
7
  HTTP_NOT_FOUND,
8
8
  PRIORITY_FALLBACK,
9
9
  } from "../../../utils/constants/index.js";
10
- import { escapeHtml } from "../../../html/html-escape.js";
10
+ import { buildNonceAttribute, escapeHtml } from "../../../html/html-escape.js";
11
11
 
12
12
  export class NotFoundHandler extends BaseHandler {
13
13
  metadata: HandlerMetadata = {
@@ -18,17 +18,15 @@ export class NotFoundHandler extends BaseHandler {
18
18
 
19
19
  handle(req: dntShim.Request, ctx: HandlerContext): Promise<HandlerResult> {
20
20
  const pathname = new URL(req.url).pathname;
21
- const securityConfig = ctx.securityConfig;
22
- const corsConfig = ctx.securityConfig?.cors;
23
21
 
24
22
  try {
25
- const html = this.generate404Html(pathname);
26
- const response = ResponseBuilder.html(html, req, {
27
- securityConfig,
28
- corsConfig,
29
- cache: "no-cache",
30
- status: HTTP_NOT_FOUND,
31
- });
23
+ const builder = this.createResponseBuilder(ctx);
24
+ const html = this.generate404Html(pathname, builder.nonce);
25
+ const response = builder
26
+ .withCORS(req, ctx.securityConfig?.cors)
27
+ .withSecurity(ctx.securityConfig ?? undefined, req)
28
+ .withCache("no-cache")
29
+ .html(html, HTTP_NOT_FOUND);
32
30
 
33
31
  return Promise.resolve(this.respond(response));
34
32
  } catch (e) {
@@ -39,8 +37,8 @@ export class NotFoundHandler extends BaseHandler {
39
37
  "Internal Server Error",
40
38
  req,
41
39
  {
42
- securityConfig,
43
- corsConfig,
40
+ securityConfig: ctx.securityConfig,
41
+ corsConfig: ctx.securityConfig?.cors,
44
42
  },
45
43
  );
46
44
 
@@ -48,14 +46,15 @@ export class NotFoundHandler extends BaseHandler {
48
46
  }
49
47
  }
50
48
 
51
- private generate404Html(pathname: string): string {
49
+ private generate404Html(pathname: string, nonce?: string): string {
50
+ const nonceAttr = buildNonceAttribute(nonce);
52
51
  return `<!DOCTYPE html>
53
52
  <html lang="en">
54
53
  <head>
55
54
  <meta charset="utf-8"/>
56
55
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
57
56
  <title>404 Not Found</title>
58
- <style>
57
+ <style${nonceAttr}>
59
58
  body {
60
59
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
61
60
  margin: 0;
@@ -149,7 +148,7 @@ export class NotFoundHandler extends BaseHandler {
149
148
  </p>
150
149
  <div class="actions">
151
150
  <a href="/" class="button">Go Home</a>
152
- <a href="javascript:history.back()" class="button secondary">Go Back</a>
151
+ <a href=".." class="button secondary">Go Back</a>
153
152
  </div>
154
153
  </div>
155
154
  </body>
@@ -28,7 +28,7 @@ const rscLog = serverLogger.component("rsc");
28
28
  * @returns Response or null if not an RSC endpoint
29
29
  */
30
30
  export async function handleRSCEndpoint(
31
- { req, pathname, projectDir, projectId, adapter, config }: RSCEndpointParams,
31
+ { req, pathname, projectDir, projectId, adapter, config, nonce }: RSCEndpointParams,
32
32
  ): Promise<dntShim.Response | null> {
33
33
  if (!pathname.startsWith("/_veryfront/rsc/")) {
34
34
  return null;
@@ -67,7 +67,7 @@ export async function handleRSCEndpoint(
67
67
  }
68
68
  if (sub.startsWith("page/")) {
69
69
  metrics.recordRSC("page");
70
- return handler.handlePage(sub.replace("page/", ""), url.searchParams);
70
+ return handler.handlePage(sub.replace("page/", ""), url.searchParams, nonce);
71
71
  }
72
72
  if (sub.startsWith("stream/")) {
73
73
  metrics.recordRSC("stream");
@@ -123,7 +123,7 @@ export async function handleRSCEndpoint(
123
123
 
124
124
  if (sub === "page") {
125
125
  metrics.recordRSC("page");
126
- return handler.handlePage("/", url.searchParams);
126
+ return handler.handlePage("/", url.searchParams, nonce);
127
127
  }
128
128
 
129
129
  if (sub === "stream") {
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  export const CLIENT_BOOT_BUNDLE: string =
10
- 'var B=Object.defineProperty;var Y=(t,e,o)=>e in t?B(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var d=(t,e,o)=>Y(t,typeof e!="symbol"?e+"":e,o);var W="3.2.3";function q(t,e,o,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let g=Object.entries(n.deps).map(([a,I])=>`${a}@${I}`).join(",");s.push(`deps=${g}`)}let c=e?`@${e}`:"",l=o??"",u=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${c}${l}${u}`}function R(t,e,o,n=!1){return q(t,e,o,{external:n?["react"]:void 0,deps:{csstype:W}})}var X="19.1.1",f=X;function N(t=f){return{react:R("react",t),"react-dom":R("react-dom",t,void 0,!0),"react-dom/client":R("react-dom",t,"/client",!0),"react-dom/server":R("react-dom",t,"/server",!0),"react/jsx-runtime":R("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":R("react",t,"/jsx-dev-runtime",!0)}}function A(t=f){return N(t).react}function D(t=f){return N(t)["react-dom/client"]}function J(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function v(t){return J(btoa(t))}var Tt=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function h(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let o of Object.keys(e))if(o.endsWith("/")&&t.startsWith(o))return!0;return!1}function K(t){try{return JSON.parse(t)?.imports??{}}catch{return{}}}function L(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?K(e.textContent):{}}var i="/_veryfront",S={RSC:`${i}/rsc/`,FS:`${i}/fs/`,MODULES:`${i}/modules/`,PAGES:`${i}/pages/`,DATA:`${i}/data/`,LIB:`${i}/lib/`,CHUNKS:`${i}/chunks/`,CLIENT:`${i}/client/`},b={HMR_RUNTIME:`${i}/hmr-runtime.js`,HMR:`${i}/hmr.js`,HYDRATE:`${i}/hydrate.js`,ERROR_OVERLAY:`${i}/error-overlay.js`,DEV_LOADER:`${i}/dev-loader.js`,CLIENT_LOG:`${i}/log`,CLIENT_JS:`${i}/client.js`,ROUTER_JS:`${i}/router.js`,PREFETCH_JS:`${i}/prefetch.js`,MANIFEST_JSON:`${i}/manifest.json`,APP_JS:`${i}/app.js`,RSC_CLIENT:`${i}/rsc/client.js`,RSC_MANIFEST:`${i}/rsc/manifest`,RSC_STREAM:`${i}/rsc/stream`,RSC_PAYLOAD:`${i}/rsc/payload`,RSC_RENDER:`${i}/rsc/render`,RSC_PAGE:`${i}/rsc/page`,RSC_MODULE:`${i}/rsc/module`,RSC_DOM:`${i}/rsc/dom.js`,RSC_HYDRATOR:`${i}/rsc/hydrator.js`,RSC_HYDRATE_CLIENT:`${i}/rsc/hydrate-client.js`,LIB_AI_REACT:`${i}/lib/ai/react.js`,LIB_AI_COMPONENTS:`${i}/lib/ai/components.js`,LIB_AI_PRIMITIVES:`${i}/lib/ai/primitives.js`};var Q={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},Lt=Q.CACHE;var bt={HMR_RUNTIME:b.HMR_RUNTIME,ERROR_OVERLAY:b.ERROR_OVERLAY};var m=S.RSC,M=S.FS,U="veryfront-hydration-data",O="rsc-root";function P(t=document){try{let e=t.getElementById(U);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return console.debug?.("[RSC] hydration data parse failed",e),null}}function V(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function tt(t){return`${M}${v(t)}.js`}function et(t,e){let o=e?`&v=${encodeURIComponent(e)}`:"";return`${m}module?rel=${encodeURIComponent(t)}${o}`}function w(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?tt(e):null}return et(t.rel,t.version)}function F(t=document,e=f){let o=L(t);return{react:h("react",o)?"react":A(e),reactDomClient:h("react-dom/client",o)?"react-dom/client":D(e)}}function r(t){return{...t,create(e){return new C(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var C=class extends Error{constructor(o,n){super(o);d(this,"slug");d(this,"category");d(this,"status");d(this,"title");d(this,"suggestion");d(this,"detail");d(this,"cause");d(this,"instance");d(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var Wt=r({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),qt=r({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),zt=r({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),Xt=r({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),Jt=r({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),Kt=r({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),Zt=r({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),Qt=r({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),te=r({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),ee=r({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),re=r({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),oe=r({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),ne=r({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),se=r({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),ie=r({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),ae=r({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),ce=r({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),ue=r({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),le=r({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ge=r({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),de=r({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),pe=r({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),Re=r({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),me=r({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),Ee=r({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),fe=r({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),ye=r({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),_e=r({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),Oe=r({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),xe=r({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),Ie=r({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),he=r({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),Se=r({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Ce=r({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Te=r({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),Ne=r({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),Ae=r({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),De=r({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),ve=r({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),Le=r({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),be=r({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Me=r({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Ue=r({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Pe=r({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ve=r({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),we=r({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),Fe=r({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),$e=r({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),He=r({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),ke=r({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),Ge=r({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),je=r({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),Be=r({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),Ye=r({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),We=r({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),qe=r({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),ze=r({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Xe=r({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Je=r({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),Ke=r({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),Ze=r({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),Qe=r({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),tr=r({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),er=r({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),rr=r({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),or=r({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),nr=r({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),sr=r({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),ir=r({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),ar=r({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),cr=r({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),ur=r({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),lr=r({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),gr=r({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),dr=r({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),pr=r({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Rr=r({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),$=r({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),mr=r({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"});var rt=[{pattern:/<script[^>]*>[\\s\\S]*?<\\/script>/gi,name:"inline script"},{pattern:/javascript:/gi,name:"javascript: URL"},{pattern:/\\bon\\w+\\s*=/gi,name:"event handler attribute"},{pattern:/data:\\s*text\\/html/gi,name:"data: HTML URL"}];function ot(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function y(t,e={}){let{strict:o=!1,warn:n=!0}=e;for(let{pattern:s,name:c}of rt)if(s.lastIndex=0,!!s.test(t)&&(n&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),o||!ot()))throw $.create({detail:`Potentially unsafe HTML: ${c} detected`});return t}var E=class{constructor(e,o){this.prefix=e;this.level=o}log(e,o,n,...s){this.level>e||o?.(n,...s)}debug(e,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...o)}info(e,...o){this.log(1,console.log,`[${this.prefix}] ${e}`,...o)}warn(e,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...o)}error(e,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...o)}};function nt(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var x=nt(),p=new E("RSC",x),xr=new E("PREFETCH",x),Ir=new E("HYDRATE",x),hr=new E("VERYFRONT",x);function _(t,e){let o=e==="root"?O:`rsc-slot-${e}`,n=t.getElementById(o);if(n)return n;let s=t.createElement("div");return s.id=o,t.body.appendChild(s),s}function st(t,e){if(e.type!=="slot")return;let o=_(t,e.id);o.innerHTML=y(String(e.html??""))}function H(t,e){let o=e.split(`\n`),n=o.pop()??"";for(let s of o){let c=s.trim();if(!c)continue;let l;try{l=JSON.parse(c)}catch(g){p.debug("[client-dom] malformed NDJSON line",{line:c,error:g instanceof Error?g.message:String(g)});continue}if(!l||typeof l!="object")continue;let u=l;if(u.type==="slot"){st(t,u);try{ct(t,u.id||"root")}catch(g){p.debug("[client-dom] hydration optional failed",g)}}}return n}function it(t){return new Promise((e,o)=>{let n=()=>o(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function k(t,e=document,o){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let c=s.getReader(),l=new TextDecoder,u="",g=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let a=c.read(),{done:I,value:j}=o?await Promise.race([a,it(o)]):await a;if(I){g=!0;break}u+=l.decode(j,{stream:!0}),u=H(e,u)}u&&H(e,`${u}\n`)}catch(a){throw a instanceof Error&&a.name==="AbortError"||p.debug("[client-dom] consumeNdjsonStream error",a),a}finally{try{await c.cancel()}catch(a){g||p.debug("[client-dom] reader.cancel failed",a)}try{c.releaseLock()}catch(a){p.debug("[client-dom] reader.releaseLock failed",a)}if(typeof s.cancel=="function")try{await s.cancel()}catch(a){p.debug("[client-dom] stream.cancel failed",a)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(a){p.debug("[client-dom] response.body.cancel failed",a)}}}function at(t,e){let o=_(t,e),n=[],s=c=>{let l=c;l.dataset?.clientRef&&n.push(l);for(let u of c.children)s(u)};return s(o),n}function ct(t,e){let o=at(t,e);for(let n of o){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",p.debug("[client-dom] marked for hydration",s))}}async function ut(){let t=F(document),[e,o]=await Promise.all([import(t.react),import(t.reactDomClient)]);return{React:e,ReactDOM:o}}var lt=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function G(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||lt.has(t.tagName.toUpperCase())}function gt(t,e){return t.find(o=>o.tagName.toUpperCase()==="DIV"&&!!o.getAttribute("class")?.trim()&&!G(o))??t.find(o=>!G(o))??e}async function dt(t){try{let e=await fetch(m+"stream"+t);if(!e.ok||!e.body)return!1;let o=new AbortController;return addEventListener("pagehide",()=>o.abort(),{once:!0}),await k(e,document,o.signal),!0}catch(e){return console.debug?.("[RSC] tryStream failed",e),!1}}async function T(){try{(await import(m+"hydrate.js")).bootHydration?.()}catch(t){console.debug?.("[RSC] hydrate import failed",t)}}async function pt(t,e){try{let{React:o,ReactDOM:n}=await ut(),s=w({strategy:e,rel:t});if(!s)return!1;console.debug?.("[RSC] Loading component from:",s);let l=(await import(s)).default;if(typeof l!="function")return console.debug?.("[RSC] Page component is not a function"),!1;let u=gt(Array.from(document.body.children),document.body);return n.hydrateRoot(u,o.createElement(l,{}),{identifierPrefix:"vf",onRecoverableError:()=>{}}),console.debug?.("[RSC] Page component hydrated successfully"),!0}catch(o){return console.error("[RSC] Page hydration failed",o),!1}}async function Rt(t){try{let e=await fetch(m+"payload"+t);if(!e.ok)return!1;let o=await e.json();if(o?.slots){for(let[n,s]of Object.entries(o.slots))_(document,n).innerHTML=y(String(s||""));return!0}return _(document,O).innerHTML=y(String(o?.html||"")),!0}catch(e){return console.debug?.("[RSC] payload fetch failed",e),!1}}async function mt(){try{let t=globalThis.window?.location.search??"",e=P(document),o=e?.pagePath,n=V(e);if(o&&(console.debug?.("[RSC] Found page component in hydration data:",o),await pt(o,n))){console.debug?.("[RSC] Client component hydrated successfully");return}if(await dt(t)){await T();return}if(await Rt(t)){await T();return}await T()}catch(t){console.error("[RSC] boot failed",t)}}if(typeof document<"u"){let t=()=>{mt()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{mt as boot,gt as selectHydrationRoot};\n';
10
+ 'var B=Object.defineProperty;var Y=(t,e,o)=>e in t?B(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var d=(t,e,o)=>Y(t,typeof e!="symbol"?e+"":e,o);var W="3.2.3";function q(t,e,o,n){let s=[];if(n?.external?.length&&s.push(`external=${n.external.join(",")}`),s.push(`target=${n?.target??"es2022"}`),n?.deps){let g=Object.entries(n.deps).map(([a,I])=>`${a}@${I}`).join(",");s.push(`deps=${g}`)}let c=e?`@${e}`:"",l=o??"",u=s.length?`?${s.join("&")}`:"";return`https://esm.sh/${t}${c}${l}${u}`}function R(t,e,o,n=!1){return q(t,e,o,{external:n?["react"]:void 0,deps:{csstype:W}})}var X="19.1.1",f=X;function N(t=f){return{react:R("react",t),"react-dom":R("react-dom",t,void 0,!0),"react-dom/client":R("react-dom",t,"/client",!0),"react-dom/server":R("react-dom",t,"/server",!0),"react/jsx-runtime":R("react",t,"/jsx-runtime",!0),"react/jsx-dev-runtime":R("react",t,"/jsx-dev-runtime",!0)}}function A(t=f){return N(t).react}function D(t=f){return N(t)["react-dom/client"]}function J(t){return t.replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function v(t){return J(btoa(t))}var Nt=Object.freeze({react:"","react-dom":"","react-dom/client":"","react-dom/server":"","react/jsx-runtime":"","react/jsx-dev-runtime":""});function h(t,e){if(!e)return!1;if(Object.prototype.hasOwnProperty.call(e,t))return!0;for(let o of Object.keys(e))if(o.endsWith("/")&&t.startsWith(o))return!0;return!1}function K(t){try{return JSON.parse(t)?.imports??{}}catch{return{}}}function L(t=document){let e=t.querySelector(\'script[type="importmap"]\');return e?.textContent?K(e.textContent):{}}var i="/_veryfront",S={RSC:`${i}/rsc/`,FS:`${i}/fs/`,MODULES:`${i}/modules/`,PAGES:`${i}/pages/`,DATA:`${i}/data/`,LIB:`${i}/lib/`,CHUNKS:`${i}/chunks/`,CLIENT:`${i}/client/`},b={HMR_RUNTIME:`${i}/hmr-runtime.js`,HMR:`${i}/hmr.js`,HYDRATE:`${i}/hydrate.js`,ERROR_OVERLAY:`${i}/error-overlay.js`,DEV_LOADER:`${i}/dev-loader.js`,CLIENT_LOG:`${i}/log`,CLIENT_JS:`${i}/client.js`,ROUTER_JS:`${i}/router.js`,PREFETCH_JS:`${i}/prefetch.js`,MANIFEST_JSON:`${i}/manifest.json`,APP_JS:`${i}/app.js`,RSC_CLIENT:`${i}/rsc/client.js`,RSC_MANIFEST:`${i}/rsc/manifest`,RSC_STREAM:`${i}/rsc/stream`,RSC_PAYLOAD:`${i}/rsc/payload`,RSC_RENDER:`${i}/rsc/render`,RSC_PAGE:`${i}/rsc/page`,RSC_MODULE:`${i}/rsc/module`,RSC_DOM:`${i}/rsc/dom.js`,RSC_HYDRATOR:`${i}/rsc/hydrator.js`,RSC_HYDRATE_CLIENT:`${i}/rsc/hydrate-client.js`,LIB_AI_REACT:`${i}/lib/ai/react.js`,LIB_AI_COMPONENTS:`${i}/lib/ai/components.js`,LIB_AI_PRIMITIVES:`${i}/lib/ai/primitives.js`};var Q={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},bt=Q.CACHE;var Mt={HMR_RUNTIME:b.HMR_RUNTIME,ERROR_OVERLAY:b.ERROR_OVERLAY};var m=S.RSC,M=S.FS,U="veryfront-hydration-data",y="rsc-root";function P(t=document){try{let e=t.getElementById(U);return e?JSON.parse(e.textContent||"{}"):null}catch(e){return console.debug?.("[RSC] hydration data parse failed",e),null}}function V(t){return t?.clientModuleStrategy?t.clientModuleStrategy:t?.dev?"fs":"rsc-module"}function tt(t){return`${M}${v(t)}.js`}function et(t,e){let o=e?`&v=${encodeURIComponent(e)}`:"";return`${m}module?rel=${encodeURIComponent(t)}${o}`}function w(t){if(t.strategy==="fs"){let e=t.absPath??t.rel;return e?tt(e):null}return et(t.rel,t.version)}function F(t=document,e=f){let o=L(t);return{react:h("react",o)?"react":A(e),reactDomClient:h("react-dom/client",o)?"react-dom/client":D(e)}}function r(t){return{...t,create(e){return new C(e?.message||e?.detail||t.title,{slug:t.slug,category:t.category,status:e?.status??t.status,title:t.title,suggestion:t.suggestion,detail:e?.detail,cause:e?.cause,instance:e?.instance,context:e?.context})}}}var C=class extends Error{constructor(o,n){super(o);d(this,"slug");d(this,"category");d(this,"status");d(this,"title");d(this,"suggestion");d(this,"detail");d(this,"cause");d(this,"instance");d(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var qt=r({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),zt=r({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),Xt=r({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),Jt=r({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),Kt=r({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),Zt=r({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),Qt=r({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),te=r({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),ee=r({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),re=r({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),oe=r({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),ne=r({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),se=r({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),ie=r({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),ae=r({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),ce=r({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),ue=r({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),le=r({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ge=r({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),de=r({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),pe=r({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),Re=r({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),me=r({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),Ee=r({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),fe=r({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),ye=r({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),_e=r({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),Oe=r({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),xe=r({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),Ie=r({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),he=r({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),Se=r({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),Ce=r({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Te=r({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Ne=r({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),Ae=r({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),De=r({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),ve=r({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),Le=r({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),be=r({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Me=r({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Ue=r({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Pe=r({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Ve=r({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),we=r({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),Fe=r({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),$e=r({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),He=r({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),ke=r({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),Ge=r({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),je=r({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),Be=r({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),Ye=r({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),We=r({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),qe=r({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),ze=r({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Xe=r({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),Je=r({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),Ke=r({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),Ze=r({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),Qe=r({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),tr=r({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),er=r({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),rr=r({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),or=r({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),nr=r({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),sr=r({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),ir=r({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),ar=r({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),cr=r({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),ur=r({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),lr=r({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),gr=r({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),dr=r({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),pr=r({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),Rr=r({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),mr=r({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),$=r({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),Er=r({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"});var rt=[{pattern:/<script[^>]*>[\\s\\S]*?<\\/script>/gi,name:"inline script"},{pattern:/javascript:/gi,name:"javascript: URL"},{pattern:/\\bon\\w+\\s*=/gi,name:"event handler attribute"},{pattern:/data:\\s*text\\/html/gi,name:"data: HTML URL"}];function ot(){let t=globalThis;return t.__VERYFRONT_DEV__===!0||t.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function _(t,e={}){let{strict:o=!1,warn:n=!0}=e;for(let{pattern:s,name:c}of rt)if(s.lastIndex=0,!!s.test(t)&&(n&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),o||!ot()))throw $.create({detail:`Potentially unsafe HTML: ${c} detected`});return t}var E=class{constructor(e,o){this.prefix=e;this.level=o}log(e,o,n,...s){this.level>e||o?.(n,...s)}debug(e,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${e}`,...o)}info(e,...o){this.log(1,console.log,`[${this.prefix}] ${e}`,...o)}warn(e,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${e}`,...o)}error(e,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${e}`,...o)}};function nt(){if(typeof window>"u")return 2;let t=globalThis;return t.__VERYFRONT_DEV__||t.__RSC_DEV__?t.__VERYFRONT_DEBUG__||t.__RSC_DEBUG__?0:1:2}var x=nt(),p=new E("RSC",x),Ir=new E("PREFETCH",x),hr=new E("HYDRATE",x),Sr=new E("VERYFRONT",x);function O(t,e){let o=e==="root"?y:`rsc-slot-${e}`,n=t.getElementById(o);if(n)return n;let s=t.createElement("div");return s.id=o,t.body.appendChild(s),s}function st(t,e){if(e.type!=="slot")return;let o=O(t,e.id);o.innerHTML=_(String(e.html??""))}function H(t,e){let o=e.split(`\n`),n=o.pop()??"";for(let s of o){let c=s.trim();if(!c)continue;let l;try{l=JSON.parse(c)}catch(g){p.debug("[client-dom] malformed NDJSON line",{line:c,error:g instanceof Error?g.message:String(g)});continue}if(!l||typeof l!="object")continue;let u=l;if(u.type==="slot"){st(t,u);try{ct(t,u.id||"root")}catch(g){p.debug("[client-dom] hydration optional failed",g)}}}return n}function it(t){return new Promise((e,o)=>{let n=()=>o(new DOMException("aborted","AbortError"));if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0})})}async function k(t,e=document,o){let n="body"in t?t:null,s=n?.body??t;if(!s)return;let c=s.getReader(),l=new TextDecoder,u="",g=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let a=c.read(),{done:I,value:j}=o?await Promise.race([a,it(o)]):await a;if(I){g=!0;break}u+=l.decode(j,{stream:!0}),u=H(e,u)}u&&H(e,`${u}\n`)}catch(a){throw a instanceof Error&&a.name==="AbortError"||p.debug("[client-dom] consumeNdjsonStream error",a),a}finally{try{await c.cancel()}catch(a){g||p.debug("[client-dom] reader.cancel failed",a)}try{c.releaseLock()}catch(a){p.debug("[client-dom] reader.releaseLock failed",a)}if(typeof s.cancel=="function")try{await s.cancel()}catch(a){p.debug("[client-dom] stream.cancel failed",a)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(a){p.debug("[client-dom] response.body.cancel failed",a)}}}function at(t,e){let o=O(t,e),n=[],s=c=>{let l=c;l.dataset?.clientRef&&n.push(l);for(let u of c.children)s(u)};return s(o),n}function ct(t,e){let o=at(t,e);for(let n of o){let s=n.dataset?.clientRef;s&&(n.dataset.hydrated="true",p.debug("[client-dom] marked for hydration",s))}}async function ut(){let t=F(document),[e,o]=await Promise.all([import(t.react),import(t.reactDomClient)]);return{React:e,ReactDOM:o}}var lt=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE"]);function G(t){let e=t.getAttribute("style")??"";return t.hasAttribute("data-veryfront-head")||t.hasAttribute("hidden")||/(?:^|;)\\s*display\\s*:\\s*none(?:\\s*;|$)/i.test(e)||lt.has(t.tagName.toUpperCase())}function gt(t,e){return t.find(o=>o.tagName.toUpperCase()==="DIV"&&!!o.getAttribute("class")?.trim()&&!G(o))??t.find(o=>!G(o))??e}function dt(t,e){return e?.pagePath?!1:!!t.getElementById(y)}async function pt(t){try{let e=await fetch(m+"stream"+t);if(!e.ok||!e.body)return!1;let o=new AbortController;return addEventListener("pagehide",()=>o.abort(),{once:!0}),await k(e,document,o.signal),!0}catch(e){return console.debug?.("[RSC] tryStream failed",e),!1}}async function T(){try{(await import(m+"hydrate.js")).bootHydration?.()}catch(t){console.debug?.("[RSC] hydrate import failed",t)}}async function Rt(t,e){try{let{React:o,ReactDOM:n}=await ut(),s=w({strategy:e,rel:t});if(!s)return!1;console.debug?.("[RSC] Loading component from:",s);let l=(await import(s)).default;if(typeof l!="function")return console.debug?.("[RSC] Page component is not a function"),!1;let u=gt(Array.from(document.body.children),document.body);return n.hydrateRoot(u,o.createElement(l,{}),{identifierPrefix:"vf",onRecoverableError:()=>{}}),console.debug?.("[RSC] Page component hydrated successfully"),!0}catch(o){return console.error("[RSC] Page hydration failed",o),!1}}async function mt(t){try{let e=await fetch(m+"payload"+t);if(!e.ok)return!1;let o=await e.json();if(o?.slots){for(let[n,s]of Object.entries(o.slots))O(document,n).innerHTML=_(String(s||""));return!0}return O(document,y).innerHTML=_(String(o?.html||"")),!0}catch(e){return console.debug?.("[RSC] payload fetch failed",e),!1}}async function Et(){try{let t=globalThis.window?.location.search??"",e=P(document),o=e?.pagePath,n=V(e);if(o){console.debug?.("[RSC] Found page component in hydration data:",o),await Rt(o,n)&&console.debug?.("[RSC] Client component hydrated successfully");return}if(!dt(document,e))return;if(await pt(t)){await T();return}if(await mt(t)){await T();return}await T()}catch(t){console.error("[RSC] boot failed",t)}}if(typeof document<"u"){let t=()=>{Et()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}export{Et as boot,gt as selectHydrationRoot,dt as shouldAttemptRSCTransport};\n';
11
11
 
12
12
  export const CLIENT_DOM_BUNDLE: string =
13
13
  'var A=Object.defineProperty;var x=(r,t,o)=>t in r?A(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var u=(r,t,o)=>x(r,typeof t!="symbol"?t+"":t,o);function e(r){return{...r,create(t){return new f(t?.message||t?.detail||r.title,{slug:r.slug,category:r.category,status:t?.status??r.status,title:r.title,suggestion:r.suggestion,detail:t?.detail,cause:t?.cause,instance:t?.instance,context:t?.context})}}}var f=class extends Error{constructor(o,n){super(o);u(this,"slug");u(this,"category");u(this,"status");u(this,"title");u(this,"suggestion");u(this,"detail");u(this,"cause");u(this,"instance");u(this,"context");this.name="VeryfrontError",this.slug=n.slug,this.category=n.category,this.status=n.status,this.title=n.title,this.suggestion=n.suggestion,this.detail=n.detail,this.cause=n.cause,this.instance=n.instance,this.context=n.context}toRFC9457(){return{type:`https://veryfront.com/docs/errors/${this.slug}`,title:this.title,status:this.status,detail:this.detail,instance:this.instance,category:this.category,suggestion:this.suggestion,cause:typeof this.cause=="string"?this.cause:void 0}}getDocsUrl(){return`https://veryfront.com/docs/errors/${this.slug}`}};var $=e({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),B=e({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),Y=e({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),j=e({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),q=e({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),z=e({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),W=e({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),X=e({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),J=e({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),K=e({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),Z=e({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),Q=e({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),ee=e({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),te=e({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),re=e({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),oe=e({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),se=e({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),ne=e({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ie=e({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),ae=e({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ce=e({slug:"page-not-found",category:"RUNTIME",status:404,title:"Page component not found",suggestion:"Check that the page file exists in the routes directory"}),le=e({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),ue=e({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),ge=e({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),de=e({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),pe=e({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),Ee=e({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),Re=e({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),fe=e({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),me=e({slug:"module-not-found",category:"MODULE",status:404,title:"Module could not be resolved",suggestion:"Check the import path and ensure the module is installed"}),_e=e({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),ye=e({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),Oe=e({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Ie=e({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Te=e({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),he=e({slug:"port-in-use",category:"SERVER",status:409,title:"Server port already in use",suggestion:"Use a different port or stop the process using this port"}),ve=e({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Ne=e({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),Ae=e({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),xe=e({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Ce=e({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Se=e({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),De=e({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Le=e({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ue=e({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),be=e({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),Me=e({slug:"release-not-found",category:"SERVER",status:404,title:"No active release found",suggestion:"Deploy the project to create a release for this environment"}),Pe=e({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),Ve=e({slug:"client-boundary-violation",category:"BOUNDARY",status:400,title:"Client boundary rule violation",suggestion:"Add \'use client\' directive or move code to a client component"}),Fe=e({slug:"server-only-in-client",category:"BOUNDARY",status:400,title:"Server-only code in client component",suggestion:"Move server-only code to a server component"}),ke=e({slug:"client-only-in-server",category:"BOUNDARY",status:400,title:"Client-only code in server component",suggestion:"Move client-only code to a client component"}),we=e({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),Ge=e({slug:"invalid-use-server",category:"BOUNDARY",status:400,title:"Invalid \'use server\' directive",suggestion:"Place \'use server\' at the top of the file or function"}),He=e({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),$e=e({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),Be=e({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Ye=e({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),je=e({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),qe=e({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),ze=e({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),We=e({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),Xe=e({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),Je=e({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),Ke=e({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),Ze=e({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),Qe=e({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),et=e({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),tt=e({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),rt=e({slug:"cost-limit-exceeded",category:"AGENT",status:429,title:"Cost limit exceeded",suggestion:"Wait for the budget period to reset or increase the limit"}),ot=e({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),st=e({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),nt=e({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),it=e({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),at=e({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),ct=e({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),lt=e({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),ut=e({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),_=e({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),gt=e({slug:"input-validation-failed",category:"GENERAL",status:400,title:"Input validation failed",suggestion:"Check request input against validation rules"});var C=[{pattern:/<script[^>]*>[\\s\\S]*?<\\/script>/gi,name:"inline script"},{pattern:/javascript:/gi,name:"javascript: URL"},{pattern:/\\bon\\w+\\s*=/gi,name:"event handler attribute"},{pattern:/data:\\s*text\\/html/gi,name:"data: HTML URL"}];function S(){let r=globalThis;return r.__VERYFRONT_DEV__===!0||r.Deno?.env?.get?.("VERYFRONT_ENV")==="development"}function y(r,t={}){let{strict:o=!1,warn:n=!0}=t;for(let{pattern:i,name:c}of C)if(i.lastIndex=0,!!i.test(r)&&(n&&console.warn(`[Security] Suspicious ${c} detected in server HTML`),o||!S()))throw _.create({detail:`Potentially unsafe HTML: ${c} detected`});return r}var E=class{constructor(t,o){this.prefix=t;this.level=o}log(t,o,n,...i){this.level>t||o?.(n,...i)}debug(t,...o){this.log(0,console.debug,`[${this.prefix}] DEBUG: ${t}`,...o)}info(t,...o){this.log(1,console.log,`[${this.prefix}] ${t}`,...o)}warn(t,...o){this.log(2,console.warn,`[${this.prefix}] WARN: ${t}`,...o)}error(t,...o){this.log(3,console.error,`[${this.prefix}] ERROR: ${t}`,...o)}};function D(){if(typeof window>"u")return 2;let r=globalThis;return r.__VERYFRONT_DEV__||r.__RSC_DEV__?r.__VERYFRONT_DEBUG__||r.__RSC_DEBUG__?0:1:2}var R=D(),d=new E("RSC",R),mt=new E("PREFETCH",R),_t=new E("HYDRATE",R),yt=new E("VERYFRONT",R);var s="/_veryfront",m={RSC:`${s}/rsc/`,FS:`${s}/fs/`,MODULES:`${s}/modules/`,PAGES:`${s}/pages/`,DATA:`${s}/data/`,LIB:`${s}/lib/`,CHUNKS:`${s}/chunks/`,CLIENT:`${s}/client/`},O={HMR_RUNTIME:`${s}/hmr-runtime.js`,HMR:`${s}/hmr.js`,HYDRATE:`${s}/hydrate.js`,ERROR_OVERLAY:`${s}/error-overlay.js`,DEV_LOADER:`${s}/dev-loader.js`,CLIENT_LOG:`${s}/log`,CLIENT_JS:`${s}/client.js`,ROUTER_JS:`${s}/router.js`,PREFETCH_JS:`${s}/prefetch.js`,MANIFEST_JSON:`${s}/manifest.json`,APP_JS:`${s}/app.js`,RSC_CLIENT:`${s}/rsc/client.js`,RSC_MANIFEST:`${s}/rsc/manifest`,RSC_STREAM:`${s}/rsc/stream`,RSC_PAYLOAD:`${s}/rsc/payload`,RSC_RENDER:`${s}/rsc/render`,RSC_PAGE:`${s}/rsc/page`,RSC_MODULE:`${s}/rsc/module`,RSC_DOM:`${s}/rsc/dom.js`,RSC_HYDRATOR:`${s}/rsc/hydrator.js`,RSC_HYDRATE_CLIENT:`${s}/rsc/hydrate-client.js`,LIB_AI_REACT:`${s}/lib/ai/react.js`,LIB_AI_COMPONENTS:`${s}/lib/ai/components.js`,LIB_AI_PRIMITIVES:`${s}/lib/ai/primitives.js`};var U={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},vt=U.CACHE;var Nt={HMR_RUNTIME:O.HMR_RUNTIME,ERROR_OVERLAY:O.ERROR_OVERLAY};var St=m.RSC,Dt=m.FS;var I="rsc-root";function h(r,t){let o=t==="root"?I:`rsc-slot-${t}`,n=r.getElementById(o);if(n)return n;let i=r.createElement("div");return i.id=o,r.body.appendChild(i),i}function b(r,t){if(t.type!=="slot")return;let o=h(r,t.id);o.innerHTML=y(String(t.html??""))}function T(r,t){let o=t.split(`\n`),n=o.pop()??"";for(let i of o){let c=i.trim();if(!c)continue;let g;try{g=JSON.parse(c)}catch(p){d.debug("[client-dom] malformed NDJSON line",{line:c,error:p instanceof Error?p.message:String(p)});continue}if(!g||typeof g!="object")continue;let l=g;if(l.type==="slot"){b(r,l);try{V(r,l.id||"root")}catch(p){d.debug("[client-dom] hydration optional failed",p)}}}return n}function M(r){return new Promise((t,o)=>{let n=()=>o(new DOMException("aborted","AbortError"));if(r.aborted){n();return}r.addEventListener("abort",n,{once:!0})})}async function Pt(r,t=document,o){let n="body"in r?r:null,i=n?.body??r;if(!i)return;let c=i.getReader(),g=new TextDecoder,l="",p=!1;try{for(;;){if(o?.aborted)throw new DOMException("aborted","AbortError");let a=c.read(),{done:v,value:N}=o?await Promise.race([a,M(o)]):await a;if(v){p=!0;break}l+=g.decode(N,{stream:!0}),l=T(t,l)}l&&T(t,`${l}\n`)}catch(a){throw a instanceof Error&&a.name==="AbortError"||d.debug("[client-dom] consumeNdjsonStream error",a),a}finally{try{await c.cancel()}catch(a){p||d.debug("[client-dom] reader.cancel failed",a)}try{c.releaseLock()}catch(a){d.debug("[client-dom] reader.releaseLock failed",a)}if(typeof i.cancel=="function")try{await i.cancel()}catch(a){d.debug("[client-dom] stream.cancel failed",a)}if(typeof n?.body?.cancel=="function")try{await n.body.cancel()}catch(a){d.debug("[client-dom] response.body.cancel failed",a)}}}function P(r,t){let o=h(r,t),n=[],i=c=>{let g=c;g.dataset?.clientRef&&n.push(g);for(let l of c.children)i(l)};return i(o),n}function V(r,t){let o=P(r,t);for(let n of o){let i=n.dataset?.clientRef;i&&(n.dataset.hydrated="true",d.debug("[client-dom] marked for hydration",i))}}export{Pt as consumeNdjsonStream,h as getContainer};\n';
@@ -20,4 +20,5 @@ export interface RSCEndpointParams {
20
20
  projectId?: string;
21
21
  adapter: RuntimeAdapter;
22
22
  config?: VeryfrontConfig;
23
+ nonce?: string;
23
24
  }
@@ -44,8 +44,8 @@ export class RSCDevServerHandler {
44
44
  return this.streamHandler.handle(pathname, searchParams);
45
45
  }
46
46
 
47
- handlePage(pathname: string, searchParams: URLSearchParams): dntShim.Response {
48
- return this.pageHandler.handle(pathname, searchParams);
47
+ handlePage(pathname: string, searchParams: URLSearchParams, nonce?: string): dntShim.Response {
48
+ return this.pageHandler.handle(pathname, searchParams, nonce);
49
49
  }
50
50
 
51
51
  handleHydratorScript(): Promise<dntShim.Response> {
@@ -1,16 +1,19 @@
1
1
  import * as dntShim from "../../../../../_dnt.shims.js";
2
+ import { buildNonceAttribute } from "../../../../html/html-escape.js";
3
+
2
4
  export class PageHandler {
3
- handle(pathname: string, searchParams: URLSearchParams): dntShim.Response {
4
- const html = this.buildHtml(pathname, searchParams);
5
+ handle(pathname: string, searchParams: URLSearchParams, nonce?: string): dntShim.Response {
6
+ const html = this.buildHtml(pathname, searchParams, nonce);
5
7
 
6
8
  return new dntShim.Response(html, {
7
9
  headers: { "content-type": "text/html; charset=utf-8" },
8
10
  });
9
11
  }
10
12
 
11
- private buildHtml(pathname: string, searchParams: URLSearchParams): string {
13
+ private buildHtml(pathname: string, searchParams: URLSearchParams, nonce?: string): string {
12
14
  const queryString = searchParams.toString();
13
15
  const renderUrl = `/_veryfront/rsc/render${pathname}${queryString ? `?${queryString}` : ""}`;
16
+ const nonceAttr = buildNonceAttribute(nonce);
14
17
 
15
18
  return `<!DOCTYPE html>
16
19
  <html lang="en">
@@ -18,11 +21,11 @@ export class PageHandler {
18
21
  <meta charset="UTF-8"/>
19
22
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
20
23
  <title>Veryfront RSC</title>
21
- <script>window.__VERYFRONT_DEV__ = true;</script>
24
+ <script${nonceAttr}>window.__VERYFRONT_DEV__ = true;</script>
22
25
  </head>
23
26
  <body>
24
27
  <div id="rsc-root"></div>
25
- <script type="module">
28
+ <script type="module"${nonceAttr}>
26
29
  await import('/_veryfront/rsc/hydrate.js').catch(() => void 0);
27
30
 
28
31
  async function fetchPayload(url) {
@@ -1,6 +1,10 @@
1
1
  import { getEsbuild } from "../../platform/compat/esbuild.js";
2
2
  import { join } from "../../platform/compat/path/index.js";
3
3
  import { createFileSystem } from "../../platform/compat/fs.js";
4
+ import {
5
+ isFrameworkSourcePath,
6
+ resolveRelativeFrameworkSourceImport,
7
+ } from "../../platform/compat/framework-source-resolver.js";
4
8
  import type { RuntimeAdapter } from "../../platform/adapters/base.js";
5
9
  import { isCrossProjectImport, parseCrossProjectImport } from "./path-resolver.js";
6
10
  import { parseImports } from "./lexer.js";
@@ -138,6 +142,14 @@ async function resolveLocalImportPath(
138
142
  importSpecifier: string,
139
143
  adapter?: RuntimeAdapter,
140
144
  ): Promise<string | null> {
145
+ if (isFrameworkSourcePath(fromFile)) {
146
+ const resolvedFrameworkImport = await resolveRelativeFrameworkSourceImport(
147
+ importSpecifier,
148
+ fromFile,
149
+ );
150
+ if (resolvedFrameworkImport) return resolvedFrameworkImport;
151
+ }
152
+
141
153
  const fromDir = fromFile.substring(0, fromFile.lastIndexOf("/"));
142
154
  const basePath = resolveRelative(fromDir, importSpecifier);
143
155
 
@@ -8,6 +8,7 @@
8
8
  import { createFileSystem, exists } from "../../../../platform/compat/fs.js";
9
9
  import { join } from "../../../../platform/compat/path/index.js";
10
10
  import { rendererLogger as logger } from "../../../../utils/index.js";
11
+ import { resolveRelativeFrameworkSourceImport } from "../../../../platform/compat/framework-source-resolver.js";
11
12
  import { resolveInternalModuleTarget } from "../../../veryfront-module-urls.js";
12
13
  import {
13
14
  EMBEDDED_SRC_DIR,
@@ -201,75 +202,15 @@ export async function resolveVeryfrontSourcePath(
201
202
  export async function resolveRelativeFrameworkImport(
202
203
  specifier: string,
203
204
  fromSourcePath: string,
204
- _fs: ReturnType<typeof createFileSystem>,
205
+ fs: ReturnType<typeof createFileSystem>,
205
206
  existsFn: (path: string) => Promise<boolean> = exists,
206
207
  ): Promise<string | null> {
207
- const fromDir = fromSourcePath.substring(0, fromSourcePath.lastIndexOf("/"));
208
- const parts = fromDir.split("/").filter(Boolean);
209
- const importParts = specifier.split("/").filter(Boolean);
210
-
211
- for (const part of importParts) {
212
- if (part === "..") {
213
- parts.pop();
214
- } else if (part !== ".") {
215
- parts.push(part);
216
- }
217
- }
218
-
219
- const basePath = "/" + parts.join("/");
220
-
221
- // If specifier already has extension (e.g., ./Head.tsx), we need to try:
222
- // 1. The exact path (basePath)
223
- // 2. The path with .src suffix (basePath.src) for embedded sources
224
- // 3. For transpiled .js/.mjs imports, fall back to sibling TS/TSX/JSX sources
225
- if (/\.(tsx?|jsx?|mjs)$/.test(specifier)) {
226
- const explicitCandidates = [basePath, `${basePath}.src`];
227
-
228
- // esbuild rewrites TS/TSX relative imports to .js in transformed output.
229
- // When the original source only exists as .ts/.tsx (or embedded .src),
230
- // probe those sibling source extensions before giving up.
231
- if (basePath.endsWith(".js") || basePath.endsWith(".mjs")) {
232
- const stem = basePath.replace(/\.(?:m?js)$/, "");
233
- for (const ext of [".ts", ".tsx", ".jsx", ".js", ".mjs"]) {
234
- explicitCandidates.push(`${stem}${ext}.src`, `${stem}${ext}`);
235
- }
236
- }
237
-
238
- for (const candidate of explicitCandidates) {
239
- try {
240
- if (await existsFn(candidate)) return candidate;
241
- } catch (_) {
242
- /* expected: file may not exist at this path */
243
- }
244
- }
245
-
246
- return null;
247
- }
248
-
249
- // No extension provided - try all extensions (including .src for embedded sources)
250
- const allExtensions = [
251
- ...EXTENSIONS.map((ext) => ext + ".src"),
252
- ...EXTENSIONS,
253
- ];
254
-
255
- for (const ext of allExtensions) {
256
- const pathWithExt = basePath + ext;
257
- try {
258
- if (await existsFn(pathWithExt)) return pathWithExt;
259
- } catch (_) {
260
- /* expected: file may not exist at this path */
261
- }
262
- }
263
-
264
- // Try index file
265
- for (const ext of allExtensions) {
266
- const indexPath = join(basePath, "index" + ext);
267
- try {
268
- if (await existsFn(indexPath)) return indexPath;
269
- } catch (_) {
270
- /* expected: file may not exist at this path */
271
- }
272
- }
273
-
274
- return null;
208
+ return await resolveRelativeFrameworkSourceImport(specifier, fromSourcePath, {
209
+ fileSystem: fs,
210
+ exists: existsFn,
211
+ extensions: [
212
+ ...EXTENSIONS.map((ext) => `${ext}.src`),
213
+ ...EXTENSIONS,
214
+ ],
215
+ });
275
216
  }
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.129";
3
+ export const VERSION = "0.1.131";