@absolutejs/absolute 0.19.0-beta.845 → 0.19.0-beta.847

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 (37) hide show
  1. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  2. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  3. package/dist/angular/index.js +45 -23
  4. package/dist/angular/index.js.map +11 -10
  5. package/dist/angular/server.js +45 -23
  6. package/dist/angular/server.js.map +11 -10
  7. package/dist/build.js +955 -498
  8. package/dist/build.js.map +16 -13
  9. package/dist/cli/index.js +547 -286
  10. package/dist/client/index.js +16 -9
  11. package/dist/client/index.js.map +6 -5
  12. package/dist/dev/client/handlers/angular.ts +309 -19
  13. package/dist/dev/client/handlers/angularRuntime.ts +468 -0
  14. package/dist/dev/client/hmrToast.ts +150 -0
  15. package/dist/index.js +1002 -545
  16. package/dist/index.js.map +17 -14
  17. package/dist/islands/index.js +32 -11
  18. package/dist/islands/index.js.map +7 -6
  19. package/dist/react/index.js +32 -11
  20. package/dist/react/index.js.map +7 -6
  21. package/dist/src/build/rewriteImports.d.ts +6 -14
  22. package/dist/src/build/rewriteImportsPlugin.d.ts +48 -0
  23. package/dist/src/dev/angular/editTypeDetection.d.ts +8 -0
  24. package/dist/src/dev/pathUtils.d.ts +3 -0
  25. package/dist/src/utils/buildDirectoryLock.d.ts +26 -3
  26. package/dist/src/utils/loadConfig.d.ts +5 -0
  27. package/dist/src/utils/resolveDevPort.d.ts +21 -0
  28. package/dist/src/utils/runtimeMode.d.ts +3 -0
  29. package/dist/svelte/index.js +32 -11
  30. package/dist/svelte/index.js.map +7 -6
  31. package/dist/svelte/server.js +17 -3
  32. package/dist/svelte/server.js.map +3 -3
  33. package/dist/types/build.d.ts +15 -0
  34. package/dist/types/globals.d.ts +12 -0
  35. package/dist/vue/index.js +32 -11
  36. package/dist/vue/index.js.map +7 -6
  37. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -211,6 +211,186 @@ var init_telemetryEvent = __esm(() => {
211
211
  init_telemetry();
212
212
  });
213
213
 
214
+ // src/utils/buildDirectoryLock.ts
215
+ import { mkdirSync as mkdirSync2, unlinkSync, writeFileSync as writeFileSync2, readFileSync as readFileSync3 } from "fs";
216
+ import { dirname as dirname2, join as join3 } from "path";
217
+ var heldLocks, HELD_LOCKS_ENV = "ABSOLUTE_HELD_BUILD_DIRECTORY_LOCKS", exitHandlersRegistered = false, registerExitHandlersOnce = () => {
218
+ if (exitHandlersRegistered)
219
+ return;
220
+ exitHandlersRegistered = true;
221
+ const releaseAllSync = () => {
222
+ for (const lock of heldLocks.values()) {
223
+ try {
224
+ lock.releaseSync();
225
+ } catch {}
226
+ }
227
+ heldLocks.clear();
228
+ };
229
+ process.on("exit", releaseAllSync);
230
+ process.on("SIGINT", () => {
231
+ releaseAllSync();
232
+ process.exit(130);
233
+ });
234
+ process.on("SIGTERM", () => {
235
+ releaseAllSync();
236
+ process.exit(143);
237
+ });
238
+ process.on("uncaughtException", (err) => {
239
+ releaseAllSync();
240
+ throw err;
241
+ });
242
+ }, isAlreadyExistsError = (error) => error instanceof Error && ("code" in error) && error.code === "EEXIST", lockPathForBuildDirectory = (buildDirectory) => join3(dirname2(buildDirectory), ".absolutejs", "build.lock"), readHeldLockEnv = () => new Set((process.env[HELD_LOCKS_ENV] ?? "").split(`
243
+ `).filter((entry) => entry.length > 0)), writeHeldLockEnv = (locks) => {
244
+ if (locks.size === 0) {
245
+ delete process.env[HELD_LOCKS_ENV];
246
+ return;
247
+ }
248
+ process.env[HELD_LOCKS_ENV] = Array.from(locks).join(`
249
+ `);
250
+ }, markHeldLock = (buildDirectory) => {
251
+ const locks = readHeldLockEnv();
252
+ locks.add(buildDirectory);
253
+ writeHeldLockEnv(locks);
254
+ }, unmarkHeldLock = (buildDirectory) => {
255
+ const locks = readHeldLockEnv();
256
+ locks.delete(buildDirectory);
257
+ writeHeldLockEnv(locks);
258
+ }, writeLockFileSync = (lockPath, metadata) => {
259
+ mkdirSync2(dirname2(lockPath), { recursive: true });
260
+ writeFileSync2(lockPath, JSON.stringify(metadata, null, 2), { flag: "wx" });
261
+ }, readLockMetadata = (lockPath) => {
262
+ try {
263
+ const raw = readFileSync3(lockPath, "utf-8");
264
+ const parsed = JSON.parse(raw);
265
+ if (typeof parsed === "object" && parsed !== null && typeof parsed.pid === "number") {
266
+ return {
267
+ pid: parsed.pid,
268
+ port: typeof parsed.port === "number" ? parsed.port : null,
269
+ startedAt: typeof parsed.startedAt === "string" ? parsed.startedAt : new Date().toISOString()
270
+ };
271
+ }
272
+ } catch {}
273
+ return null;
274
+ }, isProcessAlive = (pid) => {
275
+ try {
276
+ process.kill(pid, 0);
277
+ return true;
278
+ } catch (err) {
279
+ const code = err.code;
280
+ if (code === "ESRCH")
281
+ return false;
282
+ if (code === "EPERM")
283
+ return true;
284
+ return true;
285
+ }
286
+ }, removeStaleLockSync = (lockPath, pid) => {
287
+ try {
288
+ unlinkSync(lockPath);
289
+ console.warn(`[absolutejs] removed stale lock from PID ${pid}`);
290
+ } catch {}
291
+ }, updateLockMetadata = (buildDirectory, updates) => {
292
+ const lockPath = lockPathForBuildDirectory(buildDirectory);
293
+ const current = readLockMetadata(lockPath);
294
+ if (!current)
295
+ return;
296
+ if (current.pid !== process.pid && updates.pid !== current.pid) {
297
+ return;
298
+ }
299
+ const next = {
300
+ pid: updates.pid ?? current.pid,
301
+ port: updates.port !== undefined ? updates.port : current.port,
302
+ startedAt: current.startedAt
303
+ };
304
+ try {
305
+ writeFileSync2(lockPath, JSON.stringify(next, null, 2));
306
+ } catch {}
307
+ }, LOCK_POLL_MS = 250, DEFAULT_WAIT_TIMEOUT_MS = 120000, acquireBuildDirectoryLock = async (buildDirectory, options = {}) => {
308
+ registerExitHandlersOnce();
309
+ if (readHeldLockEnv().has(buildDirectory)) {
310
+ return async () => {};
311
+ }
312
+ const heldLock = heldLocks.get(buildDirectory);
313
+ if (heldLock) {
314
+ heldLock.count += 1;
315
+ return async () => {
316
+ heldLock.count -= 1;
317
+ if (heldLock.count === 0) {
318
+ heldLocks.delete(buildDirectory);
319
+ await heldLock.release();
320
+ }
321
+ };
322
+ }
323
+ const lockPath = lockPathForBuildDirectory(buildDirectory);
324
+ const wait = options.wait !== false;
325
+ const waitTimeoutMs = options.waitTimeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
326
+ const start = Date.now();
327
+ const tryCreate = () => {
328
+ writeLockFileSync(lockPath, {
329
+ pid: process.pid,
330
+ port: options.port ?? null,
331
+ startedAt: new Date().toISOString()
332
+ });
333
+ };
334
+ while (true) {
335
+ try {
336
+ tryCreate();
337
+ break;
338
+ } catch (error) {
339
+ if (!isAlreadyExistsError(error))
340
+ throw error;
341
+ const existing = readLockMetadata(lockPath);
342
+ if (!existing) {
343
+ try {
344
+ unlinkSync(lockPath);
345
+ } catch {}
346
+ continue;
347
+ }
348
+ if (!isProcessAlive(existing.pid)) {
349
+ removeStaleLockSync(lockPath, existing.pid);
350
+ continue;
351
+ }
352
+ if (wait && Date.now() - start < waitTimeoutMs) {
353
+ await Bun.sleep(LOCK_POLL_MS);
354
+ continue;
355
+ }
356
+ const portInfo = existing.port ? ` on port ${existing.port}` : "";
357
+ const elapsedNote = wait ? ` Waited ${Math.round((Date.now() - start) / 1000)}s.` : "";
358
+ throw new Error(`AbsoluteJS build lock is held by PID ${existing.pid}${portInfo} (started ${existing.startedAt}).${elapsedNote} ` + `Another process owns ${buildDirectory}. ` + `Run \`kill ${existing.pid}\` (or wait for it to finish) and try again.`);
359
+ }
360
+ }
361
+ const releaseSync = () => {
362
+ try {
363
+ unlinkSync(lockPath);
364
+ } catch {}
365
+ };
366
+ const release = async () => {
367
+ releaseSync();
368
+ };
369
+ heldLocks.set(buildDirectory, { count: 1, release, releaseSync });
370
+ markHeldLock(buildDirectory);
371
+ return async () => {
372
+ const current = heldLocks.get(buildDirectory);
373
+ if (!current)
374
+ return;
375
+ current.count -= 1;
376
+ if (current.count > 0)
377
+ return;
378
+ heldLocks.delete(buildDirectory);
379
+ unmarkHeldLock(buildDirectory);
380
+ await current.release();
381
+ };
382
+ }, withBuildDirectoryLock = async (buildDirectory, action, options = {}) => {
383
+ const release = await acquireBuildDirectoryLock(buildDirectory, options);
384
+ try {
385
+ return await action();
386
+ } finally {
387
+ await release();
388
+ }
389
+ };
390
+ var init_buildDirectoryLock = __esm(() => {
391
+ heldLocks = new Map;
392
+ });
393
+
214
394
  // src/utils/loadConfig.ts
