@absolutejs/absolute 0.19.0-beta.102 → 0.19.0-beta.104

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.
@@ -34,18 +34,6 @@ export const handleReactUpdate = (message: {
34
34
  const serverDuration = message.data.serverDuration;
35
35
  const pageModuleUrl = message.data.pageModuleUrl;
36
36
 
37
- // For non-component files (.ts data), the root accept handler
38
- // re-imports the page and calls root.render(). Skip Fast Refresh.
39
- // For component files (.tsx/.jsx), use Fast Refresh directly.
40
- const src = message.data.primarySource ?? '';
41
- const isComponent = src.endsWith('.tsx') || src.endsWith('.jsx');
42
- if (
43
- !isComponent &&
44
- (window as unknown as Record<string, unknown>).__HMR_ROOT_ACCEPT__
45
- ) {
46
- return;
47
- }
48
-
49
37
  if (pageModuleUrl && refreshRuntime) {
50
38
  applyRefreshImport(pageModuleUrl, refreshRuntime, serverDuration);
51
39
 
package/dist/index.js CHANGED
@@ -202,7 +202,7 @@ __export(exports_generateReactIndexes, {
202
202
  });
203
203
  import { existsSync, mkdirSync } from "fs";
204
204
  import { readdir, rm, writeFile } from "fs/promises";
205
- import { basename, join, relative, resolve as resolve2 } from "path";
205
+ import { basename, join, resolve as resolve2 } from "path";
206
206
  var {Glob } = globalThis.Bun;
207
207
  var indexContentCache, resolveDevClientDir = () => {
208
208
  const fromSource = resolve2(import.meta.dir, "../dev/client");
@@ -491,42 +491,7 @@ var indexContentCache, resolveDevClientDir = () => {
491
491
  ` originalError.apply(console, args);`,
492
492
  ` };`,
493
493
  ` }`,
494
- `}`,
495
- ...isDev ? [
496
- `
497
- // HMR: re-import the page component and re-render the root.`,
498
- `// This is the Vite-style approach \u2014 the index file is the`,
499
- `// HMR boundary. Works for all patterns: dynamic imports,`,
500
- `// lazy loading, portals, data files.`,
501
- `if (window.__HMR_WS__ && window.__REACT_ROOT__ && !window.__HMR_ROOT_ACCEPT__) {`,
502
- ` window.__HMR_ROOT_ACCEPT__ = true;`,
503
- ` const origOnMessage = window.__HMR_WS__.onmessage;`,
504
- ` window.__HMR_WS__.onmessage = function(event) {`,
505
- ` if (origOnMessage) origOnMessage.call(this, event);`,
506
- ` try {`,
507
- ` const msg = JSON.parse(event.data);`,
508
- ` if (msg.type === 'react-update' && msg.data?.primarySource && !msg.data.primarySource.endsWith('.tsx') && !msg.data.primarySource.endsWith('.jsx')) {`,
509
- ` const url = "/@src/${relative(process.cwd(), resolve2(reactPagesDirectory, componentName + ".tsx")).replace(/\\/g, "/")}";`,
510
- ` const start = performance.now();`,
511
- ` import(url + '?t=' + Date.now()).then(mod => {`,
512
- ` const Comp = mod.${componentName} || mod.default;`,
513
- ` if (Comp && window.__REACT_ROOT__) {`,
514
- ` const props = window.__INITIAL_PROPS__ || {};`,
515
- ` window.__REACT_ROOT__.render(`,
516
- ` ${isDev ? `createElement(ErrorBoundary, null, createElement(Comp, props))` : `createElement(Comp, props)`}`,
517
- ` );`,
518
- ` if (window.__HMR_WS__) {`,
519
- ` const ms = Math.round(performance.now() - start);`,
520
- ` const total = (msg.data.serverDuration || 0) + ms;`,
521
- ` window.__HMR_WS__.send(JSON.stringify({ type: 'hmr-timing', duration: total }));`,
522
- ` }`,
523
- ` }`,
524
- ` }).catch(() => {});`,
525
- ` }`,
526
- ` } catch {}`,
527
- ` };`,
528
- `}`
529
- ] : []
494
+ `}`
530
495
  ].join(`
531
496
  `);
532
497
  const indexPath = join(reactIndexesDirectory, `${componentName}.tsx`);
@@ -980,7 +945,7 @@ var devVendorPaths = null, getDevVendorPaths = () => devVendorPaths, setDevVendo
980
945
 
981
946
  // src/build/angularLinkerPlugin.ts
982
947
  import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
983
- import { dirname as dirname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
948
+ import { dirname as dirname2, join as join4, relative, resolve as resolve5 } from "path";
984
949
  import { createHash } from "crypto";
985
950
  var CACHE_DIR, angularLinkerPlugin;
986
951
  var init_angularLinkerPlugin = __esm(() => {
@@ -1023,7 +988,7 @@ var init_angularLinkerPlugin = __esm(() => {
1023
988
  dirname: dirname2,
1024
989
  exists: existsSync7,
1025
990
  readFile: readFileSync3,
1026
- relative: relative2,
991
+ relative,
1027
992
  resolve: resolve5
1028
993
  },
1029
994
  linkerJitMode: false,
@@ -1064,11 +1029,11 @@ var HASHED_FILE_PATTERN, cleanStaleOutputs = async (buildPath, currentOutputPath
1064
1029
  const currentPaths = new Set(currentOutputPaths.map((path) => resolve6(path)));
1065
1030
  const glob = new Glob4("**/*");
1066
1031
  const removals = [];
1067
- for (const relative3 of glob.scanSync({ cwd: buildPath })) {
1068
- const absolute = resolve6(buildPath, relative3);
1032
+ for (const relative2 of glob.scanSync({ cwd: buildPath })) {
1033
+ const absolute = resolve6(buildPath, relative2);
1069
1034
  if (currentPaths.has(absolute))
1070
1035
  continue;
1071
- if (!HASHED_FILE_PATTERN.test(relative3))
1036
+ if (!HASHED_FILE_PATTERN.test(relative2))
1072
1037
  continue;
1073
1038
  removals.push(rm2(absolute, { force: true }));
1074
1039
  }
@@ -1222,12 +1187,12 @@ var init_startupBanner = __esm(() => {
1222
1187
  // src/utils/logger.ts
1223
1188
  var colors2, frameworkColors, formatPath = (filePath) => {
1224
1189
  const cwd = process.cwd();
1225
- let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
1226
- relative3 = relative3.replace(/\\/g, "/");
1227
- if (!relative3.startsWith("/")) {
1228
- relative3 = `/${relative3}`;
1190
+ let relative2 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
1191
+ relative2 = relative2.replace(/\\/g, "/");
1192
+ if (!relative2.startsWith("/")) {
1193
+ relative2 = `/${relative2}`;
1229
1194
  }
1230
- return relative3;
1195
+ return relative2;
1231
1196
  }, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
1232
1197
  const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1233
1198
  const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
@@ -1286,11 +1251,11 @@ var init_logger = __esm(() => {
1286
1251
  });
1287
1252
 
1288
1253
  // src/utils/validateSafePath.ts
1289
- import { resolve as resolve7, relative as relative3 } from "path";
1254
+ import { resolve as resolve7, relative as relative2 } from "path";
1290
1255
  var validateSafePath = (targetPath, baseDirectory) => {
1291
1256
  const absoluteBase = resolve7(baseDirectory);
1292
1257
  const absoluteTarget = resolve7(baseDirectory, targetPath);
1293
- const relativePath = normalizePath(relative3(absoluteBase, absoluteTarget));
1258
+ const relativePath = normalizePath(relative2(absoluteBase, absoluteTarget));
1294
1259
  if (relativePath.startsWith("../") || relativePath === "..") {
1295
1260
  throw new Error(`Unsafe path: ${targetPath}`);
1296
1261
  }
@@ -1312,7 +1277,7 @@ import {
1312
1277
  basename as basename2,
1313
1278
  extname as extname2,
1314
1279
  resolve as resolve8,
1315
- relative as relative4,
1280
+ relative as relative3,
1316
1281
  sep
1317
1282
  } from "path";
1318
1283
  import { env } from "process";
@@ -1376,7 +1341,7 @@ var resolveDevClientDir2 = () => {
1376
1341
  const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
1377
1342
  const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
1378
1343
  const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
1379
- const relDir = dirname3(relative4(svelteRoot, src)).replace(/\\/g, "/");
1344
+ const relDir = dirname3(relative3(svelteRoot, src)).replace(/\\/g, "/");
1380
1345
  const baseName = basename2(src).replace(/\.svelte(\.(ts|js))?$/, "");
1381
1346
  const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
1382
1347
  const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
@@ -1395,7 +1360,7 @@ var resolveDevClientDir2 = () => {
1395
1360
  }).js.code;
1396
1361
  let code = raw2.replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
1397
1362
  if (mode === "client" && isDev) {
1398
- const moduleKey = `/@src/${relative4(process.cwd(), src).replace(/\\/g, "/")}`;
1363
+ const moduleKey = `/@src/${relative3(process.cwd(), src).replace(/\\/g, "/")}`;
1399
1364
  code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
1400
1365
  if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
1401
1366
  var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleKey)}] = cb; };`);
@@ -1430,10 +1395,10 @@ var resolveDevClientDir2 = () => {
1430
1395
  };
1431
1396
  const roots = await Promise.all(entryPoints.map(build2));
1432
1397
  await Promise.all(roots.map(async ({ client: client2 }) => {
1433
- const relClientDir = dirname3(relative4(clientDir, client2));
1398
+ const relClientDir = dirname3(relative3(clientDir, client2));
1434
1399
  const name = basename2(client2, extname2(client2));
1435
1400
  const indexPath = join6(indexDir, relClientDir, `${name}.js`);
1436
- const importRaw = relative4(dirname3(indexPath), client2).split(sep).join("/");
1401
+ const importRaw = relative3(dirname3(indexPath), client2).split(sep).join("/");
1437
1402
  const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
1438
1403
  const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
1439
1404
  import "${hmrClientPath3}";
@@ -1473,7 +1438,7 @@ if (typeof window !== "undefined") {
1473
1438
  return {
1474
1439
  svelteClientPaths: roots.map(({ client: client2 }) => client2),
1475
1440
  svelteIndexPaths: roots.map(({ client: client2 }) => {
1476
- const rel = dirname3(relative4(clientDir, client2));
1441
+ const rel = dirname3(relative3(clientDir, client2));
1477
1442
  return join6(indexDir, rel, basename2(client2));
1478
1443
  }),
1479
1444
  svelteServerPaths: roots.map(({ ssr }) => ssr)
@@ -1498,7 +1463,7 @@ __export(exports_compileVue, {
1498
1463
  });
1499
1464
  import { existsSync as existsSync9 } from "fs";
1500
1465
  import { mkdir as mkdir2 } from "fs/promises";
1501
- import { basename as basename3, dirname as dirname4, join as join7, relative as relative5, resolve as resolve9 } from "path";
1466
+ import { basename as basename3, dirname as dirname4, join as join7, relative as relative4, resolve as resolve9 } from "path";
1502
1467
  var {file: file3, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
1503
1468
  var resolveDevClientDir3 = () => {
1504
1469
  const fromSource = resolve9(import.meta.dir, "../dev/client");
@@ -1543,7 +1508,7 @@ var resolveDevClientDir3 = () => {
1543
1508
  return "template-only";
1544
1509
  }
1545
1510
  return "full";
1546
- }, generateVueHmrId = (sourceFilePath, vueRootDir) => relative5(vueRootDir, sourceFilePath).replace(/\\/g, "/").replace(/\.vue$/, ""), extractImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => importPath !== undefined), toJs = (filePath) => {
1511
+ }, generateVueHmrId = (sourceFilePath, vueRootDir) => relative4(vueRootDir, sourceFilePath).replace(/\\/g, "/").replace(/\.vue$/, ""), extractImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => importPath !== undefined), toJs = (filePath) => {
1547
1512
  if (filePath.endsWith(".vue"))
1548
1513
  return filePath.replace(/\.vue$/, ".js");
1549
1514
  if (filePath.endsWith(".ts"))
@@ -1570,7 +1535,7 @@ var resolveDevClientDir3 = () => {
1570
1535
  const cachedResult = cacheMap.get(sourceFilePath);
1571
1536
  if (cachedResult)
1572
1537
  return cachedResult;
1573
- const relativeFilePath = relative5(vueRootDir, sourceFilePath).replace(/\\/g, "/");
1538
+ const relativeFilePath = relative4(vueRootDir, sourceFilePath).replace(/\\/g, "/");
1574
1539
  const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
1575
1540
  const fileBaseName = basename3(sourceFilePath, ".vue");
1576
1541
  const componentId = toKebab(fileBaseName);
@@ -1699,7 +1664,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1699
1664
  result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
1700
1665
  const entryBaseName = basename3(entryPath, ".vue");
1701
1666
  const indexOutputFile = join7(indexOutputDir, `${entryBaseName}.js`);
1702
- const clientOutputFile = join7(clientOutputDir, relative5(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
1667
+ const clientOutputFile = join7(clientOutputDir, relative4(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
1703
1668
  await mkdir2(dirname4(indexOutputFile), { recursive: true });
1704
1669
  const vueHmrImports = isDev ? [
1705
1670
  `window.__HMR_FRAMEWORK__ = "vue";`,
@@ -1707,7 +1672,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1707
1672
  ] : [];
1708
1673
  await write2(indexOutputFile, [
1709
1674
  ...vueHmrImports,
1710
- `import Comp from "${relative5(dirname4(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
1675
+ `import Comp from "${relative4(dirname4(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
1711
1676
  'import { createSSRApp, createApp } from "vue";',
1712
1677
  "",
1713
1678
  "// HMR State Preservation: Check for preserved state from HMR",
@@ -1807,7 +1772,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1807
1772
  await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
1808
1773
  const sourceCode = await file3(tsPath).text();
1809
1774
  const transpiledCode = transpiler2.transformSync(sourceCode);
1810
- const relativeJsPath = relative5(vueRootDir, tsPath).replace(/\.ts$/, ".js");
1775
+ const relativeJsPath = relative4(vueRootDir, tsPath).replace(/\.ts$/, ".js");
1811
1776
  const outClientPath = join7(clientOutputDir, relativeJsPath);
1812
1777
  const outServerPath = join7(serverOutputDir, relativeJsPath);
1813
1778
  await mkdir2(dirname4(outClientPath), { recursive: true });
@@ -10697,11 +10662,11 @@ ${lanes.join(`
10697
10662
  return toComponents;
10698
10663
  }
10699
10664
  const components = toComponents.slice(start);
10700
- const relative6 = [];
10665
+ const relative5 = [];
10701
10666
  for (;start < fromComponents.length; start++) {
10702
- relative6.push("..");
10667
+ relative5.push("..");
10703
10668
  }
10704
- return ["", ...relative6, ...components];
10669
+ return ["", ...relative5, ...components];
10705
10670
  }
10706
10671
  function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
10707
10672
  Debug.assert(getRootLength(fromDirectory) > 0 === getRootLength(to) > 0, "Paths must either both be absolute or both be relative");
@@ -47997,9 +47962,9 @@ ${lanes.join(`
47997
47962
  if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
47998
47963
  return;
47999
47964
  }
48000
- const relative6 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
47965
+ const relative5 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
48001
47966
  for (const symlinkDirectory of symlinkDirectories) {
48002
- const option = resolvePath(symlinkDirectory, relative6);
47967
+ const option = resolvePath(symlinkDirectory, relative5);
48003
47968
  const result2 = cb(option, target === referenceRedirect);
48004
47969
  shouldFilterIgnoredPaths = true;
48005
47970
  if (result2)
@@ -170565,7 +170530,7 @@ __export(exports_compileAngular, {
170565
170530
  compileAngular: () => compileAngular
170566
170531
  });
170567
170532
  import { existsSync as existsSync10, readFileSync as readFileSync4, promises as fs } from "fs";
170568
- import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve10, relative as relative6 } from "path";
170533
+ import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve10, relative as relative5 } from "path";
170569
170534
  import { createHash as createHash2 } from "crypto";
170570
170535
  var import_typescript, computeConfigHash = () => {
170571
170536
  try {
@@ -170874,7 +170839,7 @@ export default ${componentClassName};
170874
170839
  await fs.writeFile(ssrDepsFile, ssrDepsContent, "utf-8");
170875
170840
  }
170876
170841
  await fs.writeFile(rawServerFile, rewritten, "utf-8");
170877
- const relativePath = relative6(indexesDir, rawServerFile).replace(/\\/g, "/");
170842
+ const relativePath = relative5(indexesDir, rawServerFile).replace(/\\/g, "/");
170878
170843
  const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
170879
170844
  const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
170880
170845
  import "${hmrRuntimePath}";
@@ -171253,7 +171218,7 @@ import {
171253
171218
  rmSync,
171254
171219
  writeFileSync as writeFileSync3
171255
171220
  } from "fs";
171256
- import { basename as basename5, join as join13, relative as relative7, resolve as resolve11 } from "path";
171221
+ import { basename as basename5, join as join13, relative as relative6, resolve as resolve11 } from "path";
171257
171222
  import { cwd, env as env2, exit } from "process";
171258
171223
  var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
171259
171224
  var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
@@ -171675,6 +171640,21 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171675
171640
  }
171676
171641
  const reactClientLogs = reactClientResult?.logs ?? [];
171677
171642
  const reactClientOutputs = reactClientResult?.outputs ?? [];
171643
+ if (hmr && reactClientOutputs.length > 0) {
171644
+ const REFRESH_NOOP_RE = /window\.\$RefreshReg\$\|\|\(window\.\$RefreshReg\$=function\(\)\{\}\);window\.\$RefreshSig\$\|\|\(window\.\$RefreshSig\$=function\(\)\{return function\(t\)\{return t\}\}\);?\n?/g;
171645
+ for (const output of reactClientOutputs) {
171646
+ if (output.kind !== "entry-point")
171647
+ continue;
171648
+ try {
171649
+ const content = await Bun.file(output.path).text();
171650
+ if (REFRESH_NOOP_RE.test(content)) {
171651
+ REFRESH_NOOP_RE.lastIndex = 0;
171652
+ const stripped = content.replace(REFRESH_NOOP_RE, "");
171653
+ writeFileSync3(output.path, stripped);
171654
+ }
171655
+ } catch {}
171656
+ }
171657
+ }
171678
171658
  if (reactClientResult && !reactClientResult.success && reactClientLogs.length > 0) {
171679
171659
  extractBuildError(reactClientLogs, "react-client", "React client", frameworkNames, isIncremental, throwOnError);
171680
171660
  }
@@ -171818,7 +171798,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171818
171798
  const devIndexDir = join13(buildPath, "_src_indexes");
171819
171799
  mkdirSync8(devIndexDir, { recursive: true });
171820
171800
  const indexFiles = readDir(reactIndexesPath).filter((f) => f.endsWith(".tsx"));
171821
- const pagesRel = relative7(process.cwd(), resolve11(reactPagesPath)).replace(/\\/g, "/");
171801
+ const pagesRel = relative6(process.cwd(), resolve11(reactPagesPath)).replace(/\\/g, "/");
171822
171802
  for (const file4 of indexFiles) {
171823
171803
  let content = readFileSync5(join13(reactIndexesPath, file4), "utf-8");
171824
171804
  content = content.replace(/from\s*['"]\.\.\/pages\/([^'"]+)['"]/g, `from '/@src/${pagesRel}/$1'`);
@@ -202357,6 +202337,15 @@ var init_pageHandler = __esm(() => {
202357
202337
  });
202358
202338
 
202359
202339
  // src/dev/transformCache.ts
202340
+ var exports_transformCache = {};
202341
+ __export(exports_transformCache, {
202342
+ setTransformed: () => setTransformed,
202343
+ invalidateAll: () => invalidateAll,
202344
+ invalidate: () => invalidate,
202345
+ getTransformed: () => getTransformed,
202346
+ getInvalidationVersion: () => getInvalidationVersion,
202347
+ findNearestComponent: () => findNearestComponent
202348
+ });
202360
202349
  var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
202361
202350
  const resolvedImports = imports ?? [];
202362
202351
  cache.set(filePath, { content, imports: resolvedImports, mtime });
@@ -202375,6 +202364,28 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
202375
202364
  cache.delete(parent);
202376
202365
  }
202377
202366
  }
202367
+ }, invalidateAll = () => {
202368
+ cache.clear();
202369
+ importers.clear();
202370
+ }, findNearestComponent = (filePath) => {
202371
+ const visited = new Set;
202372
+ const queue = [filePath];
202373
+ while (queue.length > 0) {
202374
+ const current = queue.shift();
202375
+ if (visited.has(current))
202376
+ continue;
202377
+ visited.add(current);
202378
+ const parents = importers.get(current);
202379
+ if (!parents)
202380
+ continue;
202381
+ for (const parent of parents) {
202382
+ if (parent.endsWith(".tsx") || parent.endsWith(".jsx")) {
202383
+ return parent;
202384
+ }
202385
+ queue.push(parent);
202386
+ }
202387
+ }
202388
+ return;
202378
202389
  };
202379
202390
  var init_transformCache = __esm(() => {
202380
202391
  globalStore = globalThis;
@@ -202397,7 +202408,7 @@ __export(exports_moduleServer, {
202397
202408
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
202398
202409
  });
202399
202410
  import { existsSync as existsSync13, readFileSync as readFileSync9, statSync } from "fs";
202400
- import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve18, relative as relative8 } from "path";
202411
+ import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve18, relative as relative7 } from "path";
202401
202412
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
202402
202413
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
202403
202414
  const allExports = [];
@@ -202460,7 +202471,7 @@ ${stubs}
202460
202471
  const fileDir = dirname7(filePath);
202461
202472
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => {
202462
202473
  const absPath = resolve18(fileDir, relPath);
202463
- const rel = relative8(projectRoot, absPath);
202474
+ const rel = relative7(projectRoot, absPath);
202464
202475
  let srcPath = rel;
202465
202476
  if (!extname3(srcPath)) {
202466
202477
  const extensions = [
@@ -202481,19 +202492,19 @@ ${stubs}
202481
202492
  }
202482
202493
  if (extname3(srcPath) === ".svelte") {
202483
202494
  const resolved = resolveSvelteModulePath(resolve18(projectRoot, srcPath));
202484
- const resolvedRel = relative8(projectRoot, resolved);
202495
+ const resolvedRel = relative7(projectRoot, resolved);
202485
202496
  srcPath = resolvedRel;
202486
202497
  }
202487
202498
  return `${prefix}${srcUrl(srcPath, projectRoot)}${suffix}`;
202488
202499
  });
202489
202500
  result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => {
202490
202501
  const absPath = resolve18(fileDir, relPath);
202491
- const rel = relative8(projectRoot, absPath);
202502
+ const rel = relative7(projectRoot, absPath);
202492
202503
  return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
202493
202504
  });
202494
202505
  result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => {
202495
202506
  const absPath = resolve18(fileDir, relPath);
202496
- const rel = relative8(projectRoot, absPath);
202507
+ const rel = relative7(projectRoot, absPath);
202497
202508
  let srcPath = rel;
202498
202509
  if (!extname3(srcPath)) {
202499
202510
  const extensions = [
@@ -202517,10 +202528,10 @@ ${stubs}
202517
202528
  });
202518
202529
  result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, (_match, prefix, absPath, _ext, suffix) => {
202519
202530
  if (absPath.startsWith(projectRoot)) {
202520
- const rel2 = relative8(projectRoot, absPath).replace(/\\/g, "/");
202531
+ const rel2 = relative7(projectRoot, absPath).replace(/\\/g, "/");
202521
202532
  return `${prefix}${srcUrl(rel2, projectRoot)}${suffix}`;
202522
202533
  }
202523
- const rel = relative8(projectRoot, absPath).replace(/\\/g, "/");
202534
+ const rel = relative7(projectRoot, absPath).replace(/\\/g, "/");
202524
202535
  if (!rel.startsWith("..")) {
202525
202536
  return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
202526
202537
  }
@@ -202562,7 +202573,7 @@ ${stubs}
202562
202573
  transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
202563
202574
  ` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
202564
202575
  ` + transpiled;
202565
- const relPath = relative8(projectRoot, filePath).replace(/\\/g, "/");
202576
+ const relPath = relative7(projectRoot, filePath).replace(/\\/g, "/");
202566
202577
  transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
202567
202578
  return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202568
202579
  }, transformPlainFile = (filePath, projectRoot, rewriter) => {
@@ -202629,11 +202640,11 @@ ${stubs}
202629
202640
  if (compiled.css?.code) {
202630
202641
  const cssPath = `${filePath}.css`;
202631
202642
  svelteExternalCss.set(cssPath, compiled.css.code);
202632
- const cssUrl = srcUrl(relative8(projectRoot, cssPath), projectRoot);
202643
+ const cssUrl = srcUrl(relative7(projectRoot, cssPath), projectRoot);
202633
202644
  code = `import "${cssUrl}";
202634
202645
  ${code}`;
202635
202646
  }
202636
- const moduleUrl = `${SRC_PREFIX}${relative8(projectRoot, filePath).replace(/\\/g, "/")}`;
202647
+ const moduleUrl = `${SRC_PREFIX}${relative7(projectRoot, filePath).replace(/\\/g, "/")}`;
202637
202648
  code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
202638
202649
  if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
202639
202650
  var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
@@ -202697,7 +202708,7 @@ ${code}`;
202697
202708
  }
202698
202709
  code = tsTranspiler2.transformSync(code);
202699
202710
  const hmrBase = vueDir ? resolve18(vueDir) : projectRoot;
202700
- const hmrId = relative8(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
202711
+ const hmrId = relative7(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
202701
202712
  code = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
202702
202713
  code += [
202703
202714
  "",
@@ -203060,7 +203071,7 @@ var init_simpleHTMXHMR = () => {};
203060
203071
  // src/dev/rebuildTrigger.ts
203061
203072
  import { existsSync as existsSync14 } from "fs";
203062
203073
  import { rm as rm8 } from "fs/promises";
203063
- import { basename as basename8, relative as relative9, resolve as resolve21 } from "path";
203074
+ import { basename as basename8, relative as relative8, resolve as resolve21 } from "path";
203064
203075
  var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
203065
203076
  const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
203066
203077
  if (pathLineCol) {
@@ -203488,13 +203499,26 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203488
203499
  if (vendorPaths) {
203489
203500
  await rewriteReactImports2(clientResult.outputs.map((art) => art.path), vendorPaths);
203490
203501
  }
203502
+ const { readFileSync: readFs, writeFileSync: writeFs } = await import("fs");
203503
+ const NOOP_RE = /window\.\$RefreshReg\$\|\|\(window\.\$RefreshReg\$=function\(\)\{\}\);window\.\$RefreshSig\$\|\|\(window\.\$RefreshSig\$=function\(\)\{return function\(t\)\{return t\}\}\);?\n?/g;
203504
+ for (const output of clientResult.outputs) {
203505
+ if (output.kind !== "entry-point")
203506
+ continue;
203507
+ try {
203508
+ const content = readFs(output.path, "utf-8");
203509
+ if (NOOP_RE.test(content)) {
203510
+ NOOP_RE.lastIndex = 0;
203511
+ writeFs(output.path, content.replace(NOOP_RE, ""));
203512
+ }
203513
+ } catch {}
203514
+ }
203491
203515
  const clientManifest = generateManifest2(clientResult.outputs, buildDir);
203492
203516
  Object.assign(state.manifest, clientManifest);
203493
203517
  await populateAssetStore(state.assetStore, clientManifest, buildDir);
203494
203518
  }, getModuleUrl = async (pageFile) => {
203495
203519
  const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
203496
203520
  invalidateModule2(pageFile);
203497
- const rel = relative9(process.cwd(), pageFile).replace(/\\/g, "/");
203521
+ const rel = relative8(process.cwd(), pageFile).replace(/\\/g, "/");
203498
203522
  const url = `${SRC_URL_PREFIX2}${rel}`;
203499
203523
  warmCache2(url);
203500
203524
  return url;
@@ -203520,10 +203544,18 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203520
203544
  for (const file4 of reactFiles) {
203521
203545
  invalidateModule2(file4);
203522
203546
  }
203523
- const pageModuleUrl = await getReactModuleUrl(primaryFile);
203547
+ const isComponentFile = primaryFile.endsWith(".tsx") || primaryFile.endsWith(".jsx");
203548
+ let broadcastTarget = primaryFile;
203549
+ if (!isComponentFile) {
203550
+ const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
203551
+ const nearest = findNearestComponent2(resolve21(primaryFile));
203552
+ if (nearest)
203553
+ broadcastTarget = nearest;
203554
+ }
203555
+ const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
203524
203556
  if (pageModuleUrl) {
203525
203557
  const serverDuration = Date.now() - startTime;
203526
- state.lastHmrPath = relative9(process.cwd(), primaryFile).replace(/\\/g, "/");
203558
+ state.lastHmrPath = relative8(process.cwd(), primaryFile).replace(/\\/g, "/");
203527
203559
  state.lastHmrFramework = "react";
203528
203560
  broadcastToClients(state, {
203529
203561
  data: {
@@ -203909,7 +203941,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203909
203941
  const baseName = fileName.replace(/\.vue$/, "");
203910
203942
  const pascalName = toPascal(baseName);
203911
203943
  const vueRoot = config.vueDirectory;
203912
- const hmrId = vueRoot ? relative9(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
203944
+ const hmrId = vueRoot ? relative8(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
203913
203945
  const cssKey = `${pascalName}CSS`;
203914
203946
  const cssUrl = manifest[cssKey] || null;
203915
203947
  const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
@@ -205060,7 +205092,7 @@ var handleHTMLPageRequest = (pagePath) => file(pagePath);
205060
205092
  var handleHTMXPageRequest = (pagePath) => file(pagePath);
205061
205093
  // src/core/prepare.ts
205062
205094
  import { readFileSync as readFileSync10 } from "fs";
205063
- import { relative as relative11, resolve as resolve23 } from "path";
205095
+ import { relative as relative10, resolve as resolve23 } from "path";
205064
205096
 
205065
205097
  // src/utils/loadConfig.ts
205066
205098
  import { resolve } from "path";
@@ -205139,7 +205171,7 @@ var prepare = async (configOrPath) => {
205139
205171
  })) {
205140
205172
  if (file4.includes("/node_modules/"))
205141
205173
  continue;
205142
- const rel = relative11(process.cwd(), file4).replace(/\\/g, "/");
205174
+ const rel = relative10(process.cwd(), file4).replace(/\\/g, "/");
205143
205175
  warmCache2(`${SRC_URL_PREFIX2}${rel}`);
205144
205176
  }
205145
205177
  }
@@ -205149,7 +205181,7 @@ var prepare = async (configOrPath) => {
205149
205181
  if (key.endsWith("Index") && typeof result.manifest[key] === "string" && result.manifest[key].includes("/react/") && result.manifest[key].includes("/indexes/")) {
205150
205182
  const fileName = `${key.replace(/Index$/, "")}.tsx`;
205151
205183
  const srcPath = resolve23(devIndexDir, fileName);
205152
- const rel = relative11(process.cwd(), srcPath).replace(/\\/g, "/");
205184
+ const rel = relative10(process.cwd(), srcPath).replace(/\\/g, "/");
205153
205185
  result.manifest[key] = `${SRC_URL_PREFIX2}${rel}`;
205154
205186
  }
205155
205187
  }
@@ -205319,5 +205351,5 @@ export {
205319
205351
  ANGULAR_INIT_TIMEOUT_MS
205320
205352
  };
205321
205353
 
205322
- //# debugId=9822FF122B8382B864756E2164756E21
205354
+ //# debugId=6252097A699EFD8B64756E2164756E21
205323
205355
  //# sourceMappingURL=index.js.map