@absolutejs/absolute 0.19.0-beta.95 → 0.19.0-beta.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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");
@@ -239,7 +239,6 @@ var indexContentCache, resolveDevClientDir = () => {
239
239
  const hmrPreamble = isDev ? [
240
240
  `window.__HMR_FRAMEWORK__ = "react";`,
241
241
  `window.__REACT_COMPONENT_KEY__ = "${componentName}Index";`,
242
- `window.__REACT_PAGE_MODULE__ = "/@src/${relative(process.cwd(), resolve2(reactPagesDirectory, componentName + ".tsx")).replace(/\\\\/g, "/")}";`,
243
242
  `import '${refreshSetupPath}';`,
244
243
  `import '${hmrClientPath}';`,
245
244
  `import { showErrorOverlay, hideErrorOverlay } from '${errorOverlayPath}';
@@ -279,6 +278,9 @@ var indexContentCache, resolveDevClientDir = () => {
279
278
  ` reset() {`,
280
279
  ` this.setState({ hasError: false });`,
281
280
  ` }`,
281
+ ` hmrUpdate() {`,
282
+ ` this.forceUpdate();`,
283
+ ` }`,
282
284
  ` render() {`,
283
285
  ` if (this.state.hasError) return null;`,
284
286
  ``,
@@ -946,7 +948,7 @@ var devVendorPaths = null, getDevVendorPaths = () => devVendorPaths, setDevVendo
946
948
 
947
949
  // src/build/angularLinkerPlugin.ts
948
950
  import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
949
- import { dirname as dirname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
951
+ import { dirname as dirname2, join as join4, relative, resolve as resolve5 } from "path";
950
952
  import { createHash } from "crypto";
951
953
  var CACHE_DIR, angularLinkerPlugin;
952
954
  var init_angularLinkerPlugin = __esm(() => {
@@ -989,7 +991,7 @@ var init_angularLinkerPlugin = __esm(() => {
989
991
  dirname: dirname2,
990
992
  exists: existsSync7,
991
993
  readFile: readFileSync3,
992
- relative: relative2,
994
+ relative,
993
995
  resolve: resolve5
994
996
  },
995
997
  linkerJitMode: false,
@@ -1030,11 +1032,11 @@ var HASHED_FILE_PATTERN, cleanStaleOutputs = async (buildPath, currentOutputPath
1030
1032
  const currentPaths = new Set(currentOutputPaths.map((path) => resolve6(path)));
1031
1033
  const glob = new Glob4("**/*");
1032
1034
  const removals = [];
1033
- for (const relative3 of glob.scanSync({ cwd: buildPath })) {
1034
- const absolute = resolve6(buildPath, relative3);
1035
+ for (const relative2 of glob.scanSync({ cwd: buildPath })) {
1036
+ const absolute = resolve6(buildPath, relative2);
1035
1037
  if (currentPaths.has(absolute))
1036
1038
  continue;
1037
- if (!HASHED_FILE_PATTERN.test(relative3))
1039
+ if (!HASHED_FILE_PATTERN.test(relative2))
1038
1040
  continue;
1039
1041
  removals.push(rm2(absolute, { force: true }));
1040
1042
  }
@@ -1188,12 +1190,12 @@ var init_startupBanner = __esm(() => {
1188
1190
  // src/utils/logger.ts
1189
1191
  var colors2, frameworkColors, formatPath = (filePath) => {
1190
1192
  const cwd = process.cwd();
1191
- let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
1192
- relative3 = relative3.replace(/\\/g, "/");
1193
- if (!relative3.startsWith("/")) {
1194
- relative3 = `/${relative3}`;
1193
+ let relative2 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
1194
+ relative2 = relative2.replace(/\\/g, "/");
1195
+ if (!relative2.startsWith("/")) {
1196
+ relative2 = `/${relative2}`;
1195
1197
  }
1196
- return relative3;
1198
+ return relative2;
1197
1199
  }, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
1198
1200
  const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1199
1201
  const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
@@ -1252,11 +1254,11 @@ var init_logger = __esm(() => {
1252
1254
  });
1253
1255
 
1254
1256
  // src/utils/validateSafePath.ts
1255
- import { resolve as resolve7, relative as relative3 } from "path";
1257
+ import { resolve as resolve7, relative as relative2 } from "path";
1256
1258
  var validateSafePath = (targetPath, baseDirectory) => {
1257
1259
  const absoluteBase = resolve7(baseDirectory);
1258
1260
  const absoluteTarget = resolve7(baseDirectory, targetPath);
1259
- const relativePath = normalizePath(relative3(absoluteBase, absoluteTarget));
1261
+ const relativePath = normalizePath(relative2(absoluteBase, absoluteTarget));
1260
1262
  if (relativePath.startsWith("../") || relativePath === "..") {
1261
1263
  throw new Error(`Unsafe path: ${targetPath}`);
1262
1264
  }
@@ -1278,7 +1280,7 @@ import {
1278
1280
  basename as basename2,
1279
1281
  extname as extname2,
1280
1282
  resolve as resolve8,
1281
- relative as relative4,
1283
+ relative as relative3,
1282
1284
  sep
1283
1285
  } from "path";
1284
1286
  import { env } from "process";
@@ -1342,7 +1344,7 @@ var resolveDevClientDir2 = () => {
1342
1344
  const isModule = src.endsWith(".svelte.ts") || src.endsWith(".svelte.js");
1343
1345
  const preprocessed = isModule ? raw : (await preprocess(raw, {})).code;
1344
1346
  const transpiled = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed) : preprocessed;
1345
- const relDir = dirname3(relative4(svelteRoot, src)).replace(/\\/g, "/");
1347
+ const relDir = dirname3(relative3(svelteRoot, src)).replace(/\\/g, "/");
1346
1348
  const baseName = basename2(src).replace(/\.svelte(\.(ts|js))?$/, "");
1347
1349
  const importPaths = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
1348
1350
  const resolvedImports = await Promise.all(importPaths.map((importPath) => resolveSvelte(importPath, src)));
@@ -1361,7 +1363,7 @@ var resolveDevClientDir2 = () => {
1361
1363
  }).js.code;
1362
1364
  let code = raw2.replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
1363
1365
  if (mode === "client" && isDev) {
1364
- const moduleKey = `/@src/${relative4(process.cwd(), src).replace(/\\/g, "/")}`;
1366
+ const moduleKey = `/@src/${relative3(process.cwd(), src).replace(/\\/g, "/")}`;
1365
1367
  code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
1366
1368
  if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
1367
1369
  var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleKey)}] = cb; };`);
@@ -1396,10 +1398,10 @@ var resolveDevClientDir2 = () => {
1396
1398
  };
1397
1399
  const roots = await Promise.all(entryPoints.map(build2));
1398
1400
  await Promise.all(roots.map(async ({ client: client2 }) => {
1399
- const relClientDir = dirname3(relative4(clientDir, client2));
1401
+ const relClientDir = dirname3(relative3(clientDir, client2));
1400
1402
  const name = basename2(client2, extname2(client2));
1401
1403
  const indexPath = join6(indexDir, relClientDir, `${name}.js`);
1402
- const importRaw = relative4(dirname3(indexPath), client2).split(sep).join("/");
1404
+ const importRaw = relative3(dirname3(indexPath), client2).split(sep).join("/");
1403
1405
  const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
1404
1406
  const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
1405
1407
  import "${hmrClientPath3}";
@@ -1439,7 +1441,7 @@ if (typeof window !== "undefined") {
1439
1441
  return {
1440
1442
  svelteClientPaths: roots.map(({ client: client2 }) => client2),
1441
1443
  svelteIndexPaths: roots.map(({ client: client2 }) => {
1442
- const rel = dirname3(relative4(clientDir, client2));
1444
+ const rel = dirname3(relative3(clientDir, client2));
1443
1445
  return join6(indexDir, rel, basename2(client2));
1444
1446
  }),
1445
1447
  svelteServerPaths: roots.map(({ ssr }) => ssr)
@@ -1464,7 +1466,7 @@ __export(exports_compileVue, {
1464
1466
  });
1465
1467
  import { existsSync as existsSync9 } from "fs";
1466
1468
  import { mkdir as mkdir2 } from "fs/promises";
1467
- import { basename as basename3, dirname as dirname4, join as join7, relative as relative5, resolve as resolve9 } from "path";
1469
+ import { basename as basename3, dirname as dirname4, join as join7, relative as relative4, resolve as resolve9 } from "path";
1468
1470
  var {file: file3, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
1469
1471
  var resolveDevClientDir3 = () => {
1470
1472
  const fromSource = resolve9(import.meta.dir, "../dev/client");
@@ -1509,7 +1511,7 @@ var resolveDevClientDir3 = () => {
1509
1511
  return "template-only";
1510
1512
  }
1511
1513
  return "full";
1512
- }, 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) => {
1514
+ }, 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) => {
1513
1515
  if (filePath.endsWith(".vue"))
1514
1516
  return filePath.replace(/\.vue$/, ".js");
1515
1517
  if (filePath.endsWith(".ts"))
@@ -1536,7 +1538,7 @@ var resolveDevClientDir3 = () => {
1536
1538
  const cachedResult = cacheMap.get(sourceFilePath);
1537
1539
  if (cachedResult)
1538
1540
  return cachedResult;
1539
- const relativeFilePath = relative5(vueRootDir, sourceFilePath).replace(/\\/g, "/");
1541
+ const relativeFilePath = relative4(vueRootDir, sourceFilePath).replace(/\\/g, "/");
1540
1542
  const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
1541
1543
  const fileBaseName = basename3(sourceFilePath, ".vue");
1542
1544
  const componentId = toKebab(fileBaseName);
@@ -1665,7 +1667,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1665
1667
  result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
1666
1668
  const entryBaseName = basename3(entryPath, ".vue");
1667
1669
  const indexOutputFile = join7(indexOutputDir, `${entryBaseName}.js`);
1668
- const clientOutputFile = join7(clientOutputDir, relative5(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
1670
+ const clientOutputFile = join7(clientOutputDir, relative4(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
1669
1671
  await mkdir2(dirname4(indexOutputFile), { recursive: true });
1670
1672
  const vueHmrImports = isDev ? [
1671
1673
  `window.__HMR_FRAMEWORK__ = "vue";`,
@@ -1673,7 +1675,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1673
1675
  ] : [];
1674
1676
  await write2(indexOutputFile, [
1675
1677
  ...vueHmrImports,
1676
- `import Comp from "${relative5(dirname4(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
1678
+ `import Comp from "${relative4(dirname4(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
1677
1679
  'import { createSSRApp, createApp } from "vue";',
1678
1680
  "",
1679
1681
  "// HMR State Preservation: Check for preserved state from HMR",
@@ -1773,7 +1775,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1773
1775
  await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
1774
1776
  const sourceCode = await file3(tsPath).text();
1775
1777
  const transpiledCode = transpiler2.transformSync(sourceCode);
1776
- const relativeJsPath = relative5(vueRootDir, tsPath).replace(/\.ts$/, ".js");
1778
+ const relativeJsPath = relative4(vueRootDir, tsPath).replace(/\.ts$/, ".js");
1777
1779
  const outClientPath = join7(clientOutputDir, relativeJsPath);
1778
1780
  const outServerPath = join7(serverOutputDir, relativeJsPath);
1779
1781
  await mkdir2(dirname4(outClientPath), { recursive: true });
@@ -10663,11 +10665,11 @@ ${lanes.join(`
10663
10665
  return toComponents;
10664
10666
  }
10665
10667
  const components = toComponents.slice(start);
10666
- const relative6 = [];
10668
+ const relative5 = [];
10667
10669
  for (;start < fromComponents.length; start++) {
10668
- relative6.push("..");
10670
+ relative5.push("..");
10669
10671
  }
10670
- return ["", ...relative6, ...components];
10672
+ return ["", ...relative5, ...components];
10671
10673
  }
10672
10674
  function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
10673
10675
  Debug.assert(getRootLength(fromDirectory) > 0 === getRootLength(to) > 0, "Paths must either both be absolute or both be relative");
@@ -47963,9 +47965,9 @@ ${lanes.join(`
47963
47965
  if (!startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
47964
47966
  return;
47965
47967
  }
47966
- const relative6 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
47968
+ const relative5 = getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
47967
47969
  for (const symlinkDirectory of symlinkDirectories) {
47968
- const option = resolvePath(symlinkDirectory, relative6);
47970
+ const option = resolvePath(symlinkDirectory, relative5);
47969
47971
  const result2 = cb(option, target === referenceRedirect);
47970
47972
  shouldFilterIgnoredPaths = true;
47971
47973
  if (result2)
@@ -170531,7 +170533,7 @@ __export(exports_compileAngular, {
170531
170533
  compileAngular: () => compileAngular
170532
170534
  });
170533
170535
  import { existsSync as existsSync10, readFileSync as readFileSync4, promises as fs } from "fs";
170534
- import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve10, relative as relative6 } from "path";
170536
+ import { join as join8, basename as basename4, sep as sep2, dirname as dirname5, resolve as resolve10, relative as relative5 } from "path";
170535
170537
  import { createHash as createHash2 } from "crypto";
170536
170538
  var import_typescript, computeConfigHash = () => {
170537
170539
  try {
@@ -170840,7 +170842,7 @@ export default ${componentClassName};
170840
170842
  await fs.writeFile(ssrDepsFile, ssrDepsContent, "utf-8");
170841
170843
  }
170842
170844
  await fs.writeFile(rawServerFile, rewritten, "utf-8");
170843
- const relativePath = relative6(indexesDir, rawServerFile).replace(/\\/g, "/");
170845
+ const relativePath = relative5(indexesDir, rawServerFile).replace(/\\/g, "/");
170844
170846
  const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
170845
170847
  const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
170846
170848
  import "${hmrRuntimePath}";
@@ -171219,7 +171221,7 @@ import {
171219
171221
  rmSync,
171220
171222
  writeFileSync as writeFileSync3
171221
171223
  } from "fs";
171222
- import { basename as basename5, join as join13, relative as relative7, resolve as resolve11 } from "path";
171224
+ import { basename as basename5, join as join13, relative as relative6, resolve as resolve11 } from "path";
171223
171225
  import { cwd, env as env2, exit } from "process";
171224
171226
  var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
171225
171227
  var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
@@ -171784,7 +171786,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171784
171786
  const devIndexDir = join13(buildPath, "_src_indexes");
171785
171787
  mkdirSync8(devIndexDir, { recursive: true });
171786
171788
  const indexFiles = readDir(reactIndexesPath).filter((f) => f.endsWith(".tsx"));
171787
- const pagesRel = relative7(process.cwd(), resolve11(reactPagesPath)).replace(/\\/g, "/");
171789
+ const pagesRel = relative6(process.cwd(), resolve11(reactPagesPath)).replace(/\\/g, "/");
171788
171790
  for (const file4 of indexFiles) {
171789
171791
  let content = readFileSync5(join13(reactIndexesPath, file4), "utf-8");
171790
171792
  content = content.replace(/from\s*['"]\.\.\/pages\/([^'"]+)['"]/g, `from '/@src/${pagesRel}/$1'`);
@@ -202323,6 +202325,17 @@ var init_pageHandler = __esm(() => {
202323
202325
  });
202324
202326
 
202325
202327
  // src/dev/transformCache.ts
202328
+ var exports_transformCache = {};
202329
+ __export(exports_transformCache, {
202330
+ setTransformed: () => setTransformed,
202331
+ markAsDataFile: () => markAsDataFile,
202332
+ isDataFile: () => isDataFile,
202333
+ invalidateAll: () => invalidateAll,
202334
+ invalidate: () => invalidate,
202335
+ getTransformed: () => getTransformed,
202336
+ getInvalidationVersion: () => getInvalidationVersion,
202337
+ findNearestComponent: () => findNearestComponent
202338
+ });
202326
202339
  var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
202327
202340
  const resolvedImports = imports ?? [];
202328
202341
  cache.set(filePath, { content, imports: resolvedImports, mtime });
@@ -202341,6 +202354,30 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
202341
202354
  cache.delete(parent);
202342
202355
  }
202343
202356
  }
202357
+ }, invalidateAll = () => {
202358
+ cache.clear();
202359
+ importers.clear();
202360
+ }, dataFiles, markAsDataFile = (filePath) => {
202361
+ dataFiles.add(filePath);
202362
+ }, isDataFile = (filePath) => dataFiles.has(filePath), findNearestComponent = (filePath) => {
202363
+ const visited = new Set;
202364
+ const queue = [filePath];
202365
+ while (queue.length > 0) {
202366
+ const current = queue.shift();
202367
+ if (visited.has(current))
202368
+ continue;
202369
+ visited.add(current);
202370
+ const parents = importers.get(current);
202371
+ if (!parents)
202372
+ continue;
202373
+ for (const parent of parents) {
202374
+ if (parent.endsWith(".tsx") || parent.endsWith(".jsx")) {
202375
+ return parent;
202376
+ }
202377
+ queue.push(parent);
202378
+ }
202379
+ }
202380
+ return;
202344
202381
  };
202345
202382
  var init_transformCache = __esm(() => {
202346
202383
  globalStore = globalThis;
@@ -202350,6 +202387,8 @@ var init_transformCache = __esm(() => {
202350
202387
  globalStore.__transformImporters = importers;
202351
202388
  invalidationVersions = globalStore.__transformInvalidationVersions ?? new Map;
202352
202389
  globalStore.__transformInvalidationVersions = invalidationVersions;
202390
+ dataFiles = globalStore.__transformDataFiles ?? new Set;
202391
+ globalStore.__transformDataFiles = dataFiles;
202353
202392
  });
202354
202393
 
202355
202394
  // src/dev/moduleServer.ts
@@ -202363,7 +202402,7 @@ __export(exports_moduleServer, {
202363
202402
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
202364
202403
  });
202365
202404
  import { existsSync as existsSync13, readFileSync as readFileSync9, statSync } from "fs";
202366
- import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve18, relative as relative8 } from "path";
202405
+ import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve18, relative as relative7 } from "path";
202367
202406
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
202368
202407
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
202369
202408
  const allExports = [];
@@ -202426,7 +202465,7 @@ ${stubs}
202426
202465
  const fileDir = dirname7(filePath);
202427
202466
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => {
202428
202467
  const absPath = resolve18(fileDir, relPath);
202429
- const rel = relative8(projectRoot, absPath);
202468
+ const rel = relative7(projectRoot, absPath);
202430
202469
  let srcPath = rel;
202431
202470
  if (!extname3(srcPath)) {
202432
202471
  const extensions = [
@@ -202447,19 +202486,19 @@ ${stubs}
202447
202486
  }
202448
202487
  if (extname3(srcPath) === ".svelte") {
202449
202488
  const resolved = resolveSvelteModulePath(resolve18(projectRoot, srcPath));
202450
- const resolvedRel = relative8(projectRoot, resolved);
202489
+ const resolvedRel = relative7(projectRoot, resolved);
202451
202490
  srcPath = resolvedRel;
202452
202491
  }
202453
202492
  return `${prefix}${srcUrl(srcPath, projectRoot)}${suffix}`;
202454
202493
  });
202455
202494
  result = result.replace(/(import\s*\(\s*["'])(\.\.?\/[^"']+)(["']\s*\))/g, (_match, prefix, relPath, suffix) => {
202456
202495
  const absPath = resolve18(fileDir, relPath);
202457
- const rel = relative8(projectRoot, absPath);
202496
+ const rel = relative7(projectRoot, absPath);
202458
202497
  return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
202459
202498
  });
202460
202499
  result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => {
202461
202500
  const absPath = resolve18(fileDir, relPath);
202462
- const rel = relative8(projectRoot, absPath);
202501
+ const rel = relative7(projectRoot, absPath);
202463
202502
  let srcPath = rel;
202464
202503
  if (!extname3(srcPath)) {
202465
202504
  const extensions = [
@@ -202483,16 +202522,30 @@ ${stubs}
202483
202522
  });
202484
202523
  result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, (_match, prefix, absPath, _ext, suffix) => {
202485
202524
  if (absPath.startsWith(projectRoot)) {
202486
- const rel2 = relative8(projectRoot, absPath).replace(/\\/g, "/");
202525
+ const rel2 = relative7(projectRoot, absPath).replace(/\\/g, "/");
202487
202526
  return `${prefix}${srcUrl(rel2, projectRoot)}${suffix}`;
202488
202527
  }
202489
- const rel = relative8(projectRoot, absPath).replace(/\\/g, "/");
202528
+ const rel = relative7(projectRoot, absPath).replace(/\\/g, "/");
202490
202529
  if (!rel.startsWith("..")) {
202491
202530
  return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
202492
202531
  }
202493
202532
  return _match;
202494
202533
  });
202495
202534
  return result;
202535
+ }, NAMED_IMPORT_RE, rewriteDataImports = (code, projectRoot) => {
202536
+ let counter = 0;
202537
+ return code.replace(NAMED_IMPORT_RE, (_match, names, q1, srcUrl2, q2) => {
202538
+ const urlPath = srcUrl2.replace(/^\/\@src\//, "").split("?")[0];
202539
+ if (!urlPath)
202540
+ return _match;
202541
+ const absPath = resolve18(projectRoot, urlPath);
202542
+ if (!isDataFile(absPath))
202543
+ return _match;
202544
+ const alias = `__hmr_${counter++}`;
202545
+ const trimmedNames = names.trim();
202546
+ return `import ${alias} from ${q1}${srcUrl2}${q2};
202547
+ const { ${trimmedNames} } = ${alias}`;
202548
+ });
202496
202549
  }, HOOK_NAMES, REFRESH_PREAMBLE, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
202497
202550
  const imports = [];
202498
202551
  const jsxDevMatch = JSX_AUTO_RE.exec(code);
@@ -202528,9 +202581,36 @@ ${stubs}
202528
202581
  transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
202529
202582
  ` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
202530
202583
  ` + transpiled;
202531
- const relPath = relative8(projectRoot, filePath).replace(/\\/g, "/");
202584
+ const relPath = relative7(projectRoot, filePath).replace(/\\/g, "/");
202532
202585
  transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
202533
- return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202586
+ let result = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202587
+ result = rewriteDataImports(result, projectRoot);
202588
+ return result;
202589
+ }, isDataOnlyFile = (exports, transpiled) => {
202590
+ if (exports.length === 0)
202591
+ return false;
202592
+ if (exports.some((e) => /^[A-Z]/.test(e) && /^(use|[A-Z])/.test(e)))
202593
+ return false;
202594
+ if (/export\s+(function|class|async\s+function)\s/.test(transpiled))
202595
+ return false;
202596
+ return true;
202597
+ }, wrapDataExports = (transpiled, filePath, exports) => {
202598
+ const storeKey = filePath.replace(/\\/g, "/");
202599
+ let result = transpiled;
202600
+ const preamble = `const __hmr = ((globalThis.__HMR_DATA__ ??= {})[${JSON.stringify(storeKey)}] ??= {});
202601
+ `;
202602
+ for (const name of exports) {
202603
+ result = result.replace(new RegExp(`export\\s+const\\s+${name}\\s*=`), `__hmr.${name} =`);
202604
+ result = result.replace(new RegExp(`export\\s+var\\s+${name}\\s*=`), `__hmr.${name} =`);
202605
+ result = result.replace(new RegExp(`export\\s+let\\s+${name}\\s*=`), `__hmr.${name} =`);
202606
+ }
202607
+ const defaultExport = `
202608
+ export default __hmr;
202609
+ `;
202610
+ const namedExports = exports.map((name) => `export const ${name} = __hmr.${name};`).join(`
202611
+ `);
202612
+ return preamble + result + `
202613
+ ` + namedExports + defaultExport;
202534
202614
  }, transformPlainFile = (filePath, projectRoot, rewriter) => {
202535
202615
  const raw = readFileSync9(filePath, "utf-8");
202536
202616
  const ext = extname3(filePath);
@@ -202542,7 +202622,13 @@ ${stubs}
202542
202622
  if (isTS) {
202543
202623
  transpiled = preserveTypeExports(raw, transpiled, valueExports);
202544
202624
  }
202545
- return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202625
+ if (isTS && !isTSX && isDataOnlyFile(valueExports, transpiled)) {
202626
+ transpiled = wrapDataExports(transpiled, filePath, valueExports);
202627
+ markAsDataFile(filePath);
202628
+ }
202629
+ let result = rewriteImports2(transpiled, filePath, projectRoot, rewriter);
202630
+ result = rewriteDataImports(result, projectRoot);
202631
+ return result;
202546
202632
  }, svelteExternalCss, svelteCompiler = null, vueCompiler = null, warmCompilers = async (frameworks) => {
202547
202633
  const [sc, vc] = await Promise.all([
202548
202634
  frameworks.svelte ? import("svelte/compiler") : undefined,
@@ -202595,11 +202681,11 @@ ${stubs}
202595
202681
  if (compiled.css?.code) {
202596
202682
  const cssPath = `${filePath}.css`;
202597
202683
  svelteExternalCss.set(cssPath, compiled.css.code);
202598
- const cssUrl = srcUrl(relative8(projectRoot, cssPath), projectRoot);
202684
+ const cssUrl = srcUrl(relative7(projectRoot, cssPath), projectRoot);
202599
202685
  code = `import "${cssUrl}";
202600
202686
  ${code}`;
202601
202687
  }
202602
- const moduleUrl = `${SRC_PREFIX}${relative8(projectRoot, filePath).replace(/\\/g, "/")}`;
202688
+ const moduleUrl = `${SRC_PREFIX}${relative7(projectRoot, filePath).replace(/\\/g, "/")}`;
202603
202689
  code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
202604
202690
  if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
202605
202691
  var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
@@ -202663,7 +202749,7 @@ ${code}`;
202663
202749
  }
202664
202750
  code = tsTranspiler2.transformSync(code);
202665
202751
  const hmrBase = vueDir ? resolve18(vueDir) : projectRoot;
202666
- const hmrId = relative8(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
202752
+ const hmrId = relative7(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
202667
202753
  code = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
202668
202754
  code += [
202669
202755
  "",
@@ -202920,6 +203006,7 @@ var init_moduleServer = __esm(() => {
202920
203006
  STRING_CONTENTS_RE = /`(?:[^`\\]|\\.)*`|'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/gs;
202921
203007
  REACT_EXTENSIONS = new Set([".tsx", ".jsx"]);
202922
203008
  mtimeCache = new Map;
203009
+ NAMED_IMPORT_RE = /import\s*\{([^}]+)\}\s*from\s*(["'])(\/\@src\/[^"']+)(["']);?/g;
202923
203010
  HOOK_NAMES = new Set([
202924
203011
  "useState",
202925
203012
  "useReducer",
@@ -203022,7 +203109,7 @@ var init_simpleHTMXHMR = () => {};
203022
203109
  // src/dev/rebuildTrigger.ts
203023
203110
  import { existsSync as existsSync14 } from "fs";
203024
203111
  import { rm as rm8 } from "fs/promises";
203025
- import { basename as basename8, dirname as dirname8, relative as relative9, resolve as resolve21 } from "path";
203112
+ import { basename as basename8, relative as relative8, resolve as resolve21 } from "path";
203026
203113
  var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
203027
203114
  const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
203028
203115
  if (pathLineCol) {
@@ -203456,7 +203543,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203456
203543
  }, getModuleUrl = async (pageFile) => {
203457
203544
  const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
203458
203545
  invalidateModule2(pageFile);
203459
- const rel = relative9(process.cwd(), pageFile).replace(/\\/g, "/");
203546
+ const rel = relative8(process.cwd(), pageFile).replace(/\\/g, "/");
203460
203547
  const url = `${SRC_URL_PREFIX2}${rel}`;
203461
203548
  warmCache2(url);
203462
203549
  return url;
@@ -203466,12 +203553,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203466
203553
  const reactIndexesPath = resolve21(reactDir, "indexes");
203467
203554
  const { buildDir } = state.resolvedPaths;
203468
203555
  const reactFiles = filesToRebuild.filter((file4) => detectFramework(file4, state.resolvedPaths) === "react");
203469
- const componentFiles = reactFiles.filter((f) => f.endsWith(".tsx") || f.endsWith(".jsx"));
203470
- if (componentFiles.length > 0 && componentFiles.length === reactFiles.length) {
203556
+ if (reactFiles.length > 0) {
203471
203557
  for (const file4 of reactFiles) {
203472
203558
  state.fileHashes.set(resolve21(file4), computeFileHash(file4));
203473
203559
  }
203474
- const primaryFile = componentFiles.find((f) => !f.replace(/\\/g, "/").includes("/pages/")) ?? componentFiles[0];
203560
+ const primaryFile = reactFiles.find((f) => !f.replace(/\\/g, "/").includes("/pages/")) ?? reactFiles[0];
203475
203561
  if (!primaryFile) {
203476
203562
  onRebuildComplete({
203477
203563
  hmrState: state,
@@ -203483,10 +203569,18 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203483
203569
  for (const file4 of reactFiles) {
203484
203570
  invalidateModule2(file4);
203485
203571
  }
203486
- const pageModuleUrl = await getReactModuleUrl(primaryFile);
203572
+ const isComponentFile = primaryFile.endsWith(".tsx") || primaryFile.endsWith(".jsx");
203573
+ let broadcastTarget = primaryFile;
203574
+ if (!isComponentFile) {
203575
+ const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
203576
+ const nearest = findNearestComponent2(resolve21(primaryFile));
203577
+ if (nearest)
203578
+ broadcastTarget = nearest;
203579
+ }
203580
+ const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
203487
203581
  if (pageModuleUrl) {
203488
203582
  const serverDuration = Date.now() - startTime;
203489
- state.lastHmrPath = relative9(process.cwd(), primaryFile).replace(/\\/g, "/");
203583
+ state.lastHmrPath = relative8(process.cwd(), primaryFile).replace(/\\/g, "/");
203490
203584
  state.lastHmrFramework = "react";
203491
203585
  broadcastToClients(state, {
203492
203586
  data: {
@@ -203872,7 +203966,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203872
203966
  const baseName = fileName.replace(/\.vue$/, "");
203873
203967
  const pascalName = toPascal(baseName);
203874
203968
  const vueRoot = config.vueDirectory;
203875
- const hmrId = vueRoot ? relative9(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
203969
+ const hmrId = vueRoot ? relative8(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
203876
203970
  const cssKey = `${pascalName}CSS`;
203877
203971
  const cssUrl = manifest[cssKey] || null;
203878
203972
  const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
@@ -204212,11 +204306,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204212
204306
  files.filter((f) => detectFramework(f, state.resolvedPaths) === "angular").forEach((f) => handled.add(f));
204213
204307
  }
204214
204308
  if (config.reactDirectory && affectedFrameworks.includes("react")) {
204215
- const reactComponentFiles = files.filter((f) => detectFramework(f, state.resolvedPaths) === "react" && (f.endsWith(".tsx") || f.endsWith(".jsx")));
204216
- if (reactComponentFiles.length > 0) {
204217
- await handleReactFastPath(state, config, files, startTime, onRebuildComplete);
204218
- }
204219
- reactComponentFiles.forEach((f) => handled.add(f));
204309
+ await handleReactFastPath(state, config, files, startTime, onRebuildComplete);
204310
+ files.filter((f) => detectFramework(f, state.resolvedPaths) === "react").forEach((f) => handled.add(f));
204220
204311
  }
204221
204312
  if (config.svelteDirectory && affectedFrameworks.includes("svelte")) {
204222
204313
  await handleSvelteFastPath(state, config, files, startTime, onRebuildComplete);
@@ -204331,19 +204422,6 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204331
204422
  });
204332
204423
  return state.manifest;
204333
204424
  }
204334
- const hasNonComponentFiles = (filesToRebuild ?? []).some((f) => f.endsWith(".ts") && !f.endsWith(".d.ts"));
204335
- const subprocessConfig = hasNonComponentFiles ? {
204336
- buildDirectory: config.buildDirectory,
204337
- assetsDirectory: config.assetsDirectory,
204338
- reactDirectory: config.reactDirectory,
204339
- stylesConfig: config.stylesConfig,
204340
- options: {
204341
- ...config.options,
204342
- baseManifest: state.manifest,
204343
- injectHMR: true,
204344
- throwOnError: true
204345
- }
204346
- } : undefined;
204347
204425
  const buildConfig = {
204348
204426
  ...config,
204349
204427
  incrementalFiles: filesToRebuild && filesToRebuild.length > 0 ? filesToRebuild : undefined,
@@ -204354,52 +204432,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204354
204432
  throwOnError: true
204355
204433
  }
204356
204434
  };
204357
- let manifest;
204358
- if (hasNonComponentFiles && subprocessConfig) {
204359
- const distDir = dirname8(new URL(import.meta.url).pathname);
204360
- const workerPath = resolve21(distDir, "freshBuildWorker.js");
204361
- const configJson = JSON.stringify(subprocessConfig);
204362
- const proc = Bun.spawn(["bun", "run", workerPath, configJson], {
204363
- cwd: process.cwd(),
204364
- stderr: "pipe",
204365
- stdout: "pipe"
204366
- });
204367
- const stdout = await new Response(proc.stdout).text();
204368
- const stderr = await new Response(proc.stderr).text();
204369
- await proc.exited;
204370
- if (proc.exitCode !== 0) {
204371
- logWarn(`Fresh build failed: ${stderr.slice(0, 300)}`);
204372
- manifest = await build2(buildConfig);
204373
- } else {
204374
- const manifestLine = stdout.split(`
204375
- `).find((l) => l.startsWith("__MANIFEST__"));
204376
- if (manifestLine) {
204377
- const freshManifest = JSON.parse(manifestLine.slice("__MANIFEST__".length));
204378
- for (const [key, value] of Object.entries(freshManifest)) {
204379
- state.manifest[key] = value;
204380
- }
204381
- manifest = state.manifest;
204382
- } else {
204383
- manifest = await build2(buildConfig);
204384
- }
204385
- }
204386
- } else {
204387
- manifest = await build2(buildConfig);
204388
- }
204435
+ const manifest = await build2(buildConfig);
204389
204436
  if (!manifest) {
204390
204437
  throw new Error("Build failed - no manifest generated");
204391
204438
  }
204392
204439
  const duration = Date.now() - startTime;
204393
- const wasSubprocess = hasNonComponentFiles && subprocessConfig;
204394
- if (wasSubprocess) {
204395
- const dataFile = (filesToRebuild ?? []).find((f) => f.endsWith(".ts") && !f.endsWith(".d.ts"));
204396
- if (dataFile) {
204397
- const path = relative9(process.cwd(), dataFile).replace(/\\/g, "/");
204398
- logHmrUpdate(path, "react", duration);
204399
- }
204400
- state.lastHmrPath = undefined;
204401
- state.lastHmrFramework = undefined;
204402
- }
204403
204440
  sendTelemetryEvent("hmr:rebuild-complete", {
204404
204441
  durationMs: duration,
204405
204442
  fileCount: filesToRebuild?.length ?? 0,
@@ -204410,17 +204447,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204410
204447
  broadcastToClients(state, {
204411
204448
  data: {
204412
204449
  affectedFrameworks,
204413
- fullReload: wasSubprocess,
204414
204450
  manifest
204415
204451
  },
204416
204452
  message: "Rebuild completed successfully",
204417
204453
  type: "rebuild-complete"
204418
204454
  });
204419
- if (filesToRebuild && filesToRebuild.length > 0 && !wasSubprocess) {
204455
+ if (filesToRebuild && filesToRebuild.length > 0) {
204420
204456
  await handleFullBuildHMR(state, config, affectedFrameworks, filesToRebuild, manifest, duration);
204421
204457
  }
204422
- if (!wasSubprocess)
204423
- broadcastFrameworkUpdates(state, affectedFrameworks, filesToRebuild, manifest, startTime);
204458
+ broadcastFrameworkUpdates(state, affectedFrameworks, filesToRebuild, manifest, startTime);
204424
204459
  if (affectedFrameworks.includes("angular")) {
204425
204460
  invalidateAngularSsrCache();
204426
204461
  }
@@ -205071,7 +205106,7 @@ var handleHTMLPageRequest = (pagePath) => file(pagePath);
205071
205106
  var handleHTMXPageRequest = (pagePath) => file(pagePath);
205072
205107
  // src/core/prepare.ts
205073
205108
  import { readFileSync as readFileSync10 } from "fs";
205074
- import { relative as relative11, resolve as resolve23 } from "path";
205109
+ import { relative as relative10, resolve as resolve23 } from "path";
205075
205110
 
205076
205111
  // src/utils/loadConfig.ts
205077
205112
  import { resolve } from "path";
@@ -205150,7 +205185,7 @@ var prepare = async (configOrPath) => {
205150
205185
  })) {
205151
205186
  if (file4.includes("/node_modules/"))
205152
205187
  continue;
205153
- const rel = relative11(process.cwd(), file4).replace(/\\/g, "/");
205188
+ const rel = relative10(process.cwd(), file4).replace(/\\/g, "/");
205154
205189
  warmCache2(`${SRC_URL_PREFIX2}${rel}`);
205155
205190
  }
205156
205191
  }
@@ -205160,7 +205195,7 @@ var prepare = async (configOrPath) => {
205160
205195
  if (key.endsWith("Index") && typeof result.manifest[key] === "string" && result.manifest[key].includes("/react/") && result.manifest[key].includes("/indexes/")) {
205161
205196
  const fileName = `${key.replace(/Index$/, "")}.tsx`;
205162
205197
  const srcPath = resolve23(devIndexDir, fileName);
205163
- const rel = relative11(process.cwd(), srcPath).replace(/\\/g, "/");
205198
+ const rel = relative10(process.cwd(), srcPath).replace(/\\/g, "/");
205164
205199
  result.manifest[key] = `${SRC_URL_PREFIX2}${rel}`;
205165
205200
  }
205166
205201
  }
@@ -205330,5 +205365,5 @@ export {
205330
205365
  ANGULAR_INIT_TIMEOUT_MS
205331
205366
  };
205332
205367
 
205333
- //# debugId=6E4CB61F15FAF56464756E2164756E21
205368
+ //# debugId=961251AD68B6490564756E2164756E21
205334
205369
  //# sourceMappingURL=index.js.map