215
395
  import { resolve } from "path";
216
396
  var RESERVED_TOP_LEVEL_KEYS, isObject = (value) => typeof value === "object" && value !== null, isCommandService = (service) => service.kind === "command" || Array.isArray(service.command), isServiceCandidate = (value) => isObject(value) && (typeof value.entry === "string" || Array.isArray(value.command)), isWorkspaceConfig = (config) => {
@@ -315,11 +495,11 @@ var init_loadConfig = __esm(() => {
315
495
  // src/cli/utils.ts
316
496
  var {$ } = globalThis.Bun;
317
497
  import { execSync } from "child_process";
318
- import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
498
+ import { existsSync as existsSync3, readFileSync as readFileSync4 } from "fs";
319
499
  import { resolve as resolve2 } from "path";
320
500
  var COMPOSE_PATH = "db/docker-compose.db.yml", DEFAULT_SERVER_ENTRY = "src/backend/server.ts", isWSLEnvironment = () => {
321
501
  try {
322
- const release = readFileSync3("/proc/version", "utf-8");
502
+ const release = readFileSync4("/proc/version", "utf-8");
323
503
  return /microsoft|wsl/i.test(release);
324
504
  } catch {
325
505
  return false;
@@ -409,12 +589,12 @@ __export(exports_devCert, {
409
589
  hasCert: () => hasCert,
410
590
  ensureDevCert: () => ensureDevCert
411
591
  });
412
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync } from "fs";
592
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync5, rmSync } from "fs";
413
593
  import { platform as platform2 } from "os";
414
- import { join as join3 } from "path";
594
+ import { join as join4 } from "path";
415
595
  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 = () => existsSync4(CERT_PATH) && existsSync4(KEY_PATH), isCertExpired = () => {
416
596
  try {
417
- const certPem = readFileSync4(CERT_PATH, "utf-8");
597
+ const certPem = readFileSync5(CERT_PATH, "utf-8");
418
598
  const proc = Bun.spawnSync(["openssl", "x509", "-enddate", "-noout"], {
419
599
  stdin: new TextEncoder().encode(certPem)
420
600
  });
@@ -483,7 +663,7 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
483
663
  generateSelfSigned();
484
664
  }
485
665
  }, ensureDevCert = () => {
486
- mkdirSync2(CERT_DIR, { recursive: true });
666
+ mkdirSync3(CERT_DIR, { recursive: true });
487
667
  if (hasCert()) {
488
668
  return { cert: CERT_PATH, key: KEY_PATH };
489
669
  }
@@ -503,8 +683,8 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
503
683
  return null;
504
684
  try {
505
685
  return {
506
- cert: readFileSync4(paths.cert, "utf-8"),
507
- key: readFileSync4(paths.key, "utf-8")
686
+ cert: readFileSync5(paths.cert, "utf-8"),
687
+ key: readFileSync5(paths.key, "utf-8")
508
688
  };
509
689
  } catch {
510
690
  return null;
@@ -610,16 +790,16 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
610
790
  }
611
791
  rmSync(CERT_PATH, { force: true });
612
792
  rmSync(KEY_PATH, { force: true });
613
- mkdirSync2(CERT_DIR, { recursive: true });
793
+ mkdirSync3(CERT_DIR, { recursive: true });
614
794
  generateWithMkcert();
615
795
  console.log("");
616
796
  devLog("mkcert installed \u2014 HTTPS certificates are now locally trusted");
617
797
  return true;
618
798
  };
619
799
  var init_devCert = __esm(() => {
620
- CERT_DIR = join3(process.cwd(), ".absolutejs");
621
- CERT_PATH = join3(CERT_DIR, "cert.pem");
622
- KEY_PATH = join3(CERT_DIR, "key.pem");
800
+ CERT_DIR = join4(process.cwd(), ".absolutejs");
801
+ CERT_PATH = join4(CERT_DIR, "cert.pem");
802
+ KEY_PATH = join4(CERT_DIR, "key.pem");
623
803
  });
624
804
 
625
805
  // src/core/prerender.ts
@@ -632,15 +812,15 @@ __export(exports_prerender, {
632
812
  prerender: () => prerender,
633
813
  PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
634
814
  });
635
- import { mkdirSync as mkdirSync3, readFileSync as readFileSync7 } from "fs";
636
- import { join as join5 } from "path";
815
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync8 } from "fs";
816
+ import { join as join6 } from "path";
637
817
  var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_TIMEOUT_MS = 30000, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
638
818
  const metaPath = htmlPath.replace(/\.html$/, ".meta");
639
819
  await Bun.write(metaPath, String(Date.now()));
640
820
  }, readTimestamp = (htmlPath) => {
641
821
  const metaPath = htmlPath.replace(/\.html$/, ".meta");
642
822
  try {
643
- const content = readFileSync7(metaPath, "utf-8");
823
+ const content = readFileSync8(metaPath, "utf-8");
644
824
  return Number(content) || 0;
645
825
  } catch {
646
826
  return 0;
@@ -699,7 +879,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
699
879
  return false;
700
880
  const html = await res.text();
701
881
  const fileName = routeToFilename(route);
702
- const filePath = join5(prerenderDir, fileName);
882
+ const filePath = join6(prerenderDir, fileName);
703
883
  await Bun.write(filePath, html);
704
884
  await writeTimestamp(filePath);
705
885
  return true;
@@ -725,14 +905,14 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
725
905
  }
726
906
  const html = await res.text();
727
907
  const fileName = routeToFilename(route);
728
- const filePath = join5(prerenderDir, fileName);
908
+ const filePath = join6(prerenderDir, fileName);
729
909
  await Bun.write(filePath, html);
730
910
  await writeTimestamp(filePath);
731
911
  result.routes.set(route, filePath);
732
912
  log?.(` Pre-rendered ${route} \u2192 ${fileName} (${html.length} bytes)`);
733
913
  }, prerender = async (port, outDir, staticConfig, log) => {
734
- const prerenderDir = join5(outDir, "_prerendered");
735
- mkdirSync3(prerenderDir, { recursive: true });
914
+ const prerenderDir = join6(outDir, "_prerendered");
915
+ mkdirSync4(prerenderDir, { recursive: true });
736
916
  const baseUrl = `http://localhost:${port}`;
737
917
  let routes;
738
918
  if (staticConfig.routes === "all") {
@@ -886,12 +1066,9 @@ var init_nativeRewrite = __esm(() => {
886
1066
  };
887
1067
  });
888
1068
 
889
- // src/build/rewriteImports.ts
890
- var exports_rewriteImports = {};
891
- __export(exports_rewriteImports, {
892
- rewriteVendorDirectories: () => rewriteVendorDirectories,
893
- rewriteImports: () => rewriteImports
894
- });
1069
+ // src/build/rewriteImportsPlugin.ts
1070
+ import { readdir } from "fs/promises";
1071
+ import { join as join7 } from "path";
895
1072
  var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
896
1073
  let result = content;
897
1074
  for (const [specifier, webPath] of replacements) {
@@ -904,93 +1081,143 @@ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewrite
904
1081
  result = result.replace(dynamicRegex, `$1${webPath}$2`);
905
1082
  }
906
1083
  return result;
907
- }, rewriteImports = async (outputPaths, vendorPaths) => {
908
- const jsFiles = outputPaths.filter((path) => path.endsWith(".js"));
909
- if (jsFiles.length === 0)
910
- return;
1084
+ }, rewriteImportsInContent = (content, vendorPaths) => {
1085
+ if (Object.keys(vendorPaths).length === 0)
1086
+ return content;
911
1087
  const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
912
- await Promise.all(jsFiles.map(async (filePath) => {
913
- const original = await Bun.file(filePath).text();
914
- const native = nativeRewriteImports(original, replacements);
915
- const content = native ?? jsRewriteImports(original, replacements);
916
- if (content !== original) {
917
- await Bun.write(filePath, content);
1088
+ const native = nativeRewriteImports(content, replacements);
1089
+ return native ?? jsRewriteImports(content, replacements);
1090
+ }, fixMissingReExportNamespacesInContent = (content) => {
1091
+ const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
1092
+ REEXPORT_PATTERN.lastIndex = 0;
1093
+ const missing = [];
1094
+ let match;
1095
+ while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
1096
+ const ident = match[1];
1097
+ if (!ident)
1098
+ continue;
1099
+ const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
1100
+ if (nsImportRe.test(content))
1101
+ continue;
1102
+ const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
1103
+ if (declRe.test(content))
1104
+ continue;
1105
+ const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
1106
+ if (namedImportRe.test(content))
1107
+ continue;
1108
+ const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
1109
+ let pathMatch;
1110
+ let sourcePath;
1111
+ while ((pathMatch = importPathRe.exec(content)) !== null) {
1112
+ const p = pathMatch[1];
1113
+ if (!p)
1114
+ continue;
1115
+ const base = p.split("/").pop()?.replace(/\.[mc]?js$/, "");
1116
+ if (!base)
1117
+ continue;
1118
+ const normalized = base.startsWith("_") ? base.slice(1) : base;
1119
+ if (normalized === ident || normalized.endsWith(`_${ident}`)) {
1120
+ sourcePath = p;
1121
+ break;
1122
+ }
918
1123
  }
919
- }));
1124
+ if (sourcePath)
1125
+ missing.push({ ident, path: sourcePath });
1126
+ }
1127
+ if (missing.length === 0)
1128
+ return content;
1129
+ const seen = new Set;
1130
+ const unique = missing.filter((entry) => {
1131
+ if (seen.has(entry.ident))
1132
+ return false;
1133
+ seen.add(entry.ident);
1134
+ return true;
1135
+ });
1136
+ const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
1137
+ `);
1138
+ return `${inserts}
1139
+ ${content}`;
920
1140
  }, rewriteVendorDirectories = async (vendorDirs, vendorPaths) => {
921
1141
  if (Object.keys(vendorPaths).length === 0)
922
1142
  return;
923
- const { readdirSync } = await import("fs");
924
- const { join: join6 } = await import("path");
925
1143
  const allFiles = [];
926
1144
  for (const dir of vendorDirs) {
927
1145
  try {
928
- const files = readdirSync(dir).filter((f) => f.endsWith(".js")).map((f) => join6(dir, f));
929
- allFiles.push(...files);
1146
+ const entries = await readdir(dir);
1147
+ for (const entry of entries) {
1148
+ if (entry.endsWith(".js"))
1149
+ allFiles.push(join7(dir, entry));
1150
+ }
930
1151
  } catch {}
931
1152
  }
932
- await rewriteImports(allFiles, vendorPaths);
933
- await fixMissingReExportNamespaces(allFiles);
934
- }, fixMissingReExportNamespaces = async (files) => {
935
- const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
936
- await Promise.all(files.map(async (filePath) => {
937
- const content = await Bun.file(filePath).text();
938
- REEXPORT_PATTERN.lastIndex = 0;
939
- const missing = [];
940
- let match;
941
- while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
942
- const ident = match[1];
943
- if (!ident)
944
- continue;
945
- const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
946
- if (nsImportRe.test(content))
947
- continue;
948
- const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
949
- if (declRe.test(content))
950
- continue;
951
- const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
952
- if (namedImportRe.test(content))
953
- continue;
954
- const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
955
- let pathMatch;
956
- let sourcePath;
957
- while ((pathMatch = importPathRe.exec(content)) !== null) {
958
- const p = pathMatch[1];
959
- if (!p)
960
- continue;
961
- const base = p.split("/").pop()?.replace(/\.[mc]?js$/, "");
962
- if (!base)
963
- continue;
964
- const normalized = base.startsWith("_") ? base.slice(1) : base;
965
- if (normalized === ident || normalized.endsWith(`_${ident}`)) {
966
- sourcePath = p;
967
- break;
968
- }
969
- }
970
- if (sourcePath) {
971
- missing.push({ ident, path: sourcePath });
972
- }
1153
+ await Promise.all(allFiles.map(async (filePath) => {
1154
+ let original;
1155
+ try {
1156
+ original = await Bun.file(filePath).text();
1157
+ } catch (err) {
1158
+ const code = err.code;
1159
+ if (code === "ENOENT")
1160
+ return;
1161
+ throw err;
973
1162
  }
974
- if (missing.length === 0)
1163
+ let next = rewriteImportsInContent(original, vendorPaths);
1164
+ next = fixMissingReExportNamespacesInContent(next);
1165
+ if (next === original)
975
1166
  return;
976
- const seen = new Set;
977
- const unique = missing.filter((entry) => {
978
- if (seen.has(entry.ident))
979
- return false;
980
- seen.add(entry.ident);
981
- return true;
982
- });
983
- const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
984
- `);
985
- const patched = `${inserts}
986
- ${content}`;
987
- await Bun.write(filePath, patched);
1167
+ try {
1168
+ await Bun.write(filePath, next);
1169
+ } catch (err) {
1170
+ const code = err.code;
1171
+ if (code === "ENOENT")
1172
+ return;
1173
+ throw err;
1174
+ }
988
1175
  }));
