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

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 (35) 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 +29 -21
  4. package/dist/angular/index.js.map +10 -9
  5. package/dist/angular/server.js +29 -21
  6. package/dist/angular/server.js.map +10 -9
  7. package/dist/build.js +939 -496
  8. package/dist/build.js.map +15 -12
  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 +986 -543
  16. package/dist/index.js.map +16 -13
  17. package/dist/islands/index.js +16 -9
  18. package/dist/islands/index.js.map +6 -5
  19. package/dist/react/index.js +16 -9
  20. package/dist/react/index.js.map +6 -5
  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 +16 -9
  30. package/dist/svelte/index.js.map +6 -5
  31. package/dist/types/build.d.ts +15 -0
  32. package/dist/types/globals.d.ts +12 -0
  33. package/dist/vue/index.js +16 -9
  34. package/dist/vue/index.js.map +6 -5
  35. package/package.json +1 -1
package/dist/build.js CHANGED
@@ -1770,6 +1770,9 @@ var resolveAngularPackageDir = (specifier) => {
1770
1770
  };
1771
1771
  var init_resolveAngularPackage = () => {};
1772
1772
 
1773
+ // src/utils/runtimeMode.ts
1774
+ var ENV_VAR = "NODE_ENV", isProductionRuntime = () => process.env[ENV_VAR] === "production", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development";
1775
+
1773
1776
  // src/angular/angularPatch.ts
1774
1777
  var exports_angularPatch = {};
