@absolutejs/absolute 0.19.0-beta.175 → 0.19.0-beta.177

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/.absolutejs/eslint-cache +1 -1
  2. package/.absolutejs/prettier.cache.json +1 -1
  3. package/.absolutejs/tsconfig.tsbuildinfo +1 -1
  4. package/ROADMAP.md +191 -191
  5. package/dist/Image-fpjk72vg.vue +140 -0
  6. package/dist/src/angular/components/image.component.d.ts +33 -0
  7. package/dist/src/angular/components/index.d.ts +1 -0
  8. package/dist/src/angular/components/index.js +395 -0
  9. package/dist/src/angular/components/index.js.map +11 -0
  10. package/dist/{angular → src/angular}/index.js +11 -1
  11. package/dist/{angular → src/angular}/index.js.map +2 -2
  12. package/dist/src/build/optimizeHtmlImages.d.ts +2 -0
  13. package/dist/{build.js → src/build.js} +496 -243
  14. package/dist/{build.js.map → src/build.js.map} +7 -5
  15. package/dist/{index.js → src/index.js} +752 -286
  16. package/dist/{index.js.map → src/index.js.map} +9 -6
  17. package/dist/src/plugins/imageOptimizer.d.ts +2 -0
  18. package/dist/src/react/components/Image.d.ts +2 -0
  19. package/dist/src/react/components/index.d.ts +1 -0
  20. package/dist/{react → src/react}/hooks/index.js +11 -1
  21. package/dist/{react → src/react}/hooks/index.js.map +2 -2
  22. package/dist/{react → src/react}/index.js +11 -1
  23. package/dist/{react → src/react}/index.js.map +2 -2
  24. package/dist/{svelte → src/svelte}/index.js +11 -1
  25. package/dist/{svelte → src/svelte}/index.js.map +2 -2
  26. package/dist/src/utils/imageProcessing.d.ts +33 -0
  27. package/dist/src/vue/components/index.d.ts +1 -0
  28. package/dist/src/vue/components/index.js +84 -0
  29. package/dist/src/vue/components/index.js.map +9 -0
  30. package/dist/{vue → src/vue}/index.js +11 -1
  31. package/dist/{vue → src/vue}/index.js.map +2 -2
  32. package/dist/types/build.d.ts +2 -0
  33. package/dist/types/image.d.ts +77 -0
  34. package/dist/types/index.d.ts +1 -0
  35. package/package.json +17 -2
  36. package/types/build.ts +3 -0
  37. package/types/image.ts +91 -0
  38. package/types/index.ts +1 -0
@@ -61,6 +61,16 @@ var __export = (target, all) => {
61
61
  set: __exportSetter.bind(all, name)
62
62
  });
63
63
  };
64
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
65
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
66
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
67
+ r = Reflect.decorate(decorators, target, key, desc);
68
+ else
69
+ for (var i = decorators.length - 1;i >= 0; i--)
70
+ if (d = decorators[i])
71
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
72
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
73
+ };
64
74
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
65
75
  var __require = import.meta.require;
66
76
 
@@ -853,15 +863,253 @@ var scanCssEntryPoints = async (dir, ignore) => {
853
863
  };
854
864
  var init_scanCssEntryPoints = () => {};
855
865
 
856
- // src/cli/scripts/telemetry.ts
866
+ // src/utils/imageProcessing.ts
857
867
  import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
858
- import { homedir } from "os";
859
868
  import { join as join2 } from "path";
