veryfront 0.1.246 → 0.1.248
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.
- package/esm/cli/mcp/tools/project-tools.d.ts +1 -1
- package/esm/cli/mcp/tools/scaffold-tools.d.ts +2 -2
- package/esm/cli/shared/server-startup.d.ts.map +1 -1
- package/esm/cli/shared/server-startup.js +8 -0
- package/esm/deno.d.ts +0 -9
- package/esm/deno.js +5 -12
- package/esm/src/agent/durable.d.ts +67 -0
- package/esm/src/agent/durable.d.ts.map +1 -1
- package/esm/src/agent/durable.js +134 -0
- package/esm/src/agent/index.d.ts +1 -1
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +1 -1
- package/esm/src/embedding/upload-loader.d.ts +2 -2
- package/esm/src/embedding/upload-loader.d.ts.map +1 -1
- package/esm/src/embedding/upload-loader.js +11 -48
- package/esm/src/errors/middleware/cli-error-boundary.js +1 -1
- package/esm/src/errors/middleware/http-error-boundary.js +1 -1
- package/esm/src/errors/tracing.d.ts +3 -3
- package/esm/src/errors/tracing.d.ts.map +1 -1
- package/esm/src/errors/tracing.js +3 -3
- package/esm/src/extensions/interfaces/index.d.ts +2 -2
- package/esm/src/extensions/interfaces/index.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/node-compat.d.ts +68 -10
- package/esm/src/extensions/interfaces/node-compat.d.ts.map +1 -1
- package/esm/src/extensions/interfaces/tracing-exporter.d.ts +35 -1
- package/esm/src/extensions/interfaces/tracing-exporter.d.ts.map +1 -1
- package/esm/src/integrations/schema.d.ts +10 -10
- package/esm/src/mcp/index.d.ts +7 -2
- package/esm/src/mcp/index.d.ts.map +1 -1
- package/esm/src/mcp/index.js +7 -2
- package/esm/src/mcp/schemas/index.d.ts +1 -1
- package/esm/src/mcp/schemas/index.d.ts.map +1 -1
- package/esm/src/mcp/schemas/index.js +1 -1
- package/esm/src/mcp/schemas/mcp.schema.d.ts +13 -7
- package/esm/src/mcp/schemas/mcp.schema.d.ts.map +1 -1
- package/esm/src/mcp/schemas/mcp.schema.js +17 -7
- package/esm/src/mcp/server.d.ts +13 -0
- package/esm/src/mcp/server.d.ts.map +1 -1
- package/esm/src/mcp/server.js +43 -6
- package/esm/src/observability/auto-instrument/http-instrumentation.js +1 -1
- package/esm/src/observability/auto-instrument/react-instrumentation.js +1 -1
- package/esm/src/observability/instruments/build-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/build-instruments.d.ts.map +1 -1
- package/esm/src/observability/instruments/cache-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/cache-instruments.d.ts.map +1 -1
- package/esm/src/observability/instruments/data-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/data-instruments.d.ts.map +1 -1
- package/esm/src/observability/instruments/error-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/error-instruments.d.ts.map +1 -1
- package/esm/src/observability/instruments/http-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/http-instruments.d.ts.map +1 -1
- package/esm/src/observability/instruments/instruments-factory.d.ts +1 -1
- package/esm/src/observability/instruments/instruments-factory.d.ts.map +1 -1
- package/esm/src/observability/instruments/memory-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/memory-instruments.d.ts.map +1 -1
- package/esm/src/observability/instruments/render-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/render-instruments.d.ts.map +1 -1
- package/esm/src/observability/instruments/rsc-instruments.d.ts +1 -1
- package/esm/src/observability/instruments/rsc-instruments.d.ts.map +1 -1
- package/esm/src/observability/metrics/manager.d.ts.map +1 -1
- package/esm/src/observability/metrics/manager.js +10 -2
- package/esm/src/observability/metrics/types.d.ts +1 -1
- package/esm/src/observability/metrics/types.d.ts.map +1 -1
- package/esm/src/observability/simple-metrics/otel-instruments.d.ts.map +1 -1
- package/esm/src/observability/simple-metrics/otel-instruments.js +7 -2
- package/esm/src/observability/simple-metrics/types.d.ts +1 -1
- package/esm/src/observability/simple-metrics/types.d.ts.map +1 -1
- package/esm/src/observability/tracing/api-shim.d.ts +177 -0
- package/esm/src/observability/tracing/api-shim.d.ts.map +1 -0
- package/esm/src/observability/tracing/api-shim.js +234 -0
- package/esm/src/observability/tracing/manager.d.ts.map +1 -1
- package/esm/src/observability/tracing/manager.js +29 -4
- package/esm/src/observability/tracing/otlp-setup.d.ts +12 -8
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
- package/esm/src/observability/tracing/otlp-setup.js +59 -136
- package/esm/src/observability/tracing/types.d.ts +1 -1
- package/esm/src/observability/tracing/types.d.ts.map +1 -1
- package/esm/src/platform/compat/kv/factory.d.ts.map +1 -1
- package/esm/src/platform/compat/kv/factory.js +15 -6
- package/esm/src/platform/compat/opaque-deps.d.ts +6 -5
- package/esm/src/platform/compat/opaque-deps.d.ts.map +1 -1
- package/esm/src/platform/compat/opaque-deps.js +13 -37
- package/esm/src/proxy/tracing.d.ts +7 -2
- package/esm/src/proxy/tracing.d.ts.map +1 -1
- package/esm/src/proxy/tracing.js +31 -96
- package/esm/src/rendering/rsc/client-module-strategy.d.ts.map +1 -1
- package/esm/src/rendering/rsc/client-module-strategy.js +9 -1
- package/esm/src/server/bootstrap.d.ts.map +1 -1
- package/esm/src/server/bootstrap.js +27 -1
- package/esm/src/server/context/request-context.d.ts.map +1 -1
- package/esm/src/server/context/request-context.js +7 -4
- package/esm/src/server/dev-server/middleware.js +1 -1
- package/esm/src/server/handlers/dev/files/dev-file.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/files/dev-file.handler.js +4 -14
- package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
- package/esm/src/server/services/rendering/ssr.service.js +4 -1
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/workflow/claude-code/workspace-sync.d.ts +17 -2
- package/esm/src/workflow/claude-code/workspace-sync.d.ts.map +1 -1
- package/esm/src/workflow/claude-code/workspace-sync.js +106 -19
- package/esm/src/workflow/schemas/workflow.schema.d.ts +3 -3
- package/package.json +1 -9
- package/src/cli/shared/server-startup.ts +8 -0
- package/src/deno.js +5 -12
- package/src/src/agent/durable.ts +237 -0
- package/src/src/agent/index.ts +4 -0
- package/src/src/cache/backends/factory.ts +1 -1
- package/src/src/cache/backends/redis.ts +1 -1
- package/src/src/cache/keys/utils.ts +1 -1
- package/src/src/cache/registry.ts +1 -1
- package/src/src/data/static-paths-fetcher.ts +1 -1
- package/src/src/embedding/upload-loader.ts +14 -63
- package/src/src/errors/middleware/cli-error-boundary.ts +1 -1
- package/src/src/errors/middleware/http-error-boundary.ts +1 -1
- package/src/src/errors/tracing.ts +4 -4
- package/src/src/extensions/interfaces/index.ts +7 -2
- package/src/src/extensions/interfaces/node-compat.ts +74 -10
- package/src/src/extensions/interfaces/tracing-exporter.ts +36 -1
- package/src/src/mcp/index.ts +7 -2
- package/src/src/mcp/schemas/index.ts +1 -0
- package/src/src/mcp/schemas/mcp.schema.ts +20 -7
- package/src/src/mcp/server.ts +60 -6
- package/src/src/observability/auto-instrument/http-instrumentation.ts +1 -1
- package/src/src/observability/auto-instrument/react-instrumentation.ts +1 -1
- package/src/src/observability/auto-instrument/wrappers.ts +1 -1
- package/src/src/observability/instruments/build-instruments.ts +1 -1
- package/src/src/observability/instruments/cache-instruments.ts +6 -1
- package/src/src/observability/instruments/data-instruments.ts +1 -1
- package/src/src/observability/instruments/error-instruments.ts +1 -1
- package/src/src/observability/instruments/http-instruments.ts +6 -1
- package/src/src/observability/instruments/instruments-factory.ts +1 -1
- package/src/src/observability/instruments/memory-instruments.ts +5 -1
- package/src/src/observability/instruments/render-instruments.ts +1 -1
- package/src/src/observability/instruments/rsc-instruments.ts +1 -1
- package/src/src/observability/metrics/manager.ts +11 -3
- package/src/src/observability/metrics/types.ts +7 -1
- package/src/src/observability/simple-metrics/otel-instruments.ts +7 -2
- package/src/src/observability/simple-metrics/types.ts +1 -1
- package/src/src/observability/tracing/api-shim.ts +409 -0
- package/src/src/observability/tracing/manager.ts +29 -4
- package/src/src/observability/tracing/otlp-setup.ts +76 -168
- package/src/src/observability/tracing/types.ts +1 -1
- package/src/src/platform/compat/kv/factory.ts +18 -7
- package/src/src/platform/compat/opaque-deps.ts +16 -44
- package/src/src/proxy/tracing.ts +43 -117
- package/src/src/rendering/rsc/client-module-strategy.ts +9 -1
- package/src/src/server/bootstrap.ts +38 -1
- package/src/src/server/context/request-context.ts +10 -7
- package/src/src/server/dev-server/middleware.ts +1 -1
- package/src/src/server/handlers/dev/files/dev-file.handler.ts +4 -22
- package/src/src/server/services/rendering/ssr.service.ts +4 -1
- package/src/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +1 -1
- package/src/src/utils/version-constant.ts +1 -1
- package/src/src/workflow/claude-code/workspace-sync.ts +109 -20
- package/esm/src/utils/logger/trace-bridge.d.ts +0 -11
- package/esm/src/utils/logger/trace-bridge.d.ts.map +0 -1
- package/esm/src/utils/logger/trace-bridge.js +0 -12
- package/src/src/utils/logger/trace-bridge.ts +0 -14
package/src/src/proxy/tracing.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
/****
|
|
2
2
|
* OpenTelemetry OTLP tracing for proxy.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Uses the core api-shim for in-process tracing; when ext-opentelemetry
|
|
5
|
+
* is loaded, the shim delegates to the real SDK provider.
|
|
6
|
+
*
|
|
7
|
+
* Env: OTEL_TRACES_ENABLED, OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
8
|
+
* OTEL_EXPORTER_OTLP_HEADERS
|
|
4
9
|
*/
|
|
5
10
|
|
|
6
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
type Context,
|
|
13
|
+
context as shimContext,
|
|
14
|
+
defaultTextMapGetter,
|
|
15
|
+
defaultTextMapSetter,
|
|
16
|
+
propagation as shimPropagation,
|
|
17
|
+
type Span,
|
|
18
|
+
SpanKind,
|
|
19
|
+
SpanStatusCode,
|
|
20
|
+
trace as shimTrace,
|
|
21
|
+
type Tracer,
|
|
22
|
+
} from "../observability/tracing/api-shim.js";
|
|
7
23
|
import { getEnv } from "./env.js";
|
|
8
24
|
import { proxyLogger } from "./logger.js";
|
|
9
|
-
import { PROXY_RUNTIME_VERSION } from "./version.js";
|
|
10
25
|
|
|
11
26
|
let initialized = false;
|
|
12
|
-
let tracerProvider: { shutdown: () => Promise<void> } | null = null;
|
|
13
27
|
let tracer: Tracer | null = null;
|
|
14
28
|
|
|
15
29
|
interface OTLPConfig {
|
|
@@ -31,21 +45,6 @@ function parseHeaders(headerString: string | undefined): Record<string, string>
|
|
|
31
45
|
return headers;
|
|
32
46
|
}
|
|
33
47
|
|
|
34
|
-
/**
|
|
35
|
-
* Parse OTEL_RESOURCE_ATTRIBUTES env var (key=value,key2=value2 format).
|
|
36
|
-
*/
|
|
37
|
-
function parseResourceAttributes(attrString: string | undefined): Record<string, string> {
|
|
38
|
-
if (!attrString) return {};
|
|
39
|
-
const attrs: Record<string, string> = {};
|
|
40
|
-
for (const part of attrString.split(",")) {
|
|
41
|
-
const [key, ...valueParts] = part.split("=");
|
|
42
|
-
if (key && valueParts.length > 0) {
|
|
43
|
-
attrs[key.trim()] = valueParts.join("=").trim();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return attrs;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
48
|
function getConfig(): OTLPConfig {
|
|
50
49
|
return {
|
|
51
50
|
enabled: getEnv("OTEL_TRACES_ENABLED") === "true",
|
|
@@ -55,15 +54,6 @@ function getConfig(): OTLPConfig {
|
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
let traceApi: typeof import("@opentelemetry/api") | null = null;
|
|
59
|
-
let propagationApi: typeof import("@opentelemetry/core") | null = null;
|
|
60
|
-
|
|
61
|
-
async function loadApis(): Promise<void> {
|
|
62
|
-
if (traceApi) return;
|
|
63
|
-
traceApi = await import("@opentelemetry/api");
|
|
64
|
-
propagationApi = await import("@opentelemetry/core");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
57
|
export async function initializeOTLPWithApis(): Promise<void> {
|
|
68
58
|
if (initialized) return;
|
|
69
59
|
|
|
@@ -81,42 +71,12 @@ export async function initializeOTLPWithApis(): Promise<void> {
|
|
|
81
71
|
}
|
|
82
72
|
|
|
83
73
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
88
|
-
const { OTLPTraceExporter } = await import("@opentelemetry/exporter-trace-otlp-http");
|
|
89
|
-
const { resourceFromAttributes } = await import("@opentelemetry/resources");
|
|
90
|
-
const { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } = await import(
|
|
91
|
-
"@opentelemetry/semantic-conventions"
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const resourceAttrs = parseResourceAttributes(getEnv("OTEL_RESOURCE_ATTRIBUTES"));
|
|
95
|
-
const resource = resourceFromAttributes({
|
|
96
|
-
[ATTR_SERVICE_NAME]: config.serviceName,
|
|
97
|
-
[ATTR_SERVICE_VERSION]: PROXY_RUNTIME_VERSION,
|
|
98
|
-
...resourceAttrs,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const exporter = new OTLPTraceExporter({
|
|
102
|
-
url: `${config.endpoint}/v1/traces`,
|
|
103
|
-
headers: config.headers,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const provider = new BasicTracerProvider({
|
|
107
|
-
resource,
|
|
108
|
-
spanProcessors: [new BatchSpanProcessor(exporter)],
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// In OTel SDK v2, provider.register() is removed.
|
|
112
|
-
trace.setGlobalTracerProvider(provider);
|
|
113
|
-
|
|
114
|
-
tracerProvider = provider;
|
|
115
|
-
tracer = trace.getTracer(config.serviceName);
|
|
74
|
+
// The shim's provider is wired by ext-opentelemetry via bootstrap.ts.
|
|
75
|
+
// We simply get a tracer from the shim — it delegates to the real SDK
|
|
76
|
+
// when the extension is active, otherwise returns the no-op tracer.
|
|
77
|
+
tracer = shimTrace.getTracer(config.serviceName);
|
|
116
78
|
initialized = true;
|
|
117
79
|
|
|
118
|
-
await loadApis();
|
|
119
|
-
|
|
120
80
|
proxyLogger.info("[otel] Initialized", {
|
|
121
81
|
serviceName: config.serviceName,
|
|
122
82
|
endpoint: config.endpoint,
|
|
@@ -128,51 +88,22 @@ export async function initializeOTLPWithApis(): Promise<void> {
|
|
|
128
88
|
}
|
|
129
89
|
|
|
130
90
|
export async function shutdownOTLP(): Promise<void> {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
await tracerProvider.shutdown();
|
|
135
|
-
proxyLogger.info("[otel] Shutdown complete");
|
|
136
|
-
} catch (error) {
|
|
137
|
-
proxyLogger.error("[otel] Shutdown error", error);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function getPropagator(): import("@opentelemetry/core").W3CTraceContextPropagator | null {
|
|
142
|
-
if (!propagationApi) return null;
|
|
143
|
-
return new propagationApi.W3CTraceContextPropagator();
|
|
91
|
+
proxyLogger.info("[otel] Shutdown complete");
|
|
144
92
|
}
|
|
145
93
|
|
|
146
94
|
export function extractContext(headers: Headers): Context | undefined {
|
|
147
|
-
if (!traceApi) return undefined;
|
|
148
|
-
|
|
149
|
-
const propagator = getPropagator();
|
|
150
|
-
if (!propagator) return undefined;
|
|
151
|
-
|
|
152
95
|
const carrier: Record<string, string> = {};
|
|
153
96
|
headers.forEach((v, k) => {
|
|
154
97
|
carrier[k.toLowerCase()] = v;
|
|
155
98
|
});
|
|
156
99
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
carrier,
|
|
160
|
-
traceApi.defaultTextMapGetter,
|
|
161
|
-
);
|
|
100
|
+
const extracted = shimPropagation.extract(shimContext.active(), carrier, defaultTextMapGetter);
|
|
101
|
+
return extracted;
|
|
162
102
|
}
|
|
163
103
|
|
|
164
104
|
export function injectContext(headers: Headers): void {
|
|
165
|
-
if (!traceApi) return;
|
|
166
|
-
|
|
167
|
-
const propagator = getPropagator();
|
|
168
|
-
if (!propagator) return;
|
|
169
|
-
|
|
170
105
|
const carrier: Record<string, string> = {};
|
|
171
|
-
|
|
172
|
-
traceApi.context.active(),
|
|
173
|
-
carrier,
|
|
174
|
-
traceApi.defaultTextMapSetter,
|
|
175
|
-
);
|
|
106
|
+
shimPropagation.inject(shimContext.active(), carrier, defaultTextMapSetter);
|
|
176
107
|
|
|
177
108
|
for (const [k, v] of Object.entries(carrier)) {
|
|
178
109
|
headers.set(k, v);
|
|
@@ -184,43 +115,38 @@ export function startServerSpan(
|
|
|
184
115
|
path: string,
|
|
185
116
|
parentContext?: Context,
|
|
186
117
|
): { span: Span; context: Context } | null {
|
|
187
|
-
if (!
|
|
118
|
+
if (!tracer) return null;
|
|
188
119
|
|
|
189
|
-
const ctx = parentContext ??
|
|
190
|
-
const span = tracer.startSpan(`${method} ${path}`, { kind:
|
|
191
|
-
return { span, context:
|
|
120
|
+
const ctx = parentContext ?? shimContext.active();
|
|
121
|
+
const span = tracer.startSpan(`${method} ${path}`, { kind: SpanKind.SERVER }, ctx);
|
|
122
|
+
return { span, context: shimTrace.setSpan(ctx, span) };
|
|
192
123
|
}
|
|
193
124
|
|
|
194
125
|
export function endSpan(span: Span | undefined, statusCode: number, error?: Error): void {
|
|
195
|
-
if (!span
|
|
126
|
+
if (!span) return;
|
|
196
127
|
|
|
197
128
|
span.setAttribute("http.status_code", statusCode);
|
|
198
129
|
|
|
199
130
|
if (error) {
|
|
200
|
-
span.setStatus({ code:
|
|
131
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
201
132
|
span.recordException(error);
|
|
202
133
|
span.end();
|
|
203
134
|
return;
|
|
204
135
|
}
|
|
205
136
|
|
|
206
137
|
if (statusCode >= 400) {
|
|
207
|
-
span.setStatus({ code:
|
|
138
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
208
139
|
}
|
|
209
140
|
|
|
210
141
|
span.end();
|
|
211
142
|
}
|
|
212
143
|
|
|
213
144
|
export function withContext<T>(spanContext: Context, fn: () => Promise<T>): Promise<T> {
|
|
214
|
-
|
|
215
|
-
return traceApi.context.with(spanContext, fn);
|
|
145
|
+
return shimContext.with(spanContext, fn);
|
|
216
146
|
}
|
|
217
147
|
|
|
218
|
-
function getActiveSpanContext():
|
|
219
|
-
|
|
220
|
-
| null {
|
|
221
|
-
if (!traceApi) return null;
|
|
222
|
-
|
|
223
|
-
const activeSpan = traceApi.trace.getSpan(traceApi.context.active());
|
|
148
|
+
function getActiveSpanContext(): { traceId: string; spanId: string } | null {
|
|
149
|
+
const activeSpan = shimTrace.getActiveSpan?.();
|
|
224
150
|
return activeSpan ? activeSpan.spanContext() : null;
|
|
225
151
|
}
|
|
226
152
|
|
|
@@ -249,24 +175,24 @@ export async function withSpan<T>(
|
|
|
249
175
|
fn: () => Promise<T>,
|
|
250
176
|
attributes?: Record<string, string | number | boolean>,
|
|
251
177
|
): Promise<T> {
|
|
252
|
-
if (!
|
|
178
|
+
if (!tracer) return await fn();
|
|
253
179
|
|
|
254
|
-
const parentContext =
|
|
180
|
+
const parentContext = shimContext.active();
|
|
255
181
|
const span = tracer.startSpan(
|
|
256
182
|
name,
|
|
257
|
-
{ kind:
|
|
183
|
+
{ kind: SpanKind.INTERNAL, attributes },
|
|
258
184
|
parentContext,
|
|
259
185
|
);
|
|
260
186
|
|
|
261
|
-
const spanContext =
|
|
187
|
+
const spanContext = shimTrace.setSpan(parentContext, span);
|
|
262
188
|
|
|
263
189
|
try {
|
|
264
|
-
const result = await
|
|
265
|
-
span.setStatus({ code:
|
|
190
|
+
const result = await shimContext.with(spanContext, fn);
|
|
191
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
266
192
|
return result;
|
|
267
193
|
} catch (error) {
|
|
268
194
|
span.setStatus({
|
|
269
|
-
code:
|
|
195
|
+
code: SpanStatusCode.ERROR,
|
|
270
196
|
message: error instanceof Error ? error.message : String(error),
|
|
271
197
|
});
|
|
272
198
|
if (error instanceof Error) span.recordException(error);
|
|
@@ -33,7 +33,15 @@ export interface ClientModuleUrlOptions {
|
|
|
33
33
|
export function determineClientModuleStrategy(
|
|
34
34
|
options: ClientModuleStrategyOptions,
|
|
35
35
|
): ClientModuleStrategy {
|
|
36
|
-
|
|
36
|
+
// Only emit the `fs` strategy when the server is backed by a real on-disk
|
|
37
|
+
// project (server-trusted `isLocalProject` signal). The `/_veryfront/fs/`
|
|
38
|
+
// handler that serves those modules was narrowed to local projects only
|
|
39
|
+
// under VULN-SRV-1/2: honoring a client-reachable `environment === "preview"`
|
|
40
|
+
// here would advertise a dev-only endpoint that returns 404 in preview pods
|
|
41
|
+
// and — more importantly — mixes the preview-mode signal (environment) with
|
|
42
|
+
// the local-filesystem signal (isLocalProject). Preview pods serve the same
|
|
43
|
+
// compiled client modules as production, via the RSC module endpoint.
|
|
44
|
+
return options.isLocalProject ? "fs" : "rsc-module";
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
export function readHydrationData(
|
|
@@ -2,7 +2,13 @@ import type { RuntimeAdapter } from "../platform/adapters/base.js";
|
|
|
2
2
|
import type { VeryfrontConfig } from "../config/index.js";
|
|
3
3
|
import type { InvalidationProjectContext } from "../platform/adapters/fs/veryfront/types.js";
|
|
4
4
|
import { clearConfigCache, getConfig } from "../config/index.js";
|
|
5
|
-
import { type ExtensionLoader, orchestrateExtensions } from "../extensions/index.js";
|
|
5
|
+
import { type ExtensionLoader, orchestrateExtensions, tryResolve } from "../extensions/index.js";
|
|
6
|
+
import type { TracingExporter } from "../extensions/interfaces/tracing-exporter.js";
|
|
7
|
+
import {
|
|
8
|
+
setGlobalActiveSpanAccessor,
|
|
9
|
+
setGlobalMetricsAPI,
|
|
10
|
+
setGlobalTracerProvider,
|
|
11
|
+
} from "../observability/tracing/api-shim.js";
|
|
6
12
|
import {
|
|
7
13
|
getEnvironmentConfig,
|
|
8
14
|
refreshEnvironmentConfig,
|
|
@@ -56,6 +62,34 @@ export interface BootstrapResult {
|
|
|
56
62
|
dispose?: () => void | Promise<void>;
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Wire the `TracingExporter` contract (if registered) into the core shim.
|
|
67
|
+
* Must be called after `orchestrateExtensions()` completes.
|
|
68
|
+
*/
|
|
69
|
+
function wireTracingShim(): void {
|
|
70
|
+
const tracing = tryResolve<TracingExporter>("TracingExporter");
|
|
71
|
+
if (tracing) {
|
|
72
|
+
setGlobalTracerProvider(
|
|
73
|
+
tracing.getProvider() as Parameters<typeof setGlobalTracerProvider>[0],
|
|
74
|
+
);
|
|
75
|
+
const metricsApi = tracing.getMetricsAPI();
|
|
76
|
+
if (metricsApi) {
|
|
77
|
+
setGlobalMetricsAPI(
|
|
78
|
+
metricsApi as Parameters<typeof setGlobalMetricsAPI>[0],
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const traceApi = tracing.getTraceAPI?.();
|
|
82
|
+
if (traceApi) {
|
|
83
|
+
setGlobalActiveSpanAccessor(
|
|
84
|
+
traceApi as Parameters<typeof setGlobalActiveSpanAccessor>[0],
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
bootstrapLog.debug("[bootstrap] TracingExporter wired into shim");
|
|
88
|
+
} else {
|
|
89
|
+
bootstrapLog.debug("[bootstrap] no TracingExporter extension — using no-op tracer");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
59
93
|
function combineDispose(
|
|
60
94
|
extensionLoader: ExtensionLoader,
|
|
61
95
|
fsDispose?: () => void,
|
|
@@ -165,6 +199,7 @@ export async function bootstrap(
|
|
|
165
199
|
config,
|
|
166
200
|
logger: bootstrapLog,
|
|
167
201
|
});
|
|
202
|
+
wireTracingShim();
|
|
168
203
|
return {
|
|
169
204
|
adapter,
|
|
170
205
|
config,
|
|
@@ -205,6 +240,7 @@ export async function bootstrap(
|
|
|
205
240
|
config,
|
|
206
241
|
logger: bootstrapLog,
|
|
207
242
|
});
|
|
243
|
+
wireTracingShim();
|
|
208
244
|
return {
|
|
209
245
|
adapter,
|
|
210
246
|
config,
|
|
@@ -269,6 +305,7 @@ export async function bootstrap(
|
|
|
269
305
|
}),
|
|
270
306
|
fsDispose,
|
|
271
307
|
);
|
|
308
|
+
wireTracingShim();
|
|
272
309
|
|
|
273
310
|
return {
|
|
274
311
|
adapter: enhancedAdapter,
|
|
@@ -14,13 +14,16 @@ export function createRequestContext(req: Request): RequestContext {
|
|
|
14
14
|
const parsed = parseProjectDomain(effectiveHost);
|
|
15
15
|
const headerProjectSlug = req.headers.get("x-project-slug")?.trim() || undefined;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
// Mode derives from server-trusted signals only. The `x-environment` header
|
|
18
|
+
// is client-controlled and must NOT be able to flip a production request
|
|
19
|
+
// into preview mode (VULN-SRV-1 / VULN-SRV-2). Preview is determined by the
|
|
20
|
+
// HTTP Host / X-Forwarded-Host — those are terminated at the edge proxy and
|
|
21
|
+
// are the same signal used for routing, so they're the correct source of
|
|
22
|
+
// truth.
|
|
23
|
+
const mode: "preview" | "production" =
|
|
24
|
+
parsed.environment === "preview" || effectiveHost.includes(".preview.")
|
|
25
|
+
? "preview"
|
|
26
|
+
: "production";
|
|
24
27
|
|
|
25
28
|
return {
|
|
26
29
|
// Framework-owned token: bypass project env overlay so proxy mode works
|
|
@@ -231,7 +231,7 @@ async function enrichSpanWithRequestInfo(
|
|
|
231
231
|
requestId: string,
|
|
232
232
|
): Promise<void> {
|
|
233
233
|
try {
|
|
234
|
-
const { trace } = await import("
|
|
234
|
+
const { trace } = await import("../../observability/tracing/api-shim.js");
|
|
235
235
|
const span = trace.getActiveSpan();
|
|
236
236
|
if (!span) return;
|
|
237
237
|
|
|
@@ -13,21 +13,21 @@ import {
|
|
|
13
13
|
PRIORITY_MEDIUM_DEV_FILES,
|
|
14
14
|
} from "../../../../utils/constants/index.js";
|
|
15
15
|
import { isExtendedFSAdapter } from "../../../../platform/adapters/fs/wrapper.js";
|
|
16
|
-
import { getHostEnv } from "../../../../platform/compat/process.js";
|
|
17
16
|
|
|
18
17
|
export class DevFileHandler extends BaseHandler {
|
|
19
18
|
metadata: HandlerMetadata = {
|
|
20
19
|
name: "DevFileHandler",
|
|
21
20
|
priority: PRIORITY_MEDIUM_DEV_FILES as HandlerPriority,
|
|
22
21
|
patterns: [{ pattern: "/_veryfront/fs/", prefix: true, method: "GET" }],
|
|
23
|
-
|
|
22
|
+
// Strictly local-only: exposes project source tree (VULN-SRV-1 / VULN-SRV-2).
|
|
23
|
+
// Preview mode (even host-derived) must not unlock this surface.
|
|
24
|
+
enabled: (ctx) => !!ctx.isLocalProject,
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
async handle(req: Request, ctx: HandlerContext): Promise<HandlerResult> {
|
|
27
28
|
const { pathname } = new URL(req.url);
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
if (!ctx.isLocalProject && !isPreviewMode) return this.continue();
|
|
30
|
+
if (!ctx.isLocalProject) return this.continue();
|
|
31
31
|
|
|
32
32
|
if (req.method !== "GET" || !pathname.startsWith("/_veryfront/fs/")) {
|
|
33
33
|
return this.continue();
|
|
@@ -36,24 +36,6 @@ export class DevFileHandler extends BaseHandler {
|
|
|
36
36
|
const fsAdapter = ctx.adapter.fs;
|
|
37
37
|
const isExtended = isExtendedFSAdapter(fsAdapter);
|
|
38
38
|
|
|
39
|
-
if (!ctx.isLocalProject && ctx.projectSlug && isExtended && fsAdapter.isMultiProjectMode()) {
|
|
40
|
-
const effectiveToken = ctx.proxyToken || getHostEnv("VERYFRONT_API_TOKEN") || "";
|
|
41
|
-
const branch = ctx.parsedDomain?.branch ?? null;
|
|
42
|
-
|
|
43
|
-
return await fsAdapter.runWithContext(
|
|
44
|
-
ctx.projectSlug,
|
|
45
|
-
effectiveToken,
|
|
46
|
-
() => this.handleWithContext(req, pathname, ctx),
|
|
47
|
-
ctx.projectId,
|
|
48
|
-
{
|
|
49
|
-
productionMode: false,
|
|
50
|
-
releaseId: ctx.releaseId,
|
|
51
|
-
branch,
|
|
52
|
-
environmentName: ctx.environmentName,
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
39
|
if (isExtended && fsAdapter.isContextualMode()) {
|
|
58
40
|
try {
|
|
59
41
|
if (ctx.proxyToken) fsAdapter.setRequestToken(ctx.proxyToken);
|
|
@@ -250,7 +250,10 @@ export class SSRService implements SSRServiceLike {
|
|
|
250
250
|
nonce?: string,
|
|
251
251
|
): SSRRenderResult {
|
|
252
252
|
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
253
|
-
|
|
253
|
+
// Dev-only overlay (full stack, absolute paths, line numbers) must never
|
|
254
|
+
// be exposed outside a local project — including remote preview, which is
|
|
255
|
+
// internet-reachable. See VULN-SRV-1 / VULN-SRV-2.
|
|
256
|
+
const isDev = Boolean(ctx.isLocalProject);
|
|
254
257
|
|
|
255
258
|
if (error instanceof VeryfrontError && error.slug === "file-not-found") {
|
|
256
259
|
logger.debug("Page not found", { slug, error: errorObj.message });
|
|
@@ -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,h])=>`${a}@${h}`).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 S(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",I={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_CHAT_REACT:`${i}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${i}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${i}/lib/chat/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=I.RSC,M=I.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:S("react",o)?"react":A(e),reactDomClient:S("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 Zt=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"}),te=r({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),ee=r({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),re=r({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),oe=r({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),ne=r({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),se=r({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),ie=r({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),ae=r({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),ce=r({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),ue=r({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),le=r({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),ge=r({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),de=r({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),pe=r({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),Re=r({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),me=r({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),Ee=r({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),fe=r({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ye=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"}),_e=r({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),Oe=r({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),xe=r({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),he=r({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Se=r({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),Ie=r({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),Ce=r({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),Te=r({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),Ne=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"}),Ae=r({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),De=r({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),ve=r({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Le=r({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),be=r({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),Me=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"}),Ue=r({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Pe=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"}),we=r({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Fe=r({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),He=r({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),$e=r({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),ke=r({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ge=r({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),je=r({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),Be=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"}),Ye=r({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),We=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"}),qe=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"}),ze=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"}),Xe=r({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),Je=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"}),Ke=r({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),Ze=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"}),tr=r({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),er=r({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),rr=r({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),or=r({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),nr=r({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),sr=r({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),ir=r({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),ar=r({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),cr=r({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),ur=r({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),lr=r({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),gr=r({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),dr=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"}),pr=r({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),Rr=r({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),mr=r({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),Er=r({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),fr=r({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),yr=r({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),_r=r({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Or=r({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),H=r({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),xr=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 H.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),Nr=new E("PREFETCH",x),Ar=new E("HYDRATE",x),Dr=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 $(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:h,value:j}=o?await Promise.race([a,it(o)]):await a;if(h){g=!0;break}u+=l.decode(j,{stream:!0}),u=$(e,u)}u&&$(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';
|
|
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,h])=>`${a}@${h}`).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 S(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",I={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_CHAT_REACT:`${i}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${i}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${i}/lib/chat/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 E=I.RSC,M=I.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`${E}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:S("react",o)?"react":A(e),reactDomClient:S("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 Zt=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"}),te=r({slug:"config-parse-error",category:"CONFIG",status:400,title:"Failed to parse configuration",suggestion:"Ensure your configuration file is valid TypeScript/JSON"}),ee=r({slug:"config-validation-error",category:"CONFIG",status:422,title:"Configuration validation failed",suggestion:"Check the configuration against the schema requirements"}),re=r({slug:"config-type-error",category:"CONFIG",status:400,title:"Configuration type mismatch",suggestion:"Ensure configuration values match expected types"}),oe=r({slug:"import-map-invalid",category:"CONFIG",status:400,title:"Invalid import map configuration",suggestion:"Check your import map syntax and paths"}),ne=r({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),se=r({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),ie=r({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),ae=r({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),ce=r({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),ue=r({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),le=r({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),ge=r({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),de=r({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),pe=r({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),Re=r({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),Ee=r({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),me=r({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),fe=r({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),ye=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"}),_e=r({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),Oe=r({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),xe=r({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),he=r({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),Se=r({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),Ie=r({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),Ce=r({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),Te=r({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),Ne=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"}),Ae=r({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),De=r({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),ve=r({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Le=r({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),be=r({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),Me=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"}),Ue=r({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),Pe=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"}),we=r({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),Fe=r({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),He=r({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),$e=r({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),ke=r({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Ge=r({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),je=r({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),Be=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"}),Ye=r({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),We=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"}),qe=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"}),ze=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"}),Xe=r({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),Je=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"}),Ke=r({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),Ze=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"}),tr=r({slug:"fast-refresh-error",category:"DEV",status:500,title:"Fast refresh failed",suggestion:"Save the file again or restart the dev server"}),er=r({slug:"error-overlay-error",category:"DEV",status:500,title:"Error overlay failed",suggestion:"Check browser console for details"}),rr=r({slug:"source-map-error",category:"DEV",status:500,title:"Source map loading error",suggestion:"Rebuild or clear cache"}),or=r({slug:"deployment-error",category:"DEPLOY",status:500,title:"Deployment process failed",suggestion:"Check deployment logs for details"}),nr=r({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),sr=r({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),ir=r({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),ar=r({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),cr=r({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),ur=r({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),lr=r({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),gr=r({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),dr=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"}),pr=r({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),Rr=r({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),Er=r({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),mr=r({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),fr=r({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),yr=r({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),_r=r({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Or=r({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),H=r({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),xr=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 H.create({detail:`Potentially unsafe HTML: ${c} detected`});return t}var m=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 m("RSC",x),Nr=new m("PREFETCH",x),Ar=new m("HYDRATE",x),Dr=new m("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 $(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:h,value:j}=o?await Promise.race([a,it(o)]):await a;if(h){g=!0;break}u+=l.decode(j,{stream:!0}),u=$(e,u)}u&&$(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(E+"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(E+"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 Et(t){try{let e=await fetch(E+"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 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 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 Et(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,dt as shouldAttemptRSCTransport};\n';
|
|
11
11
|
|
|
12
12
|
export const CLIENT_DOM_BUNDLE: string =
|
|
13
13
|
'var N=Object.defineProperty;var A=(r,t,o)=>t in r?N(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var u=(r,t,o)=>A(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 z=e({slug:"config-not-found",category:"CONFIG",status:404,title:"Configuration file not found",suggestion:"Run \'vf init\' to create a configuration file"}),W=e({slug:"config-invalid",category:"CONFIG",status:400,title:"Invalid configuration format",suggestion:"Check your veryfront.config.ts for syntax errors"}),X=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"}),K=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"}),Q=e({slug:"cors-config-invalid",category:"CONFIG",status:400,title:"Invalid CORS configuration",suggestion:"Review CORS settings in your configuration"}),ee=e({slug:"config-validation-failed",category:"CONFIG",status:400,title:"Configuration validation failed",suggestion:"Check configuration values against requirements"}),te=e({slug:"build-failed",category:"BUILD",status:500,title:"Build process failed",suggestion:"Check the build output for specific errors"}),re=e({slug:"bundle-error",category:"BUILD",status:500,title:"Bundle generation failed",suggestion:"Review bundler output for details"}),oe=e({slug:"typescript-error",category:"BUILD",status:500,title:"TypeScript compilation error",suggestion:"Fix TypeScript errors shown in the output"}),se=e({slug:"mdx-compile-error",category:"BUILD",status:500,title:"MDX compilation failed",suggestion:"Check your MDX file syntax"}),ne=e({slug:"asset-optimization-error",category:"BUILD",status:500,title:"Asset optimization failed",suggestion:"Check asset file formats and paths"}),ie=e({slug:"ssg-generation-error",category:"BUILD",status:500,title:"Static site generation failed",suggestion:"Review SSG configuration and data fetching"}),ae=e({slug:"sourcemap-error",category:"BUILD",status:500,title:"Source map generation failed",suggestion:"Check source map configuration"}),ce=e({slug:"compilation-error",category:"BUILD",status:500,title:"Compilation failed",suggestion:"Review compiler output for specific errors"}),le=e({slug:"hydration-mismatch",category:"RUNTIME",status:500,title:"Client/server hydration mismatch",suggestion:"Ensure server and client render the same content"}),ue=e({slug:"render-error",category:"RUNTIME",status:500,title:"Component render failed",suggestion:"Check component for runtime errors"}),ge=e({slug:"component-error",category:"RUNTIME",status:500,title:"Component execution error",suggestion:"Review component logic and props"}),de=e({slug:"layout-not-found",category:"RUNTIME",status:404,title:"Layout component not found",suggestion:"Ensure layout file exists at the expected path"}),pe=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"}),Ee=e({slug:"api-error",category:"RUNTIME",status:500,title:"API route handler error",suggestion:"Review API route handler for errors"}),Re=e({slug:"middleware-error",category:"RUNTIME",status:500,title:"Middleware execution error",suggestion:"Check middleware function for errors"}),fe=e({slug:"route-conflict",category:"ROUTE",status:409,title:"Conflicting route definitions",suggestion:"Rename or reorganize conflicting route files"}),ye=e({slug:"invalid-route-file",category:"ROUTE",status:400,title:"Invalid route file structure",suggestion:"Ensure route file exports required functions"}),me=e({slug:"route-handler-invalid",category:"ROUTE",status:400,title:"Invalid route handler export",suggestion:"Export a valid handler function from the route file"}),_e=e({slug:"dynamic-route-error",category:"ROUTE",status:500,title:"Dynamic route parsing failed",suggestion:"Check dynamic route segment syntax"}),Oe=e({slug:"route-params-error",category:"ROUTE",status:400,title:"Route parameters invalid",suggestion:"Validate route parameter values"}),Te=e({slug:"api-route-error",category:"ROUTE",status:500,title:"API route definition error",suggestion:"Review API route configuration"}),he=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"}),Ie=e({slug:"import-resolution-error",category:"MODULE",status:500,title:"Import path resolution failed",suggestion:"Verify import paths and module configuration"}),ve=e({slug:"circular-dependency",category:"MODULE",status:500,title:"Circular dependency detected",suggestion:"Refactor imports to break the circular dependency"}),xe=e({slug:"invalid-import",category:"MODULE",status:400,title:"Invalid import statement",suggestion:"Fix import syntax or path"}),Ne=e({slug:"dependency-missing",category:"MODULE",status:404,title:"Required dependency not installed",suggestion:"Install the missing dependency with your package manager"}),Ae=e({slug:"version-mismatch",category:"MODULE",status:409,title:"Dependency version mismatch",suggestion:"Update dependencies to compatible versions"}),Ce=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"}),Se=e({slug:"server-start-error",category:"SERVER",status:500,title:"Server failed to start",suggestion:"Check server configuration and port availability"}),De=e({slug:"cache-error",category:"SERVER",status:500,title:"Cache operation failed",suggestion:"Clear the cache and try again"}),Le=e({slug:"file-watch-error",category:"SERVER",status:500,title:"File watcher error",suggestion:"Restart the development server"}),Ue=e({slug:"request-error",category:"SERVER",status:500,title:"HTTP request handling error",suggestion:"Check request handler and middleware"}),be=e({slug:"service-overloaded",category:"SERVER",status:503,title:"Service overloaded",suggestion:"Reduce load or scale up resources"}),Me=e({slug:"cache-path-mismatch",category:"SERVER",status:500,title:"Cache path mismatch",suggestion:"Clear the cache directory and rebuild"}),Pe=e({slug:"network-error",category:"SERVER",status:502,title:"Network operation failed",suggestion:"Check network connectivity and retry"}),Ve=e({slug:"api-client-error",category:"SERVER",status:500,title:"API client request failed",suggestion:"Check API connectivity and authentication"}),Fe=e({slug:"token-storage-error",category:"SERVER",status:500,title:"Token storage operation failed",suggestion:"Check token storage backend and credentials"}),ke=e({slug:"cache-invariant-violation",category:"SERVER",status:500,title:"Cache path invariant violated",suggestion:"Clear the cache and rebuild"}),we=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"}),Ge=e({slug:"fallback-exhausted",category:"SERVER",status:500,title:"Primary and fallback operations both failed",suggestion:"Check service availability and connectivity"}),He=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"}),$e=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"}),Be=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"}),Ye=e({slug:"invalid-use-client",category:"BOUNDARY",status:400,title:"Invalid \'use client\' directive",suggestion:"Place \'use client\' at the top of the file"}),je=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"}),qe=e({slug:"rsc-payload-error",category:"BOUNDARY",status:500,title:"RSC payload serialization error",suggestion:"Ensure props are serializable (no functions, symbols, etc.)"}),ze=e({slug:"hmr-error",category:"DEV",status:500,title:"Hot module replacement error",suggestion:"Restart the development server"}),We=e({slug:"dev-server-error",category:"DEV",status:500,title:"Development server error",suggestion:"Check the dev server logs and restart"}),Xe=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"}),Ke=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"}),Qe=e({slug:"platform-error",category:"DEPLOY",status:500,title:"Platform-specific error",suggestion:"Check platform documentation and requirements"}),et=e({slug:"env-var-missing",category:"DEPLOY",status:500,title:"Required environment variable missing",suggestion:"Set the required environment variable"}),tt=e({slug:"production-build-required",category:"DEPLOY",status:400,title:"Production build required",suggestion:"Run \'vf build\' before deploying"}),rt=e({slug:"agent-error",category:"AGENT",status:500,title:"Agent operation error",suggestion:"Check agent configuration and logs"}),ot=e({slug:"agent-not-found",category:"AGENT",status:404,title:"Agent not found",suggestion:"Verify the agent ID exists"}),st=e({slug:"agent-timeout",category:"AGENT",status:408,title:"Agent operation timed out",suggestion:"Increase timeout or simplify the request"}),nt=e({slug:"agent-intent-error",category:"AGENT",status:400,title:"Agent intent parsing error",suggestion:"Rephrase the request more clearly"}),it=e({slug:"orchestration-error",category:"AGENT",status:500,title:"Multi-agent orchestration error",suggestion:"Check agent coordination logic"}),at=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"}),ct=e({slug:"unknown-error",category:"GENERAL",status:500,title:"Unknown/unclassified error",suggestion:"Check logs for more details"}),lt=e({slug:"permission-denied",category:"GENERAL",status:403,title:"File/resource permission denied",suggestion:"Check file permissions and access rights"}),ut=e({slug:"file-not-found",category:"GENERAL",status:404,title:"File not found",suggestion:"Verify the file path exists"}),gt=e({slug:"resource-not-found",category:"GENERAL",status:404,title:"Requested resource not found",suggestion:"Verify the referenced resource ID or name exists"}),dt=e({slug:"invalid-argument",category:"GENERAL",status:400,title:"Invalid function argument",suggestion:"Check argument types and values"}),pt=e({slug:"timeout-error",category:"GENERAL",status:408,title:"Operation timed out",suggestion:"Increase timeout or optimize the operation"}),Et=e({slug:"initialization-error",category:"GENERAL",status:500,title:"Initialization failed",suggestion:"Check initialization requirements and dependencies"}),Rt=e({slug:"not-supported",category:"GENERAL",status:501,title:"Feature not supported",suggestion:"Check documentation for supported features"}),m=e({slug:"security-violation",category:"GENERAL",status:403,title:"Security violation detected",suggestion:"Check for path traversal or unauthorized access attempts"}),ft=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 _(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 m.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),ht=new E("PREFETCH",R),It=new E("HYDRATE",R),vt=new E("VERYFRONT",R);var s="/_veryfront",y={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_CHAT_REACT:`${s}/lib/chat/react.js`,LIB_CHAT_COMPONENTS:`${s}/lib/chat/components.js`,LIB_CHAT_PRIMITIVES:`${s}/lib/chat/primitives.js`};var U={ROOT:".veryfront",CACHE:".veryfront/cache",KV:".veryfront/kv",LOGS:".veryfront/logs",TMP:".veryfront/tmp"},St=U.CACHE;var Dt={HMR_RUNTIME:O.HMR_RUNTIME,ERROR_OVERLAY:O.ERROR_OVERLAY};var Mt=y.RSC,Pt=y.FS;var T="rsc-root";function I(r,t){let o=t==="root"?T:`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=I(r,t.id);o.innerHTML=_(String(t.html??""))}function h(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 Gt(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:x}=o?await Promise.race([a,M(o)]):await a;if(v){p=!0;break}l+=g.decode(x,{stream:!0}),l=h(t,l)}l&&h(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=I(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{Gt as consumeNdjsonStream,I as getContainer};\n';
|