1775
1778
  __export(exports_angularPatch, {
@@ -1852,7 +1855,8 @@ var ensureHead = (doc) => {
1852
1855
  }
1853
1856
  layoutPatchApplied = true;
1854
1857
  }, applyPatches = async () => {
1855
- const { \u{275}DominoAdapter } = await import(resolveAngularRuntimePath("@angular/platform-server"));
1858
+ const spec = isProductionRuntime() ? resolveAngularRuntimePath("@angular/platform-server") : "@angular/platform-server";
1859
+ const { \u{275}DominoAdapter } = await import(spec);
1856
1860
  if (!\u{275}DominoAdapter?.prototype) {
1857
1861
  console.warn("[Angular Patch] \u0275DominoAdapter not found, skipping patches");
1858
1862
  return false;
@@ -1919,18 +1923,21 @@ var initDominoAdapter = (platformServer) => {
1919
1923
  console.error("Failed to initialize DominoAdapter:", err);
1920
1924
  }
1921
1925
  }, loadAngularDeps = async () => {
1922
- if (true) {
1923
- await import(resolveAngularRuntimePath("@angular/compiler"));
1926
+ if (!isProductionRuntime()) {
1927
+ await import("@angular/compiler");
1924
1928
  }
1925
1929
  const { applyPatches: applyPatches2 } = await Promise.resolve().then(() => (init_angularPatch(), exports_angularPatch));
1926
1930
  await applyPatches2();
1931
+ const useBareSpecifiers = !isProductionRuntime();
1927
1932
  const [platformBrowser, platformServer, common, core] = await Promise.all([
1928
- import(resolveAngularRuntimePath("@angular/platform-browser")),
1929
- import(resolveAngularRuntimePath("@angular/platform-server")),
1930
- import(resolveAngularRuntimePath("@angular/common")),
1931
- import(resolveAngularRuntimePath("@angular/core"))
1933
+ useBareSpecifiers ? import("@angular/platform-browser") : import(resolveAngularRuntimePath("@angular/platform-browser")),
1934
+ useBareSpecifiers ? import("@angular/platform-server") : import(resolveAngularRuntimePath("@angular/platform-server")),
1935
+ useBareSpecifiers ? import("@angular/common") : import(resolveAngularRuntimePath("@angular/common")),
1936
+ useBareSpecifiers ? import("@angular/core") : import(resolveAngularRuntimePath("@angular/core"))
1932
1937
  ]);
1933
- if (false) {}
1938
+ if (!isDevelopmentRuntime()) {
1939
+ core.enableProdMode();
1940
+ }
1934
1941
  initDominoAdapter(platformServer);
1935
1942
  return {
1936
1943
  APP_BASE_HREF: common.APP_BASE_HREF,
@@ -9571,9 +9578,34 @@ var commonAncestor = (paths, fallback) => {
9571
9578
  var init_commonAncestor = () => {};
9572
9579
 
9573
9580
  // src/utils/buildDirectoryLock.ts
9574
- import { mkdir as mkdir3, rm as rm4, stat as stat2, writeFile as writeFile4 } from "fs/promises";
9581
+ import { mkdirSync as mkdirSync6, unlinkSync, writeFileSync as writeFileSync6, readFileSync as readFileSync10 } from "fs";
9575
9582
  import { dirname as dirname8, join as join13 } from "path";
9576
- 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) => join13(dirname8(buildDirectory), `.${buildDirectory.split(/[\\/]/).pop()}.lock`), readHeldLockEnv = () => new Set((process.env[HELD_LOCKS_ENV] ?? "").split(`
9583
+ var heldLocks, HELD_LOCKS_ENV = "ABSOLUTE_HELD_BUILD_DIRECTORY_LOCKS", exitHandlersRegistered = false, registerExitHandlersOnce = () => {
9584
+ if (exitHandlersRegistered)
9585
+ return;
9586
+ exitHandlersRegistered = true;
9587
+ const releaseAllSync = () => {
9588
+ for (const lock of heldLocks.values()) {
9589
+ try {
9590
+ lock.releaseSync();
9591
+ } catch {}
9592
+ }
9593
+ heldLocks.clear();
9594
+ };
9595
+ process.on("exit", releaseAllSync);
9596
+ process.on("SIGINT", () => {
9597
+ releaseAllSync();
9598
+ process.exit(130);
9599
+ });
9600
+ process.on("SIGTERM", () => {
9601
+ releaseAllSync();
9602
+ process.exit(143);
9603
+ });
9604
+ process.on("uncaughtException", (err) => {
9605
+ releaseAllSync();
9606
+ throw err;
9607
+ });
9608
+ }, isAlreadyExistsError = (error) => error instanceof Error && ("code" in error) && error.code === "EEXIST", lockPathForBuildDirectory = (buildDirectory) => join13(dirname8(buildDirectory), ".absolutejs", "build.lock"), readHeldLockEnv = () => new Set((process.env[HELD_LOCKS_ENV] ?? "").split(`
9577
9609
  `).filter((entry) => entry.length > 0)), writeHeldLockEnv = (locks) => {
9578
9610
  if (locks.size === 0) {
9579
9611
  delete process.env[HELD_LOCKS_ENV];
@@ -9589,7 +9621,41 @@ var DEFAULT_LOCK_TIMEOUT_MS = 120000, DEFAULT_STALE_LOCK_MS, LOCK_POLL_MS = 250,
9589
9621
  const locks = readHeldLockEnv();
9590
9622
  locks.delete(buildDirectory);
9591
9623
  writeHeldLockEnv(locks);
9592
- }, acquireBuildDirectoryLock = async (buildDirectory, options = {}) => {
9624
+ }, writeLockFileSync = (lockPath, metadata) => {
9625
+ mkdirSync6(dirname8(lockPath), { recursive: true });
9626
+ writeFileSync6(lockPath, JSON.stringify(metadata, null, 2), { flag: "wx" });
9627
+ }, readLockMetadata = (lockPath) => {
9628
+ try {
9629
+ const raw = readFileSync10(lockPath, "utf-8");
9630
+ const parsed = JSON.parse(raw);
9631
+ if (typeof parsed === "object" && parsed !== null && typeof parsed.pid === "number") {
9632
+ return {
9633
+ pid: parsed.pid,
9634
+ port: typeof parsed.port === "number" ? parsed.port : null,
9635
+ startedAt: typeof parsed.startedAt === "string" ? parsed.startedAt : new Date().toISOString()
9636
+ };
9637
+ }
9638
+ } catch {}
9639
+ return null;
9640
+ }, isProcessAlive = (pid) => {
9641
+ try {
9642
+ process.kill(pid, 0);
9643
+ return true;
9644
+ } catch (err) {
9645
+ const code = err.code;
9646
+ if (code === "ESRCH")
9647
+ return false;
9648
+ if (code === "EPERM")
9649
+ return true;
9650
+ return true;
9651
+ }
9652
+ }, removeStaleLockSync = (lockPath, pid) => {
9653
+ try {
9654
+ unlinkSync(lockPath);
9655
+ console.warn(`[absolutejs] removed stale lock from PID ${pid}`);
9656
+ } catch {}
9657
+ }, LOCK_POLL_MS = 250, DEFAULT_WAIT_TIMEOUT_MS = 120000, acquireBuildDirectoryLock = async (buildDirectory, options = {}) => {
9658
+ registerExitHandlersOnce();
9593
9659
  if (readHeldLockEnv().has(buildDirectory)) {
9594
9660
  return async () => {};
9595
9661
  }
@@ -9605,52 +9671,66 @@ var DEFAULT_LOCK_TIMEOUT_MS = 120000, DEFAULT_STALE_LOCK_MS, LOCK_POLL_MS = 250,
9605
9671
  };
9606
9672
  }
9607
9673
  const lockPath = lockPathForBuildDirectory(buildDirectory);
9608
- const staleLockMs = options.staleLockMs ?? DEFAULT_STALE_LOCK_MS;
9609
- const timeoutMs = options.timeoutMs ?? DEFAULT_LOCK_TIMEOUT_MS;
9674
+ const wait = options.wait !== false;
9675
+ const waitTimeoutMs = options.waitTimeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
9610
9676
  const start = Date.now();
9677
+ const tryCreate = () => {
9678
+ writeLockFileSync(lockPath, {
9679
+ pid: process.pid,
9680
+ port: options.port ?? null,
9681
+ startedAt: new Date().toISOString()
9682
+ });
9683
+ };
9611
9684
  while (true) {
9612
9685
  try {
9613
- await mkdir3(dirname8(lockPath), { recursive: true });
9614
- await mkdir3(lockPath);
9615
- await writeFile4(join13(lockPath, "owner"), JSON.stringify({
9616
- buildDirectory,
9617
- createdAt: new Date().toISOString(),
9618
- pid: process.pid
9619
- }, null, 2));
9620
- const release = async () => {
9621
- await rm4(lockPath, { force: true, recursive: true }).catch(() => {});
9622
- };
9623
- heldLocks.set(buildDirectory, { count: 1, release });
9624
- markHeldLock(buildDirectory);
9625
- return async () => {
9626
- const current = heldLocks.get(buildDirectory);
9627
- if (!current)
9628
- return;
9629
- current.count -= 1;
9630
- if (current.count > 0)
9631
- return;
9632
- heldLocks.delete(buildDirectory);
9633
- unmarkHeldLock(buildDirectory);
9634
- await current.release();
9635
- };
9686
+ tryCreate();
9687
+ break;
9636
9688
  } catch (error) {
9637
9689
  if (!isAlreadyExistsError(error))
9638
9690
  throw error;
9639
- try {
9640
- const lockStat = await stat2(lockPath);
9641
- if (Date.now() - lockStat.mtimeMs > staleLockMs) {
9642
- await rm4(lockPath, { force: true, recursive: true });
9643
- continue;
9644
- }
9645
- } catch {}
9646
- if (Date.now() - start > timeoutMs) {
9647
- throw new Error(`Timed out waiting for AbsoluteJS build directory lock: ${buildDirectory}`);
9691
+ const existing = readLockMetadata(lockPath);
9692
+ if (!existing) {
9693
+ try {
9694
+ unlinkSync(lockPath);
9695
+ } catch {}
9696
+ continue;
9648
9697
  }
9649
- await Bun.sleep(LOCK_POLL_MS);
9698
+ if (!isProcessAlive(existing.pid)) {
9699
+ removeStaleLockSync(lockPath, existing.pid);
9700
+ continue;
9701
+ }
9702
+ if (wait && Date.now() - start < waitTimeoutMs) {
9703
+ await Bun.sleep(LOCK_POLL_MS);
9704
+ continue;
9705
+ }
9706
+ const portInfo = existing.port ? ` on port ${existing.port}` : "";
9707
+ const elapsedNote = wait ? ` Waited ${Math.round((Date.now() - start) / 1000)}s.` : "";
9708
+ 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.`);
9650
9709
  }
9651
9710
  }
9652
- }, withBuildDirectoryLock = async (buildDirectory, action) => {
9653
- const release = await acquireBuildDirectoryLock(buildDirectory);
9711
+ const releaseSync = () => {
9712
+ try {
9713
+ unlinkSync(lockPath);
9714
+ } catch {}
9715
+ };
9716
+ const release = async () => {
9717
+ releaseSync();
9718
+ };
9719
+ heldLocks.set(buildDirectory, { count: 1, release, releaseSync });
9720
+ markHeldLock(buildDirectory);
9721
+ return async () => {
9722
+ const current = heldLocks.get(buildDirectory);
9723
+ if (!current)
9724
+ return;
9725
+ current.count -= 1;
9726
+ if (current.count > 0)
9727
+ return;
9728
+ heldLocks.delete(buildDirectory);
9729
+ unmarkHeldLock(buildDirectory);
9730
+ await current.release();
9731
+ };
9732
+ }, withBuildDirectoryLock = async (buildDirectory, action, options = {}) => {
9733
+ const release = await acquireBuildDirectoryLock(buildDirectory, options);
9654
9734
  try {
9655
9735
  return await action();
9656
9736
  } finally {
@@ -9658,7 +9738,6 @@ var DEFAULT_LOCK_TIMEOUT_MS = 120000, DEFAULT_STALE_LOCK_MS, LOCK_POLL_MS = 250,
9658
9738
  }
9659
9739
  };
9660
9740
  var init_buildDirectoryLock = __esm(() => {
9661
- DEFAULT_STALE_LOCK_MS = 10 * 60000;
9662
9741
  heldLocks = new Map;
9663
9742
  });
9664
9743
 
@@ -9815,7 +9894,7 @@ __export(exports_compileSvelte, {
9815
9894
  clearSvelteCompilerCache: () => clearSvelteCompilerCache
9816
9895
  });
9817
9896
  import { existsSync as existsSync14 } from "fs";
9818
- import { mkdir as mkdir4, stat as stat3 } from "fs/promises";
9897
+ import { mkdir as mkdir3, stat as stat2 } from "fs/promises";
9819
9898
  import {
9820
9899
  dirname as dirname9,
9821
9900
  join as join14,
@@ -9858,7 +9937,7 @@ var resolveDevClientDir2 = () => {
9858
9937
  return /\b__require\b/.test(stripped) ? code : stripped;
9859
9938
  }, exists = async (path) => {
9860
9939
  try {
9861
- await stat3(path);
9940
+ await stat2(path);
9862
9941
  return true;
9863
9942
  } catch {
9864
9943
  return false;
@@ -9926,7 +10005,7 @@ var resolveDevClientDir2 = () => {
9926
10005
  const clientDir = join14(generatedDir, "client");
9927
10006
  const indexDir = join14(generatedDir, "indexes");
9928
10007
  const serverDir = join14(generatedDir, "server");
9929
- await Promise.all([clientDir, indexDir, serverDir].map((dir) => mkdir4(dir, { recursive: true })));
10008
+ await Promise.all([clientDir, indexDir, serverDir].map((dir) => mkdir3(dir, { recursive: true })));
9930
10009
  const dev = env.NODE_ENV !== "production";
9931
10010
  const build = async (src) => {
9932
10011
  const memoized = cache.get(src);
@@ -10032,8 +10111,8 @@ var resolveDevClientDir2 = () => {
10032
10111
  const ssrPath = join14(serverDir, relDir, `${baseName}.js`);
10033
10112
  const clientPath = join14(clientDir, relDir, `${baseName}.js`);
10034
10113
  await Promise.all([
10035
- mkdir4(dirname9(ssrPath), { recursive: true }),
10036
- mkdir4(dirname9(clientPath), { recursive: true })
10114
+ mkdir3(dirname9(ssrPath), { recursive: true }),
10115
+ mkdir3(dirname9(clientPath), { recursive: true })
10037
10116
  ]);
10038
10117
  if (isModule) {
10039
10118
  const bundle = rewriteExternalImports(generate("client"), "client");
@@ -10134,7 +10213,7 @@ if (typeof window !== "undefined") {
10134
10213
  setTimeout(releaseStreamingSlots, 0);
10135
10214
  }
10136
10215
  }`;
10137
- await mkdir4(dirname9(indexPath), { recursive: true });
10216
+ await mkdir3(dirname9(indexPath), { recursive: true });
10138
10217
  return write(indexPath, bootstrap);
10139
10218
  }));
10140
10219
  return {
@@ -10222,7 +10301,7 @@ __export(exports_compileVue, {
10222
10301
  clearVueHmrCaches: () => clearVueHmrCaches
10223
10302
  });
10224
10303
  import { existsSync as existsSync15 } from "fs";
10225
- import { mkdir as mkdir5 } from "fs/promises";
10304
+ import { mkdir as mkdir4 } from "fs/promises";
10226
10305
  import {
10227
10306
  basename as basename5,
10228
10307
  dirname as dirname10,
@@ -10403,7 +10482,7 @@ var resolveDevClientDir3 = () => {
10403
10482
  let cssOutputPaths = [];
10404
10483
  if (isEntryPoint && allCss.length) {
10405
10484
  const cssOutputFile = join15(outputDirs.css, `${toKebab(fileBaseName)}-compiled.css`);
10406
- await mkdir5(dirname10(cssOutputFile), { recursive: true });
10485
+ await mkdir4(dirname10(cssOutputFile), { recursive: true });
10407
10486
  await write2(cssOutputFile, allCss.join(`
10408
10487
  `));
10409
10488
  cssOutputPaths = [cssOutputFile];
@@ -10454,8 +10533,8 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
10454
10533
  }
10455
10534
  return result2;
10456
10535
  };
10457
- await mkdir5(dirname10(clientOutputPath), { recursive: true });
10458
- await mkdir5(dirname10(serverOutputPath), { recursive: true });
10536
+ await mkdir4(dirname10(clientOutputPath), { recursive: true });
10537
+ await mkdir4(dirname10(serverOutputPath), { recursive: true });
10459
10538
  await write2(clientOutputPath, rewritePackageImports(adjustImports(clientCode), clientOutputPath, "client"));
10460
10539
  await write2(serverOutputPath, rewritePackageImports(adjustImports(serverCode), serverOutputPath, "server"));
10461
10540
  const result = {
@@ -10480,10 +10559,10 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
10480
10559
  const serverOutputDir = join15(generatedDir, "server");
10481
10560
  const cssOutputDir = join15(generatedDir, "compiled");
10482
10561
  await Promise.all([
10483
- mkdir5(clientOutputDir, { recursive: true }),
10484
- mkdir5(indexOutputDir, { recursive: true }),
10485
- mkdir5(serverOutputDir, { recursive: true }),
10486
- mkdir5(cssOutputDir, { recursive: true })
10562
+ mkdir4(clientOutputDir, { recursive: true }),
10563
+ mkdir4(indexOutputDir, { recursive: true }),
10564
+ mkdir4(serverOutputDir, { recursive: true }),
10565
+ mkdir4(cssOutputDir, { recursive: true })
10487
10566
  ]);
10488
10567
  const buildCache = new Map;
10489
10568
  const allTsHelperPaths = new Set;
@@ -10497,7 +10576,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
10497
10576
  const entryBaseName = basename5(entryPath, ".vue");
10498
10577
  const indexOutputFile = join15(indexOutputDir, `${entryBaseName}.js`);
10499
10578
  const clientOutputFile = join15(clientOutputDir, relative8(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
10500
- await mkdir5(dirname10(indexOutputFile), { recursive: true });
10579
+ await mkdir4(dirname10(indexOutputFile), { recursive: true });
10501
10580
  const vueHmrImports = isDev ? [
10502
10581
  `window.__HMR_FRAMEWORK__ = "vue";`,
10503
10582
  `import "${hmrClientPath4}";`
@@ -10651,8 +10730,8 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
10651
10730
  const relativeJsPath = relative8(vueRootDir, tsPath).replace(/\.ts$/, ".js");
10652
10731
  const outClientPath = join15(clientOutputDir, relativeJsPath);
10653
10732
  const outServerPath = join15(serverOutputDir, relativeJsPath);
10654
- await mkdir5(dirname10(outClientPath), { recursive: true });
10655
- await mkdir5(dirname10(outServerPath), { recursive: true });
10733
+ await mkdir4(dirname10(outClientPath), { recursive: true });
10734
+ await mkdir4(dirname10(outServerPath), { recursive: true });
10656
10735
  await write2(outClientPath, transpiledCode);
10657
10736
  await write2(outServerPath, transpiledCode);
10658
10737
  }));
@@ -11151,7 +11230,7 @@ __export(exports_compileAngular, {
11151
11230
  compileAngularFile: () => compileAngularFile,
11152
11231
  compileAngular: () => compileAngular
11153
11232
  });
11154
- import { existsSync as existsSync16, readFileSync as readFileSync10, promises as fs } from "fs";
11233
+ import { existsSync as existsSync16, readFileSync as readFileSync11, promises as fs } from "fs";
11155
11234
  import { join as join16, basename as basename6, sep as sep3, dirname as dirname11, resolve as resolve16, relative as relative9 } from "path";
11156
11235
  import ts2 from "typescript";
11157
11236
  var traceAngularPhase = async (name, fn2, metadata) => {
@@ -11288,16 +11367,16 @@ var traceAngularPhase = async (name, fn2, metadata) => {
11288
11367
  return fromNodeModules;
11289
11368
  return resolve16(import.meta.dir, "./dev/client");
11290
11369
  }, devClientDir4, hmrClientPath5, hmrRuntimePath, injectHMRRegistration = (content, sourceId) => {
11291
- const componentClassRegex = /(?:export\s+)?class\s+(\w+Component)\s/g;
11292
- const componentNames = [];
11370
+ const entityClassRegex = /(?:export\s+)?class\s+(\w+(?:Component|Service|Directive|Pipe))\s/g;
11371
+ const entityNames = [];
11293
11372
  let match;
11294
- while ((match = componentClassRegex.exec(content)) !== null) {
11373
+ while ((match = entityClassRegex.exec(content)) !== null) {
11295
11374
  if (match[1])
11296
- componentNames.push(match[1]);
11375
+ entityNames.push(match[1]);
11297
11376
  }
11298
- if (componentNames.length === 0)
11377
+ if (entityNames.length === 0)
11299
11378
  return content;
11300
- const registrations = componentNames.map((name) => ` if (typeof ${name} === 'function') window.__ANGULAR_HMR__.register('${sourceId}#${name}', ${name});`).join(`
11379
+ const registrations = entityNames.map((name) => ` if (typeof ${name} === 'function') window.__ANGULAR_HMR__.register('${sourceId}#${name}', ${name});`).join(`
11301
11380
  `);
11302
11381
  const hmrBlock = `
11303
11382
  // Angular HMR Runtime Layer (Level 3) \u2014 Auto-registration
@@ -11506,7 +11585,7 @@ ${registrations}
11506
11585
  const outputPath = resolve16(join16(outDir, relative9(process.cwd(), resolve16(inputPath)).replace(/\.[cm]?[tj]sx?$/, ".js")));
11507
11586
  return [
11508
11587
  outputPath,
11509
- buildIslandMetadataExports(readFileSync10(inputPath, "utf-8"))
11588
+ buildIslandMetadataExports(readFileSync11(inputPath, "utf-8"))
11510
11589
  ];
11511
11590
  })), { entries: inputPaths.length });
11512
11591
  await traceAngularPhase("aot/preload-compiler", () => import("@angular/compiler"));
@@ -11815,7 +11894,7 @@ ${fields}
11815
11894
  if (!existsSync16(templatePath)) {
11816
11895
  throw new Error(`Unable to inline Angular templateUrl "${templateUrlMatch[1]}": file not found at ${templatePath}`);
11817
11896
  }
11818
- const templateRaw2 = readFileSync10(templatePath, "utf-8");
11897
+ const templateRaw2 = readFileSync11(templatePath, "utf-8");
11819
11898
  const lowered2 = lowerAngularDeferSyntax(templateRaw2);
11820
11899
  const escaped2 = escapeTemplateContent(lowered2.template);
11821
11900
  const replacedSource2 = source.slice(0, templateUrlMatch.index) + `template: \`${escaped2}\`` + source.slice(templateUrlMatch.index + templateUrlMatch[0].length);
@@ -12793,7 +12872,7 @@ __export(exports_compileEmber, {
12793
12872
  basename: () => basename7
12794
12873
  });
12795
12874
  import { existsSync as existsSync17 } from "fs";
12796
- import { mkdir as mkdir6, rm as rm5 } from "fs/promises";
12875
+ import { mkdir as mkdir5, rm as rm4 } from "fs/promises";
12797
12876
  import { basename as basename7, dirname as dirname12, extname as extname6, join as join17, resolve as resolve17 } from "path";
12798
12877
  var {build: bunBuild2, Transpiler: Transpiler3, write: write3, file: file3 } = globalThis.Bun;
12799
12878
  var cachedPreprocessor = null, getPreprocessor = async () => {
@@ -12965,9 +13044,9 @@ export default PageComponent;
12965
13044
  const serverDir = join17(compiledRoot, "server");
12966
13045
  const clientDir = join17(compiledRoot, "client");
12967
13046
  await Promise.all([
12968
- mkdir6(tmpDir, { recursive: true }),
12969
- mkdir6(serverDir, { recursive: true }),
12970
- mkdir6(clientDir, { recursive: true })
13047
+ mkdir5(tmpDir, { recursive: true }),
13048
+ mkdir5(serverDir, { recursive: true }),
13049
+ mkdir5(clientDir, { recursive: true })
12971
13050
  ]);
12972
13051
  const tmpPagePath = resolve17(join17(tmpDir, `${baseName}.module.js`));
12973
13052
  const tmpHarnessPath = resolve17(join17(tmpDir, `${baseName}.harness.js`));
@@ -12994,7 +13073,7 @@ export default PageComponent;
12994
13073
  if (!buildResult.success) {
12995
13074
  console.warn(`\u26A0\uFE0F Ember server build for ${baseName} had errors:`, buildResult.logs);
12996
13075
  }
12997
- await rm5(tmpDir, { force: true, recursive: true });
13076
+ await rm4(tmpDir, { force: true, recursive: true });
12998
13077
  const clientPath = join17(clientDir, `${baseName}.js`);
12999
13078
  await write3(clientPath, transpiled);
13000
13079
  return { clientPath, serverPath };
@@ -13043,9 +13122,9 @@ __export(exports_buildReactVendor, {
13043
13122
  computeVendorPaths: () => computeVendorPaths,
13044
13123
  buildReactVendor: () => buildReactVendor
13045
13124
  });
13046
- import { existsSync as existsSync18, mkdirSync as mkdirSync6 } from "fs";
13125
+ import { existsSync as existsSync18, mkdirSync as mkdirSync7 } from "fs";
13047
13126
  import { join as join18, resolve as resolve18 } from "path";
13048
- import { rm as rm6 } from "fs/promises";
13127
+ import { rm as rm5 } from "fs/promises";
13049
13128
  var {build: bunBuild3 } = globalThis.Bun;
13050
13129
  var resolveJsxDevRuntimeCompatPath = () => {
13051
13130
  const candidates = [
@@ -13099,9 +13178,9 @@ var resolveJsxDevRuntimeCompatPath = () => {
13099
13178
  `;
13100
13179
  }, buildReactVendor = async (buildDir) => {
13101
13180
  const vendorDir = join18(buildDir, "react", "vendor");
13102
- mkdirSync6(vendorDir, { recursive: true });
13181
+ mkdirSync7(vendorDir, { recursive: true });
13103
13182
  const tmpDir = join18(buildDir, "_vendor_tmp");
13104
- mkdirSync6(tmpDir, { recursive: true });
13183
+ mkdirSync7(tmpDir, { recursive: true });
13105
13184
  const specifiers = resolveVendorSpecifiers();
13106
13185
  const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
13107
13186
  const safeName = toSafeFileName(specifier);
@@ -13120,7 +13199,7 @@ var resolveJsxDevRuntimeCompatPath = () => {
13120
13199
  target: "browser",
13121
13200
  throw: false
13122
13201
  });
13123
- await rm6(tmpDir, { force: true, recursive: true });
13202
+ await rm5(tmpDir, { force: true, recursive: true });
13124
13203
  if (!result.success) {
13125
13204
  console.warn("\u26A0\uFE0F React vendor build had errors:", result.logs);
13126
13205
  }
@@ -13169,9 +13248,9 @@ __export(exports_buildAngularVendor, {
13169
13248
  buildAngularVendor: () => buildAngularVendor,
13170
13249
  buildAngularServerVendor: () => buildAngularServerVendor
13171
13250
  });
13172
- import { mkdirSync as mkdirSync7 } from "fs";
13251
+ import { mkdirSync as mkdirSync8 } from "fs";
13173
13252
  import { join as join19 } from "path";
13174
- import { rm as rm7 } from "fs/promises";
13253
+ import { rm as rm6 } from "fs/promises";
13175
13254
  var {build: bunBuild4, Glob: Glob6 } = globalThis.Bun;
13176
13255
  var REQUIRED_ANGULAR_SPECIFIERS_BASE, requiredAngularSpecifiers = (jitMode) => jitMode ? [...REQUIRED_ANGULAR_SPECIFIERS_BASE, "@angular/compiler"] : REQUIRED_ANGULAR_SPECIFIERS_BASE, SERVER_ONLY_ANGULAR_SPECIFIERS, BUILD_ONLY_ANGULAR_SPECIFIER_PREFIXES, isBuildOnlyAngularSpecifier = (spec) => BUILD_ONLY_ANGULAR_SPECIFIER_PREFIXES.some((prefix) => spec === prefix || spec.startsWith(`${prefix}/`)), SCAN_SKIP_DIRS, isResolvable2 = (specifier) => {
13177
13256
  try {
@@ -13207,7 +13286,7 @@ var REQUIRED_ANGULAR_SPECIFIERS_BASE, requiredAngularSpecifiers = (jitMode) => j
13207
13286
  }
13208
13287
  return { angular, transitiveRoots };
13209
13288
  }, PARTIAL_DECL_MARKERS, containsPartialDeclarations = (source) => PARTIAL_DECL_MARKERS.some((marker) => source.includes(marker)), collectTransitiveAngularSpecs = async (roots, angularFound) => {
13210
- const { readFileSync: readFileSync11 } = await import("fs");
13289
+ const { readFileSync: readFileSync12 } = await import("fs");
13211
13290
  const transpiler5 = new Bun.Transpiler({ loader: "js" });
13212
13291
  const visited = new Set;
13213
13292
  const frontier = [];
@@ -13228,7 +13307,7 @@ var REQUIRED_ANGULAR_SPECIFIERS_BASE, requiredAngularSpecifiers = (jitMode) => j
13228
13307
  }
13229
13308
  let content;
13230
13309
  try {
13231
- content = readFileSync11(resolved, "utf-8");
13310
+ content = readFileSync12(resolved, "utf-8");
13232
13311
  } catch {
13233
13312
  continue;
13234
13313
  }
@@ -13268,9 +13347,9 @@ var REQUIRED_ANGULAR_SPECIFIERS_BASE, requiredAngularSpecifiers = (jitMode) => j
13268
13347
  return Array.from(angular).filter(isResolvable2);
13269
13348
  }, buildAngularVendor = async (buildDir, directories = [], linkerJitMode = false, depVendorSpecifiers = []) => {
13270
13349
  const vendorDir = join19(buildDir, "angular", "vendor");
13271
- mkdirSync7(vendorDir, { recursive: true });
13350
+ mkdirSync8(vendorDir, { recursive: true });
13272
13351
  const tmpDir = join19(buildDir, "_angular_vendor_tmp");
13273
- mkdirSync7(tmpDir, { recursive: true });
13352
+ mkdirSync8(tmpDir, { recursive: true });
13274
13353
  const specifiers = await resolveAngularSpecifiers(directories, linkerJitMode);
13275
13354
  const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
13276
13355
  const safeName = toSafeFileName2(specifier);
@@ -13290,7 +13369,7 @@ var REQUIRED_ANGULAR_SPECIFIERS_BASE, requiredAngularSpecifiers = (jitMode) => j
13290
13369
  target: "browser",
13291
13370
  throw: false
13292
13371
  });
13293
- await rm7(tmpDir, { force: true, recursive: true });
13372
+ await rm6(tmpDir, { force: true, recursive: true });
13294
13373
  if (!result.success) {
13295
13374
  console.warn("\u26A0\uFE0F Angular vendor build had errors:", result.logs);
13296
13375
  }
@@ -13306,9 +13385,9 @@ var REQUIRED_ANGULAR_SPECIFIERS_BASE, requiredAngularSpecifiers = (jitMode) => j
13306
13385
  return computeAngularVendorPaths(specifiers);
13307
13386
  }, buildAngularServerVendor = async (buildDir, directories = [], linkerJitMode = false) => {
13308
13387
  const vendorDir = join19(buildDir, "angular", "vendor", "server");
13309
- mkdirSync7(vendorDir, { recursive: true });
13388
+ mkdirSync8(vendorDir, { recursive: true });
13310
13389
  const tmpDir = join19(buildDir, "_angular_server_vendor_tmp");
13311
- mkdirSync7(tmpDir, { recursive: true });
13390
+ mkdirSync8(tmpDir, { recursive: true });
13312
13391
  const browserSpecs = await resolveAngularSpecifiers(directories, linkerJitMode);
13313
13392
  const allSpecs = new Set(browserSpecs);
13314
13393
  for (const spec of SERVER_ONLY_ANGULAR_SPECIFIERS) {
@@ -13333,7 +13412,7 @@ var REQUIRED_ANGULAR_SPECIFIERS_BASE, requiredAngularSpecifiers = (jitMode) => j
13333
13412
  target: "bun",
13334
13413
  throw: false
13335
13414
  });
13336
- await rm7(tmpDir, { force: true, recursive: true });
13415
+ await rm6(tmpDir, { force: true, recursive: true });
13337
13416
  if (!result.success) {
13338
13417
  console.warn("\u26A0\uFE0F Angular server vendor build had errors:", result.logs);
13339
13418
  }
@@ -13397,15 +13476,15 @@ __export(exports_buildVueVendor, {
13397
13476
  computeVueVendorPaths: () => computeVueVendorPaths,
13398
13477
  buildVueVendor: () => buildVueVendor
13399
13478
  });
13400
- import { mkdirSync as mkdirSync8 } from "fs";
13479
+ import { mkdirSync as mkdirSync9 } from "fs";
13401
13480
  import { join as join20 } from "path";
13402
- import { rm as rm8 } from "fs/promises";
13481
+ import { rm as rm7 } from "fs/promises";
13403
13482
  var {build: bunBuild5 } = globalThis.Bun;
13404
13483
  var vueSpecifiers, toSafeFileName3 = (specifier) => specifier.replace(/\//g, "_"), buildVueVendor = async (buildDir) => {
13405
13484
  const vendorDir = join20(buildDir, "vue", "vendor");
13406
- mkdirSync8(vendorDir, { recursive: true });
13485
+ mkdirSync9(vendorDir, { recursive: true });
13407
13486
  const tmpDir = join20(buildDir, "_vue_vendor_tmp");
13408
- mkdirSync8(tmpDir, { recursive: true });
13487
+ mkdirSync9(tmpDir, { recursive: true });
13409
13488
  const entrypoints = await Promise.all(vueSpecifiers.map(async (specifier) => {
13410
13489
  const safeName = toSafeFileName3(specifier);
13411
13490
  const entryPath = join20(tmpDir, `${safeName}.ts`);
@@ -13428,22 +13507,22 @@ var vueSpecifiers, toSafeFileName3 = (specifier) => specifier.replace(/\//g, "_"
13428
13507
  target: "browser",
13429
13508
  throw: false
13430
13509
  });
13431
- await rm8(tmpDir, { force: true, recursive: true });
13510
+ await rm7(tmpDir, { force: true, recursive: true });
13432
13511
  if (!result.success) {
13433
13512
  console.warn("\u26A0\uFE0F Vue vendor build had errors:", result.logs);
13434
13513
  return;
13435
13514
  }
13436
- const { readFileSync: readFileSync11, writeFileSync: writeFileSync6, readdirSync } = await import("fs");
13515
+ const { readFileSync: readFileSync12, writeFileSync: writeFileSync7, readdirSync } = await import("fs");
13437
13516
  const files = readdirSync(vendorDir).filter((f2) => f2.endsWith(".js"));
13438
13517
  for (const file4 of files) {
13439
13518
  const filePath = join20(vendorDir, file4);
13440
- const content = readFileSync11(filePath, "utf-8");
13519
+ const content = readFileSync12(filePath, "utf-8");
13441
13520
  if (!content.includes("__VUE_HMR_RUNTIME__"))
13442
13521
  continue;
13443
13522
  const patched = content.replace(/getGlobalThis\(\)\.__VUE_HMR_RUNTIME__\s*=\s*\{/, "getGlobalThis().__VUE_HMR_RUNTIME__ = getGlobalThis().__VUE_HMR_RUNTIME__ || {");
13444
13523
  if (patched === content)
13445
13524
  continue;
13446
- writeFileSync6(filePath, patched);
13525
+ writeFileSync7(filePath, patched);
13447
13526
  }
13448
13527
  }, computeVueVendorPaths = () => {
13449
13528
  const paths = {};
@@ -13462,9 +13541,9 @@ __export(exports_buildSvelteVendor, {
13462
13541
  computeSvelteVendorPaths: () => computeSvelteVendorPaths,
13463
13542
  buildSvelteVendor: () => buildSvelteVendor
13464
13543
  });
13465
- import { mkdirSync as mkdirSync9 } from "fs";
13544
+ import { mkdirSync as mkdirSync10 } from "fs";
13466
13545
  import { join as join21 } from "path";
13467
- import { rm as rm9 } from "fs/promises";
13546
+ import { rm as rm8 } from "fs/promises";
13468
13547
  var {build: bunBuild6 } = globalThis.Bun;
13469
13548
  var svelteSpecifiers, isResolvable3 = (specifier) => {
13470
13549
  try {
@@ -13478,9 +13557,9 @@ var svelteSpecifiers, isResolvable3 = (specifier) => {
13478
13557
  if (specifiers.length === 0)
13479
13558
  return;
13480
13559
  const vendorDir = join21(buildDir, "svelte", "vendor");
13481
- mkdirSync9(vendorDir, { recursive: true });
13560
+ mkdirSync10(vendorDir, { recursive: true });
13482
13561
  const tmpDir = join21(buildDir, "_svelte_vendor_tmp");
13483
- mkdirSync9(tmpDir, { recursive: true });
13562
+ mkdirSync10(tmpDir, { recursive: true });
13484
13563
  const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
13485
13564
  const safeName = toSafeFileName4(specifier);
13486
13565
  const entryPath = join21(tmpDir, `${safeName}.ts`);
@@ -13498,7 +13577,7 @@ var svelteSpecifiers, isResolvable3 = (specifier) => {
13498
13577
  target: "browser",
13499
13578
  throw: false
13500
13579
  });
13501
- await rm9(tmpDir, { force: true, recursive: true });
13580
+ await rm8(tmpDir, { force: true, recursive: true });
13502
13581
  if (!result.success) {
13503
13582
  console.warn("\u26A0\uFE0F Svelte vendor build had errors:", result.logs);
13504
13583
  }
@@ -13521,12 +13600,19 @@ var init_buildSvelteVendor = __esm(() => {
13521
13600
  ];
13522
13601
  });
13523
13602
 
13524
- // src/build/rewriteImports.ts
13525
- var exports_rewriteImports = {};
13526
- __export(exports_rewriteImports, {
13603
+ // src/build/rewriteImportsPlugin.ts
13604
+ var exports_rewriteImportsPlugin = {};
13605
+ __export(exports_rewriteImportsPlugin, {
13527
13606
  rewriteVendorDirectories: () => rewriteVendorDirectories,
13528
- rewriteImports: () => rewriteImports
13607
+ rewriteImportsInContent: () => rewriteImportsInContent,
13608
+ rewriteBuildOutputsWith: () => rewriteBuildOutputsWith,
13609
+ rewriteBuildOutputs: () => rewriteBuildOutputs,
13610
+ jsRewriteImports: () => jsRewriteImports,
13611
+ fixMissingReExportNamespacesInContent: () => fixMissingReExportNamespacesInContent,
13612
+ buildWithImportRewrite: () => buildWithImportRewrite
13529
13613
  });
13614
+ import { readdir as readdir3 } from "fs/promises";
13615
+ import { join as join22 } from "path";
13530
13616
  var escapeRegex2 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
13531
13617
  let result = content;
13532
13618
  for (const [specifier, webPath] of replacements) {
@@ -13539,90 +13625,157 @@ var escapeRegex2 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewrit
13539
13625
  result = result.replace(dynamicRegex, `$1${webPath}$2`);
13540
13626
  }
13541
13627
  return result;
13542
- }, rewriteImports = async (outputPaths, vendorPaths) => {
13543
- const jsFiles = outputPaths.filter((path) => path.endsWith(".js"));
13544
- if (jsFiles.length === 0)
13545
- return;
13628
+ }, rewriteImportsInContent = (content, vendorPaths) => {
13629
+ if (Object.keys(vendorPaths).length === 0)
13630
+ return content;
13546
13631
  const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
13547
- await Promise.all(jsFiles.map(async (filePath) => {
13548
- const original = await Bun.file(filePath).text();
13549
- const native = nativeRewriteImports(original, replacements);
13550
- const content = native ?? jsRewriteImports(original, replacements);
13551
- if (content !== original) {
13552
- await Bun.write(filePath, content);
13632
+ const native = nativeRewriteImports(content, replacements);
13633
+ return native ?? jsRewriteImports(content, replacements);
13634
+ }, fixMissingReExportNamespacesInContent = (content) => {
13635
+ const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
13636
+ REEXPORT_PATTERN.lastIndex = 0;
13637
+ const missing = [];
13638
+ let match;
13639
+ while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
13640
+ const ident = match[1];
13641
+ if (!ident)
13642
+ continue;
13643
+ const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
13644
+ if (nsImportRe.test(content))
13645
+ continue;
13646
+ const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
13647
+ if (declRe.test(content))
13648
+ continue;
13649
+ const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
13650
+ if (namedImportRe.test(content))
13651
+ continue;
13652
+ const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
13653
+ let pathMatch;
13654
+ let sourcePath;
13655
+ while ((pathMatch = importPathRe.exec(content)) !== null) {
13656
+ const p2 = pathMatch[1];
13657
+ if (!p2)
13658
+ continue;
13659
+ const base = p2.split("/").pop()?.replace(/\.[mc]?js$/, "");
13660
+ if (!base)
13661
+ continue;
13662
+ const normalized = base.startsWith("_") ? base.slice(1) : base;
13663
+ if (normalized === ident || normalized.endsWith(`_${ident}`)) {
13664
+ sourcePath = p2;
13665
+ break;
13666
+ }
13667
+ }
13668
+ if (sourcePath)
13669
+ missing.push({ ident, path: sourcePath });
13670
+ }
13671
+ if (missing.length === 0)
13672
+ return content;
13673
+ const seen = new Set;
13674
+ const unique = missing.filter((entry) => {
13675
+ if (seen.has(entry.ident))
13676
+ return false;
13677
+ seen.add(entry.ident);
13678
+ return true;
13679
+ });
13680
+ const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
13681
+ `);
13682
+ return `${inserts}
13683
+ ${content}`;
13684
+ }, isReadableArtifact = (artifact) => artifact.path.endsWith(".js"), rewriteBuildOutputs = async (outputs, vendorPaths) => {
13685
+ if (Object.keys(vendorPaths).length === 0)
13686
+ return;
13687
+ await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
13688
+ let original;
13689
+ try {
13690
+ original = await artifact.text();
13691
+ } catch (err) {
13692
+ const code = err.code;
13693
+ if (code === "ENOENT")
13694
+ return;
13695
+ throw err;
13696
+ }
13697
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
13698
+ if (rewritten === original)
13699
+ return;
13700
+ try {
13701
+ await Bun.write(artifact.path, rewritten);
13702
+ } catch (err) {
13703
+ const code = err.code;
13704
+ if (code === "ENOENT")
13705
+ return;
13706
+ throw err;
13707
+ }
13708
+ }));
13709
+ }, rewriteBuildOutputsWith = async (outputs, resolveVendorPaths) => {
13710
+ await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
13711
+ const vendorPaths = resolveVendorPaths(artifact);
13712
+ if (Object.keys(vendorPaths).length === 0)
13713
+ return;
13714
+ let original;
13715
+ try {
13716
+ original = await artifact.text();
13717
+ } catch (err) {
13718
+ const code = err.code;
13719
+ if (code === "ENOENT")
13720
+ return;
13721
+ throw err;
13722
+ }
13723
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
13724
+ if (rewritten === original)
13725
+ return;
13726
+ try {
13727
+ await Bun.write(artifact.path, rewritten);
13728
+ } catch (err) {
13729
+ const code = err.code;
13730
+ if (code === "ENOENT")
13731
+ return;
13732
+ throw err;
13553
13733
  }
13554
13734
  }));
13555
13735
  }, rewriteVendorDirectories = async (vendorDirs, vendorPaths) => {
13556
13736
  if (Object.keys(vendorPaths).length === 0)
13557
13737
  return;
13558
- const { readdirSync } = await import("fs");
13559
- const { join: join22 } = await import("path");
13560
13738
  const allFiles = [];
13561
13739
  for (const dir of vendorDirs) {
13562
13740
  try {
13563
- const files = readdirSync(dir).filter((f2) => f2.endsWith(".js")).map((f2) => join22(dir, f2));
13564
- allFiles.push(...files);
13741
+ const entries = await readdir3(dir);
13742
+ for (const entry of entries) {
13743
+ if (entry.endsWith(".js"))
13744
+ allFiles.push(join22(dir, entry));
13745
+ }
13565
13746
  } catch {}
13566
13747
  }
13567
- await rewriteImports(allFiles, vendorPaths);
13568
- await fixMissingReExportNamespaces(allFiles);
13569
- }, fixMissingReExportNamespaces = async (files) => {
13570
- const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
13571
- await Promise.all(files.map(async (filePath) => {
13572
- const content = await Bun.file(filePath).text();
13573
- REEXPORT_PATTERN.lastIndex = 0;
13574
- const missing = [];
13575
- let match;
13576
- while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
13577
- const ident = match[1];
13578
- if (!ident)
13579
- continue;
13580
- const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
13581
- if (nsImportRe.test(content))
13582
- continue;
13583
- const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
13584
- if (declRe.test(content))
13585
- continue;
13586
- const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
13587
- if (namedImportRe.test(content))
13588
- continue;
13589
- const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
13590
- let pathMatch;
13591
- let sourcePath;
13592
- while ((pathMatch = importPathRe.exec(content)) !== null) {
13593
- const p2 = pathMatch[1];
13594
- if (!p2)
13595
- continue;
13596
- const base = p2.split("/").pop()?.replace(/\.[mc]?js$/, "");
13597
- if (!base)
13598
- continue;
13599
- const normalized = base.startsWith("_") ? base.slice(1) : base;
13600
- if (normalized === ident || normalized.endsWith(`_${ident}`)) {
13601
- sourcePath = p2;
13602
- break;
13603
- }
13604
- }
13605
- if (sourcePath) {
13606
- missing.push({ ident, path: sourcePath });
13607
- }
13748
+ await Promise.all(allFiles.map(async (filePath) => {
13749
+ let original;
13750
+ try {
13751
+ original = await Bun.file(filePath).text();
13752
+ } catch (err) {
13753
+ const code = err.code;
13754
+ if (code === "ENOENT")
13755
+ return;
13756
+ throw err;
13608
13757
  }
13609
- if (missing.length === 0)
13758
+ let next = rewriteImportsInContent(original, vendorPaths);
13759
+ next = fixMissingReExportNamespacesInContent(next);
13760
+ if (next === original)
13610
13761
  return;
13611
- const seen = new Set;
13612
- const unique = missing.filter((entry) => {
13613
- if (seen.has(entry.ident))
13614
- return false;
13615
- seen.add(entry.ident);
13616
- return true;
13617
- });
13618
- const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
13619
- `);
13620
- const patched = `${inserts}
13621
- ${content}`;
13622
- await Bun.write(filePath, patched);
13762
+ try {
13763
+ await Bun.write(filePath, next);
13764
+ } catch (err) {
13765
+ const code = err.code;
13766
+ if (code === "ENOENT")
13767
+ return;
13768
+ throw err;
13769
+ }
13623
13770
  }));
13771
+ }, buildWithImportRewrite = async (pendingBuild, vendorPaths) => {
13772
+ const result = await pendingBuild;
13773
+ if (result.outputs.length > 0) {
13774
+ await rewriteBuildOutputs(result.outputs, vendorPaths);
13775
+ }
13776
+ return result;
13624
13777
  };
13625
- var init_rewriteImports = __esm(() => {
13778
+ var init_rewriteImportsPlugin = __esm(() => {
13626
13779
  init_nativeRewrite();
13627
13780
  });
13628
13781
 
@@ -13631,13 +13784,13 @@ import {
13631
13784
  copyFileSync,
13632
13785
  cpSync,
13633
13786
  existsSync as existsSync19,
13634
- mkdirSync as mkdirSync10,
13635
- readFileSync as readFileSync11,
13787
+ mkdirSync as mkdirSync11,
13788
+ readFileSync as readFileSync12,
13636
13789
  rmSync as rmSync2,
13637
13790
  statSync,
13638
- writeFileSync as writeFileSync6
13791
+ writeFileSync as writeFileSync7
13639
13792
  } from "fs";
13640
- import { basename as basename8, dirname as dirname13, extname as extname7, join as join22, relative as relative10, resolve as resolve19 } from "path";
13793
+ import { basename as basename8, dirname as dirname13, extname as extname7, join as join23, relative as relative10, resolve as resolve19 } from "path";
13641
13794
  import { cwd, env as env2, exit } from "process";
13642
13795
  var {build: bunBuild7, Glob: Glob7 } = globalThis.Bun;
13643
13796
  var isDev, isBuildTraceEnabled = () => {
@@ -13712,11 +13865,11 @@ var isDev, isBuildTraceEnabled = () => {
13712
13865
  throw err;
13713
13866
  exit(1);
13714
13867
  }, copyHtmxVendor = (htmxDir, htmxDestDir) => {
13715
- mkdirSync10(htmxDestDir, { recursive: true });
13868
+ mkdirSync11(htmxDestDir, { recursive: true });
13716
13869
  const glob = new Glob7("htmx*.min.js");
13717
13870
  for (const relPath of glob.scanSync({ cwd: htmxDir })) {
13718
- const src = join22(htmxDir, relPath);
13719
- const dest = join22(htmxDestDir, "htmx.min.js");
13871
+ const src = join23(htmxDir, relPath);
13872
+ const dest = join23(htmxDestDir, "htmx.min.js");
13720
13873
  copyFileSync(src, dest);
13721
13874
  return;
13722
13875
  }
@@ -13760,7 +13913,7 @@ var isDev, isBuildTraceEnabled = () => {
13760
13913
  addWorkerPathIfExists(file4, relPath, workerPaths);
13761
13914
  }
13762
13915
  }, collectWorkerPathsFromFile = (file4, patterns, workerPaths) => {
13763
- const content = readFileSync11(file4, "utf-8");
13916
+ const content = readFileSync12(file4, "utf-8");
13764
13917
  for (const pattern of patterns) {
13765
13918
  collectWorkerPathsFromContent(content, pattern, file4, workerPaths);
13766
13919
  }
@@ -13791,8 +13944,8 @@ var isDev, isBuildTraceEnabled = () => {
13791
13944
  vuePagesPath
13792
13945
  }) => {
13793
13946
  const { readdirSync: readDir } = await import("fs");
13794
- const devIndexDir = join22(buildPath, "_src_indexes");
13795
- mkdirSync10(devIndexDir, { recursive: true });
13947
+ const devIndexDir = join23(buildPath, "_src_indexes");
13948
+ mkdirSync11(devIndexDir, { recursive: true });
13796
13949
  if (reactIndexesPath && reactPagesPath) {
13797
13950
  copyReactDevIndexes(reactIndexesPath, reactPagesPath, devIndexDir, readDir);
13798
13951
  }
@@ -13809,35 +13962,35 @@ var isDev, isBuildTraceEnabled = () => {
13809
13962
  const indexFiles = readDir(reactIndexesPath).filter((file4) => file4.endsWith(".tsx"));
13810
13963
  const pagesRel = relative10(process.cwd(), resolve19(reactPagesPath)).replace(/\\/g, "/");
13811
13964
  for (const file4 of indexFiles) {
13812
- let content = readFileSync11(join22(reactIndexesPath, file4), "utf-8");
13965
+ let content = readFileSync12(join23(reactIndexesPath, file4), "utf-8");
13813
13966
  content = content.replace(/from\s*['"]([^'"]*\/pages\/([^'"]+))['"]/g, (_match, _fullPath, componentName) => `from '/@src/${pagesRel}/${componentName}'`);
13814
- writeFileSync6(join22(devIndexDir, file4), content);
13967
+ writeFileSync7(join23(devIndexDir, file4), content);
13815
13968
  }
13816
13969
  }, copySvelteDevIndexes = (svelteDir, sveltePagesPath, svelteEntries, devIndexDir) => {
13817
- const svelteIndexDir = join22(svelteDir, "generated", "indexes");
13970
+ const svelteIndexDir = join23(svelteDir, "generated", "indexes");
13818
13971
  const sveltePageEntries = svelteEntries.filter((file4) => resolve19(file4).startsWith(resolve19(sveltePagesPath)));
13819
13972
  for (const entry of sveltePageEntries) {
13820
13973
  const name = basename8(entry).replace(/\.svelte(\.(ts|js))?$/, "");
13821
- const indexFile = join22(svelteIndexDir, "pages", `${name}.js`);
13974
+ const indexFile = join23(svelteIndexDir, "pages", `${name}.js`);
13822
13975
  if (!existsSync19(indexFile))
13823
13976
  continue;
13824
- let content = readFileSync11(indexFile, "utf-8");
13977
+ let content = readFileSync12(indexFile, "utf-8");
13825
13978
  const srcRel = relative10(process.cwd(), resolve19(entry)).replace(/\\/g, "/");
13826
13979
  content = content.replace(/import\s+Component\s+from\s+['"]([^'"]+)['"]/, `import Component from "/@src/${srcRel}"`);
13827
- writeFileSync6(join22(devIndexDir, `${name}.svelte.js`), content);
13980
+ writeFileSync7(join23(devIndexDir, `${name}.svelte.js`), content);
13828
13981
  }
13829
13982
  }, copyVueDevIndexes = (vueDir, vuePagesPath, vueEntries, devIndexDir) => {
13830
- const vueIndexDir = join22(vueDir, "generated", "indexes");
13983
+ const vueIndexDir = join23(vueDir, "generated", "indexes");
13831
13984
  const vuePageEntries = vueEntries.filter((file4) => resolve19(file4).startsWith(resolve19(vuePagesPath)));
13832
13985
  for (const entry of vuePageEntries) {
13833
13986
  const name = basename8(entry, ".vue");
13834
- const indexFile = join22(vueIndexDir, `${name}.js`);
13987
+ const indexFile = join23(vueIndexDir, `${name}.js`);
13835
13988
  if (!existsSync19(indexFile))
13836
13989
  continue;
13837
- let content = readFileSync11(indexFile, "utf-8");
13990
+ let content = readFileSync12(indexFile, "utf-8");
13838
13991
  const srcRel = relative10(process.cwd(), resolve19(entry)).replace(/\\/g, "/");
13839
13992
  content = content.replace(/import\s+Comp(?:\s*,\s*\*\s+as\s+\w+)?\s+from\s+['"]([^'"]+)['"]/, (match) => match.replace(/from\s+['"][^'"]+['"]/, `from "/@src/${srcRel}"`));
13840
- writeFileSync6(join22(devIndexDir, `${name}.vue.js`), content);
13993
+ writeFileSync7(join23(devIndexDir, `${name}.vue.js`), content);
13841
13994
  }
13842
13995
  }, resolveVueRuntimeId = (content, firstUseName, outputPath, projectRoot) => {
13843
13996
  const varIdx = content.indexOf(`var ${firstUseName} =`);
@@ -13885,7 +14038,7 @@ var isDev, isBuildTraceEnabled = () => {
13885
14038
  }
13886
14039
  return result;
13887
14040
  }, VUE_HMR_RUNTIME, injectVueComposableTracking = (outputPath, projectRoot) => {
13888
- let content = readFileSync11(outputPath, "utf-8");
14041
+ let content = readFileSync12(outputPath, "utf-8");
13889
14042
  const usePattern = /^var\s+(use[A-Z]\w*)\s*=/gm;
13890
14043
  const useNames = [];
13891
14044
  let match;
@@ -13906,7 +14059,7 @@ var isDev, isBuildTraceEnabled = () => {
13906
14059
  content = `${content.slice(0, firstUseIdx) + runtime}
13907
14060
  ${content.slice(firstUseIdx)}`;
13908
14061
  content = wrapUseFunctions(content, useNames);
13909
- writeFileSync6(outputPath, content);
14062
+ writeFileSync7(outputPath, content);
13910
14063
  }, buildDevUrlFileMap = (urlReferencedFiles, projectRoot) => {
13911
14064
  const urlFileMap = new Map;
13912
14065
  for (const srcPath of urlReferencedFiles) {
@@ -13935,7 +14088,7 @@ ${content.slice(firstUseIdx)}`;
13935
14088
  }, rewriteUrlReferences = (outputPaths, urlFileMap) => {
13936
14089
  const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
13937
14090
  for (const outputPath of outputPaths) {
13938
- let content = readFileSync11(outputPath, "utf-8");
14091
+ let content = readFileSync12(outputPath, "utf-8");
13939
14092
  let changed = false;
13940
14093
  content = content.replace(urlPattern, (_match, relPath) => {
13941
14094
  const targetName = basename8(relPath);
@@ -13946,7 +14099,7 @@ ${content.slice(firstUseIdx)}`;
13946
14099
  return `new URL('${resolvedPath}', import.meta.url)`;
13947
14100
  });
13948
14101
  if (changed)
13949
- writeFileSync6(outputPath, content);
14102
+ writeFileSync7(outputPath, content);
13950
14103
  }
13951
14104
  }, vueFeatureFlags, bunBuildPassKeys, bunBuildPassKeySet, reservedBunBuildConfigKeys, passLockedKeys, isObject = (value) => typeof value === "object" && value !== null, isBunBuildPassConfig = (config) => isObject(config) && Object.keys(config).some((key) => bunBuildPassKeySet.has(key)), sanitizeBunBuildOverride = (override, extraReservedKeys = new Set) => {
13952
14105
  if (!override)
@@ -14059,10 +14212,10 @@ ${content.slice(firstUseIdx)}`;
14059
14212
  restoreTracePhase();
14060
14213
  return;
14061
14214
  }
14062
- const traceDir = join22(buildPath2, ".absolute-trace");
14215
+ const traceDir = join23(buildPath2, ".absolute-trace");
14063
14216
  const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
14064
- mkdirSync10(traceDir, { recursive: true });
14065
- writeFileSync6(join22(traceDir, `build-trace-${timestamp}.json`), JSON.stringify({
14217
+ mkdirSync11(traceDir, { recursive: true });
14218
+ writeFileSync7(join23(traceDir, `build-trace-${timestamp}.json`), JSON.stringify({
14066
14219
  events: traceEvents,
14067
14220
  frameworks: traceFrameworkNames,
14068
14221
  generatedAt: new Date().toISOString(),
@@ -14093,15 +14246,15 @@ ${content.slice(firstUseIdx)}`;
14093
14246
  const stylesPath = typeof stylesConfig === "string" ? stylesConfig : stylesConfig?.path;
14094
14247
  const stylesIgnore = typeof stylesConfig === "object" ? stylesConfig.ignore : undefined;
14095
14248
  const stylesDir = stylesPath && validateSafePath(stylesPath, projectRoot);
14096
- const reactIndexesPath = reactDir && join22(reactDir, "generated", "indexes");
14097
- const reactPagesPath = reactDir && join22(reactDir, "pages");
14098
- const htmlPagesPath = htmlDir && join22(htmlDir, "pages");
14099
- const htmlScriptsPath = htmlDir && join22(htmlDir, "scripts");
14100
- const sveltePagesPath = svelteDir && join22(svelteDir, "pages");
14101
- const vuePagesPath = vueDir && join22(vueDir, "pages");
14102
- const htmxPagesPath = htmxDir && join22(htmxDir, "pages");
14103
- const angularPagesPath = angularDir && join22(angularDir, "pages");
14104
- const emberPagesPath = emberDir && join22(emberDir, "pages");
14249
+ const reactIndexesPath = reactDir && join23(reactDir, "generated", "indexes");
14250
+ const reactPagesPath = reactDir && join23(reactDir, "pages");
14251
+ const htmlPagesPath = htmlDir && join23(htmlDir, "pages");
14252
+ const htmlScriptsPath = htmlDir && join23(htmlDir, "scripts");
14253
+ const sveltePagesPath = svelteDir && join23(svelteDir, "pages");
14254
+ const vuePagesPath = vueDir && join23(vueDir, "pages");
14255
+ const htmxPagesPath = htmxDir && join23(htmxDir, "pages");
14256
+ const angularPagesPath = angularDir && join23(angularDir, "pages");
14257
+ const emberPagesPath = emberDir && join23(emberDir, "pages");
14105
14258
  const frontends = [
14106
14259
  reactDir,
14107
14260
  htmlDir,
@@ -14141,12 +14294,12 @@ ${content.slice(firstUseIdx)}`;
14141
14294
  if (svelteDir)
14142
14295
  serverDirMap.push({
14143
14296
  dir: svelteDir,
14144
- subdir: join22("generated", "server")
14297
+ subdir: join23("generated", "server")
14145
14298
  });
14146
14299
  if (vueDir)
14147
14300
  serverDirMap.push({
14148
14301
  dir: vueDir,
14149
- subdir: join22("generated", "server")
14302
+ subdir: join23("generated", "server")
14150
14303
  });
14151
14304
  if (angularDir)
14152
14305
  serverDirMap.push({ dir: angularDir, subdir: "generated" });
@@ -14156,14 +14309,14 @@ ${content.slice(firstUseIdx)}`;
14156
14309
  const [firstEntry] = serverDirMap;
14157
14310
  if (!firstEntry)
14158
14311
  throw new Error("Expected at least one server directory entry");
14159
- serverRoot = join22(firstEntry.dir, firstEntry.subdir);
14160
- serverOutDir = join22(buildPath, basename8(firstEntry.dir));
14312
+ serverRoot = join23(firstEntry.dir, firstEntry.subdir);
14313
+ serverOutDir = join23(buildPath, basename8(firstEntry.dir));
14161
14314
  } else if (serverDirMap.length > 1) {
14162
14315
  serverRoot = commonAncestor(serverDirMap.map((entry) => entry.dir), projectRoot);
14163
14316
  serverOutDir = buildPath;
14164
14317
  }
14165
14318
  const publicPath = publicDirectory && validateSafePath(publicDirectory, projectRoot);
14166
- await tracePhase("build-dir/create", () => mkdirSync10(buildPath, { recursive: true }));
14319
+ await tracePhase("build-dir/create", () => mkdirSync11(buildPath, { recursive: true }));
14167
14320
  if (publicPath)
14168
14321
  await tracePhase("public/copy", () => cpSync(publicPath, buildPath, { force: true, recursive: true }));
14169
14322
  const filterToIncrementalEntries = (entryPoints, mapToSource) => {
@@ -14185,7 +14338,7 @@ ${content.slice(firstUseIdx)}`;
14185
14338
  await tracePhase("react/index-generation", () => generateReactIndexFiles(reactPagesPath, reactIndexesPath, hmr));
14186
14339
  }
14187
14340
  if (assetsPath && (!isIncremental || normalizedIncrementalFiles?.some((f2) => f2.includes("/assets/")))) {
14188
- await tracePhase("assets/copy", () => cpSync(assetsPath, join22(buildPath, "assets"), {
14341
+ await tracePhase("assets/copy", () => cpSync(assetsPath, join23(buildPath, "assets"), {
14189
14342
  force: true,
14190
14343
  recursive: true
14191
14344
  }));
@@ -14239,7 +14392,7 @@ ${content.slice(firstUseIdx)}`;
14239
14392
  const reactEntries = isIncremental && reactIndexesPath && reactPagesPath ? filterToIncrementalEntries(allReactEntries, (entry) => {
14240
14393
  if (entry.startsWith(resolve19(reactIndexesPath))) {
14241
14394
  const pageName = basename8(entry, ".tsx");
14242
- return join22(reactPagesPath, `${pageName}.tsx`);
14395
+ return join23(reactPagesPath, `${pageName}.tsx`);
14243
14396
  }
14244
14397
  return null;
14245
14398
  }) : allReactEntries;
@@ -14343,9 +14496,9 @@ ${content.slice(firstUseIdx)}`;
14343
14496
  const compileReactConventions = async () => {
14344
14497
  if (reactConventionSources.length === 0)
14345
14498
  return emptyStringArray;
14346
- const destDir = join22(buildPath, "conventions", "react");
14499
+ const destDir = join23(buildPath, "conventions", "react");
14347
14500
  rmSync2(destDir, { force: true, recursive: true });
14348
- mkdirSync10(destDir, { recursive: true });
14501
+ mkdirSync11(destDir, { recursive: true });
14349
14502
  const destPaths = [];
14350
14503
  for (let idx = 0;idx < reactConventionSources.length; idx++) {
14351
14504
  const source = reactConventionSources[idx];
@@ -14387,9 +14540,9 @@ ${content.slice(firstUseIdx)}`;
14387
14540
  angularConventionSources.length > 0 && angularDir ? tracePhase("compile/convention-angular", () => Promise.resolve().then(() => (init_compileAngular(), exports_compileAngular)).then((mod) => mod.compileAngular(angularConventionSources, angularDir, hmr, styleTransformConfig))) : { serverPaths: emptyStringArray }
14388
14541
  ]);
14389
14542
  const bundleConventionFiles = async (framework, compiledPaths) => {
14390
- const destDir = join22(buildPath, "conventions", framework);
14543
+ const destDir = join23(buildPath, "conventions", framework);
14391
14544
  rmSync2(destDir, { force: true, recursive: true });
14392
- mkdirSync10(destDir, { recursive: true });
14545
+ mkdirSync11(destDir, { recursive: true });
14393
14546
  const destPaths = [];
14394
14547
  for (let idx = 0;idx < compiledPaths.length; idx++) {
14395
14548
  const compiledPath = compiledPaths[idx];
@@ -14460,7 +14613,7 @@ ${content.slice(firstUseIdx)}`;
14460
14613
  }
14461
14614
  })) : {
14462
14615
  entries: [],
14463
- generatedRoot: join22(buildPath, "_island_entries")
14616
+ generatedRoot: join23(buildPath, "_island_entries")
14464
14617
  };
14465
14618
  const islandClientEntryPoints = islandEntryResult.entries.map((entry) => entry.entryPath);
14466
14619
  if (serverEntryPoints.length === 0 && reactClientEntryPoints.length === 0 && nonReactClientEntryPoints.length === 0 && islandClientEntryPoints.length === 0 && htmxDir === undefined && htmlDir === undefined) {
@@ -14496,7 +14649,7 @@ ${content.slice(firstUseIdx)}`;
14496
14649
  return {};
14497
14650
  }
14498
14651
  if (hmr && reactIndexesPath && reactClientEntryPoints.length > 0) {
14499
- const refreshEntry = join22(reactIndexesPath, "_refresh.tsx");
14652
+ const refreshEntry = join23(reactIndexesPath, "_refresh.tsx");
14500
14653
  if (!reactClientEntryPoints.includes(refreshEntry))
14501
14654
  reactClientEntryPoints.push(refreshEntry);
14502
14655
  }
@@ -14512,12 +14665,7 @@ ${content.slice(firstUseIdx)}`;
14512
14665
  angularVendorPaths2 = computeAngularVendorPaths2(globalThis.__angularVendorSpecifiers);
14513
14666
  setAngularVendorPaths(angularVendorPaths2);
14514
14667
  }
14515
- let angularServerVendorPaths2 = getAngularServerVendorPaths();
14516
- if (!angularServerVendorPaths2 && hmr && angularDir) {
14517
- const { computeAngularServerVendorPaths: computeAngularServerVendorPaths2 } = await Promise.resolve().then(() => (init_buildAngularVendor(), exports_buildAngularVendor));
14518
- angularServerVendorPaths2 = computeAngularServerVendorPaths2(buildPath, globalThis.__angularVendorSpecifiers ?? []);
14519
- setAngularServerVendorPaths(angularServerVendorPaths2);
14520
- }
14668
+ let angularServerVendorPaths2 = hmr ? undefined : getAngularServerVendorPaths();
14521
14669
  if (!hmr && angularDir) {
14522
14670
  const angularSourceDirs = [
14523
14671
  angularDir,
@@ -14600,19 +14748,19 @@ ${content.slice(firstUseIdx)}`;
14600
14748
  throw: false
14601
14749
  }, resolveBunBuildOverride(bunBuildConfig, "reactClient")) : undefined;
14602
14750
  if (reactDir && reactClientEntryPoints.length > 0) {
14603
- rmSync2(join22(buildPath, "react", "generated", "indexes"), {
14751
+ rmSync2(join23(buildPath, "react", "generated", "indexes"), {
14604
14752
  force: true,
14605
14753
  recursive: true
14606
14754
  });
14607
14755
  }
14608
14756
  if (angularDir && angularClientPaths.length > 0) {
14609
- rmSync2(join22(buildPath, "angular", "indexes"), {
14757
+ rmSync2(join23(buildPath, "angular", "indexes"), {
14610
14758
  force: true,
14611
14759
  recursive: true
14612
14760
  });
14613
14761
  }
14614
14762
  if (islandClientEntryPoints.length > 0) {
14615
- rmSync2(join22(buildPath, "islands"), {
14763
+ rmSync2(join23(buildPath, "islands"), {
14616
14764
  force: true,
14617
14765
  recursive: true
14618
14766
  });
@@ -14681,7 +14829,7 @@ ${content.slice(firstUseIdx)}`;
14681
14829
  globalCssEntries.length > 0 ? tracePhase("bun/global-css", () => bunBuild7(mergeBunBuildConfig({
14682
14830
  entrypoints: globalCssEntries,
14683
14831
  naming: `[dir]/[name].[hash].[ext]`,
14684
- outdir: stylesDir ? join22(buildPath, basename8(stylesDir)) : buildPath,
14832
+ outdir: stylesDir ? join23(buildPath, basename8(stylesDir)) : buildPath,
14685
14833
  plugins: [stylePreprocessorPlugin2],
14686
14834
  root: stylesDir || clientRoot,
14687
14835
  target: "browser",
@@ -14690,7 +14838,7 @@ ${content.slice(firstUseIdx)}`;
14690
14838
  vueCssPaths.length > 0 ? tracePhase("bun/vue-css", () => bunBuild7(mergeBunBuildConfig({
14691
14839
  entrypoints: vueCssPaths,
14692
14840
  naming: `[name].[hash].[ext]`,
14693
- outdir: join22(buildPath, assetsPath ? basename8(assetsPath) : "assets", "css"),
14841
+ outdir: join23(buildPath, assetsPath ? basename8(assetsPath) : "assets", "css"),
14694
14842
  target: "browser",
14695
14843
  throw: false
14696
14844
  }, resolveBunBuildOverride(bunBuildConfig, "vueCss")))) : undefined
@@ -14747,25 +14895,24 @@ ${content.slice(firstUseIdx)}`;
14747
14895
  ...allNonReactVendorPaths
14748
14896
  };
14749
14897
  if (nonReactClientOutputs.length > 0 && Object.keys(allNonReactVendorPaths).length > 0) {
14750
- const { rewriteImports: rewriteImports2 } = await Promise.resolve().then(() => (init_rewriteImports(), exports_rewriteImports));
14751
- await tracePhase("postprocess/non-react-vendor-imports", () => rewriteImports2(nonReactClientOutputs.map((artifact) => artifact.path), allNonReactVendorPaths));
14898
+ const { rewriteBuildOutputs: rewriteBuildOutputs2 } = await Promise.resolve().then(() => (init_rewriteImportsPlugin(), exports_rewriteImportsPlugin));
14899
+ await tracePhase("postprocess/non-react-vendor-imports", () => rewriteBuildOutputs2(nonReactClientOutputs, allNonReactVendorPaths));
14752
14900
  }
14753
14901
  if (islandClientOutputs.length > 0 && Object.keys(allIslandVendorPaths).length > 0) {
14754
- const { rewriteImports: rewriteImports2 } = await Promise.resolve().then(() => (init_rewriteImports(), exports_rewriteImports));
14755
- await tracePhase("postprocess/island-vendor-imports", () => rewriteImports2(islandClientOutputs.map((artifact) => artifact.path), allIslandVendorPaths));
14902
+ const { rewriteBuildOutputs: rewriteBuildOutputs2 } = await Promise.resolve().then(() => (init_rewriteImportsPlugin(), exports_rewriteImportsPlugin));
14903
+ await tracePhase("postprocess/island-vendor-imports", () => rewriteBuildOutputs2(islandClientOutputs, allIslandVendorPaths));
14756
14904
  }
14757
14905
  if (serverOutputs.length > 0 && angularServerVendorPaths2 && Object.keys(angularServerVendorPaths2).length > 0) {
14758
- const { rewriteImports: rewriteImports2 } = await Promise.resolve().then(() => (init_rewriteImports(), exports_rewriteImports));
14759
- const jsArtifacts = serverOutputs.filter((artifact) => artifact.path.endsWith(".js"));
14760
- await tracePhase("postprocess/server-angular-vendor-imports", () => Promise.all(jsArtifacts.map(async (artifact) => {
14906
+ const { rewriteBuildOutputsWith: rewriteBuildOutputsWith2 } = await Promise.resolve().then(() => (init_rewriteImportsPlugin(), exports_rewriteImportsPlugin));
14907
+ await tracePhase("postprocess/server-angular-vendor-imports", () => rewriteBuildOutputsWith2(serverOutputs, (artifact) => {
14761
14908
  const fileDir = dirname13(artifact.path);
14762
14909
  const relativePaths = {};
14763
14910
  for (const [specifier, absolute] of Object.entries(angularServerVendorPaths2)) {
14764
14911
  const rel = relative10(fileDir, absolute);
14765
14912
  relativePaths[specifier] = rel.startsWith(".") ? rel : `./${rel}`;
14766
14913
  }
14767
- return rewriteImports2([artifact.path], relativePaths);
14768
- })));
14914
+ return relativePaths;
14915
+ }));
14769
14916
  }
14770
14917
  const cssLogs = [
14771
14918
  ...globalCssResult?.logs ?? [],
@@ -14831,19 +14978,19 @@ ${content.slice(firstUseIdx)}`;
14831
14978
  const injectHMRIntoHTMLFile = (filePath, framework) => {
14832
14979
  if (!hmrClientBundle)
14833
14980
  return;
14834
- let html = readFileSync11(filePath, "utf-8");
14981
+ let html = readFileSync12(filePath, "utf-8");
14835
14982
  if (html.includes("data-hmr-client"))
14836
14983
  return;
14837
14984
  const tag = `<script>window.__HMR_FRAMEWORK__="${framework}";</script><script data-hmr-client>${hmrClientBundle}</script>`;
14838
14985
  const bodyClose = /<\/body\s*>/i.exec(html);
14839
14986
  html = bodyClose ? html.slice(0, bodyClose.index) + tag + html.slice(bodyClose.index) : html + tag;
14840
- writeFileSync6(filePath, html);
14987
+ writeFileSync7(filePath, html);
14841
14988
  };
14842
14989
  const processHtmlPages = async () => {
14843
14990
  if (!(htmlDir && htmlPagesPath))
14844
14991
  return;
14845
- const outputHtmlPages = isSingle ? join22(buildPath, "pages") : join22(buildPath, basename8(htmlDir), "pages");
14846
- mkdirSync10(outputHtmlPages, { recursive: true });
14992
+ const outputHtmlPages = isSingle ? join23(buildPath, "pages") : join23(buildPath, basename8(htmlDir), "pages");
14993
+ mkdirSync11(outputHtmlPages, { recursive: true });
14847
14994
  cpSync(htmlPagesPath, outputHtmlPages, {
14848
14995
  force: true,
14849
14996
  recursive: true
@@ -14864,14 +15011,14 @@ ${content.slice(firstUseIdx)}`;
14864
15011
  const processHtmxPages = async () => {
14865
15012
  if (!(htmxDir && htmxPagesPath))
14866
15013
  return;
14867
- const outputHtmxPages = isSingle ? join22(buildPath, "pages") : join22(buildPath, basename8(htmxDir), "pages");
14868
- mkdirSync10(outputHtmxPages, { recursive: true });
15014
+ const outputHtmxPages = isSingle ? join23(buildPath, "pages") : join23(buildPath, basename8(htmxDir), "pages");
15015
+ mkdirSync11(outputHtmxPages, { recursive: true });
14869
15016
  cpSync(htmxPagesPath, outputHtmxPages, {
14870
15017
  force: true,
14871
15018
  recursive: true
14872
15019
  });
14873
15020
  if (shouldCopyHtmx) {
14874
- const htmxDestDir = isSingle ? buildPath : join22(buildPath, basename8(htmxDir));
15021
+ const htmxDestDir = isSingle ? buildPath : join23(buildPath, basename8(htmxDir));
14875
15022
  copyHtmxVendor(htmxDir, htmxDestDir);
14876
15023
  }
14877
15024
  if (shouldUpdateHtmxAssetPaths) {
@@ -14932,9 +15079,9 @@ ${content.slice(firstUseIdx)}`;
14932
15079
  writeBuildTrace(buildPath);
14933
15080
  return { conventions: conventionsMap, manifest };
14934
15081
  }
14935
- writeFileSync6(join22(buildPath, "manifest.json"), JSON.stringify(manifest, null, "\t"));
15082
+ writeFileSync7(join23(buildPath, "manifest.json"), JSON.stringify(manifest, null, "\t"));
14936
15083
  if (Object.keys(conventionsMap).length > 0) {
14937
- writeFileSync6(join22(buildPath, "conventions.json"), JSON.stringify(conventionsMap, null, "\t"));
15084
+ writeFileSync7(join23(buildPath, "conventions.json"), JSON.stringify(conventionsMap, null, "\t"));
14938
15085
  }
14939
15086
  writeBuildTrace(buildPath);
14940
15087
  if (tailwind && mode === "production") {
@@ -15031,9 +15178,9 @@ var init_build = __esm(() => {
15031
15178
  });
15032
15179
 
15033
15180
  // src/build/buildEmberVendor.ts
15034
- import { mkdirSync as mkdirSync11, existsSync as existsSync20 } from "fs";
15035
- import { join as join23 } from "path";
15036
- import { rm as rm10 } from "fs/promises";
15181
+ import { mkdirSync as mkdirSync12, existsSync as existsSync20 } from "fs";
15182
+ import { join as join24 } from "path";
15183
+ import { rm as rm9 } from "fs/promises";
15037
15184
  var {build: bunBuild8 } = globalThis.Bun;
15038
15185
  var toSafeFileName5 = (specifier) => specifier.replace(/^@/, "").replace(/\//g, "_"), generateMacrosShim = () => `// Generated shim for @embroider/macros \u2014 provides minimal runtime
15039
15186
  // implementations for macros that would normally be replaced at
@@ -15084,7 +15231,7 @@ export const importSync = (specifier) => {
15084
15231
  if (standaloneSpecifiers.has(specifier)) {
15085
15232
  return { resolveTo: specifier, specifier };
15086
15233
  }
15087
- const emberInternalPath = join23(cwd2, "node_modules/ember-source/dist/packages", specifier, "index.js");
15234
+ const emberInternalPath = join24(cwd2, "node_modules/ember-source/dist/packages", specifier, "index.js");
15088
15235
  if (!existsSync20(emberInternalPath)) {
15089
15236
  throw new Error(`Ember vendor build: cannot find ${specifier} at ${emberInternalPath}. ` + `Is ember-source installed and at least 6.12?`);
15090
15237
  }
@@ -15116,7 +15263,7 @@ export const importSync = (specifier) => {
15116
15263
  if (standalonePackages.has(args.path)) {
15117
15264
  return;
15118
15265
  }
15119
- const internal = join23(cwd2, "node_modules/ember-source/dist/packages", args.path, "index.js");
15266
+ const internal = join24(cwd2, "node_modules/ember-source/dist/packages", args.path, "index.js");
15120
15267
  if (existsSync20(internal)) {
15121
15268
  return { path: internal };
15122
15269
  }
@@ -15124,16 +15271,16 @@ export const importSync = (specifier) => {
15124
15271
  });
15125
15272
  }
15126
15273
  }), buildEmberVendor = async (buildDir, cwd2 = process.cwd()) => {
15127
- const vendorDir = join23(buildDir, "ember", "vendor");
15128
- mkdirSync11(vendorDir, { recursive: true });
15129
- const tmpDir = join23(buildDir, "_ember_vendor_tmp");
15130
- mkdirSync11(tmpDir, { recursive: true });
15131
- const macrosShimPath = join23(tmpDir, "embroider_macros_shim.js");
15274
+ const vendorDir = join24(buildDir, "ember", "vendor");
15275
+ mkdirSync12(vendorDir, { recursive: true });
15276
+ const tmpDir = join24(buildDir, "_ember_vendor_tmp");
15277
+ mkdirSync12(tmpDir, { recursive: true });
15278
+ const macrosShimPath = join24(tmpDir, "embroider_macros_shim.js");
15132
15279
  await Bun.write(macrosShimPath, generateMacrosShim());
15133
15280
  const resolutions = REQUIRED_EMBER_SPECIFIERS.map((specifier) => resolveEmberSpecifier(specifier, cwd2));
15134
15281
  const entrypoints = await Promise.all(resolutions.map(async (resolution) => {
15135
15282
  const safeName = toSafeFileName5(resolution.specifier);
15136
- const entryPath = join23(tmpDir, `${safeName}.js`);
15283
+ const entryPath = join24(tmpDir, `${safeName}.js`);
15137
15284
  const source = resolution.specifier === "@embroider/macros" ? `export * from ${JSON.stringify(macrosShimPath)};
15138
15285
  ` : generateVendorEntrySource2(resolution);
15139
15286
  await Bun.write(entryPath, source);
@@ -15150,7 +15297,7 @@ export const importSync = (specifier) => {
15150
15297
  target: "browser",
15151
15298
  throw: false
15152
15299
  });
15153
- await rm10(tmpDir, { force: true, recursive: true });
15300
+ await rm9(tmpDir, { force: true, recursive: true });
15154
15301
  if (!result.success) {
15155
15302
  console.warn("\u26A0\uFE0F Ember vendor build had errors:", result.logs);
15156
15303
  }
@@ -15177,7 +15324,7 @@ var init_buildEmberVendor = __esm(() => {
15177
15324
  });
15178
15325
 
15179
15326
  // src/dev/dependencyGraph.ts
15180
- import { existsSync as existsSync21, readFileSync as readFileSync12 } from "fs";
15327
+ import { existsSync as existsSync21, readFileSync as readFileSync13 } from "fs";
15181
15328
  var {Glob: Glob8 } = globalThis.Bun;
15182
15329
  import { resolve as resolve20 } from "path";
15183
15330
  var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath) => {
@@ -15338,15 +15485,15 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
15338
15485
  const lowerPath = filePath.toLowerCase();
15339
15486
  const isSvelteOrVue = lowerPath.endsWith(".svelte") || lowerPath.endsWith(".vue");
15340
15487
  if (loader === "html") {
15341
- const content = readFileSync12(filePath, "utf-8");
15488
+ const content = readFileSync13(filePath, "utf-8");
15342
15489
  return extractHtmlDependencies(filePath, content);
15343
15490
  }
15344
15491
  if (loader === "tsx" || loader === "js") {
15345
- const content = readFileSync12(filePath, "utf-8");
15492
+ const content = readFileSync13(filePath, "utf-8");
15346
15493
  return extractJsDependencies(filePath, content, loader);
15347
15494
  }
15348
15495
  if (isSvelteOrVue) {
15349
- const content = readFileSync12(filePath, "utf-8");
15496
+ const content = readFileSync13(filePath, "utf-8");
15350
15497
  return extractSvelteVueDependencies(filePath, content);
15351
15498
  }
15352
15499
  return [];
@@ -15497,7 +15644,8 @@ var init_clientManager = __esm(() => {
15497
15644
  });
15498
15645
 
15499
15646
  // src/dev/pathUtils.ts
15500
- import { readdirSync } from "fs";
15647
+ import { existsSync as existsSync22 } from "fs";
15648
+ import { resolve as resolve22 } from "path";
15501
15649
  var STYLE_EXTENSION_PATTERN2, detectFramework = (filePath, resolved) => {
15502
15650
  if (shouldIgnorePath(filePath, resolved)) {
15503
15651
  return "ignored";
@@ -15571,28 +15719,15 @@ var STYLE_EXTENSION_PATTERN2, detectFramework = (filePath, resolved) => {
15571
15719
  return "assets";
15572
15720
  }
15573
15721
  return "unknown";
15574
- }, getSiblingDirs = (frameworkDirs, cfg) => {
15575
- if (frameworkDirs.length === 0)
15576
- return [];
15577
- const root = commonAncestor(frameworkDirs);
15578
- if (!root)
15579
- return [];
15580
- const knownNames = new Set([...frameworkDirs, cfg.assetsDir, cfg.stylesDir].filter((dir) => Boolean(dir)).map((dir) => normalizePath(dir).split("/").pop()));
15581
- knownNames.add("build");
15582
- knownNames.add("node_modules");
15583
- knownNames.add(".absolutejs");
15584
- try {
15585
- return readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !knownNames.has(entry.name)).map((entry) => `${root}/${entry.name}`);
15586
- } catch {
15587
- return [];
15588
- }
15589
- }, getWatchPaths = (config, resolved) => {
15590
- const paths = [];
15591
- const push = (base, sub) => {
15592
- if (!base)
15722
+ }, collectPositiveWatchRoots = (config, resolved) => {
15723
+ const cwd2 = process.cwd();
15724
+ const roots = [];
15725
+ const push = (path) => {
15726
+ if (!path)
15593
15727
  return;
15594
- const normalizedBase = normalizePath(base);
15595
- paths.push(sub ? `${normalizedBase}/${sub}` : normalizedBase);
15728
+ const abs = normalizePath(resolve22(cwd2, path));
15729
+ if (!roots.includes(abs))
15730
+ roots.push(abs);
15596
15731
  };
15597
15732
  const cfg = resolved ?? {
15598
15733
  angularDir: config.angularDirectory,
@@ -15610,44 +15745,76 @@ var STYLE_EXTENSION_PATTERN2, detectFramework = (filePath, resolved) => {
15610
15745
  push(cfg.vueDir);
15611
15746
  push(cfg.emberDir);
15612
15747
  push(cfg.angularDir);
15613
- push(cfg.htmlDir, "pages");
15614
- push(cfg.htmlDir, "scripts");
15615
- push(cfg.htmlDir, "styles");
15616
- push(cfg.htmxDir, "pages");
15617
- push(cfg.htmxDir, "scripts");
15618
- push(cfg.htmxDir, "styles");
15748
+ push(cfg.htmlDir);
15749
+ push(cfg.htmxDir);
15619
15750
  push(cfg.assetsDir);
15620
15751
  push(cfg.stylesDir);
15621
- const frameworkDirs = [
15622
- cfg.reactDir,
15623
- cfg.svelteDir,
15624
- cfg.vueDir,
15625
- cfg.angularDir,
15626
- cfg.emberDir,
15627
- cfg.htmlDir,
15628
- cfg.htmxDir
15629
- ].filter((dir) => Boolean(dir)).map(normalizePath);
15630
- for (const siblingPath of getSiblingDirs(frameworkDirs, cfg)) {
15631
- push(siblingPath);
15752
+ for (const candidate of ["src", "db", "assets", "styles"]) {
15753
+ const abs = normalizePath(resolve22(cwd2, candidate));
15754
+ if (existsSync22(abs) && !roots.includes(abs))
15755
+ roots.push(abs);
15756
+ }
15757
+ const extraDirs = config.dev?.watchDirs ?? [];
15758
+ for (const dir of extraDirs)
15759
+ push(dir);
15760
+ return roots;
15761
+ }, getWatchPaths = (config, resolved) => {
15762
+ const roots = collectPositiveWatchRoots(config, resolved);
15763
+ const paths = [];
15764
+ const push = (base, sub) => {
15765
+ if (!base)
15766
+ return;
15767
+ const normalizedBase = normalizePath(base);
15768
+ paths.push(sub ? `${normalizedBase}/${sub}` : normalizedBase);
15769
+ };
15770
+ const cfg = resolved ?? {
15771
+ htmlDir: config.htmlDirectory,
15772
+ htmxDir: config.htmxDirectory
15773
+ };
15774
+ if (cfg.htmlDir) {
15775
+ push(cfg.htmlDir, "pages");
15776
+ push(cfg.htmlDir, "scripts");
15777
+ push(cfg.htmlDir, "styles");
15778
+ }
15779
+ if (cfg.htmxDir) {
15780
+ push(cfg.htmxDir, "pages");
15781
+ push(cfg.htmxDir, "scripts");
15782
+ push(cfg.htmxDir, "styles");
15783
+ }
15784
+ for (const root of roots) {
15785
+ if (root === normalizePath(cfg.htmlDir ?? ""))
15786
+ continue;
15787
+ if (root === normalizePath(cfg.htmxDir ?? ""))
15788
+ continue;
15789
+ paths.push(root);
15632
15790
  }
15633
15791
  return paths;
15634
- }, shouldIgnorePath = (path, resolved) => {
15635
- const normalizedPath = path.replace(/\\/g, "/");
15636
- if (resolved?.stylesDir && normalizedPath.startsWith(resolved.stylesDir)) {
15637
- return false;
15792
+ }, HARD_DENY_PATTERN, shouldIgnorePath = (path, resolved) => {
15793
+ const normalized = path.replace(/\\/g, "/");
15794
+ if (resolved?.stylesDir) {
15795
+ const styles = normalized.startsWith(resolved.stylesDir.replace(/\\/g, "/"));
15796
+ if (styles)
15797
+ return false;
15638
15798
  }
15639
- const managedDirPattern = /(^|\/)(build|generated|\.absolutejs|node_modules|\.git)(\/|$)/;
15640
- return managedDirPattern.test(normalizedPath) || normalizedPath.endsWith(".log") || normalizedPath.endsWith(".tmp");
15799
+ if (HARD_DENY_PATTERN.test(normalized))
15800
+ return true;
15801
+ if (normalized.endsWith(".log"))
15802
+ return true;
15803
+ if (normalized.endsWith(".tmp"))
15804
+ return true;
15805
+ if (normalized.endsWith("~"))
15806
+ return true;
15807
+ return false;
15641
15808
  };
15642
15809
  var init_pathUtils = __esm(() => {
15643
- init_commonAncestor();
15644
15810
  STYLE_EXTENSION_PATTERN2 = /\.(css|s[ac]ss|less|styl(?:us)?)$/i;
15811
+ HARD_DENY_PATTERN = /(^|\/)(build|generated|compiled|indexes|\.absolutejs|node_modules|\.git|\.test-builds|dist)(\/|$)/;
15645
15812
  });
15646
15813
 
15647
15814
  // src/dev/fileWatcher.ts
15648
15815
  import { watch } from "fs";
15649
- import { existsSync as existsSync22 } from "fs";
15650
- import { join as join24, resolve as resolve22 } from "path";
15816
+ import { existsSync as existsSync23 } from "fs";
15817
+ import { join as join25, resolve as resolve23 } from "path";
15651
15818
  var safeRemoveFromGraph = (graph, fullPath) => {
15652
15819
  try {
15653
15820
  removeFileFromGraph(graph, fullPath);
@@ -15674,16 +15841,16 @@ var safeRemoveFromGraph = (graph, fullPath) => {
15674
15841
  if (shouldSkipFilename(filename, isStylesDir)) {
15675
15842
  return;
15676
15843
  }
15677
- const fullPath = join24(absolutePath, filename).replace(/\\/g, "/");
15844
+ const fullPath = join25(absolutePath, filename).replace(/\\/g, "/");
15678
15845
  if (shouldIgnorePath(fullPath, state.resolvedPaths)) {
15679
15846
  return;
15680
15847
  }
15681
- if (event === "rename" && !existsSync22(fullPath)) {
15848
+ if (event === "rename" && !existsSync23(fullPath)) {
15682
15849
  safeRemoveFromGraph(state.dependencyGraph, fullPath);
15683
15850
  onFileChange(fullPath);
15684
15851
  return;
15685
15852
  }
15686
- if (existsSync22(fullPath)) {
15853
+ if (existsSync23(fullPath)) {
15687
15854
  onFileChange(fullPath);
15688
15855
  safeAddToGraph(state.dependencyGraph, fullPath);
15689
15856
  }
@@ -15692,8 +15859,8 @@ var safeRemoveFromGraph = (graph, fullPath) => {
15692
15859
  }, addFileWatchers = (state, paths, onFileChange) => {
15693
15860
  const stylesDir = state.resolvedPaths?.stylesDir;
15694
15861
  paths.forEach((path) => {
15695
- const absolutePath = resolve22(path).replace(/\\/g, "/");
15696
- if (!existsSync22(absolutePath)) {
15862
+ const absolutePath = resolve23(path).replace(/\\/g, "/");
15863
+ if (!existsSync23(absolutePath)) {
15697
15864
  return;
15698
15865
  }
15699
15866
  const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
@@ -15703,8 +15870,8 @@ var safeRemoveFromGraph = (graph, fullPath) => {
15703
15870
  const watchPaths = getWatchPaths(config, state.resolvedPaths);
15704
15871
  const stylesDir = state.resolvedPaths?.stylesDir;
15705
15872
  watchPaths.forEach((path) => {
15706
- const absolutePath = resolve22(path).replace(/\\/g, "/");
15707
- if (!existsSync22(absolutePath)) {
15873
+ const absolutePath = resolve23(path).replace(/\\/g, "/");
15874
+ if (!existsSync23(absolutePath)) {
15708
15875
  return;
15709
15876
  }
15710
15877
  const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
@@ -15718,13 +15885,13 @@ var init_fileWatcher = __esm(() => {
15718
15885
  });
15719
15886
 
15720
15887
  // src/dev/assetStore.ts
15721
- import { resolve as resolve23 } from "path";
15722
- import { readdir as readdir3, unlink } from "fs/promises";
15888
+ import { resolve as resolve24 } from "path";
15889
+ import { readdir as readdir4, unlink } from "fs/promises";
15723
15890
  var mimeTypes, getMimeType = (filePath) => {
15724
15891
  const ext = filePath.slice(filePath.lastIndexOf("."));
15725
15892
  return mimeTypes[ext] ?? "application/octet-stream";
15726
15893
  }, HASHED_FILE_RE, stripHash = (webPath) => webPath.replace(/\.[a-z0-9]{8}(\.(js|css|mjs))$/, "$1"), processWalkEntry = (entry, dir, liveByIdentity, walkAndClean) => {
15727
- const fullPath = resolve23(dir, entry.name);
15894
+ const fullPath = resolve24(dir, entry.name);
15728
15895
  if (entry.isDirectory()) {
15729
15896
  return walkAndClean(fullPath);
15730
15897
  }
@@ -15740,10 +15907,10 @@ var mimeTypes, getMimeType = (filePath) => {
15740
15907
  }, cleanStaleAssets = async (store, manifest, buildDir) => {
15741
15908
  const liveByIdentity = new Map;
15742
15909
  for (const webPath of store.keys()) {
15743
- const diskPath = resolve23(buildDir, webPath.slice(1));
15910
+ const diskPath = resolve24(buildDir, webPath.slice(1));
15744
15911
  liveByIdentity.set(stripHash(diskPath), diskPath);
15745
15912
  }
15746
- const absBuildDir = resolve23(buildDir);
15913
+ const absBuildDir = resolve24(buildDir);
15747
15914
  Object.values(manifest).forEach((val) => {
15748
15915
  if (!HASHED_FILE_RE.test(val))
15749
15916
  return;
@@ -15753,7 +15920,7 @@ var mimeTypes, getMimeType = (filePath) => {
15753
15920
  });
15754
15921
  try {
15755
15922
  const walkAndClean = async (dir) => {
15756
- const entries = await readdir3(dir, { withFileTypes: true });
15923
+ const entries = await readdir4(dir, { withFileTypes: true });
15757
15924
  const tasks = entries.map((entry) => processWalkEntry(entry, dir, liveByIdentity, walkAndClean)).filter((task) => task !== null);
15758
15925
  await Promise.all(tasks);
15759
15926
  };
@@ -15761,7 +15928,7 @@ var mimeTypes, getMimeType = (filePath) => {
15761
15928
  } catch {}
15762
15929
  }, lookupAsset = (store, path) => store.get(path), processScanEntry = (entry, dir, prefix, store, scanDir) => {
15763
15930
  if (entry.isDirectory()) {
15764
- return scanDir(resolve23(dir, entry.name), `${prefix}${entry.name}/`);
15931
+ return scanDir(resolve24(dir, entry.name), `${prefix}${entry.name}/`);
15765
15932
  }
15766
15933
  if (!entry.name.startsWith("chunk-")) {
15767
15934
  return null;
@@ -15770,7 +15937,7 @@ var mimeTypes, getMimeType = (filePath) => {
15770
15937
  if (store.has(webPath)) {
15771
15938
  return null;
15772
15939
  }
15773
- return Bun.file(resolve23(dir, entry.name)).bytes().then((bytes) => {
15940
+ return Bun.file(resolve24(dir, entry.name)).bytes().then((bytes) => {
15774
15941
  store.set(webPath, bytes);
15775
15942
  return;
15776
15943
  }).catch(() => {});
@@ -15792,14 +15959,14 @@ var mimeTypes, getMimeType = (filePath) => {
15792
15959
  for (const webPath of newIdentities.values()) {
15793
15960
  if (store.has(webPath))
15794
15961
  continue;
15795
- loadPromises.push(Bun.file(resolve23(buildDir, webPath.slice(1))).bytes().then((bytes) => {
15962
+ loadPromises.push(Bun.file(resolve24(buildDir, webPath.slice(1))).bytes().then((bytes) => {
15796
15963
  store.set(webPath, bytes);
15797
15964
  return;
15798
15965
  }).catch(() => {}));
15799
15966
  }
15800
15967
  try {
15801
15968
  const scanDir = async (dir, prefix) => {
15802
- const entries = await readdir3(dir, { withFileTypes: true });
15969
+ const entries = await readdir4(dir, { withFileTypes: true });
15803
15970
  const subTasks = entries.map((entry) => processScanEntry(entry, dir, prefix, store, scanDir)).filter((task) => task !== null);
15804
15971
  await Promise.all(subTasks);
15805
15972
  };
@@ -15822,8 +15989,8 @@ var init_assetStore = __esm(() => {
15822
15989
  });
15823
15990
 
15824
15991
  // src/islands/pageMetadata.ts
15825
- import { readFileSync as readFileSync13 } from "fs";
15826
- import { dirname as dirname14, resolve as resolve24 } from "path";
15992
+ import { readFileSync as readFileSync14 } from "fs";
15993
+ import { dirname as dirname14, resolve as resolve25 } from "path";
15827
15994
  var pagePatterns, getPageDirs = (config) => [
15828
15995
  { dir: config.angularDirectory, framework: "angular" },
15829
15996
  { dir: config.emberDirectory, framework: "ember" },
@@ -15843,15 +16010,15 @@ var pagePatterns, getPageDirs = (config) => [
15843
16010
  const source = definition.buildReference?.source;
15844
16011
  if (!source)
15845
16012
  continue;
15846
- const resolvedSource = source.startsWith("file://") ? new URL(source).pathname : resolve24(dirname14(buildInfo.resolvedRegistryPath), source);
15847
- lookup.set(`${definition.framework}:${definition.component}`, resolve24(resolvedSource));
16013
+ const resolvedSource = source.startsWith("file://") ? new URL(source).pathname : resolve25(dirname14(buildInfo.resolvedRegistryPath), source);
16014
+ lookup.set(`${definition.framework}:${definition.component}`, resolve25(resolvedSource));
15848
16015
  }
15849
16016
  return lookup;
15850
16017
  }, getCurrentPageIslandMetadata = () => globalThis.__absolutePageIslandMetadata ?? new Map, metadataUsesSource = (metadata, target) => metadata.islands.some((usage) => {
15851
16018
  const candidate = usage.source;
15852
- return candidate ? resolve24(candidate) === target : false;
16019
+ return candidate ? resolve25(candidate) === target : false;
15853
16020
  }), getPagesUsingIslandSource = (sourcePath) => {
15854
- const target = resolve24(sourcePath);
16021
+ const target = resolve25(sourcePath);
15855
16022
  return [...getCurrentPageIslandMetadata().values()].filter((metadata) => metadataUsesSource(metadata, target)).map((metadata) => metadata.pagePath);
15856
16023
  }, resolveIslandUsages = (islands, islandSourceLookup) => islands.map((usage) => {
15857
16024
  const sourcePath = islandSourceLookup.get(`${usage.framework}:${usage.component}`);
@@ -15863,13 +16030,13 @@ var pagePatterns, getPageDirs = (config) => [
15863
16030
  const pattern = pagePatterns[entry.framework];
15864
16031
  if (!pattern)
15865
16032
  return;
15866
- const files = await scanEntryPoints(resolve24(entry.dir), pattern);
16033
+ const files = await scanEntryPoints(resolve25(entry.dir), pattern);
15867
16034
  for (const filePath of files) {
15868
- const source = readFileSync13(filePath, "utf-8");
16035
+ const source = readFileSync14(filePath, "utf-8");
15869
16036
  const islands = extractIslandUsagesFromSource(source);
15870
- pageMetadata.set(resolve24(filePath), {
16037
+ pageMetadata.set(resolve25(filePath), {
15871
16038
  islands: resolveIslandUsages(islands, islandSourceLookup),
15872
- pagePath: resolve24(filePath)
16039
+ pagePath: resolve25(filePath)
15873
16040
  });
15874
16041
  }
15875
16042
  }, loadPageIslandMetadata = async (config) => {
@@ -15896,10 +16063,10 @@ var init_pageMetadata = __esm(() => {
15896
16063
  });
15897
16064
 
15898
16065
  // src/dev/fileHashTracker.ts
15899
- import { readFileSync as readFileSync14 } from "fs";
16066
+ import { readFileSync as readFileSync15 } from "fs";
15900
16067
  var computeFileHash = (filePath) => {
15901
16068
  try {
15902
- const fileContent = readFileSync14(filePath);
16069
+ const fileContent = readFileSync15(filePath);
15903
16070
  return Number(Bun.hash(fileContent));
15904
16071
  } catch {
15905
16072
  return UNFOUND_INDEX;
@@ -15979,9 +16146,9 @@ var init_transformCache = __esm(() => {
15979
16146
  });
15980
16147
 
15981
16148
  // src/dev/reactComponentClassifier.ts
15982
- import { resolve as resolve25 } from "path";
16149
+ import { resolve as resolve26 } from "path";
15983
16150
  var classifyComponent = (filePath) => {
15984
- const normalizedPath = resolve25(filePath);
16151
+ const normalizedPath = resolve26(filePath);
15985
16152
  if (normalizedPath.includes("/react/pages/")) {
15986
16153
  return "server";
15987
16154
  }
@@ -15993,7 +16160,7 @@ var classifyComponent = (filePath) => {
15993
16160
  var init_reactComponentClassifier = () => {};
15994
16161
 
15995
16162
  // src/dev/moduleMapper.ts
15996
- import { basename as basename9, resolve as resolve26 } from "path";
16163
+ import { basename as basename9, resolve as resolve27 } from "path";
15997
16164
  var buildModulePaths = (moduleKeys, manifest) => {
15998
16165
  const modulePaths = {};
15999
16166
  moduleKeys.forEach((key) => {
@@ -16003,7 +16170,7 @@ var buildModulePaths = (moduleKeys, manifest) => {
16003
16170
  });
16004
16171
  return modulePaths;
16005
16172
  }, processChangedFile = (sourceFile, framework, manifest, resolvedPaths, processedFiles) => {
16006
- const normalizedFile = resolve26(sourceFile);
16173
+ const normalizedFile = resolve27(sourceFile);
16007
16174
  const normalizedPath = normalizedFile.replace(/\\/g, "/");
16008
16175
  if (processedFiles.has(normalizedFile)) {
16009
16176
  return null;
@@ -16039,7 +16206,7 @@ var buildModulePaths = (moduleKeys, manifest) => {
16039
16206
  });
16040
16207
  return grouped;
16041
16208
  }, mapSourceFileToManifestKeys = (sourceFile, framework, resolvedPaths) => {
16042
- const normalizedFile = resolve26(sourceFile);
16209
+ const normalizedFile = resolve27(sourceFile);
16043
16210
  const fileName = basename9(normalizedFile);
16044
16211
  const baseName = fileName.replace(/\.(tsx?|jsx?|vue|svelte|css|html)$/, "");
16045
16212
  const pascalName = toPascal(baseName);
@@ -16221,6 +16388,239 @@ var init_ssrCache = __esm(() => {
16221
16388
  dirtyFrameworks = new Set;
16222
16389
  });
16223
16390
 
16391
+ // src/dev/angular/editTypeDetection.ts
16392
+ import { readFileSync as readFileSync16 } from "fs";
16393
+ import { basename as basename10 } from "path";
16394
+ import * as ts3 from "typescript";
16395
+ var TYPE_PRIORITY, STYLE_EXT_RE, COMPONENT_STYLE_RE, TEMPLATE_RE, COMPONENT_CLASS_RE, SERVICE_RE, ROUTES_RE, SIDE_EFFECT_CALL_NAMES, SIDE_EFFECT_NEW_NAMES, getCalleeName = (node) => {
16396
+ const callee = node.expression;
16397
+ if (ts3.isIdentifier(callee))
16398
+ return callee.text;
16399
+ if (ts3.isPropertyAccessExpression(callee))
16400
+ return callee.name.text;
16401
+ return null;
16402
+ }, getNewExprName = (node) => {
16403
+ const callee = node.expression;
16404
+ if (ts3.isIdentifier(callee))
16405
+ return callee.text;
16406
+ if (ts3.isPropertyAccessExpression(callee))
16407
+ return callee.name.text;
16408
+ return null;
16409
+ }, collectMethodBodies = (cls) => {
16410
+ const methods = new Map;
16411
+ cls.members.forEach((member) => {
16412
+ if (!member.name || !ts3.isIdentifier(member.name))
16413
+ return;
16414
+ if (ts3.isMethodDeclaration(member) && member.body) {
16415
+ methods.set(member.name.text, member.body);
16416
+ return;
16417
+ }
16418
+ if (ts3.isPropertyDeclaration(member) && member.initializer) {
16419
+ const init = member.initializer;
16420
+ if (ts3.isArrowFunction(init) || ts3.isFunctionExpression(init)) {
16421
+ methods.set(member.name.text, init.body);
16422
+ }
16423
+ }
16424
+ });
16425
+ return methods;
16426
+ }, findSideEffectInBody = (body, methods, visited) => {
16427
+ let hit = { found: false };
16428
+ const walk = (node) => {
16429
+ if (hit.found)
16430
+ return;
16431
+ if (ts3.isCallExpression(node)) {
16432
+ const name = getCalleeName(node);
16433
+ if (name && SIDE_EFFECT_CALL_NAMES.has(name)) {
16434
+ hit = {
16435
+ found: true,
16436
+ reason: `constructor invokes ${name}(...)`
16437
+ };
16438
+ return;
16439
+ }
16440
+ if (name && methods.has(name) && !visited.has(name)) {
16441
+ visited.add(name);
16442
+ const target = methods.get(name);
16443
+ if (target) {
16444
+ const inner = findSideEffectInBody(target, methods, visited);
16445
+ if (inner.found) {
16446
+ hit = {
16447
+ found: true,
16448
+ reason: `${inner.reason} (via this.${name}())`
16449
+ };
16450
+ return;
16451
+ }
16452
+ }
16453
+ }
16454
+ }
16455
+ if (ts3.isNewExpression(node)) {
16456
+ const name = getNewExprName(node);
16457
+ if (name && SIDE_EFFECT_NEW_NAMES.has(name)) {
16458
+ hit = {
16459
+ found: true,
16460
+ reason: `constructor instantiates new ${name}(...)`
16461
+ };
16462
+ return;
16463
+ }
16464
+ }
16465
+ ts3.forEachChild(node, walk);
16466
+ };
16467
+ walk(body);
16468
+ return hit;
16469
+ }, analyzeServiceFile = (file4) => {
16470
+ let source;
16471
+ try {
16472
+ source = readFileSync16(file4, "utf8");
16473
+ } catch {
16474
+ return {
16475
+ hasSideEffectCtor: true,
16476
+ reason: "service file unreadable \u2014 defaulting to reboot"
16477
+ };
16478
+ }
16479
+ const sf = ts3.createSourceFile(file4, source, ts3.ScriptTarget.Latest, true);
16480
+ let result = {
16481
+ hasSideEffectCtor: false,
16482
+ reason: "constructor has no side-effecting calls"
16483
+ };
16484
+ const visit = (node) => {
16485
+ if (result.hasSideEffectCtor)
16486
+ return;
16487
+ if (!ts3.isClassDeclaration(node)) {
16488
+ ts3.forEachChild(node, visit);
16489
+ return;
16490
+ }
16491
+ const methods = collectMethodBodies(node);
16492
+ const ctor = node.members.find(ts3.isConstructorDeclaration);
16493
+ const targets = [];
16494
+ if (ctor?.body)
16495
+ targets.push(ctor.body);
16496
+ node.members.forEach((member) => {
16497
+ if (ts3.isPropertyDeclaration(member) && member.initializer) {
16498
+ targets.push(member.initializer);
16499
+ }
16500
+ });
16501
+ for (const target of targets) {
16502
+ const r = findSideEffectInBody(target, methods, new Set);
16503
+ if (r.found) {
16504
+ result = { hasSideEffectCtor: true, reason: r.reason };
16505
+ break;
16506
+ }
16507
+ }
16508
+ if (!result.hasSideEffectCtor)
16509
+ ts3.forEachChild(node, visit);
16510
+ };
16511
+ visit(sf);
16512
+ return result;
16513
+ }, classifyAngularEdit = (file4) => {
16514
+ const base = basename10(file4);
16515
+ if (TEMPLATE_RE.test(file4)) {
16516
+ return {
16517
+ type: "template",
16518
+ reason: `${base} \u2014 template edit`,
16519
+ sourceFile: file4
16520
+ };
16521
+ }
16522
+ if (COMPONENT_STYLE_RE.test(file4)) {
16523
+ return {
16524
+ type: "style-component",
16525
+ reason: `${base} \u2014 component-scoped stylesheet edit`,
16526
+ sourceFile: file4
16527
+ };
16528
+ }
16529
+ if (STYLE_EXT_RE.test(file4)) {
16530
+ return {
16531
+ type: "reboot",
16532
+ reason: `${base} \u2014 non-component-named stylesheet, falling back to reboot until scoping is verified`,
16533
+ sourceFile: file4
16534
+ };
16535
+ }
16536
+ if (ROUTES_RE.test(file4)) {
16537
+ return {
16538
+ type: "route",
16539
+ reason: `${base} \u2014 router config, requires reboot`,
16540
+ sourceFile: file4
16541
+ };
16542
+ }
16543
+ if (SERVICE_RE.test(file4)) {
16544
+ const a = analyzeServiceFile(file4);
16545
+ if (a.hasSideEffectCtor) {
16546
+ return {
16547
+ type: "service-with-side-effects",
16548
+ reason: `${base} \u2014 ${a.reason}`,
16549
+ sourceFile: file4
16550
+ };
16551
+ }
16552
+ return {
16553
+ type: "service-method-only",
16554
+ reason: `${base} \u2014 ${a.reason}`,
16555
+ sourceFile: file4
16556
+ };
16557
+ }
16558
+ if (COMPONENT_CLASS_RE.test(file4)) {
16559
+ return {
16560
+ type: "class-component",
16561
+ reason: `${base} \u2014 component class edit`,
16562
+ sourceFile: file4
16563
+ };
16564
+ }
16565
+ return {
16566
+ type: "reboot",
16567
+ reason: `${base} \u2014 unrecognized angular file type, falling back to reboot`,
16568
+ sourceFile: file4
16569
+ };
16570
+ }, collapseClassifications = (classifications) => {
16571
+ if (classifications.length === 0) {
16572
+ return {
16573
+ type: "reboot",
16574
+ reason: "no classifiable files in batch",
16575
+ sourceFile: ""
16576
+ };
16577
+ }
16578
+ let winner = classifications[0];
16579
+ for (let i = 1;i < classifications.length; i++) {
16580
+ const candidate = classifications[i];
16581
+ if (TYPE_PRIORITY[candidate.type] > TYPE_PRIORITY[winner.type]) {
16582
+ winner = candidate;
16583
+ }
16584
+ }
16585
+ return winner;
16586
+ };
16587
+ var init_editTypeDetection = __esm(() => {
16588
+ TYPE_PRIORITY = {
16589
+ template: 0,
16590
+ "style-component": 1,
16591
+ "service-method-only": 2,
16592
+ "class-component": 3,
16593
+ "service-with-side-effects": 4,
16594
+ route: 5,
16595
+ reboot: 6
16596
+ };
16597
+ STYLE_EXT_RE = /\.(css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
16598
+ COMPONENT_STYLE_RE = /\.component\.(css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
16599
+ TEMPLATE_RE = /\.html$/i;
16600
+ COMPONENT_CLASS_RE = /\.component\.ts$/i;
16601
+ SERVICE_RE = /\.service\.ts$/i;
16602
+ ROUTES_RE = /(?:^|[\\/])(?:app\.)?routes\.ts$/i;
16603
+ SIDE_EFFECT_CALL_NAMES = new Set([
16604
+ "subscribe",
16605
+ "setInterval",
16606
+ "setTimeout",
16607
+ "addEventListener",
16608
+ "effect",
16609
+ "afterNextRender",
16610
+ "afterRender",
16611
+ "afterEveryRender",
16612
+ "requestAnimationFrame",
16613
+ "requestIdleCallback"
16614
+ ]);
16615
+ SIDE_EFFECT_NEW_NAMES = new Set([
16616
+ "Worker",
16617
+ "SharedWorker",
16618
+ "EventSource",
16619
+ "WebSocket",
16620
+ "BroadcastChannel"
16621
+ ]);
16622
+ });
16623
+
16224
16624
  // src/dev/moduleServer.ts
16225
16625
  var exports_moduleServer = {};
16226
16626
  __export(exports_moduleServer, {
@@ -16232,8 +16632,8 @@ __export(exports_moduleServer, {
16232
16632
  createModuleServer: () => createModuleServer,
16233
16633
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
16234
16634
  });
16235
- import { existsSync as existsSync23, readFileSync as readFileSync15, statSync as statSync2 } from "fs";
16236
- import { basename as basename10, dirname as dirname15, extname as extname8, join as join25, resolve as resolve27, relative as relative11 } from "path";
16635
+ import { existsSync as existsSync24, readFileSync as readFileSync17, statSync as statSync2 } from "fs";
16636
+ import { basename as basename11, dirname as dirname15, extname as extname8, join as join26, resolve as resolve28, relative as relative11 } from "path";
16237
16637
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
16238
16638
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
16239
16639
  const allExports = [];
@@ -16253,7 +16653,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPIL
16253
16653
  ${stubs}
16254
16654
  `;
16255
16655
  }, resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
16256
- const found = extensions.find((ext) => existsSync23(resolve27(projectRoot, srcPath + ext)));
16656
+ const found = extensions.find((ext) => existsSync24(resolve28(projectRoot, srcPath + ext)));
16257
16657
  return found ? srcPath + found : srcPath;
16258
16658
  }, IMPORT_EXTENSIONS, SIDE_EFFECT_EXTENSIONS, MODULE_EXTENSIONS, RESOLVED_MODULE_EXTENSIONS, REACT_EXTENSIONS, escapeRegex3 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), buildImportRewriter = (vendorPaths) => {
16259
16659
  const entries = Object.entries(vendorPaths).sort(([a], [b2]) => b2.length - a.length);
@@ -16268,7 +16668,7 @@ ${stubs}
16268
16668
  return invalidationVersion > 0 ? `${mtime}.${invalidationVersion}` : `${mtime}`;
16269
16669
  }, srcUrl = (relPath, projectRoot) => {
16270
16670
  const base = `${SRC_PREFIX}${relPath.replace(/\\/g, "/")}`;
16271
- const absPath = resolve27(projectRoot, relPath);
16671
+ const absPath = resolve28(projectRoot, relPath);
16272
16672
  const cached = mtimeCache.get(absPath);
16273
16673
  if (cached !== undefined)
16274
16674
  return `${base}?v=${buildVersion(cached, absPath)}`;
@@ -16280,12 +16680,12 @@ ${stubs}
16280
16680
  return base;
16281
16681
  }
16282
16682
  }, resolveRelativeImport = (relPath, fileDir, projectRoot, extensions) => {
16283
- const absPath = resolve27(fileDir, relPath);
16683
+ const absPath = resolve28(fileDir, relPath);
16284
16684
  const rel = relative11(projectRoot, absPath);
16285
16685
  const extension = extname8(rel);
16286
16686
  let srcPath = RESOLVED_MODULE_EXTENSIONS.has(extension) ? rel : resolveRelativeExtension(rel, projectRoot, extensions);
16287
16687
  if (extname8(srcPath) === ".svelte") {
16288
- srcPath = relative11(projectRoot, resolveSvelteModulePath(resolve27(projectRoot, srcPath)));
16688
+ srcPath = relative11(projectRoot, resolveSvelteModulePath(resolve28(projectRoot, srcPath)));
16289
16689
  }
16290
16690
  return srcUrl(srcPath, projectRoot);
16291
16691
  }, resolveAbsoluteSpecifier = (specifier, projectRoot) => {
@@ -16302,14 +16702,14 @@ ${stubs}
16302
16702
  const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
16303
16703
  const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
16304
16704
  if (!subpath) {
16305
- const pkgDir = resolve27(projectRoot, "node_modules", packageName ?? "");
16306
- const pkgJsonPath = join25(pkgDir, "package.json");
16307
- if (existsSync23(pkgJsonPath)) {
16308
- const pkg = JSON.parse(readFileSync15(pkgJsonPath, "utf-8"));
16705
+ const pkgDir = resolve28(projectRoot, "node_modules", packageName ?? "");
16706
+ const pkgJsonPath = join26(pkgDir, "package.json");
16707
+ if (existsSync24(pkgJsonPath)) {
16708
+ const pkg = JSON.parse(readFileSync17(pkgJsonPath, "utf-8"));
16309
16709
  const esmEntry = typeof pkg.module === "string" && pkg.module || typeof pkg.browser === "string" && pkg.browser;
16310
16710
  if (esmEntry) {
16311
- const resolved = resolve27(pkgDir, esmEntry);
16312
- if (existsSync23(resolved))
16711
+ const resolved = resolve28(pkgDir, esmEntry);
16712
+ if (existsSync24(resolved))
16313
16713
  return relative11(projectRoot, resolved);
16314
16714
  }
16315
16715
  }
@@ -16319,7 +16719,7 @@ ${stubs}
16319
16719
  } catch {
16320
16720
  return;
16321
16721
  }
16322
- }, rewriteImports2 = (code, filePath, projectRoot, rewriter) => {
16722
+ }, rewriteImports = (code, filePath, projectRoot, rewriter) => {
16323
16723
  let result = code;
16324
16724
  const vendorReplace = (_match, prefix, specifier, suffix) => {
16325
16725
  const webPath = rewriter?.lookup.get(specifier);
@@ -16353,12 +16753,12 @@ ${stubs}
16353
16753
  return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
16354
16754
  });
16355
16755
  result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
16356
- const absPath = resolve27(fileDir, relPath);
16756
+ const absPath = resolve28(fileDir, relPath);
16357
16757
  const rel = relative11(projectRoot, absPath);
16358
16758
  return `new URL('${srcUrl(rel, projectRoot)}', import.meta.url)`;
16359
16759
  });
16360
16760
  result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
16361
- const absPath = resolve27(fileDir, relPath);
16761
+ const absPath = resolve28(fileDir, relPath);
16362
16762
  const rel = relative11(projectRoot, absPath);
16363
16763
  return `'${srcUrl(rel, projectRoot)}'`;
16364
16764
  });
@@ -16404,7 +16804,7 @@ ${code}`;
16404
16804
  reactFastRefreshWarningEmitted = true;
16405
16805
  logWarn("React HMR is blocked: this Bun build ignores " + "`reactFastRefresh` on Bun.Transpiler, so component state " + "cannot be preserved across edits. Tracking " + "https://github.com/oven-sh/bun/pull/28312 \u2014 if it still has " + "not merged, leave a \uD83D\uDC4D on the PR so the Bun team knows it " + "is blocking you. Until then, React edits trigger a full " + "reload instead of a fast refresh.");
16406
16806
  }, transformReactFile = (filePath, projectRoot, rewriter) => {
16407
- const raw = readFileSync15(filePath, "utf-8");
16807
+ const raw = readFileSync17(filePath, "utf-8");
16408
16808
  const valueExports = tsxTranspiler.scan(raw).exports;
16409
16809
  let transpiled = reactTranspiler.transformSync(raw);
16410
16810
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
@@ -16418,9 +16818,9 @@ ${transpiled}`;
16418
16818
  const relPath = relative11(projectRoot, filePath).replace(/\\/g, "/");
16419
16819
  transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
16420
16820
  transpiled += buildIslandMetadataExports(raw);
16421
- return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
16821
+ return rewriteImports(transpiled, filePath, projectRoot, rewriter);
16422
16822
  }, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
16423
- const raw = readFileSync15(filePath, "utf-8");
16823
+ const raw = readFileSync17(filePath, "utf-8");
16424
16824
  const ext = extname8(filePath);
16425
16825
  const isTS = ext === ".ts" || ext === ".tsx";
16426
16826
  const isTSX = ext === ".tsx" || ext === ".jsx";
@@ -16434,7 +16834,7 @@ ${transpiled}`;
16434
16834
  if (isTS) {
16435
16835
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
16436
16836
  }
16437
- transpiled = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
16837
+ transpiled = rewriteImports(transpiled, filePath, projectRoot, rewriter);
16438
16838
  if (!vueDir || !filePath.startsWith(vueDir) || !isTS)
16439
16839
  return transpiled;
16440
16840
  const useExports = valueExports.filter((e) => e.startsWith("use"));
@@ -16586,7 +16986,7 @@ ${code}`;
16586
16986
  ` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
16587
16987
  return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
16588
16988
  }, transformSvelteFile = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
16589
- const raw = readFileSync15(filePath, "utf-8");
16989
+ const raw = readFileSync17(filePath, "utf-8");
16590
16990
  if (!svelteCompiler) {
16591
16991
  svelteCompiler = await import("svelte/compiler");
16592
16992
  }
@@ -16596,7 +16996,7 @@ ${code}`;
16596
16996
  const source = isModule ? loweredSource.code : (await svelteCompiler.preprocess(loweredSource.code, createSvelteStylePreprocessor(stylePreprocessors))).code;
16597
16997
  const enableAsync = loweredAwaitSource.transformed || loweredSource.transformed;
16598
16998
  const code = isModule ? compileSvelteModule(source, filePath) : compileSvelteComponent(source, filePath, projectRoot, enableAsync);
16599
- return rewriteImports2(code, filePath, projectRoot, rewriter);
16999
+ return rewriteImports(code, filePath, projectRoot, rewriter);
16600
17000
  }, compileVueTemplate = (descriptor, compiledScript, filePath, componentId) => {
16601
17001
  const compiler = getLoadedVueCompiler();
16602
17002
  const scriptContent = compiledScript.content;
@@ -16646,12 +17046,12 @@ export default __script__;`;
16646
17046
  return `${cssInjection}
16647
17047
  ${code}`;
16648
17048
  }, transformVueFile = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
16649
- const rawSource = readFileSync15(filePath, "utf-8");
17049
+ const rawSource = readFileSync17(filePath, "utf-8");
16650
17050
  const raw = addAutoRouterSetupApp(rawSource);
16651
17051
  if (!vueCompiler) {
16652
17052
  vueCompiler = await import("@vue/compiler-sfc");
16653
17053
  }
16654
- const fileName = basename10(filePath, ".vue");
17054
+ const fileName = basename11(filePath, ".vue");
16655
17055
  const componentId = fileName.toLowerCase();
16656
17056
  const { descriptor } = vueCompiler.parse(raw, { filename: filePath });
16657
17057
  const hasScript = descriptor.script || descriptor.scriptSetup;
@@ -16667,9 +17067,9 @@ ${code}`;
16667
17067
  code = await compileVueStyles(descriptor, filePath, componentId, code, stylePreprocessors);
16668
17068
  code = tsTranspiler2.transformSync(code);
16669
17069
  code = injectVueHmr(code, filePath, projectRoot, vueDir);
16670
- return rewriteImports2(code, filePath, projectRoot, rewriter);
17070
+ return rewriteImports(code, filePath, projectRoot, rewriter);
16671
17071
  }, injectVueHmr = (code, filePath, projectRoot, vueDir) => {
16672
- const hmrBase = vueDir ? resolve27(vueDir) : projectRoot;
17072
+ const hmrBase = vueDir ? resolve28(vueDir) : projectRoot;
16673
17073
  const hmrId = relative11(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
16674
17074
  let result = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
16675
17075
  result += [
@@ -16684,11 +17084,11 @@ ${code}`;
16684
17084
  `);
16685
17085
  return result;
16686
17086
  }, resolveSvelteModulePath = (path) => {
16687
- if (existsSync23(path))
17087
+ if (existsSync24(path))
16688
17088
  return path;
16689
- if (existsSync23(`${path}.ts`))
17089
+ if (existsSync24(`${path}.ts`))
16690
17090
  return `${path}.ts`;
16691
- if (existsSync23(`${path}.js`))
17091
+ if (existsSync24(`${path}.js`))
16692
17092
  return `${path}.js`;
16693
17093
  return path;
16694
17094
  }, jsResponse = (body) => {
@@ -16701,7 +17101,7 @@ ${code}`;
16701
17101
  }
16702
17102
  });
16703
17103
  }, handleCssRequest = (filePath) => {
16704
- const raw = readFileSync15(filePath, "utf-8");
17104
+ const raw = readFileSync17(filePath, "utf-8");
16705
17105
  const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
16706
17106
  return [
16707
17107
  `const style = document.createElement('style');`,
@@ -16828,13 +17228,13 @@ export default {};
16828
17228
  const escaped = virtualCss.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
16829
17229
  return jsResponse(`var s=document.createElement('style');s.textContent=\`${escaped}\`;s.dataset.svelteHmr=${JSON.stringify(cssCheckPath)};var p=document.querySelector('style[data-svelte-hmr="${cssCheckPath}"]');if(p)p.remove();document.head.appendChild(s);`);
16830
17230
  }, resolveSourcePath = (relPath, projectRoot) => {
16831
- const filePath = resolve27(projectRoot, relPath);
17231
+ const filePath = resolve28(projectRoot, relPath);
16832
17232
  const ext = extname8(filePath);
16833
17233
  if (ext === ".svelte")
16834
17234
  return { ext, filePath: resolveSvelteModulePath(filePath) };
16835
17235
  if (ext)
16836
17236
  return { ext, filePath };
16837
- const found = MODULE_EXTENSIONS.find((candidate) => existsSync23(filePath + candidate));
17237
+ const found = MODULE_EXTENSIONS.find((candidate) => existsSync24(filePath + candidate));
16838
17238
  if (!found)
16839
17239
  return { ext, filePath };
16840
17240
  const resolved = filePath + found;
@@ -16854,20 +17254,20 @@ export default {};
16854
17254
  return transformAndCacheVue(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
16855
17255
  if (!TRANSPILABLE.has(ext))
16856
17256
  return;
16857
- const stat4 = statSync2(filePath);
16858
- const resolvedVueDir = vueDir ? resolve27(vueDir) : undefined;
17257
+ const stat3 = statSync2(filePath);
17258
+ const resolvedVueDir = vueDir ? resolve28(vueDir) : undefined;
16859
17259
  const content = REACT_EXTENSIONS.has(ext) ? transformReactFile(filePath, projectRoot, rewriter) : transformPlainFile(filePath, projectRoot, rewriter, resolvedVueDir);
16860
- setTransformed(filePath, content, stat4.mtimeMs, extractImportedFiles(content, projectRoot));
17260
+ setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
16861
17261
  return jsResponse(content);
16862
17262
  }, transformAndCacheSvelte = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
16863
- const stat4 = statSync2(filePath);
17263
+ const stat3 = statSync2(filePath);
16864
17264
  const content = await transformSvelteFile(filePath, projectRoot, rewriter, stylePreprocessors);
16865
- setTransformed(filePath, content, stat4.mtimeMs, extractImportedFiles(content, projectRoot));
17265
+ setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
16866
17266
  return jsResponse(content);
16867
17267
  }, transformAndCacheVue = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
16868
- const stat4 = statSync2(filePath);
17268
+ const stat3 = statSync2(filePath);
16869
17269
  const content = await transformVueFile(filePath, projectRoot, rewriter, vueDir, stylePreprocessors);
16870
- setTransformed(filePath, content, stat4.mtimeMs, extractImportedFiles(content, projectRoot));
17270
+ setTransformed(filePath, content, stat3.mtimeMs, extractImportedFiles(content, projectRoot));
16871
17271
  return jsResponse(content);
16872
17272
  }, transformErrorResponse = (err) => {
16873
17273
  const errMsg = err instanceof Error ? err.message : String(err);
@@ -16886,7 +17286,7 @@ export default {};
16886
17286
  if (!pathname.startsWith(SRC_PREFIX))
16887
17287
  return;
16888
17288
  const relPath = pathname.slice(SRC_PREFIX.length);
16889
- const virtualCssResponse = handleVirtualSvelteCss(resolve27(projectRoot, relPath));
17289
+ const virtualCssResponse = handleVirtualSvelteCss(resolve28(projectRoot, relPath));
16890
17290
  if (virtualCssResponse)
16891
17291
  return virtualCssResponse;
16892
17292
  const { filePath, ext } = resolveSourcePath(relPath, projectRoot);
@@ -16902,11 +17302,11 @@ export default {};
16902
17302
  SRC_IMPORT_RE.lastIndex = 0;
16903
17303
  while ((match = SRC_IMPORT_RE.exec(content)) !== null) {
16904
17304
  if (match[1])
16905
- files.push(resolve27(projectRoot, match[1]));
17305
+ files.push(resolve28(projectRoot, match[1]));
16906
17306
  }
16907
17307
  return files;
16908
17308
  }, invalidateModule = (filePath) => {
16909
- const resolved = resolve27(filePath);
17309
+ const resolved = resolve28(filePath);
16910
17310
  invalidate(filePath);
16911
17311
  if (resolved !== filePath)
16912
17312
  invalidate(resolved);
@@ -16981,6 +17381,46 @@ var init_moduleServer = __esm(() => {
16981
17381
  SRC_URL_PREFIX = SRC_PREFIX;
16982
17382
  });
16983
17383
 
17384
+ // src/build/rewriteImports.ts
17385
+ var exports_rewriteImports = {};
17386
+ __export(exports_rewriteImports, {
17387
+ rewriteVendorDirectories: () => rewriteVendorDirectories2,
17388
+ rewriteImports: () => rewriteImports2
17389
+ });
17390
+ var rewriteImports2 = async (outputPaths, vendorPaths) => {
17391
+ const jsFiles = outputPaths.filter((path) => path.endsWith(".js"));
17392
+ if (jsFiles.length === 0)
17393
+ return;
17394
+ if (Object.keys(vendorPaths).length === 0)
17395
+ return;
17396
+ await Promise.all(jsFiles.map(async (filePath) => {
17397
+ let original;
17398
+ try {
17399
+ original = await Bun.file(filePath).text();
17400
+ } catch (err) {
17401
+ const code = err.code;
17402
+ if (code === "ENOENT")
17403
+ return;
17404
+ throw err;
17405
+ }
17406
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
17407
+ if (rewritten === original)
17408
+ return;
17409
+ try {
17410
+ await Bun.write(filePath, rewritten);
17411
+ } catch (err) {
17412
+ const code = err.code;
17413
+ if (code === "ENOENT")
17414
+ return;
17415
+ throw err;
17416
+ }
17417
+ }));
17418
+ }, rewriteVendorDirectories2;
17419
+ var init_rewriteImports = __esm(() => {
17420
+ init_rewriteImportsPlugin();
17421
+ rewriteVendorDirectories2 = rewriteVendorDirectories;
17422
+ });
17423
+
16984
17424
  // src/utils/ssrErrorPage.ts
16985
17425
  var ssrErrorPage = (framework, error) => {
16986
17426
  const frameworkColors2 = {
@@ -17112,11 +17552,11 @@ var exports_simpleHTMLHMR = {};
17112
17552
  __export(exports_simpleHTMLHMR, {
17113
17553
  handleHTMLUpdate: () => handleHTMLUpdate
17114
17554
  });
17115
- import { resolve as resolve28 } from "path";
17555
+ import { resolve as resolve29 } from "path";
17116
17556
  var handleHTMLUpdate = async (htmlFilePath) => {
17117
17557
  let htmlContent;
17118
17558
  try {
17119
- const resolvedPath = resolve28(htmlFilePath);
17559
+ const resolvedPath = resolve29(htmlFilePath);
17120
17560
  const file4 = Bun.file(resolvedPath);
17121
17561
  if (!await file4.exists()) {
17122
17562
  return null;
@@ -17142,11 +17582,11 @@ var exports_simpleHTMXHMR = {};
17142
17582
  __export(exports_simpleHTMXHMR, {
17143
17583
  handleHTMXUpdate: () => handleHTMXUpdate
17144
17584
  });
17145
- import { resolve as resolve29 } from "path";
17585
+ import { resolve as resolve30 } from "path";
17146
17586
  var handleHTMXUpdate = async (htmxFilePath) => {
17147
17587
  let htmlContent;
17148
17588
  try {
17149
- const resolvedPath = resolve29(htmxFilePath);
17589
+ const resolvedPath = resolve30(htmxFilePath);
17150
17590
  const file4 = Bun.file(resolvedPath);
17151
17591
  if (!await file4.exists()) {
17152
17592
  return null;
@@ -17168,8 +17608,8 @@ var handleHTMXUpdate = async (htmxFilePath) => {
17168
17608
  var init_simpleHTMXHMR = () => {};
17169
17609
 
17170
17610
  // src/dev/rebuildTrigger.ts
17171
- import { existsSync as existsSync24 } from "fs";
17172
- import { basename as basename11, dirname as dirname16, relative as relative12, resolve as resolve30 } from "path";
17611
+ import { existsSync as existsSync25 } from "fs";
17612
+ import { basename as basename12, dirname as dirname16, relative as relative12, resolve as resolve31 } from "path";
17173
17613
  var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequentially = (items, action) => items.reduce((chain, item) => chain.then(() => action(item)), Promise.resolve()), getStyleTransformConfig = (config) => createStyleTransformConfig(config.stylePreprocessors, config.postcss), recompileTailwindForFastPath = async (state, config, files) => {
17174
17614
  if (!config.tailwind)
17175
17615
  return;
@@ -17257,11 +17697,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17257
17697
  detectedFw = detected !== "ignored" ? detected : affectedFrameworks[0];
17258
17698
  }
17259
17699
  return { ...parsed, framework: detectedFw };
17260
- }, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync24(affectedFile), collectDeletedFileAffected = (state, filePathInSet, processedFiles, validFiles) => {
17700
+ }, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync25(affectedFile), collectDeletedFileAffected = (state, filePathInSet, processedFiles, validFiles) => {
17261
17701
  state.fileHashes.delete(filePathInSet);
17262
17702
  try {
17263
17703
  const affectedFiles = getAffectedFiles(state.dependencyGraph, filePathInSet);
17264
- const deletedPathResolved = resolve30(filePathInSet);
17704
+ const deletedPathResolved = resolve31(filePathInSet);
17265
17705
  affectedFiles.forEach((affectedFile) => {
17266
17706
  if (isValidDeletedAffectedFile(affectedFile, deletedPathResolved, processedFiles)) {
17267
17707
  validFiles.push(affectedFile);
@@ -17275,7 +17715,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17275
17715
  if (!dependents || dependents.size === 0) {
17276
17716
  return;
17277
17717
  }
17278
- const dependentFiles = Array.from(dependents).filter((file4) => existsSync24(file4));
17718
+ const dependentFiles = Array.from(dependents).filter((file4) => existsSync25(file4));
17279
17719
  if (dependentFiles.length === 0) {
17280
17720
  return;
17281
17721
  }
@@ -17291,7 +17731,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17291
17731
  try {
17292
17732
  const affectedFiles = getAffectedFiles(state.dependencyGraph, normalizedFilePath);
17293
17733
  affectedFiles.forEach((affectedFile) => {
17294
- if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync24(affectedFile)) {
17734
+ if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync25(affectedFile)) {
17295
17735
  validFiles.push(affectedFile);
17296
17736
  processedFiles.add(affectedFile);
17297
17737
  }
@@ -17305,7 +17745,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17305
17745
  if (storedHash !== undefined && storedHash === fileHash) {
17306
17746
  return;
17307
17747
  }
17308
- const normalizedFilePath = resolve30(filePathInSet);
17748
+ const normalizedFilePath = resolve31(filePathInSet);
17309
17749
  if (!processedFiles.has(normalizedFilePath)) {
17310
17750
  validFiles.push(normalizedFilePath);
17311
17751
  processedFiles.add(normalizedFilePath);
@@ -17316,7 +17756,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17316
17756
  collectChangedFileAffected(state, normalizedFilePath, processedFiles, validFiles);
17317
17757
  }, processFilePathSet = (state, filePathSet, processedFiles, validFiles) => {
17318
17758
  filePathSet.forEach((filePathInSet) => {
17319
- if (!existsSync24(filePathInSet)) {
17759
+ if (!existsSync25(filePathInSet)) {
17320
17760
  collectDeletedFileAffected(state, filePathInSet, processedFiles, validFiles);
17321
17761
  return;
17322
17762
  }
@@ -17409,7 +17849,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17409
17849
  return;
17410
17850
  }
17411
17851
  if (framework === "unknown") {
17412
- invalidate(resolve30(filePath));
17852
+ invalidate(resolve31(filePath));
17413
17853
  const relPath = relative12(process.cwd(), filePath);
17414
17854
  logHmrUpdate(relPath);
17415
17855
  return;
@@ -17453,12 +17893,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17453
17893
  return componentFile;
17454
17894
  }
17455
17895
  const tsCounterpart = componentFile.replace(/\.html$/, ".ts");
17456
- if (existsSync24(tsCounterpart)) {
17896
+ if (existsSync25(tsCounterpart)) {
17457
17897
  return tsCounterpart;
17458
17898
  }
17459
17899
  if (!graph)
17460
17900
  return componentFile;
17461
- const dependents = graph.dependents.get(resolve30(componentFile));
17901
+ const dependents = graph.dependents.get(resolve31(componentFile));
17462
17902
  if (!dependents)
17463
17903
  return componentFile;
17464
17904
  for (const dep of dependents) {
@@ -17467,7 +17907,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17467
17907
  }
17468
17908
  return componentFile;
17469
17909
  }, resolveAngularPageEntries = (state, angularFiles, angularPagesPath) => {
17470
- const pageEntries = angularFiles.filter((file4) => file4.endsWith(".ts") && resolve30(file4).startsWith(angularPagesPath));
17910
+ const pageEntries = angularFiles.filter((file4) => file4.endsWith(".ts") && resolve31(file4).startsWith(angularPagesPath));
17471
17911
  if (pageEntries.length > 0 || !state.dependencyGraph) {
17472
17912
  return pageEntries;
17473
17913
  }
@@ -17476,7 +17916,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17476
17916
  const lookupFile = resolveComponentLookupFile(componentFile, state.dependencyGraph);
17477
17917
  const affected = getAffectedFiles(state.dependencyGraph, lookupFile);
17478
17918
  affected.forEach((file4) => {
17479
- if (file4.endsWith(".ts") && resolve30(file4).startsWith(angularPagesPath)) {
17919
+ if (file4.endsWith(".ts") && resolve31(file4).startsWith(angularPagesPath)) {
17480
17920
  resolvedPages.add(file4);
17481
17921
  }
17482
17922
  });
@@ -17493,7 +17933,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17493
17933
  const { commonAncestor: commonAncestor2 } = await Promise.resolve().then(() => (init_commonAncestor(), exports_commonAncestor));
17494
17934
  return clientRoots.length === 1 ? clientRoots[0] ?? process.cwd() : commonAncestor2(clientRoots, process.cwd());
17495
17935
  }, updateServerManifestEntry = (state, artifact) => {
17496
- const fileWithHash = basename11(artifact.path);
17936
+ const fileWithHash = basename12(artifact.path);
17497
17937
  const [baseName] = fileWithHash.split(`.${artifact.hash}.`);
17498
17938
  if (!baseName) {
17499
17939
  return;
@@ -17546,9 +17986,9 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17546
17986
  const clientManifest = generateManifest2(clientResult.outputs, buildDir);
17547
17987
  Object.assign(state.manifest, clientManifest);
17548
17988
  await populateAssetStore(state.assetStore, clientManifest, buildDir);
17549
- }, broadcastAngularPageUpdates = (state, pagesToUpdate, manifest, startTime) => {
17989
+ }, broadcastAngularPageUpdates = (state, pagesToUpdate, manifest, startTime, classification) => {
17550
17990
  pagesToUpdate.forEach((angularPagePath) => {
17551
- const fileName = basename11(angularPagePath);
17991
+ const fileName = basename12(angularPagePath);
17552
17992
  const baseName = fileName.replace(/\.[tj]s$/, "");
17553
17993
  const pascalName = toPascal(baseName);
17554
17994
  const cssKey = `${pascalName}CSS`;
@@ -17559,10 +17999,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17559
17999
  data: {
17560
18000
  cssBaseName: baseName,
17561
18001
  cssUrl,
18002
+ editSourceFile: classification.sourceFile,
17562
18003
  framework: "angular",
17563
18004
  manifest,
18005
+ reason: classification.reason,
17564
18006
  sourceFile: angularPagePath,
17565
- updateType: "logic"
18007
+ updateType: classification.type
17566
18008
  },
17567
18009
  type: "angular-update"
17568
18010
  });
@@ -17585,9 +18027,9 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17585
18027
  await rewriteImports3(ssrPaths, angServerVendorPaths);
17586
18028
  }
17587
18029
  serverPaths.forEach((serverPath, idx) => {
17588
- const fileBase = basename11(serverPath, ".js");
18030
+ const fileBase = basename12(serverPath, ".js");
17589
18031
  const ssrPath = ssrPaths[idx] ?? serverPath;
17590
- state.manifest[toPascal(fileBase)] = resolve30(ssrPath);
18032
+ state.manifest[toPascal(fileBase)] = resolve31(ssrPath);
17591
18033
  });
17592
18034
  if (clientPaths.length > 0) {
17593
18035
  await bundleAngularClient(state, clientPaths, state.resolvedPaths.buildDir);
@@ -17596,9 +18038,9 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17596
18038
  const angularDir = config.angularDirectory ?? "";
17597
18039
  const angularFiles = filesToRebuild.filter((file4) => detectFramework(file4, state.resolvedPaths) === "angular");
17598
18040
  for (const file4 of angularFiles) {
17599
- state.fileHashes.set(resolve30(file4), computeFileHash(file4));
18041
+ state.fileHashes.set(resolve31(file4), computeFileHash(file4));
17600
18042
  }
17601
- const angularPagesPath = resolve30(angularDir, "pages");
18043
+ const angularPagesPath = resolve31(angularDir, "pages");
17602
18044
  const pageEntries = resolveAngularPageEntries(state, angularFiles, angularPagesPath);
17603
18045
  if (pageEntries.length > 0) {
17604
18046
  await compileAndBundleAngular(state, pageEntries, angularDir);
@@ -17608,7 +18050,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17608
18050
  const angularHmrFiles = angularFiles.filter((file4) => file4.endsWith(".ts") || file4.endsWith(".html"));
17609
18051
  const angularPageFiles = angularHmrFiles.filter((file4) => file4.replace(/\\/g, "/").includes("/pages/"));
17610
18052
  const pagesToUpdate = angularPageFiles.length > 0 ? angularPageFiles : pageEntries;
17611
- broadcastAngularPageUpdates(state, pagesToUpdate, manifest, startTime);
18053
+ const classification = collapseClassifications(angularFiles.map(classifyAngularEdit));
18054
+ broadcastAngularPageUpdates(state, pagesToUpdate, manifest, startTime, classification);
17612
18055
  onRebuildComplete({ hmrState: state, manifest });
17613
18056
  return manifest;
17614
18057
  }, getModuleUrl = async (pageFile) => {
@@ -17623,11 +18066,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17623
18066
  if (isComponentFile2)
17624
18067
  return primaryFile;
17625
18068
  const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
17626
- const nearest = findNearestComponent2(resolve30(primaryFile));
18069
+ const nearest = findNearestComponent2(resolve31(primaryFile));
17627
18070
  return nearest ?? primaryFile;
17628
18071
  }, handleReactModuleServerPath = async (state, reactFiles, startTime, onRebuildComplete) => {
17629
18072
  for (const file4 of reactFiles) {
17630
- state.fileHashes.set(resolve30(file4), computeFileHash(file4));
18073
+ state.fileHashes.set(resolve31(file4), computeFileHash(file4));
17631
18074
  }
17632
18075
  markSsrCacheDirty("react");
17633
18076
  const primaryFile = reactFiles.find((file4) => !file4.replace(/\\/g, "/").includes("/pages/")) ?? reactFiles[0];
@@ -17709,7 +18152,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17709
18152
  });
17710
18153
  }, handleSvelteModuleServerPath = async (state, svelteFiles, startTime, onRebuildComplete) => {
17711
18154
  for (const file4 of svelteFiles) {
17712
- state.fileHashes.set(resolve30(file4), computeFileHash(file4));
18155
+ state.fileHashes.set(resolve31(file4), computeFileHash(file4));
17713
18156
  }
17714
18157
  markSsrCacheDirty("svelte");
17715
18158
  const serverDuration = Date.now() - startTime;
@@ -17733,8 +18176,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17733
18176
  const { svelteServerPaths, svelteIndexPaths, svelteClientPaths } = await compileSvelte2(svelteFiles, svelteDir, new Map, true, getStyleTransformConfig(state.config));
17734
18177
  const serverEntries = [...svelteServerPaths];
17735
18178
  const clientEntries = [...svelteIndexPaths, ...svelteClientPaths];
17736
- const serverRoot = resolve30(svelteDir, "generated", "server");
17737
- const serverOutDir = resolve30(buildDir, basename11(svelteDir));
18179
+ const serverRoot = resolve31(svelteDir, "generated", "server");
18180
+ const serverOutDir = resolve31(buildDir, basename12(svelteDir));
17738
18181
  const [serverResult, clientResult] = await Promise.all([
17739
18182
  serverEntries.length > 0 ? bunBuild9({
17740
18183
  entrypoints: serverEntries,
@@ -17776,7 +18219,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17776
18219
  const duration = Date.now() - startTime;
17777
18220
  const broadcastFiles = svelteFiles.length > 0 ? svelteFiles : filesToRebuild;
17778
18221
  broadcastFiles.forEach((sveltePagePath) => {
17779
- const fileName = basename11(sveltePagePath);
18222
+ const fileName = basename12(sveltePagePath);
17780
18223
  const baseName = fileName.replace(/\.svelte$/, "");
17781
18224
  const pascalName = toPascal(baseName);
17782
18225
  const cssKey = `${pascalName}CSS`;
@@ -17831,7 +18274,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17831
18274
  });
17832
18275
  }, handleVueModuleServerPath = async (state, vueFiles, nonVueFiles, startTime, onRebuildComplete) => {
17833
18276
  for (const file4 of [...vueFiles, ...nonVueFiles]) {
17834
- state.fileHashes.set(resolve30(file4), computeFileHash(file4));
18277
+ state.fileHashes.set(resolve31(file4), computeFileHash(file4));
17835
18278
  }
17836
18279
  markSsrCacheDirty("vue");
17837
18280
  await invalidateNonVueModules(nonVueFiles);
@@ -17853,13 +18296,13 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17853
18296
  onRebuildComplete({ hmrState: state, manifest: state.manifest });
17854
18297
  return state.manifest;
17855
18298
  }, EMBER_PAGE_EXTENSIONS, collectAllEmberPages = async (emberPagesPath) => {
17856
- const { readdir: readdir4 } = await import("fs/promises");
18299
+ const { readdir: readdir5 } = await import("fs/promises");
17857
18300
  try {
17858
- const entries = await readdir4(emberPagesPath, {
18301
+ const entries = await readdir5(emberPagesPath, {
17859
18302
  recursive: true,
17860
18303
  withFileTypes: true
17861
18304
  });
17862
- return entries.filter((entry) => entry.isFile() && EMBER_PAGE_EXTENSIONS.some((ext) => entry.name.endsWith(ext))).map((entry) => resolve30(emberPagesPath, entry.name));
18305
+ return entries.filter((entry) => entry.isFile() && EMBER_PAGE_EXTENSIONS.some((ext) => entry.name.endsWith(ext))).map((entry) => resolve31(emberPagesPath, entry.name));
17863
18306
  } catch {
17864
18307
  return [];
17865
18308
  }
@@ -17871,10 +18314,10 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17871
18314
  return state.manifest;
17872
18315
  }
17873
18316
  for (const file4 of emberFiles) {
17874
- state.fileHashes.set(resolve30(file4), computeFileHash(file4));
18317
+ state.fileHashes.set(resolve31(file4), computeFileHash(file4));
17875
18318
  }
17876
- const emberPagesPath = resolve30(emberDir, "pages");
17877
- const directPageEntries = emberFiles.filter((file4) => resolve30(file4).startsWith(emberPagesPath));
18319
+ const emberPagesPath = resolve31(emberDir, "pages");
18320
+ const directPageEntries = emberFiles.filter((file4) => resolve31(file4).startsWith(emberPagesPath));
17878
18321
  const allPageEntries = directPageEntries.length > 0 ? directPageEntries : await collectAllEmberPages(emberPagesPath);
17879
18322
  if (allPageEntries.length === 0) {
17880
18323
  onRebuildComplete({ hmrState: state, manifest: state.manifest });
@@ -17883,8 +18326,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17883
18326
  const { compileEmber: compileEmber2 } = await Promise.resolve().then(() => (init_compileEmber(), exports_compileEmber));
17884
18327
  const { serverPaths } = await compileEmber2(allPageEntries, emberDir, process.cwd(), true);
17885
18328
  for (const serverPath of serverPaths) {
17886
- const fileBase = basename11(serverPath, ".js");
17887
- state.manifest[toPascal(fileBase)] = resolve30(serverPath);
18329
+ const fileBase = basename12(serverPath, ".js");
18330
+ state.manifest[toPascal(fileBase)] = resolve31(serverPath);
17888
18331
  }
17889
18332
  const { invalidateEmberSsrCache: invalidateEmberSsrCache2 } = await Promise.resolve().then(() => (init_ember(), exports_ember));
17890
18333
  invalidateEmberSsrCache2();
@@ -17954,7 +18397,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17954
18397
  });
17955
18398
  }
17956
18399
  }, handleScriptUpdate = (state, scriptFile, manifest, framework, duration) => {
17957
- const scriptBaseName = basename11(scriptFile).replace(/\.(ts|js|tsx|jsx)$/, "");
18400
+ const scriptBaseName = basename12(scriptFile).replace(/\.(ts|js|tsx|jsx)$/, "");
17958
18401
  const pascalName = toPascal(scriptBaseName);
17959
18402
  const scriptPath = manifest[pascalName] || null;
17960
18403
  if (!scriptPath) {
@@ -17976,8 +18419,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17976
18419
  if (!buildReference?.source) {
17977
18420
  return;
17978
18421
  }
17979
- const sourcePath = buildReference.source.startsWith("file://") ? new URL(buildReference.source).pathname : resolve30(dirname16(buildInfo.resolvedRegistryPath), buildReference.source);
17980
- islandFiles.add(resolve30(sourcePath));
18422
+ const sourcePath = buildReference.source.startsWith("file://") ? new URL(buildReference.source).pathname : resolve31(dirname16(buildInfo.resolvedRegistryPath), buildReference.source);
18423
+ islandFiles.add(resolve31(sourcePath));
17981
18424
  }, resolveIslandSourceFiles = async (config) => {
17982
18425
  const registryPath = config.islands?.registry;
17983
18426
  if (!registryPath) {
@@ -17985,7 +18428,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17985
18428
  }
17986
18429
  const buildInfo = await loadIslandRegistryBuildInfo(registryPath);
17987
18430
  const islandFiles = new Set([
17988
- resolve30(buildInfo.resolvedRegistryPath)
18431
+ resolve31(buildInfo.resolvedRegistryPath)
17989
18432
  ]);
17990
18433
  for (const definition of buildInfo.definitions) {
17991
18434
  resolveIslandDefinitionSource(definition, buildInfo, islandFiles);
@@ -17996,7 +18439,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
17996
18439
  if (islandFiles.size === 0) {
17997
18440
  return false;
17998
18441
  }
17999
- return filesToRebuild.some((file4) => islandFiles.has(resolve30(file4)));
18442
+ return filesToRebuild.some((file4) => islandFiles.has(resolve31(file4)));
18000
18443
  }, handleIslandSourceReload = async (state, config, filesToRebuild, manifest) => {
18001
18444
  const shouldReload = await didStaticPagesNeedIslandRefresh(config, filesToRebuild);
18002
18445
  if (!shouldReload) {
@@ -18031,10 +18474,10 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18031
18474
  }, computeOutputPagesDir = (state, config, framework) => {
18032
18475
  const isSingle = !config.reactDirectory && !config.svelteDirectory && !config.vueDirectory && (framework === "html" ? !config.htmxDirectory : !config.htmlDirectory);
18033
18476
  if (isSingle) {
18034
- return resolve30(state.resolvedPaths.buildDir, "pages");
18477
+ return resolve31(state.resolvedPaths.buildDir, "pages");
18035
18478
  }
18036
- const dirName = framework === "html" ? basename11(config.htmlDirectory ?? "html") : basename11(config.htmxDirectory ?? "htmx");
18037
- return resolve30(state.resolvedPaths.buildDir, dirName, "pages");
18479
+ const dirName = framework === "html" ? basename12(config.htmlDirectory ?? "html") : basename12(config.htmxDirectory ?? "htmx");
18480
+ return resolve31(state.resolvedPaths.buildDir, dirName, "pages");
18038
18481
  }, processHtmlPageUpdate = async (state, pageFile, builtHtmlPagePath, manifest, duration) => {
18039
18482
  try {
18040
18483
  const { handleHTMLUpdate: handleHTMLUpdate2 } = await Promise.resolve().then(() => (init_simpleHTMLHMR(), exports_simpleHTMLHMR));
@@ -18072,8 +18515,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18072
18515
  const shouldRefreshAllPages = htmlPageFiles.length === 0 && shouldRefreshFromIslandChange;
18073
18516
  const pageFilesToUpdate = shouldRefreshAllPages ? await scanEntryPoints(outputHtmlPages, "*.html") : htmlPageFiles;
18074
18517
  await runSequentially(pageFilesToUpdate, async (pageFile) => {
18075
- const htmlPageName = basename11(pageFile);
18076
- const builtHtmlPagePath = resolve30(outputHtmlPages, htmlPageName);
18518
+ const htmlPageName = basename12(pageFile);
18519
+ const builtHtmlPagePath = resolve31(outputHtmlPages, htmlPageName);
18077
18520
  await processHtmlPageUpdate(state, pageFile, builtHtmlPagePath, manifest, duration);
18078
18521
  });
18079
18522
  }, handleVueCssOnlyUpdate = (state, vueCssFiles, manifest, duration) => {
@@ -18081,7 +18524,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18081
18524
  if (!cssFile) {
18082
18525
  return;
18083
18526
  }
18084
- const cssBaseName = basename11(getStyleBaseName(cssFile));
18527
+ const cssBaseName = basename12(getStyleBaseName(cssFile));
18085
18528
  const cssPascalName = toPascal(cssBaseName);
18086
18529
  const cssKey = `${cssPascalName}CSS`;
18087
18530
  const cssUrl = manifest[cssKey] || null;
@@ -18130,7 +18573,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18130
18573
  type: "vue-update"
18131
18574
  });
18132
18575
  }, broadcastVuePageChange = async (state, config, vuePagePath, manifest, duration) => {
18133
- const fileName = basename11(vuePagePath);
18576
+ const fileName = basename12(vuePagePath);
18134
18577
  const baseName = fileName.replace(/\.vue$/, "");
18135
18578
  const pascalName = toPascal(baseName);
18136
18579
  const vueRoot = config.vueDirectory;
@@ -18138,7 +18581,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18138
18581
  const cssKey = `${pascalName}CSS`;
18139
18582
  const cssUrl = manifest[cssKey] || null;
18140
18583
  const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
18141
- const hmrMeta = vueHmrMetadata2.get(resolve30(vuePagePath));
18584
+ const hmrMeta = vueHmrMetadata2.get(resolve31(vuePagePath));
18142
18585
  const changeType = hmrMeta?.changeType ?? "full";
18143
18586
  if (changeType === "style-only") {
18144
18587
  broadcastVueStyleOnly(state, vuePagePath, baseName, cssUrl, hmrId, manifest, duration);
@@ -18176,7 +18619,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18176
18619
  if (!cssFile) {
18177
18620
  return;
18178
18621
  }
18179
- const cssBaseName = basename11(getStyleBaseName(cssFile));
18622
+ const cssBaseName = basename12(getStyleBaseName(cssFile));
18180
18623
  const cssPascalName = toPascal(cssBaseName);
18181
18624
  const cssKey = `${cssPascalName}CSS`;
18182
18625
  const cssUrl = manifest[cssKey] || null;
@@ -18194,7 +18637,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18194
18637
  });
18195
18638
  }, broadcastSveltePageUpdate = (state, sveltePagePath, manifest, duration) => {
18196
18639
  try {
18197
- const fileName = basename11(sveltePagePath);
18640
+ const fileName = basename12(sveltePagePath);
18198
18641
  const baseName = fileName.replace(/\.svelte$/, "");
18199
18642
  const pascalName = toPascal(baseName);
18200
18643
  const cssKey = `${pascalName}CSS`;
@@ -18256,7 +18699,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18256
18699
  if (!cssFile) {
18257
18700
  return;
18258
18701
  }
18259
- const cssBaseName = basename11(getStyleBaseName(cssFile));
18702
+ const cssBaseName = basename12(getStyleBaseName(cssFile));
18260
18703
  const cssPascalName = toPascal(cssBaseName);
18261
18704
  const cssKey = `${cssPascalName}CSS`;
18262
18705
  const cssUrl = manifest[cssKey] || null;
@@ -18272,9 +18715,9 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18272
18715
  },
18273
18716
  type: "angular-update"
18274
18717
  });
18275
- }, broadcastAngularPageHmrUpdate = (state, angularPagePath, manifest, duration) => {
18718
+ }, broadcastAngularPageHmrUpdate = (state, angularPagePath, manifest, duration, classification) => {
18276
18719
  try {
18277
- const fileName = basename11(angularPagePath);
18720
+ const fileName = basename12(angularPagePath);
18278
18721
  const baseName = fileName.replace(/\.[tj]s$/, "");
18279
18722
  const pascalName = toPascal(baseName);
18280
18723
  const cssKey = `${pascalName}CSS`;
@@ -18284,10 +18727,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18284
18727
  data: {
18285
18728
  cssBaseName: baseName,
18286
18729
  cssUrl,
18730
+ editSourceFile: classification.sourceFile,
18287
18731
  framework: "angular",
18288
18732
  manifest,
18733
+ reason: classification.reason,
18289
18734
  sourceFile: angularPagePath,
18290
- updateType: "logic"
18735
+ updateType: classification.type
18291
18736
  },
18292
18737
  type: "angular-update"
18293
18738
  });
@@ -18316,8 +18761,9 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18316
18761
  handleAngularCssOnlyUpdate(state, angularCssFiles, manifest, duration);
18317
18762
  return;
18318
18763
  }
18764
+ const classification = collapseClassifications(angularFiles.map(classifyAngularEdit));
18319
18765
  pagesToUpdate.forEach((angularPagePath) => {
18320
- broadcastAngularPageHmrUpdate(state, angularPagePath, manifest, duration);
18766
+ broadcastAngularPageHmrUpdate(state, angularPagePath, manifest, duration, classification);
18321
18767
  });
18322
18768
  }, handleHTMXScriptHMR = (state, filesToRebuild, manifest, duration) => {
18323
18769
  if (!state.resolvedPaths.htmxDir) {
@@ -18372,8 +18818,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18372
18818
  const shouldRefreshAllPages = htmxPageFiles.length === 0 && shouldRefreshFromIslandChange;
18373
18819
  const pageFilesToUpdate = shouldRefreshAllPages ? await scanEntryPoints(outputHtmxPages, "*.html") : htmxPageFiles;
18374
18820
  await runSequentially(pageFilesToUpdate, async (htmxPageFile) => {
18375
- const htmxPageName = basename11(htmxPageFile);
18376
- const builtHtmxPagePath = resolve30(outputHtmxPages, htmxPageName);
18821
+ const htmxPageName = basename12(htmxPageFile);
18822
+ const builtHtmxPagePath = resolve31(outputHtmxPages, htmxPageName);
18377
18823
  await processHtmxPageUpdate(state, htmxPageFile, builtHtmxPagePath, manifest, duration);
18378
18824
  });
18379
18825
  }, collectUpdatedModulePaths = (allModuleUpdates) => {
@@ -18482,7 +18928,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
18482
18928
  html = html.slice(0, bodyClose.index) + hmrScript + html.slice(bodyClose.index);
18483
18929
  writeFs(destPath, html);
18484
18930
  }, processMarkupFileFastPath = async (state, sourceFile, outputDir, framework, startTime, updateAssetPaths2, handleUpdate, readFs, writeFs) => {
18485
- const destPath = resolve30(outputDir, basename11(sourceFile));
18931
+ const destPath = resolve31(outputDir, basename12(sourceFile));
18486
18932
  const hmrScript = extractHmrScript(destPath, readFs);
18487
18933
  const source = await Bun.file(sourceFile).text();
18488
18934
  await Bun.write(destPath, source);
@@ -18728,6 +19174,7 @@ var init_rebuildTrigger = __esm(() => {
18728
19174
  init_compileTailwind();
18729
19175
  init_tailwindCompiler();
18730
19176
  init_ssrCache();
19177
+ init_editTypeDetection();
18731
19178
  moduleServerPromise = Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
18732
19179
  getReactModuleUrl = getModuleUrl;
18733
19180
  EMBER_PAGE_EXTENSIONS = [".gts", ".gjs", ".ts", ".js"];
@@ -18760,9 +19207,9 @@ __export(exports_buildDepVendor, {
18760
19207
  computeDepVendorPaths: () => computeDepVendorPaths,
18761
19208
  buildDepVendor: () => buildDepVendor
18762
19209
  });
18763
- import { mkdirSync as mkdirSync12 } from "fs";
18764
- import { join as join26 } from "path";
18765
- import { rm as rm11 } from "fs/promises";
19210
+ import { mkdirSync as mkdirSync13 } from "fs";
19211
+ import { join as join27 } from "path";
19212
+ import { rm as rm10 } from "fs/promises";
18766
19213
  var {build: bunBuild9, Glob: Glob9 } = globalThis.Bun;
18767
19214
  var toSafeFileName6 = (specifier) => {
18768
19215
  const prefix = specifier.startsWith("@") ? "_" : "";
@@ -18815,7 +19262,7 @@ var toSafeFileName6 = (specifier) => {
18815
19262
  framework: Array.from(framework).filter(isResolvable4)
18816
19263
  };
18817
19264
  }, collectTransitiveImports = async (specs, alreadyVendored, alreadyScanned) => {
18818
- const { readFileSync: readFileSync16 } = await import("fs");
19265
+ const { readFileSync: readFileSync18 } = await import("fs");
18819
19266
  const transpiler5 = new Bun.Transpiler({ loader: "js" });
18820
19267
  const newSpecs = new Set;
18821
19268
  for (const spec of specs) {
@@ -18830,7 +19277,7 @@ var toSafeFileName6 = (specifier) => {
18830
19277
  }
18831
19278
  let content;
18832
19279
  try {
18833
- content = readFileSync16(resolved, "utf-8");
19280
+ content = readFileSync18(resolved, "utf-8");
18834
19281
  } catch {
18835
19282
  continue;
18836
19283
  }
@@ -18872,7 +19319,7 @@ var toSafeFileName6 = (specifier) => {
18872
19319
  }), buildDepVendorPass = async (specifiers, vendorDir, tmpDir) => {
18873
19320
  const entries = await Promise.all(specifiers.map(async (specifier) => {
18874
19321
  const safeName = toSafeFileName6(specifier);
18875
- const entryPath = join26(tmpDir, `${safeName}.ts`);
19322
+ const entryPath = join27(tmpDir, `${safeName}.ts`);
18876
19323
  await Bun.write(entryPath, await generateVendorEntrySource(specifier));
18877
19324
  return { entryPath, specifier };
18878
19325
  }));
@@ -18933,10 +19380,10 @@ var toSafeFileName6 = (specifier) => {
18933
19380
  const { dep: initialSpecs, framework: frameworkRoots } = await scanBareImports(directories);
18934
19381
  if (initialSpecs.length === 0 && frameworkRoots.length === 0)
18935
19382
  return {};
18936
- const vendorDir = join26(buildDir, "vendor");
18937
- mkdirSync12(vendorDir, { recursive: true });
18938
- const tmpDir = join26(buildDir, "_dep_vendor_tmp");
18939
- mkdirSync12(tmpDir, { recursive: true });
19383
+ const vendorDir = join27(buildDir, "vendor");
19384
+ mkdirSync13(vendorDir, { recursive: true });
19385
+ const tmpDir = join27(buildDir, "_dep_vendor_tmp");
19386
+ mkdirSync13(tmpDir, { recursive: true });
18940
19387
  const allSpecs = new Set(initialSpecs);
18941
19388
  const alreadyScanned = new Set;
18942
19389
  let frontier = [...allSpecs, ...frameworkRoots];
@@ -18955,7 +19402,7 @@ var toSafeFileName6 = (specifier) => {
18955
19402
  if (!success) {
18956
19403
  console.warn("\u26A0\uFE0F Dependency vendor build had errors:", result.logs);
18957
19404
  }
18958
- await rm11(tmpDir, { force: true, recursive: true });
19405
+ await rm10(tmpDir, { force: true, recursive: true });
18959
19406
  const paths = {};
18960
19407
  for (const specifier of allSpecs) {
18961
19408
  paths[specifier] = `/vendor/${toSafeFileName6(specifier)}.js`;
@@ -19016,9 +19463,9 @@ var exports_devBuild = {};
19016
19463
  __export(exports_devBuild, {
19017
19464
  devBuild: () => devBuild
19018
19465
  });
19019
- import { readdir as readdir4 } from "fs/promises";
19466
+ import { readdir as readdir5 } from "fs/promises";
19020
19467
  import { statSync as statSync3 } from "fs";
19021
- import { resolve as resolve31 } from "path";
19468
+ import { resolve as resolve32 } from "path";
19022
19469
  var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19023
19470
  const configuredDirs = [
19024
19471
  config.reactDirectory,
@@ -19041,7 +19488,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19041
19488
  return Object.keys(config).length > 0 ? config : null;
19042
19489
  }, reloadConfig = async () => {
19043
19490
  try {
19044
- const configPath2 = resolve31(process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
19491
+ const configPath2 = resolve32(process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
19045
19492
  const source = await Bun.file(configPath2).text();
19046
19493
  return parseDirectoryConfig(source);
19047
19494
  } catch {
@@ -19126,7 +19573,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19126
19573
  state.fileChangeQueue.clear();
19127
19574
  }
19128
19575
  }, handleCachedReload = async () => {
19129
- const serverMtime = statSync3(resolve31(Bun.main)).mtimeMs;
19576
+ const serverMtime = statSync3(resolve32(Bun.main)).mtimeMs;
19130
19577
  const lastMtime = globalThis.__hmrServerMtime;
19131
19578
  globalThis.__hmrServerMtime = serverMtime;
19132
19579
  const cached = globalThis.__hmrDevResult;
@@ -19163,8 +19610,8 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19163
19610
  return true;
19164
19611
  }, resolveAbsoluteVersion2 = async () => {
19165
19612
  const candidates = [
19166
- resolve31(import.meta.dir, "..", "..", "package.json"),
19167
- resolve31(import.meta.dir, "..", "package.json")
19613
+ resolve32(import.meta.dir, "..", "..", "package.json"),
19614
+ resolve32(import.meta.dir, "..", "package.json")
19168
19615
  ];
19169
19616
  const [candidate, ...remaining] = candidates;
19170
19617
  if (!candidate) {
@@ -19187,10 +19634,10 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19187
19634
  await resolveAbsoluteVersionFromCandidates(remaining);
19188
19635
  }, loadVendorFiles = async (assetStore, vendorDir, framework) => {
19189
19636
  const emptyStringArray = [];
19190
- const entries = await readdir4(vendorDir).catch(() => emptyStringArray);
19637
+ const entries = await readdir5(vendorDir).catch(() => emptyStringArray);
19191
19638
  await Promise.all(entries.filter((entry) => entry.endsWith(".js")).map(async (entry) => {
19192
19639
  const webPath = `/${framework}/vendor/${entry}`;
19193
- const bytes = await Bun.file(resolve31(vendorDir, entry)).bytes();
19640
+ const bytes = await Bun.file(resolve32(vendorDir, entry)).bytes();
19194
19641
  assetStore.set(webPath, bytes);
19195
19642
  }));
19196
19643
  }, devBuild = async (config) => {
@@ -19231,7 +19678,6 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19231
19678
  const sourceDirs = collectDepVendorSourceDirs(config);
19232
19679
  if (config.angularDirectory) {
19233
19680
  setAngularVendorPaths(await computeAngularVendorPathsAsync(sourceDirs));
19234
- setAngularServerVendorPaths(await computeAngularServerVendorPathsAsync(state.resolvedPaths.buildDir, sourceDirs));
19235
19681
  }
19236
19682
  const { computeDepVendorPaths: computeDepVendorPaths2 } = await Promise.resolve().then(() => (init_buildDepVendor(), exports_buildDepVendor));
19237
19683
  globalThis.__depVendorPaths = await computeDepVendorPaths2(sourceDirs);
@@ -19259,16 +19705,16 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19259
19705
  cleanStaleAssets(state.assetStore, manifest, state.resolvedPaths.buildDir);
19260
19706
  recordStep("populate asset store", stepStartedAt);
19261
19707
  stepStartedAt = performance.now();
19262
- const reactVendorDir = resolve31(state.resolvedPaths.buildDir, "react", "vendor");
19263
- const angularVendorDir = resolve31(state.resolvedPaths.buildDir, "angular", "vendor");
19264
- const svelteVendorDir = resolve31(state.resolvedPaths.buildDir, "svelte", "vendor");
19265
- const vueVendorDir = resolve31(state.resolvedPaths.buildDir, "vue", "vendor");
19266
- const depVendorDir = resolve31(state.resolvedPaths.buildDir, "vendor");
19708
+ const reactVendorDir = resolve32(state.resolvedPaths.buildDir, "react", "vendor");
19709
+ const angularVendorDir = resolve32(state.resolvedPaths.buildDir, "angular", "vendor");
19710
+ const svelteVendorDir = resolve32(state.resolvedPaths.buildDir, "svelte", "vendor");
19711
+ const vueVendorDir = resolve32(state.resolvedPaths.buildDir, "vue", "vendor");
19712
+ const depVendorDir = resolve32(state.resolvedPaths.buildDir, "vendor");
19267
19713
  const { buildDepVendor: buildDepVendor2 } = await Promise.resolve().then(() => (init_buildDepVendor(), exports_buildDepVendor));
19268
- const [, angularSpecs, angularServerSpecs, , , , depPaths] = await Promise.all([
19714
+ const [, angularSpecs, , , , , depPaths] = await Promise.all([
19269
19715
  config.reactDirectory ? buildReactVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
19270
19716
  config.angularDirectory ? buildAngularVendor(state.resolvedPaths.buildDir, sourceDirs, true, Object.keys(globalThis.__depVendorPaths ?? {})) : Promise.resolve(undefined),
19271
- config.angularDirectory ? buildAngularServerVendor(state.resolvedPaths.buildDir, sourceDirs, true) : Promise.resolve(undefined),
19717
+ Promise.resolve(undefined),
19272
19718
  config.svelteDirectory ? buildSvelteVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
19273
19719
  config.vueDirectory ? buildVueVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
19274
19720
  config.emberDirectory ? buildEmberVendor(state.resolvedPaths.buildDir) : Promise.resolve(undefined),
@@ -19276,9 +19722,6 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19276
19722
  ]);
19277
19723
  if (angularSpecs)
19278
19724
  globalThis.__angularVendorSpecifiers = angularSpecs;
19279
- if (angularServerSpecs) {
19280
- setAngularServerVendorPaths(computeAngularServerVendorPaths(state.resolvedPaths.buildDir, angularServerSpecs));
19281
- }
19282
19725
  if (config.emberDirectory) {
19283
19726
  setEmberVendorPaths(computeEmberVendorPaths());
19284
19727
  }
@@ -19299,8 +19742,8 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19299
19742
  config.vueDirectory ? vueVendorDir : null,
19300
19743
  depVendorDir
19301
19744
  ].filter((d2) => d2 !== null);
19302
- const { rewriteVendorDirectories: rewriteVendorDirectories2 } = await Promise.resolve().then(() => (init_rewriteImports(), exports_rewriteImports));
19303
- await rewriteVendorDirectories2(activeVendorDirs, combinedVendorPaths);
19745
+ const { rewriteVendorDirectories: rewriteVendorDirectories3 } = await Promise.resolve().then(() => (init_rewriteImportsPlugin(), exports_rewriteImportsPlugin));
19746
+ await rewriteVendorDirectories3(activeVendorDirs, combinedVendorPaths);
19304
19747
  recordStep("rewrite vendor cross-references", stepStartedAt);
19305
19748
  stepStartedAt = performance.now();
19306
19749
  await Promise.all([
@@ -19344,7 +19787,7 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
19344
19787
  manifest
19345
19788
  };
19346
19789
  globalThis.__hmrDevResult = result;
19347
- globalThis.__hmrServerMtime = statSync3(resolve31(Bun.main)).mtimeMs;
19790
+ globalThis.__hmrServerMtime = statSync3(resolve32(Bun.main)).mtimeMs;
19348
19791
  return result;
19349
19792
  };
19350
19793
  var init_devBuild = __esm(() => {
@@ -19381,5 +19824,5 @@ export {
19381
19824
  build
19382
19825
  };
19383
19826
 
19384
- //# debugId=6C326DB07EC8C78F64756E2164756E21
19827
+ //# debugId=2EEDD738FB4FC7B664756E2164756E21
19385
19828
  //# sourceMappingURL=build.js.map