989
1176
  };
990
- var init_rewriteImports = __esm(() => {
1177
+ var init_rewriteImportsPlugin = __esm(() => {
991
1178
  init_nativeRewrite();
992
1179
  });
993
1180
 
1181
+ // src/build/rewriteImports.ts
1182
+ var exports_rewriteImports = {};
1183
+ __export(exports_rewriteImports, {
1184
+ rewriteVendorDirectories: () => rewriteVendorDirectories2,
1185
+ rewriteImports: () => rewriteImports
1186
+ });
1187
+ var rewriteImports = async (outputPaths, vendorPaths) => {
1188
+ const jsFiles = outputPaths.filter((path) => path.endsWith(".js"));
1189
+ if (jsFiles.length === 0)
1190
+ return;
1191
+ if (Object.keys(vendorPaths).length === 0)
1192
+ return;
1193
+ await Promise.all(jsFiles.map(async (filePath) => {
1194
+ let original;
1195
+ try {
1196
+ original = await Bun.file(filePath).text();
1197
+ } catch (err) {
1198
+ const code = err.code;
1199
+ if (code === "ENOENT")
1200
+ return;
1201
+ throw err;
1202
+ }
1203
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
1204
+ if (rewritten === original)
1205
+ return;
1206
+ try {
1207
+ await Bun.write(filePath, rewritten);
1208
+ } catch (err) {
1209
+ const code = err.code;
1210
+ if (code === "ENOENT")
1211
+ return;
1212
+ throw err;
1213
+ }
1214
+ }));
1215
+ }, rewriteVendorDirectories2;
1216
+ var init_rewriteImports = __esm(() => {
1217
+ init_rewriteImportsPlugin();
1218
+ rewriteVendorDirectories2 = rewriteVendorDirectories;
1219
+ });
1220
+
994
1221
  // src/cli/scripts/build.ts
995
1222
  var exports_build = {};
996
1223
  __export(exports_build, {
@@ -1050,98 +1277,6 @@ var init_build = __esm(() => {
1050
1277
  init_telemetryEvent();
1051
1278
  });
1052
1279
 
1053
- // src/utils/buildDirectoryLock.ts
1054
- import { mkdir as mkdir2, rm, stat, writeFile } from "fs/promises";
1055
- import { dirname as dirname2, join as join6 } from "path";
1056
- var DEFAULT_LOCK_TIMEOUT_MS = 120000, DEFAULT_STALE_LOCK_MS, LOCK_POLL_MS = 250, heldLocks, HELD_LOCKS_ENV = "ABSOLUTE_HELD_BUILD_DIRECTORY_LOCKS", isAlreadyExistsError = (error) => error instanceof Error && ("code" in error) && error.code === "EEXIST", lockPathForBuildDirectory = (buildDirectory) => join6(dirname2(buildDirectory), `.${buildDirectory.split(/[\\/]/).pop()}.lock`), readHeldLockEnv = () => new Set((process.env[HELD_LOCKS_ENV] ?? "").split(`
1057
- `).filter((entry) => entry.length > 0)), writeHeldLockEnv = (locks) => {
1058
- if (locks.size === 0) {
1059
- delete process.env[HELD_LOCKS_ENV];
1060
- return;
1061
- }
1062
- process.env[HELD_LOCKS_ENV] = Array.from(locks).join(`
1063
- `);
1064
- }, markHeldLock = (buildDirectory) => {
1065
- const locks = readHeldLockEnv();
1066
- locks.add(buildDirectory);
1067
- writeHeldLockEnv(locks);
1068
- }, unmarkHeldLock = (buildDirectory) => {
1069
- const locks = readHeldLockEnv();
1070
- locks.delete(buildDirectory);
1071
- writeHeldLockEnv(locks);
1072
- }, acquireBuildDirectoryLock = async (buildDirectory, options = {}) => {
1073
- if (readHeldLockEnv().has(buildDirectory)) {
1074
- return async () => {};
1075
- }
1076
- const heldLock = heldLocks.get(buildDirectory);
1077
- if (heldLock) {
1078
- heldLock.count += 1;
1079
- return async () => {
1080
- heldLock.count -= 1;
1081
- if (heldLock.count === 0) {
1082
- heldLocks.delete(buildDirectory);
1083
- await heldLock.release();
1084
- }
1085
- };
1086
- }
1087
- const lockPath = lockPathForBuildDirectory(buildDirectory);
1088
- const staleLockMs = options.staleLockMs ?? DEFAULT_STALE_LOCK_MS;
1089
- const timeoutMs = options.timeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS;
1090
- const start2 = Date.now();
1091
- while (true) {
1092
- try {
1093
- await mkdir2(dirname2(lockPath), { recursive: true });
1094
- await mkdir2(lockPath);
1095
- await writeFile(join6(lockPath, "owner"), JSON.stringify({
1096
- buildDirectory,
1097
- createdAt: new Date().toISOString(),
1098
- pid: process.pid
1099
- }, null, 2));
1100
- const release = async () => {
1101
- await rm(lockPath, { force: true, recursive: true }).catch(() => {});
1102
- };
1103
- heldLocks.set(buildDirectory, { count: 1, release });
1104
- markHeldLock(buildDirectory);
1105
- return async () => {
1106
- const current = heldLocks.get(buildDirectory);
1107
- if (!current)
1108
- return;
1109
- current.count -= 1;
1110
- if (current.count > 0)
1111
- return;
1112
- heldLocks.delete(buildDirectory);
1113
- unmarkHeldLock(buildDirectory);
1114
- await current.release();
1115
- };
1116
- } catch (error) {
1117
- if (!isAlreadyExistsError(error))
1118
- throw error;
1119
- try {
1120
- const lockStat = await stat(lockPath);
1121
- if (Date.now() - lockStat.mtimeMs > staleLockMs) {
1122
- await rm(lockPath, { force: true, recursive: true });
1123
- continue;
1124
- }
1125
- } catch {}
1126
- if (Date.now() - start2 > timeoutMs) {
1127
- throw new Error(`Timed out waiting for AbsoluteJS build directory lock: ${buildDirectory}`);
1128
- }
1129
- await Bun.sleep(LOCK_POLL_MS);
1130
- }
1131
- }
1132
- }, withBuildDirectoryLock = async (buildDirectory, action) => {
1133
- const release = await acquireBuildDirectoryLock(buildDirectory);
1134
- try {
1135
- return await action();
1136
- } finally {
1137
- await release();
1138
- }
1139
- };
1140
- var init_buildDirectoryLock = __esm(() => {
1141
- DEFAULT_STALE_LOCK_MS = 10 * 60000;
1142
- heldLocks = new Map;
1143
- });
1144
-
1145
1280
  // src/cli/scripts/compile.ts
1146
1281
  var exports_compile = {};
1147
1282
  __export(exports_compile, {
@@ -1152,15 +1287,15 @@ var {env: env3 } = globalThis.Bun;
1152
1287
  import {
1153
1288
  cpSync,
1154
1289
  existsSync as existsSync10,
1155
- mkdirSync as mkdirSync5,
1290
+ mkdirSync as mkdirSync6,
1156
1291
  readdirSync as readdirSync2,
1157
- readFileSync as readFileSync10,
1292
+ readFileSync as readFileSync11,
1158
1293
  rmSync as rmSync3,
1159
1294
  statSync,
1160
- unlinkSync as unlinkSync2,
1161
- writeFileSync as writeFileSync3
1295
+ unlinkSync as unlinkSync3,
1296
+ writeFileSync as writeFileSync4
1162
1297
  } from "fs";
1163
- import { basename as basename2, dirname as dirname3, join as join7, relative, resolve as resolve10 } from "path";
1298
+ import { basename as basename2, dirname as dirname3, join as join8, relative, resolve as resolve10 } from "path";
1164
1299
  var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
1165
1300
  const resolvedVersion = version2 || "unknown";
1166
1301
  console.log("");
@@ -1173,7 +1308,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1173
1308
  const entry = pending.pop();
1174
1309
  if (!entry)
1175
1310
  continue;
1176
- const fullPath = join7(entry.parentPath, entry.name);
1311
+ const fullPath = join8(entry.parentPath, entry.name);
1177
1312
  if (entry.isDirectory())
1178
1313
  pending = pending.concat(readdirSync2(fullPath, { withFileTypes: true }));
1179
1314
  else
@@ -1193,7 +1328,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1193
1328
  const entry = pending.pop();
1194
1329
  if (!entry)
1195
1330
  continue;
1196
- const fullPath = join7(entry.parentPath, entry.name);
1331
+ const fullPath = join8(entry.parentPath, entry.name);
1197
1332
  if (entry.isDirectory()) {
1198
1333
  if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
1199
1334
  continue;
@@ -1216,11 +1351,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1216
1351
  if (copied.has(assetTarget))
1217
1352
  return;
1218
1353
  copied.add(assetTarget);
1219
- mkdirSync5(dirname3(assetTarget), { recursive: true });
1354
+ mkdirSync6(dirname3(assetTarget), { recursive: true });
1220
1355
  cpSync(assetSource, assetTarget, { force: true });
1221
1356
  };
1222
1357
  for (const filePath of collectProjectSourceFiles(process.cwd())) {
1223
- const source = readFileSync10(filePath, "utf-8");
1358
+ const source = readFileSync11(filePath, "utf-8");
1224
1359
  SERVER_RUNTIME_ASSET_RE.lastIndex = 0;
1225
1360
  let match;
1226
1361
  while ((match = SERVER_RUNTIME_ASSET_RE.exec(source)) !== null) {
@@ -1249,7 +1384,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1249
1384
  }
1250
1385
  }, readPackageVersion4 = (candidate) => {
1251
1386
  try {
1252
- const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
1387
+ const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
1253
1388
  if (pkg.name !== "@absolutejs/absolute")
1254
1389
  return null;
1255
1390
  const ver = pkg.version;
@@ -1308,7 +1443,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1308
1443
  return true;
1309
1444
  }, tryReadNodePackageJson = (packageDir) => {
1310
1445
  try {
1311
- return JSON.parse(readFileSync10(join7(packageDir, "package.json"), "utf-8"));
1446
+ return JSON.parse(readFileSync11(join8(packageDir, "package.json"), "utf-8"));
1312
1447
  } catch {
1313
1448
  return null;
1314
1449
  }
@@ -1320,7 +1455,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1320
1455
  if (!pkg)
1321
1456
  return;
1322
1457
  seen.add(specifier);
1323
- const destDir = join7(outdir, "node_modules", ...specifier.split("/"));
1458
+ const destDir = join8(outdir, "node_modules", ...specifier.split("/"));
1324
1459
  rmSync3(destDir, { force: true, recursive: true });
1325
1460
  cpSync(srcDir, destDir, {
1326
1461
  filter(source) {
@@ -1366,7 +1501,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1366
1501
  }
1367
1502
  copyAngularRuntimePackages(buildConfig, outdir);
1368
1503
  }, collectRuntimePackageSpecifiers = (distDir) => {
1369
- const nodeModulesDir = join7(distDir, "node_modules");
1504
+ const nodeModulesDir = join8(distDir, "node_modules");
1370
1505
  if (!existsSync10(nodeModulesDir))
1371
1506
  return [];
1372
1507
  const specifiers = [];
@@ -1374,7 +1509,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1374
1509
  if (!entry.isDirectory())
1375
1510
  continue;
1376
1511
  if (entry.name.startsWith("@")) {
1377
- const scopeDir = join7(nodeModulesDir, entry.name);
1512
+ const scopeDir = join8(nodeModulesDir, entry.name);
1378
1513
  for (const scopedEntry of readdirSync2(scopeDir, {
1379
1514
  withFileTypes: true
1380
1515
  })) {
@@ -1406,18 +1541,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1406
1541
  const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
1407
1542
  if (!packageSpecifier)
1408
1543
  return null;
1409
- const packageDir = join7(distDir, "node_modules", ...packageSpecifier.split("/"));
1544
+ const packageDir = join8(distDir, "node_modules", ...packageSpecifier.split("/"));
1410
1545
  const subpath = specifier.slice(packageSpecifier.length);
1411
- const subPackageDir = subpath ? join7(packageDir, ...subpath.slice(1).split("/")) : null;
1412
- const resolvedPackageDir = subPackageDir && existsSync10(join7(subPackageDir, "package.json")) ? subPackageDir : packageDir;
1413
- const packageJsonPath = join7(resolvedPackageDir, "package.json");
1546
+ const subPackageDir = subpath ? join8(packageDir, ...subpath.slice(1).split("/")) : null;
1547
+ const resolvedPackageDir = subPackageDir && existsSync10(join8(subPackageDir, "package.json")) ? subPackageDir : packageDir;
1548
+ const packageJsonPath = join8(resolvedPackageDir, "package.json");
1414
1549
  if (!existsSync10(packageJsonPath))
1415
1550
  return null;
1416
- const pkg = JSON.parse(readFileSync10(packageJsonPath, "utf-8"));
1551
+ const pkg = JSON.parse(readFileSync11(packageJsonPath, "utf-8"));
1417
1552
  const exportKey = resolvedPackageDir === subPackageDir ? "." : subpath ? `.${subpath}` : ".";
1418
1553
  const rootExport = pkg.exports?.[exportKey];
1419
1554
  const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
1420
- return join7(resolvedPackageDir, entry);
1555
+ return join8(resolvedPackageDir, entry);
1421
1556
  }, RUNTIME_JS_EXTENSIONS, MODULE_SPECIFIER_RE, isRuntimeJsFile = (filePath) => RUNTIME_JS_EXTENSIONS.some((extension) => filePath.endsWith(extension)), isNodeModulesPath = (filePath) => filePath.split(/[\\/]/).includes("node_modules"), isFile = (filePath) => {
1422
1557
  try {
1423
1558
  return statSync(filePath).isFile();
@@ -1430,13 +1565,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1430
1565
  const candidates = [
1431
1566
  candidate,
1432
1567
  ...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
1433
- ...RUNTIME_JS_EXTENSIONS.map((extension) => join7(candidate, `index${extension}`))
1568
+ ...RUNTIME_JS_EXTENSIONS.map((extension) => join8(candidate, `index${extension}`))
1434
1569
  ];
1435
1570
  return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
1436
1571
  }, findContainingRuntimePackageDir = (filePath) => {
1437
1572
  let dir = dirname3(filePath);
1438
1573
  while (dir !== dirname3(dir)) {
1439
- if (isNodeModulesPath(dir) && existsSync10(join7(dir, "package.json"))) {
1574
+ if (isNodeModulesPath(dir) && existsSync10(join8(dir, "package.json"))) {
1440
1575
  return dir;
1441
1576
  }
1442
1577
  dir = dirname3(dir);
@@ -1452,7 +1587,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1452
1587
  const entry = pickExportEntry(pkg?.imports?.[specifier]);
1453
1588
  if (!entry)
1454
1589
  return null;
1455
- return join7(packageDir, entry);
1590
+ return join8(packageDir, entry);
1456
1591
  }, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), rewriteRuntimeModuleSpecifiers = (distDir) => {
1457
1592
  const packageSpecifiers = collectRuntimePackageSpecifiers(distDir);
1458
1593
  if (packageSpecifiers.length === 0)
@@ -1471,7 +1606,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1471
1606
  if (!filePath || seen.has(filePath))
1472
1607
  continue;
1473
1608
  seen.add(filePath);
1474
- const source = readFileSync10(filePath, "utf-8");
1609
+ const source = readFileSync11(filePath, "utf-8");
1475
1610
  const rewritten = source.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
1476
1611
  if (typeof specifier === "string" && specifier.startsWith(".")) {
1477
1612
  enqueue(resolveRuntimeJsFile(resolve10(dirname3(filePath), specifier)));
@@ -1489,7 +1624,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1489
1624
  return `${prefix}${quote}${ensureRelativeModuleSpecifier(filePath, target)}${quote}`;
1490
1625
  });
1491
1626
  if (rewritten !== source) {
1492
- writeFileSync3(filePath, rewritten);
1627
+ writeFileSync4(filePath, rewritten);
1493
1628
  }
1494
1629
  }
1495
1630
  }, generateEntrypoint = (distDir, serverEntry, prerenderMap, version2, buildConfig) => {
@@ -1937,7 +2072,7 @@ console.log(\`
1937
2072
  copyServerRuntimeAssetReferences(resolvedOutdir);
1938
2073
  const prerenderStart = performance.now();
1939
2074
  process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
1940
- rmSync3(join7(resolvedOutdir, "_prerendered"), {
2075
+ rmSync3(join8(resolvedOutdir, "_prerendered"), {
1941
2076
  force: true,
1942
2077
  recursive: true
1943
2078
  });
@@ -1956,9 +2091,9 @@ console.log(\`
1956
2091
  const compileStart = performance.now();
1957
2092
  process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
1958
2093
  const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
1959
- const entrypointPath = join7(resolvedOutdir, "_compile_entrypoint.ts");
2094
+ const entrypointPath = join8(resolvedOutdir, "_compile_entrypoint.ts");
1960
2095
  await Bun.write(entrypointPath, entrypointCode);
1961
- mkdirSync5(dirname3(resolvedOutfile), { recursive: true });
2096
+ mkdirSync6(dirname3(resolvedOutfile), { recursive: true });
1962
2097
  const result = await Bun.build({
1963
2098
  compile: { outfile: resolvedOutfile },
1964
2099
  define: { "process.env.NODE_ENV": '"production"' },
@@ -1980,7 +2115,7 @@ console.log(\`
1980
2115
  }
1981
2116
  console.log(` \x1B[2m(${getDurationString(performance.now() - compileStart)})\x1B[0m`);
1982
2117
  try {
1983
- unlinkSync2(entrypointPath);
2118
+ unlinkSync3(entrypointPath);
1984
2119
  } catch {}
1985
2120
  const BYTES_PER_MB = 1048576;
1986
2121
  const size = (Bun.file(resolvedOutfile).size / BYTES_PER_MB).toFixed(0);
@@ -2049,9 +2184,9 @@ var exports_typecheck = {};
2049
2184
  __export(exports_typecheck, {
2050
2185
  typecheck: () => typecheck
2051
2186
  });
2052
- import { resolve as resolve11, join as join8 } from "path";
2053
- import { existsSync as existsSync11, readFileSync as readFileSync11 } from "fs";
2054
- import { mkdir as mkdir3, writeFile as writeFile2 } from "fs/promises";
2187
+ import { resolve as resolve11, join as join9 } from "path";
2188
+ import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";
2189
+ import { mkdir as mkdir2, writeFile } from "fs/promises";
2055
2190
  var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), getTypecheckTargets = async (configPath2) => {
2056
2191
  const rawConfig = await loadRawConfig(configPath2);
2057
2192
  if (!isWorkspaceConfig(rawConfig)) {
@@ -2126,7 +2261,7 @@ Found ${errorCount} error${suffix}.`;
2126
2261
  return candidates.find((candidate) => existsSync11(candidate)) ?? candidates[0];
2127
2262
  }, ABSOLUTE_TYPECHECK_FILES, readProjectTsconfig = () => {
2128
2263
  try {
2129
- return JSON.parse(readFileSync11(resolve11("tsconfig.json"), "utf-8"));
2264
+ return JSON.parse(readFileSync12(resolve11("tsconfig.json"), "utf-8"));
2130
2265
  } catch {
2131
2266
  return {};
2132
2267
  }
@@ -2154,8 +2289,8 @@ Found ${errorCount} error${suffix}.`;
2154
2289
  console.error("\x1B[31m\u2717\x1B[0m vue-tsc is required for Vue type checking. Install it: bun add -d vue-tsc");
2155
2290
  process.exit(1);
2156
2291
  }
2157
- const vueTsconfigPath = join8(cacheDir, "tsconfig.vue-check.json");
2158
- return writeFile2(vueTsconfigPath, JSON.stringify({
2292
+ const vueTsconfigPath = join9(cacheDir, "tsconfig.vue-check.json");
2293
+ return writeFile(vueTsconfigPath, JSON.stringify({
2159
2294
  compilerOptions: {
2160
2295
  rootDir: ".."
2161
2296
  },
@@ -2169,7 +2304,7 @@ Found ${errorCount} error${suffix}.`;
2169
2304
  resolve11(vueTsconfigPath),
2170
2305
  "--incremental",
2171
2306
  "--tsBuildInfoFile",
2172
- join8(cacheDir, "vue-tsc.tsbuildinfo"),
2307
+ join9(cacheDir, "vue-tsc.tsbuildinfo"),
2173
2308
  "--pretty"
2174
2309
  ]));
2175
2310
  }, buildAngularCheck = async (cacheDir, angularDir) => {
@@ -2178,8 +2313,8 @@ Found ${errorCount} error${suffix}.`;
2178
2313
  console.error("\x1B[31m\u2717\x1B[0m @angular/compiler-cli is required for Angular type checking. Install it: bun add -d @angular/compiler-cli");
2179
2314
  process.exit(1);
2180
2315
  }
2181
- const angularTsconfigPath = join8(cacheDir, "tsconfig.angular-check.json");
2182
- await writeFile2(angularTsconfigPath, JSON.stringify({
2316
+ const angularTsconfigPath = join9(cacheDir, "tsconfig.angular-check.json");
2317
+ await writeFile(angularTsconfigPath, JSON.stringify({
2183
2318
  angularCompilerOptions: {
2184
2319
  strictTemplates: true
2185
2320
  },
@@ -2198,8 +2333,8 @@ Found ${errorCount} error${suffix}.`;
2198
2333
  console.error("\x1B[31m\u2717\x1B[0m typescript is required for type checking. Install it: bun add -d typescript");
2199
2334
  process.exit(1);
2200
2335
  }
2201
- const tscConfigPath = join8(cacheDir, "tsconfig.typecheck.json");
2202
- return writeFile2(tscConfigPath, JSON.stringify({
2336
+ const tscConfigPath = join9(cacheDir, "tsconfig.typecheck.json");
2337
+ return writeFile(tscConfigPath, JSON.stringify({
2203
2338
  compilerOptions: {
2204
2339
  rootDir: ".."
2205
2340
  },
@@ -2213,7 +2348,7 @@ Found ${errorCount} error${suffix}.`;
2213
2348
  resolve11(tscConfigPath),
2214
2349
  "--incremental",
2215
2350
  "--tsBuildInfoFile",
2216
- join8(cacheDir, "tsc.tsbuildinfo"),
2351
+ join9(cacheDir, "tsc.tsbuildinfo"),
2217
2352
  "--pretty"
2218
2353
  ]));
2219
2354
  }, buildSvelteCheck = async (cacheDir, svelteDir) => {
@@ -2222,8 +2357,8 @@ Found ${errorCount} error${suffix}.`;
2222
2357
  console.error("\x1B[31m\u2717\x1B[0m svelte-check is required for Svelte type checking. Install it: bun add -d svelte-check");
2223
2358
  process.exit(1);
2224
2359
  }
2225
- const svelteTsconfigPath = join8(cacheDir, "tsconfig.svelte-check.json");
2226
- await writeFile2(svelteTsconfigPath, JSON.stringify({
2360
+ const svelteTsconfigPath = join9(cacheDir, "tsconfig.svelte-check.json");
2361
+ await writeFile(svelteTsconfigPath, JSON.stringify({
2227
2362
  extends: resolve11("tsconfig.json"),
2228
2363
  files: ABSOLUTE_TYPECHECK_FILES,
2229
2364
  include: [`../${svelteDir}/**/*`]
@@ -2252,7 +2387,7 @@ Found ${errorCount} error${suffix}.`;
2252
2387
  ...new Set(targets.map((config) => config.angularDirectory).filter((dir) => typeof dir === "string" && dir.length > 0))
2253
2388
  ];
2254
2389
  const cacheDir = ".absolutejs";
2255
- await mkdir3(cacheDir, { recursive: true });
2390
+ await mkdir2(cacheDir, { recursive: true });
2256
2391
  const checks = [];
2257
2392
  checks.push(hasVue ? buildVueTscCheck(cacheDir) : buildTscCheck(cacheDir));
2258
2393
  for (const svelteDir of hasSvelte ? svelteDirs : []) {
@@ -2298,6 +2433,7 @@ var init_typecheck = __esm(() => {
2298
2433
  init_constants();
2299
2434
  init_startupBanner();
2300
2435
  var {$: $2, env } = globalThis.Bun;
2436
+ import { spawn as nodeSpawn } from "child_process";
2301
2437
  import { existsSync as existsSync5 } from "fs";
2302
2438
  import { resolve as resolve3 } from "path";
2303
2439
 
@@ -2570,9 +2706,49 @@ var createInteractiveHandler = (actions) => {
2570
2706
 
2571
2707
  // src/cli/scripts/dev.ts
2572
2708
  init_telemetryEvent();
2709
+ init_buildDirectoryLock();
2573
2710
  init_loadConfig();
2711
+
2712
+ // src/utils/resolveDevPort.ts
2713
+ import { createServer } from "net";
2714
+ var isPortFree = (port, host = "localhost") => new Promise((resolvePort) => {
2715
+ const server = createServer();
2716
+ server.unref();
2717
+ server.once("error", (err) => {
2718
+ if (err.code === "EADDRINUSE") {
2719
+ resolvePort(false);
2720
+ return;
2721
+ }
2722
+ resolvePort(false);
2723
+ });
2724
+ server.listen(port, host, () => {
2725
+ server.close(() => resolvePort(true));
2726
+ });
2727
+ });
2728
+ var resolveDevPort = async (requestedPort, options = {}) => {
2729
+ const strictPort = options.strictPort === true;
2730
+ const portRange = options.portRange ?? 10;
2731
+ const host = options.host ?? "localhost";
2732
+ const tried = [];
2733
+ for (let offset = 0;offset < portRange; offset += 1) {
2734
+ const candidate = requestedPort + offset;
2735
+ tried.push(candidate);
2736
+ const free = await isPortFree(candidate, host);
2737
+ if (free) {
2738
+ return { fellBack: candidate !== requestedPort, port: candidate };
2739
+ }
2740
+ if (offset === 0 && strictPort) {
2741
+ throw new Error(`Port ${requestedPort} is in use, try another port or set strictPort: false in your absolute.config.ts`);
2742
+ }
2743
+ }
2744
+ throw new Error(`Could not find a free port in the range ${tried[0]}-${tried[tried.length - 1]}. Tried: ${tried.join(", ")}.
2745
+ ` + `Set \`dev.port\` to a different value in absolute.config.ts (or via the ABSOLUTE_PORT env var), or extend \`dev.portRange\`.`);
2746
+ };
2747
+
2748
+ // src/cli/scripts/dev.ts
2574
2749
  init_utils();
2575
2750
  var cliTag = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
2751
+ var DEFAULT_PORT_RANGE = 10;
2576
2752
  var confirmPrompt = (message, defaultYes = true) => {
2577
2753
  const { promise, resolve: resolvePrompt } = Promise.withResolvers();
2578
2754
  let selected = defaultYes;
@@ -2630,16 +2806,52 @@ var setupHttpsCert = async () => {
2630
2806
  }
2631
2807
  await setupCertWithPrompt(ensureDevCert2, setupMkcert2);
2632
2808
  };
2809
+ var resolveDevConfig = (configDev) => ({
2810
+ port: Number(env.ABSOLUTE_PORT) || Number(env.PORT) || configDev?.port || DEFAULT_PORT,
2811
+ portRange: Number(env.ABSOLUTE_PORT_RANGE) || configDev?.portRange || DEFAULT_PORT_RANGE,
2812
+ strictPort: env.ABSOLUTE_STRICT_PORT === "true" || configDev?.strictPort === true,
2813
+ host: env.ABSOLUTE_HOST ?? configDev?.host ?? "localhost",
2814
+ https: env.ABSOLUTE_HTTPS === "true" || configDev?.https === true
2815
+ });
2633
2816
  var dev = async (serverEntry, configPath2) => {
2634
- const port = Number(env.PORT) || DEFAULT_PORT;
2635
- killStaleProcesses(port);
2636
2817
  let httpsEnabled = false;
2818
+ let resolvedDev;
2819
+ let buildDirectory = resolve3(process.cwd(), "build");
2637
2820
  try {
2638
2821
  const config = await loadConfig(configPath2);
2639
- httpsEnabled = config?.dev?.https === true;
2822
+ resolvedDev = resolveDevConfig(config?.dev);
2823
+ httpsEnabled = resolvedDev.https;
2824
+ if (config?.buildDirectory) {
2825
+ buildDirectory = resolve3(process.cwd(), config.buildDirectory);
2826
+ }
2640
2827
  if (httpsEnabled)
2641
2828
  await setupHttpsCert();
2642
- } catch {}
2829
+ } catch {
2830
+ resolvedDev = resolveDevConfig(undefined);
2831
+ httpsEnabled = resolvedDev.https;
2832
+ }
2833
+ try {
2834
+ await acquireBuildDirectoryLock(buildDirectory, {
2835
+ port: null,
2836
+ wait: false
2837
+ });
2838
+ } catch (err) {
2839
+ console.error(cliTag("\x1B[31m", err instanceof Error ? err.message : String(err)));
2840
+ process.exit(1);
2841
+ }
2842
+ const { port, fellBack } = await resolveDevPort(resolvedDev.port, {
2843
+ host: resolvedDev.host,
2844
+ portRange: resolvedDev.portRange,
2845
+ strictPort: resolvedDev.strictPort
2846
+ }).catch((err) => {
2847
+ console.error(cliTag("\x1B[31m", String(err.message ?? err)));
2848
+ process.exit(1);
2849
+ });
2850
+ if (fellBack) {
2851
+ const displayHost = resolvedDev.host === "0.0.0.0" ? "localhost" : resolvedDev.host;
2852
+ console.log(cliTag("\x1B[33m", `Port ${resolvedDev.port} is in use, trying another one... \u2192 http://${displayHost}:${port}/`));
2853
+ }
2854
+ updateLockMetadata(buildDirectory, { port });
2643
2855
  const usesDocker = existsSync5(resolve3(COMPOSE_PATH));
2644
2856
  const scripts = usesDocker ? await readDbScripts() : null;
2645
2857
  if (scripts)
@@ -2649,7 +2861,7 @@ var dev = async (serverEntry, configPath2) => {
2649
2861
  let interactive = null;
2650
2862
  let serverReady = false;
2651
2863
  const checkServerReady = (value) => {
2652
- const chunk = Buffer.from(value).toString();
2864
+ const chunk = value.toString();
2653
2865
  if (!chunk.includes("Local:"))
2654
2866
  return;
2655
2867
  serverReady = true;
@@ -2663,34 +2875,29 @@ var dev = async (serverEntry, configPath2) => {
2663
2875
  interactive?.showPrompt();
2664
2876
  };
2665
2877
  const spawnServer = () => {
2666
- const proc = Bun.spawn(["bun", "--hot", "--no-clear-screen", serverEntry], {
2878
+ const proc = nodeSpawn("bun", ["--hot", "--no-clear-screen", serverEntry], {
2667
2879
  cwd: process.cwd(),
2880
+ detached: true,
2668
2881
  env: {
2669
2882
  ...process.env,
2670
2883
  FORCE_COLOR: "1",
2671
2884
  NODE_ENV: "development",
2885
+ ABSOLUTE_PORT: String(port),
2886
+ PORT: String(port),
2672
2887
  ...configPath2 ? { ABSOLUTE_CONFIG: configPath2 } : {},
2673
2888
  ...httpsEnabled ? { ABSOLUTE_HTTPS: "true" } : {}
2674
2889
  },
2675
- stderr: "pipe",
2676
- stdin: "ignore",
2677
- stdout: "pipe"
2890
+ stdio: ["ignore", "pipe", "pipe"]
2678
2891
  });
2679
- const forward = (stream, dest) => {
2680
- const reader = stream.getReader();
2681
- const pump = () => {
2682
- reader.read().then(({ done, value }) => {
2683
- if (done)
2684
- return;
2685
- if (serverReady)
2686
- interactive?.clearPrompt();
2687
- dest.write(value);
2688
- handleChunk(value);
2689
- pump();
2690
- return;
2691
- }).catch(() => {});
2692
- };
2693
- pump();
2892
+ const forward = (source, dest) => {
2893
+ if (!source)
2894
+ return;
2895
+ source.on("data", (chunk) => {
2896
+ if (serverReady)
2897
+ interactive?.clearPrompt();
2898
+ dest.write(chunk);
2899
+ handleChunk(chunk);
2900
+ });
2694
2901
  };
2695
2902
  forward(proc.stdout, process.stdout);
2696
2903
  forward(proc.stderr, process.stderr);
@@ -2711,6 +2918,18 @@ var dev = async (serverEntry, configPath2) => {
2711
2918
  ].filter((val) => Boolean(val));
2712
2919
  } catch {}
2713
2920
  sendTelemetryEvent("dev:start", { entry: serverEntry, frameworks });
2921
+ const killChildTree = (signal) => {
2922
+ const childPid = serverProcess.pid;
2923
+ if (typeof childPid !== "number")
2924
+ return;
2925
+ try {
2926
+ process.kill(-childPid, signal);
2927
+ return;
2928
+ } catch {}
2929
+ try {
2930
+ process.kill(childPid, signal);
2931
+ } catch {}
2932
+ };
2714
2933
  const cleanup = async (exitCode = 0) => {
2715
2934
  if (cleaning)
2716
2935
  return;
@@ -2723,10 +2942,17 @@ var dev = async (serverEntry, configPath2) => {
2723
2942
  interactive.dispose();
2724
2943
  if (paused)
2725
2944
  sendSignal("SIGCONT");
2726
- try {
2727
- serverProcess.kill();
2728
- } catch {}
2729
- await serverProcess.exited;
2945
+ killChildTree("SIGTERM");
2946
+ await new Promise((res) => {
2947
+ if (serverProcess.exitCode !== null) {
2948
+ res();
2949
+ return;
2950
+ }
2951
+ serverProcess.once("exit", () => res());
2952
+ setTimeout(() => {
2953
+ killChildTree("SIGKILL");
2954
+ }, 2000).unref();
2955
+ });
2730
2956
  if (scripts)
2731
2957
  await stopDatabase(scripts);
2732
2958
  process.exit(exitCode);
@@ -2741,15 +2967,24 @@ var dev = async (serverEntry, configPath2) => {
2741
2967
  paused = false;
2742
2968
  }
2743
2969
  try {
2744
- old.kill();
2970
+ old.kill("SIGTERM");
2745
2971
  } catch {}
2746
2972
  serverProcess = spawnServer();
2747
- await old.exited;
2973
+ await new Promise((res) => {
2974
+ if (old.exitCode !== null) {
2975
+ res();
2976
+ return;
2977
+ }
2978
+ old.once("exit", () => res());
2979
+ });
2748
2980
  console.log(cliTag("\x1B[32m", "Server restarted."));
2749
2981
  };
2750
2982
  const sendSignalToGroup = (signal) => {
2983
+ const childPid = serverProcess.pid;
2984
+ if (typeof childPid !== "number")
2985
+ return false;
2751
2986
  try {
2752
- process.kill(-serverProcess.pid, signal);
2987
+ process.kill(-childPid, signal);
2753
2988
  return true;
2754
2989
  } catch {
2755
2990
  return false;
@@ -2758,8 +2993,11 @@ var dev = async (serverEntry, configPath2) => {
2758
2993
  const sendSignal = (signal) => {
2759
2994
  if (sendSignalToGroup(signal))
2760
2995
  return;
2996
+ const childPid = serverProcess.pid;
2997
+ if (typeof childPid !== "number")
2998
+ return;
2761
2999
  try {
2762
- process.kill(serverProcess.pid, signal);
3000
+ process.kill(childPid, signal);
2763
3001
  } catch {}
2764
3002
  };
2765
3003
  const togglePause = () => {
@@ -2777,7 +3015,7 @@ var dev = async (serverEntry, configPath2) => {
2777
3015
  await $2`${{ raw: command }}`.env({ ...process.env, FORCE_COLOR: "1" }).nothrow();
2778
3016
  };
2779
3017
  const openInBrowser = async () => {
2780
- const url = `http://localhost:${port}`;
3018
+ const url = `http://${resolvedDev.host === "0.0.0.0" ? "localhost" : resolvedDev.host}:${port}`;
2781
3019
  const { platform: platform3 } = process;
2782
3020
  const isWSL = platform3 === "linux" && isWSLEnvironment();
2783
3021
  let cmd;
@@ -2820,6 +3058,23 @@ var dev = async (serverEntry, configPath2) => {
2820
3058
  });
2821
3059
  process.on("SIGINT", () => cleanup(0));
2822
3060
  process.on("SIGTERM", () => cleanup(0));
3061
+ process.on("exit", () => {
3062
+ const childPid = serverProcess.pid;
3063
+ if (typeof childPid !== "number")
3064
+ return;
3065
+ try {
3066
+ process.kill(-childPid, "SIGTERM");
3067
+ } catch {}
3068
+ });
3069
+ const initialPpid = process.ppid;
3070
+ const ppidWatcher = setInterval(() => {
3071
+ if (process.ppid !== initialPpid) {
3072
+ clearInterval(ppidWatcher);
3073
+ cleanup(0);
3074
+ }
3075
+ }, 1000);
3076
+ if (typeof ppidWatcher.unref === "function")
3077
+ ppidWatcher.unref();
2823
3078
  printHint();
2824
3079
  const handleServerExit = async (exitCode) => {
2825
3080
  if (exitCode === SIGINT_EXIT_CODE || exitCode === SIGTERM_EXIT_CODE) {
@@ -2829,7 +3084,7 @@ var dev = async (serverEntry, configPath2) => {
2829
3084
  console.error(cliTag("\x1B[31m", `Server exited (code ${exitCode}), restarting...`));
2830
3085
  sendTelemetryEvent("dev:server-crash", {
2831
3086
  entry: serverEntry,
2832
- exitCode
3087
+ exitCode: exitCode ?? -1
2833
3088
  });
2834
3089
  serverProcess = spawnServer();
2835
3090
  return true;
@@ -2839,7 +3094,13 @@ var dev = async (serverEntry, configPath2) => {
2839
3094
  return;
2840
3095
  }
2841
3096
  const current = serverProcess;
2842
- const exitCode = await current.exited;
3097
+ const exitCode = await new Promise((res) => {
3098
+ if (current.exitCode !== null) {
3099
+ res(current.exitCode);
3100
+ return;
3101
+ }
3102
+ current.once("exit", (code) => res(code));
3103
+ });
2843
3104
  if (cleaning || serverProcess !== current) {
2844
3105
  await monitorServer();
2845
3106
  return;
@@ -2854,7 +3115,7 @@ var dev = async (serverEntry, configPath2) => {
2854
3115
  };
2855
3116
 
2856
3117
  // src/cli/scripts/eslint.ts
2857
- import { existsSync as existsSync6, readFileSync as readFileSync5, rmSync as rmSync2 } from "fs";
3118
+ import { existsSync as existsSync6, readFileSync as readFileSync6, rmSync as rmSync2 } from "fs";
2858
3119
  import { resolve as resolve4 } from "path";
2859
3120
  var DEFAULT_CACHE_LOCATION = ".absolutejs/eslint-cache";
2860
3121
  var getCacheLocation = () => process.env.ABSOLUTE_ESLINT_CACHE?.trim() || DEFAULT_CACHE_LOCATION;
@@ -3011,7 +3272,7 @@ var checkForMisplacedIgnores = () => {
3011
3272
  return;
3012
3273
  let source;
3013
3274
  try {
3014
- source = readFileSync5(configPath2, "utf-8");
3275
+ source = readFileSync6(configPath2, "utf-8");
3015
3276
  } catch {
3016
3277
  return;
3017
3278
  }
@@ -3096,7 +3357,7 @@ var eslint = async (args) => {
3096
3357
  init_constants();
3097
3358
  init_utils();
3098
3359
  import { execSync as execSync2 } from "child_process";
3099
- import { existsSync as existsSync7, readFileSync as readFileSync6 } from "fs";
3360
+ import { existsSync as existsSync7, readFileSync as readFileSync7 } from "fs";
3100
3361
  import { arch as arch2, cpus, platform as platform3, totalmem, version } from "os";
3101
3362
  import { resolve as resolve5 } from "path";
3102
3363
  var bold = (str) => `\x1B[1m${str}\x1B[0m`;
@@ -3118,7 +3379,7 @@ var getPackageVersion = (packageName) => {
3118
3379
  const pkgPath = __require.resolve(`${packageName}/package.json`, {
3119
3380
  paths: [process.cwd()]
3120
3381
  });
3121
- const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
3382
+ const pkg = JSON.parse(readFileSync7(pkgPath, "utf-8"));
3122
3383
  const ver = pkg.version;
3123
3384
  return ver;
3124
3385
  } catch {
@@ -3140,7 +3401,7 @@ var getAbsoluteVersion = () => {
3140
3401
  return getPackageVersion("@absolutejs/absolute");
3141
3402
  };
3142
3403
  var readPackageVersion = (pkgPath) => {
3143
- const pkg = JSON.parse(readFileSync6(pkgPath, "utf-8"));
3404
+ const pkg = JSON.parse(readFileSync7(pkgPath, "utf-8"));
3144
3405
  const ver = pkg.version;
3145
3406
  return ver;
3146
3407
  };
@@ -3242,7 +3503,7 @@ var info = () => {
3242
3503
  // src/cli/cache.ts
3243
3504
  init_constants();
3244
3505
  import { mkdir } from "fs/promises";
3245
- import { join as join4 } from "path";
3506
+ import { join as join5 } from "path";
3246
3507
  var {Glob } = globalThis.Bun;
3247
3508
  var CACHE_DIR = ".absolutejs";
3248
3509
  var MAX_FILES_PER_BATCH = 200;
@@ -3294,7 +3555,7 @@ var hashFiles = async (paths) => {
3294
3555
  };
3295
3556
  var loadCache = async (tool) => {
3296
3557
  try {
3297
- const path = join4(CACHE_DIR, `${tool}.cache.json`);
3558
+ const path = join5(CACHE_DIR, `${tool}.cache.json`);
3298
3559
  const data = await Bun.file(path).json();
3299
3560
  const result = data;
3300
3561
  return result;
@@ -3341,7 +3602,7 @@ var runTool = async (adapter, args) => {
3341
3602
  };
3342
3603
  var saveCache = async (tool, data) => {
3343
3604
  await mkdir(CACHE_DIR, { recursive: true });
3344
- const path = join4(CACHE_DIR, `${tool}.cache.json`);
3605
+ const path = join5(CACHE_DIR, `${tool}.cache.json`);
3345
3606
  await Bun.write(path, JSON.stringify(data, null, "\t"));
3346
3607
  };
3347
3608
 
@@ -3383,7 +3644,7 @@ init_startupBanner();
3383
3644
  init_telemetryEvent();
3384
3645
  init_utils();
3385
3646
  var {env: env2 } = globalThis.Bun;
3386
- import { existsSync as existsSync8, readFileSync as readFileSync8 } from "fs";
3647
+ import { existsSync as existsSync8, readFileSync as readFileSync9 } from "fs";
3387
3648
  import { basename, resolve as resolve7 } from "path";
3388
3649
  var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`;
3389
3650
  var resolvePackageVersion = (candidates) => {
@@ -3397,7 +3658,7 @@ var resolvePackageVersion = (candidates) => {
3397
3658
  };
3398
3659
  var readPackageVersion2 = (candidate) => {
3399
3660
  try {
3400
- const pkg = JSON.parse(readFileSync8(candidate, "utf-8"));
3661
+ const pkg = JSON.parse(readFileSync9(candidate, "utf-8"));
3401
3662
  if (pkg.name !== "@absolutejs/absolute")
3402
3663
  return null;
3403
3664
  const ver = pkg.version;
@@ -3708,11 +3969,11 @@ init_getDurationString();
3708
3969
  import {
3709
3970
  appendFileSync,
3710
3971
  existsSync as existsSync9,
3711
- mkdirSync as mkdirSync4,
3972
+ mkdirSync as mkdirSync5,
3712
3973
  readdirSync,
3713
- readFileSync as readFileSync9,
3714
- unlinkSync,
3715
- writeFileSync as writeFileSync2
3974
+ readFileSync as readFileSync10,
3975
+ unlinkSync as unlinkSync2,
3976
+ writeFileSync as writeFileSync3
3716
3977
  } from "fs";
3717
3978
  import { createConnection } from "net";
3718
3979
  import { resolve as resolve8 } from "path";
@@ -4378,10 +4639,10 @@ var stripAnsi2 = (value) => value.replace(ANSI_REGEX2, "");
4378
4639
  var sanitizeLogFileName = (value) => value.replace(/[^a-zA-Z0-9._-]/g, "_") || "unknown";
4379
4640
  var createWorkspaceLogSink = (appendLog) => {
4380
4641
  const logDirectory = resolve8(".absolutejs", "workspace", "logs");
4381
- mkdirSync4(logDirectory, { recursive: true });
4382
- readdirSync(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync(resolve8(logDirectory, file)));
4383
- writeFileSync2(resolve8(logDirectory, "all.log"), "");
4384
- writeFileSync2(resolve8(logDirectory, "workspace.log"), "");
4642
+ mkdirSync5(logDirectory, { recursive: true });
4643
+ readdirSync(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync2(resolve8(logDirectory, file)));
4644
+ writeFileSync3(resolve8(logDirectory, "all.log"), "");
4645
+ writeFileSync3(resolve8(logDirectory, "workspace.log"), "");
4385
4646
  const initializedSources = new Set(["workspace"]);
4386
4647
  const writeLog = (source, message, level) => {
4387
4648
  const cleanMessage = stripAnsi2(message).trimEnd();
@@ -4393,7 +4654,7 @@ var createWorkspaceLogSink = (appendLog) => {
4393
4654
  `;
4394
4655
  const sourceFile = resolve8(logDirectory, `${sanitizeLogFileName(source)}.log`);
4395
4656
  if (!initializedSources.has(source)) {
4396
- writeFileSync2(sourceFile, "");
4657
+ writeFileSync3(sourceFile, "");
4397
4658
  initializedSources.add(source);
4398
4659
  }
4399
4660
  appendFileSync(sourceFile, line);
@@ -4409,7 +4670,7 @@ var createWorkspaceLogSink = (appendLog) => {
4409
4670
  };
4410
4671
  var readPackageVersion3 = (candidate) => {
4411
4672
  try {
4412
- const pkg = JSON.parse(readFileSync9(candidate, "utf-8"));
4673
+ const pkg = JSON.parse(readFileSync10(candidate, "utf-8"));
4413
4674
  if (pkg.name !== "@absolutejs/absolute") {
4414
4675
  return null;
4415
4676
  }