869
+ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY = 75, OPTIMIZATION_ENDPOINT = "/_absolute/image", BLUR_DEVIATION = 20, sharpModule = undefined, sharpLoaded = false, sharpWarned = false, snapToSize = (target, sizes) => {
870
+ for (const size of sizes) {
871
+ if (size >= target)
872
+ return size;
873
+ }
874
+ return sizes[sizes.length - 1] ?? target;
875
+ }, matchHostname = (actual, pattern) => {
876
+ if (pattern === actual)
877
+ return true;
878
+ if (pattern.startsWith("*.")) {
879
+ const suffix = pattern.slice(1);
880
+ return actual.endsWith(suffix) && actual.length > suffix.length;
881
+ }
882
+ return false;
883
+ }, matchPathname = (actual, pattern) => {
884
+ if (pattern.endsWith("/**")) {
885
+ const prefix = pattern.slice(0, -2);
886
+ return actual.startsWith(prefix);
887
+ }
888
+ return actual === pattern;
889
+ }, MIME_MAP, callSharp = (sharpRef, input) => {
890
+ const factory = sharpRef;
891
+ return factory(input);
892
+ }, toBuffer = (input) => {
893
+ if (Buffer.isBuffer(input))
894
+ return input;
895
+ return Buffer.from(input);
896
+ }, buildOptimizedUrl = (src, width, quality, basePath = OPTIMIZATION_ENDPOINT) => `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${quality}`, formatToMime = (format) => MIME_MAP[format], generateBlurSvg = (base64Thumbnail) => {
897
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320"><filter id="b" color-interpolation-filters="sRGB"><feGaussianBlur stdDeviation="${BLUR_DEVIATION}"/><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1"/></filter><image filter="url(#b)" x="0" y="0" width="100%" height="100%" href="${base64Thumbnail}"/></svg>`;
898
+ const encoded = encodeURIComponent(svg);
899
+ return `url("data:image/svg+xml,${encoded}")`;
900
+ }, generateSrcSet = (src, width, sizes, config, loader) => {
901
+ const quality = config?.quality ?? DEFAULT_QUALITY;
902
+ const basePath = config?.path ?? OPTIMIZATION_ENDPOINT;
903
+ const buildUrl = loader ?? ((params) => buildOptimizedUrl(params.src, params.width, params.quality, basePath));
904
+ if (sizes) {
905
+ const allSizes = getAllSizes(config);
906
+ return allSizes.map((sizeWidth) => `${buildUrl({ quality, src, width: sizeWidth })} ${sizeWidth}w`).join(", ");
907
+ }
908
+ if (width) {
909
+ const allSizes = getAllSizes(config);
910
+ const w1x = snapToSize(width, allSizes);
911
+ const w2x = snapToSize(width * 2, allSizes);
912
+ return `${buildUrl({ quality, src, width: w1x })} 1x, ${buildUrl({ quality, src, width: w2x })} 2x`;
913
+ }
914
+ const deviceSizes = config?.deviceSizes ?? DEFAULT_DEVICE_SIZES;
915
+ return deviceSizes.map((sizeWidth) => `${buildUrl({ quality, src, width: sizeWidth })} ${sizeWidth}w`).join(", ");
916
+ }, getAllSizes = (config) => {
917
+ const device = config?.deviceSizes ?? DEFAULT_DEVICE_SIZES;
918
+ const image2 = config?.imageSizes ?? DEFAULT_IMAGE_SIZES;
919
+ return [...device, ...image2].sort((left, right) => left - right);
920
+ }, getCacheDir = (buildDir) => {
921
+ const dir = join2(buildDir, ".cache", "images");
922
+ if (!existsSync4(dir))
923
+ mkdirSync2(dir, { recursive: true });
924
+ return dir;
925
+ }, getCacheKey = (url, width, quality, format) => {
926
+ const hasher = new Bun.CryptoHasher("sha256");
927
+ hasher.update(`${url}|${width}|${quality}|${format}`);
928
+ return hasher.digest("hex");
929
+ }, isCacheStale = (meta) => Date.now() > meta.expireAt, matchRemotePattern = (urlString, patterns) => {
930
+ let parsed;
931
+ try {
932
+ parsed = new URL(urlString);
933
+ } catch {
934
+ return false;
935
+ }
936
+ return patterns.some((pattern) => {
937
+ if (pattern.protocol && parsed.protocol !== `${pattern.protocol}:`)
938
+ return false;
939
+ if (!matchHostname(parsed.hostname, pattern.hostname))
940
+ return false;
941
+ if (pattern.port && parsed.port !== pattern.port)
942
+ return false;
943
+ if (pattern.pathname && !matchPathname(parsed.pathname, pattern.pathname))
944
+ return false;
945
+ return true;
946
+ });
947
+ }, negotiateFormat = (acceptHeader, configuredFormats) => {
948
+ for (const format of configuredFormats) {
949
+ const mime = MIME_MAP[format];
950
+ if (mime && acceptHeader.includes(mime))
951
+ return format;
952
+ }
953
+ if (configuredFormats.includes("webp") && acceptHeader.includes("image/webp")) {
954
+ return "webp";
955
+ }
956
+ return "jpeg";
957
+ }, AVIF_QUALITY_OFFSET = 20, AVIF_EFFORT = 3, optimizeImage = async (buffer, width, quality, format) => {
958
+ const sharp = await tryLoadSharp();
959
+ if (!sharp)
960
+ return toBuffer(buffer);
961
+ const pipeline = callSharp(sharp, toBuffer(buffer)).rotate().resize(width, undefined, { withoutEnlargement: true });
962
+ switch (format) {
963
+ case "avif":
964
+ return pipeline.avif({ effort: AVIF_EFFORT, quality: Math.max(1, quality - AVIF_QUALITY_OFFSET) }).toBuffer();
965
+ case "jpeg":
966
+ return pipeline.jpeg({ mozjpeg: true, quality }).toBuffer();
967
+ case "png":
968
+ return pipeline.png({ quality }).toBuffer();
969
+ case "webp":
970
+ return pipeline.webp({ quality }).toBuffer();
971
+ default:
972
+ return toBuffer(buffer);
973
+ }
974
+ }, readFromCache = (cacheDir, cacheKey) => {
975
+ const metaPath = join2(cacheDir, `${cacheKey}.meta`);
976
+ const dataPath = join2(cacheDir, `${cacheKey}.data`);
977
+ if (!existsSync4(metaPath) || !existsSync4(dataPath))
978
+ return null;
979
+ try {
980
+ const meta = JSON.parse(readFileSync(metaPath, "utf-8"));
981
+ const buffer = readFileSync(dataPath);
982
+ return { buffer, meta };
983
+ } catch {
984
+ return null;
985
+ }
986
+ }, tryLoadSharp = async () => {
987
+ if (sharpLoaded)
988
+ return sharpModule;
989
+ sharpLoaded = true;
990
+ try {
991
+ const name = "sharp";
992
+ const mod = await import(name);
993
+ sharpModule = mod.default ?? mod;
994
+ return sharpModule;
995
+ } catch {
996
+ if (sharpWarned)
997
+ return null;
998
+ sharpWarned = true;
999
+ console.warn("[image] sharp not installed \u2014 serving unoptimized images. Install with: bun add sharp");
1000
+ return null;
1001
+ }
1002
+ }, writeToCache = (cacheDir, cacheKey, buffer, meta) => {
1003
+ const metaPath = join2(cacheDir, `${cacheKey}.meta`);
1004
+ const dataPath = join2(cacheDir, `${cacheKey}.data`);
1005
+ writeFileSync(dataPath, buffer);
1006
+ writeFileSync(metaPath, JSON.stringify(meta));
1007
+ };
1008
+ var init_imageProcessing = __esm(() => {
1009
+ DEFAULT_DEVICE_SIZES = [
1010
+ 640,
1011
+ 750,
1012
+ 828,
1013
+ 1080,
1014
+ 1200,
1015
+ 1920,
1016
+ 2048,
1017
+ 3840
1018
+ ];
1019
+ DEFAULT_IMAGE_SIZES = [
1020
+ 16,
1021
+ 32,
1022
+ 48,
1023
+ 64,
1024
+ 96,
1025
+ 128,
1026
+ 256,
1027
+ 384
1028
+ ];
1029
+ MIME_MAP = {
1030
+ avif: "image/avif",
1031
+ jpeg: "image/jpeg",
1032
+ png: "image/png",
1033
+ webp: "image/webp"
1034
+ };
1035
+ });
1036
+
1037
+ // src/build/optimizeHtmlImages.ts
1038
+ var exports_optimizeHtmlImages = {};
1039
+ __export(exports_optimizeHtmlImages, {
1040
+ optimizeHtmlImages: () => optimizeHtmlImages
1041
+ });
1042
+ import { readFile, writeFile as writeFile2 } from "fs/promises";
1043
+ var IMG_REGEX, getAttr = (attrs, name) => {
1044
+ const regex = new RegExp(`${name}\\s*=\\s*["']([^"']*)["']`, "i");
1045
+ const match = regex.exec(attrs);
1046
+ return match ? match[1] : undefined;
1047
+ }, removeAttr = (attrs, name) => attrs.replace(new RegExp(`\\s*${name}\\s*=\\s*["'][^"']*["']`, "gi"), ""), transformImgTag = (fullMatch, before, after, config) => {
1048
+ const attrs = before + after;
1049
+ const src = getAttr(attrs, "src");
1050
+ if (!src)
1051
+ return fullMatch;
1052
+ const widthStr = getAttr(attrs, "width");
1053
+ const sizes = getAttr(attrs, "sizes");
1054
+ const quality = config?.quality ?? DEFAULT_QUALITY;
1055
+ const basePath = config?.path ?? OPTIMIZATION_ENDPOINT;
1056
+ const width = widthStr ? parseInt(widthStr, 10) : undefined;
1057
+ const optimizedSrc = buildOptimizedUrl(src, width ?? 0, quality, basePath);
1058
+ let srcset;
1059
+ if (sizes) {
1060
+ const allSizes = getAllSizes(config);
1061
+ srcset = allSizes.map((sizeWidth) => `${buildOptimizedUrl(src, sizeWidth, quality, basePath)} ${sizeWidth}w`).join(", ");
1062
+ } else if (width) {
1063
+ const allSizes = getAllSizes(config);
1064
+ const w1x = snapUp(width, allSizes);
1065
+ const w2x = snapUp(width * 2, allSizes);
1066
+ srcset = `${buildOptimizedUrl(src, w1x, quality, basePath)} 1x, ${buildOptimizedUrl(src, w2x, quality, basePath)} 2x`;
1067
+ } else {
1068
+ const deviceSizes = config?.deviceSizes ?? [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
1069
+ srcset = deviceSizes.map((sizeWidth) => `${buildOptimizedUrl(src, sizeWidth, quality, basePath)} ${sizeWidth}w`).join(", ");
1070
+ }
1071
+ let cleanAttrs = removeAttr(attrs, "data-optimized");
1072
+ cleanAttrs = removeAttr(cleanAttrs, "src");
1073
+ cleanAttrs = removeAttr(cleanAttrs, "loading");
1074
+ cleanAttrs = removeAttr(cleanAttrs, "decoding");
1075
+ cleanAttrs = cleanAttrs.trim();
1076
+ const resolvedSizes = sizes ?? (width ? undefined : "100vw");
1077
+ const sizesAttr = resolvedSizes ? ` sizes="${resolvedSizes}"` : "";
1078
+ return `<img src="${optimizedSrc}" srcset="${srcset}"${sizesAttr} ${cleanAttrs} loading="lazy" decoding="async">`;
1079
+ }, snapUp = (target, sizes) => {
1080
+ for (const size of sizes) {
1081
+ if (size >= target)
1082
+ return size;
1083
+ }
1084
+ return sizes[sizes.length - 1] ?? target;
1085
+ }, optimizeHtmlImages = async (directory, config) => {
1086
+ const htmlFiles = await scanEntryPoints(directory, "*.html");
1087
+ const tasks = htmlFiles.map(async (filePath) => {
1088
+ const original = await readFile(filePath, "utf8");
1089
+ if (!original.includes("data-optimized"))
1090
+ return;
1091
+ const updated = original.replace(IMG_REGEX, (match, before, after) => transformImgTag(match, before, after, config));
1092
+ if (updated !== original) {
1093
+ await writeFile2(filePath, updated, "utf8");
1094
+ }
1095
+ });
1096
+ await Promise.all(tasks);
1097
+ };
1098
+ var init_optimizeHtmlImages = __esm(() => {
1099
+ init_imageProcessing();
1100
+ init_scanEntryPoints();
1101
+ IMG_REGEX = /<img\s+([^>]*?)data-optimized([^>]*?)\/?>/gi;
1102
+ });
1103
+
1104
+ // src/cli/scripts/telemetry.ts
1105
+ import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
1106
+ import { homedir } from "os";
1107
+ import { join as join3 } from "path";
860
1108
  var configDir, configPath, getTelemetryConfig = () => {
861
1109
  try {
862
- if (!existsSync4(configPath))
1110
+ if (!existsSync5(configPath))
863
1111
  return null;
864
- const raw = readFileSync(configPath, "utf-8");
1112
+ const raw = readFileSync2(configPath, "utf-8");
865
1113
  const config = JSON.parse(raw);
866
1114
  return config;
867
1115
  } catch {
@@ -869,19 +1117,19 @@ var configDir, configPath, getTelemetryConfig = () => {
869
1117
  }
870
1118
  };
871
1119
  var init_telemetry = __esm(() => {
872
- configDir = join2(homedir(), ".absolutejs");
873
- configPath = join2(configDir, "telemetry.json");
1120
+ configDir = join3(homedir(), ".absolutejs");
1121
+ configPath = join3(configDir, "telemetry.json");
874
1122
  });
875
1123
 
876
1124
  // src/cli/telemetryEvent.ts
877
- import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
1125
+ import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
878
1126
  import { arch, platform } from "os";
879
- import { dirname, join as join3, parse } from "path";
1127
+ import { dirname, join as join4, parse } from "path";
880
1128
  var checkCandidate = (candidate) => {
881
- if (!existsSync5(candidate)) {
1129
+ if (!existsSync6(candidate)) {
882
1130
  return null;
883
1131
  }
884
- const pkg = JSON.parse(readFileSync2(candidate, "utf-8"));
1132
+ const pkg = JSON.parse(readFileSync3(candidate, "utf-8"));
885
1133
  if (pkg.name === "@absolutejs/absolute") {
886
1134
  const ver = pkg.version;
887
1135
  return ver;
@@ -896,7 +1144,7 @@ var checkCandidate = (candidate) => {
896
1144
  }, findPackageVersion = () => {
897
1145
  let { dir } = import.meta;
898
1146
  while (dir !== parse(dir).root) {
899
- const candidate = join3(dir, "package.json");
1147
+ const candidate = join4(dir, "package.json");
900
1148
  const version = checkCandidate(candidate);
901
1149
  if (version) {
902
1150
  return version;
@@ -939,7 +1187,7 @@ var exports_updateAssetPaths = {};
939
1187
  __export(exports_updateAssetPaths, {
940
1188
  updateAssetPaths: () => updateAssetPaths
941
1189
  });
942
- import { readFile, writeFile as writeFile2 } from "fs/promises";
1190
+ import { readFile as readFile2, writeFile as writeFile3 } from "fs/promises";
943
1191
  var replaceAssetRef = (match, prefix, dir, name, ext, suffix, manifest, filePath) => {
944
1192
  const pascal = toPascal(name);
945
1193
  let key;
@@ -971,9 +1219,9 @@ var replaceAssetRef = (match, prefix, dir, name, ext, suffix, manifest, filePath
971
1219
  const htmlFiles = await scanEntryPoints(directory, "*.html");
972
1220
  const assetRegex = /((?:<script[^>]+src=|<link[^>]*?rel=["']stylesheet["'][^>]*?href=)["'])(?!\/?(?:.*\/)?htmx\.min\.js)(\/?(?:.*\/)?)([^./"']+)(?:\.[^."'/]+)?(\.(?:js|ts|css))(["'][^>]*>)/g;
973
1221
  const tasks = htmlFiles.map(async (filePath) => {
974
- const original = await readFile(filePath, "utf8");
1222
+ const original = await readFile2(filePath, "utf8");
975
1223
  const updated = original.replace(assetRegex, (match, prefix, dir, name, ext, suffix) => replaceAssetRef(match, prefix, dir, name, ext, suffix, manifest, filePath));
976
- await writeFile2(filePath, updated, "utf8");
1224
+ await writeFile3(filePath, updated, "utf8");
977
1225
  });
978
1226
  await Promise.all(tasks);
979
1227
  };
@@ -983,12 +1231,12 @@ var init_updateAssetPaths = __esm(() => {
983
1231
  });
984
1232
 
985
1233
  // src/dev/buildHMRClient.ts
986
- import { existsSync as existsSync6 } from "fs";
1234
+ import { existsSync as existsSync7 } from "fs";
987
1235
  import { resolve as resolve3 } from "path";
988
1236
  var {build: bunBuild } = globalThis.Bun;
989
1237
  var resolveHmrClientPath = () => {
990
1238
  const fromSource = resolve3(import.meta.dir, "client/hmrClient.ts");
991
- if (existsSync6(fromSource))
1239
+ if (existsSync7(fromSource))
992
1240
  return fromSource;
993
1241
  return resolve3(import.meta.dir, "dev/client/hmrClient.ts");
994
1242
  }, hmrClientPath2, buildHMRClient = async () => {
@@ -1180,8 +1428,8 @@ var devVendorPaths = null, getDevVendorPaths = () => devVendorPaths, setDevVendo
1180
1428
  };
1181
1429
 
1182
1430
  // src/build/angularLinkerPlugin.ts
1183
- import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
1184
- import { dirname as dirname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
1431
+ import { existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
1432
+ import { dirname as dirname2, join as join5, relative as relative2, resolve as resolve5 } from "path";
1185
1433
  import { createHash } from "crypto";
1186
1434
  var CACHE_DIR, angularLinkerPlugin;
1187
1435
  var init_angularLinkerPlugin = __esm(() => {
@@ -1204,10 +1452,10 @@ var init_angularLinkerPlugin = __esm(() => {
1204
1452
  return;
1205
1453
  }
1206
1454
  const hash = createHash("md5").update(source).digest("hex");
1207
- const cachePath = join4(CACHE_DIR, `${hash}.js`);
1208
- if (existsSync7(cachePath)) {
1455
+ const cachePath = join5(CACHE_DIR, `${hash}.js`);
1456
+ if (existsSync8(cachePath)) {
1209
1457
  return {
1210
- contents: readFileSync3(cachePath, "utf-8"),
1458
+ contents: readFileSync4(cachePath, "utf-8"),
1211
1459
  loader: "js"
1212
1460
  };
1213
1461
  }
@@ -1222,8 +1470,8 @@ var init_angularLinkerPlugin = __esm(() => {
1222
1470
  linkerPlugin = mod.createEs2015LinkerPlugin({
1223
1471
  fileSystem: {
1224
1472
  dirname: dirname2,
1225
- exists: existsSync7,
1226
- readFile: readFileSync3,
1473
+ exists: existsSync8,
1474
+ readFile: readFileSync4,
1227
1475
  relative: relative2,
1228
1476
  resolve: resolve5
1229
1477
  },
@@ -1249,8 +1497,8 @@ var init_angularLinkerPlugin = __esm(() => {
1249
1497
  sourceMaps: false
1250
1498
  });
1251
1499
  const linked = result?.code ?? source;
1252
- mkdirSync3(CACHE_DIR, { recursive: true });
1253
- writeFileSync2(cachePath, linked, "utf-8");
1500
+ mkdirSync4(CACHE_DIR, { recursive: true });
1501
+ writeFileSync3(cachePath, linked, "utf-8");
1254
1502
  return { contents: linked, loader: "js" };
1255
1503
  });
1256
1504
  }
@@ -1281,7 +1529,7 @@ var init_cleanStaleOutputs = __esm(() => {
1281
1529
 
1282
1530
  // src/utils/cleanup.ts
1283
1531
  import { rm as rm3 } from "fs/promises";
1284
- import { join as join5 } from "path";
1532
+ import { join as join6 } from "path";
1285
1533
  var cleanup = async ({
1286
1534
  angularDir,
1287
1535
  reactDir,
@@ -1289,19 +1537,19 @@ var cleanup = async ({
1289
1537
  vueDir
1290
1538
  }) => {
1291
1539
  await Promise.all([
1292
- angularDir ? rm3(join5(angularDir, "generated"), {
1540
+ angularDir ? rm3(join6(angularDir, "generated"), {
1293
1541
  force: true,
1294
1542
  recursive: true
1295
1543
  }) : undefined,
1296
- reactDir ? rm3(join5(reactDir, "generated"), {
1544
+ reactDir ? rm3(join6(reactDir, "generated"), {
1297
1545
  force: true,
1298
1546
  recursive: true
1299
1547
  }) : undefined,
1300
- svelteDir ? rm3(join5(svelteDir, "generated"), {
1548
+ svelteDir ? rm3(join6(svelteDir, "generated"), {
1301
1549
  force: true,
1302
1550
  recursive: true
1303
1551
  }) : undefined,
1304
- vueDir ? rm3(join5(vueDir, "generated"), {
1552
+ vueDir ? rm3(join6(vueDir, "generated"), {
1305
1553
  force: true,
1306
1554
  recursive: true
1307
1555
  }) : undefined
@@ -1345,11 +1593,11 @@ __export(exports_compileSvelte, {
1345
1593
  compileSvelte: () => compileSvelte,
1346
1594
  clearSvelteCompilerCache: () => clearSvelteCompilerCache
1347
1595
  });
1348
- import { existsSync as existsSync8 } from "fs";
1596
+ import { existsSync as existsSync9 } from "fs";
1349
1597
  import { mkdir, stat } from "fs/promises";
1350
1598
  import {
1351
1599
  dirname as dirname3,
1352
- join as join6,
1600
+ join as join7,
1353
1601
  basename as basename2,
1354
1602
  extname as extname2,
1355
1603
  resolve as resolve8,
@@ -1360,7 +1608,7 @@ import { env } from "process";
1360
1608
  var {write, file: file2, Transpiler } = globalThis.Bun;
1361
1609
  var resolveDevClientDir2 = () => {
1362
1610
  const fromSource = resolve8(import.meta.dir, "../dev/client");
1363
- if (existsSync8(fromSource))
1611
+ if (existsSync9(fromSource))
1364
1612
  return fromSource;
1365
1613
  return resolve8(import.meta.dir, "./dev/client");
1366
1614
  }, devClientDir2, hmrClientPath3, persistentCache, sourceHashCache, clearSvelteCompilerCache = () => {
@@ -1396,10 +1644,10 @@ var resolveDevClientDir2 = () => {
1396
1644
  return null;
1397
1645
  }, compileSvelte = async (entryPoints, svelteRoot, cache = new Map, isDev = false) => {
1398
1646
  const { compile, compileModule, preprocess } = await import("svelte/compiler");
1399
- const generatedDir = join6(svelteRoot, "generated");
1400
- const clientDir = join6(generatedDir, "client");
1401
- const indexDir = join6(generatedDir, "indexes");
1402
- const serverDir = join6(generatedDir, "server");
1647
+ const generatedDir = join7(svelteRoot, "generated");
1648
+ const clientDir = join7(generatedDir, "client");
1649
+ const indexDir = join7(generatedDir, "indexes");
1650
+ const serverDir = join7(generatedDir, "server");
1403
1651
  await Promise.all([clientDir, indexDir, serverDir].map((dir) => mkdir(dir, { recursive: true })));
1404
1652
  const dev = env.NODE_ENV !== "production";
1405
1653
  const build2 = async (src) => {
@@ -1440,8 +1688,8 @@ var resolveDevClientDir2 = () => {
1440
1688
  if (!rawSpec)
1441
1689
  continue;
1442
1690
  const origSpec = rawSpec.replace(/\.svelte(?:\.(?:ts|js))?$/, ".js");
1443
- const ssrOutputDir = dirname3(join6(serverDir, relDir, `${baseName}.js`));
1444
- const clientOutputDir = dirname3(join6(clientDir, relDir, `${baseName}.js`));
1691
+ const ssrOutputDir = dirname3(join7(serverDir, relDir, `${baseName}.js`));
1692
+ const clientOutputDir = dirname3(join7(clientDir, relDir, `${baseName}.js`));
1445
1693
  const toServer = relative4(ssrOutputDir, childBuilt.ssr).replace(/\\/g, "/");
1446
1694
  const toClient = relative4(clientOutputDir, childBuilt.client).replace(/\\/g, "/");
1447
1695
  externalRewrites.set(origSpec, {
@@ -1485,8 +1733,8 @@ var resolveDevClientDir2 = () => {
1485
1733
  return `${prefix}${dots}`;
1486
1734
  return `${prefix}../../${dots}`;
1487
1735
  });
1488
- const ssrPath = join6(serverDir, relDir, `${baseName}.js`);
1489
- const clientPath = join6(clientDir, relDir, `${baseName}.js`);
1736
+ const ssrPath = join7(serverDir, relDir, `${baseName}.js`);
1737
+ const clientPath = join7(clientDir, relDir, `${baseName}.js`);
1490
1738
  await Promise.all([
1491
1739
  mkdir(dirname3(ssrPath), { recursive: true }),
1492
1740
  mkdir(dirname3(clientPath), { recursive: true })
@@ -1514,7 +1762,7 @@ var resolveDevClientDir2 = () => {
1514
1762
  await Promise.all(roots.map(async ({ client: client2 }) => {
1515
1763
  const relClientDir = dirname3(relative4(clientDir, client2));
1516
1764
  const name = basename2(client2, extname2(client2));
1517
- const indexPath = join6(indexDir, relClientDir, `${name}.js`);
1765
+ const indexPath = join7(indexDir, relClientDir, `${name}.js`);
1518
1766
  const importRaw = relative4(dirname3(indexPath), client2).split(sep2).join("/");
1519
1767
  const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
1520
1768
  const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
@@ -1559,7 +1807,7 @@ if (typeof window !== "undefined") {
1559
1807
  svelteClientPaths: roots.map(({ client: client2 }) => client2),
1560
1808
  svelteIndexPaths: roots.map(({ client: client2 }) => {
1561
1809
  const rel = dirname3(relative4(clientDir, client2));
1562
- return join6(indexDir, rel, basename2(client2));
1810
+ return join7(indexDir, rel, basename2(client2));
1563
1811
  }),
1564
1812
  svelteServerPaths: roots.map(({ ssr }) => ssr)
1565
1813
  };
@@ -1567,7 +1815,7 @@ if (typeof window !== "undefined") {
1567
1815
  var init_compileSvelte = __esm(() => {
1568
1816
  init_constants();
1569
1817
  devClientDir2 = resolveDevClientDir2();
1570
- hmrClientPath3 = join6(devClientDir2, "hmrClient.ts").replace(/\\/g, "/");
1818
+ hmrClientPath3 = join7(devClientDir2, "hmrClient.ts").replace(/\\/g, "/");
1571
1819
  persistentCache = new Map;
1572
1820
  sourceHashCache = new Map;
1573
1821
  transpiler = new Transpiler({ loader: "ts", target: "browser" });
@@ -1582,13 +1830,13 @@ __export(exports_compileVue, {
1582
1830
  compileVue: () => compileVue,
1583
1831
  clearVueHmrCaches: () => clearVueHmrCaches
1584
1832
  });
1585
- import { existsSync as existsSync9 } from "fs";
1833
+ import { existsSync as existsSync10 } from "fs";
1586
1834
  import { mkdir as mkdir2 } from "fs/promises";
1587
- import { basename as basename3, dirname as dirname4, join as join7, relative as relative5, resolve as resolve9 } from "path";
1835
+ import { basename as basename3, dirname as dirname4, join as join8, relative as relative5, resolve as resolve9 } from "path";
1588
1836
  var {file: file3, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
1589
1837
  var resolveDevClientDir3 = () => {
1590
1838
  const fromSource = resolve9(import.meta.dir, "../dev/client");
1591
- if (existsSync9(fromSource))
1839
+ if (existsSync10(fromSource))
1592
1840
  return fromSource;
1593
1841
  return resolve9(import.meta.dir, "./dev/client");
1594
1842
  }, devClientDir3, hmrClientPath4, transpiler2, scriptCache, scriptSetupCache, templateCache, styleCache, persistentBuildCache, vueSourceHashCache, vueHmrMetadata, clearVueHmrCaches = () => {
@@ -1712,7 +1960,7 @@ var resolveDevClientDir3 = () => {
1712
1960
  ];
1713
1961
  let cssOutputPaths = [];
1714
1962
  if (isEntryPoint && allCss.length) {
1715
- const cssOutputFile = join7(outputDirs.css, `${toKebab(fileBaseName)}-compiled.css`);
1963
+ const cssOutputFile = join8(outputDirs.css, `${toKebab(fileBaseName)}-compiled.css`);
1716
1964
  await mkdir2(dirname4(cssOutputFile), { recursive: true });
1717
1965
  await write2(cssOutputFile, allCss.join(`
1718
1966
  `));
@@ -1743,8 +1991,8 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1743
1991
  };
1744
1992
  const clientCode = assembleModule(generateRenderFunction(false), "render", true);
1745
1993
  const serverCode = assembleModule(generateRenderFunction(true), "ssrRender", false);
1746
- const clientOutputPath = join7(outputDirs.client, `${relativeWithoutExtension}.js`);
1747
- const serverOutputPath = join7(outputDirs.server, `${relativeWithoutExtension}.js`);
1994
+ const clientOutputPath = join8(outputDirs.client, `${relativeWithoutExtension}.js`);
1995
+ const serverOutputPath = join8(outputDirs.server, `${relativeWithoutExtension}.js`);
1748
1996
  const relDir = dirname4(relativeFilePath);
1749
1997
  const relDepth = relDir === "." ? 0 : relDir.split("/").length;
1750
1998
  const adjustImports = (code) => code.replace(/(from\s+['"])(\.\.\/(?:\.\.\/)*)/g, (_, prefix, dots) => {
@@ -1773,11 +2021,11 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1773
2021
  return result;
1774
2022
  }, compileVue = async (entryPoints, vueRootDir, isDev = false) => {
1775
2023
  const compiler = await import("@vue/compiler-sfc");
1776
- const generatedDir = join7(vueRootDir, "generated");
1777
- const clientOutputDir = join7(generatedDir, "client");
1778
- const indexOutputDir = join7(generatedDir, "indexes");
1779
- const serverOutputDir = join7(generatedDir, "server");
1780
- const cssOutputDir = join7(generatedDir, "compiled");
2024
+ const generatedDir = join8(vueRootDir, "generated");
2025
+ const clientOutputDir = join8(generatedDir, "client");
2026
+ const indexOutputDir = join8(generatedDir, "indexes");
2027
+ const serverOutputDir = join8(generatedDir, "server");
2028
+ const cssOutputDir = join8(generatedDir, "compiled");
1781
2029
  await Promise.all([
1782
2030
  mkdir2(clientOutputDir, { recursive: true }),
1783
2031
  mkdir2(indexOutputDir, { recursive: true }),
@@ -1794,8 +2042,8 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1794
2042
  }, buildCache, true, vueRootDir, compiler);
1795
2043
  result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
1796
2044
  const entryBaseName = basename3(entryPath, ".vue");
1797
- const indexOutputFile = join7(indexOutputDir, `${entryBaseName}.js`);
1798
- const clientOutputFile = join7(clientOutputDir, relative5(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
2045
+ const indexOutputFile = join8(indexOutputDir, `${entryBaseName}.js`);
2046
+ const clientOutputFile = join8(clientOutputDir, relative5(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
1799
2047
  await mkdir2(dirname4(indexOutputFile), { recursive: true });
1800
2048
  const vueHmrImports = isDev ? [
1801
2049
  `window.__HMR_FRAMEWORK__ = "vue";`,
@@ -1905,8 +2153,8 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1905
2153
  const sourceCode = await file3(tsPath).text();
1906
2154
  const transpiledCode = transpiler2.transformSync(sourceCode);
1907
2155
  const relativeJsPath = relative5(vueRootDir, tsPath).replace(/\.ts$/, ".js");
1908
- const outClientPath = join7(clientOutputDir, relativeJsPath);
1909
- const outServerPath = join7(serverOutputDir, relativeJsPath);
2156
+ const outClientPath = join8(clientOutputDir, relativeJsPath);
2157
+ const outServerPath = join8(serverOutputDir, relativeJsPath);
1910
2158
  await mkdir2(dirname4(outClientPath), { recursive: true });
1911
2159
  await mkdir2(dirname4(outServerPath), { recursive: true });
1912
2160
  await write2(outClientPath, transpiledCode);
@@ -1923,7 +2171,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1923
2171
  var init_compileVue = __esm(() => {
1924
2172
  init_constants();
1925
2173
  devClientDir3 = resolveDevClientDir3();
1926
- hmrClientPath4 = join7(devClientDir3, "hmrClient.ts").replace(/\\/g, "/");
2174
+ hmrClientPath4 = join8(devClientDir3, "hmrClient.ts").replace(/\\/g, "/");
1927
2175
  transpiler2 = new Transpiler2({ loader: "ts", target: "browser" });
1928
2176
  scriptCache = new Map;
1929
2177
  scriptSetupCache = new Map;
@@ -4213,7 +4461,7 @@ var require_typescript = __commonJS((exports, module) => {
4213
4461
  walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
4214
4462
  whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
4215
4463
  writeCommentRange: () => writeCommentRange,
4216
- writeFile: () => writeFile3,
4464
+ writeFile: () => writeFile4,
4217
4465
  writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
4218
4466
  zipWith: () => zipWith
4219
4467
  });
@@ -10005,7 +10253,7 @@ ${lanes.join(`
10005
10253
  writeOutputIsTTY() {
10006
10254
  return process.stdout.isTTY;
10007
10255
  },
10008
- readFile: readFile2,
10256
+ readFile: readFile3,
10009
10257
  writeFile: writeFile22,
10010
10258
  watchFile: watchFile2,
10011
10259
  watchDirectory,
@@ -10198,7 +10446,7 @@ ${lanes.join(`
10198
10446
  function fsWatchWorker(fileOrDirectory, recursive, callback) {
10199
10447
  return _fs.watch(fileOrDirectory, fsSupportsRecursiveFsWatch ? { persistent: true, recursive: !!recursive } : { persistent: true }, callback);
10200
10448
  }
10201
- function readFile2(fileName, _encoding) {
10449
+ function readFile3(fileName, _encoding) {
10202
10450
  let buffer;
10203
10451
  try {
10204
10452
  buffer = _fs.readFileSync(fileName);
@@ -21522,7 +21770,7 @@ ${lanes.join(`
21522
21770
  sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
21523
21771
  return combinePaths(newDirPath, sourceFilePath);
21524
21772
  }
21525
- function writeFile3(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
21773
+ function writeFile4(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
21526
21774
  host.writeFile(fileName, text, writeByteOrderMark, (hostErrorMessage) => {
21527
21775
  diagnostics.add(createCompilerDiagnostic(Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
21528
21776
  }, sourceFiles, data);
@@ -41145,7 +41393,7 @@ ${lanes.join(`
41145
41393
  const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
41146
41394
  return possibleOption ? createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : createDiagnosticForNodeInSourceFileOrCompilerDiagnostic(sourceFile, node, diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
41147
41395
  }
41148
- function parseCommandLineWorker(diagnostics, commandLine, readFile2) {
41396
+ function parseCommandLineWorker(diagnostics, commandLine, readFile3) {
41149
41397
  const options = {};
41150
41398
  let watchOptions;
41151
41399
  const fileNames = [];
@@ -41183,7 +41431,7 @@ ${lanes.join(`
41183
41431
  }
41184
41432
  }
41185
41433
  function parseResponseFile(fileName) {
41186
- const text = tryReadFile(fileName, readFile2 || ((fileName2) => sys.readFile(fileName2)));
41434
+ const text = tryReadFile(fileName, readFile3 || ((fileName2) => sys.readFile(fileName2)));
41187
41435
  if (!isString(text)) {
41188
41436
  errors.push(text);
41189
41437
  return;
@@ -41286,8 +41534,8 @@ ${lanes.join(`
41286
41534
  unknownDidYouMeanDiagnostic: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
41287
41535
  optionTypeMismatchDiagnostic: Diagnostics.Compiler_option_0_expects_an_argument
41288
41536
  };
41289
- function parseCommandLine(commandLine, readFile2) {
41290
- return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile2);
41537
+ function parseCommandLine(commandLine, readFile3) {
41538
+ return parseCommandLineWorker(compilerOptionsDidYouMeanDiagnostics, commandLine, readFile3);
41291
41539
  }
41292
41540
  function getOptionFromName(optionName, allowShort) {
41293
41541
  return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
@@ -41355,8 +41603,8 @@ ${lanes.join(`
41355
41603
  result.originalFileName = result.fileName;
41356
41604
  return parseJsonSourceFileConfigFileContent(result, host, getNormalizedAbsolutePath(getDirectoryPath(configFileName), cwd), optionsToExtend, getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
41357
41605
  }
41358
- function readConfigFile(fileName, readFile2) {
41359
- const textOrDiagnostic = tryReadFile(fileName, readFile2);
41606
+ function readConfigFile(fileName, readFile3) {
41607
+ const textOrDiagnostic = tryReadFile(fileName, readFile3);
41360
41608
  return isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
41361
41609
  }
41362
41610
  function parseConfigFileTextToJson(fileName, jsonText) {
@@ -41366,14 +41614,14 @@ ${lanes.join(`
41366
41614
  error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
41367
41615
  };
41368
41616
  }
41369
- function readJsonConfigFile(fileName, readFile2) {
41370
- const textOrDiagnostic = tryReadFile(fileName, readFile2);
41617
+ function readJsonConfigFile(fileName, readFile3) {
41618
+ const textOrDiagnostic = tryReadFile(fileName, readFile3);
41371
41619
  return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : { fileName, parseDiagnostics: [textOrDiagnostic] };
41372
41620
  }
41373
- function tryReadFile(fileName, readFile2) {
41621
+ function tryReadFile(fileName, readFile3) {
41374
41622
  let text;
41375
41623
  try {
41376
- text = readFile2(fileName);
41624
+ text = readFile3(fileName);
41377
41625
  } catch (e) {
41378
41626
  return createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
41379
41627
  }
@@ -104115,7 +104363,7 @@ ${lanes.join(`
104115
104363
  return;
104116
104364
  }
104117
104365
  const buildInfo = host.getBuildInfo() || { version };
104118
- writeFile3(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), false, undefined, { buildInfo });
104366
+ writeFile4(host, emitterDiagnostics, buildInfoPath, getBuildInfoText(buildInfo), false, undefined, { buildInfo });
104119
104367
  emittedFilesList == null || emittedFilesList.push(buildInfoPath);
104120
104368
  }
104121
104369
  function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath) {
@@ -104274,14 +104522,14 @@ ${lanes.join(`
104274
104522
  }
104275
104523
  if (sourceMapFilePath) {
104276
104524
  const sourceMap = sourceMapGenerator.toString();
104277
- writeFile3(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
104525
+ writeFile4(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
104278
104526
  }
104279
104527
  } else {
104280
104528
  writer.writeLine();
104281
104529
  }
104282
104530
  const text = writer.getText();
104283
104531
  const data = { sourceMapUrlPos, diagnostics: transform2.diagnostics };
104284
- writeFile3(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
104532
+ writeFile4(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, data);
104285
104533
  writer.clear();
104286
104534
  return !data.skippedDtsWrite;
104287
104535
  }
@@ -108803,12 +109051,12 @@ ${lanes.join(`
108803
109051
  function createCompilerHost(options, setParentNodes) {
108804
109052
  return createCompilerHostWorker(options, setParentNodes);
108805
109053
  }
108806
- function createGetSourceFile(readFile2, setParentNodes) {
109054
+ function createGetSourceFile(readFile3, setParentNodes) {
108807
109055
  return (fileName, languageVersionOrOptions, onError) => {
108808
109056
  let text;
108809
109057
  try {
108810
109058
  mark("beforeIORead");
108811
- text = readFile2(fileName);
109059
+ text = readFile3(fileName);
108812
109060
  mark("afterIORead");
108813
109061
  measure("I/O Read", "beforeIORead", "afterIORead");
108814
109062
  } catch (e) {
@@ -109599,7 +109847,7 @@ ${lanes.join(`
109599
109847
  getRedirectFromOutput,
109600
109848
  forEachResolvedProjectReference: forEachResolvedProjectReference2
109601
109849
  });
109602
- const readFile2 = host.readFile.bind(host);
109850
+ const readFile3 = host.readFile.bind(host);
109603
109851
  (_e = tracing) == null || _e.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
109604
109852
  const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
109605
109853
  (_f = tracing) == null || _f.pop();
@@ -109775,7 +110023,7 @@ ${lanes.join(`
109775
110023
  shouldTransformImportCall,
109776
110024
  emitBuildInfo,
109777
110025
  fileExists,
109778
- readFile: readFile2,
110026
+ readFile: readFile3,
109779
110027
  directoryExists,
109780
110028
  getSymlinkCache,
109781
110029
  realpath: (_o = host.realpath) == null ? undefined : _o.bind(host),
@@ -160213,7 +160461,7 @@ ${options.prefix}` : `
160213
160461
  walkUpParenthesizedTypesAndGetParentAndChild: () => walkUpParenthesizedTypesAndGetParentAndChild,
160214
160462
  whitespaceOrMapCommentRegExp: () => whitespaceOrMapCommentRegExp,
160215
160463
  writeCommentRange: () => writeCommentRange,
160216
- writeFile: () => writeFile3,
160464
+ writeFile: () => writeFile4,
160217
160465
  writeFileEnsuringDirectories: () => writeFileEnsuringDirectories,
160218
160466
  zipWith: () => zipWith
160219
160467
  });
@@ -170662,19 +170910,19 @@ __export(exports_compileAngular, {
170662
170910
  compileAngularFile: () => compileAngularFile,
170663
170911
  compileAngular: () => compileAngular
170664
170912
  });
170665
- import { existsSync as existsSync10, readFileSync as readFileSync4, promises as fs } from "fs";
170666
- import { join as join8, basename as basename4, sep as sep3, dirname as dirname5, resolve as resolve10, relative as relative6 } from "path";
170913
+ import { existsSync as existsSync11, readFileSync as readFileSync5, promises as fs } from "fs";
170914
+ import { join as join9, basename as basename4, sep as sep3, dirname as dirname5, resolve as resolve10, relative as relative6 } from "path";
170667
170915
  import { createHash as createHash2 } from "crypto";
170668
170916
  var import_typescript, computeConfigHash = () => {
170669
170917
  try {
170670
- const content = readFileSync4("./tsconfig.json", "utf-8");
170918
+ const content = readFileSync5("./tsconfig.json", "utf-8");
170671
170919
  return createHash2("md5").update(content).digest("hex");
170672
170920
  } catch {
170673
170921
  return "";
170674
170922
  }
170675
170923
  }, resolveDevClientDir4 = () => {
170676
170924
  const fromSource = resolve10(import.meta.dir, "../dev/client");
170677
- if (existsSync10(fromSource))
170925
+ if (existsSync11(fromSource))
170678
170926
  return fromSource;
170679
170927
  return resolve10(import.meta.dir, "./dev/client");
170680
170928
  }, devClientDir4, hmrClientPath5, hmrRuntimePath, injectHMRRegistration = (content, sourceId) => {
@@ -170770,7 +171018,7 @@ ${registrations}
170770
171018
  const originalGetSourceFile = host.getSourceFile;
170771
171019
  host.getSourceFile = (fileName, languageVersion, onError) => {
170772
171020
  if (fileName.startsWith("lib.") && fileName.endsWith(".d.ts") && tsLibDir) {
170773
- const resolvedPath = join8(tsLibDir, fileName);
171021
+ const resolvedPath = join9(tsLibDir, fileName);
170774
171022
  return originalGetSourceFile?.call(host, resolvedPath, languageVersion, onError);
170775
171023
  }
170776
171024
  return originalGetSourceFile?.call(host, fileName, languageVersion, onError);
@@ -170797,7 +171045,7 @@ ${registrations}
170797
171045
  });
170798
171046
  throwOnCompilationErrors(diagnostics);
170799
171047
  const entries = Object.entries(emitted).filter(([fileName]) => fileName.endsWith(".js")).map(([fileName, content]) => {
170800
- const target = join8(outDir, fileName);
171048
+ const target = join9(outDir, fileName);
170801
171049
  let processedContent = content.replace(/from\s+(['"])(\.\.?\/[^'"]+)(\1)/g, (match, quote, path) => {
170802
171050
  if (!path.match(/\.(js|ts|mjs|cjs)$/)) {
170803
171051
  return `from ${quote}${path}.js${quote}`;
@@ -170816,7 +171064,7 @@ ${registrations}
170816
171064
  await Promise.all(entries.map(({ target, content }) => fs.writeFile(target, content, "utf-8")));
170817
171065
  return entries.map(({ target }) => target);
170818
171066
  }, jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), readAndEscapeFile = async (filePath) => {
170819
- if (!existsSync10(filePath))
171067
+ if (!existsSync11(filePath))
170820
171068
  return null;
170821
171069
  const content = await fs.readFile(filePath, "utf-8");
170822
171070
  return escapeTemplateContent(content);
@@ -170824,7 +171072,7 @@ ${registrations}
170824
171072
  const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
170825
171073
  if (!templateUrlMatch?.[1])
170826
171074
  return source;
170827
- const escaped = await readAndEscapeFile(join8(fileDir, templateUrlMatch[1]));
171075
+ const escaped = await readAndEscapeFile(join9(fileDir, templateUrlMatch[1]));
170828
171076
  if (!escaped)
170829
171077
  return source;
170830
171078
  return source.replace(/templateUrl\s*:\s*['"][^'"]+['"]/, `template: \`${escaped}\``);
@@ -170837,7 +171085,7 @@ ${registrations}
170837
171085
  return source;
170838
171086
  const stylePromises = urlMatches.map((urlMatch) => {
170839
171087
  const styleUrl = urlMatch.replace(/['"]/g, "");
170840
- return readAndEscapeFile(join8(fileDir, styleUrl));
171088
+ return readAndEscapeFile(join9(fileDir, styleUrl));
170841
171089
  });
170842
171090
  const results = await Promise.all(stylePromises);
170843
171091
  const inlinedStyles = results.filter(Boolean).map((escaped) => `\`${escaped}\``);
@@ -170848,7 +171096,7 @@ ${registrations}
170848
171096
  const styleUrlMatch = source.match(/styleUrl\s*:\s*['"]([^'"]+)['"]/);
170849
171097
  if (!styleUrlMatch?.[1])
170850
171098
  return source;
170851
- const escaped = await readAndEscapeFile(join8(fileDir, styleUrlMatch[1]));
171099
+ const escaped = await readAndEscapeFile(join9(fileDir, styleUrlMatch[1]));
170852
171100
  if (!escaped)
170853
171101
  return source;
170854
171102
  return source.replace(/styleUrl\s*:\s*['"][^'"]+['"]/, `styles: [\`${escaped}\`]`);
@@ -170878,15 +171126,15 @@ ${registrations}
170878
171126
  let actualPath = resolved;
170879
171127
  if (!actualPath.endsWith(".ts"))
170880
171128
  actualPath += ".ts";
170881
- if (!existsSync10(actualPath))
171129
+ if (!existsSync11(actualPath))
170882
171130
  return;
170883
171131
  let sourceCode = await fs.readFile(actualPath, "utf-8");
170884
171132
  sourceCode = await inlineResources(sourceCode, dirname5(actualPath));
170885
171133
  const inputDir = dirname5(actualPath);
170886
171134
  const relativeDir = inputDir.startsWith(baseDir) ? inputDir.substring(baseDir.length + 1) : inputDir;
170887
171135
  const fileBase = basename4(actualPath).replace(/\.ts$/, ".js");
170888
- const targetDir = join8(outDir, relativeDir);
170889
- const targetPath = join8(targetDir, fileBase);
171136
+ const targetDir = join9(outDir, relativeDir);
171137
+ const targetPath = join9(targetDir, fileBase);
170890
171138
  const importRegex = /from\s+['"](\.\.?\/[^'"]+)['"]/g;
170891
171139
  const localImports = [];
170892
171140
  let importMatch;
@@ -170896,7 +171144,7 @@ ${registrations}
170896
171144
  }
170897
171145
  const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
170898
171146
  const cacheKey2 = actualPath;
170899
- if (jitContentCache.get(cacheKey2) === contentHash && existsSync10(targetPath)) {
171147
+ if (jitContentCache.get(cacheKey2) === contentHash && existsSync11(targetPath)) {
170900
171148
  allOutputs.push(targetPath);
170901
171149
  } else {
170902
171150
  let processedContent = angularTranspiler.transformSync(sourceCode);
@@ -170930,13 +171178,13 @@ ${registrations}
170930
171178
  await transpileFile(inputPath);
170931
171179
  return allOutputs;
170932
171180
  }, compileAngular = async (entryPoints, outRoot, hmr = false) => {
170933
- const compiledParent = join8(outRoot, "generated");
171181
+ const compiledParent = join9(outRoot, "generated");
170934
171182
  if (entryPoints.length === 0) {
170935
171183
  const emptyPaths = [];
170936
171184
  return { clientPaths: [...emptyPaths], serverPaths: [...emptyPaths] };
170937
171185
  }
170938
171186
  const compiledRoot = compiledParent;
170939
- const indexesDir = join8(compiledParent, "indexes");
171187
+ const indexesDir = join9(compiledParent, "indexes");
170940
171188
  await fs.mkdir(indexesDir, { recursive: true });
170941
171189
  const compileTasks = entryPoints.map(async (entry) => {
170942
171190
  const outputs = hmr ? await compileAngularFileJIT(entry, compiledRoot, outRoot) : await compileAngularFile(entry, compiledRoot);
@@ -170953,8 +171201,8 @@ ${registrations}
170953
171201
  const componentClassName = `${toPascal(fileBase)}Component`;
170954
171202
  const serverContentHash = Bun.hash(original).toString(BASE_36_RADIX);
170955
171203
  const cachedWrapper = wrapperOutputCache.get(entry);
170956
- const clientFile = join8(indexesDir, jsName);
170957
- if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync10(clientFile)) {
171204
+ const clientFile = join9(indexesDir, jsName);
171205
+ if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync11(clientFile)) {
170958
171206
  return { clientPath: clientFile, indexUnchanged: true, serverPath: rawServerFile };
170959
171207
  }
170960
171208
  let rewritten = original.replace(new RegExp(`templateUrl:\\s*['"]\\.\\/${fileBase}\\.html['"]`), `templateUrl: '../../pages/${fileBase}.html'`);
@@ -171048,8 +171296,8 @@ var init_compileAngular = __esm(() => {
171048
171296
  init_constants();
171049
171297
  import_typescript = __toESM(require_typescript(), 1);
171050
171298
  devClientDir4 = resolveDevClientDir4();
171051
- hmrClientPath5 = join8(devClientDir4, "hmrClient.ts").replace(/\\/g, "/");
171052
- hmrRuntimePath = join8(devClientDir4, "handlers", "angularRuntime.ts").replace(/\\/g, "/");
171299
+ hmrClientPath5 = join9(devClientDir4, "hmrClient.ts").replace(/\\/g, "/");
171300
+ hmrRuntimePath = join9(devClientDir4, "handlers", "angularRuntime.ts").replace(/\\/g, "/");
171053
171301
  jitContentCache = new Map;
171054
171302
  wrapperOutputCache = new Map;
171055
171303
  });
@@ -171060,8 +171308,8 @@ __export(exports_buildReactVendor, {
171060
171308
  computeVendorPaths: () => computeVendorPaths,
171061
171309
  buildReactVendor: () => buildReactVendor
171062
171310
  });
171063
- import { mkdirSync as mkdirSync4 } from "fs";
171064
- import { join as join9 } from "path";
171311
+ import { mkdirSync as mkdirSync5 } from "fs";
171312
+ import { join as join10 } from "path";
171065
171313
  import { rm as rm4 } from "fs/promises";
171066
171314
  var {build: bunBuild2 } = globalThis.Bun;
171067
171315
  var reactSpecifiers, isResolvable = (specifier) => {
@@ -171096,14 +171344,14 @@ var reactSpecifiers, isResolvable = (specifier) => {
171096
171344
  `)}
171097
171345
  `;
171098
171346
  }, buildReactVendor = async (buildDir) => {
171099
- const vendorDir = join9(buildDir, "react", "vendor");
171100
- mkdirSync4(vendorDir, { recursive: true });
171101
- const tmpDir = join9(buildDir, "_vendor_tmp");
171102
- mkdirSync4(tmpDir, { recursive: true });
171347
+ const vendorDir = join10(buildDir, "react", "vendor");
171348
+ mkdirSync5(vendorDir, { recursive: true });
171349
+ const tmpDir = join10(buildDir, "_vendor_tmp");
171350
+ mkdirSync5(tmpDir, { recursive: true });
171103
171351
  const specifiers = resolveVendorSpecifiers();
171104
171352
  const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
171105
171353
  const safeName = toSafeFileName(specifier);
171106
- const entryPath = join9(tmpDir, `${safeName}.ts`);
171354
+ const entryPath = join10(tmpDir, `${safeName}.ts`);
171107
171355
  const source = await generateEntrySource(specifier);
171108
171356
  await Bun.write(entryPath, source);
171109
171357
  return entryPath;
@@ -171139,18 +171387,18 @@ __export(exports_buildAngularVendor, {
171139
171387
  computeAngularVendorPaths: () => computeAngularVendorPaths,
171140
171388
  buildAngularVendor: () => buildAngularVendor
171141
171389
  });
171142
- import { mkdirSync as mkdirSync5 } from "fs";
171143
- import { join as join10 } from "path";
171390
+ import { mkdirSync as mkdirSync6 } from "fs";
171391
+ import { join as join11 } from "path";
171144
171392
  import { rm as rm5 } from "fs/promises";
171145
171393
  var {build: bunBuild3 } = globalThis.Bun;
171146
171394
  var angularSpecifiers, toSafeFileName2 = (specifier) => specifier.replace(/^@/, "").replace(/\//g, "_"), buildAngularVendor = async (buildDir) => {
171147
- const vendorDir = join10(buildDir, "angular", "vendor");
171148
- mkdirSync5(vendorDir, { recursive: true });
171149
- const tmpDir = join10(buildDir, "_angular_vendor_tmp");
171150
- mkdirSync5(tmpDir, { recursive: true });
171395
+ const vendorDir = join11(buildDir, "angular", "vendor");
171396
+ mkdirSync6(vendorDir, { recursive: true });
171397
+ const tmpDir = join11(buildDir, "_angular_vendor_tmp");
171398
+ mkdirSync6(tmpDir, { recursive: true });
171151
171399
  const entrypoints = await Promise.all(angularSpecifiers.map(async (specifier) => {
171152
171400
  const safeName = toSafeFileName2(specifier);
171153
- const entryPath = join10(tmpDir, `${safeName}.ts`);
171401
+ const entryPath = join11(tmpDir, `${safeName}.ts`);
171154
171402
  await Bun.write(entryPath, `export * from '${specifier}';
171155
171403
  `);
171156
171404
  return entryPath;
@@ -171192,18 +171440,18 @@ __export(exports_buildVueVendor, {
171192
171440
  computeVueVendorPaths: () => computeVueVendorPaths,
171193
171441
  buildVueVendor: () => buildVueVendor
171194
171442
  });
171195
- import { mkdirSync as mkdirSync6 } from "fs";
171196
- import { join as join11 } from "path";
171443
+ import { mkdirSync as mkdirSync7 } from "fs";
171444
+ import { join as join12 } from "path";
171197
171445
  import { rm as rm6 } from "fs/promises";
171198
171446
  var {build: bunBuild4 } = globalThis.Bun;
171199
171447
  var vueSpecifiers, toSafeFileName3 = (specifier) => specifier.replace(/\//g, "_"), buildVueVendor = async (buildDir) => {
171200
- const vendorDir = join11(buildDir, "vue", "vendor");
171201
- mkdirSync6(vendorDir, { recursive: true });
171202
- const tmpDir = join11(buildDir, "_vue_vendor_tmp");
171203
- mkdirSync6(tmpDir, { recursive: true });
171448
+ const vendorDir = join12(buildDir, "vue", "vendor");
171449
+ mkdirSync7(vendorDir, { recursive: true });
171450
+ const tmpDir = join12(buildDir, "_vue_vendor_tmp");
171451
+ mkdirSync7(tmpDir, { recursive: true });
171204
171452
  const entrypoints = await Promise.all(vueSpecifiers.map(async (specifier) => {
171205
171453
  const safeName = toSafeFileName3(specifier);
171206
- const entryPath = join11(tmpDir, `${safeName}.ts`);
171454
+ const entryPath = join12(tmpDir, `${safeName}.ts`);
171207
171455
  await Bun.write(entryPath, `export * from '${specifier}';
171208
171456
  `);
171209
171457
  return entryPath;
@@ -171228,17 +171476,17 @@ var vueSpecifiers, toSafeFileName3 = (specifier) => specifier.replace(/\//g, "_"
171228
171476
  console.warn("\u26A0\uFE0F Vue vendor build had errors:", result.logs);
171229
171477
  return;
171230
171478
  }
171231
- const { readFileSync: readFileSync5, writeFileSync: writeFileSync3, readdirSync } = await import("fs");
171479
+ const { readFileSync: readFileSync6, writeFileSync: writeFileSync4, readdirSync } = await import("fs");
171232
171480
  const files = readdirSync(vendorDir).filter((f) => f.endsWith(".js"));
171233
171481
  for (const file4 of files) {
171234
- const filePath = join11(vendorDir, file4);
171235
- const content = readFileSync5(filePath, "utf-8");
171482
+ const filePath = join12(vendorDir, file4);
171483
+ const content = readFileSync6(filePath, "utf-8");
171236
171484
  if (!content.includes("__VUE_HMR_RUNTIME__"))
171237
171485
  continue;
171238
171486
  const patched = content.replace(/getGlobalThis\(\)\.__VUE_HMR_RUNTIME__\s*=\s*\{/, "getGlobalThis().__VUE_HMR_RUNTIME__ = getGlobalThis().__VUE_HMR_RUNTIME__ || {");
171239
171487
  if (patched === content)
171240
171488
  continue;
171241
- writeFileSync3(filePath, patched);
171489
+ writeFileSync4(filePath, patched);
171242
171490
  }
171243
171491
  }, computeVueVendorPaths = () => {
171244
171492
  const paths = {};
@@ -171257,8 +171505,8 @@ __export(exports_buildSvelteVendor, {
171257
171505
  computeSvelteVendorPaths: () => computeSvelteVendorPaths,
171258
171506
  buildSvelteVendor: () => buildSvelteVendor
171259
171507
  });
171260
- import { mkdirSync as mkdirSync7 } from "fs";
171261
- import { join as join12 } from "path";
171508
+ import { mkdirSync as mkdirSync8 } from "fs";
171509
+ import { join as join13 } from "path";
171262
171510
  import { rm as rm7 } from "fs/promises";
171263
171511
  var {build: bunBuild5 } = globalThis.Bun;
171264
171512
  var svelteSpecifiers, isResolvable2 = (specifier) => {
@@ -171272,13 +171520,13 @@ var svelteSpecifiers, isResolvable2 = (specifier) => {
171272
171520
  const specifiers = resolveVendorSpecifiers2();
171273
171521
  if (specifiers.length === 0)
171274
171522
  return;
171275
- const vendorDir = join12(buildDir, "svelte", "vendor");
171276
- mkdirSync7(vendorDir, { recursive: true });
171277
- const tmpDir = join12(buildDir, "_svelte_vendor_tmp");
171278
- mkdirSync7(tmpDir, { recursive: true });
171523
+ const vendorDir = join13(buildDir, "svelte", "vendor");
171524
+ mkdirSync8(vendorDir, { recursive: true });
171525
+ const tmpDir = join13(buildDir, "_svelte_vendor_tmp");
171526
+ mkdirSync8(tmpDir, { recursive: true });
171279
171527
  const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
171280
171528
  const safeName = toSafeFileName4(specifier);
171281
- const entryPath = join12(tmpDir, `${safeName}.ts`);
171529
+ const entryPath = join13(tmpDir, `${safeName}.ts`);
171282
171530
  await Bun.write(entryPath, `export * from '${specifier}';
171283
171531
  `);
171284
171532
  return entryPath;
@@ -171353,14 +171601,14 @@ var init_rewriteImports = __esm(() => {
171353
171601
  import {
171354
171602
  copyFileSync,
171355
171603
  cpSync,
171356
- existsSync as existsSync11,
171357
- mkdirSync as mkdirSync8,
171358
- readFileSync as readFileSync5,
171604
+ existsSync as existsSync12,
171605
+ mkdirSync as mkdirSync9,
171606
+ readFileSync as readFileSync6,
171359
171607
  rmSync,
171360
171608
  statSync,
171361
- writeFileSync as writeFileSync3
171609
+ writeFileSync as writeFileSync4
171362
171610
  } from "fs";
171363
- import { basename as basename5, join as join13, relative as relative7, resolve as resolve11 } from "path";
171611
+ import { basename as basename5, join as join14, relative as relative7, resolve as resolve11 } from "path";
171364
171612
  import { cwd, env as env2, exit } from "process";
171365
171613
  var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
171366
171614
  var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
@@ -171382,11 +171630,11 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171382
171630
  throw err;
171383
171631
  exit(1);
171384
171632
  }, copyHtmxVendor = (htmxDir, htmxDestDir) => {
171385
- mkdirSync8(htmxDestDir, { recursive: true });
171633
+ mkdirSync9(htmxDestDir, { recursive: true });
171386
171634
  const glob = new Glob5("htmx*.min.js");
171387
171635
  for (const relPath of glob.scanSync({ cwd: htmxDir })) {
171388
- const src = join13(htmxDir, relPath);
171389
- const dest = join13(htmxDestDir, "htmx.min.js");
171636
+ const src = join14(htmxDir, relPath);
171637
+ const dest = join14(htmxDestDir, "htmx.min.js");
171390
171638
  copyFileSync(src, dest);
171391
171639
  return;
171392
171640
  }
@@ -171426,7 +171674,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171426
171674
  addWorkerPathIfExists(file4, relPath, workerPaths);
171427
171675
  }
171428
171676
  }, collectWorkerPathsFromFile = (file4, patterns, workerPaths) => {
171429
- const content = readFileSync5(file4, "utf-8");
171677
+ const content = readFileSync6(file4, "utf-8");
171430
171678
  for (const pattern of patterns) {
171431
171679
  collectWorkerPathsFromContent(content, pattern, file4, workerPaths);
171432
171680
  }
@@ -171459,8 +171707,8 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171459
171707
  vuePagesPath
171460
171708
  }) => {
171461
171709
  const { readdirSync: readDir } = await import("fs");
171462
- const devIndexDir = join13(buildPath, "_src_indexes");
171463
- mkdirSync8(devIndexDir, { recursive: true });
171710
+ const devIndexDir = join14(buildPath, "_src_indexes");
171711
+ mkdirSync9(devIndexDir, { recursive: true });
171464
171712
  if (reactIndexesPath && reactPagesPath) {
171465
171713
  copyReactDevIndexes(reactIndexesPath, reactPagesPath, devIndexDir, readDir);
171466
171714
  }
@@ -171474,35 +171722,35 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171474
171722
  const indexFiles = readDir(reactIndexesPath).filter((file4) => file4.endsWith(".tsx"));
171475
171723
  const pagesRel = relative7(process.cwd(), resolve11(reactPagesPath)).replace(/\\/g, "/");
171476
171724
  for (const file4 of indexFiles) {
171477
- let content = readFileSync5(join13(reactIndexesPath, file4), "utf-8");
171725
+ let content = readFileSync6(join14(reactIndexesPath, file4), "utf-8");
171478
171726
  content = content.replace(/from\s*['"]([^'"]*\/pages\/([^'"]+))['"]/g, (_match, _fullPath, componentName) => `from '/@src/${pagesRel}/${componentName}'`);
171479
- writeFileSync3(join13(devIndexDir, file4), content);
171727
+ writeFileSync4(join14(devIndexDir, file4), content);
171480
171728
  }
171481
171729
  }, copySvelteDevIndexes = (svelteDir, sveltePagesPath, svelteEntries, devIndexDir) => {
171482
- const svelteIndexDir = join13(svelteDir, "generated", "indexes");
171730
+ const svelteIndexDir = join14(svelteDir, "generated", "indexes");
171483
171731
  const sveltePageEntries = svelteEntries.filter((file4) => resolve11(file4).startsWith(resolve11(sveltePagesPath)));
171484
171732
  for (const entry of sveltePageEntries) {
171485
171733
  const name = basename5(entry).replace(/\.svelte(\.(ts|js))?$/, "");
171486
- const indexFile = join13(svelteIndexDir, "pages", `${name}.js`);
171487
- if (!existsSync11(indexFile))
171734
+ const indexFile = join14(svelteIndexDir, "pages", `${name}.js`);
171735
+ if (!existsSync12(indexFile))
171488
171736
  continue;
171489
- let content = readFileSync5(indexFile, "utf-8");
171737
+ let content = readFileSync6(indexFile, "utf-8");
171490
171738
  const srcRel = relative7(process.cwd(), resolve11(entry)).replace(/\\/g, "/");
171491
171739
  content = content.replace(/import\s+Component\s+from\s+['"]([^'"]+)['"]/, `import Component from "/@src/${srcRel}"`);
171492
- writeFileSync3(join13(devIndexDir, `${name}.svelte.js`), content);
171740
+ writeFileSync4(join14(devIndexDir, `${name}.svelte.js`), content);
171493
171741
  }
171494
171742
  }, copyVueDevIndexes = (vueDir, vuePagesPath, vueEntries, devIndexDir) => {
171495
- const vueIndexDir = join13(vueDir, "generated", "indexes");
171743
+ const vueIndexDir = join14(vueDir, "generated", "indexes");
171496
171744
  const vuePageEntries = vueEntries.filter((file4) => resolve11(file4).startsWith(resolve11(vuePagesPath)));
171497
171745
  for (const entry of vuePageEntries) {
171498
171746
  const name = basename5(entry, ".vue");
171499
- const indexFile = join13(vueIndexDir, `${name}.js`);
171500
- if (!existsSync11(indexFile))
171747
+ const indexFile = join14(vueIndexDir, `${name}.js`);
171748
+ if (!existsSync12(indexFile))
171501
171749
  continue;
171502
- let content = readFileSync5(indexFile, "utf-8");
171750
+ let content = readFileSync6(indexFile, "utf-8");
171503
171751
  const srcRel = relative7(process.cwd(), resolve11(entry)).replace(/\\/g, "/");
171504
171752
  content = content.replace(/import\s+Comp\s+from\s+['"]([^'"]+)['"]/, `import Comp from "/@src/${srcRel}"`);
171505
- writeFileSync3(join13(devIndexDir, `${name}.vue.js`), content);
171753
+ writeFileSync4(join14(devIndexDir, `${name}.vue.js`), content);
171506
171754
  }
171507
171755
  }, resolveVueRuntimeId = (content, firstUseName, outputPath, projectRoot) => {
171508
171756
  const varIdx = content.indexOf(`var ${firstUseName} =`);
@@ -171550,7 +171798,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171550
171798
  }
171551
171799
  return result;
171552
171800
  }, VUE_HMR_RUNTIME, injectVueComposableTracking = (outputPath, projectRoot) => {
171553
- let content = readFileSync5(outputPath, "utf-8");
171801
+ let content = readFileSync6(outputPath, "utf-8");
171554
171802
  const usePattern = /^var\s+(use[A-Z]\w*)\s*=/gm;
171555
171803
  const useNames = [];
171556
171804
  let match;
@@ -171571,7 +171819,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171571
171819
  content = `${content.slice(0, firstUseIdx) + runtime}
171572
171820
  ${content.slice(firstUseIdx)}`;
171573
171821
  content = wrapUseFunctions(content, useNames);
171574
- writeFileSync3(outputPath, content);
171822
+ writeFileSync4(outputPath, content);
171575
171823
  }, buildDevUrlFileMap = (urlReferencedFiles, projectRoot) => {
171576
171824
  const urlFileMap = new Map;
171577
171825
  for (const srcPath of urlReferencedFiles) {
@@ -171600,7 +171848,7 @@ ${content.slice(firstUseIdx)}`;
171600
171848
  }, rewriteUrlReferences = (outputPaths, urlFileMap) => {
171601
171849
  const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
171602
171850
  for (const outputPath of outputPaths) {
171603
- let content = readFileSync5(outputPath, "utf-8");
171851
+ let content = readFileSync6(outputPath, "utf-8");
171604
171852
  let changed = false;
171605
171853
  content = content.replace(urlPattern, (_match, relPath) => {
171606
171854
  const targetName = basename5(relPath);
@@ -171611,7 +171859,7 @@ ${content.slice(firstUseIdx)}`;
171611
171859
  return `new URL('${resolvedPath}', import.meta.url)`;
171612
171860
  });
171613
171861
  if (changed)
171614
- writeFileSync3(outputPath, content);
171862
+ writeFileSync4(outputPath, content);
171615
171863
  }
171616
171864
  }, vueFeatureFlags, build2 = async ({
171617
171865
  buildDirectory = "build",
@@ -171647,14 +171895,14 @@ ${content.slice(firstUseIdx)}`;
171647
171895
  const stylesPath = typeof stylesConfig === "string" ? stylesConfig : stylesConfig?.path;
171648
171896
  const stylesIgnore = typeof stylesConfig === "object" ? stylesConfig.ignore : undefined;
171649
171897
  const stylesDir = stylesPath && validateSafePath(stylesPath, projectRoot);
171650
- const reactIndexesPath = reactDir && join13(reactDir, "generated", "indexes");
171651
- const reactPagesPath = reactDir && join13(reactDir, "pages");
171652
- const htmlPagesPath = htmlDir && join13(htmlDir, "pages");
171653
- const htmlScriptsPath = htmlDir && join13(htmlDir, "scripts");
171654
- const sveltePagesPath = svelteDir && join13(svelteDir, "pages");
171655
- const vuePagesPath = vueDir && join13(vueDir, "pages");
171656
- const htmxPagesPath = htmxDir && join13(htmxDir, "pages");
171657
- const angularPagesPath = angularDir && join13(angularDir, "pages");
171898
+ const reactIndexesPath = reactDir && join14(reactDir, "generated", "indexes");
171899
+ const reactPagesPath = reactDir && join14(reactDir, "pages");
171900
+ const htmlPagesPath = htmlDir && join14(htmlDir, "pages");
171901
+ const htmlScriptsPath = htmlDir && join14(htmlDir, "scripts");
171902
+ const sveltePagesPath = svelteDir && join14(svelteDir, "pages");
171903
+ const vuePagesPath = vueDir && join14(vueDir, "pages");
171904
+ const htmxPagesPath = htmxDir && join14(htmxDir, "pages");
171905
+ const angularPagesPath = angularDir && join14(angularDir, "pages");
171658
171906
  const frontends = [
171659
171907
  reactDir,
171660
171908
  htmlDir,
@@ -171690,12 +171938,12 @@ ${content.slice(firstUseIdx)}`;
171690
171938
  if (svelteDir)
171691
171939
  serverDirMap.push({
171692
171940
  dir: svelteDir,
171693
- subdir: join13("generated", "server")
171941
+ subdir: join14("generated", "server")
171694
171942
  });
171695
171943
  if (vueDir)
171696
171944
  serverDirMap.push({
171697
171945
  dir: vueDir,
171698
- subdir: join13("generated", "server")
171946
+ subdir: join14("generated", "server")
171699
171947
  });
171700
171948
  if (angularDir)
171701
171949
  serverDirMap.push({ dir: angularDir, subdir: "generated" });
@@ -171705,14 +171953,14 @@ ${content.slice(firstUseIdx)}`;
171705
171953
  const [firstEntry] = serverDirMap;
171706
171954
  if (!firstEntry)
171707
171955
  throw new Error("Expected at least one server directory entry");
171708
- serverRoot = join13(firstEntry.dir, firstEntry.subdir);
171709
- serverOutDir = join13(buildPath, basename5(firstEntry.dir));
171956
+ serverRoot = join14(firstEntry.dir, firstEntry.subdir);
171957
+ serverOutDir = join14(buildPath, basename5(firstEntry.dir));
171710
171958
  } else if (serverDirMap.length > 1) {
171711
171959
  serverRoot = commonAncestor(serverDirMap.map((entry) => entry.dir), projectRoot);
171712
171960
  serverOutDir = buildPath;
171713
171961
  }
171714
171962
  const publicPath = publicDirectory && validateSafePath(publicDirectory, projectRoot);
171715
- mkdirSync8(buildPath, { recursive: true });
171963
+ mkdirSync9(buildPath, { recursive: true });
171716
171964
  if (publicPath)
171717
171965
  cpSync(publicPath, buildPath, { force: true, recursive: true });
171718
171966
  const filterToIncrementalEntries = (entryPoints, mapToSource) => {
@@ -171734,7 +171982,7 @@ ${content.slice(firstUseIdx)}`;
171734
171982
  await generateReactIndexFiles(reactPagesPath, reactIndexesPath, hmr);
171735
171983
  }
171736
171984
  if (assetsPath && (!isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/assets/")))) {
171737
- cpSync(assetsPath, join13(buildPath, "assets"), {
171985
+ cpSync(assetsPath, join14(buildPath, "assets"), {
171738
171986
  force: true,
171739
171987
  recursive: true
171740
171988
  });
@@ -171748,7 +171996,7 @@ ${content.slice(firstUseIdx)}`;
171748
171996
  } catch {
171749
171997
  binPath = "tailwindcss";
171750
171998
  }
171751
- const proc = Bun.spawn(["bun", binPath, "-i", input, "-o", join13(buildPath, output)], { stderr: "pipe", stdout: "pipe" });
171999
+ const proc = Bun.spawn(["bun", binPath, "-i", input, "-o", join14(buildPath, output)], { stderr: "pipe", stdout: "pipe" });
171752
172000
  await proc.exited;
171753
172001
  };
171754
172002
  const tailwindPromise = tailwind && (!isIncremental || normalizedIncrementalFiles?.some((file4) => file4.endsWith(".css"))) ? compileTailwind(tailwind.input, tailwind.output) : undefined;
@@ -171773,7 +172021,7 @@ ${content.slice(firstUseIdx)}`;
171773
172021
  const reactEntries = isIncremental && reactIndexesPath && reactPagesPath ? filterToIncrementalEntries(allReactEntries, (entry) => {
171774
172022
  if (entry.startsWith(resolve11(reactIndexesPath))) {
171775
172023
  const pageName = basename5(entry, ".tsx");
171776
- return join13(reactPagesPath, `${pageName}.tsx`);
172024
+ return join14(reactPagesPath, `${pageName}.tsx`);
171777
172025
  }
171778
172026
  return null;
171779
172027
  }) : allReactEntries;
@@ -171864,7 +172112,7 @@ ${content.slice(firstUseIdx)}`;
171864
172112
  return {};
171865
172113
  }
171866
172114
  if (hmr && reactIndexesPath && reactClientEntryPoints.length > 0) {
171867
- const refreshEntry = join13(reactIndexesPath, "_refresh.tsx");
172115
+ const refreshEntry = join14(reactIndexesPath, "_refresh.tsx");
171868
172116
  if (!reactClientEntryPoints.includes(refreshEntry))
171869
172117
  reactClientEntryPoints.push(refreshEntry);
171870
172118
  }
@@ -171907,13 +172155,13 @@ ${content.slice(firstUseIdx)}`;
171907
172155
  throw: false
171908
172156
  } : undefined;
171909
172157
  if (reactDir && reactClientEntryPoints.length > 0) {
171910
- rmSync(join13(buildPath, "react", "indexes"), {
172158
+ rmSync(join14(buildPath, "react", "indexes"), {
171911
172159
  force: true,
171912
172160
  recursive: true
171913
172161
  });
171914
172162
  }
171915
172163
  if (angularDir && angularClientPaths.length > 0) {
171916
- rmSync(join13(buildPath, "angular", "indexes"), {
172164
+ rmSync(join14(buildPath, "angular", "indexes"), {
171917
172165
  force: true,
171918
172166
  recursive: true
171919
172167
  });
@@ -171975,7 +172223,7 @@ ${content.slice(firstUseIdx)}`;
171975
172223
  globalCssEntries.length > 0 ? bunBuild6({
171976
172224
  entrypoints: globalCssEntries,
171977
172225
  naming: `[dir]/[name].[hash].[ext]`,
171978
- outdir: stylesDir ? join13(buildPath, basename5(stylesDir)) : buildPath,
172226
+ outdir: stylesDir ? join14(buildPath, basename5(stylesDir)) : buildPath,
171979
172227
  root: stylesDir || clientRoot,
171980
172228
  target: "browser",
171981
172229
  throw: false
@@ -171983,7 +172231,7 @@ ${content.slice(firstUseIdx)}`;
171983
172231
  vueCssPaths.length > 0 ? bunBuild6({
171984
172232
  entrypoints: vueCssPaths,
171985
172233
  naming: `[name].[hash].[ext]`,
171986
- outdir: join13(buildPath, assetsPath ? basename5(assetsPath) : "assets", "css"),
172234
+ outdir: join14(buildPath, assetsPath ? basename5(assetsPath) : "assets", "css"),
171987
172235
  target: "browser",
171988
172236
  throw: false
171989
172237
  }) : undefined
@@ -172078,20 +172326,20 @@ ${content.slice(firstUseIdx)}`;
172078
172326
  const injectHMRIntoHTMLFile = (filePath, framework) => {
172079
172327
  if (!hmrClientBundle)
172080
172328
  return;
172081
- let html = readFileSync5(filePath, "utf-8");
172329
+ let html = readFileSync6(filePath, "utf-8");
172082
172330
  if (html.includes("data-hmr-client"))
172083
172331
  return;
172084
172332
  const tag = `<script>window.__HMR_FRAMEWORK__="${framework}";</script><script data-hmr-client>${hmrClientBundle}</script>`;
172085
172333
  const bodyClose = /<\/body\s*>/i.exec(html);
172086
172334
  html = bodyClose ? html.slice(0, bodyClose.index) + tag + html.slice(bodyClose.index) : html + tag;
172087
- writeFileSync3(filePath, html);
172335
+ writeFileSync4(filePath, html);
172088
172336
  };
172089
172337
  const processHtmlPages = async () => {
172090
172338
  if (!(htmlDir && htmlPagesPath))
172091
172339
  return;
172092
- const outputHtmlPages = isSingle ? join13(buildPath, "pages") : join13(buildPath, basename5(htmlDir), "pages");
172340
+ const outputHtmlPages = isSingle ? join14(buildPath, "pages") : join14(buildPath, basename5(htmlDir), "pages");
172093
172341
  if (shouldCopyHtml) {
172094
- mkdirSync8(outputHtmlPages, { recursive: true });
172342
+ mkdirSync9(outputHtmlPages, { recursive: true });
172095
172343
  cpSync(htmlPagesPath, outputHtmlPages, {
172096
172344
  force: true,
172097
172345
  recursive: true
@@ -172099,6 +172347,7 @@ ${content.slice(firstUseIdx)}`;
172099
172347
  }
172100
172348
  if (shouldUpdateHtmlAssetPaths) {
172101
172349
  await updateAssetPaths(manifest, outputHtmlPages);
172350
+ await optimizeHtmlImages(outputHtmlPages);
172102
172351
  }
172103
172352
  const htmlPageFiles = await scanEntryPoints(outputHtmlPages, "*.html");
172104
172353
  for (const htmlFile of htmlPageFiles) {
@@ -172111,20 +172360,21 @@ ${content.slice(firstUseIdx)}`;
172111
172360
  const processHtmxPages = async () => {
172112
172361
  if (!(htmxDir && htmxPagesPath))
172113
172362
  return;
172114
- const outputHtmxPages = isSingle ? join13(buildPath, "pages") : join13(buildPath, basename5(htmxDir), "pages");
172363
+ const outputHtmxPages = isSingle ? join14(buildPath, "pages") : join14(buildPath, basename5(htmxDir), "pages");
172115
172364
  if (shouldCopyHtmx) {
172116
- mkdirSync8(outputHtmxPages, { recursive: true });
172365
+ mkdirSync9(outputHtmxPages, { recursive: true });
172117
172366
  cpSync(htmxPagesPath, outputHtmxPages, {
172118
172367
  force: true,
172119
172368
  recursive: true
172120
172369
  });
172121
172370
  }
172122
172371
  if (shouldCopyHtmx) {
172123
- const htmxDestDir = isSingle ? buildPath : join13(buildPath, basename5(htmxDir));
172372
+ const htmxDestDir = isSingle ? buildPath : join14(buildPath, basename5(htmxDir));
172124
172373
  copyHtmxVendor(htmxDir, htmxDestDir);
172125
172374
  }
172126
172375
  if (shouldUpdateHtmxAssetPaths) {
172127
172376
  await updateAssetPaths(manifest, outputHtmxPages);
172377
+ await optimizeHtmlImages(outputHtmxPages);
172128
172378
  }
172129
172379
  const htmxPageFiles = await scanEntryPoints(outputHtmxPages, "*.html");
172130
172380
  for (const htmxFile of htmxPageFiles) {
@@ -172171,7 +172421,7 @@ ${content.slice(firstUseIdx)}`;
172171
172421
  mode: mode ?? (isDev ? "development" : "production")
172172
172422
  });
172173
172423
  if (!isIncremental) {
172174
- writeFileSync3(join13(buildPath, "manifest.json"), JSON.stringify(manifest, null, "\t"));
172424
+ writeFileSync4(join14(buildPath, "manifest.json"), JSON.stringify(manifest, null, "\t"));
172175
172425
  }
172176
172426
  return manifest;
172177
172427
  };
@@ -172183,6 +172433,7 @@ var init_build = __esm(() => {
172183
172433
  init_outputLogs();
172184
172434
  init_scanEntryPoints();
172185
172435
  init_scanCssEntryPoints();
172436
+ init_optimizeHtmlImages();
172186
172437
  init_updateAssetPaths();
172187
172438
  init_buildHMRClient();
172188
172439
  init_rewriteReactImports();
@@ -172230,7 +172481,7 @@ var init_build = __esm(() => {
172230
172481
  });
172231
172482
 
172232
172483
  // src/dev/dependencyGraph.ts
172233
- import { existsSync as existsSync12, readFileSync as readFileSync6 } from "fs";
172484
+ import { existsSync as existsSync13, readFileSync as readFileSync7 } from "fs";
172234
172485
  var {Glob: Glob6 } = globalThis.Bun;
172235
172486
  import { resolve as resolve12 } from "path";
172236
172487
  var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath) => {
@@ -172260,10 +172511,10 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
172260
172511
  ];
172261
172512
  for (const ext of extensions) {
172262
172513
  const withExt = normalized + ext;
172263
- if (existsSync12(withExt))
172514
+ if (existsSync13(withExt))
172264
172515
  return withExt;
172265
172516
  }
172266
- if (existsSync12(normalized))
172517
+ if (existsSync13(normalized))
172267
172518
  return normalized;
172268
172519
  return null;
172269
172520
  }, clearExistingDependents = (graph, normalizedPath) => {
@@ -172278,7 +172529,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
172278
172529
  }
172279
172530
  }, addFileToGraph = (graph, filePath) => {
172280
172531
  const normalizedPath = resolve12(filePath);
172281
- if (!existsSync12(normalizedPath))
172532
+ if (!existsSync13(normalizedPath))
172282
172533
  return;
172283
172534
  const dependencies = extractDependencies(normalizedPath);
172284
172535
  clearExistingDependents(graph, normalizedPath);
@@ -172294,7 +172545,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
172294
172545
  }, IGNORED_SEGMENTS, buildInitialDependencyGraph = (graph, directories) => {
172295
172546
  const processedFiles = new Set;
172296
172547
  const glob = new Glob6("**/*.{ts,tsx,js,jsx,vue,svelte,html,htm}");
172297
- const resolvedDirs = directories.map((dir) => resolve12(dir)).filter((dir) => existsSync12(dir));
172548
+ const resolvedDirs = directories.map((dir) => resolve12(dir)).filter((dir) => existsSync13(dir));
172298
172549
  const allFiles = resolvedDirs.flatMap((dir) => Array.from(glob.scanSync({ absolute: true, cwd: dir })));
172299
172550
  for (const file4 of allFiles) {
172300
172551
  const fullPath = resolve12(file4);
@@ -172391,15 +172642,15 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
172391
172642
  const lowerPath = filePath.toLowerCase();
172392
172643
  const isSvelteOrVue = lowerPath.endsWith(".svelte") || lowerPath.endsWith(".vue");
172393
172644
  if (loader === "html") {
172394
- const content = readFileSync6(filePath, "utf-8");
172645
+ const content = readFileSync7(filePath, "utf-8");
172395
172646
  return extractHtmlDependencies(filePath, content);
172396
172647
  }
172397
172648
  if (loader === "tsx" || loader === "js") {
172398
- const content = readFileSync6(filePath, "utf-8");
172649
+ const content = readFileSync7(filePath, "utf-8");
172399
172650
  return extractJsDependencies(filePath, content, loader);
172400
172651
  }
172401
172652
  if (isSvelteOrVue) {
172402
- const content = readFileSync6(filePath, "utf-8");
172653
+ const content = readFileSync7(filePath, "utf-8");
172403
172654
  return extractSvelteVueDependencies(filePath, content);
172404
172655
  }
172405
172656
  return [];
@@ -172685,8 +172936,8 @@ var init_pathUtils = __esm(() => {
172685
172936
 
172686
172937
  // src/dev/fileWatcher.ts
172687
172938
  import { watch } from "fs";
172688
- import { existsSync as existsSync13 } from "fs";
172689
- import { join as join14, resolve as resolve14 } from "path";
172939
+ import { existsSync as existsSync14 } from "fs";
172940
+ import { join as join15, resolve as resolve14 } from "path";
172690
172941
  var safeRemoveFromGraph = (graph, fullPath) => {
172691
172942
  try {
172692
172943
  removeFileFromGraph(graph, fullPath);
@@ -172713,16 +172964,16 @@ var safeRemoveFromGraph = (graph, fullPath) => {
172713
172964
  if (shouldSkipFilename(filename, isStylesDir)) {
172714
172965
  return;
172715
172966
  }
172716
- const fullPath = join14(absolutePath, filename).replace(/\\/g, "/");
172967
+ const fullPath = join15(absolutePath, filename).replace(/\\/g, "/");
172717
172968
  if (shouldIgnorePath(fullPath, state.resolvedPaths)) {
172718
172969
  return;
172719
172970
  }
172720
- if (event === "rename" && !existsSync13(fullPath)) {
172971
+ if (event === "rename" && !existsSync14(fullPath)) {
172721
172972
  safeRemoveFromGraph(state.dependencyGraph, fullPath);
172722
172973
  onFileChange(fullPath);
172723
172974
  return;
172724
172975
  }
172725
- if (existsSync13(fullPath)) {
172976
+ if (existsSync14(fullPath)) {
172726
172977
  onFileChange(fullPath);
172727
172978
  safeAddToGraph(state.dependencyGraph, fullPath);
172728
172979
  }
@@ -172732,7 +172983,7 @@ var safeRemoveFromGraph = (graph, fullPath) => {
172732
172983
  const stylesDir = state.resolvedPaths?.stylesDir;
172733
172984
  paths.forEach((path) => {
172734
172985
  const absolutePath = resolve14(path).replace(/\\/g, "/");
172735
- if (!existsSync13(absolutePath)) {
172986
+ if (!existsSync14(absolutePath)) {
172736
172987
  return;
172737
172988
  }
172738
172989
  const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
@@ -172743,7 +172994,7 @@ var safeRemoveFromGraph = (graph, fullPath) => {
172743
172994
  const stylesDir = state.resolvedPaths?.stylesDir;
172744
172995
  watchPaths.forEach((path) => {
172745
172996
  const absolutePath = resolve14(path).replace(/\\/g, "/");
172746
- if (!existsSync13(absolutePath)) {
172997
+ if (!existsSync14(absolutePath)) {
172747
172998
  return;
172748
172999
  }
172749
173000
  const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
@@ -172864,10 +173115,10 @@ var init_assetStore = __esm(() => {
172864
173115
  });
172865
173116
 
172866
173117
  // src/dev/fileHashTracker.ts
172867
- import { readFileSync as readFileSync7 } from "fs";
173118
+ import { readFileSync as readFileSync8 } from "fs";
172868
173119
  var computeFileHash = (filePath) => {
172869
173120
  try {
172870
- const fileContent = readFileSync7(filePath);
173121
+ const fileContent = readFileSync8(filePath);
172871
173122
  return Number(Bun.hash(fileContent));
172872
173123
  } catch {
172873
173124
  return UNFOUND_INDEX;
@@ -173175,8 +173426,8 @@ var init_registerClientScript = __esm(() => {
173175
173426
  });
173176
173427
 
173177
173428
  // src/angular/injectorPatch.ts
173178
- import { readFileSync as readFileSync8, writeFileSync as writeFileSync4 } from "fs";
173179
- import { dirname as dirname6, join as join15 } from "path";
173429
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "fs";
173430
+ import { dirname as dirname6, join as join16 } from "path";
173180
173431
  var applyInjectorPatch = (chunkPath, content) => {
173181
173432
  if (content.includes('Symbol.for("angular.currentInjector")')) {
173182
173433
  return;
@@ -173210,12 +173461,12 @@ var applyInjectorPatch = (chunkPath, content) => {
173210
173461
  if (patched === content) {
173211
173462
  return;
173212
173463
  }
173213
- writeFileSync4(chunkPath, patched, "utf-8");
173464
+ writeFileSync5(chunkPath, patched, "utf-8");
173214
173465
  }, patchAngularInjectorSingleton = () => {
173215
173466
  try {
173216
173467
  const coreDir = dirname6(__require.resolve("@angular/core/package.json"));
173217
- const chunkPath = join15(coreDir, "fesm2022", "_not_found-chunk.mjs");
173218
- const content = readFileSync8(chunkPath, "utf-8");
173468
+ const chunkPath = join16(coreDir, "fesm2022", "_not_found-chunk.mjs");
173469
+ const content = readFileSync9(chunkPath, "utf-8");
173219
173470
  applyInjectorPatch(chunkPath, content);
173220
173471
  } catch {}
173221
173472
  };
@@ -202959,7 +203210,7 @@ __export(exports_moduleServer, {
202959
203210
  createModuleServer: () => createModuleServer,
202960
203211
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
202961
203212
  });
202962
- import { existsSync as existsSync14, readFileSync as readFileSync9, statSync as statSync2 } from "fs";
203213
+ import { existsSync as existsSync15, readFileSync as readFileSync10, statSync as statSync2 } from "fs";
202963
203214
  import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve18, relative as relative8 } from "path";
202964
203215
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
202965
203216
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
@@ -202980,7 +203231,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPIL
202980
203231
  ${stubs}
202981
203232
  `;
202982
203233
  }, resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
202983
- const found = extensions.find((ext) => existsSync14(resolve18(projectRoot, srcPath + ext)));
203234
+ const found = extensions.find((ext) => existsSync15(resolve18(projectRoot, srcPath + ext)));
202984
203235
  return found ? srcPath + found : srcPath;
202985
203236
  }, IMPORT_EXTENSIONS, SIDE_EFFECT_EXTENSIONS, MODULE_EXTENSIONS, REACT_EXTENSIONS, escapeRegex3 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), buildImportRewriter = (vendorPaths) => {
202986
203237
  const entries = Object.entries(vendorPaths).sort(([a], [b]) => b.length - a.length);
@@ -203082,7 +203333,7 @@ ${stubs}
203082
203333
  `)}
203083
203334
  ${code}`;
203084
203335
  }, reactTranspilerOptions, reactTranspiler, transformReactFile = (filePath, projectRoot, rewriter) => {
203085
- const raw = readFileSync9(filePath, "utf-8");
203336
+ const raw = readFileSync10(filePath, "utf-8");
203086
203337
  const valueExports = tsxTranspiler.scan(raw).exports;
203087
203338
  let transpiled = reactTranspiler.transformSync(raw);
203088
203339
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
@@ -203097,7 +203348,7 @@ ${transpiled}`;
203097
203348
  transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
203098
203349
  return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
203099
203350
  }, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
203100
- const raw = readFileSync9(filePath, "utf-8");
203351
+ const raw = readFileSync10(filePath, "utf-8");
203101
203352
  const ext = extname3(filePath);
203102
203353
  const isTS = ext === ".ts" || ext === ".tsx";
203103
203354
  const isTSX = ext === ".tsx" || ext === ".jsx";
@@ -203250,7 +203501,7 @@ ${code}`;
203250
203501
  ` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
203251
203502
  return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
203252
203503
  }, transformSvelteFile = async (filePath, projectRoot, rewriter) => {
203253
- const raw = readFileSync9(filePath, "utf-8");
203504
+ const raw = readFileSync10(filePath, "utf-8");
203254
203505
  if (!svelteCompiler) {
203255
203506
  svelteCompiler = await import("svelte/compiler");
203256
203507
  }
@@ -203304,7 +203555,7 @@ export default __script__;`;
203304
203555
  return `${cssInjection}
203305
203556
  ${code}`;
203306
203557
  }, transformVueFile = async (filePath, projectRoot, rewriter, vueDir) => {
203307
- const raw = readFileSync9(filePath, "utf-8");
203558
+ const raw = readFileSync10(filePath, "utf-8");
203308
203559
  if (!vueCompiler) {
203309
203560
  vueCompiler = await import("@vue/compiler-sfc");
203310
203561
  }
@@ -203336,11 +203587,11 @@ ${code}`;
203336
203587
  `);
203337
203588
  return result;
203338
203589
  }, resolveSvelteModulePath = (path) => {
203339
- if (existsSync14(path))
203590
+ if (existsSync15(path))
203340
203591
  return path;
203341
- if (existsSync14(`${path}.ts`))
203592
+ if (existsSync15(`${path}.ts`))
203342
203593
  return `${path}.ts`;
203343
- if (existsSync14(`${path}.js`))
203594
+ if (existsSync15(`${path}.js`))
203344
203595
  return `${path}.js`;
203345
203596
  return path;
203346
203597
  }, jsResponse = (body) => {
@@ -203353,7 +203604,7 @@ ${code}`;
203353
203604
  }
203354
203605
  });
203355
203606
  }, handleCssRequest = (filePath) => {
203356
- const raw = readFileSync9(filePath, "utf-8");
203607
+ const raw = readFileSync10(filePath, "utf-8");
203357
203608
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
203358
203609
  return [
203359
203610
  `const style = document.createElement('style');`,
@@ -203485,7 +203736,7 @@ export default {};
203485
203736
  return { ext, filePath: resolveSvelteModulePath(filePath) };
203486
203737
  if (ext)
203487
203738
  return { ext, filePath };
203488
- const found = MODULE_EXTENSIONS.find((candidate) => existsSync14(filePath + candidate));
203739
+ const found = MODULE_EXTENSIONS.find((candidate) => existsSync15(filePath + candidate));
203489
203740
  if (!found)
203490
203741
  return { ext, filePath };
203491
203742
  const resolved = filePath + found;
@@ -203679,7 +203930,7 @@ var handleHTMXUpdate = async (htmxFilePath) => {
203679
203930
  var init_simpleHTMXHMR = () => {};
203680
203931
 
203681
203932
  // src/dev/rebuildTrigger.ts
203682
- import { existsSync as existsSync15 } from "fs";
203933
+ import { existsSync as existsSync16 } from "fs";
203683
203934
  import { rm as rm8 } from "fs/promises";
203684
203935
  import { basename as basename8, relative as relative9, resolve as resolve21 } from "path";
203685
203936
  var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
@@ -203749,7 +204000,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203749
204000
  detectedFw = detected !== "ignored" ? detected : affectedFrameworks[0];
203750
204001
  }
203751
204002
  return { ...parsed, framework: detectedFw };
203752
- }, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync15(affectedFile), collectDeletedFileAffected = (state, filePathInSet, processedFiles, validFiles) => {
204003
+ }, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync16(affectedFile), collectDeletedFileAffected = (state, filePathInSet, processedFiles, validFiles) => {
203753
204004
  state.fileHashes.delete(filePathInSet);
203754
204005
  try {
203755
204006
  const affectedFiles = getAffectedFiles(state.dependencyGraph, filePathInSet);
@@ -203767,7 +204018,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203767
204018
  if (!dependents || dependents.size === 0) {
203768
204019
  return;
203769
204020
  }
203770
- const dependentFiles = Array.from(dependents).filter((file4) => existsSync15(file4));
204021
+ const dependentFiles = Array.from(dependents).filter((file4) => existsSync16(file4));
203771
204022
  if (dependentFiles.length === 0) {
203772
204023
  return;
203773
204024
  }
@@ -203783,7 +204034,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203783
204034
  try {
203784
204035
  const affectedFiles = getAffectedFiles(state.dependencyGraph, normalizedFilePath);
203785
204036
  affectedFiles.forEach((affectedFile) => {
203786
- if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync15(affectedFile)) {
204037
+ if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync16(affectedFile)) {
203787
204038
  validFiles.push(affectedFile);
203788
204039
  processedFiles.add(affectedFile);
203789
204040
  }
@@ -203808,7 +204059,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203808
204059
  collectChangedFileAffected(state, normalizedFilePath, processedFiles, validFiles);
203809
204060
  }, processFilePathSet = (state, filePathSet, processedFiles, validFiles) => {
203810
204061
  filePathSet.forEach((filePathInSet) => {
203811
- if (!existsSync15(filePathInSet)) {
204062
+ if (!existsSync16(filePathInSet)) {
203812
204063
  collectDeletedFileAffected(state, filePathInSet, processedFiles, validFiles);
203813
204064
  return;
203814
204065
  }
@@ -203916,7 +204167,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203916
204167
  return componentFile;
203917
204168
  }
203918
204169
  const tsCounterpart = componentFile.replace(/\.html$/, ".ts");
203919
- if (existsSync15(tsCounterpart)) {
204170
+ if (existsSync16(tsCounterpart)) {
203920
204171
  return tsCounterpart;
203921
204172
  }
203922
204173
  if (!graph)
@@ -204053,7 +204304,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204053
204304
  }, resolveReactEntryForPageFile = (normalized, pagesPathResolved, reactIndexesPath) => {
204054
204305
  const pageName = basename8(normalized, ".tsx");
204055
204306
  const indexPath = resolve21(reactIndexesPath, `${pageName}.tsx`);
204056
- if (!existsSync15(indexPath)) {
204307
+ if (!existsSync16(indexPath)) {
204057
204308
  return;
204058
204309
  }
204059
204310
  return indexPath;
@@ -204065,7 +204316,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204065
204316
  }
204066
204317
  const pageName = basename8(dep, ".tsx");
204067
204318
  const indexPath = resolve21(reactIndexesPath, `${pageName}.tsx`);
204068
- if (existsSync15(indexPath) && !reactEntries.includes(indexPath)) {
204319
+ if (existsSync16(indexPath) && !reactEntries.includes(indexPath)) {
204069
204320
  reactEntries.push(indexPath);
204070
204321
  }
204071
204322
  });
@@ -204929,6 +205180,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204929
205180
  const source = await Bun.file(sourceFile).text();
204930
205181
  await Bun.write(destPath, source);
204931
205182
  await updateAssetPaths2(state.manifest, outputDir);
205183
+ const { optimizeHtmlImages: optimizeHtmlImages2 } = await Promise.resolve().then(() => (init_optimizeHtmlImages(), exports_optimizeHtmlImages));
205184
+ await optimizeHtmlImages2(outputDir);
204932
205185
  injectHmrScript(destPath, hmrScript, readFs, writeFs);
204933
205186
  const newHTML = await handleUpdate(destPath);
204934
205187
  if (!newHTML)
@@ -205147,8 +205400,8 @@ __export(exports_buildDepVendor, {
205147
205400
  computeDepVendorPaths: () => computeDepVendorPaths,
205148
205401
  buildDepVendor: () => buildDepVendor
205149
205402
  });
205150
- import { mkdirSync as mkdirSync9 } from "fs";
205151
- import { join as join16 } from "path";
205403
+ import { mkdirSync as mkdirSync10 } from "fs";
205404
+ import { join as join17 } from "path";
205152
205405
  import { rm as rm9 } from "fs/promises";
205153
205406
  var {build: bunBuild7, Glob: Glob7 } = globalThis.Bun;
205154
205407
  var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g, "").replace(/-/g, "_"), isResolvable3 = (specifier) => {
@@ -205188,7 +205441,7 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
205188
205441
  return Array.from(specifiers).filter(isResolvable3);
205189
205442
  }, generateEntrySource2 = (specifier) => `export * from '${specifier}';
205190
205443
  `, rewriteVendorFiles = async (vendorDir) => {
205191
- const { readdirSync: readdirSync2, readFileSync: readFileSync10, writeFileSync: writeFileSync5 } = await import("fs");
205444
+ const { readdirSync: readdirSync2, readFileSync: readFileSync11, writeFileSync: writeFileSync6 } = await import("fs");
205192
205445
  const { computeVendorPaths: computeVendorPaths2 } = await Promise.resolve().then(() => (init_buildReactVendor(), exports_buildReactVendor));
205193
205446
  const reactPaths = Object.entries(computeVendorPaths2());
205194
205447
  const rewriteContent = (content) => reactPaths.reduce((acc, [specifier, webPath]) => {
@@ -205198,23 +205451,23 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
205198
205451
  }, content);
205199
205452
  const files = readdirSync2(vendorDir).filter((f) => f.endsWith(".js"));
205200
205453
  for (const file4 of files) {
205201
- const filePath = join16(vendorDir, file4);
205202
- const original = readFileSync10(filePath, "utf-8");
205454
+ const filePath = join17(vendorDir, file4);
205455
+ const original = readFileSync11(filePath, "utf-8");
205203
205456
  const rewritten = rewriteContent(original);
205204
205457
  if (rewritten !== original)
205205
- writeFileSync5(filePath, rewritten);
205458
+ writeFileSync6(filePath, rewritten);
205206
205459
  }
205207
205460
  }, buildDepVendor = async (buildDir, directories) => {
205208
205461
  const specifiers = await scanBareImports(directories);
205209
205462
  if (specifiers.length === 0)
205210
205463
  return {};
205211
- const vendorDir = join16(buildDir, "vendor");
205212
- mkdirSync9(vendorDir, { recursive: true });
205213
- const tmpDir = join16(buildDir, "_dep_vendor_tmp");
205214
- mkdirSync9(tmpDir, { recursive: true });
205464
+ const vendorDir = join17(buildDir, "vendor");
205465
+ mkdirSync10(vendorDir, { recursive: true });
205466
+ const tmpDir = join17(buildDir, "_dep_vendor_tmp");
205467
+ mkdirSync10(tmpDir, { recursive: true });
205215
205468
  const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
205216
205469
  const safeName = toSafeFileName5(specifier);
205217
- const entryPath = join16(tmpDir, `${safeName}.ts`);
205470
+ const entryPath = join17(tmpDir, `${safeName}.ts`);
205218
205471
  const source = await generateEntrySource2(specifier);
205219
205472
  await Bun.write(entryPath, source);
205220
205473
  return entryPath;
@@ -205663,6 +205916,220 @@ var init_hmr = __esm(() => {
205663
205916
  init_webSocket();
205664
205917
  });
205665
205918
 
205919
+ // src/plugins/imageOptimizer.ts
205920
+ var exports_imageOptimizer = {};
205921
+ __export(exports_imageOptimizer, {
205922
+ imageOptimizer: () => imageOptimizer
205923
+ });
205924
+ import { existsSync as existsSync17 } from "fs";
205925
+ import { resolve as resolve23 } from "path";
205926
+ import { Elysia } from "elysia";
205927
+ var DEFAULT_CACHE_TTL_SECONDS = 60, MS_PER_SECOND = 1000, MAX_QUALITY = 100, avifInProgress, safeResolve = (path, baseDir) => {
205928
+ try {
205929
+ const resolved = validateSafePath(path, baseDir);
205930
+ if (existsSync17(resolved))
205931
+ return resolved;
205932
+ return null;
205933
+ } catch {
205934
+ return null;
205935
+ }
205936
+ }, resolveLocalImage = (url, buildDir) => {
205937
+ const cleanPath = url.startsWith("/") ? url.slice(1) : url;
205938
+ return safeResolve(cleanPath, buildDir) ?? safeResolve(cleanPath, resolve23(process.cwd()));
205939
+ }, parseQueryParams = (query, allowedSizes, defaultQuality) => {
205940
+ const url = typeof query["url"] === "string" ? query["url"] : undefined;
205941
+ const wParam = typeof query["w"] === "string" ? query["w"] : undefined;
205942
+ const qParam = typeof query["q"] === "string" ? query["q"] : undefined;
205943
+ if (!url || !wParam) {
205944
+ return {
205945
+ error: new Response("Missing required params: url, w", {
205946
+ status: 400
205947
+ })
205948
+ };
205949
+ }
205950
+ const width = parseInt(wParam, 10);
205951
+ if (isNaN(width) || !allowedSizes.has(width)) {
205952
+ return {
205953
+ error: new Response(`Invalid width: ${wParam}. Must be one of: ${[...allowedSizes].sort((left, right) => left - right).join(", ")}`, { status: 400 })
205954
+ };
205955
+ }
205956
+ const quality = qParam ? parseInt(qParam, 10) : defaultQuality;
205957
+ if (isNaN(quality) || quality < 1 || quality > MAX_QUALITY) {
205958
+ return {
205959
+ error: new Response("Invalid quality: must be 1-100", {
205960
+ status: 400
205961
+ })
205962
+ };
205963
+ }
205964
+ return { params: { quality, url, width } };
205965
+ }, validateImageSecurity = (url, remotePatterns, buildDir) => {
205966
+ const isRemote = url.startsWith("http://") || url.startsWith("https://");
205967
+ if (isRemote) {
205968
+ if (remotePatterns.length === 0 || !matchRemotePattern(url, remotePatterns)) {
205969
+ return {
205970
+ error: new Response("Remote image not allowed. Configure remotePatterns in images config.", { status: 400 }),
205971
+ isRemote
205972
+ };
205973
+ }
205974
+ return { isRemote, resolvedPath: null };
205975
+ }
205976
+ const resolvedPath = resolveLocalImage(url, buildDir);
205977
+ if (!resolvedPath) {
205978
+ return {
205979
+ error: new Response(`Image not found: ${url}`, { status: 404 }),
205980
+ isRemote
205981
+ };
205982
+ }
205983
+ return { isRemote, resolvedPath };
205984
+ }, fetchSourceImage = async (url, isRemote, resolvedPath) => {
205985
+ if (isRemote) {
205986
+ const response = await fetch(url);
205987
+ if (!response.ok) {
205988
+ return {
205989
+ error: new Response(`Failed to fetch remote image: ${response.status}`, { status: 502 })
205990
+ };
205991
+ }
205992
+ return {
205993
+ buffer: Buffer.from(await response.arrayBuffer()),
205994
+ upstreamEtag: response.headers.get("ETag") ?? undefined
205995
+ };
205996
+ }
205997
+ if (!resolvedPath) {
205998
+ return {
205999
+ error: new Response(`Image not found: ${url}`, { status: 404 })
206000
+ };
206001
+ }
206002
+ const file4 = Bun.file(resolvedPath);
206003
+ if (!await file4.exists()) {
206004
+ return {
206005
+ error: new Response(`Image not found: ${url}`, { status: 404 })
206006
+ };
206007
+ }
206008
+ return {
206009
+ buffer: Buffer.from(await file4.arrayBuffer()),
206010
+ upstreamEtag: undefined
206011
+ };
206012
+ }, scheduleAvifPregen = (url, width, quality, sourceBuffer, configuredFormats, format, cacheDir, minimumCacheTTL, upstreamEtag) => {
206013
+ if (!configuredFormats.includes("avif") || format === "avif") {
206014
+ return;
206015
+ }
206016
+ const avifKey = `${url}|${width}|${quality}`;
206017
+ if (avifInProgress.has(avifKey))
206018
+ return;
206019
+ const avifCacheKey = getCacheKey(url, width, quality, "avif");
206020
+ const avifCached = readFromCache(cacheDir, avifCacheKey);
206021
+ if (avifCached && !isCacheStale(avifCached.meta))
206022
+ return;
206023
+ avifInProgress.add(avifKey);
206024
+ queueMicrotask(async () => {
206025
+ try {
206026
+ const avifBuffer = await optimizeImage(sourceBuffer, width, quality, "avif");
206027
+ const avifMeta = {
206028
+ contentType: "image/avif",
206029
+ etag: `"${avifCacheKey}"`,
206030
+ expireAt: Date.now() + minimumCacheTTL,
206031
+ upstreamEtag
206032
+ };
206033
+ writeToCache(cacheDir, avifCacheKey, avifBuffer, avifMeta);
206034
+ } catch {} finally {
206035
+ avifInProgress.delete(avifKey);
206036
+ }
206037
+ });
206038
+ }, imageOptimizer = (config, buildDir) => (app) => {
206039
+ if (!config && config !== undefined)
206040
+ return app;
206041
+ if (config?.unoptimized)
206042
+ return app;
206043
+ const endpointPath = config?.path ?? OPTIMIZATION_ENDPOINT;
206044
+ const allowedSizes = new Set([
206045
+ ...config?.deviceSizes ?? DEFAULT_DEVICE_SIZES,
206046
+ ...config?.imageSizes ?? DEFAULT_IMAGE_SIZES
206047
+ ]);
206048
+ const defaultQuality = config?.quality ?? DEFAULT_QUALITY;
206049
+ const minimumCacheTTL = (config?.minimumCacheTTL ?? DEFAULT_CACHE_TTL_SECONDS) * MS_PER_SECOND;
206050
+ const configuredFormats = config?.formats ?? ["webp"];
206051
+ const remotePatterns = config?.remotePatterns ?? [];
206052
+ const cacheDir = getCacheDir(buildDir);
206053
+ const plugin = new Elysia({ name: "image-optimizer" }).get(endpointPath, async ({ query, request }) => {
206054
+ const parsed = parseQueryParams(query, allowedSizes, defaultQuality);
206055
+ if ("error" in parsed)
206056
+ return parsed.error;
206057
+ const { quality, url, width } = parsed.params;
206058
+ const security = validateImageSecurity(url, remotePatterns, buildDir);
206059
+ if ("error" in security)
206060
+ return security.error;
206061
+ const { isRemote, resolvedPath } = security;
206062
+ const acceptHeader = request.headers.get("Accept") ?? "";
206063
+ const format = negotiateFormat(acceptHeader, configuredFormats);
206064
+ const mime = formatToMime(format);
206065
+ const cacheKey2 = getCacheKey(url, width, quality, format);
206066
+ const cached = readFromCache(cacheDir, cacheKey2);
206067
+ if (cached && !isCacheStale(cached.meta)) {
206068
+ const ifNoneMatch = request.headers.get("If-None-Match");
206069
+ if (ifNoneMatch && ifNoneMatch === cached.meta.etag) {
206070
+ return new Response(null, {
206071
+ headers: {
206072
+ "Cache-Control": `public, max-age=${Math.ceil(minimumCacheTTL / MS_PER_SECOND)}, must-revalidate`,
206073
+ ETag: cached.meta.etag,
206074
+ Vary: "Accept"
206075
+ },
206076
+ status: 304
206077
+ });
206078
+ }
206079
+ return new Response(new Uint8Array(cached.buffer), {
206080
+ headers: {
206081
+ "Cache-Control": `public, max-age=${Math.ceil(minimumCacheTTL / MS_PER_SECOND)}, must-revalidate`,
206082
+ "Content-Type": cached.meta.contentType,
206083
+ ETag: cached.meta.etag,
206084
+ Vary: "Accept"
206085
+ }
206086
+ });
206087
+ }
206088
+ let sourceBuffer;
206089
+ let upstreamEtag;
206090
+ try {
206091
+ const source = await fetchSourceImage(url, isRemote, resolvedPath ?? null);
206092
+ if ("error" in source)
206093
+ return source.error;
206094
+ sourceBuffer = source.buffer;
206095
+ ({ upstreamEtag } = source);
206096
+ } catch (err) {
206097
+ return new Response(`Failed to load image: ${err instanceof Error ? err.message : "unknown error"}`, { status: 500 });
206098
+ }
206099
+ let optimizedBuffer;
206100
+ try {
206101
+ optimizedBuffer = await optimizeImage(sourceBuffer, width, quality, format);
206102
+ } catch {
206103
+ optimizedBuffer = sourceBuffer;
206104
+ }
206105
+ const etag = `"${cacheKey2}"`;
206106
+ const meta = {
206107
+ contentType: mime,
206108
+ etag,
206109
+ expireAt: Date.now() + minimumCacheTTL,
206110
+ upstreamEtag
206111
+ };
206112
+ try {
206113
+ writeToCache(cacheDir, cacheKey2, optimizedBuffer, meta);
206114
+ } catch {}
206115
+ scheduleAvifPregen(url, width, quality, sourceBuffer, configuredFormats, format, cacheDir, minimumCacheTTL, upstreamEtag);
206116
+ return new Response(new Uint8Array(optimizedBuffer), {
206117
+ headers: {
206118
+ "Cache-Control": `public, max-age=${Math.ceil(minimumCacheTTL / MS_PER_SECOND)}, must-revalidate`,
206119
+ "Content-Type": mime,
206120
+ ETag: etag,
206121
+ Vary: "Accept"
206122
+ }
206123
+ });
206124
+ });
206125
+ return app.use(plugin);
206126
+ };
206127
+ var init_imageOptimizer = __esm(() => {
206128
+ init_imageProcessing();
206129
+ init_validateSafePath();
206130
+ avifInProgress = new Set;
206131
+ });
206132
+
205666
206133
  // src/utils/generateSitemap.ts
205667
206134
  var exports_generateSitemap = {};
205668
206135
  __export(exports_generateSitemap, {
@@ -205755,8 +206222,8 @@ __export(exports_prerender, {
205755
206222
  prerender: () => prerender,
205756
206223
  PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
205757
206224
  });
205758
- import { mkdirSync as mkdirSync10 } from "fs";
205759
- import { join as join17 } from "path";
206225
+ import { mkdirSync as mkdirSync11 } from "fs";
206226
+ import { join as join18 } from "path";
205760
206227
  var PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
205761
206228
  const metaPath = htmlPath.replace(/\.html$/, ".meta");
205762
206229
  await Bun.write(metaPath, String(Date.now()));
@@ -205806,7 +206273,7 @@ var PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (
205806
206273
  return false;
205807
206274
  const html = await res.text();
205808
206275
  const fileName = routeToFilename(route);
205809
- const filePath = join17(prerenderDir, fileName);
206276
+ const filePath = join18(prerenderDir, fileName);
205810
206277
  await Bun.write(filePath, html);
205811
206278
  await writeTimestamp(filePath);
205812
206279
  return true;
@@ -205814,8 +206281,8 @@ var PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (
205814
206281
  return false;
205815
206282
  }
205816
206283
  }, prerender = async (port, outDir, staticConfig, log2) => {
205817
- const prerenderDir = join17(outDir, "_prerendered");
205818
- mkdirSync10(prerenderDir, { recursive: true });
206284
+ const prerenderDir = join18(outDir, "_prerendered");
206285
+ mkdirSync11(prerenderDir, { recursive: true });
205819
206286
  const baseUrl = `http://localhost:${port}`;
205820
206287
  let routes;
205821
206288
  if (staticConfig.routes === "all") {
@@ -205837,7 +206304,7 @@ var PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (
205837
206304
  }
205838
206305
  const html = await res.text();
205839
206306
  const fileName = routeToFilename(route);
205840
- const filePath = join17(prerenderDir, fileName);
206307
+ const filePath = join18(prerenderDir, fileName);
205841
206308
  await Bun.write(filePath, html);
205842
206309
  await writeTimestamp(filePath);
205843
206310
  result.routes.set(route, filePath);
@@ -205885,12 +206352,12 @@ __export(exports_devCert, {
205885
206352
  hasCert: () => hasCert,
205886
206353
  ensureDevCert: () => ensureDevCert
205887
206354
  });
205888
- import { existsSync as existsSync17, mkdirSync as mkdirSync11, readFileSync as readFileSync11, rmSync as rmSync2 } from "fs";
206355
+ import { existsSync as existsSync19, mkdirSync as mkdirSync12, readFileSync as readFileSync12, rmSync as rmSync2 } from "fs";
205889
206356
  import { platform as platform3 } from "os";
205890
- import { join as join19 } from "path";
205891
- var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[36m[dev]\x1B[0m ${msg}`), devWarn = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[33m[dev]\x1B[0m \x1B[33m${msg}\x1B[0m`), certFilesExist = () => existsSync17(CERT_PATH) && existsSync17(KEY_PATH), isCertExpired = () => {
206357
+ import { join as join20 } from "path";
206358
+ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[36m[dev]\x1B[0m ${msg}`), devWarn = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[33m[dev]\x1B[0m \x1B[33m${msg}\x1B[0m`), certFilesExist = () => existsSync19(CERT_PATH) && existsSync19(KEY_PATH), isCertExpired = () => {
205892
206359
  try {
205893
- const certPem = readFileSync11(CERT_PATH, "utf-8");
206360
+ const certPem = readFileSync12(CERT_PATH, "utf-8");
205894
206361
  const proc = Bun.spawnSync(["openssl", "x509", "-enddate", "-noout"], {
205895
206362
  stdin: new TextEncoder().encode(certPem)
205896
206363
  });
@@ -205959,7 +206426,7 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
205959
206426
  generateSelfSigned();
205960
206427
  }
205961
206428
  }, ensureDevCert = () => {
205962
- mkdirSync11(CERT_DIR, { recursive: true });
206429
+ mkdirSync12(CERT_DIR, { recursive: true });
205963
206430
  if (hasCert()) {
205964
206431
  return { cert: CERT_PATH, key: KEY_PATH };
205965
206432
  }
@@ -205979,8 +206446,8 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
205979
206446
  return null;
205980
206447
  try {
205981
206448
  return {
205982
- cert: readFileSync11(paths.cert, "utf-8"),
205983
- key: readFileSync11(paths.key, "utf-8")
206449
+ cert: readFileSync12(paths.cert, "utf-8"),
206450
+ key: readFileSync12(paths.key, "utf-8")
205984
206451
  };
205985
206452
  } catch {
205986
206453
  return null;
@@ -206086,16 +206553,16 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
206086
206553
  }
206087
206554
  rmSync2(CERT_PATH, { force: true });
206088
206555
  rmSync2(KEY_PATH, { force: true });
206089
- mkdirSync11(CERT_DIR, { recursive: true });
206556
+ mkdirSync12(CERT_DIR, { recursive: true });
206090
206557
  generateWithMkcert();
206091
206558
  console.log("");
206092
206559
  devLog("mkcert installed \u2014 HTTPS certificates are now locally trusted");
206093
206560
  return true;
206094
206561
  };
206095
206562
  var init_devCert = __esm(() => {
206096
- CERT_DIR = join19(process.cwd(), ".absolutejs");
206097
- CERT_PATH = join19(CERT_DIR, "cert.pem");
206098
- KEY_PATH = join19(CERT_DIR, "key.pem");
206563
+ CERT_DIR = join20(process.cwd(), ".absolutejs");
206564
+ CERT_PATH = join20(CERT_DIR, "cert.pem");
206565
+ KEY_PATH = join20(CERT_DIR, "key.pem");
206099
206566
  });
206100
206567
  // types/client.ts
206101
206568
  var hmrState = {
@@ -206122,8 +206589,8 @@ var {file } = globalThis.Bun;
206122
206589
  var handleHTMLPageRequest = (pagePath) => file(pagePath);
206123
206590
  var handleHTMXPageRequest = (pagePath) => file(pagePath);
206124
206591
  // src/core/prepare.ts
206125
- import { existsSync as existsSync16, readdirSync as readdirSync2, readFileSync as readFileSync10 } from "fs";
206126
- import { basename as basename9, join as join18, relative as relative10, resolve as resolve23 } from "path";
206592
+ import { existsSync as existsSync18, readdirSync as readdirSync2, readFileSync as readFileSync11 } from "fs";
206593
+ import { basename as basename9, join as join19, relative as relative10, resolve as resolve24 } from "path";
206127
206594
 
206128
206595
  // src/utils/loadConfig.ts
206129
206596
  import { resolve } from "path";
@@ -206164,7 +206631,7 @@ var collectPrewarmFiles = async (prewarmDirs) => {
206164
206631
  for (const { dir, pattern } of prewarmDirs) {
206165
206632
  const glob = new Glob8(pattern);
206166
206633
  const matches = [
206167
- ...glob.scanSync({ absolute: true, cwd: resolve23(dir) })
206634
+ ...glob.scanSync({ absolute: true, cwd: resolve24(dir) })
206168
206635
  ];
206169
206636
  files.push(...matches);
206170
206637
  }
@@ -206200,8 +206667,8 @@ var patchManifestIndexes = (manifest, devIndexDir, SRC_URL_PREFIX2) => {
206200
206667
  const fileName = resolveDevIndexFileName(manifest[key], baseName);
206201
206668
  if (!fileName)
206202
206669
  continue;
206203
- const srcPath = resolve23(devIndexDir, fileName);
206204
- if (!existsSync16(srcPath))
206670
+ const srcPath = resolve24(devIndexDir, fileName);
206671
+ if (!existsSync18(srcPath))
206205
206672
  continue;
206206
206673
  const rel = relative10(process.cwd(), srcPath).replace(/\\/g, "/");
206207
206674
  manifest[key] = `${SRC_URL_PREFIX2}${rel}`;
@@ -206244,16 +206711,17 @@ var prepareDev = async (config, buildDir) => {
206244
206711
  };
206245
206712
  }
206246
206713
  const hmrPlugin = hmr2(result.hmrState, result.manifest, moduleHandler);
206247
- const devIndexDir = resolve23(buildDir, "_src_indexes");
206714
+ const devIndexDir = resolve24(buildDir, "_src_indexes");
206248
206715
  patchManifestIndexes(result.manifest, devIndexDir, SRC_URL_PREFIX2);
206716
+ const { imageOptimizer: imageOptimizer2 } = await Promise.resolve().then(() => (init_imageOptimizer(), exports_imageOptimizer));
206249
206717
  return {
206250
206718
  manifest: result.manifest,
206251
- absolutejs: (app) => addSitemapHook(hmrPlugin(app.use(staticPlugin({ assets: buildDir, prefix: "" }))), buildDir, config.sitemap)
206719
+ absolutejs: (app) => addSitemapHook(hmrPlugin(app.use(imageOptimizer2(config.images, buildDir)).use(staticPlugin({ assets: buildDir, prefix: "" }))), buildDir, config.sitemap)
206252
206720
  };
206253
206721
  };
206254
206722
  var loadPrerenderMap = (prerenderDir) => {
206255
206723
  const map = new Map;
206256
- if (!existsSync16(prerenderDir))
206724
+ if (!existsSync18(prerenderDir))
206257
206725
  return map;
206258
206726
  try {
206259
206727
  for (const entry of readdirSync2(prerenderDir)) {
@@ -206261,40 +206729,36 @@ var loadPrerenderMap = (prerenderDir) => {
206261
206729
  continue;
206262
206730
  const name = basename9(entry, ".html");
206263
206731
  const route = name === "index" ? "/" : `/${name}`;
206264
- map.set(route, join18(prerenderDir, entry));
206732
+ map.set(route, join19(prerenderDir, entry));
206265
206733
  }
206266
206734
  } catch {}
206267
206735
  return map;
206268
206736
  };
206269
- var addSitemapHook = (app, publicDir, sitemapConfig) => {
206270
- if (!publicDir)
206271
- return app;
206272
- return app.onStart((started) => {
206273
- const { server: server2 } = started;
206274
- if (!server2)
206275
- return;
206276
- Promise.resolve().then(() => (init_generateSitemap(), exports_generateSitemap)).then(({ generateSitemap: generateSitemap2 }) => generateSitemap2(started.routes, server2.url.origin, publicDir, sitemapConfig)).catch((err) => console.error("[sitemap] Generation failed:", err));
206277
- });
206278
- };
206737
+ var addSitemapHook = (app, buildDir, sitemapConfig) => app.onStart((started) => {
206738
+ const { server: server2 } = started;
206739
+ if (!server2)
206740
+ return;
206741
+ Promise.resolve().then(() => (init_generateSitemap(), exports_generateSitemap)).then(({ generateSitemap: generateSitemap2 }) => generateSitemap2(started.routes, server2.url.origin, buildDir, sitemapConfig)).catch((err) => console.error("[sitemap] Generation failed:", err));
206742
+ });
206279
206743
  var prepare = async (configOrPath) => {
206280
206744
  const config = await loadConfig(configOrPath);
206281
206745
  const nodeEnv = process.env["NODE_ENV"];
206282
206746
  const isDev2 = nodeEnv === "development";
206283
- const buildDir = resolve23(isDev2 ? config.buildDirectory ?? "build" : process.env.ABSOLUTE_BUILD_DIR ?? config.buildDirectory ?? "build");
206747
+ const buildDir = resolve24(isDev2 ? config.buildDirectory ?? "build" : process.env.ABSOLUTE_BUILD_DIR ?? config.buildDirectory ?? "build");
206284
206748
  if (isDev2)
206285
206749
  return prepareDev(config, buildDir);
206286
- const manifest = JSON.parse(readFileSync10(`${buildDir}/manifest.json`, "utf-8"));
206750
+ const manifest = JSON.parse(readFileSync11(`${buildDir}/manifest.json`, "utf-8"));
206287
206751
  const { staticPlugin } = await import("@elysiajs/static");
206288
206752
  const staticFiles = staticPlugin({ assets: buildDir, prefix: "" });
206289
- const prerenderDir = join18(buildDir, "_prerendered");
206753
+ const prerenderDir = join19(buildDir, "_prerendered");
206290
206754
  const prerenderMap = loadPrerenderMap(prerenderDir);
206291
206755
  if (prerenderMap.size > 0) {
206292
- const { Elysia } = await import("elysia");
206756
+ const { Elysia: Elysia2 } = await import("elysia");
206293
206757
  const { PRERENDER_BYPASS_HEADER: PRERENDER_BYPASS_HEADER2, readTimestamp: readTimestamp2, rerenderRoute: rerenderRoute2 } = await Promise.resolve().then(() => (init_prerender(), exports_prerender));
206294
206758
  const revalidateMs = config.static?.revalidate ? config.static.revalidate * 1000 : 0;
206295
206759
  const port = Number(process.env.PORT) || 3000;
206296
206760
  const rerendering = new Set;
206297
- const prerenderPlugin = new Elysia({
206761
+ const prerenderPlugin = new Elysia2({
206298
206762
  name: "prerendered-pages"
206299
206763
  }).onRequest(({ request }) => {
206300
206764
  const url = new URL(request.url);
@@ -206315,10 +206779,12 @@ var prepare = async (configOrPath) => {
206315
206779
  headers: { "content-type": "text/html; charset=utf-8" }
206316
206780
  });
206317
206781
  });
206318
- const absolutejs2 = (app) => addSitemapHook(app.use(prerenderPlugin).use(staticFiles), buildDir, config.sitemap);
206782
+ const { imageOptimizer: imageOptimizer3 } = await Promise.resolve().then(() => (init_imageOptimizer(), exports_imageOptimizer));
206783
+ const absolutejs2 = (app) => addSitemapHook(app.use(imageOptimizer3(config.images, buildDir)).use(prerenderPlugin).use(staticFiles), buildDir, config.sitemap);
206319
206784
  return { absolutejs: absolutejs2, manifest };
206320
206785
  }
206321
- const absolutejs = (app) => addSitemapHook(app.use(staticFiles), buildDir, config.sitemap);
206786
+ const { imageOptimizer: imageOptimizer2 } = await Promise.resolve().then(() => (init_imageOptimizer(), exports_imageOptimizer));
206787
+ const absolutejs = (app) => addSitemapHook(app.use(imageOptimizer2(config.images, buildDir)).use(staticFiles), buildDir, config.sitemap);
206322
206788
  return { absolutejs, manifest };
206323
206789
  };
206324
206790
  // src/plugins/networking.ts
@@ -206618,5 +207084,5 @@ export {
206618
207084
  ANGULAR_INIT_TIMEOUT_MS
206619
207085
  };
206620
207086
 
206621
- //# debugId=131C329B7ED8ED0164756E2164756E21
207087
+ //# debugId=E998A8E80C0F65EC64756E2164756E21
206622
207088
  //# sourceMappingURL=index.js.map