veryfront 0.0.5 → 0.0.6
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/README.md +24 -65
- package/dist/ai/dev.js +4 -5
- package/dist/ai/dev.js.map +2 -2
- package/dist/ai/index.js +98 -43
- package/dist/ai/index.js.map +2 -2
- package/dist/ai/production.js +22 -10
- package/dist/ai/production.js.map +2 -2
- package/dist/cli.js +989 -1176
- package/dist/components.js +60 -68
- package/dist/components.js.map +3 -3
- package/dist/config.js +4 -5
- package/dist/config.js.map +2 -2
- package/dist/data.js +14 -15
- package/dist/data.js.map +2 -2
- package/dist/index.js +42 -105
- package/dist/index.js.map +3 -3
- package/package.json +8 -27
package/dist/cli.js
CHANGED
|
@@ -36,8 +36,7 @@ function getEnvironmentVariable(name) {
|
|
|
36
36
|
const value = globalThis.process?.env[name];
|
|
37
37
|
return value === "" ? void 0 : value;
|
|
38
38
|
}
|
|
39
|
-
} catch
|
|
40
|
-
console.debug(`Failed to get environment variable ${name}:`, error2);
|
|
39
|
+
} catch {
|
|
41
40
|
return void 0;
|
|
42
41
|
}
|
|
43
42
|
return void 0;
|
|
@@ -167,10 +166,10 @@ var init_logger = __esm({
|
|
|
167
166
|
const end = performance.now();
|
|
168
167
|
this.debug(`${label} completed in ${(end - start).toFixed(2)}ms`);
|
|
169
168
|
return result;
|
|
170
|
-
} catch (
|
|
169
|
+
} catch (error2) {
|
|
171
170
|
const end = performance.now();
|
|
172
|
-
this.error(`${label} failed after ${(end - start).toFixed(2)}ms`,
|
|
173
|
-
throw
|
|
171
|
+
this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, error2);
|
|
172
|
+
throw error2;
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
};
|
|
@@ -227,19 +226,19 @@ var init_cache = __esm({
|
|
|
227
226
|
MS_PER_SECOND = 1e3;
|
|
228
227
|
DEFAULT_LRU_MAX_ENTRIES = 100;
|
|
229
228
|
COMPONENT_LOADER_MAX_ENTRIES = 100;
|
|
230
|
-
COMPONENT_LOADER_TTL_MS = 10 *
|
|
229
|
+
COMPONENT_LOADER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
231
230
|
MDX_RENDERER_MAX_ENTRIES = 200;
|
|
232
|
-
MDX_RENDERER_TTL_MS = 10 *
|
|
231
|
+
MDX_RENDERER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
233
232
|
RENDERER_CORE_MAX_ENTRIES = 100;
|
|
234
|
-
RENDERER_CORE_TTL_MS = 5 *
|
|
233
|
+
RENDERER_CORE_TTL_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
235
234
|
TSX_LAYOUT_MAX_ENTRIES = 50;
|
|
236
|
-
TSX_LAYOUT_TTL_MS = 10 *
|
|
235
|
+
TSX_LAYOUT_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
237
236
|
DATA_FETCHING_MAX_ENTRIES = 200;
|
|
238
|
-
DATA_FETCHING_TTL_MS = 10 *
|
|
237
|
+
DATA_FETCHING_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
239
238
|
MDX_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
240
|
-
MDX_CACHE_TTL_DEVELOPMENT_MS = 5 *
|
|
239
|
+
MDX_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
241
240
|
BUNDLE_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
242
|
-
BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 *
|
|
241
|
+
BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
243
242
|
BUNDLE_MANIFEST_PROD_TTL_MS = 7 * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
244
243
|
BUNDLE_MANIFEST_DEV_TTL_MS = MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
245
244
|
RSC_MANIFEST_CACHE_TTL_MS = 5e3;
|
|
@@ -318,7 +317,6 @@ function getUnoCSSTailwindResetUrl() {
|
|
|
318
317
|
var ESM_CDN_BASE, JSDELIVR_CDN_BASE, DENO_STD_BASE, REACT_VERSION_17, REACT_VERSION_18_2, REACT_VERSION_18_3, REACT_VERSION_19_RC, REACT_VERSION_19, REACT_DEFAULT_VERSION, DEFAULT_ALLOWED_CDN_HOSTS, DENO_STD_VERSION, UNOCSS_VERSION;
|
|
319
318
|
var init_cdn = __esm({
|
|
320
319
|
"src/core/utils/constants/cdn.ts"() {
|
|
321
|
-
"use strict";
|
|
322
320
|
ESM_CDN_BASE = "https://esm.sh";
|
|
323
321
|
JSDELIVR_CDN_BASE = "https://cdn.jsdelivr.net";
|
|
324
322
|
DENO_STD_BASE = "https://deno.land";
|
|
@@ -338,7 +336,6 @@ var init_cdn = __esm({
|
|
|
338
336
|
var HASH_SEED_DJB2, HASH_SEED_FNV1A;
|
|
339
337
|
var init_hash = __esm({
|
|
340
338
|
"src/core/utils/constants/hash.ts"() {
|
|
341
|
-
"use strict";
|
|
342
339
|
HASH_SEED_DJB2 = 5381;
|
|
343
340
|
HASH_SEED_FNV1A = 2166136261;
|
|
344
341
|
}
|
|
@@ -348,7 +345,6 @@ var init_hash = __esm({
|
|
|
348
345
|
var KB_IN_BYTES, HTTP_MODULE_FETCH_TIMEOUT_MS, HMR_RECONNECT_DELAY_MS, HMR_RELOAD_DELAY_MS, HMR_FILE_WATCHER_DEBOUNCE_MS, HMR_KEEP_ALIVE_INTERVAL_MS, DASHBOARD_RECONNECT_DELAY_MS, SERVER_FUNCTION_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_DEFAULT_DELAY_MS, HTTP_OK, HTTP_NO_CONTENT, HTTP_CREATED, HTTP_REDIRECT_FOUND, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED, HTTP_FORBIDDEN, HTTP_NOT_FOUND, HTTP_METHOD_NOT_ALLOWED, HTTP_GONE, HTTP_PAYLOAD_TOO_LARGE, HTTP_URI_TOO_LONG, HTTP_TOO_MANY_REQUESTS, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, HTTP_SERVER_ERROR, HTTP_INTERNAL_SERVER_ERROR, HTTP_BAD_GATEWAY, HTTP_NOT_IMPLEMENTED, HTTP_UNAVAILABLE, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_STATUS_SUCCESS_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_CONTENT_TYPES, MS_PER_MINUTE, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPE_IMAGE_AVIF, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO;
|
|
349
346
|
var init_http = __esm({
|
|
350
347
|
"src/core/utils/constants/http.ts"() {
|
|
351
|
-
"use strict";
|
|
352
348
|
init_cache();
|
|
353
349
|
KB_IN_BYTES = 1024;
|
|
354
350
|
HTTP_MODULE_FETCH_TIMEOUT_MS = 2500;
|
|
@@ -533,7 +529,7 @@ var init_deno = __esm({
|
|
|
533
529
|
"deno.json"() {
|
|
534
530
|
deno_default = {
|
|
535
531
|
name: "veryfront",
|
|
536
|
-
version: "0.
|
|
532
|
+
version: "0.0.6",
|
|
537
533
|
nodeModulesDir: "auto",
|
|
538
534
|
workspace: [
|
|
539
535
|
"./examples/async-worker-redis",
|
|
@@ -1582,7 +1578,7 @@ function safeLog(logFn) {
|
|
|
1582
1578
|
} catch (error2) {
|
|
1583
1579
|
try {
|
|
1584
1580
|
serverLogger.warn("[errors] Logging failed:", error2);
|
|
1585
|
-
} catch
|
|
1581
|
+
} catch {
|
|
1586
1582
|
}
|
|
1587
1583
|
}
|
|
1588
1584
|
}
|
|
@@ -2747,7 +2743,6 @@ var init_deno2 = __esm({
|
|
|
2747
2743
|
"use strict";
|
|
2748
2744
|
init_ansi();
|
|
2749
2745
|
colors2 = {
|
|
2750
|
-
// Basic colors
|
|
2751
2746
|
red,
|
|
2752
2747
|
green,
|
|
2753
2748
|
yellow,
|
|
@@ -2756,13 +2751,11 @@ var init_deno2 = __esm({
|
|
|
2756
2751
|
magenta,
|
|
2757
2752
|
white,
|
|
2758
2753
|
gray,
|
|
2759
|
-
// Text modifiers
|
|
2760
2754
|
bold,
|
|
2761
2755
|
dim,
|
|
2762
2756
|
italic,
|
|
2763
2757
|
underline,
|
|
2764
2758
|
strikethrough,
|
|
2765
|
-
// Utility
|
|
2766
2759
|
reset
|
|
2767
2760
|
};
|
|
2768
2761
|
}
|
|
@@ -2793,7 +2786,6 @@ var init_node = __esm({
|
|
|
2793
2786
|
"src/platform/compat/console/node.ts"() {
|
|
2794
2787
|
"use strict";
|
|
2795
2788
|
colors3 = {
|
|
2796
|
-
// Basic colors
|
|
2797
2789
|
red: pc.red,
|
|
2798
2790
|
green: pc.green,
|
|
2799
2791
|
yellow: pc.yellow,
|
|
@@ -2802,13 +2794,11 @@ var init_node = __esm({
|
|
|
2802
2794
|
magenta: pc.magenta,
|
|
2803
2795
|
white: pc.white,
|
|
2804
2796
|
gray: pc.gray,
|
|
2805
|
-
// Text modifiers
|
|
2806
2797
|
bold: pc.bold,
|
|
2807
2798
|
dim: pc.dim,
|
|
2808
2799
|
italic: pc.italic,
|
|
2809
2800
|
underline: pc.underline,
|
|
2810
2801
|
strikethrough: pc.strikethrough,
|
|
2811
|
-
// Utility - picocolors doesn't have reset, so we implement it
|
|
2812
2802
|
reset: (text2) => pc.reset(text2)
|
|
2813
2803
|
};
|
|
2814
2804
|
red2 = pc.red;
|
|
@@ -2990,70 +2980,70 @@ __export(process_exports, {
|
|
|
2990
2980
|
});
|
|
2991
2981
|
import process2 from "node:process";
|
|
2992
2982
|
function getArgs() {
|
|
2993
|
-
if (
|
|
2983
|
+
if (isDeno) {
|
|
2994
2984
|
return Deno.args;
|
|
2995
2985
|
}
|
|
2996
2986
|
return process2.argv.slice(2);
|
|
2997
2987
|
}
|
|
2998
2988
|
function exit(code) {
|
|
2999
|
-
if (
|
|
2989
|
+
if (isDeno) {
|
|
3000
2990
|
Deno.exit(code);
|
|
3001
2991
|
}
|
|
3002
2992
|
process2.exit(code);
|
|
3003
2993
|
}
|
|
3004
2994
|
function cwd() {
|
|
3005
|
-
if (
|
|
2995
|
+
if (isDeno) {
|
|
3006
2996
|
return Deno.cwd();
|
|
3007
2997
|
}
|
|
3008
2998
|
return process2.cwd();
|
|
3009
2999
|
}
|
|
3010
3000
|
function chdir(directory) {
|
|
3011
|
-
if (
|
|
3001
|
+
if (isDeno) {
|
|
3012
3002
|
Deno.chdir(directory);
|
|
3013
3003
|
} else {
|
|
3014
3004
|
process2.chdir(directory);
|
|
3015
3005
|
}
|
|
3016
3006
|
}
|
|
3017
3007
|
function env() {
|
|
3018
|
-
if (
|
|
3008
|
+
if (isDeno) {
|
|
3019
3009
|
return Deno.env.toObject();
|
|
3020
3010
|
}
|
|
3021
3011
|
return process2.env;
|
|
3022
3012
|
}
|
|
3023
3013
|
function getEnv(key) {
|
|
3024
|
-
if (
|
|
3014
|
+
if (isDeno) {
|
|
3025
3015
|
return Deno.env.get(key);
|
|
3026
3016
|
}
|
|
3027
3017
|
return process2.env[key];
|
|
3028
3018
|
}
|
|
3029
3019
|
function setEnv(key, value) {
|
|
3030
|
-
if (
|
|
3020
|
+
if (isDeno) {
|
|
3031
3021
|
Deno.env.set(key, value);
|
|
3032
3022
|
} else {
|
|
3033
3023
|
process2.env[key] = value;
|
|
3034
3024
|
}
|
|
3035
3025
|
}
|
|
3036
3026
|
function deleteEnv(key) {
|
|
3037
|
-
if (
|
|
3027
|
+
if (isDeno) {
|
|
3038
3028
|
Deno.env.delete(key);
|
|
3039
3029
|
} else {
|
|
3040
3030
|
delete process2.env[key];
|
|
3041
3031
|
}
|
|
3042
3032
|
}
|
|
3043
3033
|
function pid() {
|
|
3044
|
-
if (
|
|
3034
|
+
if (isDeno) {
|
|
3045
3035
|
return Deno.pid;
|
|
3046
3036
|
}
|
|
3047
3037
|
return process2.pid;
|
|
3048
3038
|
}
|
|
3049
3039
|
function ppid() {
|
|
3050
|
-
if (
|
|
3040
|
+
if (isDeno && "ppid" in Deno) {
|
|
3051
3041
|
return Deno.ppid || 0;
|
|
3052
3042
|
}
|
|
3053
3043
|
return process2.ppid || 0;
|
|
3054
3044
|
}
|
|
3055
3045
|
function memoryUsage() {
|
|
3056
|
-
if (
|
|
3046
|
+
if (isDeno) {
|
|
3057
3047
|
const usage2 = Deno.memoryUsage();
|
|
3058
3048
|
return {
|
|
3059
3049
|
rss: usage2.rss,
|
|
@@ -3071,13 +3061,13 @@ function memoryUsage() {
|
|
|
3071
3061
|
};
|
|
3072
3062
|
}
|
|
3073
3063
|
function isInteractive() {
|
|
3074
|
-
if (
|
|
3064
|
+
if (isDeno) {
|
|
3075
3065
|
return Deno.stdin.isTerminal();
|
|
3076
3066
|
}
|
|
3077
3067
|
return process2.stdin.isTTY ?? false;
|
|
3078
3068
|
}
|
|
3079
3069
|
async function getNetworkInterfaces() {
|
|
3080
|
-
if (
|
|
3070
|
+
if (isDeno) {
|
|
3081
3071
|
const interfaces2 = Deno.networkInterfaces();
|
|
3082
3072
|
return interfaces2.map((iface) => ({
|
|
3083
3073
|
name: iface.name,
|
|
@@ -3102,7 +3092,7 @@ async function getNetworkInterfaces() {
|
|
|
3102
3092
|
return result;
|
|
3103
3093
|
}
|
|
3104
3094
|
function getRuntimeVersion() {
|
|
3105
|
-
if (
|
|
3095
|
+
if (isDeno) {
|
|
3106
3096
|
return `Deno ${Deno.version.deno}`;
|
|
3107
3097
|
}
|
|
3108
3098
|
if ("Bun" in globalThis) {
|
|
@@ -3110,11 +3100,10 @@ function getRuntimeVersion() {
|
|
|
3110
3100
|
}
|
|
3111
3101
|
return `Node.js ${process2.version}`;
|
|
3112
3102
|
}
|
|
3113
|
-
var IS_DENO;
|
|
3114
3103
|
var init_process = __esm({
|
|
3115
3104
|
"src/platform/compat/process.ts"() {
|
|
3116
3105
|
"use strict";
|
|
3117
|
-
|
|
3106
|
+
init_runtime();
|
|
3118
3107
|
}
|
|
3119
3108
|
});
|
|
3120
3109
|
|
|
@@ -3233,7 +3222,6 @@ var init_fs = __esm({
|
|
|
3233
3222
|
NodeFileSystem = class {
|
|
3234
3223
|
constructor() {
|
|
3235
3224
|
this.fs = null;
|
|
3236
|
-
this.initNodeModules();
|
|
3237
3225
|
}
|
|
3238
3226
|
async initNodeModules() {
|
|
3239
3227
|
try {
|
|
@@ -3251,7 +3239,6 @@ var init_fs = __esm({
|
|
|
3251
3239
|
await this.initNodeModules();
|
|
3252
3240
|
return await this.fs.readFile(path, "utf8");
|
|
3253
3241
|
}
|
|
3254
|
-
// Alias for readTextFile (compatibility with FileSystemAdapter)
|
|
3255
3242
|
async readFile(path) {
|
|
3256
3243
|
return this.readTextFile(path);
|
|
3257
3244
|
}
|
|
@@ -3260,7 +3247,6 @@ var init_fs = __esm({
|
|
|
3260
3247
|
await this.initNodeModules();
|
|
3261
3248
|
await this.fs.writeFile(path, data, "utf8");
|
|
3262
3249
|
}
|
|
3263
|
-
// Alias for writeTextFile (compatibility with FileSystemAdapter)
|
|
3264
3250
|
async writeFile(path, data) {
|
|
3265
3251
|
return this.writeTextFile(path, data);
|
|
3266
3252
|
}
|
|
@@ -3282,7 +3268,6 @@ var init_fs = __esm({
|
|
|
3282
3268
|
isFile: stat2.isFile(),
|
|
3283
3269
|
isDirectory: stat2.isDirectory(),
|
|
3284
3270
|
isSymlink: false,
|
|
3285
|
-
// Node.js stat doesn't track symlinks by default
|
|
3286
3271
|
size: stat2.size,
|
|
3287
3272
|
mtime: stat2.mtime
|
|
3288
3273
|
};
|
|
@@ -4351,11 +4336,15 @@ async function createNodeServer(handler, options = {}) {
|
|
|
4351
4336
|
headersRecord[key] = value[0] || "";
|
|
4352
4337
|
}
|
|
4353
4338
|
}
|
|
4354
|
-
const
|
|
4339
|
+
const requestInit = {
|
|
4355
4340
|
method: _req.method,
|
|
4356
4341
|
headers: headersRecord,
|
|
4357
4342
|
body
|
|
4358
|
-
}
|
|
4343
|
+
};
|
|
4344
|
+
if (body !== null) {
|
|
4345
|
+
requestInit.duplex = "half";
|
|
4346
|
+
}
|
|
4347
|
+
const request = new Request(url.toString(), requestInit);
|
|
4359
4348
|
const response = await handler(request);
|
|
4360
4349
|
if (response.status === 101) {
|
|
4361
4350
|
return;
|
|
@@ -5064,9 +5053,7 @@ function createMockAdapter() {
|
|
|
5064
5053
|
},
|
|
5065
5054
|
fs: {
|
|
5066
5055
|
files,
|
|
5067
|
-
// Expose files Map for tests to populate
|
|
5068
5056
|
directories,
|
|
5069
|
-
// Expose directories Set for tests to track empty dirs
|
|
5070
5057
|
readFile: (path) => {
|
|
5071
5058
|
const content = files.get(path);
|
|
5072
5059
|
if (!content) {
|
|
@@ -5090,12 +5077,7 @@ function createMockAdapter() {
|
|
|
5090
5077
|
if (filePath.startsWith(path + "/"))
|
|
5091
5078
|
return true;
|
|
5092
5079
|
}
|
|
5093
|
-
|
|
5094
|
-
await Deno.stat(path);
|
|
5095
|
-
return true;
|
|
5096
|
-
} catch {
|
|
5097
|
-
return false;
|
|
5098
|
-
}
|
|
5080
|
+
return false;
|
|
5099
5081
|
},
|
|
5100
5082
|
readDir: async function* (path) {
|
|
5101
5083
|
const entries = /* @__PURE__ */ new Map();
|
|
@@ -5940,7 +5922,7 @@ function shouldDisableInterval() {
|
|
|
5940
5922
|
}
|
|
5941
5923
|
try {
|
|
5942
5924
|
return Deno.env.get("VF_DISABLE_LRU_INTERVAL") === "1";
|
|
5943
|
-
} catch
|
|
5925
|
+
} catch {
|
|
5944
5926
|
return false;
|
|
5945
5927
|
}
|
|
5946
5928
|
}
|
|
@@ -6029,7 +6011,7 @@ function isLruIntervalDisabled() {
|
|
|
6029
6011
|
}
|
|
6030
6012
|
try {
|
|
6031
6013
|
return process.env.VF_DISABLE_LRU_INTERVAL === "1";
|
|
6032
|
-
} catch
|
|
6014
|
+
} catch {
|
|
6033
6015
|
return false;
|
|
6034
6016
|
}
|
|
6035
6017
|
}
|
|
@@ -6090,7 +6072,7 @@ var init_redis_store = __esm({
|
|
|
6090
6072
|
try {
|
|
6091
6073
|
const mod = await import("@redis/client");
|
|
6092
6074
|
createClient = mod.createClient;
|
|
6093
|
-
} catch
|
|
6075
|
+
} catch {
|
|
6094
6076
|
throw toError(createError({
|
|
6095
6077
|
type: "render",
|
|
6096
6078
|
message: "Redis cache store requires npm:@redis/client. Install dependencies or switch cache.render.type to 'memory' or 'filesystem'."
|
|
@@ -6292,11 +6274,8 @@ function detectFeatures(major, minor, isReact19Flag) {
|
|
|
6292
6274
|
improvedSuspense: isReact19Flag,
|
|
6293
6275
|
enhancedStreaming: isReact19Flag,
|
|
6294
6276
|
renderToString: true,
|
|
6295
|
-
// Available in all versions
|
|
6296
6277
|
renderToStaticMarkup: true,
|
|
6297
|
-
// Available in all versions
|
|
6298
6278
|
renderToNodeStream: true,
|
|
6299
|
-
// Available in all versions (deprecated in 18+)
|
|
6300
6279
|
renderToPipeableStream: major >= 18,
|
|
6301
6280
|
renderToReadableStream: major >= 18
|
|
6302
6281
|
};
|
|
@@ -8336,7 +8315,6 @@ var init_templates = __esm({
|
|
|
8336
8315
|
app: appTemplate,
|
|
8337
8316
|
minimal: minimalTemplate,
|
|
8338
8317
|
ai: aiTemplate,
|
|
8339
|
-
// Legacy names for backward compatibility
|
|
8340
8318
|
"pages-router": minimalTemplate,
|
|
8341
8319
|
"app-router": minimalTemplate
|
|
8342
8320
|
};
|
|
@@ -8626,14 +8604,10 @@ var init_context_propagation = __esm({
|
|
|
8626
8604
|
async withActiveSpan(span, fn) {
|
|
8627
8605
|
if (!span)
|
|
8628
8606
|
return await fn();
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
);
|
|
8634
|
-
} catch (error2) {
|
|
8635
|
-
throw error2;
|
|
8636
|
-
}
|
|
8607
|
+
return await this.api.context.with(
|
|
8608
|
+
this.api.trace.setSpan(this.api.context.active(), span),
|
|
8609
|
+
fn
|
|
8610
|
+
);
|
|
8637
8611
|
}
|
|
8638
8612
|
withSpan(name, fn, startSpan2, endSpan2) {
|
|
8639
8613
|
const span = startSpan2(name);
|
|
@@ -9195,7 +9169,6 @@ async function initializeInstruments(meter, config, runtimeState) {
|
|
|
9195
9169
|
} catch (error2) {
|
|
9196
9170
|
serverLogger.warn("[metrics] Failed to initialize metric instruments", error2);
|
|
9197
9171
|
}
|
|
9198
|
-
await Promise.resolve();
|
|
9199
9172
|
return instruments;
|
|
9200
9173
|
}
|
|
9201
9174
|
var init_instruments_factory = __esm({
|
|
@@ -9229,37 +9202,17 @@ var init_recorder = __esm({
|
|
|
9229
9202
|
constructor(instruments, runtimeState) {
|
|
9230
9203
|
this.instruments = instruments;
|
|
9231
9204
|
this.runtimeState = runtimeState;
|
|
9232
|
-
this.stateLock = { locked: false };
|
|
9233
|
-
}
|
|
9234
|
-
/**
|
|
9235
|
-
* Execute state mutation atomically to prevent race conditions
|
|
9236
|
-
*/
|
|
9237
|
-
atomicUpdate(fn) {
|
|
9238
|
-
while (this.stateLock.locked) {
|
|
9239
|
-
}
|
|
9240
|
-
this.stateLock.locked = true;
|
|
9241
|
-
try {
|
|
9242
|
-
fn();
|
|
9243
|
-
} finally {
|
|
9244
|
-
this.stateLock.locked = false;
|
|
9245
|
-
}
|
|
9246
9205
|
}
|
|
9247
|
-
// HTTP Metrics
|
|
9248
9206
|
recordHttpRequest(attributes) {
|
|
9249
9207
|
this.instruments.httpRequestCounter?.add(1, attributes);
|
|
9250
9208
|
this.instruments.httpActiveRequests?.add(1, attributes);
|
|
9251
|
-
this.
|
|
9252
|
-
this.runtimeState.activeRequests++;
|
|
9253
|
-
});
|
|
9209
|
+
this.runtimeState.activeRequests++;
|
|
9254
9210
|
}
|
|
9255
9211
|
recordHttpRequestComplete(durationMs, attributes) {
|
|
9256
9212
|
this.instruments.httpRequestDuration?.record(durationMs, attributes);
|
|
9257
9213
|
this.instruments.httpActiveRequests?.add(-1, attributes);
|
|
9258
|
-
this.
|
|
9259
|
-
this.runtimeState.activeRequests--;
|
|
9260
|
-
});
|
|
9214
|
+
this.runtimeState.activeRequests--;
|
|
9261
9215
|
}
|
|
9262
|
-
// Cache Metrics
|
|
9263
9216
|
recordCacheGet(hit, attributes) {
|
|
9264
9217
|
this.instruments.cacheGetCounter?.add(1, attributes);
|
|
9265
9218
|
if (hit) {
|
|
@@ -9270,23 +9223,17 @@ var init_recorder = __esm({
|
|
|
9270
9223
|
}
|
|
9271
9224
|
recordCacheSet(attributes) {
|
|
9272
9225
|
this.instruments.cacheSetCounter?.add(1, attributes);
|
|
9273
|
-
this.
|
|
9274
|
-
this.runtimeState.cacheSize++;
|
|
9275
|
-
});
|
|
9226
|
+
this.runtimeState.cacheSize++;
|
|
9276
9227
|
}
|
|
9277
9228
|
recordCacheInvalidate(count, attributes) {
|
|
9278
9229
|
this.instruments.cacheInvalidateCounter?.add(count, attributes);
|
|
9279
|
-
this.
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
);
|
|
9284
|
-
});
|
|
9230
|
+
this.runtimeState.cacheSize = Math.max(
|
|
9231
|
+
0,
|
|
9232
|
+
this.runtimeState.cacheSize - count
|
|
9233
|
+
);
|
|
9285
9234
|
}
|
|
9286
9235
|
setCacheSize(size) {
|
|
9287
|
-
this.
|
|
9288
|
-
this.runtimeState.cacheSize = size;
|
|
9289
|
-
});
|
|
9236
|
+
this.runtimeState.cacheSize = size;
|
|
9290
9237
|
}
|
|
9291
9238
|
// Render Metrics
|
|
9292
9239
|
recordRender(durationMs, attributes) {
|
|
@@ -10130,7 +10077,6 @@ function getSecurityHeader(headerName, defaultValue, config, adapter) {
|
|
|
10130
10077
|
return (typeof configValue === "string" ? configValue : void 0) || envValue || defaultValue;
|
|
10131
10078
|
}
|
|
10132
10079
|
function applySecurityHeaders(headers, isDev, nonce, cspUserHeader, config, adapter) {
|
|
10133
|
-
serverLogger.debug("[NONCE-TRACE] applySecurityHeaders called", { nonce });
|
|
10134
10080
|
const getHeaderOverride = (name) => {
|
|
10135
10081
|
const overrides = config?.headers;
|
|
10136
10082
|
if (!overrides)
|
|
@@ -10188,7 +10134,6 @@ var init_security_handler = __esm({
|
|
|
10188
10134
|
"src/security/http/response/security-handler.ts"() {
|
|
10189
10135
|
"use strict";
|
|
10190
10136
|
init_observability();
|
|
10191
|
-
init_utils();
|
|
10192
10137
|
}
|
|
10193
10138
|
});
|
|
10194
10139
|
|
|
@@ -10496,10 +10441,8 @@ var init_builder = __esm({
|
|
|
10496
10441
|
init_response_methods();
|
|
10497
10442
|
init_static_helpers();
|
|
10498
10443
|
init_security_handler();
|
|
10499
|
-
init_utils();
|
|
10500
10444
|
ResponseBuilder = class {
|
|
10501
10445
|
constructor(config) {
|
|
10502
|
-
// Fluent methods - bind imported functions to this instance
|
|
10503
10446
|
this.withCORS = withCORS;
|
|
10504
10447
|
this.withCORSAsync = withCORSAsync;
|
|
10505
10448
|
this.withSecurity = withSecurity;
|
|
@@ -10508,7 +10451,6 @@ var init_builder = __esm({
|
|
|
10508
10451
|
this.withHeaders = withHeaders;
|
|
10509
10452
|
this.withStatus = withStatus;
|
|
10510
10453
|
this.withAllow = withAllow;
|
|
10511
|
-
// Response methods - bind imported functions to this instance
|
|
10512
10454
|
this.json = json;
|
|
10513
10455
|
this.text = text;
|
|
10514
10456
|
this.html = html;
|
|
@@ -10521,15 +10463,10 @@ var init_builder = __esm({
|
|
|
10521
10463
|
this.securityConfig = config?.securityConfig ?? null;
|
|
10522
10464
|
this.isDev = config?.isDev ?? false;
|
|
10523
10465
|
this.nonce = config?.nonce ?? generateNonce();
|
|
10524
|
-
serverLogger.debug("[NONCE-TRACE] ResponseBuilder nonce", {
|
|
10525
|
-
nonce: this.nonce,
|
|
10526
|
-
provided: !!config?.nonce
|
|
10527
|
-
});
|
|
10528
10466
|
this.cspUserHeader = config?.cspUserHeader ?? null;
|
|
10529
10467
|
this.adapter = config?.adapter;
|
|
10530
10468
|
}
|
|
10531
10469
|
static {
|
|
10532
|
-
// Static helper methods - delegate to static-helpers module
|
|
10533
10470
|
this.error = error;
|
|
10534
10471
|
}
|
|
10535
10472
|
static {
|
|
@@ -10863,24 +10800,17 @@ function encodeBase64(value) {
|
|
|
10863
10800
|
try {
|
|
10864
10801
|
return globalThis.btoa(value);
|
|
10865
10802
|
} catch {
|
|
10866
|
-
const
|
|
10867
|
-
let
|
|
10868
|
-
for (const byte of
|
|
10869
|
-
|
|
10870
|
-
return globalThis.btoa(
|
|
10803
|
+
const bytes = new TextEncoder().encode(value);
|
|
10804
|
+
let binary = "";
|
|
10805
|
+
for (const byte of bytes)
|
|
10806
|
+
binary += String.fromCharCode(byte);
|
|
10807
|
+
return globalThis.btoa(binary);
|
|
10871
10808
|
}
|
|
10872
10809
|
}
|
|
10873
10810
|
const bufferCtor = globalThis.Buffer;
|
|
10874
10811
|
if (bufferCtor) {
|
|
10875
10812
|
return bufferCtor.from(value, "utf8").toString("base64");
|
|
10876
10813
|
}
|
|
10877
|
-
const bytes = new TextEncoder().encode(value);
|
|
10878
|
-
let binary = "";
|
|
10879
|
-
for (const byte of bytes)
|
|
10880
|
-
binary += String.fromCharCode(byte);
|
|
10881
|
-
if (typeof globalThis.btoa === "function") {
|
|
10882
|
-
return globalThis.btoa(binary);
|
|
10883
|
-
}
|
|
10884
10814
|
throw toError(createError({
|
|
10885
10815
|
type: "not_supported",
|
|
10886
10816
|
message: "Base64 encoding is not supported in this runtime",
|
|
@@ -10890,19 +10820,23 @@ function encodeBase64(value) {
|
|
|
10890
10820
|
var AuthHandler;
|
|
10891
10821
|
var init_auth = __esm({
|
|
10892
10822
|
"src/security/http/auth.ts"() {
|
|
10823
|
+
"use strict";
|
|
10893
10824
|
init_base_handler();
|
|
10894
10825
|
init_veryfront_error();
|
|
10895
10826
|
AuthHandler = class extends BaseHandler {
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10827
|
+
constructor() {
|
|
10828
|
+
super(...arguments);
|
|
10829
|
+
this.metadata = {
|
|
10830
|
+
name: "AuthHandler",
|
|
10831
|
+
priority: 0,
|
|
10832
|
+
// CRITICAL priority - runs first
|
|
10833
|
+
patterns: []
|
|
10834
|
+
// Checks all requests
|
|
10835
|
+
};
|
|
10836
|
+
this.basicUser = null;
|
|
10837
|
+
this.basicPass = null;
|
|
10838
|
+
this.bearerToken = null;
|
|
10839
|
+
}
|
|
10906
10840
|
handle(req, ctx) {
|
|
10907
10841
|
this.loadAuthConfig(ctx);
|
|
10908
10842
|
if (req.method.toUpperCase() === "OPTIONS") {
|
|
@@ -10959,6 +10893,7 @@ var init_auth = __esm({
|
|
|
10959
10893
|
var SecurityConfigLoader;
|
|
10960
10894
|
var init_config7 = __esm({
|
|
10961
10895
|
"src/security/http/config.ts"() {
|
|
10896
|
+
"use strict";
|
|
10962
10897
|
init_config();
|
|
10963
10898
|
init_utils();
|
|
10964
10899
|
init_security_handler();
|
|
@@ -10966,11 +10901,11 @@ var init_config7 = __esm({
|
|
|
10966
10901
|
constructor(projectDir, adapter) {
|
|
10967
10902
|
this.projectDir = projectDir;
|
|
10968
10903
|
this.adapter = adapter;
|
|
10904
|
+
this.securityConfig = null;
|
|
10905
|
+
this.cspUserHeader = null;
|
|
10906
|
+
this.isLoaded = false;
|
|
10907
|
+
this.loadPromise = null;
|
|
10969
10908
|
}
|
|
10970
|
-
securityConfig = null;
|
|
10971
|
-
cspUserHeader = null;
|
|
10972
|
-
isLoaded = false;
|
|
10973
|
-
loadPromise = null;
|
|
10974
10909
|
/**
|
|
10975
10910
|
* Ensure security config is loaded (singleton pattern)
|
|
10976
10911
|
*/
|
|
@@ -11479,7 +11414,6 @@ var init_secure_fs = __esm({
|
|
|
11479
11414
|
throwOnError: true,
|
|
11480
11415
|
onSecurityEvent: () => {
|
|
11481
11416
|
},
|
|
11482
|
-
// No-op by default
|
|
11483
11417
|
validationOptions: {},
|
|
11484
11418
|
...config
|
|
11485
11419
|
};
|
|
@@ -11538,7 +11472,6 @@ var init_secure_fs = __esm({
|
|
|
11538
11472
|
}
|
|
11539
11473
|
return result;
|
|
11540
11474
|
}
|
|
11541
|
-
// ========== Filesystem Operations ==========
|
|
11542
11475
|
async readFile(path) {
|
|
11543
11476
|
const validation = await this.validatePathForOperation(path, "readFile");
|
|
11544
11477
|
if (!validation.valid || !validation.canonicalPath) {
|
|
@@ -11697,7 +11630,6 @@ var init_api_route_matcher = __esm({
|
|
|
11697
11630
|
this.routeCache = new LRUCache({
|
|
11698
11631
|
maxEntries: 500,
|
|
11699
11632
|
ttlMs: disableIntervals ? void 0 : 5 * 60 * 1e3
|
|
11700
|
-
// 5 minutes when intervals allowed
|
|
11701
11633
|
});
|
|
11702
11634
|
}
|
|
11703
11635
|
addRoute(pattern, page) {
|
|
@@ -11772,7 +11704,7 @@ var init_api_route_matcher = __esm({
|
|
|
11772
11704
|
return cached;
|
|
11773
11705
|
}
|
|
11774
11706
|
const sortedRoutes = this.sortRoutesByPriority();
|
|
11775
|
-
for (const [
|
|
11707
|
+
for (const [, routeData] of sortedRoutes) {
|
|
11776
11708
|
const match = normalizedPath.match(routeData.regex);
|
|
11777
11709
|
if (match) {
|
|
11778
11710
|
const params = this.extractParams(
|
|
@@ -12151,23 +12083,27 @@ async function loadAndTranspileModule(modulePath, projectDir, adapter, config) {
|
|
|
12151
12083
|
"ai",
|
|
12152
12084
|
"ai/*",
|
|
12153
12085
|
"ai/react",
|
|
12154
|
-
// Explicitly exclude React hooks (client-side only)
|
|
12155
12086
|
"@ai-sdk/*",
|
|
12156
12087
|
"zod",
|
|
12157
12088
|
"node:*",
|
|
12158
12089
|
"std/*",
|
|
12159
|
-
// Deno standard library
|
|
12160
12090
|
"@std/*",
|
|
12161
|
-
|
|
12162
|
-
|
|
12091
|
+
"https://deno.land/*",
|
|
12092
|
+
// Veryfront packages - should use runtime resolution, not bundled
|
|
12093
|
+
"veryfront",
|
|
12094
|
+
"veryfront/*",
|
|
12095
|
+
// OpenTelemetry packages used by veryfront/ai
|
|
12096
|
+
"@opentelemetry/*",
|
|
12097
|
+
// Path module - Node.js built-in
|
|
12098
|
+
"path"
|
|
12163
12099
|
];
|
|
12100
|
+
const resolveDir = dirname2(modulePath);
|
|
12164
12101
|
const result = await build3({
|
|
12165
12102
|
bundle: true,
|
|
12166
12103
|
write: false,
|
|
12167
12104
|
format: "esm",
|
|
12168
12105
|
platform: "neutral",
|
|
12169
12106
|
target: "es2022",
|
|
12170
|
-
// Support top-level await
|
|
12171
12107
|
jsx: "automatic",
|
|
12172
12108
|
jsxImportSource: "react",
|
|
12173
12109
|
resolveExtensions: [".ts", ".tsx", ".js", ".jsx", ".mjs"],
|
|
@@ -12175,7 +12111,7 @@ async function loadAndTranspileModule(modulePath, projectDir, adapter, config) {
|
|
|
12175
12111
|
stdin: {
|
|
12176
12112
|
contents: source,
|
|
12177
12113
|
loader,
|
|
12178
|
-
resolveDir
|
|
12114
|
+
resolveDir,
|
|
12179
12115
|
sourcefile: modulePath
|
|
12180
12116
|
},
|
|
12181
12117
|
plugins
|
|
@@ -12190,12 +12126,12 @@ async function loadAndTranspileModule(modulePath, projectDir, adapter, config) {
|
|
|
12190
12126
|
serverLogger.info(`[API] built handler ${modulePath}`);
|
|
12191
12127
|
const js = result.outputFiles?.[0]?.text ?? "export {}";
|
|
12192
12128
|
serverLogger.debug(`[API] transpiled size ${js.length} bytes`);
|
|
12193
|
-
return await loadModuleFromCode(js, adapter);
|
|
12129
|
+
return await loadModuleFromCode(js, adapter, projectDir);
|
|
12194
12130
|
}
|
|
12195
|
-
async function loadModuleFromCode(code, adapter) {
|
|
12131
|
+
async function loadModuleFromCode(code, adapter, projectDir) {
|
|
12196
12132
|
const tempDir = await createTempDir(adapter);
|
|
12197
12133
|
const tempFile = join2(tempDir, "handler.mjs");
|
|
12198
|
-
const transformedCode = rewriteExternalImports(code);
|
|
12134
|
+
const transformedCode = await rewriteExternalImports(code, projectDir);
|
|
12199
12135
|
await writeTempFile(tempFile, transformedCode, adapter);
|
|
12200
12136
|
try {
|
|
12201
12137
|
return await import(`file://${tempFile}?v=${Date.now()}`);
|
|
@@ -12207,11 +12143,57 @@ async function loadModuleFromCode(code, adapter) {
|
|
|
12207
12143
|
await removeTempDir(tempDir, adapter);
|
|
12208
12144
|
}
|
|
12209
12145
|
}
|
|
12210
|
-
function
|
|
12146
|
+
function isNodeRuntime() {
|
|
12147
|
+
const _global2 = globalThis;
|
|
12148
|
+
return typeof Deno === "undefined" && typeof _global2.process !== "undefined" && !!_global2.process?.versions?.node;
|
|
12149
|
+
}
|
|
12150
|
+
async function rewriteExternalImports(code, projectDir) {
|
|
12151
|
+
let transformed = code;
|
|
12152
|
+
if (isNodeRuntime()) {
|
|
12153
|
+
try {
|
|
12154
|
+
const { pathToFileURL: pathToFileURL2 } = await import("node:url");
|
|
12155
|
+
serverLogger.debug(`[API] Rewriting external imports for Node.js, projectDir: ${projectDir}`);
|
|
12156
|
+
const vfPackagePath = join2(projectDir, "node_modules", "veryfront");
|
|
12157
|
+
const vfPackageJsonPath = join2(vfPackagePath, "package.json");
|
|
12158
|
+
let exportsMap = {};
|
|
12159
|
+
try {
|
|
12160
|
+
const pkgJson = JSON.parse(await (await import("node:fs/promises")).readFile(vfPackageJsonPath, "utf-8"));
|
|
12161
|
+
exportsMap = pkgJson.exports || {};
|
|
12162
|
+
} catch {
|
|
12163
|
+
serverLogger.debug("[API] Could not read veryfront package.json");
|
|
12164
|
+
}
|
|
12165
|
+
transformed = transformed.replace(
|
|
12166
|
+
/from\s+["'](veryfront\/[^"']+)["']/g,
|
|
12167
|
+
(_match, fullSpecifier) => {
|
|
12168
|
+
const subpath = "./" + fullSpecifier.replace("veryfront/", "");
|
|
12169
|
+
const exportEntry = exportsMap[subpath];
|
|
12170
|
+
if (exportEntry?.import) {
|
|
12171
|
+
const resolvedPath = join2(vfPackagePath, exportEntry.import);
|
|
12172
|
+
serverLogger.debug(`[API] Resolved ${fullSpecifier} -> ${resolvedPath}`);
|
|
12173
|
+
return `from "${pathToFileURL2(resolvedPath).href}"`;
|
|
12174
|
+
}
|
|
12175
|
+
serverLogger.warn(`[API] No export found for ${subpath}`);
|
|
12176
|
+
return _match;
|
|
12177
|
+
}
|
|
12178
|
+
);
|
|
12179
|
+
transformed = transformed.replace(
|
|
12180
|
+
/from\s+["']veryfront["']/g,
|
|
12181
|
+
() => {
|
|
12182
|
+
const exportEntry = exportsMap["."];
|
|
12183
|
+
if (exportEntry?.import) {
|
|
12184
|
+
const resolvedPath = join2(vfPackagePath, exportEntry.import);
|
|
12185
|
+
serverLogger.debug(`[API] Resolved veryfront -> ${resolvedPath}`);
|
|
12186
|
+
return `from "${pathToFileURL2(resolvedPath).href}"`;
|
|
12187
|
+
}
|
|
12188
|
+
return 'from "veryfront"';
|
|
12189
|
+
}
|
|
12190
|
+
);
|
|
12191
|
+
} catch (e) {
|
|
12192
|
+
serverLogger.warn(`[API] Failed to import node:module: ${e}`);
|
|
12193
|
+
}
|
|
12194
|
+
}
|
|
12211
12195
|
const externalPackages = [
|
|
12212
|
-
// Base ai package (but exclude ai/react which is client-side only)
|
|
12213
12196
|
{ pattern: /from\s+["']ai["']/g, replacement: 'from "npm:ai@latest"' },
|
|
12214
|
-
// AI SDK provider packages
|
|
12215
12197
|
{
|
|
12216
12198
|
pattern: /from\s+["']@ai-sdk\/anthropic["']/g,
|
|
12217
12199
|
replacement: 'from "npm:@ai-sdk/anthropic@latest"'
|
|
@@ -12230,9 +12212,7 @@ function rewriteExternalImports(code) {
|
|
|
12230
12212
|
pattern: /from\s+["']@ai-sdk\/provider-utils["']/g,
|
|
12231
12213
|
replacement: 'from "npm:@ai-sdk/provider-utils@latest"'
|
|
12232
12214
|
},
|
|
12233
|
-
// Validation library
|
|
12234
12215
|
{ pattern: /from\s+["']zod["']/g, replacement: 'from "npm:zod@latest"' },
|
|
12235
|
-
// Also handle dynamic imports
|
|
12236
12216
|
{ pattern: /import\s*\(\s*["']ai["']\s*\)/g, replacement: 'import("npm:ai@latest")' },
|
|
12237
12217
|
{
|
|
12238
12218
|
pattern: /import\s*\(\s*["']@ai-sdk\/anthropic["']\s*\)/g,
|
|
@@ -12260,7 +12240,6 @@ function rewriteExternalImports(code) {
|
|
|
12260
12240
|
},
|
|
12261
12241
|
{ pattern: /import\s*\(\s*["']zod["']\s*\)/g, replacement: 'import("npm:zod@latest")' }
|
|
12262
12242
|
];
|
|
12263
|
-
let transformed = code;
|
|
12264
12243
|
for (const { pattern, replacement } of externalPackages) {
|
|
12265
12244
|
transformed = transformed.replace(pattern, replacement);
|
|
12266
12245
|
}
|
|
@@ -12620,18 +12599,12 @@ async function executeAppRoute(handler, request, match, pathname, adapter) {
|
|
|
12620
12599
|
const handlerModule = handler;
|
|
12621
12600
|
const handlerFn = handlerModule[method];
|
|
12622
12601
|
const defaultFn = handlerModule.default;
|
|
12623
|
-
|
|
12624
|
-
let headShim = false;
|
|
12602
|
+
let resolvedFn = handlerFn || defaultFn;
|
|
12625
12603
|
const appContext = { params: normalizeParams(match.params) };
|
|
12626
12604
|
if (!resolvedFn && method === "HEAD") {
|
|
12627
12605
|
const getFn = handlerModule.GET;
|
|
12628
12606
|
if (typeof getFn === "function") {
|
|
12629
|
-
|
|
12630
|
-
const res = await getFn(request, appContext);
|
|
12631
|
-
return new Response(null, {
|
|
12632
|
-
status: res?.status ?? HTTP_OK,
|
|
12633
|
-
headers: res?.headers || {}
|
|
12634
|
-
});
|
|
12607
|
+
resolvedFn = getFn;
|
|
12635
12608
|
}
|
|
12636
12609
|
}
|
|
12637
12610
|
if (!resolvedFn) {
|
|
@@ -12648,7 +12621,7 @@ async function executeAppRoute(handler, request, match, pathname, adapter) {
|
|
|
12648
12621
|
message: "API handler must return a Response"
|
|
12649
12622
|
}));
|
|
12650
12623
|
}
|
|
12651
|
-
if (
|
|
12624
|
+
if (method === "HEAD") {
|
|
12652
12625
|
return new Response(null, {
|
|
12653
12626
|
status: response.status,
|
|
12654
12627
|
headers: response.headers
|
|
@@ -12682,7 +12655,6 @@ async function executePagesRoute(handler, request, match, pathname, adapter) {
|
|
|
12682
12655
|
var init_route_executor = __esm({
|
|
12683
12656
|
"src/routing/api/route-executor.ts"() {
|
|
12684
12657
|
"use strict";
|
|
12685
|
-
init_utils();
|
|
12686
12658
|
init_context_builder();
|
|
12687
12659
|
init_veryfront_error();
|
|
12688
12660
|
init_method_validator();
|
|
@@ -14112,8 +14084,8 @@ var init_templates2 = __esm({
|
|
|
14112
14084
|
padding: 0;
|
|
14113
14085
|
color: inherit;
|
|
14114
14086
|
}`;
|
|
14115
|
-
CLIENT_ROUTER_BUNDLE = 'var __defProp = Object.defineProperty;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __esm = (fn, res) => function __init() {\n return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;\n};\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\n\n// src/core/utils/runtime-guards.ts\nfunction hasDenoRuntime(global) {\n return typeof global === "object" && global !== null && "Deno" in global && typeof global.Deno?.env?.get === "function";\n}\nfunction hasNodeProcess(global) {\n return typeof global === "object" && global !== null && "process" in global && typeof global.process?.env === "object";\n}\nfunction hasBunRuntime(global) {\n return typeof global === "object" && global !== null && "Bun" in global && typeof global.Bun !== "undefined";\n}\nvar init_runtime_guards = __esm({\n "src/core/utils/runtime-guards.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/logger/env.ts\nfunction getEnvironmentVariable(name) {\n try {\n if (typeof Deno !== "undefined" && hasDenoRuntime(globalThis)) {\n const value = globalThis.Deno?.env.get(name);\n return value === "" ? void 0 : value;\n }\n if (hasNodeProcess(globalThis)) {\n const value = globalThis.process?.env[name];\n return value === "" ? void 0 : value;\n }\n } catch (error2) {\n console.debug(`Failed to get environment variable ${name}:`, error2);\n return void 0;\n }\n return void 0;\n}\nfunction isTestEnvironment() {\n return getEnvironmentVariable("NODE_ENV") === "test";\n}\nfunction isProductionEnvironment() {\n return getEnvironmentVariable("NODE_ENV") === "production";\n}\nfunction isDevelopmentEnvironment() {\n const env = getEnvironmentVariable("NODE_ENV");\n return env === "development" || env === void 0;\n}\nvar init_env = __esm({\n "src/core/utils/logger/env.ts"() {\n "use strict";\n init_runtime_guards();\n }\n});\n\n// src/core/utils/logger/logger.ts\nfunction resolveLogLevel(force = false) {\n if (force || cachedLogLevel === void 0) {\n cachedLogLevel = getDefaultLevel();\n }\n return cachedLogLevel;\n}\nfunction parseLogLevel(levelString) {\n if (!levelString)\n return void 0;\n const upper = levelString.toUpperCase();\n switch (upper) {\n case "DEBUG":\n return 0 /* DEBUG */;\n case "WARN":\n return 2 /* WARN */;\n case "ERROR":\n return 3 /* ERROR */;\n case "INFO":\n return 1 /* INFO */;\n default:\n return void 0;\n }\n}\nfunction createLogger(prefix) {\n const logger2 = new ConsoleLogger(prefix);\n trackedLoggers.add(logger2);\n return logger2;\n}\nfunction __loggerResetForTests(options = {}) {\n const updatedLevel = resolveLogLevel(true);\n for (const instance of trackedLoggers) {\n instance.setLevel(updatedLevel);\n }\n if (options.restoreConsole) {\n console.debug = originalConsole.debug;\n console.log = originalConsole.log;\n console.warn = originalConsole.warn;\n console.error = originalConsole.error;\n }\n}\nvar LogLevel, originalConsole, cachedLogLevel, ConsoleLogger, getDefaultLevel, trackedLoggers, cliLogger, serverLogger, rendererLogger, bundlerLogger, agentLogger, logger;\nvar init_logger = __esm({\n "src/core/utils/logger/logger.ts"() {\n "use strict";\n init_env();\n LogLevel = /* @__PURE__ */ ((LogLevel2) => {\n LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";\n LogLevel2[LogLevel2["INFO"] = 1] = "INFO";\n LogLevel2[LogLevel2["WARN"] = 2] = "WARN";\n LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";\n return LogLevel2;\n })(LogLevel || {});\n originalConsole = {\n debug: console.debug,\n log: console.log,\n warn: console.warn,\n error: console.error\n };\n ConsoleLogger = class {\n constructor(prefix, level = resolveLogLevel()) {\n this.prefix = prefix;\n this.level = level;\n }\n setLevel(level) {\n this.level = level;\n }\n getLevel() {\n return this.level;\n }\n debug(message, ...args) {\n if (this.level <= 0 /* DEBUG */) {\n console.debug(`[${this.prefix}] DEBUG: ${message}`, ...args);\n }\n }\n info(message, ...args) {\n if (this.level <= 1 /* INFO */) {\n console.log(`[${this.prefix}] ${message}`, ...args);\n }\n }\n warn(message, ...args) {\n if (this.level <= 2 /* WARN */) {\n console.warn(`[${this.prefix}] WARN: ${message}`, ...args);\n }\n }\n error(message, ...args) {\n if (this.level <= 3 /* ERROR */) {\n console.error(`[${this.prefix}] ERROR: ${message}`, ...args);\n }\n }\n async time(label, fn) {\n const start = performance.now();\n try {\n const result = await fn();\n const end = performance.now();\n this.debug(`${label} completed in ${(end - start).toFixed(2)}ms`);\n return result;\n } catch (_error) {\n const end = performance.now();\n this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, _error);\n throw _error;\n }\n }\n };\n getDefaultLevel = () => {\n const envLevel = getEnvironmentVariable("LOG_LEVEL");\n const parsedLevel = parseLogLevel(envLevel);\n if (parsedLevel !== void 0)\n return parsedLevel;\n const debugFlag = getEnvironmentVariable("VERYFRONT_DEBUG");\n if (debugFlag === "1" || debugFlag === "true")\n return 0 /* DEBUG */;\n return 1 /* INFO */;\n };\n trackedLoggers = /* @__PURE__ */ new Set();\n cliLogger = createLogger("CLI");\n serverLogger = createLogger("SERVER");\n rendererLogger = createLogger("RENDERER");\n bundlerLogger = createLogger("BUNDLER");\n agentLogger = createLogger("AGENT");\n logger = createLogger("VERYFRONT");\n }\n});\n\n// src/core/utils/logger/index.ts\nvar init_logger2 = __esm({\n "src/core/utils/logger/index.ts"() {\n "use strict";\n init_logger();\n init_env();\n }\n});\n\n// src/core/utils/constants/build.ts\nvar DEFAULT_BUILD_CONCURRENCY, IMAGE_OPTIMIZATION;\nvar init_build = __esm({\n "src/core/utils/constants/build.ts"() {\n "use strict";\n DEFAULT_BUILD_CONCURRENCY = 4;\n IMAGE_OPTIMIZATION = {\n DEFAULT_SIZES: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],\n DEFAULT_QUALITY: 80\n };\n }\n});\n\n// src/core/utils/constants/cache.ts\nvar SECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, MS_PER_SECOND, DEFAULT_LRU_MAX_ENTRIES, COMPONENT_LOADER_MAX_ENTRIES, COMPONENT_LOADER_TTL_MS, MDX_RENDERER_MAX_ENTRIES, MDX_RENDERER_TTL_MS, RENDERER_CORE_MAX_ENTRIES, RENDERER_CORE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_TTL_MS, DATA_FETCHING_MAX_ENTRIES, DATA_FETCHING_TTL_MS, MDX_CACHE_TTL_PRODUCTION_MS, MDX_CACHE_TTL_DEVELOPMENT_MS, BUNDLE_CACHE_TTL_PRODUCTION_MS, BUNDLE_CACHE_TTL_DEVELOPMENT_MS, BUNDLE_MANIFEST_PROD_TTL_MS, BUNDLE_MANIFEST_DEV_TTL_MS, RSC_MANIFEST_CACHE_TTL_MS, SERVER_ACTION_DEFAULT_TTL_SEC, DENO_KV_SAFE_SIZE_LIMIT_BYTES, HTTP_CACHE_SHORT_MAX_AGE_SEC, HTTP_CACHE_MEDIUM_MAX_AGE_SEC, HTTP_CACHE_LONG_MAX_AGE_SEC, ONE_DAY_MS, CACHE_CLEANUP_INTERVAL_MS, LRU_DEFAULT_MAX_ENTRIES, LRU_DEFAULT_MAX_SIZE_BYTES, CLEANUP_INTERVAL_MULTIPLIER;\nvar init_cache = __esm({\n "src/core/utils/constants/cache.ts"() {\n "use strict";\n SECONDS_PER_MINUTE = 60;\n MINUTES_PER_HOUR = 60;\n HOURS_PER_DAY = 24;\n MS_PER_SECOND = 1e3;\n DEFAULT_LRU_MAX_ENTRIES = 100;\n COMPONENT_LOADER_MAX_ENTRIES = 100;\n COMPONENT_LOADER_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\n MDX_RENDERER_MAX_ENTRIES = 200;\n MDX_RENDERER_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\n RENDERER_CORE_MAX_ENTRIES = 100;\n RENDERER_CORE_TTL_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;\n TSX_LAYOUT_MAX_ENTRIES = 50;\n TSX_LAYOUT_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\n DATA_FETCHING_MAX_ENTRIES = 200;\n DATA_FETCHING_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\n MDX_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n MDX_CACHE_TTL_DEVELOPMENT_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;\n BUNDLE_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;\n BUNDLE_MANIFEST_PROD_TTL_MS = 7 * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n BUNDLE_MANIFEST_DEV_TTL_MS = MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n RSC_MANIFEST_CACHE_TTL_MS = 5e3;\n SERVER_ACTION_DEFAULT_TTL_SEC = MINUTES_PER_HOUR * SECONDS_PER_MINUTE;\n DENO_KV_SAFE_SIZE_LIMIT_BYTES = 64e3;\n HTTP_CACHE_SHORT_MAX_AGE_SEC = 60;\n HTTP_CACHE_MEDIUM_MAX_AGE_SEC = 3600;\n HTTP_CACHE_LONG_MAX_AGE_SEC = 31536e3;\n ONE_DAY_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n CACHE_CLEANUP_INTERVAL_MS = 6e4;\n LRU_DEFAULT_MAX_ENTRIES = 1e3;\n LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;\n CLEANUP_INTERVAL_MULTIPLIER = 2;\n }\n});\n\n// src/core/utils/constants/cdn.ts\nfunction getReactCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react@${version}`;\n}\nfunction getReactDOMCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react-dom@${version}`;\n}\nfunction getReactDOMClientCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react-dom@${version}/client`;\n}\nfunction getReactDOMServerCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react-dom@${version}/server`;\n}\nfunction getReactJSXRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react@${version}/jsx-runtime`;\n}\nfunction getReactJSXDevRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react@${version}/jsx-dev-runtime`;\n}\nfunction getReactImportMap(version = REACT_DEFAULT_VERSION) {\n return {\n react: getReactCDNUrl(version),\n "react-dom": getReactDOMCDNUrl(version),\n "react-dom/client": getReactDOMClientCDNUrl(version),\n "react-dom/server": getReactDOMServerCDNUrl(version),\n "react/jsx-runtime": getReactJSXRuntimeCDNUrl(version),\n "react/jsx-dev-runtime": getReactJSXDevRuntimeCDNUrl(version)\n };\n}\nfunction getDenoStdNodeBase() {\n return `${DENO_STD_BASE}/std@${DENO_STD_VERSION}/node`;\n}\nfunction getUnoCSSTailwindResetUrl() {\n return `${ESM_CDN_BASE}/@unocss/reset@${UNOCSS_VERSION}/tailwind.css`;\n}\nvar ESM_CDN_BASE, JSDELIVR_CDN_BASE, DENO_STD_BASE, REACT_VERSION_17, REACT_VERSION_18_2, REACT_VERSION_18_3, REACT_VERSION_19_RC, REACT_VERSION_19, REACT_DEFAULT_VERSION, DEFAULT_ALLOWED_CDN_HOSTS, DENO_STD_VERSION, UNOCSS_VERSION;\nvar init_cdn = __esm({\n "src/core/utils/constants/cdn.ts"() {\n "use strict";\n ESM_CDN_BASE = "https://esm.sh";\n JSDELIVR_CDN_BASE = "https://cdn.jsdelivr.net";\n DENO_STD_BASE = "https://deno.land";\n REACT_VERSION_17 = "17.0.2";\n REACT_VERSION_18_2 = "18.2.0";\n REACT_VERSION_18_3 = "18.3.1";\n REACT_VERSION_19_RC = "19.0.0-rc.0";\n REACT_VERSION_19 = "19.1.1";\n REACT_DEFAULT_VERSION = REACT_VERSION_18_3;\n DEFAULT_ALLOWED_CDN_HOSTS = [ESM_CDN_BASE, DENO_STD_BASE];\n DENO_STD_VERSION = "0.220.0";\n UNOCSS_VERSION = "0.59.0";\n }\n});\n\n// src/core/utils/constants/hash.ts\nvar HASH_SEED_DJB2, HASH_SEED_FNV1A;\nvar init_hash = __esm({\n "src/core/utils/constants/hash.ts"() {\n "use strict";\n HASH_SEED_DJB2 = 5381;\n HASH_SEED_FNV1A = 2166136261;\n }\n});\n\n// src/core/utils/constants/http.ts\nvar KB_IN_BYTES, HTTP_MODULE_FETCH_TIMEOUT_MS, HMR_RECONNECT_DELAY_MS, HMR_RELOAD_DELAY_MS, HMR_FILE_WATCHER_DEBOUNCE_MS, HMR_KEEP_ALIVE_INTERVAL_MS, DASHBOARD_RECONNECT_DELAY_MS, SERVER_FUNCTION_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_DEFAULT_DELAY_MS, HTTP_OK, HTTP_NO_CONTENT, HTTP_CREATED, HTTP_REDIRECT_FOUND, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED, HTTP_FORBIDDEN, HTTP_NOT_FOUND, HTTP_METHOD_NOT_ALLOWED, HTTP_GONE, HTTP_PAYLOAD_TOO_LARGE, HTTP_URI_TOO_LONG, HTTP_TOO_MANY_REQUESTS, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, HTTP_SERVER_ERROR, HTTP_INTERNAL_SERVER_ERROR, HTTP_BAD_GATEWAY, HTTP_NOT_IMPLEMENTED, HTTP_UNAVAILABLE, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_STATUS_SUCCESS_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_CONTENT_TYPES, MS_PER_MINUTE, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPE_IMAGE_AVIF, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO;\nvar init_http = __esm({\n "src/core/utils/constants/http.ts"() {\n "use strict";\n init_cache();\n KB_IN_BYTES = 1024;\n HTTP_MODULE_FETCH_TIMEOUT_MS = 2500;\n HMR_RECONNECT_DELAY_MS = 1e3;\n HMR_RELOAD_DELAY_MS = 1e3;\n HMR_FILE_WATCHER_DEBOUNCE_MS = 100;\n HMR_KEEP_ALIVE_INTERVAL_MS = 3e4;\n DASHBOARD_RECONNECT_DELAY_MS = 3e3;\n SERVER_FUNCTION_DEFAULT_TIMEOUT_MS = 3e4;\n PREFETCH_MAX_SIZE_BYTES = 200 * KB_IN_BYTES;\n PREFETCH_DEFAULT_TIMEOUT_MS = 1e4;\n PREFETCH_DEFAULT_DELAY_MS = 200;\n HTTP_OK = 200;\n HTTP_NO_CONTENT = 204;\n HTTP_CREATED = 201;\n HTTP_REDIRECT_FOUND = 302;\n HTTP_NOT_MODIFIED = 304;\n HTTP_BAD_REQUEST = 400;\n HTTP_UNAUTHORIZED = 401;\n HTTP_FORBIDDEN = 403;\n HTTP_NOT_FOUND = 404;\n HTTP_METHOD_NOT_ALLOWED = 405;\n HTTP_GONE = 410;\n HTTP_PAYLOAD_TOO_LARGE = 413;\n HTTP_URI_TOO_LONG = 414;\n HTTP_TOO_MANY_REQUESTS = 429;\n HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;\n HTTP_SERVER_ERROR = 500;\n HTTP_INTERNAL_SERVER_ERROR = 500;\n HTTP_BAD_GATEWAY = 502;\n HTTP_NOT_IMPLEMENTED = 501;\n HTTP_UNAVAILABLE = 503;\n HTTP_NETWORK_CONNECT_TIMEOUT = 599;\n HTTP_STATUS_SUCCESS_MIN = 200;\n HTTP_STATUS_REDIRECT_MIN = 300;\n HTTP_STATUS_CLIENT_ERROR_MIN = 400;\n HTTP_STATUS_SERVER_ERROR_MIN = 500;\n HTTP_CONTENT_TYPES = {\n JS: "application/javascript; charset=utf-8",\n JSON: "application/json; charset=utf-8",\n HTML: "text/html; charset=utf-8",\n CSS: "text/css; charset=utf-8",\n TEXT: "text/plain; charset=utf-8"\n };\n MS_PER_MINUTE = 6e4;\n HTTP_CONTENT_TYPE_IMAGE_PNG = "image/png";\n HTTP_CONTENT_TYPE_IMAGE_JPEG = "image/jpeg";\n HTTP_CONTENT_TYPE_IMAGE_WEBP = "image/webp";\n HTTP_CONTENT_TYPE_IMAGE_AVIF = "image/avif";\n HTTP_CONTENT_TYPE_IMAGE_SVG = "image/svg+xml";\n HTTP_CONTENT_TYPE_IMAGE_GIF = "image/gif";\n HTTP_CONTENT_TYPE_IMAGE_ICO = "image/x-icon";\n }\n});\n\n// src/core/utils/constants/hmr.ts\nfunction isValidHMRMessageType(type) {\n return Object.values(HMR_MESSAGE_TYPES).includes(\n type\n );\n}\nvar HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_CLIENT_RELOAD_DELAY_MS, HMR_PORT_OFFSET, HMR_RATE_LIMIT_WINDOW_MS, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_MESSAGE_TYPES;\nvar init_hmr = __esm({\n "src/core/utils/constants/hmr.ts"() {\n "use strict";\n init_http();\n HMR_MAX_MESSAGE_SIZE_BYTES = 1024 * KB_IN_BYTES;\n HMR_MAX_MESSAGES_PER_MINUTE = 100;\n HMR_CLIENT_RELOAD_DELAY_MS = 3e3;\n HMR_PORT_OFFSET = 1;\n HMR_RATE_LIMIT_WINDOW_MS = 6e4;\n HMR_CLOSE_NORMAL = 1e3;\n HMR_CLOSE_RATE_LIMIT = 1008;\n HMR_CLOSE_MESSAGE_TOO_LARGE = 1009;\n HMR_MESSAGE_TYPES = {\n CONNECTED: "connected",\n UPDATE: "update",\n RELOAD: "reload",\n PING: "ping",\n PONG: "pong"\n };\n }\n});\n\n// src/core/utils/constants/html.ts\nvar Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, BREAKPOINT_SM, BREAKPOINT_MD, BREAKPOINT_LG, BREAKPOINT_XL, PROSE_MAX_WIDTH;\nvar init_html = __esm({\n "src/core/utils/constants/html.ts"() {\n "use strict";\n Z_INDEX_DEV_INDICATOR = 9998;\n Z_INDEX_ERROR_OVERLAY = 9999;\n BREAKPOINT_SM = 640;\n BREAKPOINT_MD = 768;\n BREAKPOINT_LG = 1024;\n BREAKPOINT_XL = 1280;\n PROSE_MAX_WIDTH = "65ch";\n }\n});\n\n// src/core/utils/constants/network.ts\nvar DEFAULT_DEV_SERVER_PORT, DEFAULT_REDIS_PORT, DEFAULT_API_SERVER_PORT, DEFAULT_PREVIEW_SERVER_PORT, DEFAULT_METRICS_PORT, BYTES_PER_KB, BYTES_PER_MB, DEFAULT_IMAGE_THUMBNAIL_SIZE, DEFAULT_IMAGE_SMALL_SIZE, DEFAULT_IMAGE_LARGE_SIZE, RESPONSIVE_IMAGE_WIDTH_XS, RESPONSIVE_IMAGE_WIDTH_SM, RESPONSIVE_IMAGE_WIDTH_MD, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, MAX_CHUNK_SIZE_KB, MIN_PORT, MAX_PORT, DEFAULT_SERVER_PORT;\nvar init_network = __esm({\n "src/core/utils/constants/network.ts"() {\n "use strict";\n DEFAULT_DEV_SERVER_PORT = 3e3;\n DEFAULT_REDIS_PORT = 6379;\n DEFAULT_API_SERVER_PORT = 8080;\n DEFAULT_PREVIEW_SERVER_PORT = 5e3;\n DEFAULT_METRICS_PORT = 9e3;\n BYTES_PER_KB = 1024;\n BYTES_PER_MB = 1024 * 1024;\n DEFAULT_IMAGE_THUMBNAIL_SIZE = 256;\n DEFAULT_IMAGE_SMALL_SIZE = 512;\n DEFAULT_IMAGE_LARGE_SIZE = 2048;\n RESPONSIVE_IMAGE_WIDTH_XS = 320;\n RESPONSIVE_IMAGE_WIDTH_SM = 640;\n RESPONSIVE_IMAGE_WIDTH_MD = 1024;\n RESPONSIVE_IMAGE_WIDTH_LG = 1920;\n RESPONSIVE_IMAGE_WIDTHS = [\n RESPONSIVE_IMAGE_WIDTH_XS,\n RESPONSIVE_IMAGE_WIDTH_SM,\n RESPONSIVE_IMAGE_WIDTH_MD,\n RESPONSIVE_IMAGE_WIDTH_LG\n ];\n MAX_CHUNK_SIZE_KB = 4096;\n MIN_PORT = 1;\n MAX_PORT = 65535;\n DEFAULT_SERVER_PORT = 8e3;\n }\n});\n\n// src/core/utils/constants/security.ts\nvar MAX_PATH_TRAVERSAL_DEPTH, FORBIDDEN_PATH_PATTERNS, DIRECTORY_TRAVERSAL_PATTERN, ABSOLUTE_PATH_PATTERN, MAX_PATH_LENGTH, DEFAULT_MAX_STRING_LENGTH;\nvar init_security = __esm({\n "src/core/utils/constants/security.ts"() {\n "use strict";\n MAX_PATH_TRAVERSAL_DEPTH = 10;\n FORBIDDEN_PATH_PATTERNS = [\n /\\0/\n // Null bytes\n ];\n DIRECTORY_TRAVERSAL_PATTERN = /\\.\\.[\\/\\\\]/;\n ABSOLUTE_PATH_PATTERN = /^[\\/\\\\]/;\n MAX_PATH_LENGTH = 4096;\n DEFAULT_MAX_STRING_LENGTH = 1e3;\n }\n});\n\n// src/core/utils/constants/server.ts\nvar DEFAULT_DASHBOARD_PORT, DEV_SERVER_ENDPOINTS;\nvar init_server = __esm({\n "src/core/utils/constants/server.ts"() {\n "use strict";\n DEFAULT_DASHBOARD_PORT = 3002;\n DEV_SERVER_ENDPOINTS = {\n HMR_RUNTIME: "/_veryfront/hmr-runtime.js",\n ERROR_OVERLAY: "/_veryfront/error-overlay.js"\n };\n }\n});\n\n// src/core/utils/constants/index.ts\nvar init_constants = __esm({\n "src/core/utils/constants/index.ts"() {\n "use strict";\n init_build();\n init_cache();\n init_cdn();\n init_hash();\n init_hmr();\n init_html();\n init_http();\n init_network();\n init_security();\n init_server();\n }\n});\n\n// deno.json\nvar deno_default;\nvar init_deno = __esm({\n "deno.json"() {\n deno_default = {\n name: "veryfront",\n version: "0.1.0",\n nodeModulesDir: "auto",\n workspace: [\n "./examples/async-worker-redis",\n "./examples/knowledge-base",\n "./examples/form-handling",\n "./examples/middleware-demo",\n "./examples/coding-agent",\n "./examples/durable-workflows"\n ],\n exports: {\n ".": "./src/index.ts",\n "./cli": "./src/cli/main.ts",\n "./server": "./src/server/index.ts",\n "./middleware": "./src/middleware/index.ts",\n "./components": "./src/react/components/index.ts",\n "./data": "./src/data/index.ts",\n "./config": "./src/core/config/index.ts",\n "./ai": "./src/ai/index.ts",\n "./ai/client": "./src/ai/client.ts",\n "./ai/react": "./src/ai/react/index.ts",\n "./ai/primitives": "./src/ai/react/primitives/index.ts",\n "./ai/components": "./src/ai/react/components/index.ts",\n "./ai/production": "./src/ai/production/index.ts",\n "./ai/dev": "./src/ai/dev/index.ts",\n "./ai/workflow": "./src/ai/workflow/index.ts",\n "./ai/workflow/react": "./src/ai/workflow/react/index.ts"\n },\n imports: {\n "@veryfront": "./src/index.ts",\n "@veryfront/": "./src/",\n "@veryfront/ai": "./src/ai/index.ts",\n "@veryfront/ai/": "./src/ai/",\n "@veryfront/platform": "./src/platform/index.ts",\n "@veryfront/platform/": "./src/platform/",\n "@veryfront/types": "./src/core/types/index.ts",\n "@veryfront/types/": "./src/core/types/",\n "@veryfront/utils": "./src/core/utils/index.ts",\n "@veryfront/utils/": "./src/core/utils/",\n "@veryfront/middleware": "./src/middleware/index.ts",\n "@veryfront/middleware/": "./src/middleware/",\n "@veryfront/errors": "./src/core/errors/index.ts",\n "@veryfront/errors/": "./src/core/errors/",\n "@veryfront/config": "./src/core/config/index.ts",\n "@veryfront/config/": "./src/core/config/",\n "@veryfront/observability": "./src/observability/index.ts",\n "@veryfront/observability/": "./src/observability/",\n "@veryfront/routing": "./src/routing/index.ts",\n "@veryfront/routing/": "./src/routing/",\n "@veryfront/transforms": "./src/build/transforms/index.ts",\n "@veryfront/transforms/": "./src/build/transforms/",\n "@veryfront/data": "./src/data/index.ts",\n "@veryfront/data/": "./src/data/",\n "@veryfront/security": "./src/security/index.ts",\n "@veryfront/security/": "./src/security/",\n "@veryfront/components": "./src/react/components/index.ts",\n "@veryfront/react": "./src/react/index.ts",\n "@veryfront/react/": "./src/react/",\n "@veryfront/html": "./src/html/index.ts",\n "@veryfront/html/": "./src/html/",\n "@veryfront/rendering": "./src/rendering/index.ts",\n "@veryfront/rendering/": "./src/rendering/",\n "@veryfront/build": "./src/build/index.ts",\n "@veryfront/build/": "./src/build/",\n "@veryfront/server": "./src/server/index.ts",\n "@veryfront/server/": "./src/server/",\n "@veryfront/modules": "./src/module-system/index.ts",\n "@veryfront/modules/": "./src/module-system/",\n "@veryfront/compat/console": "./src/platform/compat/console/index.ts",\n "@veryfront/compat/": "./src/platform/compat/",\n "std/": "https://deno.land/std@0.220.0/",\n "@std/path": "https://deno.land/std@0.220.0/path/mod.ts",\n "@std/testing/bdd.ts": "https://deno.land/std@0.220.0/testing/bdd.ts",\n "@std/expect": "https://deno.land/std@0.220.0/expect/mod.ts",\n csstype: "https://esm.sh/csstype@3.2.3",\n "@types/react": "https://esm.sh/@types/react@18.3.27?deps=csstype@3.2.3",\n "@types/react-dom": "https://esm.sh/@types/react-dom@18.3.7?deps=csstype@3.2.3",\n react: "https://esm.sh/react@18.3.1",\n "react-dom": "https://esm.sh/react-dom@18.3.1",\n "react-dom/server": "https://esm.sh/react-dom@18.3.1/server",\n "react-dom/client": "https://esm.sh/react-dom@18.3.1/client",\n "react/jsx-runtime": "https://esm.sh/react@18.3.1/jsx-runtime",\n "react/jsx-dev-runtime": "https://esm.sh/react@18.3.1/jsx-dev-runtime",\n "@mdx-js/mdx": "https://esm.sh/@mdx-js/mdx@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "@mdx-js/react": "https://esm.sh/@mdx-js/react@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "unist-util-visit": "https://esm.sh/unist-util-visit@5.0.0",\n "mdast-util-to-string": "https://esm.sh/mdast-util-to-string@4.0.0",\n "github-slugger": "https://esm.sh/github-slugger@2.0.0",\n "remark-gfm": "https://esm.sh/remark-gfm@4.0.1",\n "remark-frontmatter": "https://esm.sh/remark-frontmatter@5.0.0",\n "rehype-highlight": "https://esm.sh/rehype-highlight@7.0.2",\n "rehype-slug": "https://esm.sh/rehype-slug@6.0.0",\n esbuild: "https://deno.land/x/esbuild@v0.20.1/wasm.js",\n "esbuild/mod.js": "https://deno.land/x/esbuild@v0.20.1/mod.js",\n "es-module-lexer": "https://esm.sh/es-module-lexer@1.5.0",\n zod: "https://esm.sh/zod@3.22.0",\n "mime-types": "https://esm.sh/mime-types@2.1.35",\n mdast: "https://esm.sh/@types/mdast@4.0.3",\n hast: "https://esm.sh/@types/hast@3.0.3",\n unist: "https://esm.sh/@types/unist@3.0.2",\n unified: "https://esm.sh/unified@11.0.5?dts",\n ai: "https://esm.sh/ai@5.0.76",\n "ai/react": "https://esm.sh/@ai-sdk/react@2.0.59",\n "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",\n "@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.4",\n unocss: "https://esm.sh/unocss@0.59.0",\n "@unocss/core": "https://esm.sh/@unocss/core@0.59.0",\n "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0"\n },\n compilerOptions: {\n jsx: "react-jsx",\n jsxImportSource: "react",\n strict: true,\n noImplicitAny: true,\n noUncheckedIndexedAccess: true,\n types: [],\n lib: [\n "deno.window",\n "dom",\n "dom.iterable",\n "dom.asynciterable",\n "deno.ns"\n ]\n },\n tasks: {\n setup: "deno run --allow-all scripts/setup.ts",\n dev: "deno run --allow-all --no-lock --unstable-net --unstable-worker-options src/cli/main.ts dev",\n build: "deno compile --allow-all --output ../../bin/veryfront src/cli/main.ts",\n "build:npm": "deno run -A scripts/build-npm.ts",\n test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",\n "test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",\n "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",\n "test:batches": "deno run --allow-all scripts/test-batches.ts",\n "test:unsafe": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net",\n "test:coverage": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:unit": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --ignore=tests --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:integration": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage tests --unstable-worker-options --unstable-net || exit 1",\n "coverage:report": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --lcov > coverage/lcov.info && deno run --allow-read scripts/check-coverage.ts 80",\n "coverage:html": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --html",\n lint: "deno lint src/",\n fmt: "deno fmt src/",\n typecheck: "deno check src/index.ts src/cli/main.ts src/server/index.ts src/routing/api/index.ts src/rendering/index.ts src/platform/index.ts src/platform/adapters/index.ts src/build/index.ts src/build/production-build/index.ts src/build/transforms/index.ts src/core/config/index.ts src/core/utils/index.ts src/data/index.ts src/security/index.ts src/middleware/index.ts src/server/handlers/dev/index.ts src/server/handlers/request/api/index.ts src/rendering/cache/index.ts src/rendering/cache/stores/index.ts src/rendering/rsc/actions/index.ts src/html/index.ts src/module-system/index.ts",\n "docs:check-links": "deno run -A scripts/check-doc-links.ts",\n "lint:ban-console": "deno run --allow-read scripts/ban-console.ts",\n "lint:ban-deep-imports": "deno run --allow-read scripts/ban-deep-imports.ts",\n "lint:ban-internal-root-imports": "deno run --allow-read scripts/ban-internal-root-imports.ts",\n "lint:check-awaits": "deno run --allow-read scripts/check-unawaited-promises.ts",\n "check:circular": "deno run -A jsr:@cunarist/deno-circular-deps src/index.ts"\n },\n lint: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n rules: {\n tags: [\n "recommended"\n ],\n include: [\n "ban-untagged-todo"\n ],\n exclude: [\n "no-explicit-any",\n "no-process-global",\n "no-console"\n ]\n }\n },\n fmt: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n options: {\n useTabs: false,\n lineWidth: 100,\n indentWidth: 2,\n semiColons: true,\n singleQuote: false,\n proseWrap: "preserve"\n }\n }\n };\n }\n});\n\n// src/core/utils/version.ts\nvar VERSION;\nvar init_version = __esm({\n "src/core/utils/version.ts"() {\n "use strict";\n init_deno();\n VERSION = typeof deno_default.version === "string" ? deno_default.version : "0.0.0";\n }\n});\n\n// src/core/utils/paths.ts\nvar PATHS, VERYFRONT_PATHS, FILE_EXTENSIONS;\nvar init_paths = __esm({\n "src/core/utils/paths.ts"() {\n "use strict";\n PATHS = {\n PAGES_DIR: "pages",\n COMPONENTS_DIR: "components",\n PUBLIC_DIR: "public",\n STYLES_DIR: "styles",\n DIST_DIR: "dist",\n CONFIG_FILE: "veryfront.config.js"\n };\n VERYFRONT_PATHS = {\n INTERNAL_PREFIX: "/_veryfront",\n BUILD_DIR: "_veryfront",\n CHUNKS_DIR: "_veryfront/chunks",\n DATA_DIR: "_veryfront/data",\n ASSETS_DIR: "_veryfront/assets",\n HMR_RUNTIME: "/_veryfront/hmr-runtime.js",\n CLIENT_JS: "/_veryfront/client.js",\n ROUTER_JS: "/_veryfront/router.js",\n ERROR_OVERLAY: "/_veryfront/error-overlay.js"\n };\n FILE_EXTENSIONS = {\n MDX: [".mdx", ".md"],\n SCRIPT: [".tsx", ".ts", ".jsx", ".js"],\n STYLE: [".css", ".scss", ".sass"],\n ALL: [".mdx", ".md", ".tsx", ".ts", ".jsx", ".js", ".css"]\n };\n }\n});\n\n// src/core/utils/hash-utils.ts\nasync function computeHash(content) {\n const encoder = new TextEncoder();\n const data = encoder.encode(content);\n const hashBuffer = await crypto.subtle.digest("SHA-256", data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");\n}\nfunction getContentHash(content) {\n return computeHash(content);\n}\nfunction computeContentHash(content) {\n return computeHash(content);\n}\nfunction computeCodeHash(code) {\n const combined = code.code + (code.css || "") + (code.sourceMap || "");\n return computeHash(combined);\n}\nfunction simpleHash(str) {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return Math.abs(hash);\n}\nasync function shortHash(content) {\n const fullHash = await computeHash(content);\n return fullHash.slice(0, 8);\n}\nvar init_hash_utils = __esm({\n "src/core/utils/hash-utils.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/memoize.ts\nfunction memoizeAsync(fn, keyHasher) {\n const cache = new MemoCache();\n return async (...args) => {\n const key = keyHasher(...args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = await fn(...args);\n cache.set(key, result);\n return result;\n };\n}\nfunction memoize(fn, keyHasher) {\n const cache = new MemoCache();\n return (...args) => {\n const key = keyHasher(...args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n}\nfunction simpleHash2(...values) {\n const FNV_OFFSET_BASIS = 2166136261;\n const FNV_PRIME = 16777619;\n let hash = FNV_OFFSET_BASIS;\n for (const value of values) {\n const str = typeof value === "string" ? value : String(value);\n for (let i = 0; i < str.length; i++) {\n hash ^= str.charCodeAt(i);\n hash = Math.imul(hash, FNV_PRIME);\n }\n }\n return (hash >>> 0).toString(36);\n}\nvar MemoCache;\nvar init_memoize = __esm({\n "src/core/utils/memoize.ts"() {\n "use strict";\n MemoCache = class {\n constructor() {\n this.cache = /* @__PURE__ */ new Map();\n }\n get(key) {\n return this.cache.get(key);\n }\n set(key, value) {\n this.cache.set(key, value);\n }\n has(key) {\n return this.cache.has(key);\n }\n clear() {\n this.cache.clear();\n }\n size() {\n return this.cache.size;\n }\n };\n }\n});\n\n// src/core/utils/path-utils.ts\nfunction normalizePath(pathname) {\n pathname = pathname.replace(/\\\\+/g, "/").replace(/\\/\\.+\\//g, "/");\n if (pathname !== "/" && pathname.endsWith("/")) {\n pathname = pathname.slice(0, -1);\n }\n return pathname;\n}\nfunction joinPath(a, b) {\n return `${a.replace(/\\/$/, "")}/${b.replace(/^\\//, "")}`;\n}\nfunction isWithinDirectory(root, target) {\n const normalizedRoot = normalizePath(root);\n const normalizedTarget = normalizePath(target);\n return normalizedTarget.startsWith(`${normalizedRoot}/`) || normalizedTarget === normalizedRoot;\n}\nfunction getExtension(path) {\n const lastDot = path.lastIndexOf(".");\n if (lastDot === -1 || lastDot === path.length - 1) {\n return "";\n }\n return path.slice(lastDot);\n}\nfunction getDirectory(path) {\n const normalized = normalizePath(path);\n const lastSlash = normalized.lastIndexOf("/");\n return lastSlash <= 0 ? "/" : normalized.slice(0, lastSlash);\n}\nfunction hasHashedFilename(path) {\n return /\\.[a-f0-9]{8,}\\./.test(path);\n}\nfunction isAbsolutePath(path) {\n return path.startsWith("/") || /^[A-Za-z]:[\\\\/]/.test(path);\n}\nfunction toBase64Url(s) {\n const b64 = btoa(s);\n return b64.replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");\n}\nfunction fromBase64Url(encoded) {\n const b64 = encoded.replaceAll("-", "+").replaceAll("_", "/");\n const pad = b64.length % 4 === 2 ? "==" : b64.length % 4 === 3 ? "=" : "";\n try {\n return atob(b64 + pad);\n } catch (error2) {\n logger.debug(`Failed to decode base64url string "${encoded}":`, error2);\n return "";\n }\n}\nvar init_path_utils = __esm({\n "src/core/utils/path-utils.ts"() {\n "use strict";\n init_logger();\n }\n});\n\n// src/core/utils/format-utils.ts\nfunction formatBytes(bytes) {\n if (bytes === 0)\n return "0 Bytes";\n const absBytes = Math.abs(bytes);\n if (absBytes < 1) {\n return `${absBytes} Bytes`;\n }\n const k = 1024;\n const sizes = ["Bytes", "KB", "MB", "GB", "TB"];\n const i = Math.floor(Math.log(absBytes) / Math.log(k));\n const index = Math.max(0, Math.min(i, sizes.length - 1));\n return `${parseFloat((absBytes / Math.pow(k, index)).toFixed(2))} ${sizes[index]}`;\n}\nfunction estimateSize(value) {\n if (value === null || value === void 0)\n return 8;\n switch (typeof value) {\n case "boolean":\n return 4;\n case "number":\n return 8;\n case "string":\n return value.length * 2;\n case "function":\n return 0;\n case "object":\n return estimateObjectSize(value);\n default:\n return 32;\n }\n}\nfunction estimateSizeWithCircularHandling(value) {\n const seen = /* @__PURE__ */ new WeakSet();\n const encoder = new TextEncoder();\n const json3 = JSON.stringify(value, (_key, val) => {\n if (typeof val === "object" && val !== null) {\n if (seen.has(val))\n return void 0;\n seen.add(val);\n if (val instanceof Map) {\n return { __type: "Map", entries: Array.from(val.entries()) };\n }\n if (val instanceof Set) {\n return { __type: "Set", values: Array.from(val.values()) };\n }\n }\n if (typeof val === "function")\n return void 0;\n if (val instanceof Uint8Array) {\n return { __type: "Uint8Array", length: val.length };\n }\n return val;\n });\n return encoder.encode(json3 ?? "").length;\n}\nfunction estimateObjectSize(value) {\n if (value instanceof ArrayBuffer)\n return value.byteLength;\n if (value instanceof Uint8Array || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array) {\n return value.byteLength;\n }\n try {\n return JSON.stringify(value).length * 2;\n } catch (error2) {\n logger.debug("Failed to estimate size of non-serializable object:", error2);\n return 1024;\n }\n}\nfunction formatDuration(ms) {\n if (ms < 1e3)\n return `${ms}ms`;\n if (ms < 6e4)\n return `${(ms / 1e3).toFixed(1)}s`;\n if (ms < 36e5)\n return `${Math.floor(ms / 6e4)}m ${Math.floor(ms % 6e4 / 1e3)}s`;\n return `${Math.floor(ms / 36e5)}h ${Math.floor(ms % 36e5 / 6e4)}m`;\n}\nfunction formatNumber(num) {\n return num.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, ",");\n}\nfunction truncateString(str, maxLength) {\n if (str.length <= maxLength)\n return str;\n return str.slice(0, maxLength - 3) + "...";\n}\nvar init_format_utils = __esm({\n "src/core/utils/format-utils.ts"() {\n "use strict";\n init_logger();\n }\n});\n\n// src/core/utils/bundle-manifest.ts\nfunction setBundleManifestStore(store) {\n manifestStore = store;\n serverLogger.info("[bundle-manifest] Bundle manifest store configured", {\n type: store.constructor.name\n });\n}\nfunction getBundleManifestStore() {\n return manifestStore;\n}\nvar InMemoryBundleManifestStore, manifestStore;\nvar init_bundle_manifest = __esm({\n "src/core/utils/bundle-manifest.ts"() {\n "use strict";\n init_logger2();\n init_hash_utils();\n InMemoryBundleManifestStore = class {\n constructor() {\n this.metadata = /* @__PURE__ */ new Map();\n this.code = /* @__PURE__ */ new Map();\n this.sourceIndex = /* @__PURE__ */ new Map();\n }\n getBundleMetadata(key) {\n const entry = this.metadata.get(key);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.metadata.delete(key);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleMetadata(key, metadata, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.metadata.set(key, { value: metadata, expiry });\n if (!this.sourceIndex.has(metadata.source)) {\n this.sourceIndex.set(metadata.source, /* @__PURE__ */ new Set());\n }\n this.sourceIndex.get(metadata.source).add(key);\n return Promise.resolve();\n }\n getBundleCode(hash) {\n const entry = this.code.get(hash);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.code.delete(hash);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleCode(hash, code, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.code.set(hash, { value: code, expiry });\n return Promise.resolve();\n }\n async deleteBundle(key) {\n const metadata = await this.getBundleMetadata(key);\n this.metadata.delete(key);\n if (metadata) {\n this.code.delete(metadata.codeHash);\n const sourceKeys = this.sourceIndex.get(metadata.source);\n if (sourceKeys) {\n sourceKeys.delete(key);\n if (sourceKeys.size === 0) {\n this.sourceIndex.delete(metadata.source);\n }\n }\n }\n }\n async invalidateSource(source) {\n const keys = this.sourceIndex.get(source);\n if (!keys)\n return 0;\n let count = 0;\n for (const key of Array.from(keys)) {\n await this.deleteBundle(key);\n count++;\n }\n this.sourceIndex.delete(source);\n return count;\n }\n clear() {\n this.metadata.clear();\n this.code.clear();\n this.sourceIndex.clear();\n return Promise.resolve();\n }\n isAvailable() {\n return Promise.resolve(true);\n }\n getStats() {\n let totalSize = 0;\n let oldest;\n let newest;\n for (const { value } of this.metadata.values()) {\n totalSize += value.size;\n if (!oldest || value.compiledAt < oldest)\n oldest = value.compiledAt;\n if (!newest || value.compiledAt > newest)\n newest = value.compiledAt;\n }\n return Promise.resolve({\n totalBundles: this.metadata.size,\n totalSize,\n oldestBundle: oldest,\n newestBundle: newest\n });\n }\n };\n manifestStore = new InMemoryBundleManifestStore();\n }\n});\n\n// src/core/utils/bundle-manifest-init.ts\nasync function initializeBundleManifest(config, mode, adapter) {\n const manifestConfig = config.cache?.bundleManifest;\n const enabled = manifestConfig?.enabled ?? mode === "production";\n if (!enabled) {\n serverLogger.info("[bundle-manifest] Bundle manifest disabled");\n setBundleManifestStore(new InMemoryBundleManifestStore());\n return;\n }\n const envType = adapter?.env.get("VERYFRONT_BUNDLE_MANIFEST_TYPE");\n const storeType = manifestConfig?.type || envType || "memory";\n serverLogger.info("[bundle-manifest] Initializing bundle manifest", {\n type: storeType,\n mode\n });\n try {\n let store;\n switch (storeType) {\n case "redis": {\n const { RedisBundleManifestStore } = await import("./bundle-manifest-redis.ts");\n const redisUrl = manifestConfig?.redisUrl || adapter?.env.get("VERYFRONT_BUNDLE_MANIFEST_REDIS_URL");\n store = new RedisBundleManifestStore(\n {\n url: redisUrl,\n keyPrefix: manifestConfig?.keyPrefix\n },\n adapter\n );\n const available = await store.isAvailable();\n if (!available) {\n serverLogger.warn("[bundle-manifest] Redis not available, falling back to in-memory");\n store = new InMemoryBundleManifestStore();\n } else {\n serverLogger.info("[bundle-manifest] Redis store initialized");\n }\n break;\n }\n case "kv": {\n const { KVBundleManifestStore } = await import("./bundle-manifest-kv.ts");\n store = new KVBundleManifestStore({\n keyPrefix: manifestConfig?.keyPrefix\n });\n const available = await store.isAvailable();\n if (!available) {\n serverLogger.warn("[bundle-manifest] KV not available, falling back to in-memory");\n store = new InMemoryBundleManifestStore();\n } else {\n serverLogger.info("[bundle-manifest] KV store initialized");\n }\n break;\n }\n case "memory":\n default: {\n store = new InMemoryBundleManifestStore();\n serverLogger.info("[bundle-manifest] In-memory store initialized");\n break;\n }\n }\n setBundleManifestStore(store);\n try {\n const stats = await store.getStats();\n serverLogger.info("[bundle-manifest] Store statistics", stats);\n } catch (error2) {\n serverLogger.debug("[bundle-manifest] Failed to get stats", { error: error2 });\n }\n } catch (error2) {\n serverLogger.error("[bundle-manifest] Failed to initialize store, using in-memory fallback", {\n error: error2\n });\n setBundleManifestStore(new InMemoryBundleManifestStore());\n }\n}\nfunction getBundleManifestTTL(config, mode) {\n const manifestConfig = config.cache?.bundleManifest;\n if (manifestConfig?.ttl) {\n return manifestConfig.ttl;\n }\n if (mode === "production") {\n return BUNDLE_MANIFEST_PROD_TTL_MS;\n } else {\n return BUNDLE_MANIFEST_DEV_TTL_MS;\n }\n}\nasync function warmupBundleManifest(store, keys) {\n serverLogger.info("[bundle-manifest] Warming up cache", { keys: keys.length });\n let loaded = 0;\n let failed = 0;\n for (const key of keys) {\n try {\n const metadata = await store.getBundleMetadata(key);\n if (metadata) {\n await store.getBundleCode(metadata.codeHash);\n loaded++;\n }\n } catch (error2) {\n serverLogger.debug("[bundle-manifest] Failed to warm up key", { key, error: error2 });\n failed++;\n }\n }\n serverLogger.info("[bundle-manifest] Cache warmup complete", { loaded, failed });\n}\nvar init_bundle_manifest_init = __esm({\n "src/core/utils/bundle-manifest-init.ts"() {\n "use strict";\n init_logger2();\n init_bundle_manifest();\n init_cache();\n }\n});\n\n// src/core/utils/feature-flags.ts\nfunction isRSCEnabled(config) {\n if (config?.experimental?.rsc !== void 0) {\n return config.experimental.rsc;\n }\n if (typeof Deno !== "undefined" && Deno.env) {\n return Deno.env.get("VERYFRONT_EXPERIMENTAL_RSC") === "1";\n }\n if (typeof process !== "undefined" && process?.env) {\n return process.env.VERYFRONT_EXPERIMENTAL_RSC === "1";\n }\n return false;\n}\nvar init_feature_flags = __esm({\n "src/core/utils/feature-flags.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/platform.ts\nfunction isCompiledBinary() {\n const hasDeno = typeof Deno !== "undefined";\n const hasExecPath = hasDeno && typeof Deno.execPath === "function";\n if (!hasExecPath)\n return false;\n try {\n const execPath = Deno.execPath();\n return execPath.includes("veryfront");\n } catch {\n return false;\n }\n}\nvar init_platform = __esm({\n "src/core/utils/platform.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/index.ts\nvar utils_exports = {};\n__export(utils_exports, {\n ABSOLUTE_PATH_PATTERN: () => ABSOLUTE_PATH_PATTERN,\n BREAKPOINT_LG: () => BREAKPOINT_LG,\n BREAKPOINT_MD: () => BREAKPOINT_MD,\n BREAKPOINT_SM: () => BREAKPOINT_SM,\n BREAKPOINT_XL: () => BREAKPOINT_XL,\n BUNDLE_CACHE_TTL_DEVELOPMENT_MS: () => BUNDLE_CACHE_TTL_DEVELOPMENT_MS,\n BUNDLE_CACHE_TTL_PRODUCTION_MS: () => BUNDLE_CACHE_TTL_PRODUCTION_MS,\n BUNDLE_MANIFEST_DEV_TTL_MS: () => BUNDLE_MANIFEST_DEV_TTL_MS,\n BUNDLE_MANIFEST_PROD_TTL_MS: () => BUNDLE_MANIFEST_PROD_TTL_MS,\n BYTES_PER_KB: () => BYTES_PER_KB,\n BYTES_PER_MB: () => BYTES_PER_MB,\n CACHE_CLEANUP_INTERVAL_MS: () => CACHE_CLEANUP_INTERVAL_MS,\n CLEANUP_INTERVAL_MULTIPLIER: () => CLEANUP_INTERVAL_MULTIPLIER,\n COMPONENT_LOADER_MAX_ENTRIES: () => COMPONENT_LOADER_MAX_ENTRIES,\n COMPONENT_LOADER_TTL_MS: () => COMPONENT_LOADER_TTL_MS,\n DASHBOARD_RECONNECT_DELAY_MS: () => DASHBOARD_RECONNECT_DELAY_MS,\n DATA_FETCHING_MAX_ENTRIES: () => DATA_FETCHING_MAX_ENTRIES,\n DATA_FETCHING_TTL_MS: () => DATA_FETCHING_TTL_MS,\n DEFAULT_ALLOWED_CDN_HOSTS: () => DEFAULT_ALLOWED_CDN_HOSTS,\n DEFAULT_API_SERVER_PORT: () => DEFAULT_API_SERVER_PORT,\n DEFAULT_BUILD_CONCURRENCY: () => DEFAULT_BUILD_CONCURRENCY,\n DEFAULT_DASHBOARD_PORT: () => DEFAULT_DASHBOARD_PORT,\n DEFAULT_DEV_SERVER_PORT: () => DEFAULT_DEV_SERVER_PORT,\n DEFAULT_IMAGE_LARGE_SIZE: () => DEFAULT_IMAGE_LARGE_SIZE,\n DEFAULT_IMAGE_SMALL_SIZE: () => DEFAULT_IMAGE_SMALL_SIZE,\n DEFAULT_IMAGE_THUMBNAIL_SIZE: () => DEFAULT_IMAGE_THUMBNAIL_SIZE,\n DEFAULT_LRU_MAX_ENTRIES: () => DEFAULT_LRU_MAX_ENTRIES,\n DEFAULT_MAX_STRING_LENGTH: () => DEFAULT_MAX_STRING_LENGTH,\n DEFAULT_METRICS_PORT: () => DEFAULT_METRICS_PORT,\n DEFAULT_PREVIEW_SERVER_PORT: () => DEFAULT_PREVIEW_SERVER_PORT,\n DEFAULT_REDIS_PORT: () => DEFAULT_REDIS_PORT,\n DEFAULT_SERVER_PORT: () => DEFAULT_SERVER_PORT,\n DENO_KV_SAFE_SIZE_LIMIT_BYTES: () => DENO_KV_SAFE_SIZE_LIMIT_BYTES,\n DENO_STD_BASE: () => DENO_STD_BASE,\n DENO_STD_VERSION: () => DENO_STD_VERSION,\n DEV_SERVER_ENDPOINTS: () => DEV_SERVER_ENDPOINTS,\n DIRECTORY_TRAVERSAL_PATTERN: () => DIRECTORY_TRAVERSAL_PATTERN,\n ESM_CDN_BASE: () => ESM_CDN_BASE,\n FILE_EXTENSIONS: () => FILE_EXTENSIONS,\n FORBIDDEN_PATH_PATTERNS: () => FORBIDDEN_PATH_PATTERNS,\n HASH_SEED_DJB2: () => HASH_SEED_DJB2,\n HASH_SEED_FNV1A: () => HASH_SEED_FNV1A,\n HMR_CLIENT_RELOAD_DELAY_MS: () => HMR_CLIENT_RELOAD_DELAY_MS,\n HMR_CLOSE_MESSAGE_TOO_LARGE: () => HMR_CLOSE_MESSAGE_TOO_LARGE,\n HMR_CLOSE_NORMAL: () => HMR_CLOSE_NORMAL,\n HMR_CLOSE_RATE_LIMIT: () => HMR_CLOSE_RATE_LIMIT,\n HMR_FILE_WATCHER_DEBOUNCE_MS: () => HMR_FILE_WATCHER_DEBOUNCE_MS,\n HMR_KEEP_ALIVE_INTERVAL_MS: () => HMR_KEEP_ALIVE_INTERVAL_MS,\n HMR_MAX_MESSAGES_PER_MINUTE: () => HMR_MAX_MESSAGES_PER_MINUTE,\n HMR_MAX_MESSAGE_SIZE_BYTES: () => HMR_MAX_MESSAGE_SIZE_BYTES,\n HMR_MESSAGE_TYPES: () => HMR_MESSAGE_TYPES,\n HMR_PORT_OFFSET: () => HMR_PORT_OFFSET,\n HMR_RATE_LIMIT_WINDOW_MS: () => HMR_RATE_LIMIT_WINDOW_MS,\n HMR_RECONNECT_DELAY_MS: () => HMR_RECONNECT_DELAY_MS,\n HMR_RELOAD_DELAY_MS: () => HMR_RELOAD_DELAY_MS,\n HOURS_PER_DAY: () => HOURS_PER_DAY,\n HTTP_BAD_GATEWAY: () => HTTP_BAD_GATEWAY,\n HTTP_BAD_REQUEST: () => HTTP_BAD_REQUEST,\n HTTP_CACHE_LONG_MAX_AGE_SEC: () => HTTP_CACHE_LONG_MAX_AGE_SEC,\n HTTP_CACHE_MEDIUM_MAX_AGE_SEC: () => HTTP_CACHE_MEDIUM_MAX_AGE_SEC,\n HTTP_CACHE_SHORT_MAX_AGE_SEC: () => HTTP_CACHE_SHORT_MAX_AGE_SEC,\n HTTP_CONTENT_TYPES: () => HTTP_CONTENT_TYPES,\n HTTP_CONTENT_TYPE_IMAGE_AVIF: () => HTTP_CONTENT_TYPE_IMAGE_AVIF,\n HTTP_CONTENT_TYPE_IMAGE_GIF: () => HTTP_CONTENT_TYPE_IMAGE_GIF,\n HTTP_CONTENT_TYPE_IMAGE_ICO: () => HTTP_CONTENT_TYPE_IMAGE_ICO,\n HTTP_CONTENT_TYPE_IMAGE_JPEG: () => HTTP_CONTENT_TYPE_IMAGE_JPEG,\n HTTP_CONTENT_TYPE_IMAGE_PNG: () => HTTP_CONTENT_TYPE_IMAGE_PNG,\n HTTP_CONTENT_TYPE_IMAGE_SVG: () => HTTP_CONTENT_TYPE_IMAGE_SVG,\n HTTP_CONTENT_TYPE_IMAGE_WEBP: () => HTTP_CONTENT_TYPE_IMAGE_WEBP,\n HTTP_CREATED: () => HTTP_CREATED,\n HTTP_FORBIDDEN: () => HTTP_FORBIDDEN,\n HTTP_GONE: () => HTTP_GONE,\n HTTP_INTERNAL_SERVER_ERROR: () => HTTP_INTERNAL_SERVER_ERROR,\n HTTP_METHOD_NOT_ALLOWED: () => HTTP_METHOD_NOT_ALLOWED,\n HTTP_MODULE_FETCH_TIMEOUT_MS: () => HTTP_MODULE_FETCH_TIMEOUT_MS,\n HTTP_NETWORK_CONNECT_TIMEOUT: () => HTTP_NETWORK_CONNECT_TIMEOUT,\n HTTP_NOT_FOUND: () => HTTP_NOT_FOUND,\n HTTP_NOT_IMPLEMENTED: () => HTTP_NOT_IMPLEMENTED,\n HTTP_NOT_MODIFIED: () => HTTP_NOT_MODIFIED,\n HTTP_NO_CONTENT: () => HTTP_NO_CONTENT,\n HTTP_OK: () => HTTP_OK,\n HTTP_PAYLOAD_TOO_LARGE: () => HTTP_PAYLOAD_TOO_LARGE,\n HTTP_REDIRECT_FOUND: () => HTTP_REDIRECT_FOUND,\n HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE: () => HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE,\n HTTP_SERVER_ERROR: () => HTTP_SERVER_ERROR,\n HTTP_STATUS_CLIENT_ERROR_MIN: () => HTTP_STATUS_CLIENT_ERROR_MIN,\n HTTP_STATUS_REDIRECT_MIN: () => HTTP_STATUS_REDIRECT_MIN,\n HTTP_STATUS_SERVER_ERROR_MIN: () => HTTP_STATUS_SERVER_ERROR_MIN,\n HTTP_STATUS_SUCCESS_MIN: () => HTTP_STATUS_SUCCESS_MIN,\n HTTP_TOO_MANY_REQUESTS: () => HTTP_TOO_MANY_REQUESTS,\n HTTP_UNAUTHORIZED: () => HTTP_UNAUTHORIZED,\n HTTP_UNAVAILABLE: () => HTTP_UNAVAILABLE,\n HTTP_URI_TOO_LONG: () => HTTP_URI_TOO_LONG,\n IMAGE_OPTIMIZATION: () => IMAGE_OPTIMIZATION,\n InMemoryBundleManifestStore: () => InMemoryBundleManifestStore,\n JSDELIVR_CDN_BASE: () => JSDELIVR_CDN_BASE,\n KB_IN_BYTES: () => KB_IN_BYTES,\n LRU_DEFAULT_MAX_ENTRIES: () => LRU_DEFAULT_MAX_ENTRIES,\n LRU_DEFAULT_MAX_SIZE_BYTES: () => LRU_DEFAULT_MAX_SIZE_BYTES,\n LogLevel: () => LogLevel,\n MAX_CHUNK_SIZE_KB: () => MAX_CHUNK_SIZE_KB,\n MAX_PATH_LENGTH: () => MAX_PATH_LENGTH,\n MAX_PATH_TRAVERSAL_DEPTH: () => MAX_PATH_TRAVERSAL_DEPTH,\n MAX_PORT: () => MAX_PORT,\n MDX_CACHE_TTL_DEVELOPMENT_MS: () => MDX_CACHE_TTL_DEVELOPMENT_MS,\n MDX_CACHE_TTL_PRODUCTION_MS: () => MDX_CACHE_TTL_PRODUCTION_MS,\n MDX_RENDERER_MAX_ENTRIES: () => MDX_RENDERER_MAX_ENTRIES,\n MDX_RENDERER_TTL_MS: () => MDX_RENDERER_TTL_MS,\n MINUTES_PER_HOUR: () => MINUTES_PER_HOUR,\n MIN_PORT: () => MIN_PORT,\n MS_PER_MINUTE: () => MS_PER_MINUTE,\n MS_PER_SECOND: () => MS_PER_SECOND,\n MemoCache: () => MemoCache,\n ONE_DAY_MS: () => ONE_DAY_MS,\n PATHS: () => PATHS,\n PREFETCH_DEFAULT_DELAY_MS: () => PREFETCH_DEFAULT_DELAY_MS,\n PREFETCH_DEFAULT_TIMEOUT_MS: () => PREFETCH_DEFAULT_TIMEOUT_MS,\n PREFETCH_MAX_SIZE_BYTES: () => PREFETCH_MAX_SIZE_BYTES,\n PROSE_MAX_WIDTH: () => PROSE_MAX_WIDTH,\n REACT_DEFAULT_VERSION: () => REACT_DEFAULT_VERSION,\n REACT_VERSION_17: () => REACT_VERSION_17,\n REACT_VERSION_18_2: () => REACT_VERSION_18_2,\n REACT_VERSION_18_3: () => REACT_VERSION_18_3,\n REACT_VERSION_19: () => REACT_VERSION_19,\n REACT_VERSION_19_RC: () => REACT_VERSION_19_RC,\n RENDERER_CORE_MAX_ENTRIES: () => RENDERER_CORE_MAX_ENTRIES,\n RENDERER_CORE_TTL_MS: () => RENDERER_CORE_TTL_MS,\n RESPONSIVE_IMAGE_WIDTHS: () => RESPONSIVE_IMAGE_WIDTHS,\n RESPONSIVE_IMAGE_WIDTH_LG: () => RESPONSIVE_IMAGE_WIDTH_LG,\n RESPONSIVE_IMAGE_WIDTH_MD: () => RESPONSIVE_IMAGE_WIDTH_MD,\n RESPONSIVE_IMAGE_WIDTH_SM: () => RESPONSIVE_IMAGE_WIDTH_SM,\n RESPONSIVE_IMAGE_WIDTH_XS: () => RESPONSIVE_IMAGE_WIDTH_XS,\n RSC_MANIFEST_CACHE_TTL_MS: () => RSC_MANIFEST_CACHE_TTL_MS,\n SECONDS_PER_MINUTE: () => SECONDS_PER_MINUTE,\n SERVER_ACTION_DEFAULT_TTL_SEC: () => SERVER_ACTION_DEFAULT_TTL_SEC,\n SERVER_FUNCTION_DEFAULT_TIMEOUT_MS: () => SERVER_FUNCTION_DEFAULT_TIMEOUT_MS,\n TSX_LAYOUT_MAX_ENTRIES: () => TSX_LAYOUT_MAX_ENTRIES,\n TSX_LAYOUT_TTL_MS: () => TSX_LAYOUT_TTL_MS,\n UNOCSS_VERSION: () => UNOCSS_VERSION,\n VERSION: () => VERSION,\n VERYFRONT_PATHS: () => VERYFRONT_PATHS,\n Z_INDEX_DEV_INDICATOR: () => Z_INDEX_DEV_INDICATOR,\n Z_INDEX_ERROR_OVERLAY: () => Z_INDEX_ERROR_OVERLAY,\n __loggerResetForTests: () => __loggerResetForTests,\n agentLogger: () => agentLogger,\n bundlerLogger: () => bundlerLogger,\n cliLogger: () => cliLogger,\n computeCodeHash: () => computeCodeHash,\n computeContentHash: () => computeContentHash,\n computeHash: () => computeHash,\n estimateSize: () => estimateSize,\n estimateSizeWithCircularHandling: () => estimateSizeWithCircularHandling,\n formatBytes: () => formatBytes,\n formatDuration: () => formatDuration,\n formatNumber: () => formatNumber,\n fromBase64Url: () => fromBase64Url,\n getBundleManifestStore: () => getBundleManifestStore,\n getBundleManifestTTL: () => getBundleManifestTTL,\n getContentHash: () => getContentHash,\n getDenoStdNodeBase: () => getDenoStdNodeBase,\n getDirectory: () => getDirectory,\n getEnvironmentVariable: () => getEnvironmentVariable,\n getExtension: () => getExtension,\n getReactCDNUrl: () => getReactCDNUrl,\n getReactDOMCDNUrl: () => getReactDOMCDNUrl,\n getReactDOMClientCDNUrl: () => getReactDOMClientCDNUrl,\n getReactDOMServerCDNUrl: () => getReactDOMServerCDNUrl,\n getReactImportMap: () => getReactImportMap,\n getReactJSXDevRuntimeCDNUrl: () => getReactJSXDevRuntimeCDNUrl,\n getReactJSXRuntimeCDNUrl: () => getReactJSXRuntimeCDNUrl,\n getUnoCSSTailwindResetUrl: () => getUnoCSSTailwindResetUrl,\n hasBunRuntime: () => hasBunRuntime,\n hasDenoRuntime: () => hasDenoRuntime,\n hasHashedFilename: () => hasHashedFilename,\n hasNodeProcess: () => hasNodeProcess,\n initializeBundleManifest: () => initializeBundleManifest,\n isAbsolutePath: () => isAbsolutePath,\n isCompiledBinary: () => isCompiledBinary,\n isDevelopmentEnvironment: () => isDevelopmentEnvironment,\n isProductionEnvironment: () => isProductionEnvironment,\n isRSCEnabled: () => isRSCEnabled,\n isTestEnvironment: () => isTestEnvironment,\n isValidHMRMessageType: () => isValidHMRMessageType,\n isWithinDirectory: () => isWithinDirectory,\n joinPath: () => joinPath,\n logger: () => logger,\n memoize: () => memoize,\n memoizeAsync: () => memoizeAsync,\n memoizeHash: () => simpleHash2,\n normalizePath: () => normalizePath,\n numericHash: () => simpleHash,\n rendererLogger: () => rendererLogger,\n serverLogger: () => serverLogger,\n setBundleManifestStore: () => setBundleManifestStore,\n shortHash: () => shortHash,\n simpleHash: () => simpleHash,\n toBase64Url: () => toBase64Url,\n truncateString: () => truncateString,\n warmupBundleManifest: () => warmupBundleManifest\n});\nvar init_utils = __esm({\n "src/core/utils/index.ts"() {\n init_runtime_guards();\n init_logger2();\n init_constants();\n init_version();\n init_paths();\n init_hash_utils();\n init_memoize();\n init_path_utils();\n init_format_utils();\n init_bundle_manifest();\n init_bundle_manifest_init();\n init_feature_flags();\n init_platform();\n }\n});\n\n// src/core/errors/veryfront-error.ts\nfunction createError(error2) {\n return error2;\n}\nfunction toError(veryfrontError) {\n const error2 = new Error(veryfrontError.message);\n error2.name = `VeryfrontError[${veryfrontError.type}]`;\n Object.defineProperty(error2, "context", {\n value: veryfrontError,\n enumerable: false,\n configurable: true\n });\n return error2;\n}\nvar init_veryfront_error = __esm({\n "src/core/errors/veryfront-error.ts"() {\n "use strict";\n }\n});\n\n// src/core/config/schema.ts\nimport { z } from "zod";\nvar corsSchema, veryfrontConfigSchema;\nvar init_schema = __esm({\n "src/core/config/schema.ts"() {\n "use strict";\n init_veryfront_error();\n corsSchema = z.union([z.boolean(), z.object({ origin: z.string().optional() }).strict()]);\n veryfrontConfigSchema = z.object({\n title: z.string().optional(),\n description: z.string().optional(),\n experimental: z.object({\n esmLayouts: z.boolean().optional(),\n precompileMDX: z.boolean().optional()\n }).partial().optional(),\n router: z.enum(["app", "pages"]).optional(),\n defaultLayout: z.string().optional(),\n theme: z.object({ colors: z.record(z.string()).optional() }).partial().optional(),\n build: z.object({\n outDir: z.string().optional(),\n trailingSlash: z.boolean().optional(),\n esbuild: z.object({\n wasmURL: z.string().url().optional(),\n worker: z.boolean().optional()\n }).partial().optional()\n }).partial().optional(),\n cache: z.object({\n dir: z.string().optional(),\n bundleManifest: z.object({\n type: z.enum(["redis", "kv", "memory"]).optional(),\n redisUrl: z.string().optional(),\n keyPrefix: z.string().optional(),\n ttl: z.number().int().positive().optional(),\n enabled: z.boolean().optional()\n }).partial().optional()\n }).partial().optional(),\n dev: z.object({\n port: z.number().int().positive().optional(),\n host: z.string().optional(),\n open: z.boolean().optional(),\n hmr: z.boolean().optional(),\n components: z.array(z.string()).optional()\n }).partial().optional(),\n resolve: z.object({\n importMap: z.object({\n imports: z.record(z.string()).optional(),\n scopes: z.record(z.record(z.string())).optional()\n }).partial().optional()\n }).partial().optional(),\n security: z.object({\n csp: z.record(z.array(z.string())).optional(),\n remoteHosts: z.array(z.string().url()).optional(),\n cors: corsSchema.optional(),\n coop: z.enum(["same-origin", "same-origin-allow-popups", "unsafe-none"]).optional(),\n corp: z.enum(["same-origin", "same-site", "cross-origin"]).optional(),\n coep: z.enum(["require-corp", "unsafe-none"]).optional()\n }).partial().optional(),\n middleware: z.object({\n custom: z.array(z.function()).optional()\n }).partial().optional(),\n theming: z.object({\n brandName: z.string().optional(),\n logoHtml: z.string().optional()\n }).partial().optional(),\n assetPipeline: z.object({\n images: z.object({\n enabled: z.boolean().optional(),\n formats: z.array(z.enum(["webp", "avif", "jpeg", "png"])).optional(),\n sizes: z.array(z.number().int().positive()).optional(),\n quality: z.number().int().min(1).max(100).optional(),\n inputDir: z.string().optional(),\n outputDir: z.string().optional(),\n preserveOriginal: z.boolean().optional()\n }).partial().optional(),\n css: z.object({\n enabled: z.boolean().optional(),\n minify: z.boolean().optional(),\n autoprefixer: z.boolean().optional(),\n purge: z.boolean().optional(),\n criticalCSS: z.boolean().optional(),\n inputDir: z.string().optional(),\n outputDir: z.string().optional(),\n browsers: z.array(z.string()).optional(),\n purgeContent: z.array(z.string()).optional(),\n sourceMap: z.boolean().optional()\n }).partial().optional()\n }).partial().optional(),\n observability: z.object({\n tracing: z.object({\n enabled: z.boolean().optional(),\n exporter: z.enum(["jaeger", "zipkin", "otlp", "console"]).optional(),\n endpoint: z.string().optional(),\n serviceName: z.string().optional(),\n sampleRate: z.number().min(0).max(1).optional()\n }).partial().optional(),\n metrics: z.object({\n enabled: z.boolean().optional(),\n exporter: z.enum(["prometheus", "otlp", "console"]).optional(),\n endpoint: z.string().optional(),\n prefix: z.string().optional(),\n collectInterval: z.number().int().positive().optional()\n }).partial().optional()\n }).partial().optional(),\n fs: z.object({\n type: z.enum(["local", "veryfront-api", "memory"]).optional(),\n local: z.object({\n baseDir: z.string().optional()\n }).partial().optional(),\n veryfront: z.object({\n apiBaseUrl: z.string().url(),\n apiToken: z.string(),\n projectSlug: z.string(),\n cache: z.object({\n enabled: z.boolean().optional(),\n ttl: z.number().int().positive().optional(),\n maxSize: z.number().int().positive().optional()\n }).partial().optional(),\n retry: z.object({\n maxRetries: z.number().int().min(0).optional(),\n initialDelay: z.number().int().positive().optional(),\n maxDelay: z.number().int().positive().optional()\n }).partial().optional()\n }).partial().optional(),\n memory: z.object({\n files: z.record(z.union([z.string(), z.instanceof(Uint8Array)])).optional()\n }).partial().optional()\n }).partial().optional()\n }).partial();\n }\n});\n\n// src/_shims/std-path.ts\nimport * as nodeUrl from "node:url";\nimport * as nodePath from "node:path";\nvar init_std_path = __esm({\n "src/_shims/std-path.ts"() {\n }\n});\n\n// src/core/config/loader.ts\nfunction getDefaultImportMapForConfig() {\n return { imports: getReactImportMap(REACT_DEFAULT_VERSION) };\n}\nvar DEFAULT_CONFIG;\nvar init_loader = __esm({\n "src/core/config/loader.ts"() {\n "use strict";\n init_schema();\n init_std_path();\n init_logger();\n init_cdn();\n DEFAULT_CONFIG = {\n title: "Veryfront App",\n description: "Built with Veryfront",\n experimental: {\n esmLayouts: true\n },\n router: void 0,\n defaultLayout: void 0,\n theme: {\n colors: {\n primary: "#3B82F6"\n }\n },\n build: {\n outDir: "dist",\n trailingSlash: false,\n esbuild: {\n wasmURL: "https://deno.land/x/esbuild@v0.20.1/esbuild.wasm",\n worker: false\n }\n },\n cache: {\n dir: ".veryfront/cache",\n render: {\n type: "memory",\n ttl: void 0,\n maxEntries: 500,\n kvPath: void 0,\n redisUrl: void 0,\n redisKeyPrefix: void 0\n }\n },\n dev: {\n port: 3002,\n host: "localhost",\n open: false\n },\n resolve: {\n importMap: getDefaultImportMapForConfig()\n }\n };\n }\n});\n\n// src/core/config/define-config.ts\nvar init_define_config = __esm({\n "src/core/config/define-config.ts"() {\n "use strict";\n init_veryfront_error();\n }\n});\n\n// src/core/config/defaults.ts\nvar DEFAULT_DEV_PORT, DEFAULT_PREFETCH_DELAY_MS, DURATION_HISTOGRAM_BOUNDARIES_MS, SIZE_HISTOGRAM_BOUNDARIES_KB, PAGE_TRANSITION_DELAY_MS;\nvar init_defaults = __esm({\n "src/core/config/defaults.ts"() {\n "use strict";\n DEFAULT_DEV_PORT = 3e3;\n DEFAULT_PREFETCH_DELAY_MS = 100;\n DURATION_HISTOGRAM_BOUNDARIES_MS = [\n 5,\n 10,\n 25,\n 50,\n 75,\n 100,\n 250,\n 500,\n 750,\n 1e3,\n 2500,\n 5e3,\n 7500,\n 1e4\n ];\n SIZE_HISTOGRAM_BOUNDARIES_KB = [\n 1,\n 5,\n 10,\n 25,\n 50,\n 100,\n 250,\n 500,\n 1e3,\n 2500,\n 5e3,\n 1e4\n ];\n PAGE_TRANSITION_DELAY_MS = 150;\n }\n});\n\n// src/core/config/network-defaults.ts\nvar init_network_defaults = __esm({\n "src/core/config/network-defaults.ts"() {\n "use strict";\n }\n});\n\n// src/core/config/index.ts\nvar init_config = __esm({\n "src/core/config/index.ts"() {\n init_loader();\n init_define_config();\n init_schema();\n init_defaults();\n init_network_defaults();\n }\n});\n\n// src/core/errors/types.ts\nvar VeryfrontError;\nvar init_types = __esm({\n "src/core/errors/types.ts"() {\n "use strict";\n VeryfrontError = class extends Error {\n constructor(message, code, context) {\n super(message);\n this.name = "VeryfrontError";\n this.code = code;\n this.context = context;\n }\n };\n }\n});\n\n// src/core/errors/agent-errors.ts\nvar init_agent_errors = __esm({\n "src/core/errors/agent-errors.ts"() {\n "use strict";\n init_types();\n }\n});\n\n// src/core/errors/build-errors.ts\nvar init_build_errors = __esm({\n "src/core/errors/build-errors.ts"() {\n "use strict";\n init_types();\n }\n});\n\n// src/core/errors/runtime-errors.ts\nvar init_runtime_errors = __esm({\n "src/core/errors/runtime-errors.ts"() {\n "use strict";\n init_types();\n }\n});\n\n// src/core/errors/system-errors.ts\nvar NetworkError;\nvar init_system_errors = __esm({\n "src/core/errors/system-errors.ts"() {\n "use strict";\n init_types();\n NetworkError = class extends VeryfrontError {\n constructor(message, context) {\n super(message, "NETWORK_ERROR" /* NETWORK_ERROR */, context);\n this.name = "NetworkError";\n }\n };\n }\n});\n\n// src/core/errors/error-handlers.ts\nvar init_error_handlers = __esm({\n "src/core/errors/error-handlers.ts"() {\n "use strict";\n init_logger();\n init_types();\n }\n});\n\n// src/core/errors/error-codes.ts\nfunction getErrorDocsUrl(code) {\n return `https://veryfront.com/docs/errors/${code}`;\n}\nvar ErrorCode2;\nvar init_error_codes = __esm({\n "src/core/errors/error-codes.ts"() {\n "use strict";\n ErrorCode2 = {\n CONFIG_NOT_FOUND: "VF001",\n CONFIG_INVALID: "VF002",\n CONFIG_PARSE_ERROR: "VF003",\n CONFIG_VALIDATION_ERROR: "VF004",\n CONFIG_TYPE_ERROR: "VF005",\n IMPORT_MAP_INVALID: "VF006",\n CORS_CONFIG_INVALID: "VF007",\n BUILD_FAILED: "VF100",\n BUNDLE_ERROR: "VF101",\n TYPESCRIPT_ERROR: "VF102",\n MDX_COMPILE_ERROR: "VF103",\n ASSET_OPTIMIZATION_ERROR: "VF104",\n SSG_GENERATION_ERROR: "VF105",\n SOURCEMAP_ERROR: "VF106",\n HYDRATION_MISMATCH: "VF200",\n RENDER_ERROR: "VF201",\n COMPONENT_ERROR: "VF202",\n LAYOUT_NOT_FOUND: "VF203",\n PAGE_NOT_FOUND: "VF204",\n API_ERROR: "VF205",\n MIDDLEWARE_ERROR: "VF206",\n ROUTE_CONFLICT: "VF300",\n INVALID_ROUTE_FILE: "VF301",\n ROUTE_HANDLER_INVALID: "VF302",\n DYNAMIC_ROUTE_ERROR: "VF303",\n ROUTE_PARAMS_ERROR: "VF304",\n API_ROUTE_ERROR: "VF305",\n MODULE_NOT_FOUND: "VF400",\n IMPORT_RESOLUTION_ERROR: "VF401",\n CIRCULAR_DEPENDENCY: "VF402",\n INVALID_IMPORT: "VF403",\n DEPENDENCY_MISSING: "VF404",\n VERSION_MISMATCH: "VF405",\n PORT_IN_USE: "VF500",\n SERVER_START_ERROR: "VF501",\n HMR_ERROR: "VF502",\n CACHE_ERROR: "VF503",\n FILE_WATCH_ERROR: "VF504",\n REQUEST_ERROR: "VF505",\n CLIENT_BOUNDARY_VIOLATION: "VF600",\n SERVER_ONLY_IN_CLIENT: "VF601",\n CLIENT_ONLY_IN_SERVER: "VF602",\n INVALID_USE_CLIENT: "VF603",\n INVALID_USE_SERVER: "VF604",\n RSC_PAYLOAD_ERROR: "VF605",\n DEV_SERVER_ERROR: "VF700",\n FAST_REFRESH_ERROR: "VF701",\n ERROR_OVERLAY_ERROR: "VF702",\n SOURCE_MAP_ERROR: "VF703",\n DEPLOYMENT_ERROR: "VF800",\n PLATFORM_ERROR: "VF801",\n ENV_VAR_MISSING: "VF802",\n PRODUCTION_BUILD_REQUIRED: "VF803",\n UNKNOWN_ERROR: "VF900",\n PERMISSION_DENIED: "VF901",\n FILE_NOT_FOUND: "VF902",\n INVALID_ARGUMENT: "VF903",\n TIMEOUT_ERROR: "VF904"\n };\n }\n});\n\n// src/core/errors/catalog/factory.ts\nfunction createErrorSolution(code, config) {\n return {\n code,\n ...config,\n docs: config.docs ?? getErrorDocsUrl(code)\n };\n}\nfunction createSimpleError(code, title, message, steps) {\n return createErrorSolution(code, { title, message, steps });\n}\nvar init_factory = __esm({\n "src/core/errors/catalog/factory.ts"() {\n "use strict";\n init_error_codes();\n }\n});\n\n// src/core/errors/catalog/config-errors.ts\nvar CONFIG_ERROR_CATALOG;\nvar init_config_errors = __esm({\n "src/core/errors/catalog/config-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n CONFIG_ERROR_CATALOG = {\n [ErrorCode2.CONFIG_NOT_FOUND]: createErrorSolution(ErrorCode2.CONFIG_NOT_FOUND, {\n title: "Configuration file not found",\n message: "Veryfront could not find veryfront.config.js in your project root.",\n steps: [\n "Create veryfront.config.js in your project root directory",\n "Run \'veryfront init\' to generate a default configuration",\n "Or copy from an example project"\n ],\n example: `// veryfront.config.js\nexport default {\n title: "My App",\n dev: { port: 3002 }\n}`,\n tips: ["You can use .ts or .mjs extensions too", "Config is optional for simple projects"]\n }),\n [ErrorCode2.CONFIG_INVALID]: createErrorSolution(ErrorCode2.CONFIG_INVALID, {\n title: "Invalid configuration",\n message: "Your configuration file has invalid values or structure.",\n steps: [\n "Check that the config exports a default object",\n "Ensure all values are valid JavaScript types",\n "Remove any trailing commas",\n "Verify property names match the schema"\n ],\n example: `// \\u2713 Valid config\nexport default {\n title: "My App",\n dev: {\n port: 3002,\n open: true\n }\n}`\n }),\n [ErrorCode2.CONFIG_PARSE_ERROR]: createSimpleError(\n ErrorCode2.CONFIG_PARSE_ERROR,\n "Configuration parse error",\n "Failed to parse your configuration file.",\n [\n "Check for syntax errors (missing brackets, quotes, etc.)",\n "Ensure the file has valid JavaScript/TypeScript syntax",\n "Look for the specific parse error in the output above"\n ]\n ),\n [ErrorCode2.CONFIG_VALIDATION_ERROR]: createSimpleError(\n ErrorCode2.CONFIG_VALIDATION_ERROR,\n "Configuration validation failed",\n "Configuration values do not pass validation.",\n [\n "Check that port numbers are between 1-65535",\n "Ensure boolean flags are true/false (not strings)",\n "Verify URLs are properly formatted",\n "Check array/object structures match expected format"\n ]\n ),\n [ErrorCode2.CONFIG_TYPE_ERROR]: createSimpleError(\n ErrorCode2.CONFIG_TYPE_ERROR,\n "Configuration type error",\n "A configuration value has the wrong type.",\n [\n "Check that numbers are not in quotes",\n \'Ensure booleans are true/false, not "true"/"false"\',\n "Verify arrays use [] brackets",\n "Check objects use {} braces"\n ]\n ),\n [ErrorCode2.IMPORT_MAP_INVALID]: createErrorSolution(ErrorCode2.IMPORT_MAP_INVALID, {\n title: "Invalid import map",\n message: "The import map in your configuration is invalid.",\n steps: [\n "Check import map structure: { imports: {}, scopes: {} }",\n "Ensure URLs are valid and accessible",\n "Verify package names are correct"\n ],\n example: `resolve: {\n importMap: {\n imports: {\n "react": "https://esm.sh/react@19",\n "@/utils": "./src/utils/index.ts"\n }\n }\n}`\n }),\n [ErrorCode2.CORS_CONFIG_INVALID]: createErrorSolution(ErrorCode2.CORS_CONFIG_INVALID, {\n title: "Invalid CORS configuration",\n message: "The CORS configuration is invalid.",\n steps: [\n "Use true for default CORS settings",\n "Or provide an object with origin, methods, headers",\n "Ensure origin is a string, not an array"\n ],\n example: `security: {\n cors: true // or { origin: "https://example.com" }\n}`\n })\n };\n }\n});\n\n// src/core/errors/catalog/build-errors.ts\nvar BUILD_ERROR_CATALOG;\nvar init_build_errors2 = __esm({\n "src/core/errors/catalog/build-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n BUILD_ERROR_CATALOG = {\n [ErrorCode2.BUILD_FAILED]: createErrorSolution(ErrorCode2.BUILD_FAILED, {\n title: "Build failed",\n message: "The build process encountered errors.",\n steps: [\n "Check the error messages above for specific issues",\n "Fix any TypeScript or syntax errors",\n "Ensure all imports can be resolved",\n "Run \'veryfront doctor\' to check your environment"\n ],\n tips: ["Try running with --verbose for more details", "Check build logs for warnings"]\n }),\n [ErrorCode2.BUNDLE_ERROR]: createSimpleError(\n ErrorCode2.BUNDLE_ERROR,\n "Bundle generation failed",\n "Failed to generate JavaScript bundles.",\n [\n "Check for circular dependencies",\n "Ensure all imports are valid",\n "Try clearing cache: veryfront clean"\n ]\n ),\n [ErrorCode2.TYPESCRIPT_ERROR]: createSimpleError(\n ErrorCode2.TYPESCRIPT_ERROR,\n "TypeScript compilation error",\n "TypeScript found errors in your code.",\n [\n "Fix the TypeScript errors shown above",\n "Check your tsconfig.json configuration",\n "Ensure all types are properly imported"\n ]\n ),\n [ErrorCode2.MDX_COMPILE_ERROR]: createErrorSolution(ErrorCode2.MDX_COMPILE_ERROR, {\n title: "MDX compilation failed",\n message: "Failed to compile MDX file.",\n steps: [\n "Check for syntax errors in your MDX file",\n "Ensure frontmatter YAML is valid",\n "Verify JSX components are properly imported",\n "Check for unclosed tags or brackets"\n ],\n example: `---\ntitle: My Post\n---\n\nimport Button from \'./components/Button.jsx\'\n\n# Hello World\n\n<Button>Click me</Button>`\n }),\n [ErrorCode2.ASSET_OPTIMIZATION_ERROR]: createSimpleError(\n ErrorCode2.ASSET_OPTIMIZATION_ERROR,\n "Asset optimization failed",\n "Failed to optimize assets (images, CSS, etc.).",\n [\n "Check that asset files are valid",\n "Ensure file paths are correct",\n "Try disabling optimization temporarily"\n ]\n ),\n [ErrorCode2.SSG_GENERATION_ERROR]: createSimpleError(\n ErrorCode2.SSG_GENERATION_ERROR,\n "Static site generation failed",\n "Failed to generate static pages.",\n [\n "Check that all routes are valid",\n "Ensure getStaticData functions return correctly",\n "Verify no dynamic content requires runtime"\n ]\n ),\n [ErrorCode2.SOURCEMAP_ERROR]: createSimpleError(\n ErrorCode2.SOURCEMAP_ERROR,\n "Source map generation failed",\n "Failed to generate source maps.",\n [\n "Try disabling source maps temporarily",\n "Check for very large files that might cause issues"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/runtime-errors.ts\nvar RUNTIME_ERROR_CATALOG;\nvar init_runtime_errors2 = __esm({\n "src/core/errors/catalog/runtime-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n RUNTIME_ERROR_CATALOG = {\n [ErrorCode2.HYDRATION_MISMATCH]: createErrorSolution(ErrorCode2.HYDRATION_MISMATCH, {\n title: "Hydration mismatch",\n message: "Client-side HTML does not match server-rendered HTML.",\n steps: [\n "Check for random values or timestamps in render",\n "Ensure Date() calls are consistent",\n "Avoid using browser-only APIs during SSR",\n "Check for white space or formatting differences"\n ],\n example: `// \\u274C Wrong - random on each render\n<div>{Math.random()}</div>\n\nconst [random, setRandom] = useState(0)\nuseEffect(() => setRandom(Math.random()), [])\n<div>{random}</div>`,\n relatedErrors: [ErrorCode2.RENDER_ERROR]\n }),\n [ErrorCode2.RENDER_ERROR]: createSimpleError(\n ErrorCode2.RENDER_ERROR,\n "Render error",\n "Failed to render component.",\n [\n "Check the component for errors",\n "Ensure all props are valid",\n "Look for null/undefined access",\n "Check error boundaries"\n ]\n ),\n [ErrorCode2.COMPONENT_ERROR]: createSimpleError(\n ErrorCode2.COMPONENT_ERROR,\n "Component error",\n "Error in component lifecycle or render.",\n [\n "Check component code for errors",\n "Ensure hooks follow Rules of Hooks",\n "Verify props are passed correctly"\n ]\n ),\n [ErrorCode2.LAYOUT_NOT_FOUND]: createErrorSolution(ErrorCode2.LAYOUT_NOT_FOUND, {\n title: "Layout file not found",\n message: "Required layout file is missing.",\n steps: [\n "Create app/layout.tsx in App Router",\n "Or create layouts/default.mdx for Pages Router",\n "Check file path and name are correct"\n ],\n example: `// app/layout.tsx\nexport default function RootLayout({ children }) {\n return (\n <html lang="en">\n <body>{children}</body>\n </html>\n )\n}`\n }),\n [ErrorCode2.PAGE_NOT_FOUND]: createSimpleError(\n ErrorCode2.PAGE_NOT_FOUND,\n "Page not found",\n "The requested page does not exist.",\n [\n "Check that the page file exists",\n "Verify file name matches route",\n "Ensure file extension is correct (.tsx, .jsx, .mdx)"\n ]\n ),\n [ErrorCode2.API_ERROR]: createSimpleError(\n ErrorCode2.API_ERROR,\n "API handler error",\n "Error in API route handler.",\n [\n "Check API handler code for errors",\n "Ensure proper error handling",\n "Verify request/response format"\n ]\n ),\n [ErrorCode2.MIDDLEWARE_ERROR]: createSimpleError(\n ErrorCode2.MIDDLEWARE_ERROR,\n "Middleware error",\n "Error in middleware execution.",\n [\n "Check middleware code for errors",\n "Ensure middleware returns Response",\n "Verify middleware is properly exported"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/route-errors.ts\nvar ROUTE_ERROR_CATALOG;\nvar init_route_errors = __esm({\n "src/core/errors/catalog/route-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n ROUTE_ERROR_CATALOG = {\n [ErrorCode2.ROUTE_CONFLICT]: createSimpleError(\n ErrorCode2.ROUTE_CONFLICT,\n "Route conflict",\n "Multiple files are trying to handle the same route.",\n [\n "Check for duplicate route files",\n "Remove conflicting routes",\n "Use dynamic routes [id] carefully"\n ]\n ),\n [ErrorCode2.INVALID_ROUTE_FILE]: createErrorSolution(ErrorCode2.INVALID_ROUTE_FILE, {\n title: "Invalid route file",\n message: "Route file has invalid structure or exports.",\n steps: [\n "API routes must export GET, POST, etc. functions",\n "Page routes must export default component",\n "Check for syntax errors"\n ],\n example: `// app/api/users/route.ts\nexport async function GET() {\n return Response.json({ users: [] })\n}`\n }),\n [ErrorCode2.ROUTE_HANDLER_INVALID]: createSimpleError(\n ErrorCode2.ROUTE_HANDLER_INVALID,\n "Invalid route handler",\n "Route handler does not return Response.",\n [\n "Ensure handler returns Response object",\n "Use Response.json() for JSON responses",\n "Check for missing return statement"\n ]\n ),\n [ErrorCode2.DYNAMIC_ROUTE_ERROR]: createSimpleError(\n ErrorCode2.DYNAMIC_ROUTE_ERROR,\n "Dynamic route error",\n "Error in dynamic route handling.",\n [\n "Check [param] syntax is correct",\n "Ensure params are accessed properly",\n "Verify dynamic segment names"\n ]\n ),\n [ErrorCode2.ROUTE_PARAMS_ERROR]: createSimpleError(\n ErrorCode2.ROUTE_PARAMS_ERROR,\n "Route parameters error",\n "Error accessing route parameters.",\n [\n "Check params object structure",\n "Ensure parameter names match route",\n "Verify params are strings"\n ]\n ),\n [ErrorCode2.API_ROUTE_ERROR]: createSimpleError(\n ErrorCode2.API_ROUTE_ERROR,\n "API route error",\n "Error in API route execution.",\n [\n "Check API handler code",\n "Ensure proper error handling",\n "Verify request parsing"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/module-errors.ts\nvar MODULE_ERROR_CATALOG;\nvar init_module_errors = __esm({\n "src/core/errors/catalog/module-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n MODULE_ERROR_CATALOG = {\n [ErrorCode2.MODULE_NOT_FOUND]: createErrorSolution(ErrorCode2.MODULE_NOT_FOUND, {\n title: "Module not found",\n message: "Cannot find the imported module.",\n steps: [\n "Check that the file path is correct",\n "Ensure the module is installed or exists",\n "Add missing module to import map",\n "Check for typos in import statement"\n ],\n example: `// Add to veryfront.config.js\nresolve: {\n importMap: {\n imports: {\n "missing-lib": "https://esm.sh/missing-lib@1.0.0"\n }\n }\n}`\n }),\n [ErrorCode2.IMPORT_RESOLUTION_ERROR]: createSimpleError(\n ErrorCode2.IMPORT_RESOLUTION_ERROR,\n "Import resolution failed",\n "Failed to resolve import specifier.",\n [\n "Check import paths are correct",\n "Ensure modules are in import map",\n "Verify network connectivity for remote imports"\n ]\n ),\n [ErrorCode2.CIRCULAR_DEPENDENCY]: createSimpleError(\n ErrorCode2.CIRCULAR_DEPENDENCY,\n "Circular dependency detected",\n "Files are importing each other in a circle.",\n [\n "Identify the circular import chain",\n "Extract shared code to separate file",\n "Use dependency injection or lazy imports"\n ]\n ),\n [ErrorCode2.INVALID_IMPORT]: createSimpleError(\n ErrorCode2.INVALID_IMPORT,\n "Invalid import statement",\n "Import statement has invalid syntax.",\n [\n \'Check import syntax: import X from "y"\',\n "Ensure quotes are properly closed",\n "Verify export exists in target module"\n ]\n ),\n [ErrorCode2.DEPENDENCY_MISSING]: createErrorSolution(ErrorCode2.DEPENDENCY_MISSING, {\n title: "Required dependency not found",\n message: "A required dependency is missing.",\n steps: [\n "Add React to your import map",\n "Ensure all peer dependencies are included",\n "Run \'veryfront doctor\' to verify setup"\n ],\n example: `// Minimum required imports\nresolve: {\n importMap: {\n imports: {\n "react": "https://esm.sh/react@19",\n "react-dom": "https://esm.sh/react-dom@19"\n }\n }\n}`\n }),\n [ErrorCode2.VERSION_MISMATCH]: createSimpleError(\n ErrorCode2.VERSION_MISMATCH,\n "Dependency version mismatch",\n "Incompatible versions of dependencies detected.",\n [\n "Ensure React and React-DOM versions match",\n "Check for multiple React instances",\n "Update dependencies to compatible versions"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/server-errors.ts\nvar SERVER_ERROR_CATALOG;\nvar init_server_errors = __esm({\n "src/core/errors/catalog/server-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n SERVER_ERROR_CATALOG = {\n [ErrorCode2.PORT_IN_USE]: createErrorSolution(ErrorCode2.PORT_IN_USE, {\n title: "Port already in use",\n message: "Another process is using the specified port.",\n steps: [\n "Stop the other process: lsof -i :PORT",\n "Use a different port: veryfront dev --port 3003",\n "Add port to config file"\n ],\n example: `// veryfront.config.js\ndev: {\n port: 3003\n}`\n }),\n [ErrorCode2.SERVER_START_ERROR]: createSimpleError(\n ErrorCode2.SERVER_START_ERROR,\n "Server failed to start",\n "Development server could not start.",\n [\n "Check for port conflicts",\n "Ensure file permissions are correct",\n "Verify configuration is valid"\n ]\n ),\n [ErrorCode2.HMR_ERROR]: createSimpleError(\n ErrorCode2.HMR_ERROR,\n "Hot Module Replacement error",\n "HMR failed to update module.",\n [\n "Try refreshing the page",\n "Check for syntax errors",\n "Restart dev server if persistent"\n ]\n ),\n [ErrorCode2.CACHE_ERROR]: createSimpleError(\n ErrorCode2.CACHE_ERROR,\n "Cache operation failed",\n "Error reading or writing cache.",\n [\n "Clear cache: veryfront clean --cache",\n "Check disk space",\n "Verify file permissions"\n ]\n ),\n [ErrorCode2.FILE_WATCH_ERROR]: createSimpleError(\n ErrorCode2.FILE_WATCH_ERROR,\n "File watching failed",\n "Could not watch files for changes.",\n [\n "Check system file watch limits",\n "Reduce number of watched files",\n "Try restarting dev server"\n ]\n ),\n [ErrorCode2.REQUEST_ERROR]: createSimpleError(\n ErrorCode2.REQUEST_ERROR,\n "Request handling error",\n "Error processing HTTP request.",\n [\n "Check request format and headers",\n "Verify route handler code",\n "Check for middleware errors"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/rsc-errors.ts\nvar RSC_ERROR_CATALOG;\nvar init_rsc_errors = __esm({\n "src/core/errors/catalog/rsc-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n RSC_ERROR_CATALOG = {\n [ErrorCode2.CLIENT_BOUNDARY_VIOLATION]: createErrorSolution(\n ErrorCode2.CLIENT_BOUNDARY_VIOLATION,\n {\n title: "Client/Server boundary violation",\n message: "Server-only code used in Client Component.",\n steps: [\n "Move server-only imports to Server Components",\n "Use \'use server\' for server actions",\n "Split component into server and client parts"\n ],\n example: `// \\u2713 Correct pattern\nimport { db } from \'./database\'\nexport default async function ServerComponent() {\n const data = await db.query(\'...\')\n return <ClientComponent data={data} />\n}\n\n\'use client\'\nexport default function ClientComponent({ data }) {\n return <div>{data}</div>\n}`\n }\n ),\n [ErrorCode2.SERVER_ONLY_IN_CLIENT]: createSimpleError(\n ErrorCode2.SERVER_ONLY_IN_CLIENT,\n "Server-only module in Client Component",\n "Cannot use server-only module in client code.",\n [\n "Move server logic to Server Component",\n "Use API routes for client data fetching",\n "Pass data as props from server"\n ]\n ),\n [ErrorCode2.CLIENT_ONLY_IN_SERVER]: createSimpleError(\n ErrorCode2.CLIENT_ONLY_IN_SERVER,\n "Client-only code in Server Component",\n "Cannot use browser APIs in Server Component.",\n [\n "Add \'use client\' directive",\n "Move client-only code to Client Component",\n "Use useEffect for client-side logic"\n ]\n ),\n [ErrorCode2.INVALID_USE_CLIENT]: createErrorSolution(ErrorCode2.INVALID_USE_CLIENT, {\n title: "Invalid \'use client\' directive",\n message: "\'use client\' directive is not properly placed.",\n steps: [\n "Place \'use client\' at the very top of file",\n "Must be before any imports",\n \'Use exact string: "use client"\'\n ],\n example: `\'use client\' // Must be first line\n\nimport React from \'react\'`\n }),\n [ErrorCode2.INVALID_USE_SERVER]: createSimpleError(\n ErrorCode2.INVALID_USE_SERVER,\n "Invalid \'use server\' directive",\n "\'use server\' directive is not properly placed.",\n [\n "Place \'use server\' at top of function",\n "Or at top of file for all functions",\n \'Use exact string: "use server"\'\n ]\n ),\n [ErrorCode2.RSC_PAYLOAD_ERROR]: createSimpleError(\n ErrorCode2.RSC_PAYLOAD_ERROR,\n "RSC payload error",\n "Error serializing Server Component payload.",\n [\n "Ensure props are JSON-serializable",\n "Avoid passing functions as props",\n "Check for circular references"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/dev-errors.ts\nvar DEV_ERROR_CATALOG;\nvar init_dev_errors = __esm({\n "src/core/errors/catalog/dev-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n DEV_ERROR_CATALOG = {\n [ErrorCode2.DEV_SERVER_ERROR]: createSimpleError(\n ErrorCode2.DEV_SERVER_ERROR,\n "Development server error",\n "Error in development server.",\n [\n "Check server logs for details",\n "Try restarting dev server",\n "Clear cache and restart"\n ]\n ),\n [ErrorCode2.FAST_REFRESH_ERROR]: createSimpleError(\n ErrorCode2.FAST_REFRESH_ERROR,\n "Fast Refresh error",\n "React Fast Refresh failed.",\n [\n "Check for syntax errors",\n "Ensure components follow Fast Refresh rules",\n "Try full page refresh"\n ]\n ),\n [ErrorCode2.ERROR_OVERLAY_ERROR]: createSimpleError(\n ErrorCode2.ERROR_OVERLAY_ERROR,\n "Error overlay failed",\n "Could not display error overlay.",\n [\n "Check browser console for details",\n "Try disabling browser extensions",\n "Refresh the page"\n ]\n ),\n [ErrorCode2.SOURCE_MAP_ERROR]: createSimpleError(\n ErrorCode2.SOURCE_MAP_ERROR,\n "Source map error",\n "Error loading or parsing source map.",\n [\n "Check that source maps are enabled",\n "Try rebuilding the project",\n "Check for corrupted build files"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/deployment-errors.ts\nvar DEPLOYMENT_ERROR_CATALOG;\nvar init_deployment_errors = __esm({\n "src/core/errors/catalog/deployment-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n DEPLOYMENT_ERROR_CATALOG = {\n [ErrorCode2.DEPLOYMENT_ERROR]: createSimpleError(\n ErrorCode2.DEPLOYMENT_ERROR,\n "Deployment failed",\n "Failed to deploy application.",\n [\n "Check deployment logs for details",\n "Verify platform credentials",\n "Ensure build succeeded first"\n ]\n ),\n [ErrorCode2.PLATFORM_ERROR]: createSimpleError(\n ErrorCode2.PLATFORM_ERROR,\n "Platform error",\n "Deployment platform returned an error.",\n [\n "Check platform status page",\n "Verify API keys and credentials",\n "Try deploying again"\n ]\n ),\n [ErrorCode2.ENV_VAR_MISSING]: createSimpleError(\n ErrorCode2.ENV_VAR_MISSING,\n "Environment variable missing",\n "Required environment variable is not set.",\n [\n "Add variable to .env file",\n "Set variable in deployment platform",\n "Check variable name is correct"\n ]\n ),\n [ErrorCode2.PRODUCTION_BUILD_REQUIRED]: createSimpleError(\n ErrorCode2.PRODUCTION_BUILD_REQUIRED,\n "Production build required",\n "Must build project before deploying.",\n [\n "Run \'veryfront build\' first",\n "Check that dist/ directory exists",\n "Verify build completed successfully"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/general-errors.ts\nvar GENERAL_ERROR_CATALOG;\nvar init_general_errors = __esm({\n "src/core/errors/catalog/general-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n GENERAL_ERROR_CATALOG = {\n [ErrorCode2.UNKNOWN_ERROR]: createSimpleError(\n ErrorCode2.UNKNOWN_ERROR,\n "Unknown error",\n "An unexpected error occurred.",\n [\n "Check error details above",\n "Run \'veryfront doctor\' to diagnose",\n "Try restarting the operation",\n "Check GitHub issues for similar problems"\n ]\n ),\n [ErrorCode2.PERMISSION_DENIED]: createSimpleError(\n ErrorCode2.PERMISSION_DENIED,\n "Permission denied",\n "Insufficient permissions to perform operation.",\n [\n "Check file/directory permissions",\n "Run with appropriate permissions",\n "Verify user has write access"\n ]\n ),\n [ErrorCode2.FILE_NOT_FOUND]: createSimpleError(\n ErrorCode2.FILE_NOT_FOUND,\n "File not found",\n "Required file does not exist.",\n [\n "Check that file path is correct",\n "Verify file exists in project",\n "Check for typos in file name"\n ]\n ),\n [ErrorCode2.INVALID_ARGUMENT]: createSimpleError(\n ErrorCode2.INVALID_ARGUMENT,\n "Invalid argument",\n "Command received invalid argument.",\n [\n "Check command syntax",\n "Verify argument values",\n "Run \'veryfront help <command>\' for usage"\n ]\n ),\n [ErrorCode2.TIMEOUT_ERROR]: createSimpleError(\n ErrorCode2.TIMEOUT_ERROR,\n "Operation timed out",\n "Operation took too long to complete.",\n [\n "Check network connectivity",\n "Try increasing timeout if available",\n "Check for very large files"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/index.ts\nvar ERROR_CATALOG;\nvar init_catalog = __esm({\n "src/core/errors/catalog/index.ts"() {\n "use strict";\n init_config_errors();\n init_build_errors2();\n init_runtime_errors2();\n init_route_errors();\n init_module_errors();\n init_server_errors();\n init_rsc_errors();\n init_dev_errors();\n init_deployment_errors();\n init_general_errors();\n init_factory();\n ERROR_CATALOG = {\n ...CONFIG_ERROR_CATALOG,\n ...BUILD_ERROR_CATALOG,\n ...RUNTIME_ERROR_CATALOG,\n ...ROUTE_ERROR_CATALOG,\n ...MODULE_ERROR_CATALOG,\n ...SERVER_ERROR_CATALOG,\n ...RSC_ERROR_CATALOG,\n ...DEV_ERROR_CATALOG,\n ...DEPLOYMENT_ERROR_CATALOG,\n ...GENERAL_ERROR_CATALOG\n };\n }\n});\n\n// src/core/errors/user-friendly/error-catalog.ts\nvar init_error_catalog = __esm({\n "src/core/errors/user-friendly/error-catalog.ts"() {\n "use strict";\n }\n});\n\n// src/platform/compat/runtime.ts\nvar isDeno, isNode, isBun, isCloudflare;\nvar init_runtime = __esm({\n "src/platform/compat/runtime.ts"() {\n "use strict";\n isDeno = typeof Deno !== "undefined";\n isNode = typeof globalThis.process !== "undefined" && globalThis.process?.versions?.node !== void 0;\n isBun = typeof globalThis.Bun !== "undefined";\n isCloudflare = typeof globalThis !== "undefined" && "caches" in globalThis && "WebSocketPair" in globalThis;\n }\n});\n\n// src/platform/compat/console/ansi.ts\nvar ansi, red, green, yellow, blue, magenta, cyan, white, gray, bold, dim, italic, underline, strikethrough, reset;\nvar init_ansi = __esm({\n "src/platform/compat/console/ansi.ts"() {\n ansi = (open, close) => (text2) => `\\x1B[${open}m${text2}\\x1B[${close}m`;\n red = ansi(31, 39);\n green = ansi(32, 39);\n yellow = ansi(33, 39);\n blue = ansi(34, 39);\n magenta = ansi(35, 39);\n cyan = ansi(36, 39);\n white = ansi(37, 39);\n gray = ansi(90, 39);\n bold = ansi(1, 22);\n dim = ansi(2, 22);\n italic = ansi(3, 23);\n underline = ansi(4, 24);\n strikethrough = ansi(9, 29);\n reset = (text2) => `\\x1B[0m${text2}`;\n }\n});\n\n// src/platform/compat/console/deno.ts\nvar deno_exports = {};\n__export(deno_exports, {\n blue: () => blue,\n bold: () => bold,\n colors: () => colors,\n cyan: () => cyan,\n dim: () => dim,\n gray: () => gray,\n green: () => green,\n italic: () => italic,\n magenta: () => magenta,\n red: () => red,\n reset: () => reset,\n strikethrough: () => strikethrough,\n underline: () => underline,\n white: () => white,\n yellow: () => yellow\n});\nvar colors;\nvar init_deno2 = __esm({\n "src/platform/compat/console/deno.ts"() {\n "use strict";\n init_ansi();\n colors = {\n // Basic colors\n red,\n green,\n yellow,\n blue,\n cyan,\n magenta,\n white,\n gray,\n // Text modifiers\n bold,\n dim,\n italic,\n underline,\n strikethrough,\n // Utility\n reset\n };\n }\n});\n\n// src/platform/compat/console/node.ts\nvar node_exports = {};\n__export(node_exports, {\n blue: () => blue2,\n bold: () => bold2,\n colors: () => colors2,\n cyan: () => cyan2,\n dim: () => dim2,\n gray: () => gray2,\n green: () => green2,\n italic: () => italic2,\n magenta: () => magenta2,\n red: () => red2,\n reset: () => reset2,\n strikethrough: () => strikethrough2,\n underline: () => underline2,\n white: () => white2,\n yellow: () => yellow2\n});\nimport pc from "npm:picocolors";\nvar colors2, red2, green2, yellow2, blue2, cyan2, magenta2, white2, gray2, bold2, dim2, italic2, underline2, strikethrough2, reset2;\nvar init_node = __esm({\n "src/platform/compat/console/node.ts"() {\n "use strict";\n colors2 = {\n // Basic colors\n red: pc.red,\n green: pc.green,\n yellow: pc.yellow,\n blue: pc.blue,\n cyan: pc.cyan,\n magenta: pc.magenta,\n white: pc.white,\n gray: pc.gray,\n // Text modifiers\n bold: pc.bold,\n dim: pc.dim,\n italic: pc.italic,\n underline: pc.underline,\n strikethrough: pc.strikethrough,\n // Utility - picocolors doesn\'t have reset, so we implement it\n reset: (text2) => pc.reset(text2)\n };\n red2 = pc.red;\n green2 = pc.green;\n yellow2 = pc.yellow;\n blue2 = pc.blue;\n cyan2 = pc.cyan;\n magenta2 = pc.magenta;\n white2 = pc.white;\n gray2 = pc.gray;\n bold2 = pc.bold;\n dim2 = pc.dim;\n italic2 = pc.italic;\n underline2 = pc.underline;\n strikethrough2 = pc.strikethrough;\n reset2 = (text2) => pc.reset(text2);\n }\n});\n\n// src/platform/compat/console/index.ts\nasync function loadColors() {\n if (_colors)\n return _colors;\n try {\n if (isDeno) {\n const mod = await Promise.resolve().then(() => (init_deno2(), deno_exports));\n _colors = mod.colors;\n } else {\n const mod = await Promise.resolve().then(() => (init_node(), node_exports));\n _colors = mod.colors;\n }\n } catch {\n _colors = fallbackColors;\n }\n return _colors;\n}\nvar noOp, fallbackColors, _colors, colorsPromise;\nvar init_console = __esm({\n "src/platform/compat/console/index.ts"() {\n init_runtime();\n noOp = (text2) => text2;\n fallbackColors = {\n red: noOp,\n green: noOp,\n yellow: noOp,\n blue: noOp,\n cyan: noOp,\n magenta: noOp,\n white: noOp,\n gray: noOp,\n bold: noOp,\n dim: noOp,\n italic: noOp,\n underline: noOp,\n strikethrough: noOp,\n reset: noOp\n };\n _colors = null;\n colorsPromise = loadColors();\n }\n});\n\n// src/core/errors/user-friendly/error-identifier.ts\nvar init_error_identifier = __esm({\n "src/core/errors/user-friendly/error-identifier.ts"() {\n "use strict";\n }\n});\n\n// src/core/errors/user-friendly/error-formatter.ts\nvar init_error_formatter = __esm({\n "src/core/errors/user-friendly/error-formatter.ts"() {\n "use strict";\n init_console();\n init_error_catalog();\n init_error_identifier();\n }\n});\n\n// src/platform/compat/process.ts\nimport process2 from "node:process";\nvar IS_DENO;\nvar init_process = __esm({\n "src/platform/compat/process.ts"() {\n IS_DENO = typeof Deno !== "undefined" && "Deno" in globalThis;\n }\n});\n\n// src/core/errors/user-friendly/error-wrapper.ts\nvar init_error_wrapper = __esm({\n "src/core/errors/user-friendly/error-wrapper.ts"() {\n "use strict";\n init_console();\n init_process();\n init_logger();\n init_error_formatter();\n }\n});\n\n// src/core/errors/user-friendly/index.ts\nvar init_user_friendly = __esm({\n "src/core/errors/user-friendly/index.ts"() {\n "use strict";\n init_error_catalog();\n init_error_formatter();\n init_error_identifier();\n init_error_wrapper();\n }\n});\n\n// src/core/errors/index.ts\nvar init_errors = __esm({\n "src/core/errors/index.ts"() {\n init_types();\n init_agent_errors();\n init_build_errors();\n init_runtime_errors();\n init_system_errors();\n init_error_handlers();\n init_catalog();\n init_user_friendly();\n }\n});\n\n// src/platform/adapters/deno.ts\nvar DenoFileSystemAdapter, DenoEnvironmentAdapter, DenoServerAdapter, DenoShellAdapter, DenoServer, DenoAdapter, denoAdapter;\nvar init_deno3 = __esm({\n "src/platform/adapters/deno.ts"() {\n "use strict";\n init_veryfront_error();\n init_config();\n init_utils();\n DenoFileSystemAdapter = class {\n async readFile(path) {\n return await Deno.readTextFile(path);\n }\n async writeFile(path, content) {\n await Deno.writeTextFile(path, content);\n }\n async exists(path) {\n try {\n await Deno.stat(path);\n return true;\n } catch (_error) {\n return false;\n }\n }\n async *readDir(path) {\n for await (const entry of Deno.readDir(path)) {\n yield {\n name: entry.name,\n isFile: entry.isFile,\n isDirectory: entry.isDirectory,\n isSymlink: entry.isSymlink\n };\n }\n }\n async stat(path) {\n const stat = await Deno.stat(path);\n return {\n size: stat.size,\n isFile: stat.isFile,\n isDirectory: stat.isDirectory,\n isSymlink: stat.isSymlink,\n mtime: stat.mtime\n };\n }\n async mkdir(path, options) {\n await Deno.mkdir(path, options);\n }\n async remove(path, options) {\n await Deno.remove(path, options);\n }\n async makeTempDir(prefix) {\n return await Deno.makeTempDir({ prefix });\n }\n watch(paths, options) {\n const pathArray = Array.isArray(paths) ? paths : [paths];\n const recursive = options?.recursive ?? true;\n const signal = options?.signal;\n const watcher = Deno.watchFs(pathArray, { recursive });\n let closed = false;\n const denoIterator = watcher[Symbol.asyncIterator]();\n const mapEventKind = (kind) => {\n switch (kind) {\n case "create":\n return "create";\n case "modify":\n return "modify";\n case "remove":\n return "delete";\n default:\n return "any";\n }\n };\n const iterator = {\n async next() {\n if (closed || signal?.aborted) {\n return { done: true, value: void 0 };\n }\n try {\n const result = await denoIterator.next();\n if (result.done) {\n return { done: true, value: void 0 };\n }\n return {\n done: false,\n value: {\n kind: mapEventKind(result.value.kind),\n paths: result.value.paths\n }\n };\n } catch (error2) {\n if (closed || signal?.aborted) {\n return { done: true, value: void 0 };\n }\n throw error2;\n }\n },\n async return() {\n closed = true;\n if (denoIterator.return) {\n await denoIterator.return();\n }\n return { done: true, value: void 0 };\n }\n };\n const cleanup = () => {\n if (closed)\n return;\n closed = true;\n try {\n if ("close" in watcher && typeof watcher.close === "function") {\n watcher.close();\n }\n } catch (error2) {\n serverLogger.debug("[Deno] Filesystem watcher cleanup failed", { error: error2 });\n }\n };\n if (signal) {\n signal.addEventListener("abort", cleanup);\n }\n return {\n [Symbol.asyncIterator]() {\n return iterator;\n },\n close: cleanup\n };\n }\n };\n DenoEnvironmentAdapter = class {\n get(key) {\n return Deno.env.get(key);\n }\n set(key, value) {\n Deno.env.set(key, value);\n }\n toObject() {\n return Deno.env.toObject();\n }\n };\n DenoServerAdapter = class {\n upgradeWebSocket(request) {\n const { socket, response } = Deno.upgradeWebSocket(request);\n return { socket, response };\n }\n };\n DenoShellAdapter = class {\n statSync(path) {\n try {\n const stat = Deno.statSync(path);\n return {\n isFile: stat.isFile,\n isDirectory: stat.isDirectory\n };\n } catch (error2) {\n throw toError(createError({\n type: "file",\n message: `Failed to stat file: ${error2}`\n }));\n }\n }\n readFileSync(path) {\n try {\n return Deno.readTextFileSync(path);\n } catch (error2) {\n throw toError(createError({\n type: "file",\n message: `Failed to read file: ${error2}`\n }));\n }\n }\n };\n DenoServer = class {\n constructor(server, hostname, port, abortController) {\n this.server = server;\n this.hostname = hostname;\n this.port = port;\n this.abortController = abortController;\n }\n async stop() {\n try {\n if (this.abortController) {\n this.abortController.abort();\n }\n await this.server.shutdown();\n } catch (error2) {\n serverLogger.debug("[Deno] Server shutdown failed", { error: error2 });\n }\n }\n get addr() {\n return { hostname: this.hostname, port: this.port };\n }\n };\n DenoAdapter = class {\n constructor() {\n this.id = "deno";\n this.name = "deno";\n /** @deprecated Use `id` instead */\n this.platform = "deno";\n this.fs = new DenoFileSystemAdapter();\n this.env = new DenoEnvironmentAdapter();\n this.server = new DenoServerAdapter();\n this.shell = new DenoShellAdapter();\n this.capabilities = {\n typescript: true,\n jsx: true,\n http2: true,\n websocket: true,\n workers: true,\n fileWatching: true,\n shell: true,\n kvStore: true,\n // Deno KV available\n writableFs: true\n };\n /** @deprecated Use `capabilities` instead */\n this.features = {\n websocket: true,\n http2: true,\n workers: true,\n jsx: true,\n typescript: true\n };\n }\n serve(handler, options = {}) {\n const { port = DEFAULT_DEV_PORT, hostname = "localhost", onListen } = options;\n const controller = new AbortController();\n const signal = options.signal || controller.signal;\n const server = Deno.serve({\n port,\n hostname,\n signal,\n handler: async (request, _info) => {\n try {\n return await handler(request);\n } catch (error2) {\n const { serverLogger: serverLogger2 } = await Promise.resolve().then(() => (init_utils(), utils_exports));\n serverLogger2.error("Request handler error:", error2);\n return new Response("Internal Server Error", { status: 500 });\n }\n },\n onListen: (params) => {\n onListen?.({ hostname: params.hostname, port: params.port });\n }\n });\n const controllerToPass = options.signal ? void 0 : controller;\n return Promise.resolve(new DenoServer(server, hostname, port, controllerToPass));\n }\n };\n denoAdapter = new DenoAdapter();\n }\n});\n\n// src/rendering/client/router.ts\ninit_utils();\nimport ReactDOM from "react-dom/client";\n\n// src/routing/matchers/pattern-route-matcher.ts\ninit_path_utils();\n\n// src/routing/matchers/index.ts\ninit_utils();\n\n// src/routing/slug-mapper/path-candidate-generator.ts\nimport { join } from "https://deno.land/std@0.220.0/path/mod.ts";\n\n// src/routing/client/dom-utils.ts\ninit_utils();\nfunction isInternalLink(target) {\n const href = target.getAttribute("href");\n if (!href)\n return false;\n if (href.startsWith("http") || href.startsWith("mailto:"))\n return false;\n if (href.startsWith("#"))\n return false;\n if (target.getAttribute("target") === "_blank" || target.getAttribute("download")) {\n return false;\n }\n return true;\n}\nfunction findAnchorElement(element) {\n let current = element;\n while (current && current.tagName !== "A") {\n current = current.parentElement;\n }\n if (!current || !(current instanceof HTMLAnchorElement)) {\n return null;\n }\n return current;\n}\nfunction updateMetaTags(frontmatter) {\n if (frontmatter.description) {\n updateMetaTag(\'meta[name="description"]\', "name", "description", frontmatter.description);\n }\n if (frontmatter.ogTitle) {\n updateMetaTag(\'meta[property="og:title"]\', "property", "og:title", frontmatter.ogTitle);\n }\n}\nfunction updateMetaTag(selector, attributeName, attributeValue, content) {\n let metaTag = document.querySelector(selector);\n if (!metaTag) {\n metaTag = document.createElement("meta");\n metaTag.setAttribute(attributeName, attributeValue);\n document.head.appendChild(metaTag);\n }\n metaTag.setAttribute("content", content);\n}\nfunction executeScripts(container) {\n const scripts = container.querySelectorAll("script");\n scripts.forEach((oldScript) => {\n const newScript = document.createElement("script");\n Array.from(oldScript.attributes).forEach((attribute) => {\n newScript.setAttribute(attribute.name, attribute.value);\n });\n newScript.textContent = oldScript.textContent;\n oldScript.parentNode?.replaceChild(newScript, oldScript);\n });\n}\nfunction applyHeadDirectives(container) {\n const nodes = container.querySelectorAll(\'[data-veryfront-head="1"], vf-head\');\n if (nodes.length > 0) {\n cleanManagedHeadTags();\n }\n nodes.forEach((wrapper) => {\n processHeadWrapper(wrapper);\n wrapper.parentElement?.removeChild(wrapper);\n });\n}\nfunction cleanManagedHeadTags() {\n document.head.querySelectorAll(\'[data-veryfront-managed="1"]\').forEach((element) => element.parentElement?.removeChild(element));\n}\nfunction processHeadWrapper(wrapper) {\n wrapper.childNodes.forEach((node) => {\n if (!(node instanceof Element))\n return;\n const tagName = node.tagName.toLowerCase();\n if (tagName === "title") {\n document.title = node.textContent || document.title;\n return;\n }\n const clone = document.createElement(tagName);\n for (const attribute of Array.from(node.attributes)) {\n clone.setAttribute(attribute.name, attribute.value);\n }\n if (node.textContent && !clone.hasAttribute("src")) {\n clone.textContent = node.textContent;\n }\n clone.setAttribute("data-veryfront-managed", "1");\n document.head.appendChild(clone);\n });\n}\nfunction manageFocus(container) {\n try {\n const focusElement = container.querySelector("[data-router-focus]") || container.querySelector("main") || container.querySelector("h1");\n if (focusElement && focusElement instanceof HTMLElement && "focus" in focusElement) {\n focusElement.focus({ preventScroll: true });\n }\n } catch (error2) {\n rendererLogger.warn("[router] focus management failed", error2);\n }\n}\nfunction extractPageDataFromScript() {\n const pageDataScript = document.querySelector("script[data-veryfront-page]");\n if (!pageDataScript)\n return null;\n try {\n const content = pageDataScript.textContent;\n if (!content) {\n rendererLogger.warn("[dom-utils] Page data script has no content");\n return {};\n }\n return JSON.parse(content);\n } catch (error2) {\n rendererLogger.error("[dom-utils] Failed to parse page data:", error2);\n return null;\n }\n}\nfunction parsePageDataFromHTML(html3) {\n const parser = new DOMParser();\n const doc = parser.parseFromString(html3, "text/html");\n const root = doc.getElementById("root");\n let content = "";\n if (root) {\n content = root.innerHTML || "";\n } else {\n rendererLogger.warn("[dom-utils] No root element found in HTML");\n }\n const pageDataScript = doc.querySelector("script[data-veryfront-page]");\n let pageData = {};\n if (pageDataScript) {\n try {\n const content2 = pageDataScript.textContent;\n if (!content2) {\n rendererLogger.warn("[dom-utils] Page data script in HTML has no content");\n } else {\n pageData = JSON.parse(content2);\n }\n } catch (error2) {\n rendererLogger.error("[dom-utils] Failed to parse page data from HTML:", error2);\n }\n }\n return { content, pageData };\n}\n\n// src/routing/client/navigation-handlers.ts\ninit_utils();\ninit_config();\nvar NavigationHandlers = class {\n constructor(prefetchDelay = DEFAULT_PREFETCH_DELAY_MS, prefetchOptions = {}) {\n this.prefetchQueue = /* @__PURE__ */ new Set();\n this.scrollPositions = /* @__PURE__ */ new Map();\n this.isPopStateNav = false;\n this.prefetchDelay = prefetchDelay;\n this.prefetchOptions = prefetchOptions;\n }\n createClickHandler(callbacks) {\n return (event) => {\n const anchor = findAnchorElement(event.target);\n if (!anchor || !isInternalLink(anchor))\n return;\n const href = anchor.getAttribute("href");\n event.preventDefault();\n callbacks.onNavigate(href);\n };\n }\n createPopStateHandler(callbacks) {\n return (_event) => {\n const path = globalThis.location.pathname;\n this.isPopStateNav = true;\n callbacks.onNavigate(path);\n };\n }\n createMouseOverHandler(callbacks) {\n return (event) => {\n const target = event.target;\n if (target.tagName !== "A")\n return;\n const href = target.getAttribute("href");\n if (!href || href.startsWith("http") || href.startsWith("#"))\n return;\n if (!this.shouldPrefetchOnHover(target))\n return;\n if (!this.prefetchQueue.has(href)) {\n this.prefetchQueue.add(href);\n setTimeout(() => {\n callbacks.onPrefetch(href);\n this.prefetchQueue.delete(href);\n }, this.prefetchDelay);\n }\n };\n }\n shouldPrefetchOnHover(target) {\n const prefetchAttribute = target.getAttribute("data-prefetch");\n const isHoverEnabled = Boolean(this.prefetchOptions.hover);\n if (prefetchAttribute === "false")\n return false;\n return prefetchAttribute === "true" || isHoverEnabled;\n }\n saveScrollPosition(path) {\n try {\n const scrollY = globalThis.scrollY;\n if (typeof scrollY === "number") {\n this.scrollPositions.set(path, scrollY);\n } else {\n rendererLogger.debug("[router] No valid scrollY value available");\n this.scrollPositions.set(path, 0);\n }\n } catch (error2) {\n rendererLogger.warn("[router] failed to record scroll position", error2);\n }\n }\n getScrollPosition(path) {\n const position = this.scrollPositions.get(path);\n if (position === void 0) {\n rendererLogger.debug(`[router] No scroll position stored for ${path}`);\n return 0;\n }\n return position;\n }\n isPopState() {\n return this.isPopStateNav;\n }\n clearPopStateFlag() {\n this.isPopStateNav = false;\n }\n clear() {\n this.prefetchQueue.clear();\n this.scrollPositions.clear();\n this.isPopStateNav = false;\n }\n};\n\n// src/routing/client/page-loader.ts\ninit_utils();\ninit_errors();\nvar PageLoader = class {\n constructor() {\n this.cache = /* @__PURE__ */ new Map();\n }\n getCached(path) {\n return this.cache.get(path);\n }\n isCached(path) {\n return this.cache.has(path);\n }\n setCache(path, data) {\n this.cache.set(path, data);\n }\n clearCache() {\n this.cache.clear();\n }\n async fetchPageData(path) {\n const jsonData = await this.tryFetchJSON(path);\n if (jsonData)\n return jsonData;\n return this.fetchAndParseHTML(path);\n }\n async tryFetchJSON(path) {\n try {\n const response = await fetch(`/_veryfront/data${path}.json`, {\n headers: { "X-Veryfront-Navigation": "client" }\n });\n if (response.ok) {\n return await response.json();\n }\n } catch (error2) {\n rendererLogger.debug(`[PageLoader] RSC fetch failed for ${path}, falling back to HTML:`, error2);\n }\n return null;\n }\n async fetchAndParseHTML(path) {\n const response = await fetch(path, {\n headers: { "X-Veryfront-Navigation": "client" }\n });\n if (!response.ok) {\n throw new NetworkError(`Failed to fetch ${path}`, {\n status: response.status,\n path\n });\n }\n const html3 = await response.text();\n const { content, pageData } = parsePageDataFromHTML(html3);\n return {\n html: content,\n ...pageData\n };\n }\n async loadPage(path) {\n if (this.isCached(path)) {\n rendererLogger.debug(`Loading ${path} from cache`);\n const cachedData = this.getCached(path);\n if (!cachedData) {\n rendererLogger.warn(`[PageLoader] Cache entry for ${path} was unexpectedly null`);\n } else {\n return cachedData;\n }\n }\n const data = await this.fetchPageData(path);\n this.setCache(path, data);\n return data;\n }\n async prefetch(path) {\n if (this.isCached(path))\n return;\n rendererLogger.debug(`Prefetching ${path}`);\n try {\n const data = await this.fetchPageData(path);\n this.setCache(path, data);\n } catch (error2) {\n rendererLogger.warn(`Failed to prefetch ${path}`, error2);\n }\n }\n};\n\n// src/routing/client/page-transition.ts\ninit_utils();\ninit_config();\n\n// src/security/client/html-sanitizer.ts\nvar SUSPICIOUS_PATTERNS = [\n { pattern: /<script[^>]*>[\\s\\S]*?<\\/script>/gi, name: "inline script" },\n { pattern: /javascript:/gi, name: "javascript: URL" },\n { pattern: /\\bon\\w+\\s*=/gi, name: "event handler attribute" },\n { pattern: /data:\\s*text\\/html/gi, name: "data: HTML URL" }\n];\nfunction isDevMode() {\n if (typeof globalThis !== "undefined") {\n const g = globalThis;\n return g.__VERYFRONT_DEV__ === true || g.Deno?.env?.get?.("VERYFRONT_ENV") === "development";\n }\n return false;\n}\nfunction validateTrustedHtml(html3, options = {}) {\n const { strict = false, warn = true } = options;\n for (const { pattern, name } of SUSPICIOUS_PATTERNS) {\n pattern.lastIndex = 0;\n if (pattern.test(html3)) {\n const message = `[Security] Suspicious ${name} detected in server HTML`;\n if (warn) {\n console.warn(message);\n }\n if (strict || !isDevMode()) {\n throw new Error(`Potentially unsafe HTML: ${name} detected`);\n }\n }\n }\n return html3;\n}\n\n// src/routing/client/page-transition.ts\nvar PageTransition = class {\n constructor(setupViewportPrefetch) {\n this.setupViewportPrefetch = setupViewportPrefetch;\n }\n destroy() {\n if (this.pendingTransitionTimeout !== void 0) {\n clearTimeout(this.pendingTransitionTimeout);\n this.pendingTransitionTimeout = void 0;\n }\n }\n updatePage(data, isPopState, scrollY) {\n if (data.frontmatter?.title) {\n document.title = data.frontmatter.title;\n }\n updateMetaTags(data.frontmatter ?? {});\n const rootElement = document.getElementById("root");\n if (rootElement && (data.html ?? "") !== "") {\n this.performTransition(rootElement, data, isPopState, scrollY);\n }\n }\n performTransition(rootElement, data, isPopState, scrollY) {\n if (this.pendingTransitionTimeout !== void 0) {\n clearTimeout(this.pendingTransitionTimeout);\n }\n rootElement.style.opacity = "0";\n this.pendingTransitionTimeout = setTimeout(() => {\n this.pendingTransitionTimeout = void 0;\n rootElement.innerHTML = validateTrustedHtml(String(data.html ?? ""));\n rootElement.style.opacity = "1";\n executeScripts(rootElement);\n applyHeadDirectives(rootElement);\n this.setupViewportPrefetch(rootElement);\n manageFocus(rootElement);\n this.handleScroll(isPopState, scrollY);\n }, PAGE_TRANSITION_DELAY_MS);\n }\n handleScroll(isPopState, scrollY) {\n try {\n globalThis.scrollTo(0, isPopState ? scrollY : 0);\n } catch (error2) {\n rendererLogger.warn("[router] scroll handling failed", error2);\n }\n }\n showError(error2) {\n const rootElement = document.getElementById("root");\n if (!rootElement)\n return;\n const errorDiv = document.createElement("div");\n errorDiv.className = "veryfront-error-page";\n const heading = document.createElement("h1");\n heading.textContent = "Oops! Something went wrong";\n const message = document.createElement("p");\n message.textContent = error2.message;\n const button = document.createElement("button");\n button.type = "button";\n button.textContent = "Reload Page";\n button.onclick = () => globalThis.location.reload();\n errorDiv.appendChild(heading);\n errorDiv.appendChild(message);\n errorDiv.appendChild(button);\n rootElement.innerHTML = "";\n rootElement.appendChild(errorDiv);\n }\n setLoadingState(loading) {\n const indicator = document.getElementById("veryfront-loading");\n if (indicator) {\n indicator.style.display = loading ? "block" : "none";\n }\n document.body.classList.toggle("veryfront-loading", loading);\n }\n};\n\n// src/routing/client/viewport-prefetch.ts\ninit_utils();\nvar ViewportPrefetch = class {\n constructor(prefetchCallback, prefetchOptions = {}) {\n this.observer = null;\n this.prefetchCallback = prefetchCallback;\n this.prefetchOptions = prefetchOptions;\n }\n setup(root) {\n try {\n if (!("IntersectionObserver" in globalThis))\n return;\n if (this.observer)\n this.observer.disconnect();\n this.createObserver();\n this.observeLinks(root);\n } catch (error2) {\n rendererLogger.debug("[router] setupViewportPrefetch failed", error2);\n }\n }\n createObserver() {\n this.observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n const isAnchor = typeof HTMLAnchorElement !== "undefined" ? entry.target instanceof HTMLAnchorElement : entry.target.tagName === "A";\n if (isAnchor) {\n const href = entry.target.getAttribute("href");\n if (href) {\n this.prefetchCallback(href);\n }\n this.observer?.unobserve(entry.target);\n }\n }\n }\n },\n { rootMargin: "200px" }\n );\n }\n observeLinks(root) {\n const anchors = root.querySelectorAll?.(\'a[href]:not([target="_blank"])\') ?? document.createDocumentFragment().querySelectorAll("a");\n const isViewportEnabled = Boolean(this.prefetchOptions.viewport);\n anchors.forEach((anchor) => {\n if (this.shouldObserveAnchor(anchor, isViewportEnabled)) {\n this.observer?.observe(anchor);\n }\n });\n }\n shouldObserveAnchor(anchor, isViewportEnabled) {\n const href = anchor.getAttribute("href") || "";\n if (!href || href.startsWith("http") || href.startsWith("#") || anchor.getAttribute("download")) {\n return false;\n }\n const prefetchAttribute = anchor.getAttribute("data-prefetch");\n if (prefetchAttribute === "false")\n return false;\n return prefetchAttribute === "viewport" || isViewportEnabled;\n }\n disconnect() {\n if (this.observer) {\n try {\n this.observer.disconnect();\n } catch (error2) {\n rendererLogger.warn("[router] prefetchObserver.disconnect failed", error2);\n }\n this.observer = null;\n }\n }\n};\n\n// src/routing/api/handler.ts\ninit_utils();\ninit_std_path();\ninit_config();\n\n// src/core/utils/lru-wrapper.ts\ninit_utils();\n\n// src/routing/api/handler.ts\ninit_veryfront_error();\n\n// src/security/http/response/constants.ts\nvar CONTENT_TYPES = {\n JSON: "application/json; charset=utf-8",\n HTML: "text/html; charset=utf-8",\n TEXT: "text/plain; charset=utf-8",\n JAVASCRIPT: "application/javascript; charset=utf-8",\n CSS: "text/css; charset=utf-8",\n XML: "application/xml; charset=utf-8"\n};\nvar CACHE_DURATIONS = {\n SHORT: 60,\n MEDIUM: 3600,\n LONG: 31536e3\n};\n\n// src/security/http/cors/validators.ts\ninit_logger();\n\n// src/observability/tracing/manager.ts\ninit_utils();\n\n// src/observability/tracing/config.ts\nvar DEFAULT_CONFIG2 = {\n enabled: false,\n exporter: "console",\n serviceName: "veryfront",\n sampleRate: 1,\n debug: false\n};\nfunction loadConfig(config = {}, adapter) {\n const finalConfig = { ...DEFAULT_CONFIG2, ...config };\n if (adapter?.env) {\n applyEnvFromAdapter(finalConfig, adapter.env);\n } else {\n applyEnvFromDeno(finalConfig);\n }\n return finalConfig;\n}\nfunction applyEnvFromAdapter(config, envAdapter) {\n if (!envAdapter)\n return;\n const otelEnabled = envAdapter.get("OTEL_TRACES_ENABLED");\n const veryfrontOtel = envAdapter.get("VERYFRONT_OTEL");\n const serviceName = envAdapter.get("OTEL_SERVICE_NAME");\n config.enabled = otelEnabled === "true" || veryfrontOtel === "1" || config.enabled;\n if (serviceName)\n config.serviceName = serviceName;\n const otlpEndpoint = envAdapter.get("OTEL_EXPORTER_OTLP_ENDPOINT");\n const tracesEndpoint = envAdapter.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT");\n config.endpoint = otlpEndpoint || tracesEndpoint || config.endpoint;\n const exporterType = envAdapter.get("OTEL_TRACES_EXPORTER");\n if (isValidExporter(exporterType)) {\n config.exporter = exporterType;\n }\n}\nfunction applyEnvFromDeno(config) {\n try {\n const denoEnv = globalThis.Deno?.env;\n if (!denoEnv)\n return;\n config.enabled = denoEnv.get("OTEL_TRACES_ENABLED") === "true" || denoEnv.get("VERYFRONT_OTEL") === "1" || config.enabled;\n config.serviceName = denoEnv.get("OTEL_SERVICE_NAME") || config.serviceName;\n config.endpoint = denoEnv.get("OTEL_EXPORTER_OTLP_ENDPOINT") || denoEnv.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") || config.endpoint;\n const exporterType = denoEnv.get("OTEL_TRACES_EXPORTER");\n if (isValidExporter(exporterType)) {\n config.exporter = exporterType;\n }\n } catch {\n }\n}\nfunction isValidExporter(value) {\n return value === "jaeger" || value === "zipkin" || value === "otlp" || value === "console";\n}\n\n// src/observability/tracing/span-operations.ts\ninit_utils();\nvar SpanOperations = class {\n constructor(api, tracer2) {\n this.api = api;\n this.tracer = tracer2;\n }\n startSpan(name, options = {}) {\n try {\n const spanKind = this.mapSpanKind(options.kind);\n const span = this.tracer.startSpan(name, {\n kind: spanKind,\n attributes: options.attributes || {}\n }, options.parent);\n return span;\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to start span", { name, error: error2 });\n return null;\n }\n }\n endSpan(span, error2) {\n if (!span)\n return;\n try {\n if (error2) {\n span.recordException(error2);\n span.setStatus({\n code: this.api.SpanStatusCode.ERROR,\n message: error2.message\n });\n } else {\n span.setStatus({ code: this.api.SpanStatusCode.OK });\n }\n span.end();\n } catch (err) {\n serverLogger.debug("[tracing] Failed to end span", err);\n }\n }\n setAttributes(span, attributes) {\n if (!span)\n return;\n try {\n span.setAttributes(attributes);\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to set span attributes", error2);\n }\n }\n addEvent(span, name, attributes) {\n if (!span)\n return;\n try {\n span.addEvent(name, attributes);\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to add span event", error2);\n }\n }\n createChildSpan(parentSpan, name, options = {}) {\n if (!parentSpan)\n return this.startSpan(name, options);\n try {\n const parentContext = this.api.trace.setSpan(this.api.context.active(), parentSpan);\n return this.startSpan(name, { ...options, parent: parentContext });\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to create child span", error2);\n return null;\n }\n }\n mapSpanKind(kind) {\n if (!kind)\n return this.api.SpanKind.INTERNAL;\n const kindMap = {\n "internal": this.api.SpanKind.INTERNAL,\n "server": this.api.SpanKind.SERVER,\n "client": this.api.SpanKind.CLIENT,\n "producer": this.api.SpanKind.PRODUCER,\n "consumer": this.api.SpanKind.CONSUMER\n };\n return kindMap[kind.toLowerCase()] || this.api.SpanKind.INTERNAL;\n }\n};\n\n// src/observability/tracing/context-propagation.ts\ninit_utils();\nvar ContextPropagation = class {\n constructor(api, propagator) {\n this.api = api;\n this.propagator = propagator;\n }\n extractContext(headers) {\n try {\n const carrier = {};\n headers.forEach((value, key) => {\n carrier[key] = value;\n });\n return this.api.propagation.extract(this.api.context.active(), carrier);\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to extract context from headers", error2);\n return void 0;\n }\n }\n injectContext(context, headers) {\n try {\n const carrier = {};\n this.api.propagation.inject(context, carrier);\n for (const [key, value] of Object.entries(carrier)) {\n headers.set(key, value);\n }\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to inject context into headers", error2);\n }\n }\n getActiveContext() {\n try {\n return this.api.context.active();\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to get active context", error2);\n return void 0;\n }\n }\n async withActiveSpan(span, fn) {\n if (!span)\n return await fn();\n try {\n return await this.api.context.with(\n this.api.trace.setSpan(this.api.context.active(), span),\n fn\n );\n } catch (error2) {\n throw error2;\n }\n }\n withSpan(name, fn, startSpan2, endSpan2) {\n const span = startSpan2(name);\n try {\n const result = fn(span);\n endSpan2(span);\n return result;\n } catch (error2) {\n endSpan2(span, error2);\n throw error2;\n }\n }\n async withSpanAsync(name, fn, startSpan2, endSpan2) {\n const span = startSpan2(name);\n try {\n const result = await fn(span);\n endSpan2(span);\n return result;\n } catch (error2) {\n endSpan2(span, error2);\n throw error2;\n }\n }\n};\n\n// src/observability/tracing/manager.ts\nvar TracingManager = class {\n constructor() {\n this.state = {\n initialized: false,\n tracer: null,\n api: null,\n propagator: null\n };\n this.spanOps = null;\n this.contextProp = null;\n }\n async initialize(config = {}, adapter) {\n if (this.state.initialized) {\n serverLogger.debug("[tracing] Already initialized");\n return;\n }\n const finalConfig = loadConfig(config, adapter);\n if (!finalConfig.enabled) {\n serverLogger.debug("[tracing] Tracing disabled");\n this.state.initialized = true;\n return;\n }\n try {\n await this.initializeTracer(finalConfig);\n this.state.initialized = true;\n serverLogger.info("[tracing] OpenTelemetry tracing initialized", {\n exporter: finalConfig.exporter,\n serviceName: finalConfig.serviceName,\n endpoint: finalConfig.endpoint\n });\n } catch (error2) {\n serverLogger.warn("[tracing] Failed to initialize OpenTelemetry tracing", error2);\n this.state.initialized = true;\n }\n }\n async initializeTracer(config) {\n const api = await import("npm:@opentelemetry/api@1");\n this.state.api = api;\n this.state.tracer = api.trace.getTracer(config.serviceName || "veryfront", "0.1.0");\n const { W3CTraceContextPropagator } = await import("npm:@opentelemetry/core@1");\n this.state.propagator = new W3CTraceContextPropagator();\n api.propagation.setGlobalPropagator(this.state.propagator);\n if (this.state.api && this.state.tracer) {\n this.spanOps = new SpanOperations(this.state.api, this.state.tracer);\n }\n if (this.state.api && this.state.propagator) {\n this.contextProp = new ContextPropagation(this.state.api, this.state.propagator);\n }\n }\n isEnabled() {\n return this.state.initialized && this.state.tracer !== null;\n }\n getSpanOperations() {\n return this.spanOps;\n }\n getContextPropagation() {\n return this.contextProp;\n }\n getState() {\n return this.state;\n }\n shutdown() {\n if (!this.state.initialized)\n return;\n try {\n serverLogger.info("[tracing] Tracing shutdown initiated");\n } catch (error2) {\n serverLogger.warn("[tracing] Error during tracing shutdown", error2);\n }\n }\n};\nvar tracingManager = new TracingManager();\n\n// src/observability/metrics/manager.ts\ninit_utils();\n\n// src/observability/metrics/config.ts\nvar DEFAULT_METRICS_COLLECT_INTERVAL_MS2 = 6e4;\nvar DEFAULT_CONFIG3 = {\n enabled: false,\n exporter: "console",\n prefix: "veryfront",\n collectInterval: DEFAULT_METRICS_COLLECT_INTERVAL_MS2,\n debug: false\n};\nfunction loadConfig2(config, adapter) {\n const finalConfig = { ...DEFAULT_CONFIG3, ...config };\n if (adapter?.env) {\n const envAdapter = adapter.env;\n const otelEnabled = envAdapter.get("OTEL_METRICS_ENABLED");\n const veryfrontOtel = envAdapter.get("VERYFRONT_OTEL");\n finalConfig.enabled = otelEnabled === "true" || veryfrontOtel === "1" || finalConfig.enabled;\n const otlpEndpoint = envAdapter.get("OTEL_EXPORTER_OTLP_ENDPOINT");\n const metricsEndpoint = envAdapter.get(\n "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"\n );\n finalConfig.endpoint = otlpEndpoint || metricsEndpoint || finalConfig.endpoint;\n const exporterType = envAdapter.get("OTEL_METRICS_EXPORTER");\n if (exporterType === "prometheus" || exporterType === "otlp" || exporterType === "console") {\n finalConfig.exporter = exporterType;\n }\n } else {\n try {\n const env = process.env;\n if (env) {\n finalConfig.enabled = env.OTEL_METRICS_ENABLED === "true" || env.VERYFRONT_OTEL === "1" || finalConfig.enabled;\n finalConfig.endpoint = env.OTEL_EXPORTER_OTLP_ENDPOINT || env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT || finalConfig.endpoint;\n const exporterType = env.OTEL_METRICS_EXPORTER;\n if (exporterType === "prometheus" || exporterType === "otlp" || exporterType === "console") {\n finalConfig.exporter = exporterType;\n }\n }\n } catch {\n }\n }\n return finalConfig;\n}\nfunction getMemoryUsage() {\n try {\n if (process?.memoryUsage) {\n return process.memoryUsage();\n }\n return null;\n } catch {\n return null;\n }\n}\n\n// src/observability/instruments/instruments-factory.ts\ninit_utils();\n\n// src/observability/instruments/build-instruments.ts\ninit_config();\nfunction createBuildInstruments(meter, config) {\n const buildDuration = meter.createHistogram(\n `${config.prefix}.build.duration`,\n {\n description: "Build operation duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const bundleSizeHistogram = meter.createHistogram(\n `${config.prefix}.build.bundle.size`,\n {\n description: "Bundle size distribution",\n unit: "kb",\n advice: { explicitBucketBoundaries: SIZE_HISTOGRAM_BOUNDARIES_KB }\n }\n );\n const bundleCounter = meter.createCounter(\n `${config.prefix}.build.bundles`,\n {\n description: "Total number of bundles created",\n unit: "bundles"\n }\n );\n return {\n buildDuration,\n bundleSizeHistogram,\n bundleCounter\n };\n}\n\n// src/observability/instruments/cache-instruments.ts\nfunction createCacheInstruments(meter, config, runtimeState) {\n const cacheGetCounter = meter.createCounter(\n `${config.prefix}.cache.gets`,\n {\n description: "Total number of cache get operations",\n unit: "operations"\n }\n );\n const cacheHitCounter = meter.createCounter(\n `${config.prefix}.cache.hits`,\n {\n description: "Total number of cache hits",\n unit: "hits"\n }\n );\n const cacheMissCounter = meter.createCounter(\n `${config.prefix}.cache.misses`,\n {\n description: "Total number of cache misses",\n unit: "misses"\n }\n );\n const cacheSetCounter = meter.createCounter(\n `${config.prefix}.cache.sets`,\n {\n description: "Total number of cache set operations",\n unit: "operations"\n }\n );\n const cacheInvalidateCounter = meter.createCounter(\n `${config.prefix}.cache.invalidations`,\n {\n description: "Total number of cache invalidations",\n unit: "operations"\n }\n );\n const cacheSizeGauge = meter.createObservableGauge(\n `${config.prefix}.cache.size`,\n {\n description: "Current cache size",\n unit: "entries"\n }\n );\n cacheSizeGauge.addCallback((result) => {\n result.observe(runtimeState.cacheSize);\n });\n return {\n cacheGetCounter,\n cacheHitCounter,\n cacheMissCounter,\n cacheSetCounter,\n cacheInvalidateCounter,\n cacheSizeGauge\n };\n}\n\n// src/observability/instruments/data-instruments.ts\ninit_config();\nfunction createDataInstruments(meter, config) {\n const dataFetchDuration = meter.createHistogram(\n `${config.prefix}.data.fetch.duration`,\n {\n description: "Data fetch duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const dataFetchCounter = meter.createCounter(\n `${config.prefix}.data.fetch.count`,\n {\n description: "Total number of data fetches",\n unit: "fetches"\n }\n );\n const dataFetchErrorCounter = meter.createCounter(\n `${config.prefix}.data.fetch.errors`,\n {\n description: "Data fetch errors",\n unit: "errors"\n }\n );\n return {\n dataFetchDuration,\n dataFetchCounter,\n dataFetchErrorCounter\n };\n}\n\n// src/observability/instruments/http-instruments.ts\ninit_config();\nfunction createHttpInstruments(meter, config) {\n const httpRequestCounter = meter.createCounter(\n `${config.prefix}.http.requests`,\n {\n description: "Total number of HTTP requests",\n unit: "requests"\n }\n );\n const httpRequestDuration = meter.createHistogram(\n `${config.prefix}.http.request.duration`,\n {\n description: "HTTP request duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const httpActiveRequests = meter.createUpDownCounter(\n `${config.prefix}.http.requests.active`,\n {\n description: "Number of active HTTP requests",\n unit: "requests"\n }\n );\n return {\n httpRequestCounter,\n httpRequestDuration,\n httpActiveRequests\n };\n}\n\n// src/observability/instruments/memory-instruments.ts\nfunction createMemoryInstruments(meter, config) {\n const memoryUsageGauge = meter.createObservableGauge(\n `${config.prefix}.memory.usage`,\n {\n description: "Memory usage",\n unit: "bytes"\n }\n );\n memoryUsageGauge.addCallback((result) => {\n const memoryUsage = getMemoryUsage();\n if (memoryUsage) {\n result.observe(memoryUsage.rss);\n }\n });\n const heapUsageGauge = meter.createObservableGauge(\n `${config.prefix}.memory.heap`,\n {\n description: "Heap memory usage",\n unit: "bytes"\n }\n );\n heapUsageGauge.addCallback((result) => {\n const memoryUsage = getMemoryUsage();\n if (memoryUsage) {\n result.observe(memoryUsage.heapUsed);\n }\n });\n return {\n memoryUsageGauge,\n heapUsageGauge\n };\n}\n\n// src/observability/instruments/render-instruments.ts\ninit_config();\nfunction createRenderInstruments(meter, config) {\n const renderDuration = meter.createHistogram(\n `${config.prefix}.render.duration`,\n {\n description: "Page render duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const renderCounter = meter.createCounter(\n `${config.prefix}.render.count`,\n {\n description: "Total number of page renders",\n unit: "renders"\n }\n );\n const renderErrorCounter = meter.createCounter(\n `${config.prefix}.render.errors`,\n {\n description: "Total number of render errors",\n unit: "errors"\n }\n );\n return {\n renderDuration,\n renderCounter,\n renderErrorCounter\n };\n}\n\n// src/observability/instruments/rsc-instruments.ts\ninit_config();\nfunction createRscInstruments(meter, config) {\n const rscRenderDuration = meter.createHistogram(\n `${config.prefix}.rsc.render.duration`,\n {\n description: "RSC render duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const rscStreamDuration = meter.createHistogram(\n `${config.prefix}.rsc.stream.duration`,\n {\n description: "RSC stream duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const rscManifestCounter = meter.createCounter(\n `${config.prefix}.rsc.manifest`,\n {\n description: "RSC manifest requests",\n unit: "requests"\n }\n );\n const rscPageCounter = meter.createCounter(\n `${config.prefix}.rsc.page`,\n {\n description: "RSC page requests",\n unit: "requests"\n }\n );\n const rscStreamCounter = meter.createCounter(\n `${config.prefix}.rsc.stream`,\n {\n description: "RSC stream requests",\n unit: "requests"\n }\n );\n const rscActionCounter = meter.createCounter(\n `${config.prefix}.rsc.action`,\n {\n description: "RSC action requests",\n unit: "requests"\n }\n );\n const rscErrorCounter = meter.createCounter(\n `${config.prefix}.rsc.errors`,\n {\n description: "RSC errors",\n unit: "errors"\n }\n );\n return {\n rscRenderDuration,\n rscStreamDuration,\n rscManifestCounter,\n rscPageCounter,\n rscStreamCounter,\n rscActionCounter,\n rscErrorCounter\n };\n}\n\n// src/observability/instruments/instruments-factory.ts\nasync function initializeInstruments(meter, config, runtimeState) {\n const instruments = {\n httpRequestCounter: null,\n httpRequestDuration: null,\n httpActiveRequests: null,\n cacheGetCounter: null,\n cacheHitCounter: null,\n cacheMissCounter: null,\n cacheSetCounter: null,\n cacheInvalidateCounter: null,\n cacheSizeGauge: null,\n renderDuration: null,\n renderCounter: null,\n renderErrorCounter: null,\n rscRenderDuration: null,\n rscStreamDuration: null,\n rscManifestCounter: null,\n rscPageCounter: null,\n rscStreamCounter: null,\n rscActionCounter: null,\n rscErrorCounter: null,\n buildDuration: null,\n bundleSizeHistogram: null,\n bundleCounter: null,\n dataFetchDuration: null,\n dataFetchCounter: null,\n dataFetchErrorCounter: null,\n corsRejectionCounter: null,\n securityHeadersCounter: null,\n memoryUsageGauge: null,\n heapUsageGauge: null\n };\n try {\n const httpInstruments = createHttpInstruments(meter, config);\n Object.assign(instruments, httpInstruments);\n const cacheInstruments = createCacheInstruments(meter, config, runtimeState);\n Object.assign(instruments, cacheInstruments);\n const renderInstruments = createRenderInstruments(meter, config);\n Object.assign(instruments, renderInstruments);\n const rscInstruments = createRscInstruments(meter, config);\n Object.assign(instruments, rscInstruments);\n const buildInstruments = createBuildInstruments(meter, config);\n Object.assign(instruments, buildInstruments);\n const dataInstruments = createDataInstruments(meter, config);\n Object.assign(instruments, dataInstruments);\n const memoryInstruments = createMemoryInstruments(meter, config);\n Object.assign(instruments, memoryInstruments);\n } catch (error2) {\n serverLogger.warn("[metrics] Failed to initialize metric instruments", error2);\n }\n await Promise.resolve();\n return instruments;\n}\n\n// src/observability/metrics/recorder.ts\nvar MetricsRecorder = class {\n constructor(instruments, runtimeState) {\n this.instruments = instruments;\n this.runtimeState = runtimeState;\n this.stateLock = { locked: false };\n }\n /**\n * Execute state mutation atomically to prevent race conditions\n */\n atomicUpdate(fn) {\n while (this.stateLock.locked) {\n }\n this.stateLock.locked = true;\n try {\n fn();\n } finally {\n this.stateLock.locked = false;\n }\n }\n // HTTP Metrics\n recordHttpRequest(attributes) {\n this.instruments.httpRequestCounter?.add(1, attributes);\n this.instruments.httpActiveRequests?.add(1, attributes);\n this.atomicUpdate(() => {\n this.runtimeState.activeRequests++;\n });\n }\n recordHttpRequestComplete(durationMs, attributes) {\n this.instruments.httpRequestDuration?.record(durationMs, attributes);\n this.instruments.httpActiveRequests?.add(-1, attributes);\n this.atomicUpdate(() => {\n this.runtimeState.activeRequests--;\n });\n }\n // Cache Metrics\n recordCacheGet(hit, attributes) {\n this.instruments.cacheGetCounter?.add(1, attributes);\n if (hit) {\n this.instruments.cacheHitCounter?.add(1, attributes);\n } else {\n this.instruments.cacheMissCounter?.add(1, attributes);\n }\n }\n recordCacheSet(attributes) {\n this.instruments.cacheSetCounter?.add(1, attributes);\n this.atomicUpdate(() => {\n this.runtimeState.cacheSize++;\n });\n }\n recordCacheInvalidate(count, attributes) {\n this.instruments.cacheInvalidateCounter?.add(count, attributes);\n this.atomicUpdate(() => {\n this.runtimeState.cacheSize = Math.max(\n 0,\n this.runtimeState.cacheSize - count\n );\n });\n }\n setCacheSize(size) {\n this.atomicUpdate(() => {\n this.runtimeState.cacheSize = size;\n });\n }\n // Render Metrics\n recordRender(durationMs, attributes) {\n this.instruments.renderDuration?.record(durationMs, attributes);\n this.instruments.renderCounter?.add(1, attributes);\n }\n recordRenderError(attributes) {\n this.instruments.renderErrorCounter?.add(1, attributes);\n }\n // RSC Metrics\n recordRSCRender(durationMs, attributes) {\n this.instruments.rscRenderDuration?.record(durationMs, attributes);\n }\n recordRSCStream(durationMs, attributes) {\n this.instruments.rscStreamDuration?.record(durationMs, attributes);\n }\n recordRSCRequest(type, attributes) {\n switch (type) {\n case "manifest":\n this.instruments.rscManifestCounter?.add(1, attributes);\n break;\n case "page":\n this.instruments.rscPageCounter?.add(1, attributes);\n break;\n case "stream":\n this.instruments.rscStreamCounter?.add(1, attributes);\n break;\n case "action":\n this.instruments.rscActionCounter?.add(1, attributes);\n break;\n }\n }\n recordRSCError(attributes) {\n this.instruments.rscErrorCounter?.add(1, attributes);\n }\n // Build Metrics\n recordBuild(durationMs, attributes) {\n this.instruments.buildDuration?.record(durationMs, attributes);\n }\n recordBundle(sizeKb, attributes) {\n this.instruments.bundleSizeHistogram?.record(sizeKb, attributes);\n this.instruments.bundleCounter?.add(1, attributes);\n }\n // Data Fetching Metrics\n recordDataFetch(durationMs, attributes) {\n this.instruments.dataFetchDuration?.record(durationMs, attributes);\n this.instruments.dataFetchCounter?.add(1, attributes);\n }\n recordDataFetchError(attributes) {\n this.instruments.dataFetchErrorCounter?.add(1, attributes);\n }\n // Security Metrics\n recordCorsRejection(attributes) {\n this.instruments.corsRejectionCounter?.add(1, attributes);\n }\n recordSecurityHeaders(attributes) {\n this.instruments.securityHeadersCounter?.add(1, attributes);\n }\n};\n\n// src/observability/metrics/manager.ts\nvar MetricsManager = class {\n constructor() {\n this.initialized = false;\n this.meter = null;\n this.api = null;\n this.recorder = null;\n this.instruments = this.createEmptyInstruments();\n this.runtimeState = {\n cacheSize: 0,\n activeRequests: 0\n };\n this.recorder = new MetricsRecorder(this.instruments, this.runtimeState);\n }\n createEmptyInstruments() {\n return {\n httpRequestCounter: null,\n httpRequestDuration: null,\n httpActiveRequests: null,\n cacheGetCounter: null,\n cacheHitCounter: null,\n cacheMissCounter: null,\n cacheSetCounter: null,\n cacheInvalidateCounter: null,\n cacheSizeGauge: null,\n renderDuration: null,\n renderCounter: null,\n renderErrorCounter: null,\n rscRenderDuration: null,\n rscStreamDuration: null,\n rscManifestCounter: null,\n rscPageCounter: null,\n rscStreamCounter: null,\n rscActionCounter: null,\n rscErrorCounter: null,\n buildDuration: null,\n bundleSizeHistogram: null,\n bundleCounter: null,\n dataFetchDuration: null,\n dataFetchCounter: null,\n dataFetchErrorCounter: null,\n corsRejectionCounter: null,\n securityHeadersCounter: null,\n memoryUsageGauge: null,\n heapUsageGauge: null\n };\n }\n async initialize(config = {}, adapter) {\n if (this.initialized) {\n serverLogger.debug("[metrics] Already initialized");\n return;\n }\n const finalConfig = loadConfig2(config, adapter);\n if (!finalConfig.enabled) {\n serverLogger.debug("[metrics] Metrics collection disabled");\n this.initialized = true;\n return;\n }\n try {\n this.api = await import("npm:@opentelemetry/api@1");\n this.meter = this.api.metrics.getMeter(finalConfig.prefix, "0.1.0");\n this.instruments = await initializeInstruments(\n this.meter,\n finalConfig,\n this.runtimeState\n );\n if (this.recorder) {\n this.recorder.instruments = this.instruments;\n }\n this.initialized = true;\n serverLogger.info("[metrics] OpenTelemetry metrics initialized", {\n exporter: finalConfig.exporter,\n endpoint: finalConfig.endpoint,\n prefix: finalConfig.prefix\n });\n } catch (error2) {\n serverLogger.warn("[metrics] Failed to initialize OpenTelemetry metrics", error2);\n this.initialized = true;\n }\n }\n isEnabled() {\n return this.initialized && this.meter !== null;\n }\n getRecorder() {\n return this.recorder;\n }\n getState() {\n return {\n initialized: this.initialized,\n cacheSize: this.runtimeState.cacheSize,\n activeRequests: this.runtimeState.activeRequests\n };\n }\n shutdown() {\n if (!this.initialized)\n return;\n try {\n serverLogger.info("[metrics] Metrics shutdown initiated");\n } catch (error2) {\n serverLogger.warn("[metrics] Error during metrics shutdown", error2);\n }\n }\n};\nvar metricsManager = new MetricsManager();\n\n// src/observability/metrics/index.ts\nvar getRecorder = () => metricsManager.getRecorder();\nfunction recordCorsRejection(attributes) {\n getRecorder()?.recordCorsRejection?.(attributes);\n}\nfunction recordSecurityHeaders(attributes) {\n getRecorder()?.recordSecurityHeaders?.(attributes);\n}\n\n// src/observability/auto-instrument/orchestrator.ts\ninit_utils();\n\n// src/observability/auto-instrument/http-instrumentation.ts\ninit_utils();\nimport {\n context as otContext,\n propagation,\n SpanKind,\n SpanStatusCode,\n trace\n} from "npm:@opentelemetry/api@1";\nvar tracer = trace.getTracer("veryfront-http");\n\n// src/security/http/cors/validators.ts\nasync function validateOrigin(requestOrigin, config) {\n if (!config) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (config === true) {\n const origin = requestOrigin || "*";\n return { allowedOrigin: origin, allowCredentials: false };\n }\n const corsConfig = config;\n if (!corsConfig.origin) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (!requestOrigin) {\n if (corsConfig.origin === "*") {\n return { allowedOrigin: "*", allowCredentials: false };\n }\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (corsConfig.origin === "*") {\n if (corsConfig.credentials) {\n serverLogger.warn("[CORS] Cannot use credentials with wildcard origin - denying");\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Cannot use credentials with wildcard origin"\n };\n }\n return { allowedOrigin: "*", allowCredentials: false };\n }\n if (typeof corsConfig.origin === "function") {\n try {\n const result = await corsConfig.origin(requestOrigin);\n if (typeof result === "string") {\n return {\n allowedOrigin: result,\n allowCredentials: corsConfig.credentials ?? false\n };\n }\n const allowed = result === true;\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin rejected by validation function"\n };\n } catch (error2) {\n serverLogger.error("[CORS] Origin validation function error", error2);\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Origin validation error"\n };\n }\n }\n if (Array.isArray(corsConfig.origin)) {\n const allowed = corsConfig.origin.includes(requestOrigin);\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin not in allowlist", {\n requestOrigin,\n allowedOrigins: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin not in allowlist"\n };\n }\n if (typeof corsConfig.origin === "string") {\n const allowed = corsConfig.origin === requestOrigin;\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin does not match", {\n requestOrigin,\n expectedOrigin: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin does not match"\n };\n }\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Invalid origin configuration"\n };\n}\nfunction validateOriginSync(requestOrigin, config) {\n if (!config) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (config === true) {\n const origin = requestOrigin || "*";\n return { allowedOrigin: origin, allowCredentials: false };\n }\n const corsConfig = config;\n if (!corsConfig.origin) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (!requestOrigin) {\n if (corsConfig.origin === "*") {\n return { allowedOrigin: "*", allowCredentials: false };\n }\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (corsConfig.origin === "*") {\n if (corsConfig.credentials) {\n serverLogger.warn("[CORS] Cannot use credentials with wildcard origin - denying");\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Cannot use credentials with wildcard origin"\n };\n }\n return { allowedOrigin: "*", allowCredentials: false };\n }\n if (typeof corsConfig.origin === "function") {\n try {\n const result = corsConfig.origin(requestOrigin);\n if (result instanceof Promise) {\n serverLogger.warn(\n "[CORS] Async origin validators are not supported in synchronous contexts"\n );\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Async origin validators not supported"\n };\n }\n if (typeof result === "string") {\n return {\n allowedOrigin: result,\n allowCredentials: corsConfig.credentials ?? false\n };\n }\n const allowed = result === true;\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin rejected by validation function"\n };\n } catch (error2) {\n serverLogger.error("[CORS] Origin validation function error", error2);\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Origin validation error"\n };\n }\n }\n if (Array.isArray(corsConfig.origin)) {\n const allowed = corsConfig.origin.includes(requestOrigin);\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin not in allowlist (sync)", {\n requestOrigin,\n allowedOrigins: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin not in allowlist"\n };\n }\n if (typeof corsConfig.origin === "string") {\n const allowed = corsConfig.origin === requestOrigin;\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin does not match (sync)", {\n requestOrigin,\n expectedOrigin: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin does not match"\n };\n }\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Invalid origin configuration"\n };\n}\n\n// src/security/http/cors/headers.ts\nasync function applyCORSHeaders(options) {\n const { request, response, headers: headersObj, config } = options;\n const validation = await validateOrigin(request.headers.get("origin"), config);\n if (!validation.allowedOrigin) {\n return response;\n }\n const headers = headersObj || (response ? new Headers(response.headers) : new Headers());\n headers.set("Access-Control-Allow-Origin", validation.allowedOrigin);\n if (validation.allowedOrigin !== "*") {\n const existingVary = headers.get("Vary");\n const varyValues = existingVary ? existingVary.split(",").map((v) => v.trim()) : [];\n if (!varyValues.includes("Origin")) {\n varyValues.push("Origin");\n headers.set("Vary", varyValues.join(", "));\n }\n }\n if (validation.allowCredentials && validation.allowedOrigin !== "*") {\n headers.set("Access-Control-Allow-Credentials", "true");\n }\n const corsConfig = typeof config === "object" ? config : null;\n if (corsConfig?.exposedHeaders && corsConfig.exposedHeaders.length > 0) {\n headers.set("Access-Control-Expose-Headers", corsConfig.exposedHeaders.join(", "));\n }\n if (response) {\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers\n });\n }\n return;\n}\nfunction applyCORSHeadersSync(options) {\n const { request, response, headers: headersObj, config } = options;\n const validation = validateOriginSync(request.headers.get("origin"), config);\n if (!validation.allowedOrigin) {\n return response;\n }\n const headers = headersObj || (response ? new Headers(response.headers) : new Headers());\n headers.set("Access-Control-Allow-Origin", validation.allowedOrigin);\n if (validation.allowedOrigin !== "*") {\n const existingVary = headers.get("Vary");\n const varyValues = existingVary ? existingVary.split(",").map((v) => v.trim()) : [];\n if (!varyValues.includes("Origin")) {\n varyValues.push("Origin");\n headers.set("Vary", varyValues.join(", "));\n }\n }\n if (validation.allowCredentials && validation.allowedOrigin !== "*") {\n headers.set("Access-Control-Allow-Credentials", "true");\n }\n const corsConfig = typeof config === "object" ? config : null;\n if (corsConfig?.exposedHeaders && corsConfig.exposedHeaders.length > 0) {\n headers.set("Access-Control-Expose-Headers", corsConfig.exposedHeaders.join(", "));\n }\n if (response) {\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers\n });\n }\n return;\n}\n\n// src/security/http/cors/constants.ts\ninit_config();\n\n// src/security/http/cors/preflight.ts\ninit_logger();\n\n// src/security/http/cors/middleware.ts\ninit_veryfront_error();\n\n// src/security/http/response/security-handler.ts\ninit_utils();\nfunction generateNonce() {\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n return btoa(String.fromCharCode(...array));\n}\nfunction buildCSP(isDev, nonce, cspUserHeader, config, adapter) {\n const envCsp = adapter?.env?.get?.("VERYFRONT_CSP");\n if (envCsp?.trim())\n return envCsp.replace(/{NONCE}/g, nonce);\n const defaultCsp = isDev ? [\n "default-src \'self\'",\n `style-src \'self\' \'nonce-${nonce}\' \'unsafe-inline\' https://esm.sh https://cdnjs.cloudflare.com https://cdn.veryfront.com https://cdn.jsdelivr.net`,\n "img-src \'self\' data: https://cdn.veryfront.com https://cdnjs.cloudflare.com",\n `script-src \'self\' \'nonce-${nonce}\' \'unsafe-eval\' https://esm.sh https://cdn.tailwindcss.com`,\n "connect-src \'self\' https://esm.sh ws://localhost:* wss://localhost:*",\n "font-src \'self\' data: https://cdnjs.cloudflare.com"\n ].join("; ") : [\n "default-src \'self\'",\n `style-src \'self\' \'nonce-${nonce}\'`,\n "img-src \'self\' data:",\n `script-src \'self\' \'nonce-${nonce}\'`,\n "connect-src \'self\'"\n ].join("; ");\n if (cspUserHeader?.trim()) {\n return `${cspUserHeader.replace(/{NONCE}/g, nonce)}; ${defaultCsp}`;\n }\n const cfgCsp = config?.csp;\n if (cfgCsp && typeof cfgCsp === "object") {\n const pieces = [];\n for (const [k, v] of Object.entries(cfgCsp)) {\n if (v === void 0)\n continue;\n const key = String(k).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n const val = Array.isArray(v) ? v.join(" ") : String(v);\n pieces.push(`${key} ${val}`.replace(/{NONCE}/g, nonce));\n }\n if (pieces.length > 0) {\n return `${pieces.join("; ")}; ${defaultCsp}`;\n }\n }\n return defaultCsp;\n}\nfunction getSecurityHeader(headerName, defaultValue, config, adapter) {\n const configKey = headerName.toLowerCase();\n const configValue = config?.[configKey];\n const envValue = adapter?.env?.get?.(`VERYFRONT_${headerName}`);\n return (typeof configValue === "string" ? configValue : void 0) || envValue || defaultValue;\n}\nfunction applySecurityHeaders(headers, isDev, nonce, cspUserHeader, config, adapter) {\n serverLogger.debug("[NONCE-TRACE] applySecurityHeaders called", { nonce });\n const getHeaderOverride = (name) => {\n const overrides = config?.headers;\n if (!overrides)\n return void 0;\n const lower = name.toLowerCase();\n for (const [key, value] of Object.entries(overrides)) {\n if (key.toLowerCase() === lower) {\n return value;\n }\n }\n return void 0;\n };\n const contentTypeOptions = getHeaderOverride("x-content-type-options") ?? "nosniff";\n headers.set("X-Content-Type-Options", contentTypeOptions);\n const frameOptions = getHeaderOverride("x-frame-options") ?? "DENY";\n headers.set("X-Frame-Options", frameOptions);\n const xssProtection = getHeaderOverride("x-xss-protection") ?? "1; mode=block";\n headers.set("X-XSS-Protection", xssProtection);\n const csp = buildCSP(isDev, nonce, cspUserHeader, config, adapter);\n if (csp) {\n headers.set("Content-Security-Policy", csp);\n }\n if (!isDev) {\n const hstsMaxAge = config?.hsts?.maxAge ?? 31536e3;\n const hstsIncludeSubDomains = config?.hsts?.includeSubDomains ?? true;\n const hstsPreload = config?.hsts?.preload ?? false;\n let hstsValue = `max-age=${hstsMaxAge}`;\n if (hstsIncludeSubDomains) {\n hstsValue += "; includeSubDomains";\n }\n if (hstsPreload) {\n hstsValue += "; preload";\n }\n const hstsOverride = getHeaderOverride("strict-transport-security");\n headers.set("Strict-Transport-Security", hstsOverride ?? hstsValue);\n }\n const coop = getSecurityHeader("COOP", "same-origin", config, adapter);\n const corp = getSecurityHeader("CORP", "same-origin", config, adapter);\n const coep = getSecurityHeader("COEP", "", config, adapter);\n headers.set("Cross-Origin-Opener-Policy", coop);\n headers.set("Cross-Origin-Resource-Policy", corp);\n if (coep) {\n headers.set("Cross-Origin-Embedder-Policy", coep);\n }\n if (config?.headers) {\n for (const [key, value] of Object.entries(config.headers)) {\n if (value === void 0)\n continue;\n headers.set(key, value);\n }\n }\n recordSecurityHeaders();\n}\n\n// src/security/http/response/cache-handler.ts\nfunction buildCacheControl(strategy) {\n let cacheControl;\n if (typeof strategy === "string") {\n switch (strategy) {\n case "no-cache":\n cacheControl = "no-cache, no-store, must-revalidate";\n break;\n case "no-store":\n cacheControl = "no-store";\n break;\n case "short":\n cacheControl = `public, max-age=${CACHE_DURATIONS.SHORT}`;\n break;\n case "medium":\n cacheControl = `public, max-age=${CACHE_DURATIONS.MEDIUM}`;\n break;\n case "long":\n cacheControl = `public, max-age=${CACHE_DURATIONS.LONG}`;\n break;\n case "immutable":\n cacheControl = `public, max-age=${CACHE_DURATIONS.LONG}, immutable`;\n break;\n case "none":\n cacheControl = "no-cache, no-store, must-revalidate";\n break;\n default:\n cacheControl = "public, max-age=0";\n }\n } else {\n const parts = [];\n parts.push(strategy.public !== false ? "public" : "private");\n parts.push(`max-age=${strategy.maxAge}`);\n if (strategy.immutable)\n parts.push("immutable");\n if (strategy.mustRevalidate)\n parts.push("must-revalidate");\n cacheControl = parts.join(", ");\n }\n return cacheControl;\n}\n\n// src/security/http/response/fluent-methods.ts\nfunction withCORS(req, corsConfig) {\n const config = corsConfig ?? this.securityConfig?.cors;\n applyCORSHeadersSync({\n request: req,\n headers: this.headers,\n config\n });\n return this;\n}\nfunction withCORSAsync(req) {\n return applyCORSHeaders({\n request: req,\n headers: this.headers,\n config: this.securityConfig?.cors\n }).then(() => this);\n}\nfunction withSecurity(config) {\n const cfg = config ?? this.securityConfig;\n applySecurityHeaders(\n this.headers,\n this.isDev,\n this.nonce,\n this.cspUserHeader,\n cfg,\n this.adapter\n );\n return this;\n}\nfunction withCache(strategy) {\n const cacheControl = buildCacheControl(strategy);\n this.headers.set("cache-control", cacheControl);\n return this;\n}\nfunction withETag(etag) {\n this.headers.set("ETag", etag);\n return this;\n}\nfunction withHeaders(headers) {\n if (headers instanceof Headers) {\n headers.forEach((value, key) => {\n this.headers.set(key, value);\n });\n } else if (Array.isArray(headers)) {\n headers.forEach(([key, value]) => {\n this.headers.set(key, value);\n });\n } else {\n Object.entries(headers).forEach(([key, value]) => {\n this.headers.set(key, value);\n });\n }\n return this;\n}\nfunction withStatus(status) {\n this.status = status;\n return this;\n}\nfunction withAllow(methods) {\n const methodStr = Array.isArray(methods) ? methods.join(", ") : methods;\n this.headers.set("Allow", methodStr);\n this.headers.set("Access-Control-Allow-Methods", methodStr);\n return this;\n}\n\n// src/security/http/response/response-methods.ts\nfunction json(data, status) {\n this.headers.set("content-type", CONTENT_TYPES.JSON);\n return new Response(JSON.stringify(data), {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction text(body, status) {\n this.headers.set("content-type", CONTENT_TYPES.TEXT);\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction html(body, status) {\n this.headers.set("content-type", CONTENT_TYPES.HTML);\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction javascript(code, status) {\n this.headers.set("content-type", CONTENT_TYPES.JAVASCRIPT);\n return new Response(code, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction withContentType(contentType, body, status) {\n this.headers.set("content-type", contentType);\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction build(body = null, status) {\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction notModified(etag) {\n if (etag) {\n this.headers.set("ETag", etag);\n }\n return new Response(null, {\n status: 304,\n headers: this.headers\n });\n}\n\n// src/security/http/response/static-helpers.ts\ninit_veryfront_error();\nvar ResponseBuilderClass = null;\nfunction setResponseBuilderClass(builderClass) {\n ResponseBuilderClass = builderClass;\n}\nfunction error(status, message, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n const contentType = config?.contentType ?? CONTENT_TYPES.TEXT;\n if (contentType === CONTENT_TYPES.JSON) {\n return builder.json({ error: message }, status);\n } else if (contentType === CONTENT_TYPES.HTML) {\n return builder.html(message, status);\n }\n return builder.text(message, status);\n}\nfunction json2(data, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n if (config?.cache) {\n builder.withCache(config.cache);\n }\n if (config?.etag) {\n builder.withETag(config.etag);\n }\n return builder.json(data, config?.status);\n}\nfunction html2(body, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n if (config?.cache) {\n builder.withCache(config.cache);\n }\n if (config?.etag) {\n builder.withETag(config.etag);\n }\n return builder.html(body, config?.status);\n}\nfunction preflight(req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n const methods = config?.allowMethods ?? "GET,POST,PUT,PATCH,DELETE,OPTIONS";\n builder.withAllow(methods);\n const headers = config?.allowHeaders ?? req.headers.get("access-control-request-headers") ?? "Content-Type,Authorization";\n builder.headers.set(\n "Access-Control-Allow-Headers",\n Array.isArray(headers) ? headers.join(", ") : headers\n );\n return builder.build(null, 204);\n}\nfunction stream(streamData, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n if (config?.cache) {\n builder.withCache(config.cache);\n }\n const contentType = config?.contentType ?? "application/octet-stream";\n return builder.withContentType(contentType, streamData);\n}\n\n// src/security/http/response/builder.ts\ninit_utils();\nvar ResponseBuilder = class {\n constructor(config) {\n // Fluent methods - bind imported functions to this instance\n this.withCORS = withCORS;\n this.withCORSAsync = withCORSAsync;\n this.withSecurity = withSecurity;\n this.withCache = withCache;\n this.withETag = withETag;\n this.withHeaders = withHeaders;\n this.withStatus = withStatus;\n this.withAllow = withAllow;\n // Response methods - bind imported functions to this instance\n this.json = json;\n this.text = text;\n this.html = html;\n this.javascript = javascript;\n this.withContentType = withContentType;\n this.build = build;\n this.notModified = notModified;\n this.headers = new Headers();\n this.status = 200;\n this.securityConfig = config?.securityConfig ?? null;\n this.isDev = config?.isDev ?? false;\n this.nonce = config?.nonce ?? generateNonce();\n serverLogger.debug("[NONCE-TRACE] ResponseBuilder nonce", {\n nonce: this.nonce,\n provided: !!config?.nonce\n });\n this.cspUserHeader = config?.cspUserHeader ?? null;\n this.adapter = config?.adapter;\n }\n};\n// Static helper methods - delegate to static-helpers module\nResponseBuilder.error = error;\nResponseBuilder.json = json2;\nResponseBuilder.html = html2;\nResponseBuilder.preflight = preflight;\nResponseBuilder.stream = stream;\nsetResponseBuilderClass(ResponseBuilder);\n\n// src/security/http/base-handler.ts\ninit_utils();\n\n// src/core/constants/index.ts\ninit_constants();\n\n// src/core/constants/buffers.ts\nvar DEFAULT_MAX_BODY_SIZE_BYTES = 1024 * 1024;\nvar DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;\nvar PREFETCH_QUEUE_MAX_SIZE_BYTES = 1024 * 1024;\nvar MAX_BUNDLE_CHUNK_SIZE_BYTES = 4096 * 1024;\n\n// src/core/constants/limits.ts\nvar MAX_URL_LENGTH_FOR_VALIDATION = 2048;\n\n// src/security/input-validation/parsers.ts\nimport { z as z2 } from "zod";\n\n// src/security/input-validation/schemas.ts\nimport { z as z3 } from "zod";\nvar CommonSchemas = {\n /**\n * Valid email address (RFC-compliant, max 255 chars)\n */\n email: z3.string().email().max(255),\n /**\n * Valid UUID v4 identifier\n */\n uuid: z3.string().uuid(),\n /**\n * URL-safe slug (lowercase alphanumeric with hyphens)\n */\n slug: z3.string().regex(/^[a-z0-9-]+$/).min(1).max(100),\n /**\n * Valid HTTP/HTTPS URL (max 2048 chars)\n */\n url: z3.string().url().max(MAX_URL_LENGTH_FOR_VALIDATION),\n /**\n * International phone number (E.164 format)\n */\n phoneNumber: z3.string().regex(/^\\+?[1-9]\\d{1,14}$/),\n /**\n * Pagination parameters with defaults\n */\n pagination: z3.object({\n page: z3.coerce.number().int().positive().default(1),\n limit: z3.coerce.number().int().positive().max(100).default(10),\n sort: z3.string().optional(),\n order: z3.enum(["asc", "desc"]).optional()\n }),\n /**\n * Date range with validation\n */\n dateRange: z3.object({\n from: z3.string().datetime(),\n to: z3.string().datetime()\n }).refine((data) => new Date(data.from) <= new Date(data.to), {\n message: "From date must be before or equal to To date"\n }),\n /**\n * Strong password requirements\n * - Minimum 8 characters\n * - At least one uppercase letter\n * - At least one lowercase letter\n * - At least one number\n * - At least one special character\n */\n strongPassword: z3.string().min(8, "Password must be at least 8 characters").regex(/[A-Z]/, "Password must contain at least one uppercase letter").regex(/[a-z]/, "Password must contain at least one lowercase letter").regex(/[0-9]/, "Password must contain at least one number").regex(/[^A-Za-z0-9]/, "Password must contain at least one special character")\n};\n\n// src/security/http/auth.ts\ninit_veryfront_error();\n\n// src/security/http/config.ts\ninit_config();\ninit_utils();\n\n// src/security/http/middleware/config-loader.ts\ninit_utils();\n\n// src/security/http/middleware/etag.ts\ninit_hash();\n\n// src/security/http/middleware/content-types.ts\ninit_http();\n\n// src/security/path-validation.ts\ninit_utils();\n\n// src/security/secure-fs.ts\ninit_utils();\n\n// src/routing/api/module-loader/loader.ts\ninit_utils();\ninit_std_path();\n\n// src/routing/api/module-loader/esbuild-plugin.ts\ninit_utils();\ninit_utils();\ninit_utils();\n\n// src/routing/api/module-loader/http-validator.ts\ninit_veryfront_error();\n\n// src/routing/api/module-loader/security-config.ts\ninit_utils();\ninit_utils();\n\n// src/routing/api/module-loader/loader.ts\ninit_veryfront_error();\n\n// src/routing/api/route-discovery.ts\ninit_std_path();\n\n// src/core/utils/file-discovery.ts\ninit_std_path();\ninit_deno3();\n\n// src/routing/api/route-executor.ts\ninit_utils();\ninit_veryfront_error();\n\n// src/routing/api/method-validator.ts\ninit_utils();\n\n// src/routing/api/error-handler.ts\ninit_utils();\ninit_utils();\ninit_utils();\n\n// src/rendering/client/router.ts\nvar VeryfrontRouter = class {\n constructor(options = {}) {\n this.root = null;\n const globalOptions = this.loadGlobalOptions();\n this.options = { ...globalOptions, ...options };\n this.baseUrl = options.baseUrl || globalThis.location.origin;\n this.currentPath = globalThis.location.pathname;\n this.pageLoader = new PageLoader();\n this.navigationHandlers = new NavigationHandlers(\n this.options.prefetchDelay,\n this.options.prefetch\n );\n this.pageTransition = new PageTransition((root) => this.viewportPrefetch.setup(root));\n this.viewportPrefetch = new ViewportPrefetch(\n (path) => this.prefetch(path),\n this.options.prefetch\n );\n this.handleClick = this.navigationHandlers.createClickHandler({\n onNavigate: (url) => this.navigate(url),\n onPrefetch: (url) => this.prefetch(url)\n });\n this.handlePopState = this.navigationHandlers.createPopStateHandler({\n onNavigate: (url) => this.navigate(url, false),\n onPrefetch: (url) => this.prefetch(url)\n });\n this.handleMouseOver = this.navigationHandlers.createMouseOverHandler({\n onNavigate: (url) => this.navigate(url),\n onPrefetch: (url) => this.prefetch(url)\n });\n }\n loadGlobalOptions() {\n try {\n const options = globalThis.__VERYFRONT_ROUTER_OPTS__;\n if (!options) {\n rendererLogger.debug("[router] No global options configured");\n return {};\n }\n return options;\n } catch (error2) {\n rendererLogger.error("[router] Failed to read global options:", error2);\n return {};\n }\n }\n init() {\n rendererLogger.info("Initializing client-side router");\n const rootElement = document.getElementById("root");\n if (!rootElement) {\n rendererLogger.error("Root element not found");\n return;\n }\n const ReactDOMToUse = globalThis.ReactDOM || ReactDOM;\n this.root = ReactDOMToUse.createRoot(rootElement);\n document.addEventListener("click", this.handleClick);\n globalThis.addEventListener("popstate", this.handlePopState);\n document.addEventListener("mouseover", this.handleMouseOver);\n this.viewportPrefetch.setup(document);\n this.cacheCurrentPage();\n }\n cacheCurrentPage() {\n const pageData = extractPageDataFromScript();\n if (pageData) {\n this.pageLoader.setCache(this.currentPath, pageData);\n }\n }\n async navigate(url, pushState = true) {\n rendererLogger.info(`Navigating to ${url}`);\n this.navigationHandlers.saveScrollPosition(this.currentPath);\n this.options.onStart?.(url);\n if (pushState) {\n globalThis.history.pushState({}, "", url);\n }\n await this.loadPage(url);\n this.options.onNavigate?.(url);\n }\n async loadPage(path, updateUI = true) {\n if (this.pageLoader.isCached(path)) {\n rendererLogger.debug(`Loading ${path} from cache`);\n const data = this.pageLoader.getCached(path);\n if (!data) {\n rendererLogger.warn(`[router] Cache entry for ${path} was unexpectedly null, fetching fresh data`);\n } else {\n if (updateUI) {\n this.updatePage(data);\n }\n return;\n }\n }\n this.pageTransition.setLoadingState(true);\n try {\n const data = await this.pageLoader.loadPage(path);\n if (updateUI) {\n this.updatePage(data);\n }\n this.currentPath = path;\n this.options.onComplete?.(path);\n } catch (error2) {\n rendererLogger.error(`Failed to load ${path}`, error2);\n this.options.onError?.(error2);\n this.pageTransition.showError(error2);\n } finally {\n this.pageTransition.setLoadingState(false);\n }\n }\n async prefetch(path) {\n await this.pageLoader.prefetch(path);\n }\n updatePage(data) {\n if (!this.root)\n return;\n const isPopState = this.navigationHandlers.isPopState();\n const scrollY = this.navigationHandlers.getScrollPosition(this.currentPath);\n this.pageTransition.updatePage(data, isPopState, scrollY);\n this.navigationHandlers.clearPopStateFlag();\n }\n destroy() {\n document.removeEventListener("click", this.handleClick);\n globalThis.removeEventListener("popstate", this.handlePopState);\n document.removeEventListener("mouseover", this.handleMouseOver);\n this.viewportPrefetch.disconnect();\n this.pageLoader.clearCache();\n this.navigationHandlers.clear();\n this.pageTransition.destroy();\n }\n};\nif (typeof window !== "undefined" && globalThis.document) {\n const router = new VeryfrontRouter();\n if (document.readyState === "loading") {\n document.addEventListener("DOMContentLoaded", () => router.init());\n } else {\n router.init();\n }\n globalThis.veryFrontRouter = router;\n}\nexport {\n VeryfrontRouter\n};\n';
|
|
14116
|
-
CLIENT_PREFETCH_BUNDLE = '// src/rendering/client/browser-logger.ts\nvar ConditionalBrowserLogger = class {\n constructor(prefix, level) {\n this.prefix = prefix;\n this.level = level;\n }\n debug(message, ...args) {\n if (this.level <= 0 /* DEBUG */) {\n console.debug?.(`[${this.prefix}] DEBUG: ${message}`, ...args);\n }\n }\n info(message, ...args) {\n if (this.level <= 1 /* INFO */) {\n console.log?.(`[${this.prefix}] ${message}`, ...args);\n }\n }\n warn(message, ...args) {\n if (this.level <= 2 /* WARN */) {\n console.warn?.(`[${this.prefix}] WARN: ${message}`, ...args);\n }\n }\n error(message, ...args) {\n if (this.level <= 3 /* ERROR */) {\n console.error?.(`[${this.prefix}] ERROR: ${message}`, ...args);\n }\n }\n};\nfunction getBrowserLogLevel() {\n if (typeof window === "undefined") {\n return 2 /* WARN */;\n }\n const windowObject = window;\n const isDevelopment = windowObject.__VERYFRONT_DEV__ || windowObject.__RSC_DEV__;\n if (!isDevelopment) {\n return 2 /* WARN */;\n }\n const isDebugEnabled = windowObject.__VERYFRONT_DEBUG__ || windowObject.__RSC_DEBUG__;\n return isDebugEnabled ? 0 /* DEBUG */ : 1 /* INFO */;\n}\nvar defaultLevel = getBrowserLogLevel();\nvar rscLogger = new ConditionalBrowserLogger("RSC", defaultLevel);\nvar prefetchLogger = new ConditionalBrowserLogger("PREFETCH", defaultLevel);\nvar hydrateLogger = new ConditionalBrowserLogger("HYDRATE", defaultLevel);\nvar browserLogger = new ConditionalBrowserLogger("VERYFRONT", defaultLevel);\n\n// src/rendering/client/prefetch/link-observer.ts\nvar LinkObserver = class {\n constructor(options, prefetchedUrls) {\n this.intersectionObserver = null;\n this.mutationObserver = null;\n this.pendingTimeouts = /* @__PURE__ */ new Map();\n this.elementTimeoutMap = /* @__PURE__ */ new WeakMap();\n // Track which timeout belongs to which element\n this.timeoutCounter = 0;\n this.options = options;\n this.prefetchedUrls = prefetchedUrls;\n }\n init() {\n this.createIntersectionObserver();\n this.observeLinks();\n this.setupMutationObserver();\n }\n createIntersectionObserver() {\n this.intersectionObserver = new IntersectionObserver(\n (entries) => this.handleIntersection(entries),\n { rootMargin: this.options.rootMargin }\n );\n }\n handleIntersection(entries) {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n const target = entry.target;\n let isAnchor = false;\n if (typeof HTMLAnchorElement !== "undefined") {\n isAnchor = target instanceof HTMLAnchorElement;\n } else {\n isAnchor = target.tagName === "A";\n }\n if (!isAnchor) {\n continue;\n }\n const link = target;\n const timeoutKey = this.timeoutCounter++;\n const timeoutId = setTimeout(() => {\n this.pendingTimeouts.delete(timeoutKey);\n this.elementTimeoutMap.delete(link);\n this.options.onLinkVisible(link);\n }, this.options.delay);\n this.pendingTimeouts.set(timeoutKey, timeoutId);\n this.elementTimeoutMap.set(link, timeoutKey);\n }\n }\n }\n observeLinks() {\n const links = document.querySelectorAll(\'a[href^="/"], a[href^="./"]\');\n links.forEach((link) => {\n if (this.isValidLink(link)) {\n this.intersectionObserver?.observe(link);\n }\n });\n }\n setupMutationObserver() {\n this.mutationObserver = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (mutation.type === "childList") {\n mutation.addedNodes.forEach((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n this.observeElement(node);\n }\n });\n mutation.removedNodes.forEach((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n this.clearElementTimeouts(node);\n }\n });\n }\n }\n });\n this.mutationObserver.observe(document.body, {\n childList: true,\n subtree: true\n });\n }\n clearElementTimeouts(element) {\n if (element.tagName === "A") {\n const timeoutKey = this.elementTimeoutMap.get(element);\n if (timeoutKey !== void 0) {\n const timeoutId = this.pendingTimeouts.get(timeoutKey);\n if (timeoutId) {\n clearTimeout(timeoutId);\n this.pendingTimeouts.delete(timeoutKey);\n }\n this.elementTimeoutMap.delete(element);\n }\n }\n const links = element.querySelectorAll("a");\n links.forEach((link) => {\n const timeoutKey = this.elementTimeoutMap.get(link);\n if (timeoutKey !== void 0) {\n const timeoutId = this.pendingTimeouts.get(timeoutKey);\n if (timeoutId) {\n clearTimeout(timeoutId);\n this.pendingTimeouts.delete(timeoutKey);\n }\n this.elementTimeoutMap.delete(link);\n }\n });\n }\n observeElement(element) {\n const isAnchor = typeof HTMLAnchorElement !== "undefined" ? element instanceof HTMLAnchorElement : element.tagName === "A";\n if (isAnchor && this.isValidLink(element)) {\n this.intersectionObserver?.observe(element);\n }\n const links = element.querySelectorAll(\'a[href^="/"], a[href^="./"]\');\n links.forEach((link) => {\n const isLinkAnchor = typeof HTMLAnchorElement !== "undefined" ? link instanceof HTMLAnchorElement : link.tagName === "A";\n if (isLinkAnchor && this.isValidLink(link)) {\n this.intersectionObserver?.observe(link);\n }\n });\n }\n isValidLink(link) {\n if (link.hostname !== globalThis.location.hostname)\n return false;\n if (link.hasAttribute("download"))\n return false;\n if (link.target === "_blank")\n return false;\n const url = link.href;\n if (this.prefetchedUrls.has(url))\n return false;\n if (url === globalThis.location.href)\n return false;\n if (link.hash && link.pathname === globalThis.location.pathname) {\n return false;\n }\n if (link.dataset.noPrefetch)\n return false;\n return true;\n }\n destroy() {\n for (const [_, timeoutId] of this.pendingTimeouts) {\n clearTimeout(timeoutId);\n }\n this.pendingTimeouts.clear();\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect();\n this.intersectionObserver = null;\n }\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = null;\n }\n }\n};\n\n// src/rendering/client/prefetch/network-utils.ts\nvar NetworkUtils = class {\n constructor(allowedNetworks = ["4g", "wifi", "ethernet"]) {\n this.allowedNetworks = allowedNetworks;\n this.networkInfo = this.getNetworkConnection();\n }\n getNavigatorWithConnection() {\n if (typeof globalThis.navigator === "undefined") {\n return null;\n }\n return globalThis.navigator;\n }\n getNetworkConnection() {\n const nav = this.getNavigatorWithConnection();\n return nav?.connection || nav?.mozConnection || nav?.webkitConnection || null;\n }\n shouldPrefetch() {\n const nav = this.getNavigatorWithConnection();\n if (nav?.connection?.saveData) {\n return false;\n }\n if (this.networkInfo) {\n const effectiveType = this.networkInfo.effectiveType;\n if (effectiveType !== void 0 && !this.allowedNetworks.includes(effectiveType)) {\n return false;\n }\n }\n return true;\n }\n onNetworkChange(callback) {\n if (this.networkInfo?.addEventListener) {\n this.networkInfo.addEventListener("change", callback);\n }\n }\n getNetworkInfo() {\n return this.networkInfo;\n }\n};\n\n// src/core/utils/constants/cache.ts\nvar SECONDS_PER_MINUTE = 60;\nvar MINUTES_PER_HOUR = 60;\nvar HOURS_PER_DAY = 24;\nvar MS_PER_SECOND = 1e3;\nvar COMPONENT_LOADER_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\nvar MDX_RENDERER_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\nvar RENDERER_CORE_TTL_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;\nvar TSX_LAYOUT_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\nvar DATA_FETCHING_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;\nvar MDX_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar MDX_CACHE_TTL_DEVELOPMENT_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;\nvar BUNDLE_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;\nvar BUNDLE_MANIFEST_PROD_TTL_MS = 7 * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar BUNDLE_MANIFEST_DEV_TTL_MS = MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar SERVER_ACTION_DEFAULT_TTL_SEC = MINUTES_PER_HOUR * SECONDS_PER_MINUTE;\nvar ONE_DAY_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;\n\n// src/core/utils/constants/http.ts\nvar KB_IN_BYTES = 1024;\nvar PREFETCH_MAX_SIZE_BYTES = 200 * KB_IN_BYTES;\nvar PREFETCH_DEFAULT_TIMEOUT_MS = 1e4;\nvar PREFETCH_DEFAULT_DELAY_MS = 200;\n\n// src/core/utils/constants/hmr.ts\nvar HMR_MAX_MESSAGE_SIZE_BYTES = 1024 * KB_IN_BYTES;\n\n// src/core/utils/constants/network.ts\nvar BYTES_PER_MB = 1024 * 1024;\n\n// src/core/constants/buffers.ts\nvar DEFAULT_MAX_BODY_SIZE_BYTES = 1024 * 1024;\nvar DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;\nvar PREFETCH_QUEUE_MAX_SIZE_BYTES = 1024 * 1024;\nvar MAX_BUNDLE_CHUNK_SIZE_BYTES = 4096 * 1024;\n\n// src/rendering/client/prefetch/prefetch-queue.ts\nvar DEFAULT_OPTIONS = {\n maxConcurrent: 4,\n maxSize: PREFETCH_QUEUE_MAX_SIZE_BYTES,\n // 1MB\n timeout: 5e3\n};\nfunction isAbortError(error) {\n return Boolean(\n error && typeof error === "object" && "name" in error && error.name === "AbortError"\n );\n}\nvar PrefetchQueue = class {\n constructor(options = {}, prefetchedUrls) {\n this.controllers = /* @__PURE__ */ new Map();\n this.concurrent = 0;\n this.stopped = false;\n this.options = { ...DEFAULT_OPTIONS, ...options };\n this.prefetchedUrls = prefetchedUrls ?? /* @__PURE__ */ new Set();\n }\n setResourceCallback(callback) {\n this.onResourcesFetched = callback;\n }\n enqueue(url) {\n void this.prefetch(url);\n }\n has(url) {\n return this.prefetchedUrls.has(url) || this.controllers.has(url);\n }\n get size() {\n return this.getQueueSize();\n }\n clear() {\n this.stopAll();\n this.prefetchedUrls.clear();\n }\n start() {\n this.stopped = false;\n }\n stop() {\n this.stopped = true;\n this.stopAll();\n }\n getQueueSize() {\n return this.controllers.size;\n }\n getConcurrentCount() {\n return this.concurrent;\n }\n async prefetchLink(link) {\n if (this.stopped) {\n return;\n }\n const url = link.href;\n if (!url || this.controllers.has(url) || this.prefetchedUrls.has(url)) {\n return;\n }\n if (this.concurrent >= this.options.maxConcurrent) {\n prefetchLogger.debug?.(`Prefetch queue full, skipping ${url}`);\n return;\n }\n let parsedUrl;\n try {\n parsedUrl = new URL(url);\n } catch (_error) {\n prefetchLogger.debug?.(`Invalid prefetch URL ${url}`);\n return;\n }\n const controller = new AbortController();\n this.controllers.set(url, controller);\n this.concurrent += 1;\n const timeoutId = this.options.timeout > 0 ? setTimeout(() => controller.abort(), this.options.timeout) : void 0;\n try {\n const response = await fetch(parsedUrl.toString(), {\n method: "GET",\n signal: controller.signal,\n headers: { "X-Veryfront-Prefetch": "1" }\n });\n if (!response.ok) {\n return;\n }\n if (this.isResponseTooLarge(response)) {\n prefetchLogger.debug?.(`Prefetch too large, skipping ${url}`);\n return;\n }\n this.prefetchedUrls.add(url);\n if (this.onResourcesFetched) {\n try {\n await this.onResourcesFetched(response, url);\n } catch (callbackError) {\n prefetchLogger.error?.(`Prefetch callback failed for ${url}`, callbackError);\n }\n }\n } catch (error) {\n if (!isAbortError(error)) {\n prefetchLogger.error?.(`Failed to prefetch ${url}`, error);\n }\n } finally {\n if (timeoutId !== void 0) {\n clearTimeout(timeoutId);\n }\n this.controllers.delete(url);\n this.concurrent = Math.max(0, this.concurrent - 1);\n }\n }\n async prefetch(url) {\n const link = typeof document !== "undefined" ? document.createElement("a") : { href: url };\n link.href = url;\n await this.prefetchLink(link);\n }\n stopAll() {\n for (const controller of this.controllers.values()) {\n controller.abort();\n }\n this.controllers.clear();\n this.concurrent = 0;\n }\n isResponseTooLarge(response) {\n const rawLength = response.headers.get("content-length");\n if (rawLength === null) {\n return false;\n }\n const size = Number.parseInt(rawLength, 10);\n if (!Number.isFinite(size)) {\n return false;\n }\n return size > this.options.maxSize;\n }\n};\nvar prefetchQueue = new PrefetchQueue();\n\n// src/rendering/client/prefetch/resource-hints.ts\nvar ResourceHintsManager = class {\n constructor() {\n this.appliedHints = /* @__PURE__ */ new Set();\n }\n applyResourceHints(hints) {\n for (const hint of hints) {\n const key = `${hint.type}:${hint.href}`;\n if (this.appliedHints.has(key))\n continue;\n const existing = document.querySelector(`link[rel="${hint.type}"][href="${hint.href}"]`);\n if (existing) {\n this.appliedHints.add(key);\n continue;\n }\n this.createAndAppendHint(hint);\n this.appliedHints.add(key);\n prefetchLogger.debug(`Added resource hint: ${hint.type} ${hint.href}`);\n }\n }\n createAndAppendHint(hint) {\n if (!document.head) {\n prefetchLogger.warn("document.head is not available, skipping resource hint");\n return;\n }\n const link = document.createElement("link");\n link.rel = hint.type;\n link.href = hint.href;\n if (hint.as)\n link.setAttribute("as", hint.as);\n if (hint.crossOrigin)\n link.setAttribute("crossorigin", hint.crossOrigin);\n if (hint.media)\n link.setAttribute("media", hint.media);\n document.head.appendChild(link);\n }\n extractResourceHints(html, prefetchedUrls) {\n try {\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, "text/html");\n const hints = [];\n this.extractPreloadLinks(doc, prefetchedUrls, hints);\n this.extractScripts(doc, prefetchedUrls, hints);\n this.extractStylesheets(doc, prefetchedUrls, hints);\n return hints;\n } catch (error) {\n prefetchLogger.error("Failed to parse prefetched page", error);\n return [];\n }\n }\n isValidResourceHintType(rel) {\n return rel === "prefetch" || rel === "preload" || rel === "preconnect" || rel === "dns-prefetch";\n }\n extractPreloadLinks(doc, prefetchedUrls, hints) {\n doc.querySelectorAll(\'link[rel="preload"], link[rel="prefetch"]\').forEach((link) => {\n const htmlLink = link;\n const href = htmlLink.href;\n if (href && !prefetchedUrls.has(href) && this.isValidResourceHintType(htmlLink.rel)) {\n hints.push({\n type: htmlLink.rel,\n href,\n as: htmlLink.getAttribute("as") || void 0\n });\n }\n });\n }\n extractScripts(doc, prefetchedUrls, hints) {\n doc.querySelectorAll("script[src]").forEach((script) => {\n const src = script.src;\n if (src && !prefetchedUrls.has(src)) {\n hints.push({ type: "prefetch", href: src, as: "script" });\n }\n });\n }\n extractStylesheets(doc, prefetchedUrls, hints) {\n doc.querySelectorAll(\'link[rel="stylesheet"]\').forEach((link) => {\n const href = link.href;\n if (href && !prefetchedUrls.has(href)) {\n hints.push({ type: "prefetch", href, as: "style" });\n }\n });\n }\n static generateResourceHints(_route, assets) {\n const hints = [\n \'<link rel="dns-prefetch" href="https://cdn.jsdelivr.net">\',\n \'<link rel="dns-prefetch" href="https://esm.sh">\',\n \'<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>\'\n ];\n for (const asset of assets) {\n if (asset.endsWith(".js")) {\n hints.push(`<link rel="modulepreload" href="${asset}">`);\n } else if (asset.endsWith(".css")) {\n hints.push(`<link rel="preload" as="style" href="${asset}">`);\n } else if (asset.match(/\\.(woff2?|ttf|otf)$/)) {\n hints.push(`<link rel="preload" as="font" href="${asset}" crossorigin>`);\n }\n }\n return hints.join("\\n");\n }\n};\n\n// src/core/utils/runtime-guards.ts\nfunction hasDenoRuntime(global) {\n return typeof global === "object" && global !== null && "Deno" in global && typeof global.Deno?.env?.get === "function";\n}\nfunction hasNodeProcess(global) {\n return typeof global === "object" && global !== null && "process" in global && typeof global.process?.env === "object";\n}\n\n// src/core/utils/logger/env.ts\nfunction getEnvironmentVariable(name) {\n try {\n if (typeof Deno !== "undefined" && hasDenoRuntime(globalThis)) {\n const value = globalThis.Deno?.env.get(name);\n return value === "" ? void 0 : value;\n }\n if (hasNodeProcess(globalThis)) {\n const value = globalThis.process?.env[name];\n return value === "" ? void 0 : value;\n }\n } catch (error) {\n console.debug(`Failed to get environment variable ${name}:`, error);\n return void 0;\n }\n return void 0;\n}\n\n// src/core/utils/logger/logger.ts\nvar cachedLogLevel;\nfunction resolveLogLevel(force = false) {\n if (force || cachedLogLevel === void 0) {\n cachedLogLevel = getDefaultLevel();\n }\n return cachedLogLevel;\n}\nvar ConsoleLogger = class {\n constructor(prefix, level = resolveLogLevel()) {\n this.prefix = prefix;\n this.level = level;\n }\n setLevel(level) {\n this.level = level;\n }\n getLevel() {\n return this.level;\n }\n debug(message, ...args) {\n if (this.level <= 0 /* DEBUG */) {\n console.debug(`[${this.prefix}] DEBUG: ${message}`, ...args);\n }\n }\n info(message, ...args) {\n if (this.level <= 1 /* INFO */) {\n console.log(`[${this.prefix}] ${message}`, ...args);\n }\n }\n warn(message, ...args) {\n if (this.level <= 2 /* WARN */) {\n console.warn(`[${this.prefix}] WARN: ${message}`, ...args);\n }\n }\n error(message, ...args) {\n if (this.level <= 3 /* ERROR */) {\n console.error(`[${this.prefix}] ERROR: ${message}`, ...args);\n }\n }\n async time(label, fn) {\n const start = performance.now();\n try {\n const result = await fn();\n const end = performance.now();\n this.debug(`${label} completed in ${(end - start).toFixed(2)}ms`);\n return result;\n } catch (_error) {\n const end = performance.now();\n this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, _error);\n throw _error;\n }\n }\n};\nfunction parseLogLevel(levelString) {\n if (!levelString)\n return void 0;\n const upper = levelString.toUpperCase();\n switch (upper) {\n case "DEBUG":\n return 0 /* DEBUG */;\n case "WARN":\n return 2 /* WARN */;\n case "ERROR":\n return 3 /* ERROR */;\n case "INFO":\n return 1 /* INFO */;\n default:\n return void 0;\n }\n}\nvar getDefaultLevel = () => {\n const envLevel = getEnvironmentVariable("LOG_LEVEL");\n const parsedLevel = parseLogLevel(envLevel);\n if (parsedLevel !== void 0)\n return parsedLevel;\n const debugFlag = getEnvironmentVariable("VERYFRONT_DEBUG");\n if (debugFlag === "1" || debugFlag === "true")\n return 0 /* DEBUG */;\n return 1 /* INFO */;\n};\nvar trackedLoggers = /* @__PURE__ */ new Set();\nfunction createLogger(prefix) {\n const logger2 = new ConsoleLogger(prefix);\n trackedLoggers.add(logger2);\n return logger2;\n}\nvar cliLogger = createLogger("CLI");\nvar serverLogger = createLogger("SERVER");\nvar rendererLogger = createLogger("RENDERER");\nvar bundlerLogger = createLogger("BUNDLER");\nvar agentLogger = createLogger("AGENT");\nvar logger = createLogger("VERYFRONT");\n\n// deno.json\nvar deno_default = {\n name: "veryfront",\n version: "0.1.0",\n nodeModulesDir: "auto",\n workspace: [\n "./examples/async-worker-redis",\n "./examples/knowledge-base",\n "./examples/form-handling",\n "./examples/middleware-demo",\n "./examples/coding-agent",\n "./examples/durable-workflows"\n ],\n exports: {\n ".": "./src/index.ts",\n "./cli": "./src/cli/main.ts",\n "./server": "./src/server/index.ts",\n "./middleware": "./src/middleware/index.ts",\n "./components": "./src/react/components/index.ts",\n "./data": "./src/data/index.ts",\n "./config": "./src/core/config/index.ts",\n "./ai": "./src/ai/index.ts",\n "./ai/client": "./src/ai/client.ts",\n "./ai/react": "./src/ai/react/index.ts",\n "./ai/primitives": "./src/ai/react/primitives/index.ts",\n "./ai/components": "./src/ai/react/components/index.ts",\n "./ai/production": "./src/ai/production/index.ts",\n "./ai/dev": "./src/ai/dev/index.ts",\n "./ai/workflow": "./src/ai/workflow/index.ts",\n "./ai/workflow/react": "./src/ai/workflow/react/index.ts"\n },\n imports: {\n "@veryfront": "./src/index.ts",\n "@veryfront/": "./src/",\n "@veryfront/ai": "./src/ai/index.ts",\n "@veryfront/ai/": "./src/ai/",\n "@veryfront/platform": "./src/platform/index.ts",\n "@veryfront/platform/": "./src/platform/",\n "@veryfront/types": "./src/core/types/index.ts",\n "@veryfront/types/": "./src/core/types/",\n "@veryfront/utils": "./src/core/utils/index.ts",\n "@veryfront/utils/": "./src/core/utils/",\n "@veryfront/middleware": "./src/middleware/index.ts",\n "@veryfront/middleware/": "./src/middleware/",\n "@veryfront/errors": "./src/core/errors/index.ts",\n "@veryfront/errors/": "./src/core/errors/",\n "@veryfront/config": "./src/core/config/index.ts",\n "@veryfront/config/": "./src/core/config/",\n "@veryfront/observability": "./src/observability/index.ts",\n "@veryfront/observability/": "./src/observability/",\n "@veryfront/routing": "./src/routing/index.ts",\n "@veryfront/routing/": "./src/routing/",\n "@veryfront/transforms": "./src/build/transforms/index.ts",\n "@veryfront/transforms/": "./src/build/transforms/",\n "@veryfront/data": "./src/data/index.ts",\n "@veryfront/data/": "./src/data/",\n "@veryfront/security": "./src/security/index.ts",\n "@veryfront/security/": "./src/security/",\n "@veryfront/components": "./src/react/components/index.ts",\n "@veryfront/react": "./src/react/index.ts",\n "@veryfront/react/": "./src/react/",\n "@veryfront/html": "./src/html/index.ts",\n "@veryfront/html/": "./src/html/",\n "@veryfront/rendering": "./src/rendering/index.ts",\n "@veryfront/rendering/": "./src/rendering/",\n "@veryfront/build": "./src/build/index.ts",\n "@veryfront/build/": "./src/build/",\n "@veryfront/server": "./src/server/index.ts",\n "@veryfront/server/": "./src/server/",\n "@veryfront/modules": "./src/module-system/index.ts",\n "@veryfront/modules/": "./src/module-system/",\n "@veryfront/compat/console": "./src/platform/compat/console/index.ts",\n "@veryfront/compat/": "./src/platform/compat/",\n "std/": "https://deno.land/std@0.220.0/",\n "@std/path": "https://deno.land/std@0.220.0/path/mod.ts",\n "@std/testing/bdd.ts": "https://deno.land/std@0.220.0/testing/bdd.ts",\n "@std/expect": "https://deno.land/std@0.220.0/expect/mod.ts",\n csstype: "https://esm.sh/csstype@3.2.3",\n "@types/react": "https://esm.sh/@types/react@18.3.27?deps=csstype@3.2.3",\n "@types/react-dom": "https://esm.sh/@types/react-dom@18.3.7?deps=csstype@3.2.3",\n react: "https://esm.sh/react@18.3.1",\n "react-dom": "https://esm.sh/react-dom@18.3.1",\n "react-dom/server": "https://esm.sh/react-dom@18.3.1/server",\n "react-dom/client": "https://esm.sh/react-dom@18.3.1/client",\n "react/jsx-runtime": "https://esm.sh/react@18.3.1/jsx-runtime",\n "react/jsx-dev-runtime": "https://esm.sh/react@18.3.1/jsx-dev-runtime",\n "@mdx-js/mdx": "https://esm.sh/@mdx-js/mdx@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "@mdx-js/react": "https://esm.sh/@mdx-js/react@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "unist-util-visit": "https://esm.sh/unist-util-visit@5.0.0",\n "mdast-util-to-string": "https://esm.sh/mdast-util-to-string@4.0.0",\n "github-slugger": "https://esm.sh/github-slugger@2.0.0",\n "remark-gfm": "https://esm.sh/remark-gfm@4.0.1",\n "remark-frontmatter": "https://esm.sh/remark-frontmatter@5.0.0",\n "rehype-highlight": "https://esm.sh/rehype-highlight@7.0.2",\n "rehype-slug": "https://esm.sh/rehype-slug@6.0.0",\n esbuild: "https://deno.land/x/esbuild@v0.20.1/wasm.js",\n "esbuild/mod.js": "https://deno.land/x/esbuild@v0.20.1/mod.js",\n "es-module-lexer": "https://esm.sh/es-module-lexer@1.5.0",\n zod: "https://esm.sh/zod@3.22.0",\n "mime-types": "https://esm.sh/mime-types@2.1.35",\n mdast: "https://esm.sh/@types/mdast@4.0.3",\n hast: "https://esm.sh/@types/hast@3.0.3",\n unist: "https://esm.sh/@types/unist@3.0.2",\n unified: "https://esm.sh/unified@11.0.5?dts",\n ai: "https://esm.sh/ai@5.0.76",\n "ai/react": "https://esm.sh/@ai-sdk/react@2.0.59",\n "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",\n "@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.4",\n unocss: "https://esm.sh/unocss@0.59.0",\n "@unocss/core": "https://esm.sh/@unocss/core@0.59.0",\n "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0"\n },\n compilerOptions: {\n jsx: "react-jsx",\n jsxImportSource: "react",\n strict: true,\n noImplicitAny: true,\n noUncheckedIndexedAccess: true,\n types: [],\n lib: [\n "deno.window",\n "dom",\n "dom.iterable",\n "dom.asynciterable",\n "deno.ns"\n ]\n },\n tasks: {\n setup: "deno run --allow-all scripts/setup.ts",\n dev: "deno run --allow-all --no-lock --unstable-net --unstable-worker-options src/cli/main.ts dev",\n build: "deno compile --allow-all --output ../../bin/veryfront src/cli/main.ts",\n "build:npm": "deno run -A scripts/build-npm.ts",\n test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",\n "test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",\n "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",\n "test:batches": "deno run --allow-all scripts/test-batches.ts",\n "test:unsafe": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net",\n "test:coverage": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:unit": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --ignore=tests --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:integration": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage tests --unstable-worker-options --unstable-net || exit 1",\n "coverage:report": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --lcov > coverage/lcov.info && deno run --allow-read scripts/check-coverage.ts 80",\n "coverage:html": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --html",\n lint: "deno lint src/",\n fmt: "deno fmt src/",\n typecheck: "deno check src/index.ts src/cli/main.ts src/server/index.ts src/routing/api/index.ts src/rendering/index.ts src/platform/index.ts src/platform/adapters/index.ts src/build/index.ts src/build/production-build/index.ts src/build/transforms/index.ts src/core/config/index.ts src/core/utils/index.ts src/data/index.ts src/security/index.ts src/middleware/index.ts src/server/handlers/dev/index.ts src/server/handlers/request/api/index.ts src/rendering/cache/index.ts src/rendering/cache/stores/index.ts src/rendering/rsc/actions/index.ts src/html/index.ts src/module-system/index.ts",\n "docs:check-links": "deno run -A scripts/check-doc-links.ts",\n "lint:ban-console": "deno run --allow-read scripts/ban-console.ts",\n "lint:ban-deep-imports": "deno run --allow-read scripts/ban-deep-imports.ts",\n "lint:ban-internal-root-imports": "deno run --allow-read scripts/ban-internal-root-imports.ts",\n "lint:check-awaits": "deno run --allow-read scripts/check-unawaited-promises.ts",\n "check:circular": "deno run -A jsr:@cunarist/deno-circular-deps src/index.ts"\n },\n lint: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n rules: {\n tags: [\n "recommended"\n ],\n include: [\n "ban-untagged-todo"\n ],\n exclude: [\n "no-explicit-any",\n "no-process-global",\n "no-console"\n ]\n }\n },\n fmt: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n options: {\n useTabs: false,\n lineWidth: 100,\n indentWidth: 2,\n semiColons: true,\n singleQuote: false,\n proseWrap: "preserve"\n }\n }\n};\n\n// src/core/utils/version.ts\nvar VERSION = typeof deno_default.version === "string" ? deno_default.version : "0.0.0";\n\n// src/core/utils/bundle-manifest.ts\nvar InMemoryBundleManifestStore = class {\n constructor() {\n this.metadata = /* @__PURE__ */ new Map();\n this.code = /* @__PURE__ */ new Map();\n this.sourceIndex = /* @__PURE__ */ new Map();\n }\n getBundleMetadata(key) {\n const entry = this.metadata.get(key);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.metadata.delete(key);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleMetadata(key, metadata, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.metadata.set(key, { value: metadata, expiry });\n if (!this.sourceIndex.has(metadata.source)) {\n this.sourceIndex.set(metadata.source, /* @__PURE__ */ new Set());\n }\n this.sourceIndex.get(metadata.source).add(key);\n return Promise.resolve();\n }\n getBundleCode(hash) {\n const entry = this.code.get(hash);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.code.delete(hash);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleCode(hash, code, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.code.set(hash, { value: code, expiry });\n return Promise.resolve();\n }\n async deleteBundle(key) {\n const metadata = await this.getBundleMetadata(key);\n this.metadata.delete(key);\n if (metadata) {\n this.code.delete(metadata.codeHash);\n const sourceKeys = this.sourceIndex.get(metadata.source);\n if (sourceKeys) {\n sourceKeys.delete(key);\n if (sourceKeys.size === 0) {\n this.sourceIndex.delete(metadata.source);\n }\n }\n }\n }\n async invalidateSource(source) {\n const keys = this.sourceIndex.get(source);\n if (!keys)\n return 0;\n let count = 0;\n for (const key of Array.from(keys)) {\n await this.deleteBundle(key);\n count++;\n }\n this.sourceIndex.delete(source);\n return count;\n }\n clear() {\n this.metadata.clear();\n this.code.clear();\n this.sourceIndex.clear();\n return Promise.resolve();\n }\n isAvailable() {\n return Promise.resolve(true);\n }\n getStats() {\n let totalSize = 0;\n let oldest;\n let newest;\n for (const { value } of this.metadata.values()) {\n totalSize += value.size;\n if (!oldest || value.compiledAt < oldest)\n oldest = value.compiledAt;\n if (!newest || value.compiledAt > newest)\n newest = value.compiledAt;\n }\n return Promise.resolve({\n totalBundles: this.metadata.size,\n totalSize,\n oldestBundle: oldest,\n newestBundle: newest\n });\n }\n};\nvar manifestStore = new InMemoryBundleManifestStore();\n\n// src/rendering/client/prefetch.ts\nvar PrefetchManager = class {\n constructor(options = {}) {\n this.prefetchedUrls = /* @__PURE__ */ new Set();\n this.linkObserver = null;\n this.options = {\n rootMargin: options.rootMargin || "50px",\n delay: options.delay || PREFETCH_DEFAULT_DELAY_MS,\n maxConcurrent: options.maxConcurrent || 2,\n allowedNetworks: options.allowedNetworks || ["4g", "wifi", "ethernet"],\n maxSize: options.maxSize || PREFETCH_MAX_SIZE_BYTES,\n timeout: options.timeout || PREFETCH_DEFAULT_TIMEOUT_MS\n };\n this.networkUtils = new NetworkUtils(this.options.allowedNetworks);\n this.resourceHintsManager = new ResourceHintsManager();\n this.prefetchQueue = new PrefetchQueue(\n {\n maxConcurrent: this.options.maxConcurrent,\n maxSize: this.options.maxSize,\n timeout: this.options.timeout\n },\n this.prefetchedUrls\n );\n this.prefetchQueue.setResourceCallback(\n (response, url) => this.prefetchPageResources(response, url)\n );\n }\n init() {\n prefetchLogger.info("Initializing prefetch manager");\n if (!this.networkUtils.shouldPrefetch()) {\n prefetchLogger.info("Prefetching disabled due to network conditions");\n return;\n }\n this.linkObserver = new LinkObserver(\n {\n rootMargin: this.options.rootMargin,\n delay: this.options.delay,\n onLinkVisible: (link) => this.prefetchQueue.prefetchLink(link)\n },\n this.prefetchedUrls\n );\n this.linkObserver.init();\n this.networkUtils.onNetworkChange(() => {\n if (!this.networkUtils.shouldPrefetch()) {\n this.prefetchQueue.stopAll();\n }\n });\n }\n async prefetchPageResources(response, _pageUrl) {\n const html = await response.text();\n const hints = this.resourceHintsManager.extractResourceHints(html, this.prefetchedUrls);\n this.resourceHintsManager.applyResourceHints(hints);\n }\n applyResourceHints(hints) {\n this.resourceHintsManager.applyResourceHints(hints);\n }\n async prefetch(url) {\n await this.prefetchQueue.prefetch(url);\n }\n static generateResourceHints(route, assets) {\n return ResourceHintsManager.generateResourceHints(route, assets);\n }\n destroy() {\n this.linkObserver?.destroy();\n this.prefetchQueue.stopAll();\n this.prefetchedUrls.clear();\n }\n};\nif (typeof window !== "undefined") {\n const prefetchManager = new PrefetchManager();\n if (document.readyState === "loading") {\n document.addEventListener("DOMContentLoaded", () => prefetchManager.init());\n } else {\n prefetchManager.init();\n }\n globalThis.veryFrontPrefetch = prefetchManager;\n}\nexport {\n PrefetchManager\n};\n';
|
|
14087
|
+
CLIENT_ROUTER_BUNDLE = 'var __defProp = Object.defineProperty;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __esm = (fn, res) => function __init() {\n return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;\n};\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\n\n// src/core/utils/runtime-guards.ts\nfunction hasDenoRuntime(global) {\n return typeof global === "object" && global !== null && "Deno" in global && typeof global.Deno?.env?.get === "function";\n}\nfunction hasNodeProcess(global) {\n return typeof global === "object" && global !== null && "process" in global && typeof global.process?.env === "object";\n}\nfunction hasBunRuntime(global) {\n return typeof global === "object" && global !== null && "Bun" in global && typeof global.Bun !== "undefined";\n}\nvar init_runtime_guards = __esm({\n "src/core/utils/runtime-guards.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/logger/env.ts\nfunction getEnvironmentVariable(name) {\n try {\n if (typeof Deno !== "undefined" && hasDenoRuntime(globalThis)) {\n const value = globalThis.Deno?.env.get(name);\n return value === "" ? void 0 : value;\n }\n if (hasNodeProcess(globalThis)) {\n const value = globalThis.process?.env[name];\n return value === "" ? void 0 : value;\n }\n } catch {\n return void 0;\n }\n return void 0;\n}\nfunction isTestEnvironment() {\n return getEnvironmentVariable("NODE_ENV") === "test";\n}\nfunction isProductionEnvironment() {\n return getEnvironmentVariable("NODE_ENV") === "production";\n}\nfunction isDevelopmentEnvironment() {\n const env = getEnvironmentVariable("NODE_ENV");\n return env === "development" || env === void 0;\n}\nvar init_env = __esm({\n "src/core/utils/logger/env.ts"() {\n "use strict";\n init_runtime_guards();\n }\n});\n\n// src/core/utils/logger/logger.ts\nfunction resolveLogLevel(force = false) {\n if (force || cachedLogLevel === void 0) {\n cachedLogLevel = getDefaultLevel();\n }\n return cachedLogLevel;\n}\nfunction parseLogLevel(levelString) {\n if (!levelString)\n return void 0;\n const upper = levelString.toUpperCase();\n switch (upper) {\n case "DEBUG":\n return 0 /* DEBUG */;\n case "WARN":\n return 2 /* WARN */;\n case "ERROR":\n return 3 /* ERROR */;\n case "INFO":\n return 1 /* INFO */;\n default:\n return void 0;\n }\n}\nfunction createLogger(prefix) {\n const logger2 = new ConsoleLogger(prefix);\n trackedLoggers.add(logger2);\n return logger2;\n}\nfunction __loggerResetForTests(options = {}) {\n const updatedLevel = resolveLogLevel(true);\n for (const instance of trackedLoggers) {\n instance.setLevel(updatedLevel);\n }\n if (options.restoreConsole) {\n console.debug = originalConsole.debug;\n console.log = originalConsole.log;\n console.warn = originalConsole.warn;\n console.error = originalConsole.error;\n }\n}\nvar LogLevel, originalConsole, cachedLogLevel, ConsoleLogger, getDefaultLevel, trackedLoggers, cliLogger, serverLogger, rendererLogger, bundlerLogger, agentLogger, logger;\nvar init_logger = __esm({\n "src/core/utils/logger/logger.ts"() {\n "use strict";\n init_env();\n LogLevel = /* @__PURE__ */ ((LogLevel2) => {\n LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";\n LogLevel2[LogLevel2["INFO"] = 1] = "INFO";\n LogLevel2[LogLevel2["WARN"] = 2] = "WARN";\n LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";\n return LogLevel2;\n })(LogLevel || {});\n originalConsole = {\n debug: console.debug,\n log: console.log,\n warn: console.warn,\n error: console.error\n };\n ConsoleLogger = class {\n constructor(prefix, level = resolveLogLevel()) {\n this.prefix = prefix;\n this.level = level;\n }\n setLevel(level) {\n this.level = level;\n }\n getLevel() {\n return this.level;\n }\n debug(message, ...args) {\n if (this.level <= 0 /* DEBUG */) {\n console.debug(`[${this.prefix}] DEBUG: ${message}`, ...args);\n }\n }\n info(message, ...args) {\n if (this.level <= 1 /* INFO */) {\n console.log(`[${this.prefix}] ${message}`, ...args);\n }\n }\n warn(message, ...args) {\n if (this.level <= 2 /* WARN */) {\n console.warn(`[${this.prefix}] WARN: ${message}`, ...args);\n }\n }\n error(message, ...args) {\n if (this.level <= 3 /* ERROR */) {\n console.error(`[${this.prefix}] ERROR: ${message}`, ...args);\n }\n }\n async time(label, fn) {\n const start = performance.now();\n try {\n const result = await fn();\n const end = performance.now();\n this.debug(`${label} completed in ${(end - start).toFixed(2)}ms`);\n return result;\n } catch (error2) {\n const end = performance.now();\n this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, error2);\n throw error2;\n }\n }\n };\n getDefaultLevel = () => {\n const envLevel = getEnvironmentVariable("LOG_LEVEL");\n const parsedLevel = parseLogLevel(envLevel);\n if (parsedLevel !== void 0)\n return parsedLevel;\n const debugFlag = getEnvironmentVariable("VERYFRONT_DEBUG");\n if (debugFlag === "1" || debugFlag === "true")\n return 0 /* DEBUG */;\n return 1 /* INFO */;\n };\n trackedLoggers = /* @__PURE__ */ new Set();\n cliLogger = createLogger("CLI");\n serverLogger = createLogger("SERVER");\n rendererLogger = createLogger("RENDERER");\n bundlerLogger = createLogger("BUNDLER");\n agentLogger = createLogger("AGENT");\n logger = createLogger("VERYFRONT");\n }\n});\n\n// src/core/utils/logger/index.ts\nvar init_logger2 = __esm({\n "src/core/utils/logger/index.ts"() {\n "use strict";\n init_logger();\n init_env();\n }\n});\n\n// src/core/utils/constants/build.ts\nvar DEFAULT_BUILD_CONCURRENCY, IMAGE_OPTIMIZATION;\nvar init_build = __esm({\n "src/core/utils/constants/build.ts"() {\n "use strict";\n DEFAULT_BUILD_CONCURRENCY = 4;\n IMAGE_OPTIMIZATION = {\n DEFAULT_SIZES: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],\n DEFAULT_QUALITY: 80\n };\n }\n});\n\n// src/core/utils/constants/cache.ts\nvar SECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, MS_PER_SECOND, DEFAULT_LRU_MAX_ENTRIES, COMPONENT_LOADER_MAX_ENTRIES, COMPONENT_LOADER_TTL_MS, MDX_RENDERER_MAX_ENTRIES, MDX_RENDERER_TTL_MS, RENDERER_CORE_MAX_ENTRIES, RENDERER_CORE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_TTL_MS, DATA_FETCHING_MAX_ENTRIES, DATA_FETCHING_TTL_MS, MDX_CACHE_TTL_PRODUCTION_MS, MDX_CACHE_TTL_DEVELOPMENT_MS, BUNDLE_CACHE_TTL_PRODUCTION_MS, BUNDLE_CACHE_TTL_DEVELOPMENT_MS, BUNDLE_MANIFEST_PROD_TTL_MS, BUNDLE_MANIFEST_DEV_TTL_MS, RSC_MANIFEST_CACHE_TTL_MS, SERVER_ACTION_DEFAULT_TTL_SEC, DENO_KV_SAFE_SIZE_LIMIT_BYTES, HTTP_CACHE_SHORT_MAX_AGE_SEC, HTTP_CACHE_MEDIUM_MAX_AGE_SEC, HTTP_CACHE_LONG_MAX_AGE_SEC, ONE_DAY_MS, CACHE_CLEANUP_INTERVAL_MS, LRU_DEFAULT_MAX_ENTRIES, LRU_DEFAULT_MAX_SIZE_BYTES, CLEANUP_INTERVAL_MULTIPLIER;\nvar init_cache = __esm({\n "src/core/utils/constants/cache.ts"() {\n "use strict";\n SECONDS_PER_MINUTE = 60;\n MINUTES_PER_HOUR = 60;\n HOURS_PER_DAY = 24;\n MS_PER_SECOND = 1e3;\n DEFAULT_LRU_MAX_ENTRIES = 100;\n COMPONENT_LOADER_MAX_ENTRIES = 100;\n COMPONENT_LOADER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\n MDX_RENDERER_MAX_ENTRIES = 200;\n MDX_RENDERER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\n RENDERER_CORE_MAX_ENTRIES = 100;\n RENDERER_CORE_TTL_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;\n TSX_LAYOUT_MAX_ENTRIES = 50;\n TSX_LAYOUT_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\n DATA_FETCHING_MAX_ENTRIES = 200;\n DATA_FETCHING_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\n MDX_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n MDX_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;\n BUNDLE_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;\n BUNDLE_MANIFEST_PROD_TTL_MS = 7 * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n BUNDLE_MANIFEST_DEV_TTL_MS = MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n RSC_MANIFEST_CACHE_TTL_MS = 5e3;\n SERVER_ACTION_DEFAULT_TTL_SEC = MINUTES_PER_HOUR * SECONDS_PER_MINUTE;\n DENO_KV_SAFE_SIZE_LIMIT_BYTES = 64e3;\n HTTP_CACHE_SHORT_MAX_AGE_SEC = 60;\n HTTP_CACHE_MEDIUM_MAX_AGE_SEC = 3600;\n HTTP_CACHE_LONG_MAX_AGE_SEC = 31536e3;\n ONE_DAY_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\n CACHE_CLEANUP_INTERVAL_MS = 6e4;\n LRU_DEFAULT_MAX_ENTRIES = 1e3;\n LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;\n CLEANUP_INTERVAL_MULTIPLIER = 2;\n }\n});\n\n// src/core/utils/constants/cdn.ts\nfunction getReactCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react@${version}`;\n}\nfunction getReactDOMCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react-dom@${version}`;\n}\nfunction getReactDOMClientCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react-dom@${version}/client`;\n}\nfunction getReactDOMServerCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react-dom@${version}/server`;\n}\nfunction getReactJSXRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react@${version}/jsx-runtime`;\n}\nfunction getReactJSXDevRuntimeCDNUrl(version = REACT_DEFAULT_VERSION) {\n return `${ESM_CDN_BASE}/react@${version}/jsx-dev-runtime`;\n}\nfunction getReactImportMap(version = REACT_DEFAULT_VERSION) {\n return {\n react: getReactCDNUrl(version),\n "react-dom": getReactDOMCDNUrl(version),\n "react-dom/client": getReactDOMClientCDNUrl(version),\n "react-dom/server": getReactDOMServerCDNUrl(version),\n "react/jsx-runtime": getReactJSXRuntimeCDNUrl(version),\n "react/jsx-dev-runtime": getReactJSXDevRuntimeCDNUrl(version)\n };\n}\nfunction getDenoStdNodeBase() {\n return `${DENO_STD_BASE}/std@${DENO_STD_VERSION}/node`;\n}\nfunction getUnoCSSTailwindResetUrl() {\n return `${ESM_CDN_BASE}/@unocss/reset@${UNOCSS_VERSION}/tailwind.css`;\n}\nvar ESM_CDN_BASE, JSDELIVR_CDN_BASE, DENO_STD_BASE, REACT_VERSION_17, REACT_VERSION_18_2, REACT_VERSION_18_3, REACT_VERSION_19_RC, REACT_VERSION_19, REACT_DEFAULT_VERSION, DEFAULT_ALLOWED_CDN_HOSTS, DENO_STD_VERSION, UNOCSS_VERSION;\nvar init_cdn = __esm({\n "src/core/utils/constants/cdn.ts"() {\n "use strict";\n ESM_CDN_BASE = "https://esm.sh";\n JSDELIVR_CDN_BASE = "https://cdn.jsdelivr.net";\n DENO_STD_BASE = "https://deno.land";\n REACT_VERSION_17 = "17.0.2";\n REACT_VERSION_18_2 = "18.2.0";\n REACT_VERSION_18_3 = "18.3.1";\n REACT_VERSION_19_RC = "19.0.0-rc.0";\n REACT_VERSION_19 = "19.1.1";\n REACT_DEFAULT_VERSION = REACT_VERSION_18_3;\n DEFAULT_ALLOWED_CDN_HOSTS = [ESM_CDN_BASE, DENO_STD_BASE];\n DENO_STD_VERSION = "0.220.0";\n UNOCSS_VERSION = "0.59.0";\n }\n});\n\n// src/core/utils/constants/hash.ts\nvar HASH_SEED_DJB2, HASH_SEED_FNV1A;\nvar init_hash = __esm({\n "src/core/utils/constants/hash.ts"() {\n "use strict";\n HASH_SEED_DJB2 = 5381;\n HASH_SEED_FNV1A = 2166136261;\n }\n});\n\n// src/core/utils/constants/http.ts\nvar KB_IN_BYTES, HTTP_MODULE_FETCH_TIMEOUT_MS, HMR_RECONNECT_DELAY_MS, HMR_RELOAD_DELAY_MS, HMR_FILE_WATCHER_DEBOUNCE_MS, HMR_KEEP_ALIVE_INTERVAL_MS, DASHBOARD_RECONNECT_DELAY_MS, SERVER_FUNCTION_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_DEFAULT_DELAY_MS, HTTP_OK, HTTP_NO_CONTENT, HTTP_CREATED, HTTP_REDIRECT_FOUND, HTTP_NOT_MODIFIED, HTTP_BAD_REQUEST, HTTP_UNAUTHORIZED, HTTP_FORBIDDEN, HTTP_NOT_FOUND, HTTP_METHOD_NOT_ALLOWED, HTTP_GONE, HTTP_PAYLOAD_TOO_LARGE, HTTP_URI_TOO_LONG, HTTP_TOO_MANY_REQUESTS, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE, HTTP_SERVER_ERROR, HTTP_INTERNAL_SERVER_ERROR, HTTP_BAD_GATEWAY, HTTP_NOT_IMPLEMENTED, HTTP_UNAVAILABLE, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_STATUS_SUCCESS_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_CONTENT_TYPES, MS_PER_MINUTE, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPE_IMAGE_AVIF, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO;\nvar init_http = __esm({\n "src/core/utils/constants/http.ts"() {\n "use strict";\n init_cache();\n KB_IN_BYTES = 1024;\n HTTP_MODULE_FETCH_TIMEOUT_MS = 2500;\n HMR_RECONNECT_DELAY_MS = 1e3;\n HMR_RELOAD_DELAY_MS = 1e3;\n HMR_FILE_WATCHER_DEBOUNCE_MS = 100;\n HMR_KEEP_ALIVE_INTERVAL_MS = 3e4;\n DASHBOARD_RECONNECT_DELAY_MS = 3e3;\n SERVER_FUNCTION_DEFAULT_TIMEOUT_MS = 3e4;\n PREFETCH_MAX_SIZE_BYTES = 200 * KB_IN_BYTES;\n PREFETCH_DEFAULT_TIMEOUT_MS = 1e4;\n PREFETCH_DEFAULT_DELAY_MS = 200;\n HTTP_OK = 200;\n HTTP_NO_CONTENT = 204;\n HTTP_CREATED = 201;\n HTTP_REDIRECT_FOUND = 302;\n HTTP_NOT_MODIFIED = 304;\n HTTP_BAD_REQUEST = 400;\n HTTP_UNAUTHORIZED = 401;\n HTTP_FORBIDDEN = 403;\n HTTP_NOT_FOUND = 404;\n HTTP_METHOD_NOT_ALLOWED = 405;\n HTTP_GONE = 410;\n HTTP_PAYLOAD_TOO_LARGE = 413;\n HTTP_URI_TOO_LONG = 414;\n HTTP_TOO_MANY_REQUESTS = 429;\n HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;\n HTTP_SERVER_ERROR = 500;\n HTTP_INTERNAL_SERVER_ERROR = 500;\n HTTP_BAD_GATEWAY = 502;\n HTTP_NOT_IMPLEMENTED = 501;\n HTTP_UNAVAILABLE = 503;\n HTTP_NETWORK_CONNECT_TIMEOUT = 599;\n HTTP_STATUS_SUCCESS_MIN = 200;\n HTTP_STATUS_REDIRECT_MIN = 300;\n HTTP_STATUS_CLIENT_ERROR_MIN = 400;\n HTTP_STATUS_SERVER_ERROR_MIN = 500;\n HTTP_CONTENT_TYPES = {\n JS: "application/javascript; charset=utf-8",\n JSON: "application/json; charset=utf-8",\n HTML: "text/html; charset=utf-8",\n CSS: "text/css; charset=utf-8",\n TEXT: "text/plain; charset=utf-8"\n };\n MS_PER_MINUTE = 6e4;\n HTTP_CONTENT_TYPE_IMAGE_PNG = "image/png";\n HTTP_CONTENT_TYPE_IMAGE_JPEG = "image/jpeg";\n HTTP_CONTENT_TYPE_IMAGE_WEBP = "image/webp";\n HTTP_CONTENT_TYPE_IMAGE_AVIF = "image/avif";\n HTTP_CONTENT_TYPE_IMAGE_SVG = "image/svg+xml";\n HTTP_CONTENT_TYPE_IMAGE_GIF = "image/gif";\n HTTP_CONTENT_TYPE_IMAGE_ICO = "image/x-icon";\n }\n});\n\n// src/core/utils/constants/hmr.ts\nfunction isValidHMRMessageType(type) {\n return Object.values(HMR_MESSAGE_TYPES).includes(\n type\n );\n}\nvar HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_CLIENT_RELOAD_DELAY_MS, HMR_PORT_OFFSET, HMR_RATE_LIMIT_WINDOW_MS, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_MESSAGE_TYPES;\nvar init_hmr = __esm({\n "src/core/utils/constants/hmr.ts"() {\n "use strict";\n init_http();\n HMR_MAX_MESSAGE_SIZE_BYTES = 1024 * KB_IN_BYTES;\n HMR_MAX_MESSAGES_PER_MINUTE = 100;\n HMR_CLIENT_RELOAD_DELAY_MS = 3e3;\n HMR_PORT_OFFSET = 1;\n HMR_RATE_LIMIT_WINDOW_MS = 6e4;\n HMR_CLOSE_NORMAL = 1e3;\n HMR_CLOSE_RATE_LIMIT = 1008;\n HMR_CLOSE_MESSAGE_TOO_LARGE = 1009;\n HMR_MESSAGE_TYPES = {\n CONNECTED: "connected",\n UPDATE: "update",\n RELOAD: "reload",\n PING: "ping",\n PONG: "pong"\n };\n }\n});\n\n// src/core/utils/constants/html.ts\nvar Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, BREAKPOINT_SM, BREAKPOINT_MD, BREAKPOINT_LG, BREAKPOINT_XL, PROSE_MAX_WIDTH;\nvar init_html = __esm({\n "src/core/utils/constants/html.ts"() {\n "use strict";\n Z_INDEX_DEV_INDICATOR = 9998;\n Z_INDEX_ERROR_OVERLAY = 9999;\n BREAKPOINT_SM = 640;\n BREAKPOINT_MD = 768;\n BREAKPOINT_LG = 1024;\n BREAKPOINT_XL = 1280;\n PROSE_MAX_WIDTH = "65ch";\n }\n});\n\n// src/core/utils/constants/network.ts\nvar DEFAULT_DEV_SERVER_PORT, DEFAULT_REDIS_PORT, DEFAULT_API_SERVER_PORT, DEFAULT_PREVIEW_SERVER_PORT, DEFAULT_METRICS_PORT, BYTES_PER_KB, BYTES_PER_MB, DEFAULT_IMAGE_THUMBNAIL_SIZE, DEFAULT_IMAGE_SMALL_SIZE, DEFAULT_IMAGE_LARGE_SIZE, RESPONSIVE_IMAGE_WIDTH_XS, RESPONSIVE_IMAGE_WIDTH_SM, RESPONSIVE_IMAGE_WIDTH_MD, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, MAX_CHUNK_SIZE_KB, MIN_PORT, MAX_PORT, DEFAULT_SERVER_PORT;\nvar init_network = __esm({\n "src/core/utils/constants/network.ts"() {\n "use strict";\n DEFAULT_DEV_SERVER_PORT = 3e3;\n DEFAULT_REDIS_PORT = 6379;\n DEFAULT_API_SERVER_PORT = 8080;\n DEFAULT_PREVIEW_SERVER_PORT = 5e3;\n DEFAULT_METRICS_PORT = 9e3;\n BYTES_PER_KB = 1024;\n BYTES_PER_MB = 1024 * 1024;\n DEFAULT_IMAGE_THUMBNAIL_SIZE = 256;\n DEFAULT_IMAGE_SMALL_SIZE = 512;\n DEFAULT_IMAGE_LARGE_SIZE = 2048;\n RESPONSIVE_IMAGE_WIDTH_XS = 320;\n RESPONSIVE_IMAGE_WIDTH_SM = 640;\n RESPONSIVE_IMAGE_WIDTH_MD = 1024;\n RESPONSIVE_IMAGE_WIDTH_LG = 1920;\n RESPONSIVE_IMAGE_WIDTHS = [\n RESPONSIVE_IMAGE_WIDTH_XS,\n RESPONSIVE_IMAGE_WIDTH_SM,\n RESPONSIVE_IMAGE_WIDTH_MD,\n RESPONSIVE_IMAGE_WIDTH_LG\n ];\n MAX_CHUNK_SIZE_KB = 4096;\n MIN_PORT = 1;\n MAX_PORT = 65535;\n DEFAULT_SERVER_PORT = 8e3;\n }\n});\n\n// src/core/utils/constants/security.ts\nvar MAX_PATH_TRAVERSAL_DEPTH, FORBIDDEN_PATH_PATTERNS, DIRECTORY_TRAVERSAL_PATTERN, ABSOLUTE_PATH_PATTERN, MAX_PATH_LENGTH, DEFAULT_MAX_STRING_LENGTH;\nvar init_security = __esm({\n "src/core/utils/constants/security.ts"() {\n "use strict";\n MAX_PATH_TRAVERSAL_DEPTH = 10;\n FORBIDDEN_PATH_PATTERNS = [\n /\\0/\n // Null bytes\n ];\n DIRECTORY_TRAVERSAL_PATTERN = /\\.\\.[\\/\\\\]/;\n ABSOLUTE_PATH_PATTERN = /^[\\/\\\\]/;\n MAX_PATH_LENGTH = 4096;\n DEFAULT_MAX_STRING_LENGTH = 1e3;\n }\n});\n\n// src/core/utils/constants/server.ts\nvar DEFAULT_DASHBOARD_PORT, DEV_SERVER_ENDPOINTS;\nvar init_server = __esm({\n "src/core/utils/constants/server.ts"() {\n "use strict";\n DEFAULT_DASHBOARD_PORT = 3002;\n DEV_SERVER_ENDPOINTS = {\n HMR_RUNTIME: "/_veryfront/hmr-runtime.js",\n ERROR_OVERLAY: "/_veryfront/error-overlay.js"\n };\n }\n});\n\n// src/core/utils/constants/index.ts\nvar init_constants = __esm({\n "src/core/utils/constants/index.ts"() {\n "use strict";\n init_build();\n init_cache();\n init_cdn();\n init_hash();\n init_hmr();\n init_html();\n init_http();\n init_network();\n init_security();\n init_server();\n }\n});\n\n// deno.json\nvar deno_default;\nvar init_deno = __esm({\n "deno.json"() {\n deno_default = {\n name: "veryfront",\n version: "0.0.6",\n nodeModulesDir: "auto",\n workspace: [\n "./examples/async-worker-redis",\n "./examples/knowledge-base",\n "./examples/form-handling",\n "./examples/middleware-demo",\n "./examples/coding-agent",\n "./examples/durable-workflows"\n ],\n exports: {\n ".": "./src/index.ts",\n "./cli": "./src/cli/main.ts",\n "./server": "./src/server/index.ts",\n "./middleware": "./src/middleware/index.ts",\n "./components": "./src/react/components/index.ts",\n "./data": "./src/data/index.ts",\n "./config": "./src/core/config/index.ts",\n "./ai": "./src/ai/index.ts",\n "./ai/client": "./src/ai/client.ts",\n "./ai/react": "./src/ai/react/index.ts",\n "./ai/primitives": "./src/ai/react/primitives/index.ts",\n "./ai/components": "./src/ai/react/components/index.ts",\n "./ai/production": "./src/ai/production/index.ts",\n "./ai/dev": "./src/ai/dev/index.ts",\n "./ai/workflow": "./src/ai/workflow/index.ts",\n "./ai/workflow/react": "./src/ai/workflow/react/index.ts"\n },\n imports: {\n "@veryfront": "./src/index.ts",\n "@veryfront/": "./src/",\n "@veryfront/ai": "./src/ai/index.ts",\n "@veryfront/ai/": "./src/ai/",\n "@veryfront/platform": "./src/platform/index.ts",\n "@veryfront/platform/": "./src/platform/",\n "@veryfront/types": "./src/core/types/index.ts",\n "@veryfront/types/": "./src/core/types/",\n "@veryfront/utils": "./src/core/utils/index.ts",\n "@veryfront/utils/": "./src/core/utils/",\n "@veryfront/middleware": "./src/middleware/index.ts",\n "@veryfront/middleware/": "./src/middleware/",\n "@veryfront/errors": "./src/core/errors/index.ts",\n "@veryfront/errors/": "./src/core/errors/",\n "@veryfront/config": "./src/core/config/index.ts",\n "@veryfront/config/": "./src/core/config/",\n "@veryfront/observability": "./src/observability/index.ts",\n "@veryfront/observability/": "./src/observability/",\n "@veryfront/routing": "./src/routing/index.ts",\n "@veryfront/routing/": "./src/routing/",\n "@veryfront/transforms": "./src/build/transforms/index.ts",\n "@veryfront/transforms/": "./src/build/transforms/",\n "@veryfront/data": "./src/data/index.ts",\n "@veryfront/data/": "./src/data/",\n "@veryfront/security": "./src/security/index.ts",\n "@veryfront/security/": "./src/security/",\n "@veryfront/components": "./src/react/components/index.ts",\n "@veryfront/react": "./src/react/index.ts",\n "@veryfront/react/": "./src/react/",\n "@veryfront/html": "./src/html/index.ts",\n "@veryfront/html/": "./src/html/",\n "@veryfront/rendering": "./src/rendering/index.ts",\n "@veryfront/rendering/": "./src/rendering/",\n "@veryfront/build": "./src/build/index.ts",\n "@veryfront/build/": "./src/build/",\n "@veryfront/server": "./src/server/index.ts",\n "@veryfront/server/": "./src/server/",\n "@veryfront/modules": "./src/module-system/index.ts",\n "@veryfront/modules/": "./src/module-system/",\n "@veryfront/compat/console": "./src/platform/compat/console/index.ts",\n "@veryfront/compat/": "./src/platform/compat/",\n "std/": "https://deno.land/std@0.220.0/",\n "@std/path": "https://deno.land/std@0.220.0/path/mod.ts",\n "@std/testing/bdd.ts": "https://deno.land/std@0.220.0/testing/bdd.ts",\n "@std/expect": "https://deno.land/std@0.220.0/expect/mod.ts",\n csstype: "https://esm.sh/csstype@3.2.3",\n "@types/react": "https://esm.sh/@types/react@18.3.27?deps=csstype@3.2.3",\n "@types/react-dom": "https://esm.sh/@types/react-dom@18.3.7?deps=csstype@3.2.3",\n react: "https://esm.sh/react@18.3.1",\n "react-dom": "https://esm.sh/react-dom@18.3.1",\n "react-dom/server": "https://esm.sh/react-dom@18.3.1/server",\n "react-dom/client": "https://esm.sh/react-dom@18.3.1/client",\n "react/jsx-runtime": "https://esm.sh/react@18.3.1/jsx-runtime",\n "react/jsx-dev-runtime": "https://esm.sh/react@18.3.1/jsx-dev-runtime",\n "@mdx-js/mdx": "https://esm.sh/@mdx-js/mdx@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "@mdx-js/react": "https://esm.sh/@mdx-js/react@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "unist-util-visit": "https://esm.sh/unist-util-visit@5.0.0",\n "mdast-util-to-string": "https://esm.sh/mdast-util-to-string@4.0.0",\n "github-slugger": "https://esm.sh/github-slugger@2.0.0",\n "remark-gfm": "https://esm.sh/remark-gfm@4.0.1",\n "remark-frontmatter": "https://esm.sh/remark-frontmatter@5.0.0",\n "rehype-highlight": "https://esm.sh/rehype-highlight@7.0.2",\n "rehype-slug": "https://esm.sh/rehype-slug@6.0.0",\n esbuild: "https://deno.land/x/esbuild@v0.20.1/wasm.js",\n "esbuild/mod.js": "https://deno.land/x/esbuild@v0.20.1/mod.js",\n "es-module-lexer": "https://esm.sh/es-module-lexer@1.5.0",\n zod: "https://esm.sh/zod@3.22.0",\n "mime-types": "https://esm.sh/mime-types@2.1.35",\n mdast: "https://esm.sh/@types/mdast@4.0.3",\n hast: "https://esm.sh/@types/hast@3.0.3",\n unist: "https://esm.sh/@types/unist@3.0.2",\n unified: "https://esm.sh/unified@11.0.5?dts",\n ai: "https://esm.sh/ai@5.0.76",\n "ai/react": "https://esm.sh/@ai-sdk/react@2.0.59",\n "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",\n "@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.4",\n unocss: "https://esm.sh/unocss@0.59.0",\n "@unocss/core": "https://esm.sh/@unocss/core@0.59.0",\n "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0"\n },\n compilerOptions: {\n jsx: "react-jsx",\n jsxImportSource: "react",\n strict: true,\n noImplicitAny: true,\n noUncheckedIndexedAccess: true,\n types: [],\n lib: [\n "deno.window",\n "dom",\n "dom.iterable",\n "dom.asynciterable",\n "deno.ns"\n ]\n },\n tasks: {\n setup: "deno run --allow-all scripts/setup.ts",\n dev: "deno run --allow-all --no-lock --unstable-net --unstable-worker-options src/cli/main.ts dev",\n build: "deno compile --allow-all --output ../../bin/veryfront src/cli/main.ts",\n "build:npm": "deno run -A scripts/build-npm.ts",\n test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",\n "test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",\n "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",\n "test:batches": "deno run --allow-all scripts/test-batches.ts",\n "test:unsafe": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net",\n "test:coverage": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:unit": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --ignore=tests --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:integration": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage tests --unstable-worker-options --unstable-net || exit 1",\n "coverage:report": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --lcov > coverage/lcov.info && deno run --allow-read scripts/check-coverage.ts 80",\n "coverage:html": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --html",\n lint: "deno lint src/",\n fmt: "deno fmt src/",\n typecheck: "deno check src/index.ts src/cli/main.ts src/server/index.ts src/routing/api/index.ts src/rendering/index.ts src/platform/index.ts src/platform/adapters/index.ts src/build/index.ts src/build/production-build/index.ts src/build/transforms/index.ts src/core/config/index.ts src/core/utils/index.ts src/data/index.ts src/security/index.ts src/middleware/index.ts src/server/handlers/dev/index.ts src/server/handlers/request/api/index.ts src/rendering/cache/index.ts src/rendering/cache/stores/index.ts src/rendering/rsc/actions/index.ts src/html/index.ts src/module-system/index.ts",\n "docs:check-links": "deno run -A scripts/check-doc-links.ts",\n "lint:ban-console": "deno run --allow-read scripts/ban-console.ts",\n "lint:ban-deep-imports": "deno run --allow-read scripts/ban-deep-imports.ts",\n "lint:ban-internal-root-imports": "deno run --allow-read scripts/ban-internal-root-imports.ts",\n "lint:check-awaits": "deno run --allow-read scripts/check-unawaited-promises.ts",\n "check:circular": "deno run -A jsr:@cunarist/deno-circular-deps src/index.ts"\n },\n lint: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n rules: {\n tags: [\n "recommended"\n ],\n include: [\n "ban-untagged-todo"\n ],\n exclude: [\n "no-explicit-any",\n "no-process-global",\n "no-console"\n ]\n }\n },\n fmt: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n options: {\n useTabs: false,\n lineWidth: 100,\n indentWidth: 2,\n semiColons: true,\n singleQuote: false,\n proseWrap: "preserve"\n }\n }\n };\n }\n});\n\n// src/core/utils/version.ts\nvar VERSION;\nvar init_version = __esm({\n "src/core/utils/version.ts"() {\n "use strict";\n init_deno();\n VERSION = typeof deno_default.version === "string" ? deno_default.version : "0.0.0";\n }\n});\n\n// src/core/utils/paths.ts\nvar PATHS, VERYFRONT_PATHS, FILE_EXTENSIONS;\nvar init_paths = __esm({\n "src/core/utils/paths.ts"() {\n "use strict";\n PATHS = {\n PAGES_DIR: "pages",\n COMPONENTS_DIR: "components",\n PUBLIC_DIR: "public",\n STYLES_DIR: "styles",\n DIST_DIR: "dist",\n CONFIG_FILE: "veryfront.config.js"\n };\n VERYFRONT_PATHS = {\n INTERNAL_PREFIX: "/_veryfront",\n BUILD_DIR: "_veryfront",\n CHUNKS_DIR: "_veryfront/chunks",\n DATA_DIR: "_veryfront/data",\n ASSETS_DIR: "_veryfront/assets",\n HMR_RUNTIME: "/_veryfront/hmr-runtime.js",\n CLIENT_JS: "/_veryfront/client.js",\n ROUTER_JS: "/_veryfront/router.js",\n ERROR_OVERLAY: "/_veryfront/error-overlay.js"\n };\n FILE_EXTENSIONS = {\n MDX: [".mdx", ".md"],\n SCRIPT: [".tsx", ".ts", ".jsx", ".js"],\n STYLE: [".css", ".scss", ".sass"],\n ALL: [".mdx", ".md", ".tsx", ".ts", ".jsx", ".js", ".css"]\n };\n }\n});\n\n// src/core/utils/hash-utils.ts\nasync function computeHash(content) {\n const encoder = new TextEncoder();\n const data = encoder.encode(content);\n const hashBuffer = await crypto.subtle.digest("SHA-256", data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");\n}\nfunction getContentHash(content) {\n return computeHash(content);\n}\nfunction computeContentHash(content) {\n return computeHash(content);\n}\nfunction computeCodeHash(code) {\n const combined = code.code + (code.css || "") + (code.sourceMap || "");\n return computeHash(combined);\n}\nfunction simpleHash(str) {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return Math.abs(hash);\n}\nasync function shortHash(content) {\n const fullHash = await computeHash(content);\n return fullHash.slice(0, 8);\n}\nvar init_hash_utils = __esm({\n "src/core/utils/hash-utils.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/memoize.ts\nfunction memoizeAsync(fn, keyHasher) {\n const cache = new MemoCache();\n return async (...args) => {\n const key = keyHasher(...args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = await fn(...args);\n cache.set(key, result);\n return result;\n };\n}\nfunction memoize(fn, keyHasher) {\n const cache = new MemoCache();\n return (...args) => {\n const key = keyHasher(...args);\n if (cache.has(key)) {\n return cache.get(key);\n }\n const result = fn(...args);\n cache.set(key, result);\n return result;\n };\n}\nfunction simpleHash2(...values) {\n const FNV_OFFSET_BASIS = 2166136261;\n const FNV_PRIME = 16777619;\n let hash = FNV_OFFSET_BASIS;\n for (const value of values) {\n const str = typeof value === "string" ? value : String(value);\n for (let i = 0; i < str.length; i++) {\n hash ^= str.charCodeAt(i);\n hash = Math.imul(hash, FNV_PRIME);\n }\n }\n return (hash >>> 0).toString(36);\n}\nvar MemoCache;\nvar init_memoize = __esm({\n "src/core/utils/memoize.ts"() {\n "use strict";\n MemoCache = class {\n constructor() {\n this.cache = /* @__PURE__ */ new Map();\n }\n get(key) {\n return this.cache.get(key);\n }\n set(key, value) {\n this.cache.set(key, value);\n }\n has(key) {\n return this.cache.has(key);\n }\n clear() {\n this.cache.clear();\n }\n size() {\n return this.cache.size;\n }\n };\n }\n});\n\n// src/core/utils/path-utils.ts\nfunction normalizePath(pathname) {\n pathname = pathname.replace(/\\\\+/g, "/").replace(/\\/\\.+\\//g, "/");\n if (pathname !== "/" && pathname.endsWith("/")) {\n pathname = pathname.slice(0, -1);\n }\n return pathname;\n}\nfunction joinPath(a, b) {\n return `${a.replace(/\\/$/, "")}/${b.replace(/^\\//, "")}`;\n}\nfunction isWithinDirectory(root, target) {\n const normalizedRoot = normalizePath(root);\n const normalizedTarget = normalizePath(target);\n return normalizedTarget.startsWith(`${normalizedRoot}/`) || normalizedTarget === normalizedRoot;\n}\nfunction getExtension(path) {\n const lastDot = path.lastIndexOf(".");\n if (lastDot === -1 || lastDot === path.length - 1) {\n return "";\n }\n return path.slice(lastDot);\n}\nfunction getDirectory(path) {\n const normalized = normalizePath(path);\n const lastSlash = normalized.lastIndexOf("/");\n return lastSlash <= 0 ? "/" : normalized.slice(0, lastSlash);\n}\nfunction hasHashedFilename(path) {\n return /\\.[a-f0-9]{8,}\\./.test(path);\n}\nfunction isAbsolutePath(path) {\n return path.startsWith("/") || /^[A-Za-z]:[\\\\/]/.test(path);\n}\nfunction toBase64Url(s) {\n const b64 = btoa(s);\n return b64.replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");\n}\nfunction fromBase64Url(encoded) {\n const b64 = encoded.replaceAll("-", "+").replaceAll("_", "/");\n const pad = b64.length % 4 === 2 ? "==" : b64.length % 4 === 3 ? "=" : "";\n try {\n return atob(b64 + pad);\n } catch (error2) {\n logger.debug(`Failed to decode base64url string "${encoded}":`, error2);\n return "";\n }\n}\nvar init_path_utils = __esm({\n "src/core/utils/path-utils.ts"() {\n "use strict";\n init_logger();\n }\n});\n\n// src/core/utils/format-utils.ts\nfunction formatBytes(bytes) {\n if (bytes === 0)\n return "0 Bytes";\n const absBytes = Math.abs(bytes);\n if (absBytes < 1) {\n return `${absBytes} Bytes`;\n }\n const k = 1024;\n const sizes = ["Bytes", "KB", "MB", "GB", "TB"];\n const i = Math.floor(Math.log(absBytes) / Math.log(k));\n const index = Math.max(0, Math.min(i, sizes.length - 1));\n return `${parseFloat((absBytes / Math.pow(k, index)).toFixed(2))} ${sizes[index]}`;\n}\nfunction estimateSize(value) {\n if (value === null || value === void 0)\n return 8;\n switch (typeof value) {\n case "boolean":\n return 4;\n case "number":\n return 8;\n case "string":\n return value.length * 2;\n case "function":\n return 0;\n case "object":\n return estimateObjectSize(value);\n default:\n return 32;\n }\n}\nfunction estimateSizeWithCircularHandling(value) {\n const seen = /* @__PURE__ */ new WeakSet();\n const encoder = new TextEncoder();\n const json3 = JSON.stringify(value, (_key, val) => {\n if (typeof val === "object" && val !== null) {\n if (seen.has(val))\n return void 0;\n seen.add(val);\n if (val instanceof Map) {\n return { __type: "Map", entries: Array.from(val.entries()) };\n }\n if (val instanceof Set) {\n return { __type: "Set", values: Array.from(val.values()) };\n }\n }\n if (typeof val === "function")\n return void 0;\n if (val instanceof Uint8Array) {\n return { __type: "Uint8Array", length: val.length };\n }\n return val;\n });\n return encoder.encode(json3 ?? "").length;\n}\nfunction estimateObjectSize(value) {\n if (value instanceof ArrayBuffer)\n return value.byteLength;\n if (value instanceof Uint8Array || value instanceof Uint16Array || value instanceof Uint32Array || value instanceof Int8Array || value instanceof Int16Array || value instanceof Int32Array) {\n return value.byteLength;\n }\n try {\n return JSON.stringify(value).length * 2;\n } catch (error2) {\n logger.debug("Failed to estimate size of non-serializable object:", error2);\n return 1024;\n }\n}\nfunction formatDuration(ms) {\n if (ms < 1e3)\n return `${ms}ms`;\n if (ms < 6e4)\n return `${(ms / 1e3).toFixed(1)}s`;\n if (ms < 36e5)\n return `${Math.floor(ms / 6e4)}m ${Math.floor(ms % 6e4 / 1e3)}s`;\n return `${Math.floor(ms / 36e5)}h ${Math.floor(ms % 36e5 / 6e4)}m`;\n}\nfunction formatNumber(num) {\n return num.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g, ",");\n}\nfunction truncateString(str, maxLength) {\n if (str.length <= maxLength)\n return str;\n return str.slice(0, maxLength - 3) + "...";\n}\nvar init_format_utils = __esm({\n "src/core/utils/format-utils.ts"() {\n "use strict";\n init_logger();\n }\n});\n\n// src/core/utils/bundle-manifest.ts\nfunction setBundleManifestStore(store) {\n manifestStore = store;\n serverLogger.info("[bundle-manifest] Bundle manifest store configured", {\n type: store.constructor.name\n });\n}\nfunction getBundleManifestStore() {\n return manifestStore;\n}\nvar InMemoryBundleManifestStore, manifestStore;\nvar init_bundle_manifest = __esm({\n "src/core/utils/bundle-manifest.ts"() {\n "use strict";\n init_logger2();\n init_hash_utils();\n InMemoryBundleManifestStore = class {\n constructor() {\n this.metadata = /* @__PURE__ */ new Map();\n this.code = /* @__PURE__ */ new Map();\n this.sourceIndex = /* @__PURE__ */ new Map();\n }\n getBundleMetadata(key) {\n const entry = this.metadata.get(key);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.metadata.delete(key);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleMetadata(key, metadata, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.metadata.set(key, { value: metadata, expiry });\n if (!this.sourceIndex.has(metadata.source)) {\n this.sourceIndex.set(metadata.source, /* @__PURE__ */ new Set());\n }\n this.sourceIndex.get(metadata.source).add(key);\n return Promise.resolve();\n }\n getBundleCode(hash) {\n const entry = this.code.get(hash);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.code.delete(hash);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleCode(hash, code, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.code.set(hash, { value: code, expiry });\n return Promise.resolve();\n }\n async deleteBundle(key) {\n const metadata = await this.getBundleMetadata(key);\n this.metadata.delete(key);\n if (metadata) {\n this.code.delete(metadata.codeHash);\n const sourceKeys = this.sourceIndex.get(metadata.source);\n if (sourceKeys) {\n sourceKeys.delete(key);\n if (sourceKeys.size === 0) {\n this.sourceIndex.delete(metadata.source);\n }\n }\n }\n }\n async invalidateSource(source) {\n const keys = this.sourceIndex.get(source);\n if (!keys)\n return 0;\n let count = 0;\n for (const key of Array.from(keys)) {\n await this.deleteBundle(key);\n count++;\n }\n this.sourceIndex.delete(source);\n return count;\n }\n clear() {\n this.metadata.clear();\n this.code.clear();\n this.sourceIndex.clear();\n return Promise.resolve();\n }\n isAvailable() {\n return Promise.resolve(true);\n }\n getStats() {\n let totalSize = 0;\n let oldest;\n let newest;\n for (const { value } of this.metadata.values()) {\n totalSize += value.size;\n if (!oldest || value.compiledAt < oldest)\n oldest = value.compiledAt;\n if (!newest || value.compiledAt > newest)\n newest = value.compiledAt;\n }\n return Promise.resolve({\n totalBundles: this.metadata.size,\n totalSize,\n oldestBundle: oldest,\n newestBundle: newest\n });\n }\n };\n manifestStore = new InMemoryBundleManifestStore();\n }\n});\n\n// src/core/utils/bundle-manifest-init.ts\nasync function initializeBundleManifest(config, mode, adapter) {\n const manifestConfig = config.cache?.bundleManifest;\n const enabled = manifestConfig?.enabled ?? mode === "production";\n if (!enabled) {\n serverLogger.info("[bundle-manifest] Bundle manifest disabled");\n setBundleManifestStore(new InMemoryBundleManifestStore());\n return;\n }\n const envType = adapter?.env.get("VERYFRONT_BUNDLE_MANIFEST_TYPE");\n const storeType = manifestConfig?.type || envType || "memory";\n serverLogger.info("[bundle-manifest] Initializing bundle manifest", {\n type: storeType,\n mode\n });\n try {\n let store;\n switch (storeType) {\n case "redis": {\n const { RedisBundleManifestStore } = await import("./bundle-manifest-redis.ts");\n const redisUrl = manifestConfig?.redisUrl || adapter?.env.get("VERYFRONT_BUNDLE_MANIFEST_REDIS_URL");\n store = new RedisBundleManifestStore(\n {\n url: redisUrl,\n keyPrefix: manifestConfig?.keyPrefix\n },\n adapter\n );\n const available = await store.isAvailable();\n if (!available) {\n serverLogger.warn("[bundle-manifest] Redis not available, falling back to in-memory");\n store = new InMemoryBundleManifestStore();\n } else {\n serverLogger.info("[bundle-manifest] Redis store initialized");\n }\n break;\n }\n case "kv": {\n const { KVBundleManifestStore } = await import("./bundle-manifest-kv.ts");\n store = new KVBundleManifestStore({\n keyPrefix: manifestConfig?.keyPrefix\n });\n const available = await store.isAvailable();\n if (!available) {\n serverLogger.warn("[bundle-manifest] KV not available, falling back to in-memory");\n store = new InMemoryBundleManifestStore();\n } else {\n serverLogger.info("[bundle-manifest] KV store initialized");\n }\n break;\n }\n case "memory":\n default: {\n store = new InMemoryBundleManifestStore();\n serverLogger.info("[bundle-manifest] In-memory store initialized");\n break;\n }\n }\n setBundleManifestStore(store);\n try {\n const stats = await store.getStats();\n serverLogger.info("[bundle-manifest] Store statistics", stats);\n } catch (error2) {\n serverLogger.debug("[bundle-manifest] Failed to get stats", { error: error2 });\n }\n } catch (error2) {\n serverLogger.error("[bundle-manifest] Failed to initialize store, using in-memory fallback", {\n error: error2\n });\n setBundleManifestStore(new InMemoryBundleManifestStore());\n }\n}\nfunction getBundleManifestTTL(config, mode) {\n const manifestConfig = config.cache?.bundleManifest;\n if (manifestConfig?.ttl) {\n return manifestConfig.ttl;\n }\n if (mode === "production") {\n return BUNDLE_MANIFEST_PROD_TTL_MS;\n } else {\n return BUNDLE_MANIFEST_DEV_TTL_MS;\n }\n}\nasync function warmupBundleManifest(store, keys) {\n serverLogger.info("[bundle-manifest] Warming up cache", { keys: keys.length });\n let loaded = 0;\n let failed = 0;\n for (const key of keys) {\n try {\n const metadata = await store.getBundleMetadata(key);\n if (metadata) {\n await store.getBundleCode(metadata.codeHash);\n loaded++;\n }\n } catch (error2) {\n serverLogger.debug("[bundle-manifest] Failed to warm up key", { key, error: error2 });\n failed++;\n }\n }\n serverLogger.info("[bundle-manifest] Cache warmup complete", { loaded, failed });\n}\nvar init_bundle_manifest_init = __esm({\n "src/core/utils/bundle-manifest-init.ts"() {\n "use strict";\n init_logger2();\n init_bundle_manifest();\n init_cache();\n }\n});\n\n// src/core/utils/feature-flags.ts\nfunction isRSCEnabled(config) {\n if (config?.experimental?.rsc !== void 0) {\n return config.experimental.rsc;\n }\n if (typeof Deno !== "undefined" && Deno.env) {\n return Deno.env.get("VERYFRONT_EXPERIMENTAL_RSC") === "1";\n }\n if (typeof process !== "undefined" && process?.env) {\n return process.env.VERYFRONT_EXPERIMENTAL_RSC === "1";\n }\n return false;\n}\nvar init_feature_flags = __esm({\n "src/core/utils/feature-flags.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/platform.ts\nfunction isCompiledBinary() {\n const hasDeno = typeof Deno !== "undefined";\n const hasExecPath = hasDeno && typeof Deno.execPath === "function";\n if (!hasExecPath)\n return false;\n try {\n const execPath = Deno.execPath();\n return execPath.includes("veryfront");\n } catch {\n return false;\n }\n}\nvar init_platform = __esm({\n "src/core/utils/platform.ts"() {\n "use strict";\n }\n});\n\n// src/core/utils/index.ts\nvar utils_exports = {};\n__export(utils_exports, {\n ABSOLUTE_PATH_PATTERN: () => ABSOLUTE_PATH_PATTERN,\n BREAKPOINT_LG: () => BREAKPOINT_LG,\n BREAKPOINT_MD: () => BREAKPOINT_MD,\n BREAKPOINT_SM: () => BREAKPOINT_SM,\n BREAKPOINT_XL: () => BREAKPOINT_XL,\n BUNDLE_CACHE_TTL_DEVELOPMENT_MS: () => BUNDLE_CACHE_TTL_DEVELOPMENT_MS,\n BUNDLE_CACHE_TTL_PRODUCTION_MS: () => BUNDLE_CACHE_TTL_PRODUCTION_MS,\n BUNDLE_MANIFEST_DEV_TTL_MS: () => BUNDLE_MANIFEST_DEV_TTL_MS,\n BUNDLE_MANIFEST_PROD_TTL_MS: () => BUNDLE_MANIFEST_PROD_TTL_MS,\n BYTES_PER_KB: () => BYTES_PER_KB,\n BYTES_PER_MB: () => BYTES_PER_MB,\n CACHE_CLEANUP_INTERVAL_MS: () => CACHE_CLEANUP_INTERVAL_MS,\n CLEANUP_INTERVAL_MULTIPLIER: () => CLEANUP_INTERVAL_MULTIPLIER,\n COMPONENT_LOADER_MAX_ENTRIES: () => COMPONENT_LOADER_MAX_ENTRIES,\n COMPONENT_LOADER_TTL_MS: () => COMPONENT_LOADER_TTL_MS,\n DASHBOARD_RECONNECT_DELAY_MS: () => DASHBOARD_RECONNECT_DELAY_MS,\n DATA_FETCHING_MAX_ENTRIES: () => DATA_FETCHING_MAX_ENTRIES,\n DATA_FETCHING_TTL_MS: () => DATA_FETCHING_TTL_MS,\n DEFAULT_ALLOWED_CDN_HOSTS: () => DEFAULT_ALLOWED_CDN_HOSTS,\n DEFAULT_API_SERVER_PORT: () => DEFAULT_API_SERVER_PORT,\n DEFAULT_BUILD_CONCURRENCY: () => DEFAULT_BUILD_CONCURRENCY,\n DEFAULT_DASHBOARD_PORT: () => DEFAULT_DASHBOARD_PORT,\n DEFAULT_DEV_SERVER_PORT: () => DEFAULT_DEV_SERVER_PORT,\n DEFAULT_IMAGE_LARGE_SIZE: () => DEFAULT_IMAGE_LARGE_SIZE,\n DEFAULT_IMAGE_SMALL_SIZE: () => DEFAULT_IMAGE_SMALL_SIZE,\n DEFAULT_IMAGE_THUMBNAIL_SIZE: () => DEFAULT_IMAGE_THUMBNAIL_SIZE,\n DEFAULT_LRU_MAX_ENTRIES: () => DEFAULT_LRU_MAX_ENTRIES,\n DEFAULT_MAX_STRING_LENGTH: () => DEFAULT_MAX_STRING_LENGTH,\n DEFAULT_METRICS_PORT: () => DEFAULT_METRICS_PORT,\n DEFAULT_PREVIEW_SERVER_PORT: () => DEFAULT_PREVIEW_SERVER_PORT,\n DEFAULT_REDIS_PORT: () => DEFAULT_REDIS_PORT,\n DEFAULT_SERVER_PORT: () => DEFAULT_SERVER_PORT,\n DENO_KV_SAFE_SIZE_LIMIT_BYTES: () => DENO_KV_SAFE_SIZE_LIMIT_BYTES,\n DENO_STD_BASE: () => DENO_STD_BASE,\n DENO_STD_VERSION: () => DENO_STD_VERSION,\n DEV_SERVER_ENDPOINTS: () => DEV_SERVER_ENDPOINTS,\n DIRECTORY_TRAVERSAL_PATTERN: () => DIRECTORY_TRAVERSAL_PATTERN,\n ESM_CDN_BASE: () => ESM_CDN_BASE,\n FILE_EXTENSIONS: () => FILE_EXTENSIONS,\n FORBIDDEN_PATH_PATTERNS: () => FORBIDDEN_PATH_PATTERNS,\n HASH_SEED_DJB2: () => HASH_SEED_DJB2,\n HASH_SEED_FNV1A: () => HASH_SEED_FNV1A,\n HMR_CLIENT_RELOAD_DELAY_MS: () => HMR_CLIENT_RELOAD_DELAY_MS,\n HMR_CLOSE_MESSAGE_TOO_LARGE: () => HMR_CLOSE_MESSAGE_TOO_LARGE,\n HMR_CLOSE_NORMAL: () => HMR_CLOSE_NORMAL,\n HMR_CLOSE_RATE_LIMIT: () => HMR_CLOSE_RATE_LIMIT,\n HMR_FILE_WATCHER_DEBOUNCE_MS: () => HMR_FILE_WATCHER_DEBOUNCE_MS,\n HMR_KEEP_ALIVE_INTERVAL_MS: () => HMR_KEEP_ALIVE_INTERVAL_MS,\n HMR_MAX_MESSAGES_PER_MINUTE: () => HMR_MAX_MESSAGES_PER_MINUTE,\n HMR_MAX_MESSAGE_SIZE_BYTES: () => HMR_MAX_MESSAGE_SIZE_BYTES,\n HMR_MESSAGE_TYPES: () => HMR_MESSAGE_TYPES,\n HMR_PORT_OFFSET: () => HMR_PORT_OFFSET,\n HMR_RATE_LIMIT_WINDOW_MS: () => HMR_RATE_LIMIT_WINDOW_MS,\n HMR_RECONNECT_DELAY_MS: () => HMR_RECONNECT_DELAY_MS,\n HMR_RELOAD_DELAY_MS: () => HMR_RELOAD_DELAY_MS,\n HOURS_PER_DAY: () => HOURS_PER_DAY,\n HTTP_BAD_GATEWAY: () => HTTP_BAD_GATEWAY,\n HTTP_BAD_REQUEST: () => HTTP_BAD_REQUEST,\n HTTP_CACHE_LONG_MAX_AGE_SEC: () => HTTP_CACHE_LONG_MAX_AGE_SEC,\n HTTP_CACHE_MEDIUM_MAX_AGE_SEC: () => HTTP_CACHE_MEDIUM_MAX_AGE_SEC,\n HTTP_CACHE_SHORT_MAX_AGE_SEC: () => HTTP_CACHE_SHORT_MAX_AGE_SEC,\n HTTP_CONTENT_TYPES: () => HTTP_CONTENT_TYPES,\n HTTP_CONTENT_TYPE_IMAGE_AVIF: () => HTTP_CONTENT_TYPE_IMAGE_AVIF,\n HTTP_CONTENT_TYPE_IMAGE_GIF: () => HTTP_CONTENT_TYPE_IMAGE_GIF,\n HTTP_CONTENT_TYPE_IMAGE_ICO: () => HTTP_CONTENT_TYPE_IMAGE_ICO,\n HTTP_CONTENT_TYPE_IMAGE_JPEG: () => HTTP_CONTENT_TYPE_IMAGE_JPEG,\n HTTP_CONTENT_TYPE_IMAGE_PNG: () => HTTP_CONTENT_TYPE_IMAGE_PNG,\n HTTP_CONTENT_TYPE_IMAGE_SVG: () => HTTP_CONTENT_TYPE_IMAGE_SVG,\n HTTP_CONTENT_TYPE_IMAGE_WEBP: () => HTTP_CONTENT_TYPE_IMAGE_WEBP,\n HTTP_CREATED: () => HTTP_CREATED,\n HTTP_FORBIDDEN: () => HTTP_FORBIDDEN,\n HTTP_GONE: () => HTTP_GONE,\n HTTP_INTERNAL_SERVER_ERROR: () => HTTP_INTERNAL_SERVER_ERROR,\n HTTP_METHOD_NOT_ALLOWED: () => HTTP_METHOD_NOT_ALLOWED,\n HTTP_MODULE_FETCH_TIMEOUT_MS: () => HTTP_MODULE_FETCH_TIMEOUT_MS,\n HTTP_NETWORK_CONNECT_TIMEOUT: () => HTTP_NETWORK_CONNECT_TIMEOUT,\n HTTP_NOT_FOUND: () => HTTP_NOT_FOUND,\n HTTP_NOT_IMPLEMENTED: () => HTTP_NOT_IMPLEMENTED,\n HTTP_NOT_MODIFIED: () => HTTP_NOT_MODIFIED,\n HTTP_NO_CONTENT: () => HTTP_NO_CONTENT,\n HTTP_OK: () => HTTP_OK,\n HTTP_PAYLOAD_TOO_LARGE: () => HTTP_PAYLOAD_TOO_LARGE,\n HTTP_REDIRECT_FOUND: () => HTTP_REDIRECT_FOUND,\n HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE: () => HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE,\n HTTP_SERVER_ERROR: () => HTTP_SERVER_ERROR,\n HTTP_STATUS_CLIENT_ERROR_MIN: () => HTTP_STATUS_CLIENT_ERROR_MIN,\n HTTP_STATUS_REDIRECT_MIN: () => HTTP_STATUS_REDIRECT_MIN,\n HTTP_STATUS_SERVER_ERROR_MIN: () => HTTP_STATUS_SERVER_ERROR_MIN,\n HTTP_STATUS_SUCCESS_MIN: () => HTTP_STATUS_SUCCESS_MIN,\n HTTP_TOO_MANY_REQUESTS: () => HTTP_TOO_MANY_REQUESTS,\n HTTP_UNAUTHORIZED: () => HTTP_UNAUTHORIZED,\n HTTP_UNAVAILABLE: () => HTTP_UNAVAILABLE,\n HTTP_URI_TOO_LONG: () => HTTP_URI_TOO_LONG,\n IMAGE_OPTIMIZATION: () => IMAGE_OPTIMIZATION,\n InMemoryBundleManifestStore: () => InMemoryBundleManifestStore,\n JSDELIVR_CDN_BASE: () => JSDELIVR_CDN_BASE,\n KB_IN_BYTES: () => KB_IN_BYTES,\n LRU_DEFAULT_MAX_ENTRIES: () => LRU_DEFAULT_MAX_ENTRIES,\n LRU_DEFAULT_MAX_SIZE_BYTES: () => LRU_DEFAULT_MAX_SIZE_BYTES,\n LogLevel: () => LogLevel,\n MAX_CHUNK_SIZE_KB: () => MAX_CHUNK_SIZE_KB,\n MAX_PATH_LENGTH: () => MAX_PATH_LENGTH,\n MAX_PATH_TRAVERSAL_DEPTH: () => MAX_PATH_TRAVERSAL_DEPTH,\n MAX_PORT: () => MAX_PORT,\n MDX_CACHE_TTL_DEVELOPMENT_MS: () => MDX_CACHE_TTL_DEVELOPMENT_MS,\n MDX_CACHE_TTL_PRODUCTION_MS: () => MDX_CACHE_TTL_PRODUCTION_MS,\n MDX_RENDERER_MAX_ENTRIES: () => MDX_RENDERER_MAX_ENTRIES,\n MDX_RENDERER_TTL_MS: () => MDX_RENDERER_TTL_MS,\n MINUTES_PER_HOUR: () => MINUTES_PER_HOUR,\n MIN_PORT: () => MIN_PORT,\n MS_PER_MINUTE: () => MS_PER_MINUTE,\n MS_PER_SECOND: () => MS_PER_SECOND,\n MemoCache: () => MemoCache,\n ONE_DAY_MS: () => ONE_DAY_MS,\n PATHS: () => PATHS,\n PREFETCH_DEFAULT_DELAY_MS: () => PREFETCH_DEFAULT_DELAY_MS,\n PREFETCH_DEFAULT_TIMEOUT_MS: () => PREFETCH_DEFAULT_TIMEOUT_MS,\n PREFETCH_MAX_SIZE_BYTES: () => PREFETCH_MAX_SIZE_BYTES,\n PROSE_MAX_WIDTH: () => PROSE_MAX_WIDTH,\n REACT_DEFAULT_VERSION: () => REACT_DEFAULT_VERSION,\n REACT_VERSION_17: () => REACT_VERSION_17,\n REACT_VERSION_18_2: () => REACT_VERSION_18_2,\n REACT_VERSION_18_3: () => REACT_VERSION_18_3,\n REACT_VERSION_19: () => REACT_VERSION_19,\n REACT_VERSION_19_RC: () => REACT_VERSION_19_RC,\n RENDERER_CORE_MAX_ENTRIES: () => RENDERER_CORE_MAX_ENTRIES,\n RENDERER_CORE_TTL_MS: () => RENDERER_CORE_TTL_MS,\n RESPONSIVE_IMAGE_WIDTHS: () => RESPONSIVE_IMAGE_WIDTHS,\n RESPONSIVE_IMAGE_WIDTH_LG: () => RESPONSIVE_IMAGE_WIDTH_LG,\n RESPONSIVE_IMAGE_WIDTH_MD: () => RESPONSIVE_IMAGE_WIDTH_MD,\n RESPONSIVE_IMAGE_WIDTH_SM: () => RESPONSIVE_IMAGE_WIDTH_SM,\n RESPONSIVE_IMAGE_WIDTH_XS: () => RESPONSIVE_IMAGE_WIDTH_XS,\n RSC_MANIFEST_CACHE_TTL_MS: () => RSC_MANIFEST_CACHE_TTL_MS,\n SECONDS_PER_MINUTE: () => SECONDS_PER_MINUTE,\n SERVER_ACTION_DEFAULT_TTL_SEC: () => SERVER_ACTION_DEFAULT_TTL_SEC,\n SERVER_FUNCTION_DEFAULT_TIMEOUT_MS: () => SERVER_FUNCTION_DEFAULT_TIMEOUT_MS,\n TSX_LAYOUT_MAX_ENTRIES: () => TSX_LAYOUT_MAX_ENTRIES,\n TSX_LAYOUT_TTL_MS: () => TSX_LAYOUT_TTL_MS,\n UNOCSS_VERSION: () => UNOCSS_VERSION,\n VERSION: () => VERSION,\n VERYFRONT_PATHS: () => VERYFRONT_PATHS,\n Z_INDEX_DEV_INDICATOR: () => Z_INDEX_DEV_INDICATOR,\n Z_INDEX_ERROR_OVERLAY: () => Z_INDEX_ERROR_OVERLAY,\n __loggerResetForTests: () => __loggerResetForTests,\n agentLogger: () => agentLogger,\n bundlerLogger: () => bundlerLogger,\n cliLogger: () => cliLogger,\n computeCodeHash: () => computeCodeHash,\n computeContentHash: () => computeContentHash,\n computeHash: () => computeHash,\n estimateSize: () => estimateSize,\n estimateSizeWithCircularHandling: () => estimateSizeWithCircularHandling,\n formatBytes: () => formatBytes,\n formatDuration: () => formatDuration,\n formatNumber: () => formatNumber,\n fromBase64Url: () => fromBase64Url,\n getBundleManifestStore: () => getBundleManifestStore,\n getBundleManifestTTL: () => getBundleManifestTTL,\n getContentHash: () => getContentHash,\n getDenoStdNodeBase: () => getDenoStdNodeBase,\n getDirectory: () => getDirectory,\n getEnvironmentVariable: () => getEnvironmentVariable,\n getExtension: () => getExtension,\n getReactCDNUrl: () => getReactCDNUrl,\n getReactDOMCDNUrl: () => getReactDOMCDNUrl,\n getReactDOMClientCDNUrl: () => getReactDOMClientCDNUrl,\n getReactDOMServerCDNUrl: () => getReactDOMServerCDNUrl,\n getReactImportMap: () => getReactImportMap,\n getReactJSXDevRuntimeCDNUrl: () => getReactJSXDevRuntimeCDNUrl,\n getReactJSXRuntimeCDNUrl: () => getReactJSXRuntimeCDNUrl,\n getUnoCSSTailwindResetUrl: () => getUnoCSSTailwindResetUrl,\n hasBunRuntime: () => hasBunRuntime,\n hasDenoRuntime: () => hasDenoRuntime,\n hasHashedFilename: () => hasHashedFilename,\n hasNodeProcess: () => hasNodeProcess,\n initializeBundleManifest: () => initializeBundleManifest,\n isAbsolutePath: () => isAbsolutePath,\n isCompiledBinary: () => isCompiledBinary,\n isDevelopmentEnvironment: () => isDevelopmentEnvironment,\n isProductionEnvironment: () => isProductionEnvironment,\n isRSCEnabled: () => isRSCEnabled,\n isTestEnvironment: () => isTestEnvironment,\n isValidHMRMessageType: () => isValidHMRMessageType,\n isWithinDirectory: () => isWithinDirectory,\n joinPath: () => joinPath,\n logger: () => logger,\n memoize: () => memoize,\n memoizeAsync: () => memoizeAsync,\n memoizeHash: () => simpleHash2,\n normalizePath: () => normalizePath,\n numericHash: () => simpleHash,\n rendererLogger: () => rendererLogger,\n serverLogger: () => serverLogger,\n setBundleManifestStore: () => setBundleManifestStore,\n shortHash: () => shortHash,\n simpleHash: () => simpleHash,\n toBase64Url: () => toBase64Url,\n truncateString: () => truncateString,\n warmupBundleManifest: () => warmupBundleManifest\n});\nvar init_utils = __esm({\n "src/core/utils/index.ts"() {\n init_runtime_guards();\n init_logger2();\n init_constants();\n init_version();\n init_paths();\n init_hash_utils();\n init_memoize();\n init_path_utils();\n init_format_utils();\n init_bundle_manifest();\n init_bundle_manifest_init();\n init_feature_flags();\n init_platform();\n }\n});\n\n// src/core/errors/veryfront-error.ts\nfunction createError(error2) {\n return error2;\n}\nfunction toError(veryfrontError) {\n const error2 = new Error(veryfrontError.message);\n error2.name = `VeryfrontError[${veryfrontError.type}]`;\n Object.defineProperty(error2, "context", {\n value: veryfrontError,\n enumerable: false,\n configurable: true\n });\n return error2;\n}\nvar init_veryfront_error = __esm({\n "src/core/errors/veryfront-error.ts"() {\n "use strict";\n }\n});\n\n// src/core/config/schema.ts\nimport { z } from "zod";\nvar corsSchema, veryfrontConfigSchema;\nvar init_schema = __esm({\n "src/core/config/schema.ts"() {\n "use strict";\n init_veryfront_error();\n corsSchema = z.union([z.boolean(), z.object({ origin: z.string().optional() }).strict()]);\n veryfrontConfigSchema = z.object({\n title: z.string().optional(),\n description: z.string().optional(),\n experimental: z.object({\n esmLayouts: z.boolean().optional(),\n precompileMDX: z.boolean().optional()\n }).partial().optional(),\n router: z.enum(["app", "pages"]).optional(),\n defaultLayout: z.string().optional(),\n theme: z.object({ colors: z.record(z.string()).optional() }).partial().optional(),\n build: z.object({\n outDir: z.string().optional(),\n trailingSlash: z.boolean().optional(),\n esbuild: z.object({\n wasmURL: z.string().url().optional(),\n worker: z.boolean().optional()\n }).partial().optional()\n }).partial().optional(),\n cache: z.object({\n dir: z.string().optional(),\n bundleManifest: z.object({\n type: z.enum(["redis", "kv", "memory"]).optional(),\n redisUrl: z.string().optional(),\n keyPrefix: z.string().optional(),\n ttl: z.number().int().positive().optional(),\n enabled: z.boolean().optional()\n }).partial().optional()\n }).partial().optional(),\n dev: z.object({\n port: z.number().int().positive().optional(),\n host: z.string().optional(),\n open: z.boolean().optional(),\n hmr: z.boolean().optional(),\n components: z.array(z.string()).optional()\n }).partial().optional(),\n resolve: z.object({\n importMap: z.object({\n imports: z.record(z.string()).optional(),\n scopes: z.record(z.record(z.string())).optional()\n }).partial().optional()\n }).partial().optional(),\n security: z.object({\n csp: z.record(z.array(z.string())).optional(),\n remoteHosts: z.array(z.string().url()).optional(),\n cors: corsSchema.optional(),\n coop: z.enum(["same-origin", "same-origin-allow-popups", "unsafe-none"]).optional(),\n corp: z.enum(["same-origin", "same-site", "cross-origin"]).optional(),\n coep: z.enum(["require-corp", "unsafe-none"]).optional()\n }).partial().optional(),\n middleware: z.object({\n custom: z.array(z.function()).optional()\n }).partial().optional(),\n theming: z.object({\n brandName: z.string().optional(),\n logoHtml: z.string().optional()\n }).partial().optional(),\n assetPipeline: z.object({\n images: z.object({\n enabled: z.boolean().optional(),\n formats: z.array(z.enum(["webp", "avif", "jpeg", "png"])).optional(),\n sizes: z.array(z.number().int().positive()).optional(),\n quality: z.number().int().min(1).max(100).optional(),\n inputDir: z.string().optional(),\n outputDir: z.string().optional(),\n preserveOriginal: z.boolean().optional()\n }).partial().optional(),\n css: z.object({\n enabled: z.boolean().optional(),\n minify: z.boolean().optional(),\n autoprefixer: z.boolean().optional(),\n purge: z.boolean().optional(),\n criticalCSS: z.boolean().optional(),\n inputDir: z.string().optional(),\n outputDir: z.string().optional(),\n browsers: z.array(z.string()).optional(),\n purgeContent: z.array(z.string()).optional(),\n sourceMap: z.boolean().optional()\n }).partial().optional()\n }).partial().optional(),\n observability: z.object({\n tracing: z.object({\n enabled: z.boolean().optional(),\n exporter: z.enum(["jaeger", "zipkin", "otlp", "console"]).optional(),\n endpoint: z.string().optional(),\n serviceName: z.string().optional(),\n sampleRate: z.number().min(0).max(1).optional()\n }).partial().optional(),\n metrics: z.object({\n enabled: z.boolean().optional(),\n exporter: z.enum(["prometheus", "otlp", "console"]).optional(),\n endpoint: z.string().optional(),\n prefix: z.string().optional(),\n collectInterval: z.number().int().positive().optional()\n }).partial().optional()\n }).partial().optional(),\n fs: z.object({\n type: z.enum(["local", "veryfront-api", "memory"]).optional(),\n local: z.object({\n baseDir: z.string().optional()\n }).partial().optional(),\n veryfront: z.object({\n apiBaseUrl: z.string().url(),\n apiToken: z.string(),\n projectSlug: z.string(),\n cache: z.object({\n enabled: z.boolean().optional(),\n ttl: z.number().int().positive().optional(),\n maxSize: z.number().int().positive().optional()\n }).partial().optional(),\n retry: z.object({\n maxRetries: z.number().int().min(0).optional(),\n initialDelay: z.number().int().positive().optional(),\n maxDelay: z.number().int().positive().optional()\n }).partial().optional()\n }).partial().optional(),\n memory: z.object({\n files: z.record(z.union([z.string(), z.instanceof(Uint8Array)])).optional()\n }).partial().optional()\n }).partial().optional()\n }).partial();\n }\n});\n\n// src/_shims/std-path.ts\nimport * as nodeUrl from "node:url";\nimport * as nodePath from "node:path";\nvar init_std_path = __esm({\n "src/_shims/std-path.ts"() {\n }\n});\n\n// src/core/config/loader.ts\nfunction getDefaultImportMapForConfig() {\n return { imports: getReactImportMap(REACT_DEFAULT_VERSION) };\n}\nvar DEFAULT_CONFIG;\nvar init_loader = __esm({\n "src/core/config/loader.ts"() {\n "use strict";\n init_schema();\n init_std_path();\n init_logger();\n init_cdn();\n DEFAULT_CONFIG = {\n title: "Veryfront App",\n description: "Built with Veryfront",\n experimental: {\n esmLayouts: true\n },\n router: void 0,\n defaultLayout: void 0,\n theme: {\n colors: {\n primary: "#3B82F6"\n }\n },\n build: {\n outDir: "dist",\n trailingSlash: false,\n esbuild: {\n wasmURL: "https://deno.land/x/esbuild@v0.20.1/esbuild.wasm",\n worker: false\n }\n },\n cache: {\n dir: ".veryfront/cache",\n render: {\n type: "memory",\n ttl: void 0,\n maxEntries: 500,\n kvPath: void 0,\n redisUrl: void 0,\n redisKeyPrefix: void 0\n }\n },\n dev: {\n port: 3002,\n host: "localhost",\n open: false\n },\n resolve: {\n importMap: getDefaultImportMapForConfig()\n }\n };\n }\n});\n\n// src/core/config/define-config.ts\nvar init_define_config = __esm({\n "src/core/config/define-config.ts"() {\n "use strict";\n init_veryfront_error();\n }\n});\n\n// src/core/config/defaults.ts\nvar DEFAULT_DEV_PORT, DEFAULT_PREFETCH_DELAY_MS, DURATION_HISTOGRAM_BOUNDARIES_MS, SIZE_HISTOGRAM_BOUNDARIES_KB, PAGE_TRANSITION_DELAY_MS;\nvar init_defaults = __esm({\n "src/core/config/defaults.ts"() {\n "use strict";\n DEFAULT_DEV_PORT = 3e3;\n DEFAULT_PREFETCH_DELAY_MS = 100;\n DURATION_HISTOGRAM_BOUNDARIES_MS = [\n 5,\n 10,\n 25,\n 50,\n 75,\n 100,\n 250,\n 500,\n 750,\n 1e3,\n 2500,\n 5e3,\n 7500,\n 1e4\n ];\n SIZE_HISTOGRAM_BOUNDARIES_KB = [\n 1,\n 5,\n 10,\n 25,\n 50,\n 100,\n 250,\n 500,\n 1e3,\n 2500,\n 5e3,\n 1e4\n ];\n PAGE_TRANSITION_DELAY_MS = 150;\n }\n});\n\n// src/core/config/network-defaults.ts\nvar init_network_defaults = __esm({\n "src/core/config/network-defaults.ts"() {\n "use strict";\n }\n});\n\n// src/core/config/index.ts\nvar init_config = __esm({\n "src/core/config/index.ts"() {\n init_loader();\n init_define_config();\n init_schema();\n init_defaults();\n init_network_defaults();\n }\n});\n\n// src/core/errors/types.ts\nvar VeryfrontError;\nvar init_types = __esm({\n "src/core/errors/types.ts"() {\n "use strict";\n VeryfrontError = class extends Error {\n constructor(message, code, context) {\n super(message);\n this.name = "VeryfrontError";\n this.code = code;\n this.context = context;\n }\n };\n }\n});\n\n// src/core/errors/agent-errors.ts\nvar init_agent_errors = __esm({\n "src/core/errors/agent-errors.ts"() {\n "use strict";\n init_types();\n }\n});\n\n// src/core/errors/build-errors.ts\nvar init_build_errors = __esm({\n "src/core/errors/build-errors.ts"() {\n "use strict";\n init_types();\n }\n});\n\n// src/core/errors/runtime-errors.ts\nvar init_runtime_errors = __esm({\n "src/core/errors/runtime-errors.ts"() {\n "use strict";\n init_types();\n }\n});\n\n// src/core/errors/system-errors.ts\nvar NetworkError;\nvar init_system_errors = __esm({\n "src/core/errors/system-errors.ts"() {\n "use strict";\n init_types();\n NetworkError = class extends VeryfrontError {\n constructor(message, context) {\n super(message, "NETWORK_ERROR" /* NETWORK_ERROR */, context);\n this.name = "NetworkError";\n }\n };\n }\n});\n\n// src/core/errors/error-handlers.ts\nvar init_error_handlers = __esm({\n "src/core/errors/error-handlers.ts"() {\n "use strict";\n init_logger();\n init_types();\n }\n});\n\n// src/core/errors/error-codes.ts\nfunction getErrorDocsUrl(code) {\n return `https://veryfront.com/docs/errors/${code}`;\n}\nvar ErrorCode2;\nvar init_error_codes = __esm({\n "src/core/errors/error-codes.ts"() {\n "use strict";\n ErrorCode2 = {\n CONFIG_NOT_FOUND: "VF001",\n CONFIG_INVALID: "VF002",\n CONFIG_PARSE_ERROR: "VF003",\n CONFIG_VALIDATION_ERROR: "VF004",\n CONFIG_TYPE_ERROR: "VF005",\n IMPORT_MAP_INVALID: "VF006",\n CORS_CONFIG_INVALID: "VF007",\n BUILD_FAILED: "VF100",\n BUNDLE_ERROR: "VF101",\n TYPESCRIPT_ERROR: "VF102",\n MDX_COMPILE_ERROR: "VF103",\n ASSET_OPTIMIZATION_ERROR: "VF104",\n SSG_GENERATION_ERROR: "VF105",\n SOURCEMAP_ERROR: "VF106",\n HYDRATION_MISMATCH: "VF200",\n RENDER_ERROR: "VF201",\n COMPONENT_ERROR: "VF202",\n LAYOUT_NOT_FOUND: "VF203",\n PAGE_NOT_FOUND: "VF204",\n API_ERROR: "VF205",\n MIDDLEWARE_ERROR: "VF206",\n ROUTE_CONFLICT: "VF300",\n INVALID_ROUTE_FILE: "VF301",\n ROUTE_HANDLER_INVALID: "VF302",\n DYNAMIC_ROUTE_ERROR: "VF303",\n ROUTE_PARAMS_ERROR: "VF304",\n API_ROUTE_ERROR: "VF305",\n MODULE_NOT_FOUND: "VF400",\n IMPORT_RESOLUTION_ERROR: "VF401",\n CIRCULAR_DEPENDENCY: "VF402",\n INVALID_IMPORT: "VF403",\n DEPENDENCY_MISSING: "VF404",\n VERSION_MISMATCH: "VF405",\n PORT_IN_USE: "VF500",\n SERVER_START_ERROR: "VF501",\n HMR_ERROR: "VF502",\n CACHE_ERROR: "VF503",\n FILE_WATCH_ERROR: "VF504",\n REQUEST_ERROR: "VF505",\n CLIENT_BOUNDARY_VIOLATION: "VF600",\n SERVER_ONLY_IN_CLIENT: "VF601",\n CLIENT_ONLY_IN_SERVER: "VF602",\n INVALID_USE_CLIENT: "VF603",\n INVALID_USE_SERVER: "VF604",\n RSC_PAYLOAD_ERROR: "VF605",\n DEV_SERVER_ERROR: "VF700",\n FAST_REFRESH_ERROR: "VF701",\n ERROR_OVERLAY_ERROR: "VF702",\n SOURCE_MAP_ERROR: "VF703",\n DEPLOYMENT_ERROR: "VF800",\n PLATFORM_ERROR: "VF801",\n ENV_VAR_MISSING: "VF802",\n PRODUCTION_BUILD_REQUIRED: "VF803",\n UNKNOWN_ERROR: "VF900",\n PERMISSION_DENIED: "VF901",\n FILE_NOT_FOUND: "VF902",\n INVALID_ARGUMENT: "VF903",\n TIMEOUT_ERROR: "VF904"\n };\n }\n});\n\n// src/core/errors/catalog/factory.ts\nfunction createErrorSolution(code, config) {\n return {\n code,\n ...config,\n docs: config.docs ?? getErrorDocsUrl(code)\n };\n}\nfunction createSimpleError(code, title, message, steps) {\n return createErrorSolution(code, { title, message, steps });\n}\nvar init_factory = __esm({\n "src/core/errors/catalog/factory.ts"() {\n "use strict";\n init_error_codes();\n }\n});\n\n// src/core/errors/catalog/config-errors.ts\nvar CONFIG_ERROR_CATALOG;\nvar init_config_errors = __esm({\n "src/core/errors/catalog/config-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n CONFIG_ERROR_CATALOG = {\n [ErrorCode2.CONFIG_NOT_FOUND]: createErrorSolution(ErrorCode2.CONFIG_NOT_FOUND, {\n title: "Configuration file not found",\n message: "Veryfront could not find veryfront.config.js in your project root.",\n steps: [\n "Create veryfront.config.js in your project root directory",\n "Run \'veryfront init\' to generate a default configuration",\n "Or copy from an example project"\n ],\n example: `// veryfront.config.js\nexport default {\n title: "My App",\n dev: { port: 3002 }\n}`,\n tips: ["You can use .ts or .mjs extensions too", "Config is optional for simple projects"]\n }),\n [ErrorCode2.CONFIG_INVALID]: createErrorSolution(ErrorCode2.CONFIG_INVALID, {\n title: "Invalid configuration",\n message: "Your configuration file has invalid values or structure.",\n steps: [\n "Check that the config exports a default object",\n "Ensure all values are valid JavaScript types",\n "Remove any trailing commas",\n "Verify property names match the schema"\n ],\n example: `// \\u2713 Valid config\nexport default {\n title: "My App",\n dev: {\n port: 3002,\n open: true\n }\n}`\n }),\n [ErrorCode2.CONFIG_PARSE_ERROR]: createSimpleError(\n ErrorCode2.CONFIG_PARSE_ERROR,\n "Configuration parse error",\n "Failed to parse your configuration file.",\n [\n "Check for syntax errors (missing brackets, quotes, etc.)",\n "Ensure the file has valid JavaScript/TypeScript syntax",\n "Look for the specific parse error in the output above"\n ]\n ),\n [ErrorCode2.CONFIG_VALIDATION_ERROR]: createSimpleError(\n ErrorCode2.CONFIG_VALIDATION_ERROR,\n "Configuration validation failed",\n "Configuration values do not pass validation.",\n [\n "Check that port numbers are between 1-65535",\n "Ensure boolean flags are true/false (not strings)",\n "Verify URLs are properly formatted",\n "Check array/object structures match expected format"\n ]\n ),\n [ErrorCode2.CONFIG_TYPE_ERROR]: createSimpleError(\n ErrorCode2.CONFIG_TYPE_ERROR,\n "Configuration type error",\n "A configuration value has the wrong type.",\n [\n "Check that numbers are not in quotes",\n \'Ensure booleans are true/false, not "true"/"false"\',\n "Verify arrays use [] brackets",\n "Check objects use {} braces"\n ]\n ),\n [ErrorCode2.IMPORT_MAP_INVALID]: createErrorSolution(ErrorCode2.IMPORT_MAP_INVALID, {\n title: "Invalid import map",\n message: "The import map in your configuration is invalid.",\n steps: [\n "Check import map structure: { imports: {}, scopes: {} }",\n "Ensure URLs are valid and accessible",\n "Verify package names are correct"\n ],\n example: `resolve: {\n importMap: {\n imports: {\n "react": "https://esm.sh/react@19",\n "@/utils": "./src/utils/index.ts"\n }\n }\n}`\n }),\n [ErrorCode2.CORS_CONFIG_INVALID]: createErrorSolution(ErrorCode2.CORS_CONFIG_INVALID, {\n title: "Invalid CORS configuration",\n message: "The CORS configuration is invalid.",\n steps: [\n "Use true for default CORS settings",\n "Or provide an object with origin, methods, headers",\n "Ensure origin is a string, not an array"\n ],\n example: `security: {\n cors: true // or { origin: "https://example.com" }\n}`\n })\n };\n }\n});\n\n// src/core/errors/catalog/build-errors.ts\nvar BUILD_ERROR_CATALOG;\nvar init_build_errors2 = __esm({\n "src/core/errors/catalog/build-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n BUILD_ERROR_CATALOG = {\n [ErrorCode2.BUILD_FAILED]: createErrorSolution(ErrorCode2.BUILD_FAILED, {\n title: "Build failed",\n message: "The build process encountered errors.",\n steps: [\n "Check the error messages above for specific issues",\n "Fix any TypeScript or syntax errors",\n "Ensure all imports can be resolved",\n "Run \'veryfront doctor\' to check your environment"\n ],\n tips: ["Try running with --verbose for more details", "Check build logs for warnings"]\n }),\n [ErrorCode2.BUNDLE_ERROR]: createSimpleError(\n ErrorCode2.BUNDLE_ERROR,\n "Bundle generation failed",\n "Failed to generate JavaScript bundles.",\n [\n "Check for circular dependencies",\n "Ensure all imports are valid",\n "Try clearing cache: veryfront clean"\n ]\n ),\n [ErrorCode2.TYPESCRIPT_ERROR]: createSimpleError(\n ErrorCode2.TYPESCRIPT_ERROR,\n "TypeScript compilation error",\n "TypeScript found errors in your code.",\n [\n "Fix the TypeScript errors shown above",\n "Check your tsconfig.json configuration",\n "Ensure all types are properly imported"\n ]\n ),\n [ErrorCode2.MDX_COMPILE_ERROR]: createErrorSolution(ErrorCode2.MDX_COMPILE_ERROR, {\n title: "MDX compilation failed",\n message: "Failed to compile MDX file.",\n steps: [\n "Check for syntax errors in your MDX file",\n "Ensure frontmatter YAML is valid",\n "Verify JSX components are properly imported",\n "Check for unclosed tags or brackets"\n ],\n example: `---\ntitle: My Post\n---\n\nimport Button from \'./components/Button.jsx\'\n\n# Hello World\n\n<Button>Click me</Button>`\n }),\n [ErrorCode2.ASSET_OPTIMIZATION_ERROR]: createSimpleError(\n ErrorCode2.ASSET_OPTIMIZATION_ERROR,\n "Asset optimization failed",\n "Failed to optimize assets (images, CSS, etc.).",\n [\n "Check that asset files are valid",\n "Ensure file paths are correct",\n "Try disabling optimization temporarily"\n ]\n ),\n [ErrorCode2.SSG_GENERATION_ERROR]: createSimpleError(\n ErrorCode2.SSG_GENERATION_ERROR,\n "Static site generation failed",\n "Failed to generate static pages.",\n [\n "Check that all routes are valid",\n "Ensure getStaticData functions return correctly",\n "Verify no dynamic content requires runtime"\n ]\n ),\n [ErrorCode2.SOURCEMAP_ERROR]: createSimpleError(\n ErrorCode2.SOURCEMAP_ERROR,\n "Source map generation failed",\n "Failed to generate source maps.",\n [\n "Try disabling source maps temporarily",\n "Check for very large files that might cause issues"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/runtime-errors.ts\nvar RUNTIME_ERROR_CATALOG;\nvar init_runtime_errors2 = __esm({\n "src/core/errors/catalog/runtime-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n RUNTIME_ERROR_CATALOG = {\n [ErrorCode2.HYDRATION_MISMATCH]: createErrorSolution(ErrorCode2.HYDRATION_MISMATCH, {\n title: "Hydration mismatch",\n message: "Client-side HTML does not match server-rendered HTML.",\n steps: [\n "Check for random values or timestamps in render",\n "Ensure Date() calls are consistent",\n "Avoid using browser-only APIs during SSR",\n "Check for white space or formatting differences"\n ],\n example: `// \\u274C Wrong - random on each render\n<div>{Math.random()}</div>\n\nconst [random, setRandom] = useState(0)\nuseEffect(() => setRandom(Math.random()), [])\n<div>{random}</div>`,\n relatedErrors: [ErrorCode2.RENDER_ERROR]\n }),\n [ErrorCode2.RENDER_ERROR]: createSimpleError(\n ErrorCode2.RENDER_ERROR,\n "Render error",\n "Failed to render component.",\n [\n "Check the component for errors",\n "Ensure all props are valid",\n "Look for null/undefined access",\n "Check error boundaries"\n ]\n ),\n [ErrorCode2.COMPONENT_ERROR]: createSimpleError(\n ErrorCode2.COMPONENT_ERROR,\n "Component error",\n "Error in component lifecycle or render.",\n [\n "Check component code for errors",\n "Ensure hooks follow Rules of Hooks",\n "Verify props are passed correctly"\n ]\n ),\n [ErrorCode2.LAYOUT_NOT_FOUND]: createErrorSolution(ErrorCode2.LAYOUT_NOT_FOUND, {\n title: "Layout file not found",\n message: "Required layout file is missing.",\n steps: [\n "Create app/layout.tsx in App Router",\n "Or create layouts/default.mdx for Pages Router",\n "Check file path and name are correct"\n ],\n example: `// app/layout.tsx\nexport default function RootLayout({ children }) {\n return (\n <html lang="en">\n <body>{children}</body>\n </html>\n )\n}`\n }),\n [ErrorCode2.PAGE_NOT_FOUND]: createSimpleError(\n ErrorCode2.PAGE_NOT_FOUND,\n "Page not found",\n "The requested page does not exist.",\n [\n "Check that the page file exists",\n "Verify file name matches route",\n "Ensure file extension is correct (.tsx, .jsx, .mdx)"\n ]\n ),\n [ErrorCode2.API_ERROR]: createSimpleError(\n ErrorCode2.API_ERROR,\n "API handler error",\n "Error in API route handler.",\n [\n "Check API handler code for errors",\n "Ensure proper error handling",\n "Verify request/response format"\n ]\n ),\n [ErrorCode2.MIDDLEWARE_ERROR]: createSimpleError(\n ErrorCode2.MIDDLEWARE_ERROR,\n "Middleware error",\n "Error in middleware execution.",\n [\n "Check middleware code for errors",\n "Ensure middleware returns Response",\n "Verify middleware is properly exported"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/route-errors.ts\nvar ROUTE_ERROR_CATALOG;\nvar init_route_errors = __esm({\n "src/core/errors/catalog/route-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n ROUTE_ERROR_CATALOG = {\n [ErrorCode2.ROUTE_CONFLICT]: createSimpleError(\n ErrorCode2.ROUTE_CONFLICT,\n "Route conflict",\n "Multiple files are trying to handle the same route.",\n [\n "Check for duplicate route files",\n "Remove conflicting routes",\n "Use dynamic routes [id] carefully"\n ]\n ),\n [ErrorCode2.INVALID_ROUTE_FILE]: createErrorSolution(ErrorCode2.INVALID_ROUTE_FILE, {\n title: "Invalid route file",\n message: "Route file has invalid structure or exports.",\n steps: [\n "API routes must export GET, POST, etc. functions",\n "Page routes must export default component",\n "Check for syntax errors"\n ],\n example: `// app/api/users/route.ts\nexport async function GET() {\n return Response.json({ users: [] })\n}`\n }),\n [ErrorCode2.ROUTE_HANDLER_INVALID]: createSimpleError(\n ErrorCode2.ROUTE_HANDLER_INVALID,\n "Invalid route handler",\n "Route handler does not return Response.",\n [\n "Ensure handler returns Response object",\n "Use Response.json() for JSON responses",\n "Check for missing return statement"\n ]\n ),\n [ErrorCode2.DYNAMIC_ROUTE_ERROR]: createSimpleError(\n ErrorCode2.DYNAMIC_ROUTE_ERROR,\n "Dynamic route error",\n "Error in dynamic route handling.",\n [\n "Check [param] syntax is correct",\n "Ensure params are accessed properly",\n "Verify dynamic segment names"\n ]\n ),\n [ErrorCode2.ROUTE_PARAMS_ERROR]: createSimpleError(\n ErrorCode2.ROUTE_PARAMS_ERROR,\n "Route parameters error",\n "Error accessing route parameters.",\n [\n "Check params object structure",\n "Ensure parameter names match route",\n "Verify params are strings"\n ]\n ),\n [ErrorCode2.API_ROUTE_ERROR]: createSimpleError(\n ErrorCode2.API_ROUTE_ERROR,\n "API route error",\n "Error in API route execution.",\n [\n "Check API handler code",\n "Ensure proper error handling",\n "Verify request parsing"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/module-errors.ts\nvar MODULE_ERROR_CATALOG;\nvar init_module_errors = __esm({\n "src/core/errors/catalog/module-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n MODULE_ERROR_CATALOG = {\n [ErrorCode2.MODULE_NOT_FOUND]: createErrorSolution(ErrorCode2.MODULE_NOT_FOUND, {\n title: "Module not found",\n message: "Cannot find the imported module.",\n steps: [\n "Check that the file path is correct",\n "Ensure the module is installed or exists",\n "Add missing module to import map",\n "Check for typos in import statement"\n ],\n example: `// Add to veryfront.config.js\nresolve: {\n importMap: {\n imports: {\n "missing-lib": "https://esm.sh/missing-lib@1.0.0"\n }\n }\n}`\n }),\n [ErrorCode2.IMPORT_RESOLUTION_ERROR]: createSimpleError(\n ErrorCode2.IMPORT_RESOLUTION_ERROR,\n "Import resolution failed",\n "Failed to resolve import specifier.",\n [\n "Check import paths are correct",\n "Ensure modules are in import map",\n "Verify network connectivity for remote imports"\n ]\n ),\n [ErrorCode2.CIRCULAR_DEPENDENCY]: createSimpleError(\n ErrorCode2.CIRCULAR_DEPENDENCY,\n "Circular dependency detected",\n "Files are importing each other in a circle.",\n [\n "Identify the circular import chain",\n "Extract shared code to separate file",\n "Use dependency injection or lazy imports"\n ]\n ),\n [ErrorCode2.INVALID_IMPORT]: createSimpleError(\n ErrorCode2.INVALID_IMPORT,\n "Invalid import statement",\n "Import statement has invalid syntax.",\n [\n \'Check import syntax: import X from "y"\',\n "Ensure quotes are properly closed",\n "Verify export exists in target module"\n ]\n ),\n [ErrorCode2.DEPENDENCY_MISSING]: createErrorSolution(ErrorCode2.DEPENDENCY_MISSING, {\n title: "Required dependency not found",\n message: "A required dependency is missing.",\n steps: [\n "Add React to your import map",\n "Ensure all peer dependencies are included",\n "Run \'veryfront doctor\' to verify setup"\n ],\n example: `// Minimum required imports\nresolve: {\n importMap: {\n imports: {\n "react": "https://esm.sh/react@19",\n "react-dom": "https://esm.sh/react-dom@19"\n }\n }\n}`\n }),\n [ErrorCode2.VERSION_MISMATCH]: createSimpleError(\n ErrorCode2.VERSION_MISMATCH,\n "Dependency version mismatch",\n "Incompatible versions of dependencies detected.",\n [\n "Ensure React and React-DOM versions match",\n "Check for multiple React instances",\n "Update dependencies to compatible versions"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/server-errors.ts\nvar SERVER_ERROR_CATALOG;\nvar init_server_errors = __esm({\n "src/core/errors/catalog/server-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n SERVER_ERROR_CATALOG = {\n [ErrorCode2.PORT_IN_USE]: createErrorSolution(ErrorCode2.PORT_IN_USE, {\n title: "Port already in use",\n message: "Another process is using the specified port.",\n steps: [\n "Stop the other process: lsof -i :PORT",\n "Use a different port: veryfront dev --port 3003",\n "Add port to config file"\n ],\n example: `// veryfront.config.js\ndev: {\n port: 3003\n}`\n }),\n [ErrorCode2.SERVER_START_ERROR]: createSimpleError(\n ErrorCode2.SERVER_START_ERROR,\n "Server failed to start",\n "Development server could not start.",\n [\n "Check for port conflicts",\n "Ensure file permissions are correct",\n "Verify configuration is valid"\n ]\n ),\n [ErrorCode2.HMR_ERROR]: createSimpleError(\n ErrorCode2.HMR_ERROR,\n "Hot Module Replacement error",\n "HMR failed to update module.",\n [\n "Try refreshing the page",\n "Check for syntax errors",\n "Restart dev server if persistent"\n ]\n ),\n [ErrorCode2.CACHE_ERROR]: createSimpleError(\n ErrorCode2.CACHE_ERROR,\n "Cache operation failed",\n "Error reading or writing cache.",\n [\n "Clear cache: veryfront clean --cache",\n "Check disk space",\n "Verify file permissions"\n ]\n ),\n [ErrorCode2.FILE_WATCH_ERROR]: createSimpleError(\n ErrorCode2.FILE_WATCH_ERROR,\n "File watching failed",\n "Could not watch files for changes.",\n [\n "Check system file watch limits",\n "Reduce number of watched files",\n "Try restarting dev server"\n ]\n ),\n [ErrorCode2.REQUEST_ERROR]: createSimpleError(\n ErrorCode2.REQUEST_ERROR,\n "Request handling error",\n "Error processing HTTP request.",\n [\n "Check request format and headers",\n "Verify route handler code",\n "Check for middleware errors"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/rsc-errors.ts\nvar RSC_ERROR_CATALOG;\nvar init_rsc_errors = __esm({\n "src/core/errors/catalog/rsc-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n RSC_ERROR_CATALOG = {\n [ErrorCode2.CLIENT_BOUNDARY_VIOLATION]: createErrorSolution(\n ErrorCode2.CLIENT_BOUNDARY_VIOLATION,\n {\n title: "Client/Server boundary violation",\n message: "Server-only code used in Client Component.",\n steps: [\n "Move server-only imports to Server Components",\n "Use \'use server\' for server actions",\n "Split component into server and client parts"\n ],\n example: `// \\u2713 Correct pattern\nimport { db } from \'./database\'\nexport default async function ServerComponent() {\n const data = await db.query(\'...\')\n return <ClientComponent data={data} />\n}\n\n\'use client\'\nexport default function ClientComponent({ data }) {\n return <div>{data}</div>\n}`\n }\n ),\n [ErrorCode2.SERVER_ONLY_IN_CLIENT]: createSimpleError(\n ErrorCode2.SERVER_ONLY_IN_CLIENT,\n "Server-only module in Client Component",\n "Cannot use server-only module in client code.",\n [\n "Move server logic to Server Component",\n "Use API routes for client data fetching",\n "Pass data as props from server"\n ]\n ),\n [ErrorCode2.CLIENT_ONLY_IN_SERVER]: createSimpleError(\n ErrorCode2.CLIENT_ONLY_IN_SERVER,\n "Client-only code in Server Component",\n "Cannot use browser APIs in Server Component.",\n [\n "Add \'use client\' directive",\n "Move client-only code to Client Component",\n "Use useEffect for client-side logic"\n ]\n ),\n [ErrorCode2.INVALID_USE_CLIENT]: createErrorSolution(ErrorCode2.INVALID_USE_CLIENT, {\n title: "Invalid \'use client\' directive",\n message: "\'use client\' directive is not properly placed.",\n steps: [\n "Place \'use client\' at the very top of file",\n "Must be before any imports",\n \'Use exact string: "use client"\'\n ],\n example: `\'use client\' // Must be first line\n\nimport React from \'react\'`\n }),\n [ErrorCode2.INVALID_USE_SERVER]: createSimpleError(\n ErrorCode2.INVALID_USE_SERVER,\n "Invalid \'use server\' directive",\n "\'use server\' directive is not properly placed.",\n [\n "Place \'use server\' at top of function",\n "Or at top of file for all functions",\n \'Use exact string: "use server"\'\n ]\n ),\n [ErrorCode2.RSC_PAYLOAD_ERROR]: createSimpleError(\n ErrorCode2.RSC_PAYLOAD_ERROR,\n "RSC payload error",\n "Error serializing Server Component payload.",\n [\n "Ensure props are JSON-serializable",\n "Avoid passing functions as props",\n "Check for circular references"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/dev-errors.ts\nvar DEV_ERROR_CATALOG;\nvar init_dev_errors = __esm({\n "src/core/errors/catalog/dev-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n DEV_ERROR_CATALOG = {\n [ErrorCode2.DEV_SERVER_ERROR]: createSimpleError(\n ErrorCode2.DEV_SERVER_ERROR,\n "Development server error",\n "Error in development server.",\n [\n "Check server logs for details",\n "Try restarting dev server",\n "Clear cache and restart"\n ]\n ),\n [ErrorCode2.FAST_REFRESH_ERROR]: createSimpleError(\n ErrorCode2.FAST_REFRESH_ERROR,\n "Fast Refresh error",\n "React Fast Refresh failed.",\n [\n "Check for syntax errors",\n "Ensure components follow Fast Refresh rules",\n "Try full page refresh"\n ]\n ),\n [ErrorCode2.ERROR_OVERLAY_ERROR]: createSimpleError(\n ErrorCode2.ERROR_OVERLAY_ERROR,\n "Error overlay failed",\n "Could not display error overlay.",\n [\n "Check browser console for details",\n "Try disabling browser extensions",\n "Refresh the page"\n ]\n ),\n [ErrorCode2.SOURCE_MAP_ERROR]: createSimpleError(\n ErrorCode2.SOURCE_MAP_ERROR,\n "Source map error",\n "Error loading or parsing source map.",\n [\n "Check that source maps are enabled",\n "Try rebuilding the project",\n "Check for corrupted build files"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/deployment-errors.ts\nvar DEPLOYMENT_ERROR_CATALOG;\nvar init_deployment_errors = __esm({\n "src/core/errors/catalog/deployment-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n DEPLOYMENT_ERROR_CATALOG = {\n [ErrorCode2.DEPLOYMENT_ERROR]: createSimpleError(\n ErrorCode2.DEPLOYMENT_ERROR,\n "Deployment failed",\n "Failed to deploy application.",\n [\n "Check deployment logs for details",\n "Verify platform credentials",\n "Ensure build succeeded first"\n ]\n ),\n [ErrorCode2.PLATFORM_ERROR]: createSimpleError(\n ErrorCode2.PLATFORM_ERROR,\n "Platform error",\n "Deployment platform returned an error.",\n [\n "Check platform status page",\n "Verify API keys and credentials",\n "Try deploying again"\n ]\n ),\n [ErrorCode2.ENV_VAR_MISSING]: createSimpleError(\n ErrorCode2.ENV_VAR_MISSING,\n "Environment variable missing",\n "Required environment variable is not set.",\n [\n "Add variable to .env file",\n "Set variable in deployment platform",\n "Check variable name is correct"\n ]\n ),\n [ErrorCode2.PRODUCTION_BUILD_REQUIRED]: createSimpleError(\n ErrorCode2.PRODUCTION_BUILD_REQUIRED,\n "Production build required",\n "Must build project before deploying.",\n [\n "Run \'veryfront build\' first",\n "Check that dist/ directory exists",\n "Verify build completed successfully"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/general-errors.ts\nvar GENERAL_ERROR_CATALOG;\nvar init_general_errors = __esm({\n "src/core/errors/catalog/general-errors.ts"() {\n "use strict";\n init_error_codes();\n init_factory();\n GENERAL_ERROR_CATALOG = {\n [ErrorCode2.UNKNOWN_ERROR]: createSimpleError(\n ErrorCode2.UNKNOWN_ERROR,\n "Unknown error",\n "An unexpected error occurred.",\n [\n "Check error details above",\n "Run \'veryfront doctor\' to diagnose",\n "Try restarting the operation",\n "Check GitHub issues for similar problems"\n ]\n ),\n [ErrorCode2.PERMISSION_DENIED]: createSimpleError(\n ErrorCode2.PERMISSION_DENIED,\n "Permission denied",\n "Insufficient permissions to perform operation.",\n [\n "Check file/directory permissions",\n "Run with appropriate permissions",\n "Verify user has write access"\n ]\n ),\n [ErrorCode2.FILE_NOT_FOUND]: createSimpleError(\n ErrorCode2.FILE_NOT_FOUND,\n "File not found",\n "Required file does not exist.",\n [\n "Check that file path is correct",\n "Verify file exists in project",\n "Check for typos in file name"\n ]\n ),\n [ErrorCode2.INVALID_ARGUMENT]: createSimpleError(\n ErrorCode2.INVALID_ARGUMENT,\n "Invalid argument",\n "Command received invalid argument.",\n [\n "Check command syntax",\n "Verify argument values",\n "Run \'veryfront help <command>\' for usage"\n ]\n ),\n [ErrorCode2.TIMEOUT_ERROR]: createSimpleError(\n ErrorCode2.TIMEOUT_ERROR,\n "Operation timed out",\n "Operation took too long to complete.",\n [\n "Check network connectivity",\n "Try increasing timeout if available",\n "Check for very large files"\n ]\n )\n };\n }\n});\n\n// src/core/errors/catalog/index.ts\nvar ERROR_CATALOG;\nvar init_catalog = __esm({\n "src/core/errors/catalog/index.ts"() {\n "use strict";\n init_config_errors();\n init_build_errors2();\n init_runtime_errors2();\n init_route_errors();\n init_module_errors();\n init_server_errors();\n init_rsc_errors();\n init_dev_errors();\n init_deployment_errors();\n init_general_errors();\n init_factory();\n ERROR_CATALOG = {\n ...CONFIG_ERROR_CATALOG,\n ...BUILD_ERROR_CATALOG,\n ...RUNTIME_ERROR_CATALOG,\n ...ROUTE_ERROR_CATALOG,\n ...MODULE_ERROR_CATALOG,\n ...SERVER_ERROR_CATALOG,\n ...RSC_ERROR_CATALOG,\n ...DEV_ERROR_CATALOG,\n ...DEPLOYMENT_ERROR_CATALOG,\n ...GENERAL_ERROR_CATALOG\n };\n }\n});\n\n// src/core/errors/user-friendly/error-catalog.ts\nvar init_error_catalog = __esm({\n "src/core/errors/user-friendly/error-catalog.ts"() {\n "use strict";\n }\n});\n\n// src/platform/compat/runtime.ts\nvar isDeno, isNode, isBun, isCloudflare;\nvar init_runtime = __esm({\n "src/platform/compat/runtime.ts"() {\n "use strict";\n isDeno = typeof Deno !== "undefined";\n isNode = typeof globalThis.process !== "undefined" && globalThis.process?.versions?.node !== void 0;\n isBun = typeof globalThis.Bun !== "undefined";\n isCloudflare = typeof globalThis !== "undefined" && "caches" in globalThis && "WebSocketPair" in globalThis;\n }\n});\n\n// src/platform/compat/console/ansi.ts\nvar ansi, red, green, yellow, blue, magenta, cyan, white, gray, bold, dim, italic, underline, strikethrough, reset;\nvar init_ansi = __esm({\n "src/platform/compat/console/ansi.ts"() {\n ansi = (open, close) => (text2) => `\\x1B[${open}m${text2}\\x1B[${close}m`;\n red = ansi(31, 39);\n green = ansi(32, 39);\n yellow = ansi(33, 39);\n blue = ansi(34, 39);\n magenta = ansi(35, 39);\n cyan = ansi(36, 39);\n white = ansi(37, 39);\n gray = ansi(90, 39);\n bold = ansi(1, 22);\n dim = ansi(2, 22);\n italic = ansi(3, 23);\n underline = ansi(4, 24);\n strikethrough = ansi(9, 29);\n reset = (text2) => `\\x1B[0m${text2}`;\n }\n});\n\n// src/platform/compat/console/deno.ts\nvar deno_exports = {};\n__export(deno_exports, {\n blue: () => blue,\n bold: () => bold,\n colors: () => colors,\n cyan: () => cyan,\n dim: () => dim,\n gray: () => gray,\n green: () => green,\n italic: () => italic,\n magenta: () => magenta,\n red: () => red,\n reset: () => reset,\n strikethrough: () => strikethrough,\n underline: () => underline,\n white: () => white,\n yellow: () => yellow\n});\nvar colors;\nvar init_deno2 = __esm({\n "src/platform/compat/console/deno.ts"() {\n "use strict";\n init_ansi();\n colors = {\n red,\n green,\n yellow,\n blue,\n cyan,\n magenta,\n white,\n gray,\n bold,\n dim,\n italic,\n underline,\n strikethrough,\n reset\n };\n }\n});\n\n// src/platform/compat/console/node.ts\nvar node_exports = {};\n__export(node_exports, {\n blue: () => blue2,\n bold: () => bold2,\n colors: () => colors2,\n cyan: () => cyan2,\n dim: () => dim2,\n gray: () => gray2,\n green: () => green2,\n italic: () => italic2,\n magenta: () => magenta2,\n red: () => red2,\n reset: () => reset2,\n strikethrough: () => strikethrough2,\n underline: () => underline2,\n white: () => white2,\n yellow: () => yellow2\n});\nimport pc from "npm:picocolors";\nvar colors2, red2, green2, yellow2, blue2, cyan2, magenta2, white2, gray2, bold2, dim2, italic2, underline2, strikethrough2, reset2;\nvar init_node = __esm({\n "src/platform/compat/console/node.ts"() {\n "use strict";\n colors2 = {\n red: pc.red,\n green: pc.green,\n yellow: pc.yellow,\n blue: pc.blue,\n cyan: pc.cyan,\n magenta: pc.magenta,\n white: pc.white,\n gray: pc.gray,\n bold: pc.bold,\n dim: pc.dim,\n italic: pc.italic,\n underline: pc.underline,\n strikethrough: pc.strikethrough,\n reset: (text2) => pc.reset(text2)\n };\n red2 = pc.red;\n green2 = pc.green;\n yellow2 = pc.yellow;\n blue2 = pc.blue;\n cyan2 = pc.cyan;\n magenta2 = pc.magenta;\n white2 = pc.white;\n gray2 = pc.gray;\n bold2 = pc.bold;\n dim2 = pc.dim;\n italic2 = pc.italic;\n underline2 = pc.underline;\n strikethrough2 = pc.strikethrough;\n reset2 = (text2) => pc.reset(text2);\n }\n});\n\n// src/platform/compat/console/index.ts\nasync function loadColors() {\n if (_colors)\n return _colors;\n try {\n if (isDeno) {\n const mod = await Promise.resolve().then(() => (init_deno2(), deno_exports));\n _colors = mod.colors;\n } else {\n const mod = await Promise.resolve().then(() => (init_node(), node_exports));\n _colors = mod.colors;\n }\n } catch {\n _colors = fallbackColors;\n }\n return _colors;\n}\nvar noOp, fallbackColors, _colors, colorsPromise;\nvar init_console = __esm({\n "src/platform/compat/console/index.ts"() {\n init_runtime();\n noOp = (text2) => text2;\n fallbackColors = {\n red: noOp,\n green: noOp,\n yellow: noOp,\n blue: noOp,\n cyan: noOp,\n magenta: noOp,\n white: noOp,\n gray: noOp,\n bold: noOp,\n dim: noOp,\n italic: noOp,\n underline: noOp,\n strikethrough: noOp,\n reset: noOp\n };\n _colors = null;\n colorsPromise = loadColors();\n }\n});\n\n// src/core/errors/user-friendly/error-identifier.ts\nvar init_error_identifier = __esm({\n "src/core/errors/user-friendly/error-identifier.ts"() {\n "use strict";\n }\n});\n\n// src/core/errors/user-friendly/error-formatter.ts\nvar init_error_formatter = __esm({\n "src/core/errors/user-friendly/error-formatter.ts"() {\n "use strict";\n init_console();\n init_error_catalog();\n init_error_identifier();\n }\n});\n\n// src/platform/compat/process.ts\nimport process2 from "node:process";\nvar init_process = __esm({\n "src/platform/compat/process.ts"() {\n init_runtime();\n }\n});\n\n// src/core/errors/user-friendly/error-wrapper.ts\nvar init_error_wrapper = __esm({\n "src/core/errors/user-friendly/error-wrapper.ts"() {\n "use strict";\n init_console();\n init_process();\n init_logger();\n init_error_formatter();\n }\n});\n\n// src/core/errors/user-friendly/index.ts\nvar init_user_friendly = __esm({\n "src/core/errors/user-friendly/index.ts"() {\n "use strict";\n init_error_catalog();\n init_error_formatter();\n init_error_identifier();\n init_error_wrapper();\n }\n});\n\n// src/core/errors/index.ts\nvar init_errors = __esm({\n "src/core/errors/index.ts"() {\n init_types();\n init_agent_errors();\n init_build_errors();\n init_runtime_errors();\n init_system_errors();\n init_error_handlers();\n init_catalog();\n init_user_friendly();\n }\n});\n\n// src/platform/adapters/deno.ts\nvar DenoFileSystemAdapter, DenoEnvironmentAdapter, DenoServerAdapter, DenoShellAdapter, DenoServer, DenoAdapter, denoAdapter;\nvar init_deno3 = __esm({\n "src/platform/adapters/deno.ts"() {\n "use strict";\n init_veryfront_error();\n init_config();\n init_utils();\n DenoFileSystemAdapter = class {\n async readFile(path) {\n return await Deno.readTextFile(path);\n }\n async writeFile(path, content) {\n await Deno.writeTextFile(path, content);\n }\n async exists(path) {\n try {\n await Deno.stat(path);\n return true;\n } catch (_error) {\n return false;\n }\n }\n async *readDir(path) {\n for await (const entry of Deno.readDir(path)) {\n yield {\n name: entry.name,\n isFile: entry.isFile,\n isDirectory: entry.isDirectory,\n isSymlink: entry.isSymlink\n };\n }\n }\n async stat(path) {\n const stat = await Deno.stat(path);\n return {\n size: stat.size,\n isFile: stat.isFile,\n isDirectory: stat.isDirectory,\n isSymlink: stat.isSymlink,\n mtime: stat.mtime\n };\n }\n async mkdir(path, options) {\n await Deno.mkdir(path, options);\n }\n async remove(path, options) {\n await Deno.remove(path, options);\n }\n async makeTempDir(prefix) {\n return await Deno.makeTempDir({ prefix });\n }\n watch(paths, options) {\n const pathArray = Array.isArray(paths) ? paths : [paths];\n const recursive = options?.recursive ?? true;\n const signal = options?.signal;\n const watcher = Deno.watchFs(pathArray, { recursive });\n let closed = false;\n const denoIterator = watcher[Symbol.asyncIterator]();\n const mapEventKind = (kind) => {\n switch (kind) {\n case "create":\n return "create";\n case "modify":\n return "modify";\n case "remove":\n return "delete";\n default:\n return "any";\n }\n };\n const iterator = {\n async next() {\n if (closed || signal?.aborted) {\n return { done: true, value: void 0 };\n }\n try {\n const result = await denoIterator.next();\n if (result.done) {\n return { done: true, value: void 0 };\n }\n return {\n done: false,\n value: {\n kind: mapEventKind(result.value.kind),\n paths: result.value.paths\n }\n };\n } catch (error2) {\n if (closed || signal?.aborted) {\n return { done: true, value: void 0 };\n }\n throw error2;\n }\n },\n async return() {\n closed = true;\n if (denoIterator.return) {\n await denoIterator.return();\n }\n return { done: true, value: void 0 };\n }\n };\n const cleanup = () => {\n if (closed)\n return;\n closed = true;\n try {\n if ("close" in watcher && typeof watcher.close === "function") {\n watcher.close();\n }\n } catch (error2) {\n serverLogger.debug("[Deno] Filesystem watcher cleanup failed", { error: error2 });\n }\n };\n if (signal) {\n signal.addEventListener("abort", cleanup);\n }\n return {\n [Symbol.asyncIterator]() {\n return iterator;\n },\n close: cleanup\n };\n }\n };\n DenoEnvironmentAdapter = class {\n get(key) {\n return Deno.env.get(key);\n }\n set(key, value) {\n Deno.env.set(key, value);\n }\n toObject() {\n return Deno.env.toObject();\n }\n };\n DenoServerAdapter = class {\n upgradeWebSocket(request) {\n const { socket, response } = Deno.upgradeWebSocket(request);\n return { socket, response };\n }\n };\n DenoShellAdapter = class {\n statSync(path) {\n try {\n const stat = Deno.statSync(path);\n return {\n isFile: stat.isFile,\n isDirectory: stat.isDirectory\n };\n } catch (error2) {\n throw toError(createError({\n type: "file",\n message: `Failed to stat file: ${error2}`\n }));\n }\n }\n readFileSync(path) {\n try {\n return Deno.readTextFileSync(path);\n } catch (error2) {\n throw toError(createError({\n type: "file",\n message: `Failed to read file: ${error2}`\n }));\n }\n }\n };\n DenoServer = class {\n constructor(server, hostname, port, abortController) {\n this.server = server;\n this.hostname = hostname;\n this.port = port;\n this.abortController = abortController;\n }\n async stop() {\n try {\n if (this.abortController) {\n this.abortController.abort();\n }\n await this.server.shutdown();\n } catch (error2) {\n serverLogger.debug("[Deno] Server shutdown failed", { error: error2 });\n }\n }\n get addr() {\n return { hostname: this.hostname, port: this.port };\n }\n };\n DenoAdapter = class {\n constructor() {\n this.id = "deno";\n this.name = "deno";\n /** @deprecated Use `id` instead */\n this.platform = "deno";\n this.fs = new DenoFileSystemAdapter();\n this.env = new DenoEnvironmentAdapter();\n this.server = new DenoServerAdapter();\n this.shell = new DenoShellAdapter();\n this.capabilities = {\n typescript: true,\n jsx: true,\n http2: true,\n websocket: true,\n workers: true,\n fileWatching: true,\n shell: true,\n kvStore: true,\n // Deno KV available\n writableFs: true\n };\n /** @deprecated Use `capabilities` instead */\n this.features = {\n websocket: true,\n http2: true,\n workers: true,\n jsx: true,\n typescript: true\n };\n }\n serve(handler, options = {}) {\n const { port = DEFAULT_DEV_PORT, hostname = "localhost", onListen } = options;\n const controller = new AbortController();\n const signal = options.signal || controller.signal;\n const server = Deno.serve({\n port,\n hostname,\n signal,\n handler: async (request, _info) => {\n try {\n return await handler(request);\n } catch (error2) {\n const { serverLogger: serverLogger2 } = await Promise.resolve().then(() => (init_utils(), utils_exports));\n serverLogger2.error("Request handler error:", error2);\n return new Response("Internal Server Error", { status: 500 });\n }\n },\n onListen: (params) => {\n onListen?.({ hostname: params.hostname, port: params.port });\n }\n });\n const controllerToPass = options.signal ? void 0 : controller;\n return Promise.resolve(new DenoServer(server, hostname, port, controllerToPass));\n }\n };\n denoAdapter = new DenoAdapter();\n }\n});\n\n// src/rendering/client/router.ts\ninit_utils();\nimport ReactDOM from "react-dom/client";\n\n// src/routing/matchers/pattern-route-matcher.ts\ninit_path_utils();\n\n// src/routing/matchers/index.ts\ninit_utils();\n\n// src/routing/slug-mapper/path-candidate-generator.ts\nimport { join } from "https://deno.land/std@0.220.0/path/mod.ts";\n\n// src/routing/client/dom-utils.ts\ninit_utils();\nfunction isInternalLink(target) {\n const href = target.getAttribute("href");\n if (!href)\n return false;\n if (href.startsWith("http") || href.startsWith("mailto:"))\n return false;\n if (href.startsWith("#"))\n return false;\n if (target.getAttribute("target") === "_blank" || target.getAttribute("download")) {\n return false;\n }\n return true;\n}\nfunction findAnchorElement(element) {\n let current = element;\n while (current && current.tagName !== "A") {\n current = current.parentElement;\n }\n if (!current || !(current instanceof HTMLAnchorElement)) {\n return null;\n }\n return current;\n}\nfunction updateMetaTags(frontmatter) {\n if (frontmatter.description) {\n updateMetaTag(\'meta[name="description"]\', "name", "description", frontmatter.description);\n }\n if (frontmatter.ogTitle) {\n updateMetaTag(\'meta[property="og:title"]\', "property", "og:title", frontmatter.ogTitle);\n }\n}\nfunction updateMetaTag(selector, attributeName, attributeValue, content) {\n let metaTag = document.querySelector(selector);\n if (!metaTag) {\n metaTag = document.createElement("meta");\n metaTag.setAttribute(attributeName, attributeValue);\n document.head.appendChild(metaTag);\n }\n metaTag.setAttribute("content", content);\n}\nfunction executeScripts(container) {\n const scripts = container.querySelectorAll("script");\n scripts.forEach((oldScript) => {\n const newScript = document.createElement("script");\n Array.from(oldScript.attributes).forEach((attribute) => {\n newScript.setAttribute(attribute.name, attribute.value);\n });\n newScript.textContent = oldScript.textContent;\n oldScript.parentNode?.replaceChild(newScript, oldScript);\n });\n}\nfunction applyHeadDirectives(container) {\n const nodes = container.querySelectorAll(\'[data-veryfront-head="1"], vf-head\');\n if (nodes.length > 0) {\n cleanManagedHeadTags();\n }\n nodes.forEach((wrapper) => {\n processHeadWrapper(wrapper);\n wrapper.parentElement?.removeChild(wrapper);\n });\n}\nfunction cleanManagedHeadTags() {\n document.head.querySelectorAll(\'[data-veryfront-managed="1"]\').forEach((element) => element.parentElement?.removeChild(element));\n}\nfunction processHeadWrapper(wrapper) {\n wrapper.childNodes.forEach((node) => {\n if (!(node instanceof Element))\n return;\n const tagName = node.tagName.toLowerCase();\n if (tagName === "title") {\n document.title = node.textContent || document.title;\n return;\n }\n const clone = document.createElement(tagName);\n for (const attribute of Array.from(node.attributes)) {\n clone.setAttribute(attribute.name, attribute.value);\n }\n if (node.textContent && !clone.hasAttribute("src")) {\n clone.textContent = node.textContent;\n }\n clone.setAttribute("data-veryfront-managed", "1");\n document.head.appendChild(clone);\n });\n}\nfunction manageFocus(container) {\n try {\n const focusElement = container.querySelector("[data-router-focus]") || container.querySelector("main") || container.querySelector("h1");\n if (focusElement && focusElement instanceof HTMLElement && "focus" in focusElement) {\n focusElement.focus({ preventScroll: true });\n }\n } catch (error2) {\n rendererLogger.warn("[router] focus management failed", error2);\n }\n}\nfunction extractPageDataFromScript() {\n const pageDataScript = document.querySelector("script[data-veryfront-page]");\n if (!pageDataScript)\n return null;\n try {\n const content = pageDataScript.textContent;\n if (!content) {\n rendererLogger.warn("[dom-utils] Page data script has no content");\n return {};\n }\n return JSON.parse(content);\n } catch (error2) {\n rendererLogger.error("[dom-utils] Failed to parse page data:", error2);\n return null;\n }\n}\nfunction parsePageDataFromHTML(html3) {\n const parser = new DOMParser();\n const doc = parser.parseFromString(html3, "text/html");\n const root = doc.getElementById("root");\n let content = "";\n if (root) {\n content = root.innerHTML || "";\n } else {\n rendererLogger.warn("[dom-utils] No root element found in HTML");\n }\n const pageDataScript = doc.querySelector("script[data-veryfront-page]");\n let pageData = {};\n if (pageDataScript) {\n try {\n const content2 = pageDataScript.textContent;\n if (!content2) {\n rendererLogger.warn("[dom-utils] Page data script in HTML has no content");\n } else {\n pageData = JSON.parse(content2);\n }\n } catch (error2) {\n rendererLogger.error("[dom-utils] Failed to parse page data from HTML:", error2);\n }\n }\n return { content, pageData };\n}\n\n// src/routing/client/navigation-handlers.ts\ninit_utils();\ninit_config();\nvar NavigationHandlers = class {\n constructor(prefetchDelay = DEFAULT_PREFETCH_DELAY_MS, prefetchOptions = {}) {\n this.prefetchQueue = /* @__PURE__ */ new Set();\n this.scrollPositions = /* @__PURE__ */ new Map();\n this.isPopStateNav = false;\n this.prefetchDelay = prefetchDelay;\n this.prefetchOptions = prefetchOptions;\n }\n createClickHandler(callbacks) {\n return (event) => {\n const anchor = findAnchorElement(event.target);\n if (!anchor || !isInternalLink(anchor))\n return;\n const href = anchor.getAttribute("href");\n event.preventDefault();\n callbacks.onNavigate(href);\n };\n }\n createPopStateHandler(callbacks) {\n return (_event) => {\n const path = globalThis.location.pathname;\n this.isPopStateNav = true;\n callbacks.onNavigate(path);\n };\n }\n createMouseOverHandler(callbacks) {\n return (event) => {\n const target = event.target;\n if (target.tagName !== "A")\n return;\n const href = target.getAttribute("href");\n if (!href || href.startsWith("http") || href.startsWith("#"))\n return;\n if (!this.shouldPrefetchOnHover(target))\n return;\n if (!this.prefetchQueue.has(href)) {\n this.prefetchQueue.add(href);\n setTimeout(() => {\n callbacks.onPrefetch(href);\n this.prefetchQueue.delete(href);\n }, this.prefetchDelay);\n }\n };\n }\n shouldPrefetchOnHover(target) {\n const prefetchAttribute = target.getAttribute("data-prefetch");\n const isHoverEnabled = Boolean(this.prefetchOptions.hover);\n if (prefetchAttribute === "false")\n return false;\n return prefetchAttribute === "true" || isHoverEnabled;\n }\n saveScrollPosition(path) {\n try {\n const scrollY = globalThis.scrollY;\n if (typeof scrollY === "number") {\n this.scrollPositions.set(path, scrollY);\n } else {\n rendererLogger.debug("[router] No valid scrollY value available");\n this.scrollPositions.set(path, 0);\n }\n } catch (error2) {\n rendererLogger.warn("[router] failed to record scroll position", error2);\n }\n }\n getScrollPosition(path) {\n const position = this.scrollPositions.get(path);\n if (position === void 0) {\n rendererLogger.debug(`[router] No scroll position stored for ${path}`);\n return 0;\n }\n return position;\n }\n isPopState() {\n return this.isPopStateNav;\n }\n clearPopStateFlag() {\n this.isPopStateNav = false;\n }\n clear() {\n this.prefetchQueue.clear();\n this.scrollPositions.clear();\n this.isPopStateNav = false;\n }\n};\n\n// src/routing/client/page-loader.ts\ninit_utils();\ninit_errors();\nvar PageLoader = class {\n constructor() {\n this.cache = /* @__PURE__ */ new Map();\n }\n getCached(path) {\n return this.cache.get(path);\n }\n isCached(path) {\n return this.cache.has(path);\n }\n setCache(path, data) {\n this.cache.set(path, data);\n }\n clearCache() {\n this.cache.clear();\n }\n async fetchPageData(path) {\n const jsonData = await this.tryFetchJSON(path);\n if (jsonData)\n return jsonData;\n return this.fetchAndParseHTML(path);\n }\n async tryFetchJSON(path) {\n try {\n const response = await fetch(`/_veryfront/data${path}.json`, {\n headers: { "X-Veryfront-Navigation": "client" }\n });\n if (response.ok) {\n return await response.json();\n }\n } catch (error2) {\n rendererLogger.debug(`[PageLoader] RSC fetch failed for ${path}, falling back to HTML:`, error2);\n }\n return null;\n }\n async fetchAndParseHTML(path) {\n const response = await fetch(path, {\n headers: { "X-Veryfront-Navigation": "client" }\n });\n if (!response.ok) {\n throw new NetworkError(`Failed to fetch ${path}`, {\n status: response.status,\n path\n });\n }\n const html3 = await response.text();\n const { content, pageData } = parsePageDataFromHTML(html3);\n return {\n html: content,\n ...pageData\n };\n }\n async loadPage(path) {\n const cachedData = this.getCached(path);\n if (cachedData) {\n rendererLogger.debug(`Loading ${path} from cache`);\n return cachedData;\n }\n const data = await this.fetchPageData(path);\n this.setCache(path, data);\n return data;\n }\n async prefetch(path) {\n if (this.isCached(path))\n return;\n rendererLogger.debug(`Prefetching ${path}`);\n try {\n const data = await this.fetchPageData(path);\n this.setCache(path, data);\n } catch (error2) {\n rendererLogger.warn(`Failed to prefetch ${path}`, error2);\n }\n }\n};\n\n// src/routing/client/page-transition.ts\ninit_utils();\ninit_config();\n\n// src/security/client/html-sanitizer.ts\nvar SUSPICIOUS_PATTERNS = [\n { pattern: /<script[^>]*>[\\s\\S]*?<\\/script>/gi, name: "inline script" },\n { pattern: /javascript:/gi, name: "javascript: URL" },\n { pattern: /\\bon\\w+\\s*=/gi, name: "event handler attribute" },\n { pattern: /data:\\s*text\\/html/gi, name: "data: HTML URL" }\n];\nfunction isDevMode() {\n if (typeof globalThis !== "undefined") {\n const g = globalThis;\n return g.__VERYFRONT_DEV__ === true || g.Deno?.env?.get?.("VERYFRONT_ENV") === "development";\n }\n return false;\n}\nfunction validateTrustedHtml(html3, options = {}) {\n const { strict = false, warn = true } = options;\n for (const { pattern, name } of SUSPICIOUS_PATTERNS) {\n pattern.lastIndex = 0;\n if (pattern.test(html3)) {\n const message = `[Security] Suspicious ${name} detected in server HTML`;\n if (warn) {\n console.warn(message);\n }\n if (strict || !isDevMode()) {\n throw new Error(`Potentially unsafe HTML: ${name} detected`);\n }\n }\n }\n return html3;\n}\n\n// src/routing/client/page-transition.ts\nvar PageTransition = class {\n constructor(setupViewportPrefetch) {\n this.setupViewportPrefetch = setupViewportPrefetch;\n }\n destroy() {\n if (this.pendingTransitionTimeout !== void 0) {\n clearTimeout(this.pendingTransitionTimeout);\n this.pendingTransitionTimeout = void 0;\n }\n }\n updatePage(data, isPopState, scrollY) {\n if (data.frontmatter?.title) {\n document.title = data.frontmatter.title;\n }\n updateMetaTags(data.frontmatter ?? {});\n const rootElement = document.getElementById("root");\n if (rootElement && (data.html ?? "") !== "") {\n this.performTransition(rootElement, data, isPopState, scrollY);\n }\n }\n performTransition(rootElement, data, isPopState, scrollY) {\n if (this.pendingTransitionTimeout !== void 0) {\n clearTimeout(this.pendingTransitionTimeout);\n }\n rootElement.style.opacity = "0";\n this.pendingTransitionTimeout = setTimeout(() => {\n this.pendingTransitionTimeout = void 0;\n rootElement.innerHTML = validateTrustedHtml(String(data.html ?? ""));\n rootElement.style.opacity = "1";\n executeScripts(rootElement);\n applyHeadDirectives(rootElement);\n this.setupViewportPrefetch(rootElement);\n manageFocus(rootElement);\n this.handleScroll(isPopState, scrollY);\n }, PAGE_TRANSITION_DELAY_MS);\n }\n handleScroll(isPopState, scrollY) {\n try {\n globalThis.scrollTo(0, isPopState ? scrollY : 0);\n } catch (error2) {\n rendererLogger.warn("[router] scroll handling failed", error2);\n }\n }\n showError(error2) {\n const rootElement = document.getElementById("root");\n if (!rootElement)\n return;\n const errorDiv = document.createElement("div");\n errorDiv.className = "veryfront-error-page";\n const heading = document.createElement("h1");\n heading.textContent = "Oops! Something went wrong";\n const message = document.createElement("p");\n message.textContent = error2.message;\n const button = document.createElement("button");\n button.type = "button";\n button.textContent = "Reload Page";\n button.onclick = () => globalThis.location.reload();\n errorDiv.appendChild(heading);\n errorDiv.appendChild(message);\n errorDiv.appendChild(button);\n rootElement.innerHTML = "";\n rootElement.appendChild(errorDiv);\n }\n setLoadingState(loading) {\n const indicator = document.getElementById("veryfront-loading");\n if (indicator) {\n indicator.style.display = loading ? "block" : "none";\n }\n document.body.classList.toggle("veryfront-loading", loading);\n }\n};\n\n// src/routing/client/viewport-prefetch.ts\ninit_utils();\nvar ViewportPrefetch = class {\n constructor(prefetchCallback, prefetchOptions = {}) {\n this.observer = null;\n this.prefetchCallback = prefetchCallback;\n this.prefetchOptions = prefetchOptions;\n }\n setup(root) {\n try {\n if (!("IntersectionObserver" in globalThis))\n return;\n if (this.observer)\n this.observer.disconnect();\n this.createObserver();\n this.observeLinks(root);\n } catch (error2) {\n rendererLogger.debug("[router] setupViewportPrefetch failed", error2);\n }\n }\n createObserver() {\n this.observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n const isAnchor = typeof HTMLAnchorElement !== "undefined" ? entry.target instanceof HTMLAnchorElement : entry.target.tagName === "A";\n if (isAnchor) {\n const href = entry.target.getAttribute("href");\n if (href) {\n this.prefetchCallback(href);\n }\n this.observer?.unobserve(entry.target);\n }\n }\n }\n },\n { rootMargin: "200px" }\n );\n }\n observeLinks(root) {\n const anchors = root.querySelectorAll?.(\'a[href]:not([target="_blank"])\') ?? document.createDocumentFragment().querySelectorAll("a");\n const isViewportEnabled = Boolean(this.prefetchOptions.viewport);\n anchors.forEach((anchor) => {\n if (this.shouldObserveAnchor(anchor, isViewportEnabled)) {\n this.observer?.observe(anchor);\n }\n });\n }\n shouldObserveAnchor(anchor, isViewportEnabled) {\n const href = anchor.getAttribute("href") || "";\n if (!href || href.startsWith("http") || href.startsWith("#") || anchor.getAttribute("download")) {\n return false;\n }\n const prefetchAttribute = anchor.getAttribute("data-prefetch");\n if (prefetchAttribute === "false")\n return false;\n return prefetchAttribute === "viewport" || isViewportEnabled;\n }\n disconnect() {\n if (this.observer) {\n try {\n this.observer.disconnect();\n } catch (error2) {\n rendererLogger.warn("[router] prefetchObserver.disconnect failed", error2);\n }\n this.observer = null;\n }\n }\n};\n\n// src/routing/api/handler.ts\ninit_utils();\ninit_std_path();\ninit_config();\n\n// src/core/utils/lru-wrapper.ts\ninit_utils();\n\n// src/routing/api/handler.ts\ninit_veryfront_error();\n\n// src/security/http/response/constants.ts\nvar CONTENT_TYPES = {\n JSON: "application/json; charset=utf-8",\n HTML: "text/html; charset=utf-8",\n TEXT: "text/plain; charset=utf-8",\n JAVASCRIPT: "application/javascript; charset=utf-8",\n CSS: "text/css; charset=utf-8",\n XML: "application/xml; charset=utf-8"\n};\nvar CACHE_DURATIONS = {\n SHORT: 60,\n MEDIUM: 3600,\n LONG: 31536e3\n};\n\n// src/security/http/cors/validators.ts\ninit_logger();\n\n// src/observability/tracing/manager.ts\ninit_utils();\n\n// src/observability/tracing/config.ts\nvar DEFAULT_CONFIG2 = {\n enabled: false,\n exporter: "console",\n serviceName: "veryfront",\n sampleRate: 1,\n debug: false\n};\nfunction loadConfig(config = {}, adapter) {\n const finalConfig = { ...DEFAULT_CONFIG2, ...config };\n if (adapter?.env) {\n applyEnvFromAdapter(finalConfig, adapter.env);\n } else {\n applyEnvFromDeno(finalConfig);\n }\n return finalConfig;\n}\nfunction applyEnvFromAdapter(config, envAdapter) {\n if (!envAdapter)\n return;\n const otelEnabled = envAdapter.get("OTEL_TRACES_ENABLED");\n const veryfrontOtel = envAdapter.get("VERYFRONT_OTEL");\n const serviceName = envAdapter.get("OTEL_SERVICE_NAME");\n config.enabled = otelEnabled === "true" || veryfrontOtel === "1" || config.enabled;\n if (serviceName)\n config.serviceName = serviceName;\n const otlpEndpoint = envAdapter.get("OTEL_EXPORTER_OTLP_ENDPOINT");\n const tracesEndpoint = envAdapter.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT");\n config.endpoint = otlpEndpoint || tracesEndpoint || config.endpoint;\n const exporterType = envAdapter.get("OTEL_TRACES_EXPORTER");\n if (isValidExporter(exporterType)) {\n config.exporter = exporterType;\n }\n}\nfunction applyEnvFromDeno(config) {\n try {\n const denoEnv = globalThis.Deno?.env;\n if (!denoEnv)\n return;\n config.enabled = denoEnv.get("OTEL_TRACES_ENABLED") === "true" || denoEnv.get("VERYFRONT_OTEL") === "1" || config.enabled;\n config.serviceName = denoEnv.get("OTEL_SERVICE_NAME") || config.serviceName;\n config.endpoint = denoEnv.get("OTEL_EXPORTER_OTLP_ENDPOINT") || denoEnv.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") || config.endpoint;\n const exporterType = denoEnv.get("OTEL_TRACES_EXPORTER");\n if (isValidExporter(exporterType)) {\n config.exporter = exporterType;\n }\n } catch {\n }\n}\nfunction isValidExporter(value) {\n return value === "jaeger" || value === "zipkin" || value === "otlp" || value === "console";\n}\n\n// src/observability/tracing/span-operations.ts\ninit_utils();\nvar SpanOperations = class {\n constructor(api, tracer2) {\n this.api = api;\n this.tracer = tracer2;\n }\n startSpan(name, options = {}) {\n try {\n const spanKind = this.mapSpanKind(options.kind);\n const span = this.tracer.startSpan(name, {\n kind: spanKind,\n attributes: options.attributes || {}\n }, options.parent);\n return span;\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to start span", { name, error: error2 });\n return null;\n }\n }\n endSpan(span, error2) {\n if (!span)\n return;\n try {\n if (error2) {\n span.recordException(error2);\n span.setStatus({\n code: this.api.SpanStatusCode.ERROR,\n message: error2.message\n });\n } else {\n span.setStatus({ code: this.api.SpanStatusCode.OK });\n }\n span.end();\n } catch (err) {\n serverLogger.debug("[tracing] Failed to end span", err);\n }\n }\n setAttributes(span, attributes) {\n if (!span)\n return;\n try {\n span.setAttributes(attributes);\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to set span attributes", error2);\n }\n }\n addEvent(span, name, attributes) {\n if (!span)\n return;\n try {\n span.addEvent(name, attributes);\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to add span event", error2);\n }\n }\n createChildSpan(parentSpan, name, options = {}) {\n if (!parentSpan)\n return this.startSpan(name, options);\n try {\n const parentContext = this.api.trace.setSpan(this.api.context.active(), parentSpan);\n return this.startSpan(name, { ...options, parent: parentContext });\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to create child span", error2);\n return null;\n }\n }\n mapSpanKind(kind) {\n if (!kind)\n return this.api.SpanKind.INTERNAL;\n const kindMap = {\n "internal": this.api.SpanKind.INTERNAL,\n "server": this.api.SpanKind.SERVER,\n "client": this.api.SpanKind.CLIENT,\n "producer": this.api.SpanKind.PRODUCER,\n "consumer": this.api.SpanKind.CONSUMER\n };\n return kindMap[kind.toLowerCase()] || this.api.SpanKind.INTERNAL;\n }\n};\n\n// src/observability/tracing/context-propagation.ts\ninit_utils();\nvar ContextPropagation = class {\n constructor(api, propagator) {\n this.api = api;\n this.propagator = propagator;\n }\n extractContext(headers) {\n try {\n const carrier = {};\n headers.forEach((value, key) => {\n carrier[key] = value;\n });\n return this.api.propagation.extract(this.api.context.active(), carrier);\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to extract context from headers", error2);\n return void 0;\n }\n }\n injectContext(context, headers) {\n try {\n const carrier = {};\n this.api.propagation.inject(context, carrier);\n for (const [key, value] of Object.entries(carrier)) {\n headers.set(key, value);\n }\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to inject context into headers", error2);\n }\n }\n getActiveContext() {\n try {\n return this.api.context.active();\n } catch (error2) {\n serverLogger.debug("[tracing] Failed to get active context", error2);\n return void 0;\n }\n }\n async withActiveSpan(span, fn) {\n if (!span)\n return await fn();\n return await this.api.context.with(\n this.api.trace.setSpan(this.api.context.active(), span),\n fn\n );\n }\n withSpan(name, fn, startSpan2, endSpan2) {\n const span = startSpan2(name);\n try {\n const result = fn(span);\n endSpan2(span);\n return result;\n } catch (error2) {\n endSpan2(span, error2);\n throw error2;\n }\n }\n async withSpanAsync(name, fn, startSpan2, endSpan2) {\n const span = startSpan2(name);\n try {\n const result = await fn(span);\n endSpan2(span);\n return result;\n } catch (error2) {\n endSpan2(span, error2);\n throw error2;\n }\n }\n};\n\n// src/observability/tracing/manager.ts\nvar TracingManager = class {\n constructor() {\n this.state = {\n initialized: false,\n tracer: null,\n api: null,\n propagator: null\n };\n this.spanOps = null;\n this.contextProp = null;\n }\n async initialize(config = {}, adapter) {\n if (this.state.initialized) {\n serverLogger.debug("[tracing] Already initialized");\n return;\n }\n const finalConfig = loadConfig(config, adapter);\n if (!finalConfig.enabled) {\n serverLogger.debug("[tracing] Tracing disabled");\n this.state.initialized = true;\n return;\n }\n try {\n await this.initializeTracer(finalConfig);\n this.state.initialized = true;\n serverLogger.info("[tracing] OpenTelemetry tracing initialized", {\n exporter: finalConfig.exporter,\n serviceName: finalConfig.serviceName,\n endpoint: finalConfig.endpoint\n });\n } catch (error2) {\n serverLogger.warn("[tracing] Failed to initialize OpenTelemetry tracing", error2);\n this.state.initialized = true;\n }\n }\n async initializeTracer(config) {\n const api = await import("npm:@opentelemetry/api@1");\n this.state.api = api;\n this.state.tracer = api.trace.getTracer(config.serviceName || "veryfront", "0.1.0");\n const { W3CTraceContextPropagator } = await import("npm:@opentelemetry/core@1");\n this.state.propagator = new W3CTraceContextPropagator();\n api.propagation.setGlobalPropagator(this.state.propagator);\n if (this.state.api && this.state.tracer) {\n this.spanOps = new SpanOperations(this.state.api, this.state.tracer);\n }\n if (this.state.api && this.state.propagator) {\n this.contextProp = new ContextPropagation(this.state.api, this.state.propagator);\n }\n }\n isEnabled() {\n return this.state.initialized && this.state.tracer !== null;\n }\n getSpanOperations() {\n return this.spanOps;\n }\n getContextPropagation() {\n return this.contextProp;\n }\n getState() {\n return this.state;\n }\n shutdown() {\n if (!this.state.initialized)\n return;\n try {\n serverLogger.info("[tracing] Tracing shutdown initiated");\n } catch (error2) {\n serverLogger.warn("[tracing] Error during tracing shutdown", error2);\n }\n }\n};\nvar tracingManager = new TracingManager();\n\n// src/observability/metrics/manager.ts\ninit_utils();\n\n// src/observability/metrics/config.ts\nvar DEFAULT_METRICS_COLLECT_INTERVAL_MS2 = 6e4;\nvar DEFAULT_CONFIG3 = {\n enabled: false,\n exporter: "console",\n prefix: "veryfront",\n collectInterval: DEFAULT_METRICS_COLLECT_INTERVAL_MS2,\n debug: false\n};\nfunction loadConfig2(config, adapter) {\n const finalConfig = { ...DEFAULT_CONFIG3, ...config };\n if (adapter?.env) {\n const envAdapter = adapter.env;\n const otelEnabled = envAdapter.get("OTEL_METRICS_ENABLED");\n const veryfrontOtel = envAdapter.get("VERYFRONT_OTEL");\n finalConfig.enabled = otelEnabled === "true" || veryfrontOtel === "1" || finalConfig.enabled;\n const otlpEndpoint = envAdapter.get("OTEL_EXPORTER_OTLP_ENDPOINT");\n const metricsEndpoint = envAdapter.get(\n "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"\n );\n finalConfig.endpoint = otlpEndpoint || metricsEndpoint || finalConfig.endpoint;\n const exporterType = envAdapter.get("OTEL_METRICS_EXPORTER");\n if (exporterType === "prometheus" || exporterType === "otlp" || exporterType === "console") {\n finalConfig.exporter = exporterType;\n }\n } else {\n try {\n const env = process.env;\n if (env) {\n finalConfig.enabled = env.OTEL_METRICS_ENABLED === "true" || env.VERYFRONT_OTEL === "1" || finalConfig.enabled;\n finalConfig.endpoint = env.OTEL_EXPORTER_OTLP_ENDPOINT || env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT || finalConfig.endpoint;\n const exporterType = env.OTEL_METRICS_EXPORTER;\n if (exporterType === "prometheus" || exporterType === "otlp" || exporterType === "console") {\n finalConfig.exporter = exporterType;\n }\n }\n } catch {\n }\n }\n return finalConfig;\n}\nfunction getMemoryUsage() {\n try {\n if (process?.memoryUsage) {\n return process.memoryUsage();\n }\n return null;\n } catch {\n return null;\n }\n}\n\n// src/observability/instruments/instruments-factory.ts\ninit_utils();\n\n// src/observability/instruments/build-instruments.ts\ninit_config();\nfunction createBuildInstruments(meter, config) {\n const buildDuration = meter.createHistogram(\n `${config.prefix}.build.duration`,\n {\n description: "Build operation duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const bundleSizeHistogram = meter.createHistogram(\n `${config.prefix}.build.bundle.size`,\n {\n description: "Bundle size distribution",\n unit: "kb",\n advice: { explicitBucketBoundaries: SIZE_HISTOGRAM_BOUNDARIES_KB }\n }\n );\n const bundleCounter = meter.createCounter(\n `${config.prefix}.build.bundles`,\n {\n description: "Total number of bundles created",\n unit: "bundles"\n }\n );\n return {\n buildDuration,\n bundleSizeHistogram,\n bundleCounter\n };\n}\n\n// src/observability/instruments/cache-instruments.ts\nfunction createCacheInstruments(meter, config, runtimeState) {\n const cacheGetCounter = meter.createCounter(\n `${config.prefix}.cache.gets`,\n {\n description: "Total number of cache get operations",\n unit: "operations"\n }\n );\n const cacheHitCounter = meter.createCounter(\n `${config.prefix}.cache.hits`,\n {\n description: "Total number of cache hits",\n unit: "hits"\n }\n );\n const cacheMissCounter = meter.createCounter(\n `${config.prefix}.cache.misses`,\n {\n description: "Total number of cache misses",\n unit: "misses"\n }\n );\n const cacheSetCounter = meter.createCounter(\n `${config.prefix}.cache.sets`,\n {\n description: "Total number of cache set operations",\n unit: "operations"\n }\n );\n const cacheInvalidateCounter = meter.createCounter(\n `${config.prefix}.cache.invalidations`,\n {\n description: "Total number of cache invalidations",\n unit: "operations"\n }\n );\n const cacheSizeGauge = meter.createObservableGauge(\n `${config.prefix}.cache.size`,\n {\n description: "Current cache size",\n unit: "entries"\n }\n );\n cacheSizeGauge.addCallback((result) => {\n result.observe(runtimeState.cacheSize);\n });\n return {\n cacheGetCounter,\n cacheHitCounter,\n cacheMissCounter,\n cacheSetCounter,\n cacheInvalidateCounter,\n cacheSizeGauge\n };\n}\n\n// src/observability/instruments/data-instruments.ts\ninit_config();\nfunction createDataInstruments(meter, config) {\n const dataFetchDuration = meter.createHistogram(\n `${config.prefix}.data.fetch.duration`,\n {\n description: "Data fetch duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const dataFetchCounter = meter.createCounter(\n `${config.prefix}.data.fetch.count`,\n {\n description: "Total number of data fetches",\n unit: "fetches"\n }\n );\n const dataFetchErrorCounter = meter.createCounter(\n `${config.prefix}.data.fetch.errors`,\n {\n description: "Data fetch errors",\n unit: "errors"\n }\n );\n return {\n dataFetchDuration,\n dataFetchCounter,\n dataFetchErrorCounter\n };\n}\n\n// src/observability/instruments/http-instruments.ts\ninit_config();\nfunction createHttpInstruments(meter, config) {\n const httpRequestCounter = meter.createCounter(\n `${config.prefix}.http.requests`,\n {\n description: "Total number of HTTP requests",\n unit: "requests"\n }\n );\n const httpRequestDuration = meter.createHistogram(\n `${config.prefix}.http.request.duration`,\n {\n description: "HTTP request duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const httpActiveRequests = meter.createUpDownCounter(\n `${config.prefix}.http.requests.active`,\n {\n description: "Number of active HTTP requests",\n unit: "requests"\n }\n );\n return {\n httpRequestCounter,\n httpRequestDuration,\n httpActiveRequests\n };\n}\n\n// src/observability/instruments/memory-instruments.ts\nfunction createMemoryInstruments(meter, config) {\n const memoryUsageGauge = meter.createObservableGauge(\n `${config.prefix}.memory.usage`,\n {\n description: "Memory usage",\n unit: "bytes"\n }\n );\n memoryUsageGauge.addCallback((result) => {\n const memoryUsage = getMemoryUsage();\n if (memoryUsage) {\n result.observe(memoryUsage.rss);\n }\n });\n const heapUsageGauge = meter.createObservableGauge(\n `${config.prefix}.memory.heap`,\n {\n description: "Heap memory usage",\n unit: "bytes"\n }\n );\n heapUsageGauge.addCallback((result) => {\n const memoryUsage = getMemoryUsage();\n if (memoryUsage) {\n result.observe(memoryUsage.heapUsed);\n }\n });\n return {\n memoryUsageGauge,\n heapUsageGauge\n };\n}\n\n// src/observability/instruments/render-instruments.ts\ninit_config();\nfunction createRenderInstruments(meter, config) {\n const renderDuration = meter.createHistogram(\n `${config.prefix}.render.duration`,\n {\n description: "Page render duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const renderCounter = meter.createCounter(\n `${config.prefix}.render.count`,\n {\n description: "Total number of page renders",\n unit: "renders"\n }\n );\n const renderErrorCounter = meter.createCounter(\n `${config.prefix}.render.errors`,\n {\n description: "Total number of render errors",\n unit: "errors"\n }\n );\n return {\n renderDuration,\n renderCounter,\n renderErrorCounter\n };\n}\n\n// src/observability/instruments/rsc-instruments.ts\ninit_config();\nfunction createRscInstruments(meter, config) {\n const rscRenderDuration = meter.createHistogram(\n `${config.prefix}.rsc.render.duration`,\n {\n description: "RSC render duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const rscStreamDuration = meter.createHistogram(\n `${config.prefix}.rsc.stream.duration`,\n {\n description: "RSC stream duration",\n unit: "ms",\n advice: { explicitBucketBoundaries: DURATION_HISTOGRAM_BOUNDARIES_MS }\n }\n );\n const rscManifestCounter = meter.createCounter(\n `${config.prefix}.rsc.manifest`,\n {\n description: "RSC manifest requests",\n unit: "requests"\n }\n );\n const rscPageCounter = meter.createCounter(\n `${config.prefix}.rsc.page`,\n {\n description: "RSC page requests",\n unit: "requests"\n }\n );\n const rscStreamCounter = meter.createCounter(\n `${config.prefix}.rsc.stream`,\n {\n description: "RSC stream requests",\n unit: "requests"\n }\n );\n const rscActionCounter = meter.createCounter(\n `${config.prefix}.rsc.action`,\n {\n description: "RSC action requests",\n unit: "requests"\n }\n );\n const rscErrorCounter = meter.createCounter(\n `${config.prefix}.rsc.errors`,\n {\n description: "RSC errors",\n unit: "errors"\n }\n );\n return {\n rscRenderDuration,\n rscStreamDuration,\n rscManifestCounter,\n rscPageCounter,\n rscStreamCounter,\n rscActionCounter,\n rscErrorCounter\n };\n}\n\n// src/observability/instruments/instruments-factory.ts\nasync function initializeInstruments(meter, config, runtimeState) {\n const instruments = {\n httpRequestCounter: null,\n httpRequestDuration: null,\n httpActiveRequests: null,\n cacheGetCounter: null,\n cacheHitCounter: null,\n cacheMissCounter: null,\n cacheSetCounter: null,\n cacheInvalidateCounter: null,\n cacheSizeGauge: null,\n renderDuration: null,\n renderCounter: null,\n renderErrorCounter: null,\n rscRenderDuration: null,\n rscStreamDuration: null,\n rscManifestCounter: null,\n rscPageCounter: null,\n rscStreamCounter: null,\n rscActionCounter: null,\n rscErrorCounter: null,\n buildDuration: null,\n bundleSizeHistogram: null,\n bundleCounter: null,\n dataFetchDuration: null,\n dataFetchCounter: null,\n dataFetchErrorCounter: null,\n corsRejectionCounter: null,\n securityHeadersCounter: null,\n memoryUsageGauge: null,\n heapUsageGauge: null\n };\n try {\n const httpInstruments = createHttpInstruments(meter, config);\n Object.assign(instruments, httpInstruments);\n const cacheInstruments = createCacheInstruments(meter, config, runtimeState);\n Object.assign(instruments, cacheInstruments);\n const renderInstruments = createRenderInstruments(meter, config);\n Object.assign(instruments, renderInstruments);\n const rscInstruments = createRscInstruments(meter, config);\n Object.assign(instruments, rscInstruments);\n const buildInstruments = createBuildInstruments(meter, config);\n Object.assign(instruments, buildInstruments);\n const dataInstruments = createDataInstruments(meter, config);\n Object.assign(instruments, dataInstruments);\n const memoryInstruments = createMemoryInstruments(meter, config);\n Object.assign(instruments, memoryInstruments);\n } catch (error2) {\n serverLogger.warn("[metrics] Failed to initialize metric instruments", error2);\n }\n return instruments;\n}\n\n// src/observability/metrics/recorder.ts\nvar MetricsRecorder = class {\n constructor(instruments, runtimeState) {\n this.instruments = instruments;\n this.runtimeState = runtimeState;\n }\n recordHttpRequest(attributes) {\n this.instruments.httpRequestCounter?.add(1, attributes);\n this.instruments.httpActiveRequests?.add(1, attributes);\n this.runtimeState.activeRequests++;\n }\n recordHttpRequestComplete(durationMs, attributes) {\n this.instruments.httpRequestDuration?.record(durationMs, attributes);\n this.instruments.httpActiveRequests?.add(-1, attributes);\n this.runtimeState.activeRequests--;\n }\n recordCacheGet(hit, attributes) {\n this.instruments.cacheGetCounter?.add(1, attributes);\n if (hit) {\n this.instruments.cacheHitCounter?.add(1, attributes);\n } else {\n this.instruments.cacheMissCounter?.add(1, attributes);\n }\n }\n recordCacheSet(attributes) {\n this.instruments.cacheSetCounter?.add(1, attributes);\n this.runtimeState.cacheSize++;\n }\n recordCacheInvalidate(count, attributes) {\n this.instruments.cacheInvalidateCounter?.add(count, attributes);\n this.runtimeState.cacheSize = Math.max(\n 0,\n this.runtimeState.cacheSize - count\n );\n }\n setCacheSize(size) {\n this.runtimeState.cacheSize = size;\n }\n // Render Metrics\n recordRender(durationMs, attributes) {\n this.instruments.renderDuration?.record(durationMs, attributes);\n this.instruments.renderCounter?.add(1, attributes);\n }\n recordRenderError(attributes) {\n this.instruments.renderErrorCounter?.add(1, attributes);\n }\n // RSC Metrics\n recordRSCRender(durationMs, attributes) {\n this.instruments.rscRenderDuration?.record(durationMs, attributes);\n }\n recordRSCStream(durationMs, attributes) {\n this.instruments.rscStreamDuration?.record(durationMs, attributes);\n }\n recordRSCRequest(type, attributes) {\n switch (type) {\n case "manifest":\n this.instruments.rscManifestCounter?.add(1, attributes);\n break;\n case "page":\n this.instruments.rscPageCounter?.add(1, attributes);\n break;\n case "stream":\n this.instruments.rscStreamCounter?.add(1, attributes);\n break;\n case "action":\n this.instruments.rscActionCounter?.add(1, attributes);\n break;\n }\n }\n recordRSCError(attributes) {\n this.instruments.rscErrorCounter?.add(1, attributes);\n }\n // Build Metrics\n recordBuild(durationMs, attributes) {\n this.instruments.buildDuration?.record(durationMs, attributes);\n }\n recordBundle(sizeKb, attributes) {\n this.instruments.bundleSizeHistogram?.record(sizeKb, attributes);\n this.instruments.bundleCounter?.add(1, attributes);\n }\n // Data Fetching Metrics\n recordDataFetch(durationMs, attributes) {\n this.instruments.dataFetchDuration?.record(durationMs, attributes);\n this.instruments.dataFetchCounter?.add(1, attributes);\n }\n recordDataFetchError(attributes) {\n this.instruments.dataFetchErrorCounter?.add(1, attributes);\n }\n // Security Metrics\n recordCorsRejection(attributes) {\n this.instruments.corsRejectionCounter?.add(1, attributes);\n }\n recordSecurityHeaders(attributes) {\n this.instruments.securityHeadersCounter?.add(1, attributes);\n }\n};\n\n// src/observability/metrics/manager.ts\nvar MetricsManager = class {\n constructor() {\n this.initialized = false;\n this.meter = null;\n this.api = null;\n this.recorder = null;\n this.instruments = this.createEmptyInstruments();\n this.runtimeState = {\n cacheSize: 0,\n activeRequests: 0\n };\n this.recorder = new MetricsRecorder(this.instruments, this.runtimeState);\n }\n createEmptyInstruments() {\n return {\n httpRequestCounter: null,\n httpRequestDuration: null,\n httpActiveRequests: null,\n cacheGetCounter: null,\n cacheHitCounter: null,\n cacheMissCounter: null,\n cacheSetCounter: null,\n cacheInvalidateCounter: null,\n cacheSizeGauge: null,\n renderDuration: null,\n renderCounter: null,\n renderErrorCounter: null,\n rscRenderDuration: null,\n rscStreamDuration: null,\n rscManifestCounter: null,\n rscPageCounter: null,\n rscStreamCounter: null,\n rscActionCounter: null,\n rscErrorCounter: null,\n buildDuration: null,\n bundleSizeHistogram: null,\n bundleCounter: null,\n dataFetchDuration: null,\n dataFetchCounter: null,\n dataFetchErrorCounter: null,\n corsRejectionCounter: null,\n securityHeadersCounter: null,\n memoryUsageGauge: null,\n heapUsageGauge: null\n };\n }\n async initialize(config = {}, adapter) {\n if (this.initialized) {\n serverLogger.debug("[metrics] Already initialized");\n return;\n }\n const finalConfig = loadConfig2(config, adapter);\n if (!finalConfig.enabled) {\n serverLogger.debug("[metrics] Metrics collection disabled");\n this.initialized = true;\n return;\n }\n try {\n this.api = await import("npm:@opentelemetry/api@1");\n this.meter = this.api.metrics.getMeter(finalConfig.prefix, "0.1.0");\n this.instruments = await initializeInstruments(\n this.meter,\n finalConfig,\n this.runtimeState\n );\n if (this.recorder) {\n this.recorder.instruments = this.instruments;\n }\n this.initialized = true;\n serverLogger.info("[metrics] OpenTelemetry metrics initialized", {\n exporter: finalConfig.exporter,\n endpoint: finalConfig.endpoint,\n prefix: finalConfig.prefix\n });\n } catch (error2) {\n serverLogger.warn("[metrics] Failed to initialize OpenTelemetry metrics", error2);\n this.initialized = true;\n }\n }\n isEnabled() {\n return this.initialized && this.meter !== null;\n }\n getRecorder() {\n return this.recorder;\n }\n getState() {\n return {\n initialized: this.initialized,\n cacheSize: this.runtimeState.cacheSize,\n activeRequests: this.runtimeState.activeRequests\n };\n }\n shutdown() {\n if (!this.initialized)\n return;\n try {\n serverLogger.info("[metrics] Metrics shutdown initiated");\n } catch (error2) {\n serverLogger.warn("[metrics] Error during metrics shutdown", error2);\n }\n }\n};\nvar metricsManager = new MetricsManager();\n\n// src/observability/metrics/index.ts\nvar getRecorder = () => metricsManager.getRecorder();\nfunction recordCorsRejection(attributes) {\n getRecorder()?.recordCorsRejection?.(attributes);\n}\nfunction recordSecurityHeaders(attributes) {\n getRecorder()?.recordSecurityHeaders?.(attributes);\n}\n\n// src/observability/auto-instrument/orchestrator.ts\ninit_utils();\n\n// src/observability/auto-instrument/http-instrumentation.ts\ninit_utils();\nimport {\n context as otContext,\n propagation,\n SpanKind,\n SpanStatusCode,\n trace\n} from "npm:@opentelemetry/api@1";\nvar tracer = trace.getTracer("veryfront-http");\n\n// src/security/http/cors/validators.ts\nasync function validateOrigin(requestOrigin, config) {\n if (!config) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (config === true) {\n const origin = requestOrigin || "*";\n return { allowedOrigin: origin, allowCredentials: false };\n }\n const corsConfig = config;\n if (!corsConfig.origin) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (!requestOrigin) {\n if (corsConfig.origin === "*") {\n return { allowedOrigin: "*", allowCredentials: false };\n }\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (corsConfig.origin === "*") {\n if (corsConfig.credentials) {\n serverLogger.warn("[CORS] Cannot use credentials with wildcard origin - denying");\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Cannot use credentials with wildcard origin"\n };\n }\n return { allowedOrigin: "*", allowCredentials: false };\n }\n if (typeof corsConfig.origin === "function") {\n try {\n const result = await corsConfig.origin(requestOrigin);\n if (typeof result === "string") {\n return {\n allowedOrigin: result,\n allowCredentials: corsConfig.credentials ?? false\n };\n }\n const allowed = result === true;\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin rejected by validation function"\n };\n } catch (error2) {\n serverLogger.error("[CORS] Origin validation function error", error2);\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Origin validation error"\n };\n }\n }\n if (Array.isArray(corsConfig.origin)) {\n const allowed = corsConfig.origin.includes(requestOrigin);\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin not in allowlist", {\n requestOrigin,\n allowedOrigins: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin not in allowlist"\n };\n }\n if (typeof corsConfig.origin === "string") {\n const allowed = corsConfig.origin === requestOrigin;\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin does not match", {\n requestOrigin,\n expectedOrigin: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin does not match"\n };\n }\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Invalid origin configuration"\n };\n}\nfunction validateOriginSync(requestOrigin, config) {\n if (!config) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (config === true) {\n const origin = requestOrigin || "*";\n return { allowedOrigin: origin, allowCredentials: false };\n }\n const corsConfig = config;\n if (!corsConfig.origin) {\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (!requestOrigin) {\n if (corsConfig.origin === "*") {\n return { allowedOrigin: "*", allowCredentials: false };\n }\n return { allowedOrigin: null, allowCredentials: false };\n }\n if (corsConfig.origin === "*") {\n if (corsConfig.credentials) {\n serverLogger.warn("[CORS] Cannot use credentials with wildcard origin - denying");\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Cannot use credentials with wildcard origin"\n };\n }\n return { allowedOrigin: "*", allowCredentials: false };\n }\n if (typeof corsConfig.origin === "function") {\n try {\n const result = corsConfig.origin(requestOrigin);\n if (result instanceof Promise) {\n serverLogger.warn(\n "[CORS] Async origin validators are not supported in synchronous contexts"\n );\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Async origin validators not supported"\n };\n }\n if (typeof result === "string") {\n return {\n allowedOrigin: result,\n allowCredentials: corsConfig.credentials ?? false\n };\n }\n const allowed = result === true;\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin rejected by validation function"\n };\n } catch (error2) {\n serverLogger.error("[CORS] Origin validation function error", error2);\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Origin validation error"\n };\n }\n }\n if (Array.isArray(corsConfig.origin)) {\n const allowed = corsConfig.origin.includes(requestOrigin);\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin not in allowlist (sync)", {\n requestOrigin,\n allowedOrigins: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin not in allowlist"\n };\n }\n if (typeof corsConfig.origin === "string") {\n const allowed = corsConfig.origin === requestOrigin;\n if (!allowed) {\n recordCorsRejection();\n serverLogger.warn("[CORS] Origin does not match (sync)", {\n requestOrigin,\n expectedOrigin: corsConfig.origin\n });\n }\n return {\n allowedOrigin: allowed ? requestOrigin : null,\n allowCredentials: allowed && (corsConfig.credentials ?? false),\n error: allowed ? void 0 : "Origin does not match"\n };\n }\n return {\n allowedOrigin: null,\n allowCredentials: false,\n error: "Invalid origin configuration"\n };\n}\n\n// src/security/http/cors/headers.ts\nasync function applyCORSHeaders(options) {\n const { request, response, headers: headersObj, config } = options;\n const validation = await validateOrigin(request.headers.get("origin"), config);\n if (!validation.allowedOrigin) {\n return response;\n }\n const headers = headersObj || (response ? new Headers(response.headers) : new Headers());\n headers.set("Access-Control-Allow-Origin", validation.allowedOrigin);\n if (validation.allowedOrigin !== "*") {\n const existingVary = headers.get("Vary");\n const varyValues = existingVary ? existingVary.split(",").map((v) => v.trim()) : [];\n if (!varyValues.includes("Origin")) {\n varyValues.push("Origin");\n headers.set("Vary", varyValues.join(", "));\n }\n }\n if (validation.allowCredentials && validation.allowedOrigin !== "*") {\n headers.set("Access-Control-Allow-Credentials", "true");\n }\n const corsConfig = typeof config === "object" ? config : null;\n if (corsConfig?.exposedHeaders && corsConfig.exposedHeaders.length > 0) {\n headers.set("Access-Control-Expose-Headers", corsConfig.exposedHeaders.join(", "));\n }\n if (response) {\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers\n });\n }\n return;\n}\nfunction applyCORSHeadersSync(options) {\n const { request, response, headers: headersObj, config } = options;\n const validation = validateOriginSync(request.headers.get("origin"), config);\n if (!validation.allowedOrigin) {\n return response;\n }\n const headers = headersObj || (response ? new Headers(response.headers) : new Headers());\n headers.set("Access-Control-Allow-Origin", validation.allowedOrigin);\n if (validation.allowedOrigin !== "*") {\n const existingVary = headers.get("Vary");\n const varyValues = existingVary ? existingVary.split(",").map((v) => v.trim()) : [];\n if (!varyValues.includes("Origin")) {\n varyValues.push("Origin");\n headers.set("Vary", varyValues.join(", "));\n }\n }\n if (validation.allowCredentials && validation.allowedOrigin !== "*") {\n headers.set("Access-Control-Allow-Credentials", "true");\n }\n const corsConfig = typeof config === "object" ? config : null;\n if (corsConfig?.exposedHeaders && corsConfig.exposedHeaders.length > 0) {\n headers.set("Access-Control-Expose-Headers", corsConfig.exposedHeaders.join(", "));\n }\n if (response) {\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers\n });\n }\n return;\n}\n\n// src/security/http/cors/constants.ts\ninit_config();\n\n// src/security/http/cors/preflight.ts\ninit_logger();\n\n// src/security/http/cors/middleware.ts\ninit_veryfront_error();\n\n// src/security/http/response/security-handler.ts\nfunction generateNonce() {\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n return btoa(String.fromCharCode(...array));\n}\nfunction buildCSP(isDev, nonce, cspUserHeader, config, adapter) {\n const envCsp = adapter?.env?.get?.("VERYFRONT_CSP");\n if (envCsp?.trim())\n return envCsp.replace(/{NONCE}/g, nonce);\n const defaultCsp = isDev ? [\n "default-src \'self\'",\n `style-src \'self\' \'nonce-${nonce}\' \'unsafe-inline\' https://esm.sh https://cdnjs.cloudflare.com https://cdn.veryfront.com https://cdn.jsdelivr.net`,\n "img-src \'self\' data: https://cdn.veryfront.com https://cdnjs.cloudflare.com",\n `script-src \'self\' \'nonce-${nonce}\' \'unsafe-eval\' https://esm.sh https://cdn.tailwindcss.com`,\n "connect-src \'self\' https://esm.sh ws://localhost:* wss://localhost:*",\n "font-src \'self\' data: https://cdnjs.cloudflare.com"\n ].join("; ") : [\n "default-src \'self\'",\n `style-src \'self\' \'nonce-${nonce}\'`,\n "img-src \'self\' data:",\n `script-src \'self\' \'nonce-${nonce}\'`,\n "connect-src \'self\'"\n ].join("; ");\n if (cspUserHeader?.trim()) {\n return `${cspUserHeader.replace(/{NONCE}/g, nonce)}; ${defaultCsp}`;\n }\n const cfgCsp = config?.csp;\n if (cfgCsp && typeof cfgCsp === "object") {\n const pieces = [];\n for (const [k, v] of Object.entries(cfgCsp)) {\n if (v === void 0)\n continue;\n const key = String(k).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n const val = Array.isArray(v) ? v.join(" ") : String(v);\n pieces.push(`${key} ${val}`.replace(/{NONCE}/g, nonce));\n }\n if (pieces.length > 0) {\n return `${pieces.join("; ")}; ${defaultCsp}`;\n }\n }\n return defaultCsp;\n}\nfunction getSecurityHeader(headerName, defaultValue, config, adapter) {\n const configKey = headerName.toLowerCase();\n const configValue = config?.[configKey];\n const envValue = adapter?.env?.get?.(`VERYFRONT_${headerName}`);\n return (typeof configValue === "string" ? configValue : void 0) || envValue || defaultValue;\n}\nfunction applySecurityHeaders(headers, isDev, nonce, cspUserHeader, config, adapter) {\n const getHeaderOverride = (name) => {\n const overrides = config?.headers;\n if (!overrides)\n return void 0;\n const lower = name.toLowerCase();\n for (const [key, value] of Object.entries(overrides)) {\n if (key.toLowerCase() === lower) {\n return value;\n }\n }\n return void 0;\n };\n const contentTypeOptions = getHeaderOverride("x-content-type-options") ?? "nosniff";\n headers.set("X-Content-Type-Options", contentTypeOptions);\n const frameOptions = getHeaderOverride("x-frame-options") ?? "DENY";\n headers.set("X-Frame-Options", frameOptions);\n const xssProtection = getHeaderOverride("x-xss-protection") ?? "1; mode=block";\n headers.set("X-XSS-Protection", xssProtection);\n const csp = buildCSP(isDev, nonce, cspUserHeader, config, adapter);\n if (csp) {\n headers.set("Content-Security-Policy", csp);\n }\n if (!isDev) {\n const hstsMaxAge = config?.hsts?.maxAge ?? 31536e3;\n const hstsIncludeSubDomains = config?.hsts?.includeSubDomains ?? true;\n const hstsPreload = config?.hsts?.preload ?? false;\n let hstsValue = `max-age=${hstsMaxAge}`;\n if (hstsIncludeSubDomains) {\n hstsValue += "; includeSubDomains";\n }\n if (hstsPreload) {\n hstsValue += "; preload";\n }\n const hstsOverride = getHeaderOverride("strict-transport-security");\n headers.set("Strict-Transport-Security", hstsOverride ?? hstsValue);\n }\n const coop = getSecurityHeader("COOP", "same-origin", config, adapter);\n const corp = getSecurityHeader("CORP", "same-origin", config, adapter);\n const coep = getSecurityHeader("COEP", "", config, adapter);\n headers.set("Cross-Origin-Opener-Policy", coop);\n headers.set("Cross-Origin-Resource-Policy", corp);\n if (coep) {\n headers.set("Cross-Origin-Embedder-Policy", coep);\n }\n if (config?.headers) {\n for (const [key, value] of Object.entries(config.headers)) {\n if (value === void 0)\n continue;\n headers.set(key, value);\n }\n }\n recordSecurityHeaders();\n}\n\n// src/security/http/response/cache-handler.ts\nfunction buildCacheControl(strategy) {\n let cacheControl;\n if (typeof strategy === "string") {\n switch (strategy) {\n case "no-cache":\n cacheControl = "no-cache, no-store, must-revalidate";\n break;\n case "no-store":\n cacheControl = "no-store";\n break;\n case "short":\n cacheControl = `public, max-age=${CACHE_DURATIONS.SHORT}`;\n break;\n case "medium":\n cacheControl = `public, max-age=${CACHE_DURATIONS.MEDIUM}`;\n break;\n case "long":\n cacheControl = `public, max-age=${CACHE_DURATIONS.LONG}`;\n break;\n case "immutable":\n cacheControl = `public, max-age=${CACHE_DURATIONS.LONG}, immutable`;\n break;\n case "none":\n cacheControl = "no-cache, no-store, must-revalidate";\n break;\n default:\n cacheControl = "public, max-age=0";\n }\n } else {\n const parts = [];\n parts.push(strategy.public !== false ? "public" : "private");\n parts.push(`max-age=${strategy.maxAge}`);\n if (strategy.immutable)\n parts.push("immutable");\n if (strategy.mustRevalidate)\n parts.push("must-revalidate");\n cacheControl = parts.join(", ");\n }\n return cacheControl;\n}\n\n// src/security/http/response/fluent-methods.ts\nfunction withCORS(req, corsConfig) {\n const config = corsConfig ?? this.securityConfig?.cors;\n applyCORSHeadersSync({\n request: req,\n headers: this.headers,\n config\n });\n return this;\n}\nfunction withCORSAsync(req) {\n return applyCORSHeaders({\n request: req,\n headers: this.headers,\n config: this.securityConfig?.cors\n }).then(() => this);\n}\nfunction withSecurity(config) {\n const cfg = config ?? this.securityConfig;\n applySecurityHeaders(\n this.headers,\n this.isDev,\n this.nonce,\n this.cspUserHeader,\n cfg,\n this.adapter\n );\n return this;\n}\nfunction withCache(strategy) {\n const cacheControl = buildCacheControl(strategy);\n this.headers.set("cache-control", cacheControl);\n return this;\n}\nfunction withETag(etag) {\n this.headers.set("ETag", etag);\n return this;\n}\nfunction withHeaders(headers) {\n if (headers instanceof Headers) {\n headers.forEach((value, key) => {\n this.headers.set(key, value);\n });\n } else if (Array.isArray(headers)) {\n headers.forEach(([key, value]) => {\n this.headers.set(key, value);\n });\n } else {\n Object.entries(headers).forEach(([key, value]) => {\n this.headers.set(key, value);\n });\n }\n return this;\n}\nfunction withStatus(status) {\n this.status = status;\n return this;\n}\nfunction withAllow(methods) {\n const methodStr = Array.isArray(methods) ? methods.join(", ") : methods;\n this.headers.set("Allow", methodStr);\n this.headers.set("Access-Control-Allow-Methods", methodStr);\n return this;\n}\n\n// src/security/http/response/response-methods.ts\nfunction json(data, status) {\n this.headers.set("content-type", CONTENT_TYPES.JSON);\n return new Response(JSON.stringify(data), {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction text(body, status) {\n this.headers.set("content-type", CONTENT_TYPES.TEXT);\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction html(body, status) {\n this.headers.set("content-type", CONTENT_TYPES.HTML);\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction javascript(code, status) {\n this.headers.set("content-type", CONTENT_TYPES.JAVASCRIPT);\n return new Response(code, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction withContentType(contentType, body, status) {\n this.headers.set("content-type", contentType);\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction build(body = null, status) {\n return new Response(body, {\n status: status ?? this.status,\n headers: this.headers\n });\n}\nfunction notModified(etag) {\n if (etag) {\n this.headers.set("ETag", etag);\n }\n return new Response(null, {\n status: 304,\n headers: this.headers\n });\n}\n\n// src/security/http/response/static-helpers.ts\ninit_veryfront_error();\nvar ResponseBuilderClass = null;\nfunction setResponseBuilderClass(builderClass) {\n ResponseBuilderClass = builderClass;\n}\nfunction error(status, message, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n const contentType = config?.contentType ?? CONTENT_TYPES.TEXT;\n if (contentType === CONTENT_TYPES.JSON) {\n return builder.json({ error: message }, status);\n } else if (contentType === CONTENT_TYPES.HTML) {\n return builder.html(message, status);\n }\n return builder.text(message, status);\n}\nfunction json2(data, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n if (config?.cache) {\n builder.withCache(config.cache);\n }\n if (config?.etag) {\n builder.withETag(config.etag);\n }\n return builder.json(data, config?.status);\n}\nfunction html2(body, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n if (config?.cache) {\n builder.withCache(config.cache);\n }\n if (config?.etag) {\n builder.withETag(config.etag);\n }\n return builder.html(body, config?.status);\n}\nfunction preflight(req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n const methods = config?.allowMethods ?? "GET,POST,PUT,PATCH,DELETE,OPTIONS";\n builder.withAllow(methods);\n const headers = config?.allowHeaders ?? req.headers.get("access-control-request-headers") ?? "Content-Type,Authorization";\n builder.headers.set(\n "Access-Control-Allow-Headers",\n Array.isArray(headers) ? headers.join(", ") : headers\n );\n return builder.build(null, 204);\n}\nfunction stream(streamData, req, config) {\n if (!ResponseBuilderClass) {\n throw toError(createError({\n type: "config",\n message: "ResponseBuilder class not initialized"\n }));\n }\n const builder = new ResponseBuilderClass(config);\n builder.withCORS(req, config?.corsConfig);\n if (config?.securityConfig !== void 0) {\n builder.withSecurity(config.securityConfig ?? void 0);\n }\n if (config?.cache) {\n builder.withCache(config.cache);\n }\n const contentType = config?.contentType ?? "application/octet-stream";\n return builder.withContentType(contentType, streamData);\n}\n\n// src/security/http/response/builder.ts\nvar ResponseBuilder = class {\n constructor(config) {\n this.withCORS = withCORS;\n this.withCORSAsync = withCORSAsync;\n this.withSecurity = withSecurity;\n this.withCache = withCache;\n this.withETag = withETag;\n this.withHeaders = withHeaders;\n this.withStatus = withStatus;\n this.withAllow = withAllow;\n this.json = json;\n this.text = text;\n this.html = html;\n this.javascript = javascript;\n this.withContentType = withContentType;\n this.build = build;\n this.notModified = notModified;\n this.headers = new Headers();\n this.status = 200;\n this.securityConfig = config?.securityConfig ?? null;\n this.isDev = config?.isDev ?? false;\n this.nonce = config?.nonce ?? generateNonce();\n this.cspUserHeader = config?.cspUserHeader ?? null;\n this.adapter = config?.adapter;\n }\n};\nResponseBuilder.error = error;\nResponseBuilder.json = json2;\nResponseBuilder.html = html2;\nResponseBuilder.preflight = preflight;\nResponseBuilder.stream = stream;\nsetResponseBuilderClass(ResponseBuilder);\n\n// src/security/http/base-handler.ts\ninit_utils();\n\n// src/core/constants/index.ts\ninit_constants();\n\n// src/core/constants/buffers.ts\nvar DEFAULT_MAX_BODY_SIZE_BYTES = 1024 * 1024;\nvar DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;\nvar PREFETCH_QUEUE_MAX_SIZE_BYTES = 1024 * 1024;\nvar MAX_BUNDLE_CHUNK_SIZE_BYTES = 4096 * 1024;\n\n// src/core/constants/limits.ts\nvar MAX_URL_LENGTH_FOR_VALIDATION = 2048;\n\n// src/security/input-validation/parsers.ts\nimport { z as z2 } from "zod";\n\n// src/security/input-validation/schemas.ts\nimport { z as z3 } from "zod";\nvar CommonSchemas = {\n /**\n * Valid email address (RFC-compliant, max 255 chars)\n */\n email: z3.string().email().max(255),\n /**\n * Valid UUID v4 identifier\n */\n uuid: z3.string().uuid(),\n /**\n * URL-safe slug (lowercase alphanumeric with hyphens)\n */\n slug: z3.string().regex(/^[a-z0-9-]+$/).min(1).max(100),\n /**\n * Valid HTTP/HTTPS URL (max 2048 chars)\n */\n url: z3.string().url().max(MAX_URL_LENGTH_FOR_VALIDATION),\n /**\n * International phone number (E.164 format)\n */\n phoneNumber: z3.string().regex(/^\\+?[1-9]\\d{1,14}$/),\n /**\n * Pagination parameters with defaults\n */\n pagination: z3.object({\n page: z3.coerce.number().int().positive().default(1),\n limit: z3.coerce.number().int().positive().max(100).default(10),\n sort: z3.string().optional(),\n order: z3.enum(["asc", "desc"]).optional()\n }),\n /**\n * Date range with validation\n */\n dateRange: z3.object({\n from: z3.string().datetime(),\n to: z3.string().datetime()\n }).refine((data) => new Date(data.from) <= new Date(data.to), {\n message: "From date must be before or equal to To date"\n }),\n /**\n * Strong password requirements\n * - Minimum 8 characters\n * - At least one uppercase letter\n * - At least one lowercase letter\n * - At least one number\n * - At least one special character\n */\n strongPassword: z3.string().min(8, "Password must be at least 8 characters").regex(/[A-Z]/, "Password must contain at least one uppercase letter").regex(/[a-z]/, "Password must contain at least one lowercase letter").regex(/[0-9]/, "Password must contain at least one number").regex(/[^A-Za-z0-9]/, "Password must contain at least one special character")\n};\n\n// src/security/http/auth.ts\ninit_veryfront_error();\n\n// src/security/http/config.ts\ninit_config();\ninit_utils();\n\n// src/security/http/middleware/config-loader.ts\ninit_utils();\n\n// src/security/http/middleware/etag.ts\ninit_hash();\n\n// src/security/http/middleware/content-types.ts\ninit_http();\n\n// src/security/path-validation.ts\ninit_utils();\n\n// src/security/secure-fs.ts\ninit_utils();\n\n// src/routing/api/module-loader/loader.ts\ninit_utils();\ninit_std_path();\n\n// src/routing/api/module-loader/esbuild-plugin.ts\ninit_utils();\ninit_utils();\ninit_utils();\n\n// src/routing/api/module-loader/http-validator.ts\ninit_veryfront_error();\n\n// src/routing/api/module-loader/security-config.ts\ninit_utils();\ninit_utils();\n\n// src/routing/api/module-loader/loader.ts\ninit_veryfront_error();\n\n// src/routing/api/route-discovery.ts\ninit_std_path();\n\n// src/core/utils/file-discovery.ts\ninit_std_path();\ninit_deno3();\n\n// src/routing/api/route-executor.ts\ninit_veryfront_error();\n\n// src/routing/api/method-validator.ts\ninit_utils();\n\n// src/routing/api/error-handler.ts\ninit_utils();\ninit_utils();\ninit_utils();\n\n// src/rendering/client/router.ts\nvar VeryfrontRouter = class {\n constructor(options = {}) {\n this.root = null;\n const globalOptions = this.loadGlobalOptions();\n this.options = { ...globalOptions, ...options };\n this.baseUrl = options.baseUrl || globalThis.location.origin;\n this.currentPath = globalThis.location.pathname;\n this.pageLoader = new PageLoader();\n this.navigationHandlers = new NavigationHandlers(\n this.options.prefetchDelay,\n this.options.prefetch\n );\n this.pageTransition = new PageTransition((root) => this.viewportPrefetch.setup(root));\n this.viewportPrefetch = new ViewportPrefetch(\n (path) => this.prefetch(path),\n this.options.prefetch\n );\n this.handleClick = this.navigationHandlers.createClickHandler({\n onNavigate: (url) => this.navigate(url),\n onPrefetch: (url) => this.prefetch(url)\n });\n this.handlePopState = this.navigationHandlers.createPopStateHandler({\n onNavigate: (url) => this.navigate(url, false),\n onPrefetch: (url) => this.prefetch(url)\n });\n this.handleMouseOver = this.navigationHandlers.createMouseOverHandler({\n onNavigate: (url) => this.navigate(url),\n onPrefetch: (url) => this.prefetch(url)\n });\n }\n loadGlobalOptions() {\n try {\n const options = globalThis.__VERYFRONT_ROUTER_OPTS__;\n if (!options) {\n rendererLogger.debug("[router] No global options configured");\n return {};\n }\n return options;\n } catch (error2) {\n rendererLogger.error("[router] Failed to read global options:", error2);\n return {};\n }\n }\n init() {\n rendererLogger.info("Initializing client-side router");\n const rootElement = document.getElementById("root");\n if (!rootElement) {\n rendererLogger.error("Root element not found");\n return;\n }\n const ReactDOMToUse = globalThis.ReactDOM || ReactDOM;\n this.root = ReactDOMToUse.createRoot(rootElement);\n document.addEventListener("click", this.handleClick);\n globalThis.addEventListener("popstate", this.handlePopState);\n document.addEventListener("mouseover", this.handleMouseOver);\n this.viewportPrefetch.setup(document);\n this.cacheCurrentPage();\n }\n cacheCurrentPage() {\n const pageData = extractPageDataFromScript();\n if (pageData) {\n this.pageLoader.setCache(this.currentPath, pageData);\n }\n }\n async navigate(url, pushState = true) {\n rendererLogger.info(`Navigating to ${url}`);\n this.navigationHandlers.saveScrollPosition(this.currentPath);\n this.options.onStart?.(url);\n if (pushState) {\n globalThis.history.pushState({}, "", url);\n }\n await this.loadPage(url);\n this.options.onNavigate?.(url);\n }\n async loadPage(path, updateUI = true) {\n if (this.pageLoader.isCached(path)) {\n rendererLogger.debug(`Loading ${path} from cache`);\n const data = this.pageLoader.getCached(path);\n if (!data) {\n rendererLogger.warn(`[router] Cache entry for ${path} was unexpectedly null, fetching fresh data`);\n } else {\n if (updateUI) {\n this.updatePage(data);\n }\n return;\n }\n }\n this.pageTransition.setLoadingState(true);\n try {\n const data = await this.pageLoader.loadPage(path);\n if (updateUI) {\n this.updatePage(data);\n }\n this.currentPath = path;\n this.options.onComplete?.(path);\n } catch (error2) {\n rendererLogger.error(`Failed to load ${path}`, error2);\n this.options.onError?.(error2);\n this.pageTransition.showError(error2);\n } finally {\n this.pageTransition.setLoadingState(false);\n }\n }\n async prefetch(path) {\n await this.pageLoader.prefetch(path);\n }\n updatePage(data) {\n if (!this.root)\n return;\n const isPopState = this.navigationHandlers.isPopState();\n const scrollY = this.navigationHandlers.getScrollPosition(this.currentPath);\n this.pageTransition.updatePage(data, isPopState, scrollY);\n this.navigationHandlers.clearPopStateFlag();\n }\n destroy() {\n document.removeEventListener("click", this.handleClick);\n globalThis.removeEventListener("popstate", this.handlePopState);\n document.removeEventListener("mouseover", this.handleMouseOver);\n this.viewportPrefetch.disconnect();\n this.pageLoader.clearCache();\n this.navigationHandlers.clear();\n this.pageTransition.destroy();\n }\n};\nif (typeof window !== "undefined" && globalThis.document) {\n const router = new VeryfrontRouter();\n if (document.readyState === "loading") {\n document.addEventListener("DOMContentLoaded", () => router.init());\n } else {\n router.init();\n }\n globalThis.veryFrontRouter = router;\n}\nexport {\n VeryfrontRouter\n};\n';
|
|
14088
|
+
CLIENT_PREFETCH_BUNDLE = '// src/rendering/client/browser-logger.ts\nvar ConditionalBrowserLogger = class {\n constructor(prefix, level) {\n this.prefix = prefix;\n this.level = level;\n }\n debug(message, ...args) {\n if (this.level <= 0 /* DEBUG */) {\n console.debug?.(`[${this.prefix}] DEBUG: ${message}`, ...args);\n }\n }\n info(message, ...args) {\n if (this.level <= 1 /* INFO */) {\n console.log?.(`[${this.prefix}] ${message}`, ...args);\n }\n }\n warn(message, ...args) {\n if (this.level <= 2 /* WARN */) {\n console.warn?.(`[${this.prefix}] WARN: ${message}`, ...args);\n }\n }\n error(message, ...args) {\n if (this.level <= 3 /* ERROR */) {\n console.error?.(`[${this.prefix}] ERROR: ${message}`, ...args);\n }\n }\n};\nfunction getBrowserLogLevel() {\n if (typeof window === "undefined") {\n return 2 /* WARN */;\n }\n const windowObject = window;\n const isDevelopment = windowObject.__VERYFRONT_DEV__ || windowObject.__RSC_DEV__;\n if (!isDevelopment) {\n return 2 /* WARN */;\n }\n const isDebugEnabled = windowObject.__VERYFRONT_DEBUG__ || windowObject.__RSC_DEBUG__;\n return isDebugEnabled ? 0 /* DEBUG */ : 1 /* INFO */;\n}\nvar defaultLevel = getBrowserLogLevel();\nvar rscLogger = new ConditionalBrowserLogger("RSC", defaultLevel);\nvar prefetchLogger = new ConditionalBrowserLogger("PREFETCH", defaultLevel);\nvar hydrateLogger = new ConditionalBrowserLogger("HYDRATE", defaultLevel);\nvar browserLogger = new ConditionalBrowserLogger("VERYFRONT", defaultLevel);\n\n// src/rendering/client/prefetch/link-observer.ts\nvar LinkObserver = class {\n constructor(options, prefetchedUrls) {\n this.intersectionObserver = null;\n this.mutationObserver = null;\n this.pendingTimeouts = /* @__PURE__ */ new Map();\n this.elementTimeoutMap = /* @__PURE__ */ new WeakMap();\n this.timeoutCounter = 0;\n this.options = options;\n this.prefetchedUrls = prefetchedUrls;\n }\n init() {\n this.createIntersectionObserver();\n this.observeLinks();\n this.setupMutationObserver();\n }\n createIntersectionObserver() {\n this.intersectionObserver = new IntersectionObserver(\n (entries) => this.handleIntersection(entries),\n { rootMargin: this.options.rootMargin }\n );\n }\n handleIntersection(entries) {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n const target = entry.target;\n let isAnchor = false;\n if (typeof HTMLAnchorElement !== "undefined") {\n isAnchor = target instanceof HTMLAnchorElement;\n } else {\n isAnchor = target.tagName === "A";\n }\n if (!isAnchor) {\n continue;\n }\n const link = target;\n const timeoutKey = this.timeoutCounter++;\n const timeoutId = setTimeout(() => {\n this.pendingTimeouts.delete(timeoutKey);\n this.elementTimeoutMap.delete(link);\n this.options.onLinkVisible(link);\n }, this.options.delay);\n this.pendingTimeouts.set(timeoutKey, timeoutId);\n this.elementTimeoutMap.set(link, timeoutKey);\n }\n }\n }\n observeLinks() {\n const links = document.querySelectorAll(\'a[href^="/"], a[href^="./"]\');\n links.forEach((link) => {\n if (this.isValidLink(link)) {\n this.intersectionObserver?.observe(link);\n }\n });\n }\n setupMutationObserver() {\n this.mutationObserver = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (mutation.type === "childList") {\n mutation.addedNodes.forEach((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n this.observeElement(node);\n }\n });\n mutation.removedNodes.forEach((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n this.clearElementTimeouts(node);\n }\n });\n }\n }\n });\n this.mutationObserver.observe(document.body, {\n childList: true,\n subtree: true\n });\n }\n clearElementTimeouts(element) {\n if (element.tagName === "A") {\n const timeoutKey = this.elementTimeoutMap.get(element);\n if (timeoutKey !== void 0) {\n const timeoutId = this.pendingTimeouts.get(timeoutKey);\n if (timeoutId) {\n clearTimeout(timeoutId);\n this.pendingTimeouts.delete(timeoutKey);\n }\n this.elementTimeoutMap.delete(element);\n }\n }\n const links = element.querySelectorAll("a");\n links.forEach((link) => {\n const timeoutKey = this.elementTimeoutMap.get(link);\n if (timeoutKey !== void 0) {\n const timeoutId = this.pendingTimeouts.get(timeoutKey);\n if (timeoutId) {\n clearTimeout(timeoutId);\n this.pendingTimeouts.delete(timeoutKey);\n }\n this.elementTimeoutMap.delete(link);\n }\n });\n }\n observeElement(element) {\n const isAnchor = typeof HTMLAnchorElement !== "undefined" ? element instanceof HTMLAnchorElement : element.tagName === "A";\n if (isAnchor && this.isValidLink(element)) {\n this.intersectionObserver?.observe(element);\n }\n const links = element.querySelectorAll(\'a[href^="/"], a[href^="./"]\');\n links.forEach((link) => {\n const isLinkAnchor = typeof HTMLAnchorElement !== "undefined" ? link instanceof HTMLAnchorElement : link.tagName === "A";\n if (isLinkAnchor && this.isValidLink(link)) {\n this.intersectionObserver?.observe(link);\n }\n });\n }\n isValidLink(link) {\n if (link.hostname !== globalThis.location.hostname)\n return false;\n if (link.hasAttribute("download"))\n return false;\n if (link.target === "_blank")\n return false;\n const url = link.href;\n if (this.prefetchedUrls.has(url))\n return false;\n if (url === globalThis.location.href)\n return false;\n if (link.hash && link.pathname === globalThis.location.pathname) {\n return false;\n }\n if (link.dataset.noPrefetch)\n return false;\n return true;\n }\n destroy() {\n for (const [_, timeoutId] of this.pendingTimeouts) {\n clearTimeout(timeoutId);\n }\n this.pendingTimeouts.clear();\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect();\n this.intersectionObserver = null;\n }\n if (this.mutationObserver) {\n this.mutationObserver.disconnect();\n this.mutationObserver = null;\n }\n }\n};\n\n// src/rendering/client/prefetch/network-utils.ts\nvar NetworkUtils = class {\n constructor(allowedNetworks = ["4g", "wifi", "ethernet"]) {\n this.allowedNetworks = allowedNetworks;\n this.networkInfo = this.getNetworkConnection();\n }\n getNavigatorWithConnection() {\n if (typeof globalThis.navigator === "undefined") {\n return null;\n }\n return globalThis.navigator;\n }\n getNetworkConnection() {\n const nav = this.getNavigatorWithConnection();\n return nav?.connection || nav?.mozConnection || nav?.webkitConnection || null;\n }\n shouldPrefetch() {\n const nav = this.getNavigatorWithConnection();\n if (nav?.connection?.saveData) {\n return false;\n }\n if (this.networkInfo) {\n const effectiveType = this.networkInfo.effectiveType;\n if (effectiveType !== void 0 && !this.allowedNetworks.includes(effectiveType)) {\n return false;\n }\n }\n return true;\n }\n onNetworkChange(callback) {\n if (this.networkInfo?.addEventListener) {\n this.networkInfo.addEventListener("change", callback);\n }\n }\n getNetworkInfo() {\n return this.networkInfo;\n }\n};\n\n// src/core/utils/constants/cache.ts\nvar SECONDS_PER_MINUTE = 60;\nvar MINUTES_PER_HOUR = 60;\nvar HOURS_PER_DAY = 24;\nvar MS_PER_SECOND = 1e3;\nvar COMPONENT_LOADER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar MDX_RENDERER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar RENDERER_CORE_TTL_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar TSX_LAYOUT_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar DATA_FETCHING_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar MDX_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar MDX_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar BUNDLE_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar BUNDLE_MANIFEST_PROD_TTL_MS = 7 * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar BUNDLE_MANIFEST_DEV_TTL_MS = MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar SERVER_ACTION_DEFAULT_TTL_SEC = MINUTES_PER_HOUR * SECONDS_PER_MINUTE;\nvar ONE_DAY_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;\nvar LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;\n\n// src/core/utils/constants/http.ts\nvar KB_IN_BYTES = 1024;\nvar PREFETCH_MAX_SIZE_BYTES = 200 * KB_IN_BYTES;\nvar PREFETCH_DEFAULT_TIMEOUT_MS = 1e4;\nvar PREFETCH_DEFAULT_DELAY_MS = 200;\n\n// src/core/utils/constants/hmr.ts\nvar HMR_MAX_MESSAGE_SIZE_BYTES = 1024 * KB_IN_BYTES;\n\n// src/core/utils/constants/network.ts\nvar BYTES_PER_MB = 1024 * 1024;\n\n// src/core/constants/buffers.ts\nvar DEFAULT_MAX_BODY_SIZE_BYTES = 1024 * 1024;\nvar DEFAULT_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;\nvar PREFETCH_QUEUE_MAX_SIZE_BYTES = 1024 * 1024;\nvar MAX_BUNDLE_CHUNK_SIZE_BYTES = 4096 * 1024;\n\n// src/rendering/client/prefetch/prefetch-queue.ts\nvar DEFAULT_OPTIONS = {\n maxConcurrent: 4,\n maxSize: PREFETCH_QUEUE_MAX_SIZE_BYTES,\n timeout: 5e3\n};\nfunction isAbortError(error) {\n return Boolean(\n error && typeof error === "object" && "name" in error && error.name === "AbortError"\n );\n}\nvar PrefetchQueue = class {\n constructor(options = {}, prefetchedUrls) {\n this.controllers = /* @__PURE__ */ new Map();\n this.concurrent = 0;\n this.stopped = false;\n this.options = { ...DEFAULT_OPTIONS, ...options };\n this.prefetchedUrls = prefetchedUrls ?? /* @__PURE__ */ new Set();\n }\n setResourceCallback(callback) {\n this.onResourcesFetched = callback;\n }\n enqueue(url) {\n void this.prefetch(url);\n }\n has(url) {\n return this.prefetchedUrls.has(url) || this.controllers.has(url);\n }\n get size() {\n return this.getQueueSize();\n }\n clear() {\n this.stopAll();\n this.prefetchedUrls.clear();\n }\n start() {\n this.stopped = false;\n }\n stop() {\n this.stopped = true;\n this.stopAll();\n }\n getQueueSize() {\n return this.controllers.size;\n }\n getConcurrentCount() {\n return this.concurrent;\n }\n async prefetchLink(link) {\n if (this.stopped) {\n return;\n }\n const url = link.href;\n if (!url || this.controllers.has(url) || this.prefetchedUrls.has(url)) {\n return;\n }\n if (this.concurrent >= this.options.maxConcurrent) {\n prefetchLogger.debug?.(`Prefetch queue full, skipping ${url}`);\n return;\n }\n let parsedUrl;\n try {\n parsedUrl = new URL(url);\n } catch (_error) {\n prefetchLogger.debug?.(`Invalid prefetch URL ${url}`);\n return;\n }\n const controller = new AbortController();\n this.controllers.set(url, controller);\n this.concurrent += 1;\n const timeoutId = this.options.timeout > 0 ? setTimeout(() => controller.abort(), this.options.timeout) : void 0;\n try {\n const response = await fetch(parsedUrl.toString(), {\n method: "GET",\n signal: controller.signal,\n headers: { "X-Veryfront-Prefetch": "1" }\n });\n if (!response.ok) {\n return;\n }\n if (this.isResponseTooLarge(response)) {\n prefetchLogger.debug?.(`Prefetch too large, skipping ${url}`);\n return;\n }\n this.prefetchedUrls.add(url);\n if (this.onResourcesFetched) {\n try {\n await this.onResourcesFetched(response, url);\n } catch (callbackError) {\n prefetchLogger.error?.(`Prefetch callback failed for ${url}`, callbackError);\n }\n }\n } catch (error) {\n if (!isAbortError(error)) {\n prefetchLogger.error?.(`Failed to prefetch ${url}`, error);\n }\n } finally {\n if (timeoutId !== void 0) {\n clearTimeout(timeoutId);\n }\n this.controllers.delete(url);\n this.concurrent = Math.max(0, this.concurrent - 1);\n }\n }\n async prefetch(url) {\n const link = typeof document !== "undefined" ? document.createElement("a") : { href: url };\n link.href = url;\n await this.prefetchLink(link);\n }\n stopAll() {\n for (const controller of this.controllers.values()) {\n controller.abort();\n }\n this.controllers.clear();\n this.concurrent = 0;\n }\n isResponseTooLarge(response) {\n const rawLength = response.headers.get("content-length");\n if (rawLength === null) {\n return false;\n }\n const size = Number.parseInt(rawLength, 10);\n if (!Number.isFinite(size)) {\n return false;\n }\n return size > this.options.maxSize;\n }\n};\nvar prefetchQueue = new PrefetchQueue();\n\n// src/rendering/client/prefetch/resource-hints.ts\nvar ResourceHintsManager = class {\n constructor() {\n this.appliedHints = /* @__PURE__ */ new Set();\n }\n applyResourceHints(hints) {\n for (const hint of hints) {\n const key = `${hint.type}:${hint.href}`;\n if (this.appliedHints.has(key))\n continue;\n const existing = document.querySelector(`link[rel="${hint.type}"][href="${hint.href}"]`);\n if (existing) {\n this.appliedHints.add(key);\n continue;\n }\n this.createAndAppendHint(hint);\n this.appliedHints.add(key);\n prefetchLogger.debug(`Added resource hint: ${hint.type} ${hint.href}`);\n }\n }\n createAndAppendHint(hint) {\n if (!document.head) {\n prefetchLogger.warn("document.head is not available, skipping resource hint");\n return;\n }\n const link = document.createElement("link");\n link.rel = hint.type;\n link.href = hint.href;\n if (hint.as)\n link.setAttribute("as", hint.as);\n if (hint.crossOrigin)\n link.setAttribute("crossorigin", hint.crossOrigin);\n if (hint.media)\n link.setAttribute("media", hint.media);\n document.head.appendChild(link);\n }\n extractResourceHints(html, prefetchedUrls) {\n try {\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, "text/html");\n const hints = [];\n this.extractPreloadLinks(doc, prefetchedUrls, hints);\n this.extractScripts(doc, prefetchedUrls, hints);\n this.extractStylesheets(doc, prefetchedUrls, hints);\n return hints;\n } catch (error) {\n prefetchLogger.error("Failed to parse prefetched page", error);\n return [];\n }\n }\n isValidResourceHintType(rel) {\n return rel === "prefetch" || rel === "preload" || rel === "preconnect" || rel === "dns-prefetch";\n }\n extractPreloadLinks(doc, prefetchedUrls, hints) {\n doc.querySelectorAll(\'link[rel="preload"], link[rel="prefetch"]\').forEach((link) => {\n const htmlLink = link;\n const href = htmlLink.href;\n if (href && !prefetchedUrls.has(href) && this.isValidResourceHintType(htmlLink.rel)) {\n hints.push({\n type: htmlLink.rel,\n href,\n as: htmlLink.getAttribute("as") || void 0\n });\n }\n });\n }\n extractScripts(doc, prefetchedUrls, hints) {\n doc.querySelectorAll("script[src]").forEach((script) => {\n const src = script.src;\n if (src && !prefetchedUrls.has(src)) {\n hints.push({ type: "prefetch", href: src, as: "script" });\n }\n });\n }\n extractStylesheets(doc, prefetchedUrls, hints) {\n doc.querySelectorAll(\'link[rel="stylesheet"]\').forEach((link) => {\n const href = link.href;\n if (href && !prefetchedUrls.has(href)) {\n hints.push({ type: "prefetch", href, as: "style" });\n }\n });\n }\n static generateResourceHints(_route, assets) {\n const hints = [\n \'<link rel="dns-prefetch" href="https://cdn.jsdelivr.net">\',\n \'<link rel="dns-prefetch" href="https://esm.sh">\',\n \'<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>\'\n ];\n for (const asset of assets) {\n if (asset.endsWith(".js")) {\n hints.push(`<link rel="modulepreload" href="${asset}">`);\n } else if (asset.endsWith(".css")) {\n hints.push(`<link rel="preload" as="style" href="${asset}">`);\n } else if (asset.match(/\\.(woff2?|ttf|otf)$/)) {\n hints.push(`<link rel="preload" as="font" href="${asset}" crossorigin>`);\n }\n }\n return hints.join("\\n");\n }\n};\n\n// src/core/utils/runtime-guards.ts\nfunction hasDenoRuntime(global) {\n return typeof global === "object" && global !== null && "Deno" in global && typeof global.Deno?.env?.get === "function";\n}\nfunction hasNodeProcess(global) {\n return typeof global === "object" && global !== null && "process" in global && typeof global.process?.env === "object";\n}\n\n// src/core/utils/logger/env.ts\nfunction getEnvironmentVariable(name) {\n try {\n if (typeof Deno !== "undefined" && hasDenoRuntime(globalThis)) {\n const value = globalThis.Deno?.env.get(name);\n return value === "" ? void 0 : value;\n }\n if (hasNodeProcess(globalThis)) {\n const value = globalThis.process?.env[name];\n return value === "" ? void 0 : value;\n }\n } catch {\n return void 0;\n }\n return void 0;\n}\n\n// src/core/utils/logger/logger.ts\nvar cachedLogLevel;\nfunction resolveLogLevel(force = false) {\n if (force || cachedLogLevel === void 0) {\n cachedLogLevel = getDefaultLevel();\n }\n return cachedLogLevel;\n}\nvar ConsoleLogger = class {\n constructor(prefix, level = resolveLogLevel()) {\n this.prefix = prefix;\n this.level = level;\n }\n setLevel(level) {\n this.level = level;\n }\n getLevel() {\n return this.level;\n }\n debug(message, ...args) {\n if (this.level <= 0 /* DEBUG */) {\n console.debug(`[${this.prefix}] DEBUG: ${message}`, ...args);\n }\n }\n info(message, ...args) {\n if (this.level <= 1 /* INFO */) {\n console.log(`[${this.prefix}] ${message}`, ...args);\n }\n }\n warn(message, ...args) {\n if (this.level <= 2 /* WARN */) {\n console.warn(`[${this.prefix}] WARN: ${message}`, ...args);\n }\n }\n error(message, ...args) {\n if (this.level <= 3 /* ERROR */) {\n console.error(`[${this.prefix}] ERROR: ${message}`, ...args);\n }\n }\n async time(label, fn) {\n const start = performance.now();\n try {\n const result = await fn();\n const end = performance.now();\n this.debug(`${label} completed in ${(end - start).toFixed(2)}ms`);\n return result;\n } catch (error) {\n const end = performance.now();\n this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, error);\n throw error;\n }\n }\n};\nfunction parseLogLevel(levelString) {\n if (!levelString)\n return void 0;\n const upper = levelString.toUpperCase();\n switch (upper) {\n case "DEBUG":\n return 0 /* DEBUG */;\n case "WARN":\n return 2 /* WARN */;\n case "ERROR":\n return 3 /* ERROR */;\n case "INFO":\n return 1 /* INFO */;\n default:\n return void 0;\n }\n}\nvar getDefaultLevel = () => {\n const envLevel = getEnvironmentVariable("LOG_LEVEL");\n const parsedLevel = parseLogLevel(envLevel);\n if (parsedLevel !== void 0)\n return parsedLevel;\n const debugFlag = getEnvironmentVariable("VERYFRONT_DEBUG");\n if (debugFlag === "1" || debugFlag === "true")\n return 0 /* DEBUG */;\n return 1 /* INFO */;\n};\nvar trackedLoggers = /* @__PURE__ */ new Set();\nfunction createLogger(prefix) {\n const logger2 = new ConsoleLogger(prefix);\n trackedLoggers.add(logger2);\n return logger2;\n}\nvar cliLogger = createLogger("CLI");\nvar serverLogger = createLogger("SERVER");\nvar rendererLogger = createLogger("RENDERER");\nvar bundlerLogger = createLogger("BUNDLER");\nvar agentLogger = createLogger("AGENT");\nvar logger = createLogger("VERYFRONT");\n\n// deno.json\nvar deno_default = {\n name: "veryfront",\n version: "0.0.6",\n nodeModulesDir: "auto",\n workspace: [\n "./examples/async-worker-redis",\n "./examples/knowledge-base",\n "./examples/form-handling",\n "./examples/middleware-demo",\n "./examples/coding-agent",\n "./examples/durable-workflows"\n ],\n exports: {\n ".": "./src/index.ts",\n "./cli": "./src/cli/main.ts",\n "./server": "./src/server/index.ts",\n "./middleware": "./src/middleware/index.ts",\n "./components": "./src/react/components/index.ts",\n "./data": "./src/data/index.ts",\n "./config": "./src/core/config/index.ts",\n "./ai": "./src/ai/index.ts",\n "./ai/client": "./src/ai/client.ts",\n "./ai/react": "./src/ai/react/index.ts",\n "./ai/primitives": "./src/ai/react/primitives/index.ts",\n "./ai/components": "./src/ai/react/components/index.ts",\n "./ai/production": "./src/ai/production/index.ts",\n "./ai/dev": "./src/ai/dev/index.ts",\n "./ai/workflow": "./src/ai/workflow/index.ts",\n "./ai/workflow/react": "./src/ai/workflow/react/index.ts"\n },\n imports: {\n "@veryfront": "./src/index.ts",\n "@veryfront/": "./src/",\n "@veryfront/ai": "./src/ai/index.ts",\n "@veryfront/ai/": "./src/ai/",\n "@veryfront/platform": "./src/platform/index.ts",\n "@veryfront/platform/": "./src/platform/",\n "@veryfront/types": "./src/core/types/index.ts",\n "@veryfront/types/": "./src/core/types/",\n "@veryfront/utils": "./src/core/utils/index.ts",\n "@veryfront/utils/": "./src/core/utils/",\n "@veryfront/middleware": "./src/middleware/index.ts",\n "@veryfront/middleware/": "./src/middleware/",\n "@veryfront/errors": "./src/core/errors/index.ts",\n "@veryfront/errors/": "./src/core/errors/",\n "@veryfront/config": "./src/core/config/index.ts",\n "@veryfront/config/": "./src/core/config/",\n "@veryfront/observability": "./src/observability/index.ts",\n "@veryfront/observability/": "./src/observability/",\n "@veryfront/routing": "./src/routing/index.ts",\n "@veryfront/routing/": "./src/routing/",\n "@veryfront/transforms": "./src/build/transforms/index.ts",\n "@veryfront/transforms/": "./src/build/transforms/",\n "@veryfront/data": "./src/data/index.ts",\n "@veryfront/data/": "./src/data/",\n "@veryfront/security": "./src/security/index.ts",\n "@veryfront/security/": "./src/security/",\n "@veryfront/components": "./src/react/components/index.ts",\n "@veryfront/react": "./src/react/index.ts",\n "@veryfront/react/": "./src/react/",\n "@veryfront/html": "./src/html/index.ts",\n "@veryfront/html/": "./src/html/",\n "@veryfront/rendering": "./src/rendering/index.ts",\n "@veryfront/rendering/": "./src/rendering/",\n "@veryfront/build": "./src/build/index.ts",\n "@veryfront/build/": "./src/build/",\n "@veryfront/server": "./src/server/index.ts",\n "@veryfront/server/": "./src/server/",\n "@veryfront/modules": "./src/module-system/index.ts",\n "@veryfront/modules/": "./src/module-system/",\n "@veryfront/compat/console": "./src/platform/compat/console/index.ts",\n "@veryfront/compat/": "./src/platform/compat/",\n "std/": "https://deno.land/std@0.220.0/",\n "@std/path": "https://deno.land/std@0.220.0/path/mod.ts",\n "@std/testing/bdd.ts": "https://deno.land/std@0.220.0/testing/bdd.ts",\n "@std/expect": "https://deno.land/std@0.220.0/expect/mod.ts",\n csstype: "https://esm.sh/csstype@3.2.3",\n "@types/react": "https://esm.sh/@types/react@18.3.27?deps=csstype@3.2.3",\n "@types/react-dom": "https://esm.sh/@types/react-dom@18.3.7?deps=csstype@3.2.3",\n react: "https://esm.sh/react@18.3.1",\n "react-dom": "https://esm.sh/react-dom@18.3.1",\n "react-dom/server": "https://esm.sh/react-dom@18.3.1/server",\n "react-dom/client": "https://esm.sh/react-dom@18.3.1/client",\n "react/jsx-runtime": "https://esm.sh/react@18.3.1/jsx-runtime",\n "react/jsx-dev-runtime": "https://esm.sh/react@18.3.1/jsx-dev-runtime",\n "@mdx-js/mdx": "https://esm.sh/@mdx-js/mdx@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "@mdx-js/react": "https://esm.sh/@mdx-js/react@3.0.0?deps=react@18.3.1,react-dom@18.3.1",\n "unist-util-visit": "https://esm.sh/unist-util-visit@5.0.0",\n "mdast-util-to-string": "https://esm.sh/mdast-util-to-string@4.0.0",\n "github-slugger": "https://esm.sh/github-slugger@2.0.0",\n "remark-gfm": "https://esm.sh/remark-gfm@4.0.1",\n "remark-frontmatter": "https://esm.sh/remark-frontmatter@5.0.0",\n "rehype-highlight": "https://esm.sh/rehype-highlight@7.0.2",\n "rehype-slug": "https://esm.sh/rehype-slug@6.0.0",\n esbuild: "https://deno.land/x/esbuild@v0.20.1/wasm.js",\n "esbuild/mod.js": "https://deno.land/x/esbuild@v0.20.1/mod.js",\n "es-module-lexer": "https://esm.sh/es-module-lexer@1.5.0",\n zod: "https://esm.sh/zod@3.22.0",\n "mime-types": "https://esm.sh/mime-types@2.1.35",\n mdast: "https://esm.sh/@types/mdast@4.0.3",\n hast: "https://esm.sh/@types/hast@3.0.3",\n unist: "https://esm.sh/@types/unist@3.0.2",\n unified: "https://esm.sh/unified@11.0.5?dts",\n ai: "https://esm.sh/ai@5.0.76",\n "ai/react": "https://esm.sh/@ai-sdk/react@2.0.59",\n "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",\n "@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.4",\n unocss: "https://esm.sh/unocss@0.59.0",\n "@unocss/core": "https://esm.sh/@unocss/core@0.59.0",\n "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0"\n },\n compilerOptions: {\n jsx: "react-jsx",\n jsxImportSource: "react",\n strict: true,\n noImplicitAny: true,\n noUncheckedIndexedAccess: true,\n types: [],\n lib: [\n "deno.window",\n "dom",\n "dom.iterable",\n "dom.asynciterable",\n "deno.ns"\n ]\n },\n tasks: {\n setup: "deno run --allow-all scripts/setup.ts",\n dev: "deno run --allow-all --no-lock --unstable-net --unstable-worker-options src/cli/main.ts dev",\n build: "deno compile --allow-all --output ../../bin/veryfront src/cli/main.ts",\n "build:npm": "deno run -A scripts/build-npm.ts",\n test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",\n "test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",\n "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",\n "test:batches": "deno run --allow-all scripts/test-batches.ts",\n "test:unsafe": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net",\n "test:coverage": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:unit": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --ignore=tests --unstable-worker-options --unstable-net || exit 1",\n "test:coverage:integration": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage tests --unstable-worker-options --unstable-net || exit 1",\n "coverage:report": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --lcov > coverage/lcov.info && deno run --allow-read scripts/check-coverage.ts 80",\n "coverage:html": "deno coverage coverage --include=src/ --exclude=tests --exclude=src/**/*_test.ts --exclude=src/**/*_test.tsx --exclude=src/**/*.test.ts --exclude=src/**/*.test.tsx --html",\n lint: "deno lint src/",\n fmt: "deno fmt src/",\n typecheck: "deno check src/index.ts src/cli/main.ts src/server/index.ts src/routing/api/index.ts src/rendering/index.ts src/platform/index.ts src/platform/adapters/index.ts src/build/index.ts src/build/production-build/index.ts src/build/transforms/index.ts src/core/config/index.ts src/core/utils/index.ts src/data/index.ts src/security/index.ts src/middleware/index.ts src/server/handlers/dev/index.ts src/server/handlers/request/api/index.ts src/rendering/cache/index.ts src/rendering/cache/stores/index.ts src/rendering/rsc/actions/index.ts src/html/index.ts src/module-system/index.ts",\n "docs:check-links": "deno run -A scripts/check-doc-links.ts",\n "lint:ban-console": "deno run --allow-read scripts/ban-console.ts",\n "lint:ban-deep-imports": "deno run --allow-read scripts/ban-deep-imports.ts",\n "lint:ban-internal-root-imports": "deno run --allow-read scripts/ban-internal-root-imports.ts",\n "lint:check-awaits": "deno run --allow-read scripts/check-unawaited-promises.ts",\n "check:circular": "deno run -A jsr:@cunarist/deno-circular-deps src/index.ts"\n },\n lint: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n rules: {\n tags: [\n "recommended"\n ],\n include: [\n "ban-untagged-todo"\n ],\n exclude: [\n "no-explicit-any",\n "no-process-global",\n "no-console"\n ]\n }\n },\n fmt: {\n include: [\n "src/**/*.ts",\n "src/**/*.tsx"\n ],\n exclude: [\n "dist/",\n "coverage/"\n ],\n options: {\n useTabs: false,\n lineWidth: 100,\n indentWidth: 2,\n semiColons: true,\n singleQuote: false,\n proseWrap: "preserve"\n }\n }\n};\n\n// src/core/utils/version.ts\nvar VERSION = typeof deno_default.version === "string" ? deno_default.version : "0.0.0";\n\n// src/core/utils/bundle-manifest.ts\nvar InMemoryBundleManifestStore = class {\n constructor() {\n this.metadata = /* @__PURE__ */ new Map();\n this.code = /* @__PURE__ */ new Map();\n this.sourceIndex = /* @__PURE__ */ new Map();\n }\n getBundleMetadata(key) {\n const entry = this.metadata.get(key);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.metadata.delete(key);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleMetadata(key, metadata, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.metadata.set(key, { value: metadata, expiry });\n if (!this.sourceIndex.has(metadata.source)) {\n this.sourceIndex.set(metadata.source, /* @__PURE__ */ new Set());\n }\n this.sourceIndex.get(metadata.source).add(key);\n return Promise.resolve();\n }\n getBundleCode(hash) {\n const entry = this.code.get(hash);\n if (!entry)\n return Promise.resolve(void 0);\n if (entry.expiry && Date.now() > entry.expiry) {\n this.code.delete(hash);\n return Promise.resolve(void 0);\n }\n return Promise.resolve(entry.value);\n }\n setBundleCode(hash, code, ttlMs) {\n const expiry = ttlMs ? Date.now() + ttlMs : void 0;\n this.code.set(hash, { value: code, expiry });\n return Promise.resolve();\n }\n async deleteBundle(key) {\n const metadata = await this.getBundleMetadata(key);\n this.metadata.delete(key);\n if (metadata) {\n this.code.delete(metadata.codeHash);\n const sourceKeys = this.sourceIndex.get(metadata.source);\n if (sourceKeys) {\n sourceKeys.delete(key);\n if (sourceKeys.size === 0) {\n this.sourceIndex.delete(metadata.source);\n }\n }\n }\n }\n async invalidateSource(source) {\n const keys = this.sourceIndex.get(source);\n if (!keys)\n return 0;\n let count = 0;\n for (const key of Array.from(keys)) {\n await this.deleteBundle(key);\n count++;\n }\n this.sourceIndex.delete(source);\n return count;\n }\n clear() {\n this.metadata.clear();\n this.code.clear();\n this.sourceIndex.clear();\n return Promise.resolve();\n }\n isAvailable() {\n return Promise.resolve(true);\n }\n getStats() {\n let totalSize = 0;\n let oldest;\n let newest;\n for (const { value } of this.metadata.values()) {\n totalSize += value.size;\n if (!oldest || value.compiledAt < oldest)\n oldest = value.compiledAt;\n if (!newest || value.compiledAt > newest)\n newest = value.compiledAt;\n }\n return Promise.resolve({\n totalBundles: this.metadata.size,\n totalSize,\n oldestBundle: oldest,\n newestBundle: newest\n });\n }\n};\nvar manifestStore = new InMemoryBundleManifestStore();\n\n// src/rendering/client/prefetch.ts\nvar PrefetchManager = class {\n constructor(options = {}) {\n this.prefetchedUrls = /* @__PURE__ */ new Set();\n this.linkObserver = null;\n this.options = {\n rootMargin: options.rootMargin || "50px",\n delay: options.delay || PREFETCH_DEFAULT_DELAY_MS,\n maxConcurrent: options.maxConcurrent || 2,\n allowedNetworks: options.allowedNetworks || ["4g", "wifi", "ethernet"],\n maxSize: options.maxSize || PREFETCH_MAX_SIZE_BYTES,\n timeout: options.timeout || PREFETCH_DEFAULT_TIMEOUT_MS\n };\n this.networkUtils = new NetworkUtils(this.options.allowedNetworks);\n this.resourceHintsManager = new ResourceHintsManager();\n this.prefetchQueue = new PrefetchQueue(\n {\n maxConcurrent: this.options.maxConcurrent,\n maxSize: this.options.maxSize,\n timeout: this.options.timeout\n },\n this.prefetchedUrls\n );\n this.prefetchQueue.setResourceCallback(\n (response, url) => this.prefetchPageResources(response, url)\n );\n }\n init() {\n prefetchLogger.info("Initializing prefetch manager");\n if (!this.networkUtils.shouldPrefetch()) {\n prefetchLogger.info("Prefetching disabled due to network conditions");\n return;\n }\n this.linkObserver = new LinkObserver(\n {\n rootMargin: this.options.rootMargin,\n delay: this.options.delay,\n onLinkVisible: (link) => this.prefetchQueue.prefetchLink(link)\n },\n this.prefetchedUrls\n );\n this.linkObserver.init();\n this.networkUtils.onNetworkChange(() => {\n if (!this.networkUtils.shouldPrefetch()) {\n this.prefetchQueue.stopAll();\n }\n });\n }\n async prefetchPageResources(response, _pageUrl) {\n const html = await response.text();\n const hints = this.resourceHintsManager.extractResourceHints(html, this.prefetchedUrls);\n this.resourceHintsManager.applyResourceHints(hints);\n }\n applyResourceHints(hints) {\n this.resourceHintsManager.applyResourceHints(hints);\n }\n async prefetch(url) {\n await this.prefetchQueue.prefetch(url);\n }\n static generateResourceHints(route, assets) {\n return ResourceHintsManager.generateResourceHints(route, assets);\n }\n destroy() {\n this.linkObserver?.destroy();\n this.prefetchQueue.stopAll();\n this.prefetchedUrls.clear();\n }\n};\nif (typeof window !== "undefined") {\n const prefetchManager = new PrefetchManager();\n if (document.readyState === "loading") {\n document.addEventListener("DOMContentLoaded", () => prefetchManager.init());\n } else {\n prefetchManager.init();\n }\n globalThis.veryFrontPrefetch = prefetchManager;\n}\nexport {\n PrefetchManager\n};\n';
|
|
14117
14089
|
}
|
|
14118
14090
|
});
|
|
14119
14091
|
|
|
@@ -14240,15 +14212,45 @@ var init_hooks_adapter = __esm({
|
|
|
14240
14212
|
|
|
14241
14213
|
// src/react/compat/ssr-adapter/server-loader.ts
|
|
14242
14214
|
import * as React3 from "react";
|
|
14243
|
-
function
|
|
14215
|
+
function isNodeRuntime2() {
|
|
14244
14216
|
const g = globalThis;
|
|
14245
14217
|
return typeof Deno === "undefined" && typeof g.process?.versions?.node !== "undefined";
|
|
14246
14218
|
}
|
|
14219
|
+
async function canResolveReactFromProject() {
|
|
14220
|
+
if (useProjectReact !== null) {
|
|
14221
|
+
return useProjectReact;
|
|
14222
|
+
}
|
|
14223
|
+
if (!isNodeRuntime2()) {
|
|
14224
|
+
useProjectReact = false;
|
|
14225
|
+
return false;
|
|
14226
|
+
}
|
|
14227
|
+
try {
|
|
14228
|
+
const { createRequire } = await import("node:module");
|
|
14229
|
+
const { pathToFileURL: pathToFileURL2 } = await import("node:url");
|
|
14230
|
+
const projectRequire = createRequire(pathToFileURL2(process.cwd() + "/").href);
|
|
14231
|
+
const reactPath = projectRequire.resolve("react");
|
|
14232
|
+
const reactDomPath = projectRequire.resolve("react-dom/server");
|
|
14233
|
+
rendererLogger.debug("Project has both react and react-dom", {
|
|
14234
|
+
react: reactPath,
|
|
14235
|
+
reactDom: reactDomPath
|
|
14236
|
+
});
|
|
14237
|
+
useProjectReact = true;
|
|
14238
|
+
return true;
|
|
14239
|
+
} catch (error2) {
|
|
14240
|
+
rendererLogger.debug(
|
|
14241
|
+
"Project missing react and/or react-dom, using bundled versions for consistency",
|
|
14242
|
+
error2
|
|
14243
|
+
);
|
|
14244
|
+
useProjectReact = false;
|
|
14245
|
+
return false;
|
|
14246
|
+
}
|
|
14247
|
+
}
|
|
14247
14248
|
async function getProjectReact() {
|
|
14248
14249
|
if (projectReactCache) {
|
|
14249
14250
|
return projectReactCache;
|
|
14250
14251
|
}
|
|
14251
|
-
|
|
14252
|
+
const canUseProject = await canResolveReactFromProject();
|
|
14253
|
+
if (canUseProject) {
|
|
14252
14254
|
try {
|
|
14253
14255
|
const { createRequire } = await import("node:module");
|
|
14254
14256
|
const { pathToFileURL: pathToFileURL2 } = await import("node:url");
|
|
@@ -14266,7 +14268,8 @@ async function getProjectReact() {
|
|
|
14266
14268
|
return React3;
|
|
14267
14269
|
}
|
|
14268
14270
|
async function importReactDOMServerFromProject() {
|
|
14269
|
-
|
|
14271
|
+
const canUseProject = await canResolveReactFromProject();
|
|
14272
|
+
if (canUseProject) {
|
|
14270
14273
|
try {
|
|
14271
14274
|
const { createRequire } = await import("node:module");
|
|
14272
14275
|
const { pathToFileURL: pathToFileURL2 } = await import("node:url");
|
|
@@ -14276,7 +14279,6 @@ async function importReactDOMServerFromProject() {
|
|
|
14276
14279
|
return await import(pathToFileURL2(reactDomServerPath).href);
|
|
14277
14280
|
} catch (error2) {
|
|
14278
14281
|
rendererLogger.warn("Failed to resolve react-dom from project, falling back to bundled", error2);
|
|
14279
|
-
return await import("react-dom/server");
|
|
14280
14282
|
}
|
|
14281
14283
|
}
|
|
14282
14284
|
return await import("react-dom/server");
|
|
@@ -14302,13 +14304,14 @@ async function getReactDOMServer() {
|
|
|
14302
14304
|
renderToReadableStream
|
|
14303
14305
|
};
|
|
14304
14306
|
}
|
|
14305
|
-
var projectReactCache;
|
|
14307
|
+
var projectReactCache, useProjectReact;
|
|
14306
14308
|
var init_server_loader = __esm({
|
|
14307
14309
|
"src/react/compat/ssr-adapter/server-loader.ts"() {
|
|
14308
14310
|
"use strict";
|
|
14309
14311
|
init_utils();
|
|
14310
14312
|
init_version_detector();
|
|
14311
14313
|
projectReactCache = null;
|
|
14314
|
+
useProjectReact = null;
|
|
14312
14315
|
}
|
|
14313
14316
|
});
|
|
14314
14317
|
|
|
@@ -14344,7 +14347,7 @@ var init_string_renderer = __esm({
|
|
|
14344
14347
|
// src/react/compat/ssr-adapter/stream-renderer.ts
|
|
14345
14348
|
async function renderToReadableStreamImpl(element, options, server) {
|
|
14346
14349
|
const debug = Boolean(
|
|
14347
|
-
globalThis
|
|
14350
|
+
globalThis.__VERYFRONT_DEBUG__ || process.env?.VERYFRONT_DEBUG === "1"
|
|
14348
14351
|
);
|
|
14349
14352
|
if (!server.renderToReadableStream) {
|
|
14350
14353
|
throw toError(createError({
|
|
@@ -14449,7 +14452,7 @@ function renderToPipeableStreamImpl(element, options, server) {
|
|
|
14449
14452
|
}
|
|
14450
14453
|
async function renderToStreamAdapter(element, options = {}) {
|
|
14451
14454
|
const debug = Boolean(
|
|
14452
|
-
globalThis
|
|
14455
|
+
globalThis.__VERYFRONT_DEBUG__ || process.env?.VERYFRONT_DEBUG === "1"
|
|
14453
14456
|
);
|
|
14454
14457
|
const versionInfo = getReactVersionInfo();
|
|
14455
14458
|
const server = await getReactDOMServer();
|
|
@@ -14607,11 +14610,6 @@ var init_namespace = __esm({
|
|
|
14607
14610
|
|
|
14608
14611
|
// src/module-system/import-map/default-import-map.ts
|
|
14609
14612
|
function getDefaultImportMap() {
|
|
14610
|
-
const _versionMap = {
|
|
14611
|
-
17: REACT_VERSION_17,
|
|
14612
|
-
18: REACT_DEFAULT_VERSION,
|
|
14613
|
-
19: REACT_VERSION_19
|
|
14614
|
-
};
|
|
14615
14613
|
const reactVersion = REACT_DEFAULT_VERSION;
|
|
14616
14614
|
const importMap = getReactImportMap(reactVersion);
|
|
14617
14615
|
importMap["react/"] = `https://esm.sh/react@${reactVersion}/`;
|
|
@@ -14639,7 +14637,7 @@ async function loadImportMap(startPath, adapter) {
|
|
|
14639
14637
|
scopes: cfg.resolve.importMap.scopes ?? {}
|
|
14640
14638
|
};
|
|
14641
14639
|
}
|
|
14642
|
-
} catch
|
|
14640
|
+
} catch {
|
|
14643
14641
|
}
|
|
14644
14642
|
let currentPath = startPath;
|
|
14645
14643
|
while (currentPath !== "/" && currentPath !== "") {
|
|
@@ -14654,7 +14652,7 @@ async function loadImportMap(startPath, adapter) {
|
|
|
14654
14652
|
scopes: config.scopes ?? {}
|
|
14655
14653
|
};
|
|
14656
14654
|
}
|
|
14657
|
-
} catch
|
|
14655
|
+
} catch {
|
|
14658
14656
|
}
|
|
14659
14657
|
const parent = dirname2(currentPath);
|
|
14660
14658
|
if (parent === currentPath)
|
|
@@ -14706,7 +14704,7 @@ var init_resolver = __esm({
|
|
|
14706
14704
|
function transformImportsWithMap(code, importMap, scope, options) {
|
|
14707
14705
|
let transformedCode = code;
|
|
14708
14706
|
transformedCode = transformedCode.replace(
|
|
14709
|
-
/((?:import|export)\s+(?:[\w,{
|
|
14707
|
+
/((?:import|export)\s+(?:[\w,{}\s*]+\s+from\s+)?|export\s+(?:\*|\{[^}]+\})\s+from\s+)["']([^"']+)["']/g,
|
|
14710
14708
|
(_match, prefix, specifier) => {
|
|
14711
14709
|
const isBare = !specifier.startsWith("http") && !specifier.startsWith("/") && !specifier.startsWith(".");
|
|
14712
14710
|
if (isBare && !options?.resolveBare) {
|
|
@@ -15338,7 +15336,7 @@ var init_mdx = __esm({
|
|
|
15338
15336
|
});
|
|
15339
15337
|
|
|
15340
15338
|
// src/react/components/LayoutComponent.tsx
|
|
15341
|
-
import { useMemo } from "react";
|
|
15339
|
+
import { useMemo, useRef } from "react";
|
|
15342
15340
|
import { Fragment as Fragment2, jsx } from "react/jsx-runtime";
|
|
15343
15341
|
var init_LayoutComponent = __esm({
|
|
15344
15342
|
"src/react/components/LayoutComponent.tsx"() {
|
|
@@ -15349,7 +15347,7 @@ var init_LayoutComponent = __esm({
|
|
|
15349
15347
|
});
|
|
15350
15348
|
|
|
15351
15349
|
// src/react/components/ProviderComponent.tsx
|
|
15352
|
-
import { useMemo as useMemo2 } from "react";
|
|
15350
|
+
import { useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
15353
15351
|
import { Fragment as Fragment3, jsx as jsx2 } from "react/jsx-runtime";
|
|
15354
15352
|
var init_ProviderComponent = __esm({
|
|
15355
15353
|
"src/react/components/ProviderComponent.tsx"() {
|
|
@@ -15392,9 +15390,7 @@ var MDXContext;
|
|
|
15392
15390
|
var init_MDXProvider = __esm({
|
|
15393
15391
|
"src/react/components/MDXProvider.tsx"() {
|
|
15394
15392
|
"use strict";
|
|
15395
|
-
MDXContext = createContext3({
|
|
15396
|
-
/* empty */
|
|
15397
|
-
});
|
|
15393
|
+
MDXContext = createContext3({});
|
|
15398
15394
|
}
|
|
15399
15395
|
});
|
|
15400
15396
|
|
|
@@ -15686,12 +15682,66 @@ var init_lexer2 = __esm({
|
|
|
15686
15682
|
});
|
|
15687
15683
|
|
|
15688
15684
|
// src/build/transforms/esm/react-imports.ts
|
|
15689
|
-
function
|
|
15685
|
+
function isNodeRuntime3() {
|
|
15690
15686
|
const _global2 = globalThis;
|
|
15691
15687
|
return typeof Deno === "undefined" && typeof _global2.process !== "undefined" && !!_global2.process?.versions?.node;
|
|
15692
15688
|
}
|
|
15693
|
-
async function
|
|
15694
|
-
if (
|
|
15689
|
+
async function checkProjectHasReactDom() {
|
|
15690
|
+
if (projectHasReactDom !== null) {
|
|
15691
|
+
return projectHasReactDom;
|
|
15692
|
+
}
|
|
15693
|
+
if (!isNodeRuntime3()) {
|
|
15694
|
+
projectHasReactDom = false;
|
|
15695
|
+
return false;
|
|
15696
|
+
}
|
|
15697
|
+
try {
|
|
15698
|
+
const { createRequire } = await import("node:module");
|
|
15699
|
+
const { pathToFileURL: pathToFileURL2 } = await import("node:url");
|
|
15700
|
+
const projectRequire = createRequire(pathToFileURL2(process.cwd() + "/").href);
|
|
15701
|
+
projectRequire.resolve("react");
|
|
15702
|
+
projectRequire.resolve("react-dom/server");
|
|
15703
|
+
projectHasReactDom = true;
|
|
15704
|
+
return true;
|
|
15705
|
+
} catch {
|
|
15706
|
+
projectHasReactDom = false;
|
|
15707
|
+
return false;
|
|
15708
|
+
}
|
|
15709
|
+
}
|
|
15710
|
+
async function getBundledReactPath(subpath = "") {
|
|
15711
|
+
if (!isNodeRuntime3()) {
|
|
15712
|
+
return null;
|
|
15713
|
+
}
|
|
15714
|
+
try {
|
|
15715
|
+
const { createRequire } = await import("node:module");
|
|
15716
|
+
const cliRequire = createRequire(import.meta.url);
|
|
15717
|
+
const moduleName = subpath ? `react${subpath}` : "react";
|
|
15718
|
+
return cliRequire.resolve(moduleName);
|
|
15719
|
+
} catch {
|
|
15720
|
+
return null;
|
|
15721
|
+
}
|
|
15722
|
+
}
|
|
15723
|
+
async function resolveReactImports(code, forSSR = false) {
|
|
15724
|
+
if (isNodeRuntime3() && forSSR) {
|
|
15725
|
+
const hasReactDom = await checkProjectHasReactDom();
|
|
15726
|
+
if (!hasReactDom) {
|
|
15727
|
+
const bundledReact = await getBundledReactPath();
|
|
15728
|
+
const bundledJsxRuntime = await getBundledReactPath("/jsx-runtime");
|
|
15729
|
+
const bundledJsxDevRuntime = await getBundledReactPath("/jsx-dev-runtime");
|
|
15730
|
+
if (bundledReact && bundledJsxRuntime && bundledJsxDevRuntime) {
|
|
15731
|
+
const { pathToFileURL: pathToFileURL2 } = await import("node:url");
|
|
15732
|
+
const bundledImports = {
|
|
15733
|
+
"react/jsx-runtime": pathToFileURL2(bundledJsxRuntime).href,
|
|
15734
|
+
"react/jsx-dev-runtime": pathToFileURL2(bundledJsxDevRuntime).href,
|
|
15735
|
+
"react": pathToFileURL2(bundledReact).href
|
|
15736
|
+
};
|
|
15737
|
+
return replaceSpecifiers(code, (specifier) => {
|
|
15738
|
+
return bundledImports[specifier] || null;
|
|
15739
|
+
});
|
|
15740
|
+
}
|
|
15741
|
+
}
|
|
15742
|
+
return code;
|
|
15743
|
+
}
|
|
15744
|
+
if (isNodeRuntime3()) {
|
|
15695
15745
|
return code;
|
|
15696
15746
|
}
|
|
15697
15747
|
const reactImports = {
|
|
@@ -15707,7 +15757,7 @@ async function resolveReactImports(code) {
|
|
|
15707
15757
|
});
|
|
15708
15758
|
}
|
|
15709
15759
|
async function addDepsToEsmShUrls(code) {
|
|
15710
|
-
if (
|
|
15760
|
+
if (isNodeRuntime3()) {
|
|
15711
15761
|
return code;
|
|
15712
15762
|
}
|
|
15713
15763
|
return replaceSpecifiers(code, (specifier) => {
|
|
@@ -15717,11 +15767,13 @@ async function addDepsToEsmShUrls(code) {
|
|
|
15717
15767
|
return null;
|
|
15718
15768
|
});
|
|
15719
15769
|
}
|
|
15770
|
+
var projectHasReactDom;
|
|
15720
15771
|
var init_react_imports = __esm({
|
|
15721
15772
|
"src/build/transforms/esm/react-imports.ts"() {
|
|
15722
15773
|
"use strict";
|
|
15723
15774
|
init_lexer2();
|
|
15724
15775
|
init_cdn();
|
|
15776
|
+
projectHasReactDom = null;
|
|
15725
15777
|
}
|
|
15726
15778
|
});
|
|
15727
15779
|
|
|
@@ -15831,15 +15883,8 @@ var init_path_resolver = __esm({
|
|
|
15831
15883
|
});
|
|
15832
15884
|
|
|
15833
15885
|
// src/build/transforms/esm/import-rewriter.ts
|
|
15834
|
-
async function rewriteBareImports(code,
|
|
15835
|
-
const importMap =
|
|
15836
|
-
"react": `${moduleServerUrl}/_vendor/react`,
|
|
15837
|
-
"react-dom": `${moduleServerUrl}/_vendor/react-dom`,
|
|
15838
|
-
"react-dom/client": `${moduleServerUrl}/_vendor/react-dom/client`,
|
|
15839
|
-
"react-dom/server": `${moduleServerUrl}/_vendor/react-dom/server`,
|
|
15840
|
-
"react/jsx-runtime": `${moduleServerUrl}/_vendor/react/jsx-runtime`,
|
|
15841
|
-
"react/jsx-dev-runtime": `${moduleServerUrl}/_vendor/react/jsx-dev-runtime`
|
|
15842
|
-
} : {
|
|
15886
|
+
async function rewriteBareImports(code, _moduleServerUrl) {
|
|
15887
|
+
const importMap = {
|
|
15843
15888
|
"react": `https://esm.sh/react@${REACT_DEFAULT_VERSION}`,
|
|
15844
15889
|
"react-dom": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}`,
|
|
15845
15890
|
"react-dom/client": `https://esm.sh/react-dom@${REACT_DEFAULT_VERSION}/client`,
|
|
@@ -16905,11 +16950,11 @@ async function transformToESM(source, filePath, projectDir, _adapter, options) {
|
|
|
16905
16950
|
keepNames: true
|
|
16906
16951
|
});
|
|
16907
16952
|
let code = result.code;
|
|
16908
|
-
code = await resolveReactImports(code);
|
|
16953
|
+
code = await resolveReactImports(code, ssr);
|
|
16909
16954
|
code = await addDepsToEsmShUrls(code);
|
|
16910
16955
|
code = await resolvePathAliases(code, filePath, projectDir);
|
|
16911
16956
|
if (ssr) {
|
|
16912
|
-
if (
|
|
16957
|
+
if (isNodeRuntime3()) {
|
|
16913
16958
|
code = await resolveRelativeImportsForNodeSSR(code);
|
|
16914
16959
|
} else {
|
|
16915
16960
|
code = await resolveRelativeImportsToAbsolute(code, filePath, projectDir);
|
|
@@ -16927,6 +16972,7 @@ async function transformToESM(source, filePath, projectDir, _adapter, options) {
|
|
|
16927
16972
|
}
|
|
16928
16973
|
var init_transform_core = __esm({
|
|
16929
16974
|
"src/build/transforms/esm/transform-core.ts"() {
|
|
16975
|
+
"use strict";
|
|
16930
16976
|
init_transform_cache();
|
|
16931
16977
|
init_transform_utils();
|
|
16932
16978
|
init_react_imports();
|
|
@@ -16996,14 +17042,14 @@ var component_loader_exports = {};
|
|
|
16996
17042
|
__export(component_loader_exports, {
|
|
16997
17043
|
loadComponentFromSource: () => loadComponentFromSource
|
|
16998
17044
|
});
|
|
16999
|
-
function
|
|
17045
|
+
function isNodeRuntime4() {
|
|
17000
17046
|
const _global2 = globalThis;
|
|
17001
17047
|
return typeof Deno === "undefined" && typeof _global2.process !== "undefined" && !!_global2.process?.versions?.node;
|
|
17002
17048
|
}
|
|
17003
17049
|
async function loadComponentFromSource(source, filePath, projectDir, adapter, options) {
|
|
17004
17050
|
const projectId = options?.projectId || projectDir;
|
|
17005
17051
|
const dev = options?.dev ?? true;
|
|
17006
|
-
const isNode2 =
|
|
17052
|
+
const isNode2 = isNodeRuntime4();
|
|
17007
17053
|
const ssr = isNode2 ? true : options?.ssr ?? false;
|
|
17008
17054
|
const moduleServerUrl = isNode2 ? void 0 : options?.moduleServerUrl ?? "/_vf_modules";
|
|
17009
17055
|
const vendorBundleHash = isNode2 ? void 0 : options?.vendorBundleHash;
|
|
@@ -17302,7 +17348,7 @@ var init_build_context = __esm({
|
|
|
17302
17348
|
|
|
17303
17349
|
// src/build/bundler/code-splitter/manifest-builder.ts
|
|
17304
17350
|
async function readFileBytes(path) {
|
|
17305
|
-
if (
|
|
17351
|
+
if (IS_DENO2) {
|
|
17306
17352
|
return await Deno.readFile(path);
|
|
17307
17353
|
}
|
|
17308
17354
|
const fs5 = await import("node:fs/promises");
|
|
@@ -17310,7 +17356,7 @@ async function readFileBytes(path) {
|
|
|
17310
17356
|
return new Uint8Array(buffer);
|
|
17311
17357
|
}
|
|
17312
17358
|
async function writeTextFile(path, content) {
|
|
17313
|
-
if (
|
|
17359
|
+
if (IS_DENO2) {
|
|
17314
17360
|
await Deno.writeTextFile(path, content);
|
|
17315
17361
|
return;
|
|
17316
17362
|
}
|
|
@@ -17325,7 +17371,8 @@ function extractEntryName(entryPoint) {
|
|
|
17325
17371
|
message: `Invalid entry point path: ${entryPoint}`
|
|
17326
17372
|
}));
|
|
17327
17373
|
}
|
|
17328
|
-
|
|
17374
|
+
const nameWithoutExt = filename.replace(/\.(ts|tsx|js|jsx|mdx)$/, "");
|
|
17375
|
+
return nameWithoutExt || "unknown";
|
|
17329
17376
|
}
|
|
17330
17377
|
function extractChunkName(file) {
|
|
17331
17378
|
const base = file.split("/").pop();
|
|
@@ -17400,13 +17447,13 @@ async function writeManifest(manifest, outDir) {
|
|
|
17400
17447
|
JSON.stringify(manifest, null, 2)
|
|
17401
17448
|
);
|
|
17402
17449
|
}
|
|
17403
|
-
var
|
|
17450
|
+
var IS_DENO2;
|
|
17404
17451
|
var init_manifest_builder = __esm({
|
|
17405
17452
|
"src/build/bundler/code-splitter/manifest-builder.ts"() {
|
|
17406
17453
|
"use strict";
|
|
17407
17454
|
init_std_path();
|
|
17408
17455
|
init_veryfront_error();
|
|
17409
|
-
|
|
17456
|
+
IS_DENO2 = typeof Deno !== "undefined" && "readFile" in Deno;
|
|
17410
17457
|
}
|
|
17411
17458
|
});
|
|
17412
17459
|
|
|
@@ -17802,9 +17849,6 @@ var init_config8 = __esm({
|
|
|
17802
17849
|
this.mode = options.mode;
|
|
17803
17850
|
this.adapter = options.adapter;
|
|
17804
17851
|
}
|
|
17805
|
-
/**
|
|
17806
|
-
* Load and initialize configuration
|
|
17807
|
-
*/
|
|
17808
17852
|
async initialize() {
|
|
17809
17853
|
rendererLogger.info("Loading configuration", {
|
|
17810
17854
|
projectDir: this.projectDir,
|
|
@@ -17822,9 +17866,6 @@ var init_config8 = __esm({
|
|
|
17822
17866
|
projectCacheKey: this.projectCacheKey
|
|
17823
17867
|
});
|
|
17824
17868
|
}
|
|
17825
|
-
/**
|
|
17826
|
-
* Get loaded configuration
|
|
17827
|
-
*/
|
|
17828
17869
|
getConfig() {
|
|
17829
17870
|
if (!this.config) {
|
|
17830
17871
|
throw toError(createError({
|
|
@@ -17834,16 +17875,9 @@ var init_config8 = __esm({
|
|
|
17834
17875
|
}
|
|
17835
17876
|
return this.config;
|
|
17836
17877
|
}
|
|
17837
|
-
/**
|
|
17838
|
-
* Get project cache key
|
|
17839
|
-
*/
|
|
17840
17878
|
getProjectCacheKey() {
|
|
17841
17879
|
return this.projectCacheKey;
|
|
17842
17880
|
}
|
|
17843
|
-
/**
|
|
17844
|
-
* Get cache base directory with memoization
|
|
17845
|
-
* Computes the cache directory from environment variables or config
|
|
17846
|
-
*/
|
|
17847
17881
|
getCacheBaseDir() {
|
|
17848
17882
|
const baseDirFromEnv = this.adapter.env?.get?.("VERYFRONT_CACHE_DIR");
|
|
17849
17883
|
const configDir = this.config?.cache?.dir;
|
|
@@ -17857,27 +17891,15 @@ var init_config8 = __esm({
|
|
|
17857
17891
|
this.lastConfigCacheValue = configDir;
|
|
17858
17892
|
return result;
|
|
17859
17893
|
}
|
|
17860
|
-
/**
|
|
17861
|
-
* Check if debug mode is enabled
|
|
17862
|
-
*/
|
|
17863
17894
|
isDebugMode() {
|
|
17864
17895
|
return this.adapter.env?.get?.("VERYFRONT_DEBUG") === "1" || this.adapter.env?.get?.("VERYFRONT_DEEP_INSPECT") === "1";
|
|
17865
17896
|
}
|
|
17866
|
-
/**
|
|
17867
|
-
* Get project directory
|
|
17868
|
-
*/
|
|
17869
17897
|
getProjectDir() {
|
|
17870
17898
|
return this.projectDir;
|
|
17871
17899
|
}
|
|
17872
|
-
/**
|
|
17873
|
-
* Get mode
|
|
17874
|
-
*/
|
|
17875
17900
|
getMode() {
|
|
17876
17901
|
return this.mode;
|
|
17877
17902
|
}
|
|
17878
|
-
/**
|
|
17879
|
-
* Get adapter
|
|
17880
|
-
*/
|
|
17881
17903
|
getAdapter() {
|
|
17882
17904
|
return this.adapter;
|
|
17883
17905
|
}
|
|
@@ -17905,23 +17927,14 @@ var init_virtual_module_system = __esm({
|
|
|
17905
17927
|
}
|
|
17906
17928
|
this.adapter = adapter;
|
|
17907
17929
|
}
|
|
17908
|
-
/**
|
|
17909
|
-
* Register a virtual module (alias for registerModule)
|
|
17910
|
-
*/
|
|
17911
17930
|
register(id, source, projectDir) {
|
|
17912
17931
|
return this.registerModule(id, source, projectDir);
|
|
17913
17932
|
}
|
|
17914
|
-
/**
|
|
17915
|
-
* Register a virtual module
|
|
17916
|
-
*/
|
|
17917
17933
|
async registerModule(id, source, projectDir) {
|
|
17918
17934
|
const importMap = await loadImportMap(projectDir, this.adapter);
|
|
17919
17935
|
const hasTypeScript = source.includes("interface ") || source.includes("type ") || source.includes(": React.FC") || source.includes("<") && source.includes(">") || source.includes("Props>") || source.includes("useState<") || source.includes("useRef<");
|
|
17920
17936
|
try {
|
|
17921
|
-
await initialize({
|
|
17922
|
-
worker: false
|
|
17923
|
-
// Use main thread for tests/simplicity, or true if needed
|
|
17924
|
-
});
|
|
17937
|
+
await initialize({ worker: false });
|
|
17925
17938
|
} catch {
|
|
17926
17939
|
}
|
|
17927
17940
|
const result = await transform2(source, {
|
|
@@ -17939,24 +17952,18 @@ var init_virtual_module_system = __esm({
|
|
|
17939
17952
|
'from "react/jsx-dev-runtime"'
|
|
17940
17953
|
);
|
|
17941
17954
|
transformedCode = transformedCode.replace(/from\s+["']\.\/(\w+)\.tsx["']/g, 'from "/_veryfront/modules/component:$1"').replace(/from\s+["']\.\/(\w+)\.jsx["']/g, 'from "/_veryfront/modules/component:$1"').replace(/from\s+["']\.\/(\w+)["']/g, 'from "/_veryfront/modules/component:$1"').replace(/import\(["']\.\/(\w+)\.tsx["']\)/g, 'import("/_veryfront/modules/component:$1")').replace(/import\(["']\.\/(\w+)\.jsx["']\)/g, 'import("/_veryfront/modules/component:$1")').replace(/import\(["']\.\/(\w+)["']\)/g, 'import("/_veryfront/modules/component:$1")');
|
|
17942
|
-
const
|
|
17955
|
+
const virtualModule = {
|
|
17943
17956
|
id,
|
|
17944
17957
|
source,
|
|
17945
17958
|
transformed: transformedCode,
|
|
17946
17959
|
contentType: "application/javascript"
|
|
17947
17960
|
};
|
|
17948
|
-
this.modules.set(id,
|
|
17961
|
+
this.modules.set(id, virtualModule);
|
|
17949
17962
|
return `${this.baseUrl}/${encodeURIComponent(id)}`;
|
|
17950
17963
|
}
|
|
17951
|
-
/**
|
|
17952
|
-
* Get a virtual module by ID
|
|
17953
|
-
*/
|
|
17954
17964
|
getModule(id) {
|
|
17955
17965
|
return this.modules.get(id);
|
|
17956
17966
|
}
|
|
17957
|
-
/**
|
|
17958
|
-
* Handle HTTP requests for virtual modules
|
|
17959
|
-
*/
|
|
17960
17967
|
handleRequest(request) {
|
|
17961
17968
|
const url = new URL(request.url);
|
|
17962
17969
|
if (!url.pathname.startsWith(this.baseUrl)) {
|
|
@@ -17976,9 +17983,6 @@ var init_virtual_module_system = __esm({
|
|
|
17976
17983
|
}
|
|
17977
17984
|
});
|
|
17978
17985
|
}
|
|
17979
|
-
/**
|
|
17980
|
-
* Clear all virtual modules
|
|
17981
|
-
*/
|
|
17982
17986
|
clear() {
|
|
17983
17987
|
this.modules.clear();
|
|
17984
17988
|
}
|
|
@@ -18715,60 +18719,17 @@ var init_app_route_resolver = __esm({
|
|
|
18715
18719
|
}
|
|
18716
18720
|
});
|
|
18717
18721
|
|
|
18718
|
-
// src/routing/matchers/route-parser.ts
|
|
18719
|
-
var init_route_parser = __esm({
|
|
18720
|
-
"src/routing/matchers/route-parser.ts"() {
|
|
18721
|
-
"use strict";
|
|
18722
|
-
}
|
|
18723
|
-
});
|
|
18724
|
-
|
|
18725
|
-
// src/routing/matchers/route-matcher.ts
|
|
18726
|
-
var init_route_matcher = __esm({
|
|
18727
|
-
"src/routing/matchers/route-matcher.ts"() {
|
|
18728
|
-
"use strict";
|
|
18729
|
-
}
|
|
18730
|
-
});
|
|
18731
|
-
|
|
18732
|
-
// src/routing/matchers/pattern-route-matcher.ts
|
|
18733
|
-
var init_pattern_route_matcher = __esm({
|
|
18734
|
-
"src/routing/matchers/pattern-route-matcher.ts"() {
|
|
18735
|
-
"use strict";
|
|
18736
|
-
init_route_parser();
|
|
18737
|
-
init_route_matcher();
|
|
18738
|
-
init_path_utils();
|
|
18739
|
-
}
|
|
18740
|
-
});
|
|
18741
|
-
|
|
18742
|
-
// src/routing/matchers/index.ts
|
|
18743
|
-
var init_matchers = __esm({
|
|
18744
|
-
"src/routing/matchers/index.ts"() {
|
|
18745
|
-
"use strict";
|
|
18746
|
-
init_pattern_route_matcher();
|
|
18747
|
-
init_route_parser();
|
|
18748
|
-
init_route_matcher();
|
|
18749
|
-
init_utils();
|
|
18750
|
-
}
|
|
18751
|
-
});
|
|
18752
|
-
|
|
18753
|
-
// src/routing/slug-mapper/path-candidate-generator.ts
|
|
18754
|
-
var init_path_candidate_generator = __esm({
|
|
18755
|
-
"src/routing/slug-mapper/path-candidate-generator.ts"() {
|
|
18756
|
-
"use strict";
|
|
18757
|
-
init_std_path();
|
|
18758
|
-
}
|
|
18759
|
-
});
|
|
18760
|
-
|
|
18761
18722
|
// src/routing/slug-mapper/dynamic-route-matcher.ts
|
|
18762
18723
|
var dynamic_route_matcher_exports = {};
|
|
18763
18724
|
__export(dynamic_route_matcher_exports, {
|
|
18764
|
-
extractParams: () =>
|
|
18725
|
+
extractParams: () => extractParams2,
|
|
18765
18726
|
isDynamicRoute: () => isDynamicRoute,
|
|
18766
18727
|
matchesPattern: () => matchesPattern
|
|
18767
18728
|
});
|
|
18768
18729
|
function isDynamicRoute(pattern) {
|
|
18769
18730
|
return /\[[\w.]+\]/.test(pattern);
|
|
18770
18731
|
}
|
|
18771
|
-
function
|
|
18732
|
+
function extractParams2(pattern, slug) {
|
|
18772
18733
|
const patternParts = pattern.split("/").filter(Boolean);
|
|
18773
18734
|
const slugParts = slug.split("/").filter(Boolean);
|
|
18774
18735
|
const params = {};
|
|
@@ -18816,685 +18777,120 @@ function extractParams(pattern, slug) {
|
|
|
18816
18777
|
return params;
|
|
18817
18778
|
}
|
|
18818
18779
|
function matchesPattern(pattern, slug) {
|
|
18819
|
-
return
|
|
18780
|
+
return extractParams2(pattern, slug) !== null;
|
|
18820
18781
|
}
|
|
18821
18782
|
var init_dynamic_route_matcher = __esm({
|
|
18822
18783
|
"src/routing/slug-mapper/dynamic-route-matcher.ts"() {
|
|
18823
|
-
"use strict";
|
|
18824
|
-
}
|
|
18825
|
-
});
|
|
18826
|
-
|
|
18827
|
-
// src/routing/slug-mapper/slug-normalizer.ts
|
|
18828
|
-
var init_slug_normalizer = __esm({
|
|
18829
|
-
"src/routing/slug-mapper/slug-normalizer.ts"() {
|
|
18830
|
-
"use strict";
|
|
18831
|
-
}
|
|
18832
|
-
});
|
|
18833
|
-
|
|
18834
|
-
// src/routing/slug-mapper/index.ts
|
|
18835
|
-
var init_slug_mapper = __esm({
|
|
18836
|
-
"src/routing/slug-mapper/index.ts"() {
|
|
18837
|
-
"use strict";
|
|
18838
|
-
init_path_candidate_generator();
|
|
18839
|
-
init_dynamic_route_matcher();
|
|
18840
|
-
init_slug_normalizer();
|
|
18841
18784
|
}
|
|
18842
18785
|
});
|
|
18843
18786
|
|
|
18844
|
-
// src/
|
|
18845
|
-
function
|
|
18846
|
-
const
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
|
|
18855
|
-
|
|
18856
|
-
|
|
18857
|
-
|
|
18858
|
-
|
|
18859
|
-
|
|
18860
|
-
|
|
18861
|
-
|
|
18862
|
-
|
|
18863
|
-
|
|
18864
|
-
return null;
|
|
18865
|
-
}
|
|
18866
|
-
return current;
|
|
18867
|
-
}
|
|
18868
|
-
function updateMetaTags(frontmatter) {
|
|
18869
|
-
if (frontmatter.description) {
|
|
18870
|
-
updateMetaTag('meta[name="description"]', "name", "description", frontmatter.description);
|
|
18871
|
-
}
|
|
18872
|
-
if (frontmatter.ogTitle) {
|
|
18873
|
-
updateMetaTag('meta[property="og:title"]', "property", "og:title", frontmatter.ogTitle);
|
|
18874
|
-
}
|
|
18875
|
-
}
|
|
18876
|
-
function updateMetaTag(selector, attributeName, attributeValue, content) {
|
|
18877
|
-
let metaTag = document.querySelector(selector);
|
|
18878
|
-
if (!metaTag) {
|
|
18879
|
-
metaTag = document.createElement("meta");
|
|
18880
|
-
metaTag.setAttribute(attributeName, attributeValue);
|
|
18881
|
-
document.head.appendChild(metaTag);
|
|
18882
|
-
}
|
|
18883
|
-
metaTag.setAttribute("content", content);
|
|
18884
|
-
}
|
|
18885
|
-
function executeScripts(container) {
|
|
18886
|
-
const scripts = container.querySelectorAll("script");
|
|
18887
|
-
scripts.forEach((oldScript) => {
|
|
18888
|
-
const newScript = document.createElement("script");
|
|
18889
|
-
Array.from(oldScript.attributes).forEach((attribute) => {
|
|
18890
|
-
newScript.setAttribute(attribute.name, attribute.value);
|
|
18891
|
-
});
|
|
18892
|
-
newScript.textContent = oldScript.textContent;
|
|
18893
|
-
oldScript.parentNode?.replaceChild(newScript, oldScript);
|
|
18894
|
-
});
|
|
18895
|
-
}
|
|
18896
|
-
function applyHeadDirectives(container) {
|
|
18897
|
-
const nodes = container.querySelectorAll('[data-veryfront-head="1"], vf-head');
|
|
18898
|
-
if (nodes.length > 0) {
|
|
18899
|
-
cleanManagedHeadTags();
|
|
18900
|
-
}
|
|
18901
|
-
nodes.forEach((wrapper) => {
|
|
18902
|
-
processHeadWrapper(wrapper);
|
|
18903
|
-
wrapper.parentElement?.removeChild(wrapper);
|
|
18904
|
-
});
|
|
18905
|
-
}
|
|
18906
|
-
function cleanManagedHeadTags() {
|
|
18907
|
-
document.head.querySelectorAll('[data-veryfront-managed="1"]').forEach((element) => element.parentElement?.removeChild(element));
|
|
18908
|
-
}
|
|
18909
|
-
function processHeadWrapper(wrapper) {
|
|
18910
|
-
wrapper.childNodes.forEach((node2) => {
|
|
18911
|
-
if (!(node2 instanceof Element))
|
|
18912
|
-
return;
|
|
18913
|
-
const tagName = node2.tagName.toLowerCase();
|
|
18914
|
-
if (tagName === "title") {
|
|
18915
|
-
document.title = node2.textContent || document.title;
|
|
18916
|
-
return;
|
|
18787
|
+
// src/rendering/route-params-extractor.ts
|
|
18788
|
+
async function extractAppRouteParams(projectDir, slug, adapter) {
|
|
18789
|
+
const { join: pathJoin } = await Promise.resolve().then(() => (init_std_path(), std_path_exports));
|
|
18790
|
+
const { extractParams: extractParams4 } = await Promise.resolve().then(() => (init_dynamic_route_matcher(), dynamic_route_matcher_exports));
|
|
18791
|
+
const segments = slug ? slug.split("/").filter(Boolean) : [];
|
|
18792
|
+
let currentDir = pathJoin(projectDir, "app");
|
|
18793
|
+
const patternParts = [];
|
|
18794
|
+
for (let i = 0; i < segments.length; i++) {
|
|
18795
|
+
const segment = segments[i];
|
|
18796
|
+
if (!segment)
|
|
18797
|
+
continue;
|
|
18798
|
+
const exactPath = pathJoin(currentDir, segment);
|
|
18799
|
+
try {
|
|
18800
|
+
const stat2 = await adapter.fs.stat(exactPath);
|
|
18801
|
+
if (stat2.isDirectory) {
|
|
18802
|
+
currentDir = exactPath;
|
|
18803
|
+
patternParts.push(segment);
|
|
18804
|
+
continue;
|
|
18805
|
+
}
|
|
18806
|
+
} catch {
|
|
18917
18807
|
}
|
|
18918
|
-
|
|
18919
|
-
|
|
18920
|
-
|
|
18808
|
+
let foundDynamic = false;
|
|
18809
|
+
let isCatchAll = false;
|
|
18810
|
+
try {
|
|
18811
|
+
const entries = await adapter.fs.readDir(currentDir);
|
|
18812
|
+
for await (const entry of entries) {
|
|
18813
|
+
if (entry.isDirectory && isDynamicSegment2(entry.name)) {
|
|
18814
|
+
currentDir = pathJoin(currentDir, entry.name);
|
|
18815
|
+
patternParts.push(entry.name);
|
|
18816
|
+
foundDynamic = true;
|
|
18817
|
+
if (entry.name.startsWith("[...")) {
|
|
18818
|
+
isCatchAll = true;
|
|
18819
|
+
}
|
|
18820
|
+
break;
|
|
18821
|
+
}
|
|
18822
|
+
}
|
|
18823
|
+
} catch {
|
|
18921
18824
|
}
|
|
18922
|
-
if (
|
|
18923
|
-
|
|
18825
|
+
if (!foundDynamic) {
|
|
18826
|
+
return null;
|
|
18924
18827
|
}
|
|
18925
|
-
|
|
18926
|
-
|
|
18927
|
-
});
|
|
18928
|
-
}
|
|
18929
|
-
function manageFocus(container) {
|
|
18930
|
-
try {
|
|
18931
|
-
const focusElement = container.querySelector("[data-router-focus]") || container.querySelector("main") || container.querySelector("h1");
|
|
18932
|
-
if (focusElement && focusElement instanceof HTMLElement && "focus" in focusElement) {
|
|
18933
|
-
focusElement.focus({ preventScroll: true });
|
|
18828
|
+
if (isCatchAll) {
|
|
18829
|
+
break;
|
|
18934
18830
|
}
|
|
18935
|
-
} catch (error2) {
|
|
18936
|
-
rendererLogger.warn("[router] focus management failed", error2);
|
|
18937
18831
|
}
|
|
18832
|
+
const pattern = patternParts.join("/");
|
|
18833
|
+
return extractParams4(pattern, slug);
|
|
18938
18834
|
}
|
|
18939
|
-
function
|
|
18940
|
-
const
|
|
18941
|
-
|
|
18942
|
-
|
|
18943
|
-
|
|
18944
|
-
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
18835
|
+
async function extractPagesRouteParams(projectDir, slug, adapter) {
|
|
18836
|
+
const { join: pathJoin } = await Promise.resolve().then(() => (init_std_path(), std_path_exports));
|
|
18837
|
+
const segments = slug ? slug.split("/").filter(Boolean) : [];
|
|
18838
|
+
const pagesDir = pathJoin(projectDir, "pages");
|
|
18839
|
+
const routeExtensions = [".tsx", ".jsx", ".ts", ".js", ".mdx"];
|
|
18840
|
+
const patternParts = [];
|
|
18841
|
+
let currentDir = pagesDir;
|
|
18842
|
+
for (let i = 0; i < segments.length; i++) {
|
|
18843
|
+
const segment = segments[i];
|
|
18844
|
+
if (!segment)
|
|
18845
|
+
continue;
|
|
18846
|
+
const exactPath = pathJoin(currentDir, segment);
|
|
18847
|
+
try {
|
|
18848
|
+
const stat2 = await adapter.fs.stat(exactPath);
|
|
18849
|
+
if (stat2.isDirectory) {
|
|
18850
|
+
currentDir = exactPath;
|
|
18851
|
+
patternParts.push(segment);
|
|
18852
|
+
continue;
|
|
18853
|
+
}
|
|
18854
|
+
} catch {
|
|
18948
18855
|
}
|
|
18949
|
-
|
|
18950
|
-
} catch (error2) {
|
|
18951
|
-
rendererLogger.error("[dom-utils] Failed to parse page data:", error2);
|
|
18952
|
-
return null;
|
|
18953
|
-
}
|
|
18954
|
-
}
|
|
18955
|
-
function parsePageDataFromHTML(html3) {
|
|
18956
|
-
const parser = new DOMParser();
|
|
18957
|
-
const doc = parser.parseFromString(html3, "text/html");
|
|
18958
|
-
const root = doc.getElementById("root");
|
|
18959
|
-
let content = "";
|
|
18960
|
-
if (root) {
|
|
18961
|
-
content = root.innerHTML || "";
|
|
18962
|
-
} else {
|
|
18963
|
-
rendererLogger.warn("[dom-utils] No root element found in HTML");
|
|
18964
|
-
}
|
|
18965
|
-
const pageDataScript = doc.querySelector("script[data-veryfront-page]");
|
|
18966
|
-
let pageData = {};
|
|
18967
|
-
if (pageDataScript) {
|
|
18856
|
+
let foundDynamic = false;
|
|
18968
18857
|
try {
|
|
18969
|
-
const
|
|
18970
|
-
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
|
|
18858
|
+
const entries = await adapter.fs.readDir(currentDir);
|
|
18859
|
+
for await (const entry of entries) {
|
|
18860
|
+
const entryName = entry.name;
|
|
18861
|
+
if (isDynamicSegment2(entryName)) {
|
|
18862
|
+
const isCatchAll = entryName.startsWith("[...");
|
|
18863
|
+
const isFile = routeExtensions.some((ext) => entryName.endsWith(ext));
|
|
18864
|
+
if (isFile && i === segments.length - 1) {
|
|
18865
|
+
patternParts.push(entryName.replace(/\.(tsx|jsx|ts|js|mdx)$/, ""));
|
|
18866
|
+
foundDynamic = true;
|
|
18867
|
+
break;
|
|
18868
|
+
} else if (entry.isDirectory) {
|
|
18869
|
+
currentDir = pathJoin(currentDir, entryName);
|
|
18870
|
+
patternParts.push(entryName);
|
|
18871
|
+
foundDynamic = true;
|
|
18872
|
+
if (isCatchAll) {
|
|
18873
|
+
break;
|
|
18874
|
+
}
|
|
18875
|
+
break;
|
|
18876
|
+
}
|
|
18877
|
+
}
|
|
18974
18878
|
}
|
|
18975
|
-
} catch
|
|
18976
|
-
|
|
18879
|
+
} catch {
|
|
18880
|
+
}
|
|
18881
|
+
if (!foundDynamic) {
|
|
18882
|
+
return null;
|
|
18977
18883
|
}
|
|
18978
18884
|
}
|
|
18979
|
-
|
|
18885
|
+
const pattern = patternParts.join("/");
|
|
18886
|
+
return extractParams(pattern, slug);
|
|
18980
18887
|
}
|
|
18981
|
-
|
|
18982
|
-
"
|
|
18888
|
+
function isDynamicSegment2(name) {
|
|
18889
|
+
return name.startsWith("[") && name.endsWith("]");
|
|
18890
|
+
}
|
|
18891
|
+
var init_route_params_extractor = __esm({
|
|
18892
|
+
"src/rendering/route-params-extractor.ts"() {
|
|
18983
18893
|
"use strict";
|
|
18984
|
-
init_utils();
|
|
18985
|
-
}
|
|
18986
|
-
});
|
|
18987
|
-
|
|
18988
|
-
// src/routing/client/navigation-handlers.ts
|
|
18989
|
-
var NavigationHandlers;
|
|
18990
|
-
var init_navigation_handlers = __esm({
|
|
18991
|
-
"src/routing/client/navigation-handlers.ts"() {
|
|
18992
|
-
"use strict";
|
|
18993
|
-
init_utils();
|
|
18994
|
-
init_config();
|
|
18995
|
-
init_dom_utils();
|
|
18996
|
-
NavigationHandlers = class {
|
|
18997
|
-
constructor(prefetchDelay = DEFAULT_PREFETCH_DELAY_MS, prefetchOptions = {}) {
|
|
18998
|
-
this.prefetchQueue = /* @__PURE__ */ new Set();
|
|
18999
|
-
this.scrollPositions = /* @__PURE__ */ new Map();
|
|
19000
|
-
this.isPopStateNav = false;
|
|
19001
|
-
this.prefetchDelay = prefetchDelay;
|
|
19002
|
-
this.prefetchOptions = prefetchOptions;
|
|
19003
|
-
}
|
|
19004
|
-
createClickHandler(callbacks) {
|
|
19005
|
-
return (event) => {
|
|
19006
|
-
const anchor = findAnchorElement(event.target);
|
|
19007
|
-
if (!anchor || !isInternalLink(anchor))
|
|
19008
|
-
return;
|
|
19009
|
-
const href = anchor.getAttribute("href");
|
|
19010
|
-
event.preventDefault();
|
|
19011
|
-
callbacks.onNavigate(href);
|
|
19012
|
-
};
|
|
19013
|
-
}
|
|
19014
|
-
createPopStateHandler(callbacks) {
|
|
19015
|
-
return (_event) => {
|
|
19016
|
-
const path = globalThis.location.pathname;
|
|
19017
|
-
this.isPopStateNav = true;
|
|
19018
|
-
callbacks.onNavigate(path);
|
|
19019
|
-
};
|
|
19020
|
-
}
|
|
19021
|
-
createMouseOverHandler(callbacks) {
|
|
19022
|
-
return (event) => {
|
|
19023
|
-
const target = event.target;
|
|
19024
|
-
if (target.tagName !== "A")
|
|
19025
|
-
return;
|
|
19026
|
-
const href = target.getAttribute("href");
|
|
19027
|
-
if (!href || href.startsWith("http") || href.startsWith("#"))
|
|
19028
|
-
return;
|
|
19029
|
-
if (!this.shouldPrefetchOnHover(target))
|
|
19030
|
-
return;
|
|
19031
|
-
if (!this.prefetchQueue.has(href)) {
|
|
19032
|
-
this.prefetchQueue.add(href);
|
|
19033
|
-
setTimeout(() => {
|
|
19034
|
-
callbacks.onPrefetch(href);
|
|
19035
|
-
this.prefetchQueue.delete(href);
|
|
19036
|
-
}, this.prefetchDelay);
|
|
19037
|
-
}
|
|
19038
|
-
};
|
|
19039
|
-
}
|
|
19040
|
-
shouldPrefetchOnHover(target) {
|
|
19041
|
-
const prefetchAttribute = target.getAttribute("data-prefetch");
|
|
19042
|
-
const isHoverEnabled = Boolean(this.prefetchOptions.hover);
|
|
19043
|
-
if (prefetchAttribute === "false")
|
|
19044
|
-
return false;
|
|
19045
|
-
return prefetchAttribute === "true" || isHoverEnabled;
|
|
19046
|
-
}
|
|
19047
|
-
saveScrollPosition(path) {
|
|
19048
|
-
try {
|
|
19049
|
-
const scrollY = globalThis.scrollY;
|
|
19050
|
-
if (typeof scrollY === "number") {
|
|
19051
|
-
this.scrollPositions.set(path, scrollY);
|
|
19052
|
-
} else {
|
|
19053
|
-
rendererLogger.debug("[router] No valid scrollY value available");
|
|
19054
|
-
this.scrollPositions.set(path, 0);
|
|
19055
|
-
}
|
|
19056
|
-
} catch (error2) {
|
|
19057
|
-
rendererLogger.warn("[router] failed to record scroll position", error2);
|
|
19058
|
-
}
|
|
19059
|
-
}
|
|
19060
|
-
getScrollPosition(path) {
|
|
19061
|
-
const position = this.scrollPositions.get(path);
|
|
19062
|
-
if (position === void 0) {
|
|
19063
|
-
rendererLogger.debug(`[router] No scroll position stored for ${path}`);
|
|
19064
|
-
return 0;
|
|
19065
|
-
}
|
|
19066
|
-
return position;
|
|
19067
|
-
}
|
|
19068
|
-
isPopState() {
|
|
19069
|
-
return this.isPopStateNav;
|
|
19070
|
-
}
|
|
19071
|
-
clearPopStateFlag() {
|
|
19072
|
-
this.isPopStateNav = false;
|
|
19073
|
-
}
|
|
19074
|
-
clear() {
|
|
19075
|
-
this.prefetchQueue.clear();
|
|
19076
|
-
this.scrollPositions.clear();
|
|
19077
|
-
this.isPopStateNav = false;
|
|
19078
|
-
}
|
|
19079
|
-
};
|
|
19080
|
-
}
|
|
19081
|
-
});
|
|
19082
|
-
|
|
19083
|
-
// src/routing/client/page-loader.ts
|
|
19084
|
-
var PageLoader;
|
|
19085
|
-
var init_page_loader = __esm({
|
|
19086
|
-
"src/routing/client/page-loader.ts"() {
|
|
19087
|
-
"use strict";
|
|
19088
|
-
init_utils();
|
|
19089
|
-
init_errors();
|
|
19090
|
-
init_dom_utils();
|
|
19091
|
-
PageLoader = class {
|
|
19092
|
-
constructor() {
|
|
19093
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
19094
|
-
}
|
|
19095
|
-
getCached(path) {
|
|
19096
|
-
return this.cache.get(path);
|
|
19097
|
-
}
|
|
19098
|
-
isCached(path) {
|
|
19099
|
-
return this.cache.has(path);
|
|
19100
|
-
}
|
|
19101
|
-
setCache(path, data) {
|
|
19102
|
-
this.cache.set(path, data);
|
|
19103
|
-
}
|
|
19104
|
-
clearCache() {
|
|
19105
|
-
this.cache.clear();
|
|
19106
|
-
}
|
|
19107
|
-
async fetchPageData(path) {
|
|
19108
|
-
const jsonData = await this.tryFetchJSON(path);
|
|
19109
|
-
if (jsonData)
|
|
19110
|
-
return jsonData;
|
|
19111
|
-
return this.fetchAndParseHTML(path);
|
|
19112
|
-
}
|
|
19113
|
-
async tryFetchJSON(path) {
|
|
19114
|
-
try {
|
|
19115
|
-
const response = await fetch(`/_veryfront/data${path}.json`, {
|
|
19116
|
-
headers: { "X-Veryfront-Navigation": "client" }
|
|
19117
|
-
});
|
|
19118
|
-
if (response.ok) {
|
|
19119
|
-
return await response.json();
|
|
19120
|
-
}
|
|
19121
|
-
} catch (error2) {
|
|
19122
|
-
rendererLogger.debug(`[PageLoader] RSC fetch failed for ${path}, falling back to HTML:`, error2);
|
|
19123
|
-
}
|
|
19124
|
-
return null;
|
|
19125
|
-
}
|
|
19126
|
-
async fetchAndParseHTML(path) {
|
|
19127
|
-
const response = await fetch(path, {
|
|
19128
|
-
headers: { "X-Veryfront-Navigation": "client" }
|
|
19129
|
-
});
|
|
19130
|
-
if (!response.ok) {
|
|
19131
|
-
throw new NetworkError(`Failed to fetch ${path}`, {
|
|
19132
|
-
status: response.status,
|
|
19133
|
-
path
|
|
19134
|
-
});
|
|
19135
|
-
}
|
|
19136
|
-
const html3 = await response.text();
|
|
19137
|
-
const { content, pageData } = parsePageDataFromHTML(html3);
|
|
19138
|
-
return {
|
|
19139
|
-
html: content,
|
|
19140
|
-
...pageData
|
|
19141
|
-
};
|
|
19142
|
-
}
|
|
19143
|
-
async loadPage(path) {
|
|
19144
|
-
if (this.isCached(path)) {
|
|
19145
|
-
rendererLogger.debug(`Loading ${path} from cache`);
|
|
19146
|
-
const cachedData = this.getCached(path);
|
|
19147
|
-
if (!cachedData) {
|
|
19148
|
-
rendererLogger.warn(`[PageLoader] Cache entry for ${path} was unexpectedly null`);
|
|
19149
|
-
} else {
|
|
19150
|
-
return cachedData;
|
|
19151
|
-
}
|
|
19152
|
-
}
|
|
19153
|
-
const data = await this.fetchPageData(path);
|
|
19154
|
-
this.setCache(path, data);
|
|
19155
|
-
return data;
|
|
19156
|
-
}
|
|
19157
|
-
async prefetch(path) {
|
|
19158
|
-
if (this.isCached(path))
|
|
19159
|
-
return;
|
|
19160
|
-
rendererLogger.debug(`Prefetching ${path}`);
|
|
19161
|
-
try {
|
|
19162
|
-
const data = await this.fetchPageData(path);
|
|
19163
|
-
this.setCache(path, data);
|
|
19164
|
-
} catch (error2) {
|
|
19165
|
-
rendererLogger.warn(`Failed to prefetch ${path}`, error2);
|
|
19166
|
-
}
|
|
19167
|
-
}
|
|
19168
|
-
};
|
|
19169
|
-
}
|
|
19170
|
-
});
|
|
19171
|
-
|
|
19172
|
-
// src/security/client/html-sanitizer.ts
|
|
19173
|
-
function isDevMode() {
|
|
19174
|
-
if (typeof globalThis !== "undefined") {
|
|
19175
|
-
const g = globalThis;
|
|
19176
|
-
return g.__VERYFRONT_DEV__ === true || g.Deno?.env?.get?.("VERYFRONT_ENV") === "development";
|
|
19177
|
-
}
|
|
19178
|
-
return false;
|
|
19179
|
-
}
|
|
19180
|
-
function validateTrustedHtml(html3, options = {}) {
|
|
19181
|
-
const { strict = false, warn = true } = options;
|
|
19182
|
-
for (const { pattern, name } of SUSPICIOUS_PATTERNS) {
|
|
19183
|
-
pattern.lastIndex = 0;
|
|
19184
|
-
if (pattern.test(html3)) {
|
|
19185
|
-
const message = `[Security] Suspicious ${name} detected in server HTML`;
|
|
19186
|
-
if (warn) {
|
|
19187
|
-
console.warn(message);
|
|
19188
|
-
}
|
|
19189
|
-
if (strict || !isDevMode()) {
|
|
19190
|
-
throw new Error(`Potentially unsafe HTML: ${name} detected`);
|
|
19191
|
-
}
|
|
19192
|
-
}
|
|
19193
|
-
}
|
|
19194
|
-
return html3;
|
|
19195
|
-
}
|
|
19196
|
-
var SUSPICIOUS_PATTERNS;
|
|
19197
|
-
var init_html_sanitizer = __esm({
|
|
19198
|
-
"src/security/client/html-sanitizer.ts"() {
|
|
19199
|
-
SUSPICIOUS_PATTERNS = [
|
|
19200
|
-
{ pattern: /<script[^>]*>[\s\S]*?<\/script>/gi, name: "inline script" },
|
|
19201
|
-
{ pattern: /javascript:/gi, name: "javascript: URL" },
|
|
19202
|
-
{ pattern: /\bon\w+\s*=/gi, name: "event handler attribute" },
|
|
19203
|
-
{ pattern: /data:\s*text\/html/gi, name: "data: HTML URL" }
|
|
19204
|
-
];
|
|
19205
|
-
}
|
|
19206
|
-
});
|
|
19207
|
-
|
|
19208
|
-
// src/routing/client/page-transition.ts
|
|
19209
|
-
var PageTransition;
|
|
19210
|
-
var init_page_transition = __esm({
|
|
19211
|
-
"src/routing/client/page-transition.ts"() {
|
|
19212
|
-
"use strict";
|
|
19213
|
-
init_utils();
|
|
19214
|
-
init_config();
|
|
19215
|
-
init_dom_utils();
|
|
19216
|
-
init_html_sanitizer();
|
|
19217
|
-
PageTransition = class {
|
|
19218
|
-
constructor(setupViewportPrefetch) {
|
|
19219
|
-
this.setupViewportPrefetch = setupViewportPrefetch;
|
|
19220
|
-
}
|
|
19221
|
-
destroy() {
|
|
19222
|
-
if (this.pendingTransitionTimeout !== void 0) {
|
|
19223
|
-
clearTimeout(this.pendingTransitionTimeout);
|
|
19224
|
-
this.pendingTransitionTimeout = void 0;
|
|
19225
|
-
}
|
|
19226
|
-
}
|
|
19227
|
-
updatePage(data, isPopState, scrollY) {
|
|
19228
|
-
if (data.frontmatter?.title) {
|
|
19229
|
-
document.title = data.frontmatter.title;
|
|
19230
|
-
}
|
|
19231
|
-
updateMetaTags(data.frontmatter ?? {});
|
|
19232
|
-
const rootElement = document.getElementById("root");
|
|
19233
|
-
if (rootElement && (data.html ?? "") !== "") {
|
|
19234
|
-
this.performTransition(rootElement, data, isPopState, scrollY);
|
|
19235
|
-
}
|
|
19236
|
-
}
|
|
19237
|
-
performTransition(rootElement, data, isPopState, scrollY) {
|
|
19238
|
-
if (this.pendingTransitionTimeout !== void 0) {
|
|
19239
|
-
clearTimeout(this.pendingTransitionTimeout);
|
|
19240
|
-
}
|
|
19241
|
-
rootElement.style.opacity = "0";
|
|
19242
|
-
this.pendingTransitionTimeout = setTimeout(() => {
|
|
19243
|
-
this.pendingTransitionTimeout = void 0;
|
|
19244
|
-
rootElement.innerHTML = validateTrustedHtml(String(data.html ?? ""));
|
|
19245
|
-
rootElement.style.opacity = "1";
|
|
19246
|
-
executeScripts(rootElement);
|
|
19247
|
-
applyHeadDirectives(rootElement);
|
|
19248
|
-
this.setupViewportPrefetch(rootElement);
|
|
19249
|
-
manageFocus(rootElement);
|
|
19250
|
-
this.handleScroll(isPopState, scrollY);
|
|
19251
|
-
}, PAGE_TRANSITION_DELAY_MS);
|
|
19252
|
-
}
|
|
19253
|
-
handleScroll(isPopState, scrollY) {
|
|
19254
|
-
try {
|
|
19255
|
-
globalThis.scrollTo(0, isPopState ? scrollY : 0);
|
|
19256
|
-
} catch (error2) {
|
|
19257
|
-
rendererLogger.warn("[router] scroll handling failed", error2);
|
|
19258
|
-
}
|
|
19259
|
-
}
|
|
19260
|
-
showError(error2) {
|
|
19261
|
-
const rootElement = document.getElementById("root");
|
|
19262
|
-
if (!rootElement)
|
|
19263
|
-
return;
|
|
19264
|
-
const errorDiv = document.createElement("div");
|
|
19265
|
-
errorDiv.className = "veryfront-error-page";
|
|
19266
|
-
const heading = document.createElement("h1");
|
|
19267
|
-
heading.textContent = "Oops! Something went wrong";
|
|
19268
|
-
const message = document.createElement("p");
|
|
19269
|
-
message.textContent = error2.message;
|
|
19270
|
-
const button = document.createElement("button");
|
|
19271
|
-
button.type = "button";
|
|
19272
|
-
button.textContent = "Reload Page";
|
|
19273
|
-
button.onclick = () => globalThis.location.reload();
|
|
19274
|
-
errorDiv.appendChild(heading);
|
|
19275
|
-
errorDiv.appendChild(message);
|
|
19276
|
-
errorDiv.appendChild(button);
|
|
19277
|
-
rootElement.innerHTML = "";
|
|
19278
|
-
rootElement.appendChild(errorDiv);
|
|
19279
|
-
}
|
|
19280
|
-
setLoadingState(loading) {
|
|
19281
|
-
const indicator = document.getElementById("veryfront-loading");
|
|
19282
|
-
if (indicator) {
|
|
19283
|
-
indicator.style.display = loading ? "block" : "none";
|
|
19284
|
-
}
|
|
19285
|
-
document.body.classList.toggle("veryfront-loading", loading);
|
|
19286
|
-
}
|
|
19287
|
-
};
|
|
19288
|
-
}
|
|
19289
|
-
});
|
|
19290
|
-
|
|
19291
|
-
// src/routing/client/viewport-prefetch.ts
|
|
19292
|
-
var ViewportPrefetch;
|
|
19293
|
-
var init_viewport_prefetch = __esm({
|
|
19294
|
-
"src/routing/client/viewport-prefetch.ts"() {
|
|
19295
|
-
"use strict";
|
|
19296
|
-
init_utils();
|
|
19297
|
-
ViewportPrefetch = class {
|
|
19298
|
-
constructor(prefetchCallback, prefetchOptions = {}) {
|
|
19299
|
-
this.observer = null;
|
|
19300
|
-
this.prefetchCallback = prefetchCallback;
|
|
19301
|
-
this.prefetchOptions = prefetchOptions;
|
|
19302
|
-
}
|
|
19303
|
-
setup(root) {
|
|
19304
|
-
try {
|
|
19305
|
-
if (!("IntersectionObserver" in globalThis))
|
|
19306
|
-
return;
|
|
19307
|
-
if (this.observer)
|
|
19308
|
-
this.observer.disconnect();
|
|
19309
|
-
this.createObserver();
|
|
19310
|
-
this.observeLinks(root);
|
|
19311
|
-
} catch (error2) {
|
|
19312
|
-
rendererLogger.debug("[router] setupViewportPrefetch failed", error2);
|
|
19313
|
-
}
|
|
19314
|
-
}
|
|
19315
|
-
createObserver() {
|
|
19316
|
-
this.observer = new IntersectionObserver(
|
|
19317
|
-
(entries) => {
|
|
19318
|
-
for (const entry of entries) {
|
|
19319
|
-
if (entry.isIntersecting) {
|
|
19320
|
-
const isAnchor = typeof HTMLAnchorElement !== "undefined" ? entry.target instanceof HTMLAnchorElement : entry.target.tagName === "A";
|
|
19321
|
-
if (isAnchor) {
|
|
19322
|
-
const href = entry.target.getAttribute("href");
|
|
19323
|
-
if (href) {
|
|
19324
|
-
this.prefetchCallback(href);
|
|
19325
|
-
}
|
|
19326
|
-
this.observer?.unobserve(entry.target);
|
|
19327
|
-
}
|
|
19328
|
-
}
|
|
19329
|
-
}
|
|
19330
|
-
},
|
|
19331
|
-
{ rootMargin: "200px" }
|
|
19332
|
-
);
|
|
19333
|
-
}
|
|
19334
|
-
observeLinks(root) {
|
|
19335
|
-
const anchors = root.querySelectorAll?.('a[href]:not([target="_blank"])') ?? document.createDocumentFragment().querySelectorAll("a");
|
|
19336
|
-
const isViewportEnabled = Boolean(this.prefetchOptions.viewport);
|
|
19337
|
-
anchors.forEach((anchor) => {
|
|
19338
|
-
if (this.shouldObserveAnchor(anchor, isViewportEnabled)) {
|
|
19339
|
-
this.observer?.observe(anchor);
|
|
19340
|
-
}
|
|
19341
|
-
});
|
|
19342
|
-
}
|
|
19343
|
-
shouldObserveAnchor(anchor, isViewportEnabled) {
|
|
19344
|
-
const href = anchor.getAttribute("href") || "";
|
|
19345
|
-
if (!href || href.startsWith("http") || href.startsWith("#") || anchor.getAttribute("download")) {
|
|
19346
|
-
return false;
|
|
19347
|
-
}
|
|
19348
|
-
const prefetchAttribute = anchor.getAttribute("data-prefetch");
|
|
19349
|
-
if (prefetchAttribute === "false")
|
|
19350
|
-
return false;
|
|
19351
|
-
return prefetchAttribute === "viewport" || isViewportEnabled;
|
|
19352
|
-
}
|
|
19353
|
-
disconnect() {
|
|
19354
|
-
if (this.observer) {
|
|
19355
|
-
try {
|
|
19356
|
-
this.observer.disconnect();
|
|
19357
|
-
} catch (error2) {
|
|
19358
|
-
rendererLogger.warn("[router] prefetchObserver.disconnect failed", error2);
|
|
19359
|
-
}
|
|
19360
|
-
this.observer = null;
|
|
19361
|
-
}
|
|
19362
|
-
}
|
|
19363
|
-
};
|
|
19364
|
-
}
|
|
19365
|
-
});
|
|
19366
|
-
|
|
19367
|
-
// src/routing/client/index.ts
|
|
19368
|
-
var init_client2 = __esm({
|
|
19369
|
-
"src/routing/client/index.ts"() {
|
|
19370
|
-
"use strict";
|
|
19371
|
-
init_dom_utils();
|
|
19372
|
-
init_navigation_handlers();
|
|
19373
|
-
init_page_loader();
|
|
19374
|
-
init_page_transition();
|
|
19375
|
-
init_viewport_prefetch();
|
|
19376
|
-
}
|
|
19377
|
-
});
|
|
19378
|
-
|
|
19379
|
-
// src/routing/index.ts
|
|
19380
|
-
var init_routing = __esm({
|
|
19381
|
-
"src/routing/index.ts"() {
|
|
19382
|
-
init_matchers();
|
|
19383
|
-
init_slug_mapper();
|
|
19384
|
-
init_client2();
|
|
19385
|
-
init_api2();
|
|
19386
|
-
}
|
|
19387
|
-
});
|
|
19388
|
-
|
|
19389
|
-
// src/rendering/route-params-extractor.ts
|
|
19390
|
-
async function extractAppRouteParams(projectDir, slug, adapter) {
|
|
19391
|
-
const { join: pathJoin } = await Promise.resolve().then(() => (init_std_path(), std_path_exports));
|
|
19392
|
-
const { extractParams: extractParams3 } = await Promise.resolve().then(() => (init_dynamic_route_matcher(), dynamic_route_matcher_exports));
|
|
19393
|
-
const segments = slug ? slug.split("/").filter(Boolean) : [];
|
|
19394
|
-
let currentDir = pathJoin(projectDir, "app");
|
|
19395
|
-
const patternParts = [];
|
|
19396
|
-
for (let i = 0; i < segments.length; i++) {
|
|
19397
|
-
const segment = segments[i];
|
|
19398
|
-
if (!segment)
|
|
19399
|
-
continue;
|
|
19400
|
-
const exactPath = pathJoin(currentDir, segment);
|
|
19401
|
-
try {
|
|
19402
|
-
const stat2 = await adapter.fs.stat(exactPath);
|
|
19403
|
-
if (stat2.isDirectory) {
|
|
19404
|
-
currentDir = exactPath;
|
|
19405
|
-
patternParts.push(segment);
|
|
19406
|
-
continue;
|
|
19407
|
-
}
|
|
19408
|
-
} catch {
|
|
19409
|
-
}
|
|
19410
|
-
let foundDynamic = false;
|
|
19411
|
-
let isCatchAll = false;
|
|
19412
|
-
try {
|
|
19413
|
-
const entries = await adapter.fs.readDir(currentDir);
|
|
19414
|
-
for await (const entry of entries) {
|
|
19415
|
-
if (entry.isDirectory && isDynamicSegment2(entry.name)) {
|
|
19416
|
-
currentDir = pathJoin(currentDir, entry.name);
|
|
19417
|
-
patternParts.push(entry.name);
|
|
19418
|
-
foundDynamic = true;
|
|
19419
|
-
if (entry.name.startsWith("[...")) {
|
|
19420
|
-
isCatchAll = true;
|
|
19421
|
-
}
|
|
19422
|
-
break;
|
|
19423
|
-
}
|
|
19424
|
-
}
|
|
19425
|
-
} catch {
|
|
19426
|
-
}
|
|
19427
|
-
if (!foundDynamic) {
|
|
19428
|
-
return null;
|
|
19429
|
-
}
|
|
19430
|
-
if (isCatchAll) {
|
|
19431
|
-
break;
|
|
19432
|
-
}
|
|
19433
|
-
}
|
|
19434
|
-
const pattern = patternParts.join("/");
|
|
19435
|
-
return extractParams3(pattern, slug);
|
|
19436
|
-
}
|
|
19437
|
-
async function extractPagesRouteParams(projectDir, slug, adapter) {
|
|
19438
|
-
const { join: pathJoin } = await Promise.resolve().then(() => (init_std_path(), std_path_exports));
|
|
19439
|
-
const segments = slug ? slug.split("/").filter(Boolean) : [];
|
|
19440
|
-
const pagesDir = pathJoin(projectDir, "pages");
|
|
19441
|
-
const routeExtensions = [".tsx", ".jsx", ".ts", ".js", ".mdx"];
|
|
19442
|
-
const patternParts = [];
|
|
19443
|
-
let currentDir = pagesDir;
|
|
19444
|
-
for (let i = 0; i < segments.length; i++) {
|
|
19445
|
-
const segment = segments[i];
|
|
19446
|
-
if (!segment)
|
|
19447
|
-
continue;
|
|
19448
|
-
const exactPath = pathJoin(currentDir, segment);
|
|
19449
|
-
try {
|
|
19450
|
-
const stat2 = await adapter.fs.stat(exactPath);
|
|
19451
|
-
if (stat2.isDirectory) {
|
|
19452
|
-
currentDir = exactPath;
|
|
19453
|
-
patternParts.push(segment);
|
|
19454
|
-
continue;
|
|
19455
|
-
}
|
|
19456
|
-
} catch {
|
|
19457
|
-
}
|
|
19458
|
-
let foundDynamic = false;
|
|
19459
|
-
try {
|
|
19460
|
-
const entries = await adapter.fs.readDir(currentDir);
|
|
19461
|
-
for await (const entry of entries) {
|
|
19462
|
-
const entryName = entry.name;
|
|
19463
|
-
if (isDynamicSegment2(entryName)) {
|
|
19464
|
-
const _paramName = entryName.replace(/\[\.\.\.|\[|\]/g, "");
|
|
19465
|
-
const isCatchAll = entryName.startsWith("[...");
|
|
19466
|
-
const isFile = routeExtensions.some((ext) => entryName.endsWith(ext));
|
|
19467
|
-
if (isFile && i === segments.length - 1) {
|
|
19468
|
-
patternParts.push(entryName.replace(/\.(tsx|jsx|ts|js|mdx)$/, ""));
|
|
19469
|
-
foundDynamic = true;
|
|
19470
|
-
break;
|
|
19471
|
-
} else if (entry.isDirectory) {
|
|
19472
|
-
currentDir = pathJoin(currentDir, entryName);
|
|
19473
|
-
patternParts.push(entryName);
|
|
19474
|
-
foundDynamic = true;
|
|
19475
|
-
if (isCatchAll) {
|
|
19476
|
-
break;
|
|
19477
|
-
}
|
|
19478
|
-
break;
|
|
19479
|
-
}
|
|
19480
|
-
}
|
|
19481
|
-
}
|
|
19482
|
-
} catch {
|
|
19483
|
-
}
|
|
19484
|
-
if (!foundDynamic) {
|
|
19485
|
-
return null;
|
|
19486
|
-
}
|
|
19487
|
-
}
|
|
19488
|
-
const pattern = patternParts.join("/");
|
|
19489
|
-
return extractParams(pattern, slug);
|
|
19490
|
-
}
|
|
19491
|
-
function isDynamicSegment2(name) {
|
|
19492
|
-
return name.startsWith("[") && name.endsWith("]");
|
|
19493
|
-
}
|
|
19494
|
-
var init_route_params_extractor = __esm({
|
|
19495
|
-
"src/rendering/route-params-extractor.ts"() {
|
|
19496
|
-
"use strict";
|
|
19497
|
-
init_routing();
|
|
19498
18894
|
}
|
|
19499
18895
|
});
|
|
19500
18896
|
|
|
@@ -19606,18 +19002,11 @@ var init_layout_collector = __esm({
|
|
|
19606
19002
|
this.config = options.config;
|
|
19607
19003
|
this.compileMDX = options.compileMDX;
|
|
19608
19004
|
}
|
|
19609
|
-
/**
|
|
19610
|
-
* Collect all layouts for a given page
|
|
19611
|
-
* Includes both named layouts and nested directory layouts
|
|
19612
|
-
*/
|
|
19613
19005
|
async collectLayouts(pageInfo) {
|
|
19614
19006
|
const layoutBundle = await this.collectNamedLayout(pageInfo);
|
|
19615
19007
|
const nestedLayouts = await this.collectNestedLayouts(pageInfo);
|
|
19616
19008
|
return { layoutBundle, nestedLayouts };
|
|
19617
19009
|
}
|
|
19618
|
-
/**
|
|
19619
|
-
* Collect named layout from frontmatter
|
|
19620
|
-
*/
|
|
19621
19010
|
async collectNamedLayout(pageInfo) {
|
|
19622
19011
|
const layoutValue = pageInfo.entity.frontmatter.layout;
|
|
19623
19012
|
const layoutName = typeof layoutValue === "boolean" && !layoutValue || layoutValue === "false" ? null : (typeof layoutValue === "string" ? layoutValue : null) || this.config?.defaultLayout || null;
|
|
@@ -19643,9 +19032,6 @@ var init_layout_collector = __esm({
|
|
|
19643
19032
|
});
|
|
19644
19033
|
return layoutBundle;
|
|
19645
19034
|
}
|
|
19646
|
-
/**
|
|
19647
|
-
* Collect nested directory layouts (layout.tsx, layout.mdx)
|
|
19648
|
-
*/
|
|
19649
19035
|
async collectNestedLayouts(pageInfo) {
|
|
19650
19036
|
const pageFilePath = pageInfo.entity.id;
|
|
19651
19037
|
const useAppRouter = await detectAppRouter(this.projectDir, this.config, this.adapter);
|
|
@@ -19664,9 +19050,6 @@ var init_layout_collector = __esm({
|
|
|
19664
19050
|
return await this.collectFilesystemLayouts(pageFilePath, useAppRouter);
|
|
19665
19051
|
}
|
|
19666
19052
|
}
|
|
19667
|
-
/**
|
|
19668
|
-
* Collect layouts from API project configuration
|
|
19669
|
-
*/
|
|
19670
19053
|
async collectAPILayoutConfiguration(wrappedAdapter) {
|
|
19671
19054
|
const nestedLayouts = [];
|
|
19672
19055
|
const projectData = wrappedAdapter.getProjectData();
|
|
@@ -19695,9 +19078,6 @@ var init_layout_collector = __esm({
|
|
|
19695
19078
|
}
|
|
19696
19079
|
return nestedLayouts;
|
|
19697
19080
|
}
|
|
19698
|
-
/**
|
|
19699
|
-
* Collect layouts from traditional filesystem structure
|
|
19700
|
-
*/
|
|
19701
19081
|
async collectFilesystemLayouts(pageFilePath, useAppRouter) {
|
|
19702
19082
|
const rootDir = useAppRouter ? join2(this.projectDir, "app") : join2(this.projectDir, "pages");
|
|
19703
19083
|
const nestedLayouts = await discoverNestedLayouts(
|
|
@@ -19741,16 +19121,9 @@ var init_layout_compiler = __esm({
|
|
|
19741
19121
|
this.adapter = options.adapter;
|
|
19742
19122
|
this.compileMDX = options.compileMDX;
|
|
19743
19123
|
}
|
|
19744
|
-
/**
|
|
19745
|
-
* Compile all MDX layouts in the layout items array
|
|
19746
|
-
*/
|
|
19747
19124
|
async compileLayouts(layouts) {
|
|
19748
19125
|
await compileMDXLayouts(layouts, this.compileMDX, this.adapter);
|
|
19749
19126
|
}
|
|
19750
|
-
/**
|
|
19751
|
-
* Compute dependency hash for persistent cache
|
|
19752
|
-
* Includes hashes of layout bundles, nested layouts, and providers
|
|
19753
|
-
*/
|
|
19754
19127
|
async computeDependencyHash(layoutBundle, nestedLayouts, providerInfos) {
|
|
19755
19128
|
let depsHash = "";
|
|
19756
19129
|
try {
|
|
@@ -20257,13 +19630,7 @@ async function tryLoadReservedInDirs(dirs, which, projectDir, _mode, adapter) {
|
|
|
20257
19630
|
);
|
|
20258
19631
|
if (typeof Cmp === "function")
|
|
20259
19632
|
return Cmp;
|
|
20260
|
-
} catch
|
|
20261
|
-
try {
|
|
20262
|
-
const { rendererLogger: rendererLogger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
|
|
20263
|
-
rendererLogger2.debug("reserved component probe miss", e);
|
|
20264
|
-
} catch (logError) {
|
|
20265
|
-
rendererLogger.warn("Failed to log reserved component probe miss:", logError);
|
|
20266
|
-
}
|
|
19633
|
+
} catch {
|
|
20267
19634
|
}
|
|
20268
19635
|
}
|
|
20269
19636
|
}
|
|
@@ -20303,10 +19670,6 @@ var init_layout_applicator = __esm({
|
|
|
20303
19670
|
this.mode = options.mode;
|
|
20304
19671
|
this.moduleServerUrl = options.moduleServerUrl;
|
|
20305
19672
|
}
|
|
20306
|
-
/**
|
|
20307
|
-
* Apply all layouts and wrappers to a page element
|
|
20308
|
-
* Main entry point for layout application
|
|
20309
|
-
*/
|
|
20310
19673
|
async applyLayouts(pageElement, pageInfo, layoutBundle, nestedLayouts, providerItems) {
|
|
20311
19674
|
let wrappedElement = await this.applyLayoutsAndProviders(
|
|
20312
19675
|
pageElement,
|
|
@@ -20323,10 +19686,6 @@ var init_layout_applicator = __esm({
|
|
|
20323
19686
|
}
|
|
20324
19687
|
return wrappedElement;
|
|
20325
19688
|
}
|
|
20326
|
-
/**
|
|
20327
|
-
* Apply nested layouts and providers
|
|
20328
|
-
* Chooses between ESM and function-body wrapping modes
|
|
20329
|
-
*/
|
|
20330
19689
|
async applyLayoutsAndProviders(pageElement, layoutBundle, nestedLayouts, providerItems) {
|
|
20331
19690
|
rendererLogger.info("Number of nested layouts found:", nestedLayouts.length);
|
|
20332
19691
|
const useESMWrap = Boolean(this.config?.experimental?.esmLayouts);
|
|
@@ -20346,9 +19705,6 @@ var init_layout_applicator = __esm({
|
|
|
20346
19705
|
);
|
|
20347
19706
|
}
|
|
20348
19707
|
}
|
|
20349
|
-
/**
|
|
20350
|
-
* Apply layouts using ESM wrapping (dynamic import)
|
|
20351
|
-
*/
|
|
20352
19708
|
async applyLayoutsESMMode(pageElement, layoutBundle, nestedLayouts, providerItems) {
|
|
20353
19709
|
return await applyLayoutsESM(
|
|
20354
19710
|
pageElement,
|
|
@@ -20361,9 +19717,6 @@ var init_layout_applicator = __esm({
|
|
|
20361
19717
|
this.adapter
|
|
20362
19718
|
);
|
|
20363
19719
|
}
|
|
20364
|
-
/**
|
|
20365
|
-
* Apply layouts using function-body wrapping
|
|
20366
|
-
*/
|
|
20367
19720
|
async applyLayoutsFunctionBodyMode(pageElement, layoutBundle, nestedLayouts, providerItems) {
|
|
20368
19721
|
return await applyLayoutsFunctionBody(
|
|
20369
19722
|
pageElement,
|
|
@@ -20376,9 +19729,6 @@ var init_layout_applicator = __esm({
|
|
|
20376
19729
|
this.adapter
|
|
20377
19730
|
);
|
|
20378
19731
|
}
|
|
20379
|
-
/**
|
|
20380
|
-
* Wrap page with App component for Pages Router
|
|
20381
|
-
*/
|
|
20382
19732
|
async wrapWithAppComponent(pageElement) {
|
|
20383
19733
|
const React11 = await getProjectReact();
|
|
20384
19734
|
try {
|
|
@@ -20409,9 +19759,6 @@ var init_layout_applicator = __esm({
|
|
|
20409
19759
|
}
|
|
20410
19760
|
return pageElement;
|
|
20411
19761
|
}
|
|
20412
|
-
/**
|
|
20413
|
-
* Wrap page with App Router reserved components (loading, error)
|
|
20414
|
-
*/
|
|
20415
19762
|
async wrapWithReservedComponents(pageElement, pageFilePath) {
|
|
20416
19763
|
const React11 = await getProjectReact();
|
|
20417
19764
|
try {
|
|
@@ -20466,9 +19813,6 @@ var init_provider_manager = __esm({
|
|
|
20466
19813
|
this.adapter = options.adapter;
|
|
20467
19814
|
this.compileMDX = options.compileMDX;
|
|
20468
19815
|
}
|
|
20469
|
-
/**
|
|
20470
|
-
* Collect and compile all providers
|
|
20471
|
-
*/
|
|
20472
19816
|
async collectProviders() {
|
|
20473
19817
|
const providerInfos = await this.discoverProviders();
|
|
20474
19818
|
const { providerBundles, providerItems } = await this.compileProviders(providerInfos);
|
|
@@ -20478,9 +19822,6 @@ var init_provider_manager = __esm({
|
|
|
20478
19822
|
});
|
|
20479
19823
|
return { providerBundles, providerItems, providerInfos };
|
|
20480
19824
|
}
|
|
20481
|
-
/**
|
|
20482
|
-
* Discover provider entities from the file system
|
|
20483
|
-
*/
|
|
20484
19825
|
async discoverProviders() {
|
|
20485
19826
|
const providerInfos = await getProviderEntities(this.projectDir, this.adapter);
|
|
20486
19827
|
rendererLogger.debug("[ProviderManager] Discovered providers", {
|
|
@@ -20488,9 +19829,6 @@ var init_provider_manager = __esm({
|
|
|
20488
19829
|
});
|
|
20489
19830
|
return providerInfos;
|
|
20490
19831
|
}
|
|
20491
|
-
/**
|
|
20492
|
-
* Compile all provider entities
|
|
20493
|
-
*/
|
|
20494
19832
|
async compileProviders(providerInfos) {
|
|
20495
19833
|
const providerBundles = [];
|
|
20496
19834
|
const providerItems = [];
|
|
@@ -20528,9 +19866,6 @@ var init_provider_manager = __esm({
|
|
|
20528
19866
|
}
|
|
20529
19867
|
return { providerBundles, providerItems };
|
|
20530
19868
|
}
|
|
20531
|
-
/**
|
|
20532
|
-
* Compile a single provider entity (MDX only)
|
|
20533
|
-
*/
|
|
20534
19869
|
async compileProvider(providerInfo) {
|
|
20535
19870
|
rendererLogger.debug("[ProviderManager] Compiling MDX provider", {
|
|
20536
19871
|
providerId: providerInfo.entity.id,
|
|
@@ -20721,9 +20056,6 @@ var init_component_handling = __esm({
|
|
|
20721
20056
|
|
|
20722
20057
|
// src/rendering/page-rendering.ts
|
|
20723
20058
|
async function handleMDXPage(pageInfo, slug, projectDir, mergedComponents, compileMDX2, adapter, options) {
|
|
20724
|
-
rendererLogger.info(`Checking for pre-compiled MDX: projectDir=${projectDir}, slug=${slug}`);
|
|
20725
|
-
const hasCompiled = false;
|
|
20726
|
-
rendererLogger.info(`Checking for pre-compiled MDX for ${slug}: ${hasCompiled}`);
|
|
20727
20059
|
const fmArg = pageInfo.entity.frontmatter && Object.keys(pageInfo.entity.frontmatter).length > 0 ? pageInfo.entity.frontmatter : void 0;
|
|
20728
20060
|
const pageBundle = await compileMDX2(pageInfo.entity.content, fmArg, pageInfo.entity.id);
|
|
20729
20061
|
let collectedMetadata = {};
|
|
@@ -20834,11 +20166,7 @@ var init_html_detection = __esm({
|
|
|
20834
20166
|
|
|
20835
20167
|
// src/html/metadata-extraction.ts
|
|
20836
20168
|
function extractHTMLMetadata(pageFrontmatter, layoutFrontmatter) {
|
|
20837
|
-
const base = {
|
|
20838
|
-
...layoutFrontmatter || {
|
|
20839
|
-
/* empty */
|
|
20840
|
-
}
|
|
20841
|
-
};
|
|
20169
|
+
const base = { ...layoutFrontmatter || {} };
|
|
20842
20170
|
const merged = { ...base, ...pageFrontmatter };
|
|
20843
20171
|
if (merged.metadata && typeof merged.metadata === "object") {
|
|
20844
20172
|
Object.assign(merged, merged.metadata);
|
|
@@ -21020,7 +20348,7 @@ function getDevStyles() {
|
|
|
21020
20348
|
}
|
|
21021
20349
|
</style>`;
|
|
21022
20350
|
}
|
|
21023
|
-
function getDevScripts(
|
|
20351
|
+
function getDevScripts(port = DEFAULT_DASHBOARD_PORT) {
|
|
21024
20352
|
const reloadDelay = HMR_CLIENT_RELOAD_DELAY_MS;
|
|
21025
20353
|
return `
|
|
21026
20354
|
<script>
|
|
@@ -21997,24 +21325,7 @@ var init_unocss_generator = __esm({
|
|
|
21997
21325
|
|
|
21998
21326
|
// src/html/html-shell-generator.ts
|
|
21999
21327
|
async function wrapInHTMLShell(content, meta, options, params, props) {
|
|
22000
|
-
const hasNoLayout = shouldDisableLayout(meta.frontmatter);
|
|
22001
|
-
rendererLogger.info("[HTML-SHELL] Mode received:", {
|
|
22002
|
-
mode: options.mode,
|
|
22003
|
-
modeType: typeof options.mode,
|
|
22004
|
-
slug: meta.slug
|
|
22005
|
-
});
|
|
22006
|
-
rendererLogger.info("wrapInHTMLShell called with meta:", {
|
|
22007
|
-
title: meta.title,
|
|
22008
|
-
frontmatter: meta.frontmatter,
|
|
22009
|
-
layout: meta.frontmatter?.layout,
|
|
22010
|
-
layoutType: typeof meta.frontmatter?.layout,
|
|
22011
|
-
hasNoLayout
|
|
22012
|
-
});
|
|
22013
21328
|
const tailwindCSS = await generateTailwindCSS(content);
|
|
22014
|
-
rendererLogger.info("Generated Tailwind CSS:", {
|
|
22015
|
-
cssLength: tailwindCSS.length,
|
|
22016
|
-
slug: meta.slug
|
|
22017
|
-
});
|
|
22018
21329
|
const {
|
|
22019
21330
|
effectiveTitle,
|
|
22020
21331
|
metaTags,
|
|
@@ -22043,11 +21354,7 @@ async function wrapInHTMLShell(content, meta, options, params, props) {
|
|
|
22043
21354
|
options
|
|
22044
21355
|
);
|
|
22045
21356
|
const nonce = options.nonce || "";
|
|
22046
|
-
|
|
22047
|
-
const modeScripts = (() => {
|
|
22048
|
-
rendererLogger.info("Adding scripts for mode:", options.mode, "slug:", meta.slug);
|
|
22049
|
-
return options.mode === "development" ? getDevScripts2(meta.slug || "", options.config, params, props, nonce) : getProdScripts2(meta.slug || "", params, props, nonce);
|
|
22050
|
-
})();
|
|
21357
|
+
const modeScripts = options.mode === "development" ? getDevScripts2(meta.slug || "", options.config, params, props, nonce) : getProdScripts2(meta.slug || "", params, props, nonce);
|
|
22051
21358
|
const modeStyles = options.mode === "development" ? getDevStyles2(nonce) : getProductionStyles(nonce);
|
|
22052
21359
|
const syntaxHighlightTheme = options.mode === "development" ? "github-dark" : "github";
|
|
22053
21360
|
return `<!DOCTYPE html>
|
|
@@ -22098,7 +21405,6 @@ ${tailwindCSS}
|
|
|
22098
21405
|
var init_html_shell_generator = __esm({
|
|
22099
21406
|
"src/html/html-shell-generator.ts"() {
|
|
22100
21407
|
"use strict";
|
|
22101
|
-
init_utils();
|
|
22102
21408
|
init_utils4();
|
|
22103
21409
|
init_html_escape();
|
|
22104
21410
|
init_metadata_builder();
|
|
@@ -22576,6 +21882,607 @@ var init_page_resolver = __esm({
|
|
|
22576
21882
|
}
|
|
22577
21883
|
});
|
|
22578
21884
|
|
|
21885
|
+
// src/routing/matchers/route-parser.ts
|
|
21886
|
+
var init_route_parser = __esm({
|
|
21887
|
+
"src/routing/matchers/route-parser.ts"() {
|
|
21888
|
+
"use strict";
|
|
21889
|
+
}
|
|
21890
|
+
});
|
|
21891
|
+
|
|
21892
|
+
// src/routing/matchers/route-matcher.ts
|
|
21893
|
+
var init_route_matcher = __esm({
|
|
21894
|
+
"src/routing/matchers/route-matcher.ts"() {
|
|
21895
|
+
"use strict";
|
|
21896
|
+
}
|
|
21897
|
+
});
|
|
21898
|
+
|
|
21899
|
+
// src/routing/matchers/pattern-route-matcher.ts
|
|
21900
|
+
var init_pattern_route_matcher = __esm({
|
|
21901
|
+
"src/routing/matchers/pattern-route-matcher.ts"() {
|
|
21902
|
+
"use strict";
|
|
21903
|
+
init_route_parser();
|
|
21904
|
+
init_route_matcher();
|
|
21905
|
+
init_path_utils();
|
|
21906
|
+
}
|
|
21907
|
+
});
|
|
21908
|
+
|
|
21909
|
+
// src/routing/matchers/index.ts
|
|
21910
|
+
var init_matchers = __esm({
|
|
21911
|
+
"src/routing/matchers/index.ts"() {
|
|
21912
|
+
"use strict";
|
|
21913
|
+
init_pattern_route_matcher();
|
|
21914
|
+
init_route_parser();
|
|
21915
|
+
init_route_matcher();
|
|
21916
|
+
init_utils();
|
|
21917
|
+
}
|
|
21918
|
+
});
|
|
21919
|
+
|
|
21920
|
+
// src/routing/slug-mapper/path-candidate-generator.ts
|
|
21921
|
+
var init_path_candidate_generator = __esm({
|
|
21922
|
+
"src/routing/slug-mapper/path-candidate-generator.ts"() {
|
|
21923
|
+
"use strict";
|
|
21924
|
+
init_std_path();
|
|
21925
|
+
}
|
|
21926
|
+
});
|
|
21927
|
+
|
|
21928
|
+
// src/routing/slug-mapper/slug-normalizer.ts
|
|
21929
|
+
var init_slug_normalizer = __esm({
|
|
21930
|
+
"src/routing/slug-mapper/slug-normalizer.ts"() {
|
|
21931
|
+
"use strict";
|
|
21932
|
+
}
|
|
21933
|
+
});
|
|
21934
|
+
|
|
21935
|
+
// src/routing/slug-mapper/index.ts
|
|
21936
|
+
var init_slug_mapper = __esm({
|
|
21937
|
+
"src/routing/slug-mapper/index.ts"() {
|
|
21938
|
+
"use strict";
|
|
21939
|
+
init_path_candidate_generator();
|
|
21940
|
+
init_dynamic_route_matcher();
|
|
21941
|
+
init_slug_normalizer();
|
|
21942
|
+
}
|
|
21943
|
+
});
|
|
21944
|
+
|
|
21945
|
+
// src/routing/client/dom-utils.ts
|
|
21946
|
+
function isInternalLink(target) {
|
|
21947
|
+
const href = target.getAttribute("href");
|
|
21948
|
+
if (!href)
|
|
21949
|
+
return false;
|
|
21950
|
+
if (href.startsWith("http") || href.startsWith("mailto:"))
|
|
21951
|
+
return false;
|
|
21952
|
+
if (href.startsWith("#"))
|
|
21953
|
+
return false;
|
|
21954
|
+
if (target.getAttribute("target") === "_blank" || target.getAttribute("download")) {
|
|
21955
|
+
return false;
|
|
21956
|
+
}
|
|
21957
|
+
return true;
|
|
21958
|
+
}
|
|
21959
|
+
function findAnchorElement(element) {
|
|
21960
|
+
let current = element;
|
|
21961
|
+
while (current && current.tagName !== "A") {
|
|
21962
|
+
current = current.parentElement;
|
|
21963
|
+
}
|
|
21964
|
+
if (!current || !(current instanceof HTMLAnchorElement)) {
|
|
21965
|
+
return null;
|
|
21966
|
+
}
|
|
21967
|
+
return current;
|
|
21968
|
+
}
|
|
21969
|
+
function updateMetaTags(frontmatter) {
|
|
21970
|
+
if (frontmatter.description) {
|
|
21971
|
+
updateMetaTag('meta[name="description"]', "name", "description", frontmatter.description);
|
|
21972
|
+
}
|
|
21973
|
+
if (frontmatter.ogTitle) {
|
|
21974
|
+
updateMetaTag('meta[property="og:title"]', "property", "og:title", frontmatter.ogTitle);
|
|
21975
|
+
}
|
|
21976
|
+
}
|
|
21977
|
+
function updateMetaTag(selector, attributeName, attributeValue, content) {
|
|
21978
|
+
let metaTag = document.querySelector(selector);
|
|
21979
|
+
if (!metaTag) {
|
|
21980
|
+
metaTag = document.createElement("meta");
|
|
21981
|
+
metaTag.setAttribute(attributeName, attributeValue);
|
|
21982
|
+
document.head.appendChild(metaTag);
|
|
21983
|
+
}
|
|
21984
|
+
metaTag.setAttribute("content", content);
|
|
21985
|
+
}
|
|
21986
|
+
function executeScripts(container) {
|
|
21987
|
+
const scripts = container.querySelectorAll("script");
|
|
21988
|
+
scripts.forEach((oldScript) => {
|
|
21989
|
+
const newScript = document.createElement("script");
|
|
21990
|
+
Array.from(oldScript.attributes).forEach((attribute) => {
|
|
21991
|
+
newScript.setAttribute(attribute.name, attribute.value);
|
|
21992
|
+
});
|
|
21993
|
+
newScript.textContent = oldScript.textContent;
|
|
21994
|
+
oldScript.parentNode?.replaceChild(newScript, oldScript);
|
|
21995
|
+
});
|
|
21996
|
+
}
|
|
21997
|
+
function applyHeadDirectives(container) {
|
|
21998
|
+
const nodes = container.querySelectorAll('[data-veryfront-head="1"], vf-head');
|
|
21999
|
+
if (nodes.length > 0) {
|
|
22000
|
+
cleanManagedHeadTags();
|
|
22001
|
+
}
|
|
22002
|
+
nodes.forEach((wrapper) => {
|
|
22003
|
+
processHeadWrapper(wrapper);
|
|
22004
|
+
wrapper.parentElement?.removeChild(wrapper);
|
|
22005
|
+
});
|
|
22006
|
+
}
|
|
22007
|
+
function cleanManagedHeadTags() {
|
|
22008
|
+
document.head.querySelectorAll('[data-veryfront-managed="1"]').forEach((element) => element.parentElement?.removeChild(element));
|
|
22009
|
+
}
|
|
22010
|
+
function processHeadWrapper(wrapper) {
|
|
22011
|
+
wrapper.childNodes.forEach((node2) => {
|
|
22012
|
+
if (!(node2 instanceof Element))
|
|
22013
|
+
return;
|
|
22014
|
+
const tagName = node2.tagName.toLowerCase();
|
|
22015
|
+
if (tagName === "title") {
|
|
22016
|
+
document.title = node2.textContent || document.title;
|
|
22017
|
+
return;
|
|
22018
|
+
}
|
|
22019
|
+
const clone = document.createElement(tagName);
|
|
22020
|
+
for (const attribute of Array.from(node2.attributes)) {
|
|
22021
|
+
clone.setAttribute(attribute.name, attribute.value);
|
|
22022
|
+
}
|
|
22023
|
+
if (node2.textContent && !clone.hasAttribute("src")) {
|
|
22024
|
+
clone.textContent = node2.textContent;
|
|
22025
|
+
}
|
|
22026
|
+
clone.setAttribute("data-veryfront-managed", "1");
|
|
22027
|
+
document.head.appendChild(clone);
|
|
22028
|
+
});
|
|
22029
|
+
}
|
|
22030
|
+
function manageFocus(container) {
|
|
22031
|
+
try {
|
|
22032
|
+
const focusElement = container.querySelector("[data-router-focus]") || container.querySelector("main") || container.querySelector("h1");
|
|
22033
|
+
if (focusElement && focusElement instanceof HTMLElement && "focus" in focusElement) {
|
|
22034
|
+
focusElement.focus({ preventScroll: true });
|
|
22035
|
+
}
|
|
22036
|
+
} catch (error2) {
|
|
22037
|
+
rendererLogger.warn("[router] focus management failed", error2);
|
|
22038
|
+
}
|
|
22039
|
+
}
|
|
22040
|
+
function extractPageDataFromScript() {
|
|
22041
|
+
const pageDataScript = document.querySelector("script[data-veryfront-page]");
|
|
22042
|
+
if (!pageDataScript)
|
|
22043
|
+
return null;
|
|
22044
|
+
try {
|
|
22045
|
+
const content = pageDataScript.textContent;
|
|
22046
|
+
if (!content) {
|
|
22047
|
+
rendererLogger.warn("[dom-utils] Page data script has no content");
|
|
22048
|
+
return {};
|
|
22049
|
+
}
|
|
22050
|
+
return JSON.parse(content);
|
|
22051
|
+
} catch (error2) {
|
|
22052
|
+
rendererLogger.error("[dom-utils] Failed to parse page data:", error2);
|
|
22053
|
+
return null;
|
|
22054
|
+
}
|
|
22055
|
+
}
|
|
22056
|
+
function parsePageDataFromHTML(html3) {
|
|
22057
|
+
const parser = new DOMParser();
|
|
22058
|
+
const doc = parser.parseFromString(html3, "text/html");
|
|
22059
|
+
const root = doc.getElementById("root");
|
|
22060
|
+
let content = "";
|
|
22061
|
+
if (root) {
|
|
22062
|
+
content = root.innerHTML || "";
|
|
22063
|
+
} else {
|
|
22064
|
+
rendererLogger.warn("[dom-utils] No root element found in HTML");
|
|
22065
|
+
}
|
|
22066
|
+
const pageDataScript = doc.querySelector("script[data-veryfront-page]");
|
|
22067
|
+
let pageData = {};
|
|
22068
|
+
if (pageDataScript) {
|
|
22069
|
+
try {
|
|
22070
|
+
const content2 = pageDataScript.textContent;
|
|
22071
|
+
if (!content2) {
|
|
22072
|
+
rendererLogger.warn("[dom-utils] Page data script in HTML has no content");
|
|
22073
|
+
} else {
|
|
22074
|
+
pageData = JSON.parse(content2);
|
|
22075
|
+
}
|
|
22076
|
+
} catch (error2) {
|
|
22077
|
+
rendererLogger.error("[dom-utils] Failed to parse page data from HTML:", error2);
|
|
22078
|
+
}
|
|
22079
|
+
}
|
|
22080
|
+
return { content, pageData };
|
|
22081
|
+
}
|
|
22082
|
+
var init_dom_utils = __esm({
|
|
22083
|
+
"src/routing/client/dom-utils.ts"() {
|
|
22084
|
+
"use strict";
|
|
22085
|
+
init_utils();
|
|
22086
|
+
}
|
|
22087
|
+
});
|
|
22088
|
+
|
|
22089
|
+
// src/routing/client/navigation-handlers.ts
|
|
22090
|
+
var NavigationHandlers;
|
|
22091
|
+
var init_navigation_handlers = __esm({
|
|
22092
|
+
"src/routing/client/navigation-handlers.ts"() {
|
|
22093
|
+
"use strict";
|
|
22094
|
+
init_utils();
|
|
22095
|
+
init_config();
|
|
22096
|
+
init_dom_utils();
|
|
22097
|
+
NavigationHandlers = class {
|
|
22098
|
+
constructor(prefetchDelay = DEFAULT_PREFETCH_DELAY_MS, prefetchOptions = {}) {
|
|
22099
|
+
this.prefetchQueue = /* @__PURE__ */ new Set();
|
|
22100
|
+
this.scrollPositions = /* @__PURE__ */ new Map();
|
|
22101
|
+
this.isPopStateNav = false;
|
|
22102
|
+
this.prefetchDelay = prefetchDelay;
|
|
22103
|
+
this.prefetchOptions = prefetchOptions;
|
|
22104
|
+
}
|
|
22105
|
+
createClickHandler(callbacks) {
|
|
22106
|
+
return (event) => {
|
|
22107
|
+
const anchor = findAnchorElement(event.target);
|
|
22108
|
+
if (!anchor || !isInternalLink(anchor))
|
|
22109
|
+
return;
|
|
22110
|
+
const href = anchor.getAttribute("href");
|
|
22111
|
+
event.preventDefault();
|
|
22112
|
+
callbacks.onNavigate(href);
|
|
22113
|
+
};
|
|
22114
|
+
}
|
|
22115
|
+
createPopStateHandler(callbacks) {
|
|
22116
|
+
return (_event) => {
|
|
22117
|
+
const path = globalThis.location.pathname;
|
|
22118
|
+
this.isPopStateNav = true;
|
|
22119
|
+
callbacks.onNavigate(path);
|
|
22120
|
+
};
|
|
22121
|
+
}
|
|
22122
|
+
createMouseOverHandler(callbacks) {
|
|
22123
|
+
return (event) => {
|
|
22124
|
+
const target = event.target;
|
|
22125
|
+
if (target.tagName !== "A")
|
|
22126
|
+
return;
|
|
22127
|
+
const href = target.getAttribute("href");
|
|
22128
|
+
if (!href || href.startsWith("http") || href.startsWith("#"))
|
|
22129
|
+
return;
|
|
22130
|
+
if (!this.shouldPrefetchOnHover(target))
|
|
22131
|
+
return;
|
|
22132
|
+
if (!this.prefetchQueue.has(href)) {
|
|
22133
|
+
this.prefetchQueue.add(href);
|
|
22134
|
+
setTimeout(() => {
|
|
22135
|
+
callbacks.onPrefetch(href);
|
|
22136
|
+
this.prefetchQueue.delete(href);
|
|
22137
|
+
}, this.prefetchDelay);
|
|
22138
|
+
}
|
|
22139
|
+
};
|
|
22140
|
+
}
|
|
22141
|
+
shouldPrefetchOnHover(target) {
|
|
22142
|
+
const prefetchAttribute = target.getAttribute("data-prefetch");
|
|
22143
|
+
const isHoverEnabled = Boolean(this.prefetchOptions.hover);
|
|
22144
|
+
if (prefetchAttribute === "false")
|
|
22145
|
+
return false;
|
|
22146
|
+
return prefetchAttribute === "true" || isHoverEnabled;
|
|
22147
|
+
}
|
|
22148
|
+
saveScrollPosition(path) {
|
|
22149
|
+
try {
|
|
22150
|
+
const scrollY = globalThis.scrollY;
|
|
22151
|
+
if (typeof scrollY === "number") {
|
|
22152
|
+
this.scrollPositions.set(path, scrollY);
|
|
22153
|
+
} else {
|
|
22154
|
+
rendererLogger.debug("[router] No valid scrollY value available");
|
|
22155
|
+
this.scrollPositions.set(path, 0);
|
|
22156
|
+
}
|
|
22157
|
+
} catch (error2) {
|
|
22158
|
+
rendererLogger.warn("[router] failed to record scroll position", error2);
|
|
22159
|
+
}
|
|
22160
|
+
}
|
|
22161
|
+
getScrollPosition(path) {
|
|
22162
|
+
const position = this.scrollPositions.get(path);
|
|
22163
|
+
if (position === void 0) {
|
|
22164
|
+
rendererLogger.debug(`[router] No scroll position stored for ${path}`);
|
|
22165
|
+
return 0;
|
|
22166
|
+
}
|
|
22167
|
+
return position;
|
|
22168
|
+
}
|
|
22169
|
+
isPopState() {
|
|
22170
|
+
return this.isPopStateNav;
|
|
22171
|
+
}
|
|
22172
|
+
clearPopStateFlag() {
|
|
22173
|
+
this.isPopStateNav = false;
|
|
22174
|
+
}
|
|
22175
|
+
clear() {
|
|
22176
|
+
this.prefetchQueue.clear();
|
|
22177
|
+
this.scrollPositions.clear();
|
|
22178
|
+
this.isPopStateNav = false;
|
|
22179
|
+
}
|
|
22180
|
+
};
|
|
22181
|
+
}
|
|
22182
|
+
});
|
|
22183
|
+
|
|
22184
|
+
// src/routing/client/page-loader.ts
|
|
22185
|
+
var PageLoader;
|
|
22186
|
+
var init_page_loader = __esm({
|
|
22187
|
+
"src/routing/client/page-loader.ts"() {
|
|
22188
|
+
"use strict";
|
|
22189
|
+
init_utils();
|
|
22190
|
+
init_errors();
|
|
22191
|
+
init_dom_utils();
|
|
22192
|
+
PageLoader = class {
|
|
22193
|
+
constructor() {
|
|
22194
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
22195
|
+
}
|
|
22196
|
+
getCached(path) {
|
|
22197
|
+
return this.cache.get(path);
|
|
22198
|
+
}
|
|
22199
|
+
isCached(path) {
|
|
22200
|
+
return this.cache.has(path);
|
|
22201
|
+
}
|
|
22202
|
+
setCache(path, data) {
|
|
22203
|
+
this.cache.set(path, data);
|
|
22204
|
+
}
|
|
22205
|
+
clearCache() {
|
|
22206
|
+
this.cache.clear();
|
|
22207
|
+
}
|
|
22208
|
+
async fetchPageData(path) {
|
|
22209
|
+
const jsonData = await this.tryFetchJSON(path);
|
|
22210
|
+
if (jsonData)
|
|
22211
|
+
return jsonData;
|
|
22212
|
+
return this.fetchAndParseHTML(path);
|
|
22213
|
+
}
|
|
22214
|
+
async tryFetchJSON(path) {
|
|
22215
|
+
try {
|
|
22216
|
+
const response = await fetch(`/_veryfront/data${path}.json`, {
|
|
22217
|
+
headers: { "X-Veryfront-Navigation": "client" }
|
|
22218
|
+
});
|
|
22219
|
+
if (response.ok) {
|
|
22220
|
+
return await response.json();
|
|
22221
|
+
}
|
|
22222
|
+
} catch (error2) {
|
|
22223
|
+
rendererLogger.debug(`[PageLoader] RSC fetch failed for ${path}, falling back to HTML:`, error2);
|
|
22224
|
+
}
|
|
22225
|
+
return null;
|
|
22226
|
+
}
|
|
22227
|
+
async fetchAndParseHTML(path) {
|
|
22228
|
+
const response = await fetch(path, {
|
|
22229
|
+
headers: { "X-Veryfront-Navigation": "client" }
|
|
22230
|
+
});
|
|
22231
|
+
if (!response.ok) {
|
|
22232
|
+
throw new NetworkError(`Failed to fetch ${path}`, {
|
|
22233
|
+
status: response.status,
|
|
22234
|
+
path
|
|
22235
|
+
});
|
|
22236
|
+
}
|
|
22237
|
+
const html3 = await response.text();
|
|
22238
|
+
const { content, pageData } = parsePageDataFromHTML(html3);
|
|
22239
|
+
return {
|
|
22240
|
+
html: content,
|
|
22241
|
+
...pageData
|
|
22242
|
+
};
|
|
22243
|
+
}
|
|
22244
|
+
async loadPage(path) {
|
|
22245
|
+
const cachedData = this.getCached(path);
|
|
22246
|
+
if (cachedData) {
|
|
22247
|
+
rendererLogger.debug(`Loading ${path} from cache`);
|
|
22248
|
+
return cachedData;
|
|
22249
|
+
}
|
|
22250
|
+
const data = await this.fetchPageData(path);
|
|
22251
|
+
this.setCache(path, data);
|
|
22252
|
+
return data;
|
|
22253
|
+
}
|
|
22254
|
+
async prefetch(path) {
|
|
22255
|
+
if (this.isCached(path))
|
|
22256
|
+
return;
|
|
22257
|
+
rendererLogger.debug(`Prefetching ${path}`);
|
|
22258
|
+
try {
|
|
22259
|
+
const data = await this.fetchPageData(path);
|
|
22260
|
+
this.setCache(path, data);
|
|
22261
|
+
} catch (error2) {
|
|
22262
|
+
rendererLogger.warn(`Failed to prefetch ${path}`, error2);
|
|
22263
|
+
}
|
|
22264
|
+
}
|
|
22265
|
+
};
|
|
22266
|
+
}
|
|
22267
|
+
});
|
|
22268
|
+
|
|
22269
|
+
// src/security/client/html-sanitizer.ts
|
|
22270
|
+
function isDevMode() {
|
|
22271
|
+
if (typeof globalThis !== "undefined") {
|
|
22272
|
+
const g = globalThis;
|
|
22273
|
+
return g.__VERYFRONT_DEV__ === true || g.Deno?.env?.get?.("VERYFRONT_ENV") === "development";
|
|
22274
|
+
}
|
|
22275
|
+
return false;
|
|
22276
|
+
}
|
|
22277
|
+
function validateTrustedHtml(html3, options = {}) {
|
|
22278
|
+
const { strict = false, warn = true } = options;
|
|
22279
|
+
for (const { pattern, name } of SUSPICIOUS_PATTERNS) {
|
|
22280
|
+
pattern.lastIndex = 0;
|
|
22281
|
+
if (pattern.test(html3)) {
|
|
22282
|
+
const message = `[Security] Suspicious ${name} detected in server HTML`;
|
|
22283
|
+
if (warn) {
|
|
22284
|
+
console.warn(message);
|
|
22285
|
+
}
|
|
22286
|
+
if (strict || !isDevMode()) {
|
|
22287
|
+
throw new Error(`Potentially unsafe HTML: ${name} detected`);
|
|
22288
|
+
}
|
|
22289
|
+
}
|
|
22290
|
+
}
|
|
22291
|
+
return html3;
|
|
22292
|
+
}
|
|
22293
|
+
var SUSPICIOUS_PATTERNS;
|
|
22294
|
+
var init_html_sanitizer = __esm({
|
|
22295
|
+
"src/security/client/html-sanitizer.ts"() {
|
|
22296
|
+
SUSPICIOUS_PATTERNS = [
|
|
22297
|
+
{ pattern: /<script[^>]*>[\s\S]*?<\/script>/gi, name: "inline script" },
|
|
22298
|
+
{ pattern: /javascript:/gi, name: "javascript: URL" },
|
|
22299
|
+
{ pattern: /\bon\w+\s*=/gi, name: "event handler attribute" },
|
|
22300
|
+
{ pattern: /data:\s*text\/html/gi, name: "data: HTML URL" }
|
|
22301
|
+
];
|
|
22302
|
+
}
|
|
22303
|
+
});
|
|
22304
|
+
|
|
22305
|
+
// src/routing/client/page-transition.ts
|
|
22306
|
+
var PageTransition;
|
|
22307
|
+
var init_page_transition = __esm({
|
|
22308
|
+
"src/routing/client/page-transition.ts"() {
|
|
22309
|
+
"use strict";
|
|
22310
|
+
init_utils();
|
|
22311
|
+
init_config();
|
|
22312
|
+
init_dom_utils();
|
|
22313
|
+
init_html_sanitizer();
|
|
22314
|
+
PageTransition = class {
|
|
22315
|
+
constructor(setupViewportPrefetch) {
|
|
22316
|
+
this.setupViewportPrefetch = setupViewportPrefetch;
|
|
22317
|
+
}
|
|
22318
|
+
destroy() {
|
|
22319
|
+
if (this.pendingTransitionTimeout !== void 0) {
|
|
22320
|
+
clearTimeout(this.pendingTransitionTimeout);
|
|
22321
|
+
this.pendingTransitionTimeout = void 0;
|
|
22322
|
+
}
|
|
22323
|
+
}
|
|
22324
|
+
updatePage(data, isPopState, scrollY) {
|
|
22325
|
+
if (data.frontmatter?.title) {
|
|
22326
|
+
document.title = data.frontmatter.title;
|
|
22327
|
+
}
|
|
22328
|
+
updateMetaTags(data.frontmatter ?? {});
|
|
22329
|
+
const rootElement = document.getElementById("root");
|
|
22330
|
+
if (rootElement && (data.html ?? "") !== "") {
|
|
22331
|
+
this.performTransition(rootElement, data, isPopState, scrollY);
|
|
22332
|
+
}
|
|
22333
|
+
}
|
|
22334
|
+
performTransition(rootElement, data, isPopState, scrollY) {
|
|
22335
|
+
if (this.pendingTransitionTimeout !== void 0) {
|
|
22336
|
+
clearTimeout(this.pendingTransitionTimeout);
|
|
22337
|
+
}
|
|
22338
|
+
rootElement.style.opacity = "0";
|
|
22339
|
+
this.pendingTransitionTimeout = setTimeout(() => {
|
|
22340
|
+
this.pendingTransitionTimeout = void 0;
|
|
22341
|
+
rootElement.innerHTML = validateTrustedHtml(String(data.html ?? ""));
|
|
22342
|
+
rootElement.style.opacity = "1";
|
|
22343
|
+
executeScripts(rootElement);
|
|
22344
|
+
applyHeadDirectives(rootElement);
|
|
22345
|
+
this.setupViewportPrefetch(rootElement);
|
|
22346
|
+
manageFocus(rootElement);
|
|
22347
|
+
this.handleScroll(isPopState, scrollY);
|
|
22348
|
+
}, PAGE_TRANSITION_DELAY_MS);
|
|
22349
|
+
}
|
|
22350
|
+
handleScroll(isPopState, scrollY) {
|
|
22351
|
+
try {
|
|
22352
|
+
globalThis.scrollTo(0, isPopState ? scrollY : 0);
|
|
22353
|
+
} catch (error2) {
|
|
22354
|
+
rendererLogger.warn("[router] scroll handling failed", error2);
|
|
22355
|
+
}
|
|
22356
|
+
}
|
|
22357
|
+
showError(error2) {
|
|
22358
|
+
const rootElement = document.getElementById("root");
|
|
22359
|
+
if (!rootElement)
|
|
22360
|
+
return;
|
|
22361
|
+
const errorDiv = document.createElement("div");
|
|
22362
|
+
errorDiv.className = "veryfront-error-page";
|
|
22363
|
+
const heading = document.createElement("h1");
|
|
22364
|
+
heading.textContent = "Oops! Something went wrong";
|
|
22365
|
+
const message = document.createElement("p");
|
|
22366
|
+
message.textContent = error2.message;
|
|
22367
|
+
const button = document.createElement("button");
|
|
22368
|
+
button.type = "button";
|
|
22369
|
+
button.textContent = "Reload Page";
|
|
22370
|
+
button.onclick = () => globalThis.location.reload();
|
|
22371
|
+
errorDiv.appendChild(heading);
|
|
22372
|
+
errorDiv.appendChild(message);
|
|
22373
|
+
errorDiv.appendChild(button);
|
|
22374
|
+
rootElement.innerHTML = "";
|
|
22375
|
+
rootElement.appendChild(errorDiv);
|
|
22376
|
+
}
|
|
22377
|
+
setLoadingState(loading) {
|
|
22378
|
+
const indicator = document.getElementById("veryfront-loading");
|
|
22379
|
+
if (indicator) {
|
|
22380
|
+
indicator.style.display = loading ? "block" : "none";
|
|
22381
|
+
}
|
|
22382
|
+
document.body.classList.toggle("veryfront-loading", loading);
|
|
22383
|
+
}
|
|
22384
|
+
};
|
|
22385
|
+
}
|
|
22386
|
+
});
|
|
22387
|
+
|
|
22388
|
+
// src/routing/client/viewport-prefetch.ts
|
|
22389
|
+
var ViewportPrefetch;
|
|
22390
|
+
var init_viewport_prefetch = __esm({
|
|
22391
|
+
"src/routing/client/viewport-prefetch.ts"() {
|
|
22392
|
+
"use strict";
|
|
22393
|
+
init_utils();
|
|
22394
|
+
ViewportPrefetch = class {
|
|
22395
|
+
constructor(prefetchCallback, prefetchOptions = {}) {
|
|
22396
|
+
this.observer = null;
|
|
22397
|
+
this.prefetchCallback = prefetchCallback;
|
|
22398
|
+
this.prefetchOptions = prefetchOptions;
|
|
22399
|
+
}
|
|
22400
|
+
setup(root) {
|
|
22401
|
+
try {
|
|
22402
|
+
if (!("IntersectionObserver" in globalThis))
|
|
22403
|
+
return;
|
|
22404
|
+
if (this.observer)
|
|
22405
|
+
this.observer.disconnect();
|
|
22406
|
+
this.createObserver();
|
|
22407
|
+
this.observeLinks(root);
|
|
22408
|
+
} catch (error2) {
|
|
22409
|
+
rendererLogger.debug("[router] setupViewportPrefetch failed", error2);
|
|
22410
|
+
}
|
|
22411
|
+
}
|
|
22412
|
+
createObserver() {
|
|
22413
|
+
this.observer = new IntersectionObserver(
|
|
22414
|
+
(entries) => {
|
|
22415
|
+
for (const entry of entries) {
|
|
22416
|
+
if (entry.isIntersecting) {
|
|
22417
|
+
const isAnchor = typeof HTMLAnchorElement !== "undefined" ? entry.target instanceof HTMLAnchorElement : entry.target.tagName === "A";
|
|
22418
|
+
if (isAnchor) {
|
|
22419
|
+
const href = entry.target.getAttribute("href");
|
|
22420
|
+
if (href) {
|
|
22421
|
+
this.prefetchCallback(href);
|
|
22422
|
+
}
|
|
22423
|
+
this.observer?.unobserve(entry.target);
|
|
22424
|
+
}
|
|
22425
|
+
}
|
|
22426
|
+
}
|
|
22427
|
+
},
|
|
22428
|
+
{ rootMargin: "200px" }
|
|
22429
|
+
);
|
|
22430
|
+
}
|
|
22431
|
+
observeLinks(root) {
|
|
22432
|
+
const anchors = root.querySelectorAll?.('a[href]:not([target="_blank"])') ?? document.createDocumentFragment().querySelectorAll("a");
|
|
22433
|
+
const isViewportEnabled = Boolean(this.prefetchOptions.viewport);
|
|
22434
|
+
anchors.forEach((anchor) => {
|
|
22435
|
+
if (this.shouldObserveAnchor(anchor, isViewportEnabled)) {
|
|
22436
|
+
this.observer?.observe(anchor);
|
|
22437
|
+
}
|
|
22438
|
+
});
|
|
22439
|
+
}
|
|
22440
|
+
shouldObserveAnchor(anchor, isViewportEnabled) {
|
|
22441
|
+
const href = anchor.getAttribute("href") || "";
|
|
22442
|
+
if (!href || href.startsWith("http") || href.startsWith("#") || anchor.getAttribute("download")) {
|
|
22443
|
+
return false;
|
|
22444
|
+
}
|
|
22445
|
+
const prefetchAttribute = anchor.getAttribute("data-prefetch");
|
|
22446
|
+
if (prefetchAttribute === "false")
|
|
22447
|
+
return false;
|
|
22448
|
+
return prefetchAttribute === "viewport" || isViewportEnabled;
|
|
22449
|
+
}
|
|
22450
|
+
disconnect() {
|
|
22451
|
+
if (this.observer) {
|
|
22452
|
+
try {
|
|
22453
|
+
this.observer.disconnect();
|
|
22454
|
+
} catch (error2) {
|
|
22455
|
+
rendererLogger.warn("[router] prefetchObserver.disconnect failed", error2);
|
|
22456
|
+
}
|
|
22457
|
+
this.observer = null;
|
|
22458
|
+
}
|
|
22459
|
+
}
|
|
22460
|
+
};
|
|
22461
|
+
}
|
|
22462
|
+
});
|
|
22463
|
+
|
|
22464
|
+
// src/routing/client/index.ts
|
|
22465
|
+
var init_client2 = __esm({
|
|
22466
|
+
"src/routing/client/index.ts"() {
|
|
22467
|
+
"use strict";
|
|
22468
|
+
init_dom_utils();
|
|
22469
|
+
init_navigation_handlers();
|
|
22470
|
+
init_page_loader();
|
|
22471
|
+
init_page_transition();
|
|
22472
|
+
init_viewport_prefetch();
|
|
22473
|
+
}
|
|
22474
|
+
});
|
|
22475
|
+
|
|
22476
|
+
// src/routing/index.ts
|
|
22477
|
+
var init_routing = __esm({
|
|
22478
|
+
"src/routing/index.ts"() {
|
|
22479
|
+
init_matchers();
|
|
22480
|
+
init_slug_mapper();
|
|
22481
|
+
init_client2();
|
|
22482
|
+
init_api2();
|
|
22483
|
+
}
|
|
22484
|
+
});
|
|
22485
|
+
|
|
22579
22486
|
// src/rendering/page-resolution/index.ts
|
|
22580
22487
|
var init_page_resolution = __esm({
|
|
22581
22488
|
"src/rendering/page-resolution/index.ts"() {
|
|
@@ -22961,15 +22868,9 @@ var init_compiler_service = __esm({
|
|
|
22961
22868
|
constructor() {
|
|
22962
22869
|
this._compileMDX = null;
|
|
22963
22870
|
}
|
|
22964
|
-
/**
|
|
22965
|
-
* Set the compile function
|
|
22966
|
-
*/
|
|
22967
22871
|
setCompileMDX(fn) {
|
|
22968
22872
|
this._compileMDX = fn;
|
|
22969
22873
|
}
|
|
22970
|
-
/**
|
|
22971
|
-
* Execute the compile function
|
|
22972
|
-
*/
|
|
22973
22874
|
async compileMDX(content, frontmatter, filePath) {
|
|
22974
22875
|
if (!this._compileMDX) {
|
|
22975
22876
|
throw toError(createError({
|
|
@@ -22979,9 +22880,6 @@ var init_compiler_service = __esm({
|
|
|
22979
22880
|
}
|
|
22980
22881
|
return await this._compileMDX(content, frontmatter, filePath);
|
|
22981
22882
|
}
|
|
22982
|
-
/**
|
|
22983
|
-
* Get the underlying function (if needed for direct passing)
|
|
22984
|
-
*/
|
|
22985
22883
|
getCompileFunction() {
|
|
22986
22884
|
return this.compileMDX.bind(this);
|
|
22987
22885
|
}
|
|
@@ -23015,9 +22913,6 @@ var init_lifecycle = __esm({
|
|
|
23015
22913
|
this.port = options.port;
|
|
23016
22914
|
this.moduleServerUrl = options.moduleServerUrl;
|
|
23017
22915
|
}
|
|
23018
|
-
/**
|
|
23019
|
-
* Initialize all renderer services and components
|
|
23020
|
-
*/
|
|
23021
22916
|
async initialize() {
|
|
23022
22917
|
rendererLogger.info("Initializing renderer services", {
|
|
23023
22918
|
projectDir: this.configManager.getProjectDir(),
|
|
@@ -23144,10 +23039,6 @@ var init_lifecycle = __esm({
|
|
|
23144
23039
|
rendererLogger.info("Renderer services initialized successfully");
|
|
23145
23040
|
return this.services;
|
|
23146
23041
|
}
|
|
23147
|
-
/**
|
|
23148
|
-
* Update compileMDX function in all services that need it
|
|
23149
|
-
* This is called after the renderer is created with the bound method
|
|
23150
|
-
*/
|
|
23151
23042
|
updateCompileMDX(compileMDX2) {
|
|
23152
23043
|
if (!this.services) {
|
|
23153
23044
|
throw toError(createError({
|
|
@@ -23157,9 +23048,6 @@ var init_lifecycle = __esm({
|
|
|
23157
23048
|
}
|
|
23158
23049
|
this.services.compilerService.setCompileMDX(compileMDX2);
|
|
23159
23050
|
}
|
|
23160
|
-
/**
|
|
23161
|
-
* Get initialized services
|
|
23162
|
-
*/
|
|
23163
23051
|
getServices() {
|
|
23164
23052
|
if (!this.services) {
|
|
23165
23053
|
throw toError(createError({
|
|
@@ -23169,9 +23057,6 @@ var init_lifecycle = __esm({
|
|
|
23169
23057
|
}
|
|
23170
23058
|
return this.services;
|
|
23171
23059
|
}
|
|
23172
|
-
/**
|
|
23173
|
-
* Initialize deferred components after server starts
|
|
23174
|
-
*/
|
|
23175
23060
|
async initializeComponents() {
|
|
23176
23061
|
if (!this.services) {
|
|
23177
23062
|
throw toError(createError({
|
|
@@ -23181,9 +23066,6 @@ var init_lifecycle = __esm({
|
|
|
23181
23066
|
}
|
|
23182
23067
|
await this.services.componentRegistry.initializeComponents();
|
|
23183
23068
|
}
|
|
23184
|
-
/**
|
|
23185
|
-
* Clear all caches
|
|
23186
|
-
*/
|
|
23187
23069
|
clearAllCaches() {
|
|
23188
23070
|
if (!this.services)
|
|
23189
23071
|
return;
|
|
@@ -23191,17 +23073,11 @@ var init_lifecycle = __esm({
|
|
|
23191
23073
|
this.services.virtualModules.clear();
|
|
23192
23074
|
this.services.componentRegistry.clear();
|
|
23193
23075
|
}
|
|
23194
|
-
/**
|
|
23195
|
-
* Clear cache for specific slug
|
|
23196
|
-
*/
|
|
23197
23076
|
clearSlugCache(slug) {
|
|
23198
23077
|
if (!this.services)
|
|
23199
23078
|
return;
|
|
23200
23079
|
void this.services.cacheCoordinator.clearSlug(slug);
|
|
23201
23080
|
}
|
|
23202
|
-
/**
|
|
23203
|
-
* Clean up all resources
|
|
23204
|
-
*/
|
|
23205
23081
|
async destroy() {
|
|
23206
23082
|
if (!this.services)
|
|
23207
23083
|
return;
|
|
@@ -23408,7 +23284,7 @@ function isLruIntervalDisabled3() {
|
|
|
23408
23284
|
}
|
|
23409
23285
|
try {
|
|
23410
23286
|
return process.env.VF_DISABLE_LRU_INTERVAL === "1";
|
|
23411
|
-
} catch
|
|
23287
|
+
} catch {
|
|
23412
23288
|
return false;
|
|
23413
23289
|
}
|
|
23414
23290
|
}
|
|
@@ -24171,7 +24047,6 @@ var init_link_observer = __esm({
|
|
|
24171
24047
|
this.mutationObserver = null;
|
|
24172
24048
|
this.pendingTimeouts = /* @__PURE__ */ new Map();
|
|
24173
24049
|
this.elementTimeoutMap = /* @__PURE__ */ new WeakMap();
|
|
24174
|
-
// Track which timeout belongs to which element
|
|
24175
24050
|
this.timeoutCounter = 0;
|
|
24176
24051
|
this.options = options;
|
|
24177
24052
|
this.prefetchedUrls = prefetchedUrls;
|
|
@@ -24377,7 +24252,6 @@ var init_prefetch_queue = __esm({
|
|
|
24377
24252
|
DEFAULT_OPTIONS = {
|
|
24378
24253
|
maxConcurrent: 4,
|
|
24379
24254
|
maxSize: PREFETCH_QUEUE_MAX_SIZE_BYTES,
|
|
24380
|
-
// 1MB
|
|
24381
24255
|
timeout: 5e3
|
|
24382
24256
|
};
|
|
24383
24257
|
PrefetchQueue = class {
|
|
@@ -24950,10 +24824,7 @@ async function compileMDXToJS(mdxPath, mdxContent, options) {
|
|
|
24950
24824
|
// Generated from ${mdxPath}
|
|
24951
24825
|
import * as React from "react";
|
|
24952
24826
|
|
|
24953
|
-
// Export frontmatter
|
|
24954
24827
|
export const frontmatter = ${JSON.stringify(frontmatter, null, 2)};
|
|
24955
|
-
|
|
24956
|
-
// Component imports stub
|
|
24957
24828
|
${imports.map((imp) => {
|
|
24958
24829
|
const componentName = imp.path.split("/").pop()?.replace(/\.(jsx?|tsx?)$/, "") || imp.name;
|
|
24959
24830
|
if (options.components?.includes(componentName)) {
|
|
@@ -24961,13 +24832,8 @@ ${imports.map((imp) => {
|
|
|
24961
24832
|
}
|
|
24962
24833
|
return `const ${imp.name} = () => React.createElement('div', { className: 'missing-component' }, 'Component: ${imp.name}');`;
|
|
24963
24834
|
}).join("\n")}
|
|
24964
|
-
|
|
24965
|
-
// MDX Content (remove any default export from compiled code)
|
|
24966
24835
|
${String(compiled.value).replace(/export\s+{\s*\w+\s+as\s+default\s*}/g, "").replace(/export\s+default\s+/g, "")}
|
|
24967
|
-
|
|
24968
|
-
// Wrap to accept runtime components
|
|
24969
24836
|
export default function MDXPage({ components = {} }) {
|
|
24970
|
-
// Map imported components to runtime components
|
|
24971
24837
|
${imports.map((imp) => {
|
|
24972
24838
|
const componentName = imp.path.split("/").pop()?.replace(/\.(jsx?|tsx?)$/, "") || imp.name;
|
|
24973
24839
|
return `const ${imp.name} = components["${componentName}"] || components["${imp.name}"] || (() => React.createElement('div', { className: 'missing-component' }, 'Component: ${imp.name}'));`;
|
|
@@ -25025,10 +24891,7 @@ function minifyCss(css) {
|
|
|
25025
24891
|
}
|
|
25026
24892
|
function processCssImports(css, _fromPath) {
|
|
25027
24893
|
const importRegex = /@import\s+["']([^"']+)["'];?/g;
|
|
25028
|
-
return css.replace(importRegex, (match,
|
|
25029
|
-
if (importPath.startsWith(".")) {
|
|
25030
|
-
return match;
|
|
25031
|
-
}
|
|
24894
|
+
return css.replace(importRegex, (match, _importPath) => {
|
|
25032
24895
|
return match;
|
|
25033
24896
|
});
|
|
25034
24897
|
}
|
|
@@ -25227,7 +25090,6 @@ async function bundleMdx(source, options, result, compileMDXForImport) {
|
|
|
25227
25090
|
remarkPlugins,
|
|
25228
25091
|
rehypePlugins,
|
|
25229
25092
|
providerImportSource: void 0
|
|
25230
|
-
// Don't set jsxImportSource to avoid automatic React imports
|
|
25231
25093
|
});
|
|
25232
25094
|
const slug = getSlugFromPath3(source.path);
|
|
25233
25095
|
const moduleCode = `
|
|
@@ -25292,7 +25154,6 @@ async function bundleMDXWithOptions(options) {
|
|
|
25292
25154
|
remarkPlugins: allRemarkPlugins,
|
|
25293
25155
|
rehypePlugins: allRehypePlugins,
|
|
25294
25156
|
providerImportSource: void 0
|
|
25295
|
-
// Don't set jsxImportSource to avoid automatic React imports
|
|
25296
25157
|
});
|
|
25297
25158
|
const compiledStr = String(compiled);
|
|
25298
25159
|
const dependencies = extractImports(compiledStr);
|
|
@@ -26025,9 +25886,7 @@ async function buildEmbeddedPreset(options) {
|
|
|
26025
25886
|
contents: await Deno.readTextFile(entryPath),
|
|
26026
25887
|
sourcefile: entryPath,
|
|
26027
25888
|
resolveDir: projectDir,
|
|
26028
|
-
|
|
26029
|
-
// bundling may fail; we will fall back to a stub below.
|
|
26030
|
-
loader: entryPath.endsWith(".mdx") ? "tsx" : "tsx"
|
|
25889
|
+
loader: "tsx"
|
|
26031
25890
|
},
|
|
26032
25891
|
bundle: true,
|
|
26033
25892
|
format: "esm",
|
|
@@ -27222,7 +27081,6 @@ var init_optimizer_core = __esm({
|
|
|
27222
27081
|
init_std_path();
|
|
27223
27082
|
init_utils();
|
|
27224
27083
|
init_utils();
|
|
27225
|
-
init_fs();
|
|
27226
27084
|
init_constants6();
|
|
27227
27085
|
init_sharp_loader();
|
|
27228
27086
|
init_image_finder();
|
|
@@ -27273,9 +27131,7 @@ var init_optimizer_core = __esm({
|
|
|
27273
27131
|
const relPath = relative2(this.options.inputDir, imagePath);
|
|
27274
27132
|
logger.debug(`Optimizing: ${relPath}`);
|
|
27275
27133
|
try {
|
|
27276
|
-
const
|
|
27277
|
-
const imageContent = await fs5.readFile(imagePath);
|
|
27278
|
-
const imageBuffer = new TextEncoder().encode(imageContent);
|
|
27134
|
+
const imageBuffer = await Deno.readFile(imagePath);
|
|
27279
27135
|
const image = this.sharp(imageBuffer);
|
|
27280
27136
|
const metadata = await image.metadata();
|
|
27281
27137
|
const variants = await generateImageVariants(
|
|
@@ -27958,9 +27814,6 @@ var init_registry2 = __esm({
|
|
|
27958
27814
|
getComponentNames() {
|
|
27959
27815
|
return Array.from(this.components.keys());
|
|
27960
27816
|
}
|
|
27961
|
-
getLoader() {
|
|
27962
|
-
return this.loader;
|
|
27963
|
-
}
|
|
27964
27817
|
async listComponents() {
|
|
27965
27818
|
const components = [];
|
|
27966
27819
|
for (const [name, info] of this.components) {
|
|
@@ -28445,16 +28298,7 @@ var init_api_server = __esm({
|
|
|
28445
28298
|
}
|
|
28446
28299
|
);
|
|
28447
28300
|
} catch (error2) {
|
|
28448
|
-
|
|
28449
|
-
serverLogger.error(`Error rendering page data for ${slug}:`, error2);
|
|
28450
|
-
} catch (loggingError) {
|
|
28451
|
-
const message = `[APIServer] Failed to log error: ${loggingError}
|
|
28452
|
-
`;
|
|
28453
|
-
try {
|
|
28454
|
-
console.error(message);
|
|
28455
|
-
} catch {
|
|
28456
|
-
}
|
|
28457
|
-
}
|
|
28301
|
+
serverLogger.error(`Error rendering page data for ${slug}:`, error2);
|
|
28458
28302
|
return new Response(
|
|
28459
28303
|
JSON.stringify({
|
|
28460
28304
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
@@ -28935,20 +28779,6 @@ function generateHMRClientTemplate(port, hostname, reloadDelay) {
|
|
|
28935
28779
|
});
|
|
28936
28780
|
}
|
|
28937
28781
|
|
|
28938
|
-
function updateJS(path) {
|
|
28939
|
-
// Reload page for JS updates if React Refresh is not available
|
|
28940
|
-
if (reactRefreshEnabled && window.$RefreshReg$) {
|
|
28941
|
-
try {
|
|
28942
|
-
window.$RefreshReg$(path);
|
|
28943
|
-
} catch (error) {
|
|
28944
|
-
console.error('[HMR] React Refresh failed, reloading page:', error);
|
|
28945
|
-
window.location.reload();
|
|
28946
|
-
}
|
|
28947
|
-
} else {
|
|
28948
|
-
window.location.reload();
|
|
28949
|
-
}
|
|
28950
|
-
}
|
|
28951
|
-
|
|
28952
28782
|
function setupReactRefresh() {
|
|
28953
28783
|
if (typeof window.$RefreshRuntime$ !== 'undefined') {
|
|
28954
28784
|
window.$RefreshRuntime$.injectIntoGlobalHook(window);
|
|
@@ -30833,9 +30663,8 @@ var init_dev_file_handler = __esm({
|
|
|
30833
30663
|
const absPath = await validateDevFilePath(encoded, ctx);
|
|
30834
30664
|
if (absPath.startsWith("Error:")) {
|
|
30835
30665
|
const message = absPath.replace("Error: ", "");
|
|
30836
|
-
const status = message.includes("encoding") || message.includes("outside") ? HTTP_NOT_FOUND : HTTP_NOT_FOUND;
|
|
30837
30666
|
this.logDebug("dev fs validation failed", { message }, ctx);
|
|
30838
|
-
return this.respond(this.createErrorModule(message,
|
|
30667
|
+
return this.respond(this.createErrorModule(message, HTTP_NOT_FOUND));
|
|
30839
30668
|
}
|
|
30840
30669
|
try {
|
|
30841
30670
|
const code = await bundleDevFile(absPath, ctx);
|
|
@@ -31921,7 +31750,7 @@ async function fileExists(path, fs5) {
|
|
|
31921
31750
|
return false;
|
|
31922
31751
|
}
|
|
31923
31752
|
}
|
|
31924
|
-
function
|
|
31753
|
+
function extractParams3(_pathname) {
|
|
31925
31754
|
return {};
|
|
31926
31755
|
}
|
|
31927
31756
|
var FILE_PATTERNS, ROOT_PATTERNS;
|
|
@@ -32014,7 +31843,7 @@ var init_render_handler = __esm({
|
|
|
32014
31843
|
}
|
|
32015
31844
|
buildProps(pathname, searchParams) {
|
|
32016
31845
|
return {
|
|
32017
|
-
params:
|
|
31846
|
+
params: extractParams3(pathname),
|
|
32018
31847
|
searchParams: Object.fromEntries(searchParams)
|
|
32019
31848
|
};
|
|
32020
31849
|
}
|
|
@@ -34673,11 +34502,7 @@ var init_production_server = __esm({
|
|
|
34673
34502
|
// Pass adapter to avoid re-detection
|
|
34674
34503
|
});
|
|
34675
34504
|
} catch (e) {
|
|
34676
|
-
|
|
34677
|
-
serverLogger.error("failed to start:", e);
|
|
34678
|
-
} catch (e2) {
|
|
34679
|
-
serverLogger.warn("build server render failed", e2);
|
|
34680
|
-
}
|
|
34505
|
+
serverLogger.error("Failed to start production server:", e);
|
|
34681
34506
|
}
|
|
34682
34507
|
}
|
|
34683
34508
|
}
|
|
@@ -34753,9 +34578,7 @@ init_utils();
|
|
|
34753
34578
|
init_std_path();
|
|
34754
34579
|
init_utils();
|
|
34755
34580
|
var SIZE_LIMITS = {
|
|
34756
|
-
/** Approximate bytes saved per shared dependency */
|
|
34757
34581
|
DEP_SIZE_ESTIMATE: 25e3,
|
|
34758
|
-
/** Approximate bytes saved per UI library chunk */
|
|
34759
34582
|
UI_LIB_SIZE_ESTIMATE: 15e4
|
|
34760
34583
|
};
|
|
34761
34584
|
function analyzeImports(content) {
|
|
@@ -34934,8 +34757,8 @@ async function analyzeChunksCommand(options) {
|
|
|
34934
34757
|
}
|
|
34935
34758
|
if (output) {
|
|
34936
34759
|
const fs5 = createFileSystem();
|
|
34937
|
-
const
|
|
34938
|
-
await fs5.writeTextFile(output, JSON.stringify(
|
|
34760
|
+
const manifest = generateChunkManifest(analysis);
|
|
34761
|
+
await fs5.writeTextFile(output, JSON.stringify(manifest, null, 2));
|
|
34939
34762
|
cliLogger.info(`Saved chunk manifest to ${output}`);
|
|
34940
34763
|
}
|
|
34941
34764
|
const totalSharedUsage = Array.from(analysis.sharedDeps.values()).reduce(
|
|
@@ -35029,7 +34852,7 @@ function createRenderCacheStore(type, context2) {
|
|
|
35029
34852
|
});
|
|
35030
34853
|
case "kv":
|
|
35031
34854
|
return new KVCacheStore({
|
|
35032
|
-
path: renderConfig.kvPath
|
|
34855
|
+
path: renderConfig.kvPath
|
|
35033
34856
|
});
|
|
35034
34857
|
case "redis":
|
|
35035
34858
|
if (!renderConfig.redisUrl) {
|
|
@@ -35161,10 +34984,11 @@ async function checkConfiguration(projectDir) {
|
|
|
35161
34984
|
const { getAdapter: getAdapter2 } = await Promise.resolve().then(() => (init_detect(), detect_exports));
|
|
35162
34985
|
const adapter = await getAdapter2();
|
|
35163
34986
|
const config = await getConfig(projectDir, adapter);
|
|
34987
|
+
const reactConfig = config.react;
|
|
35164
34988
|
return {
|
|
35165
34989
|
name: "Configuration",
|
|
35166
34990
|
status: "pass",
|
|
35167
|
-
message: `Loaded (React ${
|
|
34991
|
+
message: `Loaded (React ${reactConfig?.version || "auto"})`
|
|
35168
34992
|
};
|
|
35169
34993
|
} catch (error2) {
|
|
35170
34994
|
return {
|
|
@@ -35652,7 +35476,7 @@ export const POST = async (req: Request) => {
|
|
|
35652
35476
|
};
|
|
35653
35477
|
`;
|
|
35654
35478
|
await fs2.writeTextFile(join2(projectDir, "app", "api", "echo", "route.ts"), apiRoute);
|
|
35655
|
-
cliLogger.debug("Created App Router sample files
|
|
35479
|
+
cliLogger.debug("Created App Router sample files");
|
|
35656
35480
|
}
|
|
35657
35481
|
async function createAppRouterApiSample(projectDir) {
|
|
35658
35482
|
if (!fs2)
|
|
@@ -35819,7 +35643,7 @@ var fs3;
|
|
|
35819
35643
|
async function routesCommand(projectDir, options = {}) {
|
|
35820
35644
|
fs3 = createFileSystem();
|
|
35821
35645
|
const adapter = await getAdapter();
|
|
35822
|
-
|
|
35646
|
+
await getConfig(projectDir, adapter);
|
|
35823
35647
|
const pagesDir = join2(projectDir, "pages");
|
|
35824
35648
|
const apiHandler = new APIRouteHandler(projectDir, adapter);
|
|
35825
35649
|
await apiHandler.initialize();
|
|
@@ -36106,9 +35930,9 @@ try {
|
|
|
36106
35930
|
CLIENT_PREFETCH_BUNDLE2 = templates2.CLIENT_PREFETCH_BUNDLE;
|
|
36107
35931
|
} catch {
|
|
36108
35932
|
}
|
|
36109
|
-
var
|
|
35933
|
+
var IS_DENO = typeof Deno !== "undefined" && "stat" in Deno;
|
|
36110
35934
|
async function statFile(path) {
|
|
36111
|
-
if (
|
|
35935
|
+
if (IS_DENO) {
|
|
36112
35936
|
try {
|
|
36113
35937
|
const stat2 = await Deno.stat(path);
|
|
36114
35938
|
return { isFile: stat2.isFile };
|
|
@@ -36131,7 +35955,7 @@ async function statFile(path) {
|
|
|
36131
35955
|
}
|
|
36132
35956
|
}
|
|
36133
35957
|
async function readTextFile(path) {
|
|
36134
|
-
if (
|
|
35958
|
+
if (IS_DENO) {
|
|
36135
35959
|
return await Deno.readTextFile(path);
|
|
36136
35960
|
}
|
|
36137
35961
|
const fs5 = await import("node:fs/promises");
|
|
@@ -36478,8 +36302,7 @@ async function renderAppRouteToHTML(args) {
|
|
|
36478
36302
|
const st = await adapter.fs.stat(rootLayout);
|
|
36479
36303
|
if (st.isFile)
|
|
36480
36304
|
layouts.push(rootLayout);
|
|
36481
|
-
} catch
|
|
36482
|
-
serverLogger.warn?.("[build] cleanup write failed", e);
|
|
36305
|
+
} catch {
|
|
36483
36306
|
}
|
|
36484
36307
|
const segments = routePath === "/" ? [] : routePath.split("/").filter(Boolean);
|
|
36485
36308
|
let current = appRoot;
|
|
@@ -36490,8 +36313,7 @@ async function renderAppRouteToHTML(args) {
|
|
|
36490
36313
|
const st = await adapter.fs.stat(lf);
|
|
36491
36314
|
if (st.isFile)
|
|
36492
36315
|
layouts.push(lf);
|
|
36493
|
-
} catch
|
|
36494
|
-
serverLogger.warn?.("[build] copy static failed", e);
|
|
36316
|
+
} catch {
|
|
36495
36317
|
}
|
|
36496
36318
|
}
|
|
36497
36319
|
const React11 = await getProjectReact();
|
|
@@ -37853,7 +37675,7 @@ async function ensureDir2(path) {
|
|
|
37853
37675
|
}
|
|
37854
37676
|
}
|
|
37855
37677
|
function toSlug(name) {
|
|
37856
|
-
return name.replace(
|
|
37678
|
+
return name.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9_\-[\]/]/g, "").replace(/\/+/g, "/");
|
|
37857
37679
|
}
|
|
37858
37680
|
async function generateCommand(projectDir, type, name) {
|
|
37859
37681
|
fs4 = createFileSystem();
|
|
@@ -37865,8 +37687,8 @@ async function generateCommand(projectDir, type, name) {
|
|
|
37865
37687
|
const pref = cfg?.generate?.preferredRouter || cfg?.router;
|
|
37866
37688
|
if (pref === "app-router" || pref === "pages-router")
|
|
37867
37689
|
preferred = pref;
|
|
37868
|
-
} catch
|
|
37869
|
-
cliLogger.debug("Could not load config for generate command
|
|
37690
|
+
} catch {
|
|
37691
|
+
cliLogger.debug("Could not load config for generate command, using defaults");
|
|
37870
37692
|
}
|
|
37871
37693
|
const slug = toSlug(name);
|
|
37872
37694
|
switch (type) {
|
|
@@ -38393,7 +38215,6 @@ async function handleGenerateCommand(args) {
|
|
|
38393
38215
|
}
|
|
38394
38216
|
|
|
38395
38217
|
// src/cli/index/command-router.ts
|
|
38396
|
-
init_veryfront_error();
|
|
38397
38218
|
init_process();
|
|
38398
38219
|
function showBasicHelp(command) {
|
|
38399
38220
|
if (command) {
|
|
@@ -38509,11 +38330,6 @@ async function routeCommand(args) {
|
|
|
38509
38330
|
exitProcess(0);
|
|
38510
38331
|
return;
|
|
38511
38332
|
case void 0:
|
|
38512
|
-
if (args.version || args.v) {
|
|
38513
|
-
cliLogger.info(`Veryfront CLI v${VERSION}`);
|
|
38514
|
-
exitProcess(0);
|
|
38515
|
-
return;
|
|
38516
|
-
}
|
|
38517
38333
|
showBasicHelp();
|
|
38518
38334
|
exitProcess(0);
|
|
38519
38335
|
return;
|
|
@@ -38522,10 +38338,7 @@ async function routeCommand(args) {
|
|
|
38522
38338
|
`);
|
|
38523
38339
|
showBasicHelp();
|
|
38524
38340
|
exitProcess(1);
|
|
38525
|
-
|
|
38526
|
-
type: "config",
|
|
38527
|
-
message: `Unknown command: ${command}`
|
|
38528
|
-
}));
|
|
38341
|
+
return;
|
|
38529
38342
|
}
|
|
38530
38343
|
} catch (error2) {
|
|
38531
38344
|
const formattedError = error2 instanceof Error ? formatUserError(error2) : String(error2);
|