@absolutejs/absolute 0.19.0-beta.124 → 0.19.0-beta.126

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
@@ -171249,7 +171249,7 @@ import {
171249
171249
  rmSync,
171250
171250
  writeFileSync as writeFileSync3
171251
171251
  } from "fs";
171252
- import { basename as basename5, join as join13, relative as relative7, resolve as resolve11 } from "path";
171252
+ import { basename as basename5, dirname as dirname6, join as join13, relative as relative7, resolve as resolve11 } from "path";
171253
171253
  import { cwd, env as env2, exit } from "process";
171254
171254
  var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
171255
171255
  var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
@@ -171299,6 +171299,28 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171299
171299
  globalThis.__absoluteVersion = pkg.version;
171300
171300
  return;
171301
171301
  }
171302
+ }, scanWorkerReferences = async (dirs) => {
171303
+ const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
171304
+ const resolvePattern = /import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g;
171305
+ const workerPaths = new Set;
171306
+ for (const dir of dirs) {
171307
+ const glob = new Glob5("**/*.{ts,tsx,js,jsx}");
171308
+ for await (const file4 of glob.scan({ absolute: true, cwd: dir })) {
171309
+ const content = readFileSync5(file4, "utf-8");
171310
+ for (const pattern of [urlPattern, resolvePattern]) {
171311
+ pattern.lastIndex = 0;
171312
+ let match;
171313
+ while ((match = pattern.exec(content)) !== null) {
171314
+ const relPath = match[1];
171315
+ if (!relPath)
171316
+ continue;
171317
+ const absPath = resolve11(file4, "..", relPath);
171318
+ workerPaths.add(absPath);
171319
+ }
171320
+ }
171321
+ }
171322
+ }
171323
+ return [...workerPaths];
171302
171324
  }, vueFeatureFlags, build2 = async ({
171303
171325
  buildDirectory = "build",
171304
171326
  assetsDirectory,
@@ -171711,6 +171733,68 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171711
171733
  if (vueCssResult && !vueCssResult.success && vueCssResult.logs.length > 0) {
171712
171734
  extractBuildError(vueCssResult.logs, "vue-css", "Vue CSS", frameworkNames, isIncremental, throwOnError);
171713
171735
  }
171736
+ const frameworkDirs = [
171737
+ reactDir,
171738
+ svelteDir,
171739
+ vueDir,
171740
+ angularDir,
171741
+ htmlDir,
171742
+ htmxDir
171743
+ ].filter((d) => Boolean(d));
171744
+ const workerEntryPoints = await scanWorkerReferences(frameworkDirs);
171745
+ let workerOutputs = [];
171746
+ if (workerEntryPoints.length > 0) {
171747
+ const workerResult = await bunBuild6({
171748
+ entrypoints: workerEntryPoints,
171749
+ format: "esm",
171750
+ minify: !isDev,
171751
+ naming: "[dir]/[name].[hash].[ext]",
171752
+ outdir: buildPath,
171753
+ root: commonAncestor(workerEntryPoints.map((p) => dirname6(p))),
171754
+ target: "browser",
171755
+ throw: false
171756
+ });
171757
+ if (workerResult.success) {
171758
+ workerOutputs = workerResult.outputs;
171759
+ const workerUrlMap = new Map;
171760
+ for (const artifact of workerOutputs) {
171761
+ for (const ep of workerEntryPoints) {
171762
+ const epBase = basename5(ep).replace(/\.[^.]+$/, "");
171763
+ if (basename5(artifact.path).startsWith(epBase)) {
171764
+ workerUrlMap.set(ep, "/" + relative7(buildPath, artifact.path));
171765
+ }
171766
+ }
171767
+ }
171768
+ const allClientOutputPaths = [
171769
+ ...reactClientOutputPaths,
171770
+ ...nonReactClientOutputs.map((a) => a.path)
171771
+ ];
171772
+ for (const outputPath of allClientOutputPaths) {
171773
+ let content = readFileSync5(outputPath, "utf-8");
171774
+ let changed = false;
171775
+ for (const [srcPath, hashedPath] of workerUrlMap) {
171776
+ const srcRelPatterns = [
171777
+ "./" + relative7(buildPath, srcPath),
171778
+ "../" + relative7(buildPath, srcPath),
171779
+ relative7(buildPath, srcPath)
171780
+ ];
171781
+ for (const pattern of srcRelPatterns) {
171782
+ if (content.includes(pattern)) {
171783
+ content = content.replaceAll(pattern, hashedPath);
171784
+ changed = true;
171785
+ }
171786
+ }
171787
+ }
171788
+ if (changed)
171789
+ writeFileSync3(outputPath, content);
171790
+ }
171791
+ } else {
171792
+ const workerLogs = workerResult.logs;
171793
+ if (workerLogs.length > 0) {
171794
+ extractBuildError(workerLogs, "worker", "Worker", frameworkNames, isIncremental, throwOnError);
171795
+ }
171796
+ }
171797
+ }
171714
171798
  const allLogs = [
171715
171799
  ...serverLogs,
171716
171800
  ...reactClientLogs,
@@ -171724,7 +171808,8 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171724
171808
  ...serverOutputs,
171725
171809
  ...reactClientOutputs,
171726
171810
  ...nonReactClientOutputs,
171727
- ...cssOutputs
171811
+ ...cssOutputs,
171812
+ ...workerOutputs
171728
171813
  ], buildPath)
171729
171814
  };
171730
171815
  for (const artifact of serverOutputs) {
@@ -172793,7 +172878,7 @@ var init_registerClientScript = __esm(() => {
172793
172878
 
172794
172879
  // src/angular/injectorPatch.ts
172795
172880
  import { readFileSync as readFileSync8, writeFileSync as writeFileSync4 } from "fs";
172796
- import { dirname as dirname6, join as join15 } from "path";
172881
+ import { dirname as dirname7, join as join15 } from "path";
172797
172882
  var applyInjectorPatch = (chunkPath, content) => {
172798
172883
  if (content.includes('Symbol.for("angular.currentInjector")')) {
172799
172884
  return;
@@ -172830,7 +172915,7 @@ var applyInjectorPatch = (chunkPath, content) => {
172830
172915
  writeFileSync4(chunkPath, patched, "utf-8");
172831
172916
  }, patchAngularInjectorSingleton = () => {
172832
172917
  try {
172833
- const coreDir = dirname6(__require.resolve("@angular/core/package.json"));
172918
+ const coreDir = dirname7(__require.resolve("@angular/core/package.json"));
172834
172919
  const chunkPath = join15(coreDir, "fesm2022", "_not_found-chunk.mjs");
172835
172920
  const content = readFileSync8(chunkPath, "utf-8");
172836
172921
  applyInjectorPatch(chunkPath, content);
@@ -202424,7 +202509,7 @@ __export(exports_moduleServer, {
202424
202509
  SRC_URL_PREFIX: () => SRC_URL_PREFIX
202425
202510
  });
202426
202511
  import { existsSync as existsSync13, readFileSync as readFileSync9, statSync } from "fs";
202427
- import { basename as basename7, dirname as dirname7, extname as extname3, resolve as resolve18, relative as relative8 } from "path";
202512
+ import { basename as basename7, dirname as dirname8, extname as extname3, resolve as resolve18, relative as relative8 } from "path";
202428
202513
  var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
202429
202514
  const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
202430
202515
  const allExports = [];
@@ -202484,7 +202569,7 @@ ${stubs}
202484
202569
  };
202485
202570
  result = result.replace(/^((?:import\s+.+?\s+from|export\s+.+?\s+from|import)\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
202486
202571
  result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
202487
- const fileDir = dirname7(filePath);
202572
+ const fileDir = dirname8(filePath);
202488
202573
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => {
202489
202574
  const absPath = resolve18(fileDir, relPath);
202490
202575
  const rel = relative8(projectRoot, absPath);
@@ -202553,6 +202638,16 @@ ${stubs}
202553
202638
  }
202554
202639
  return _match;
202555
202640
  });
202641
+ result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
202642
+ const absPath = resolve18(fileDir, relPath);
202643
+ const rel = relative8(projectRoot, absPath);
202644
+ return `new URL('/${srcUrl(rel, projectRoot)}', import.meta.url)`;
202645
+ });
202646
+ result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
202647
+ const absPath = resolve18(fileDir, relPath);
202648
+ const rel = relative8(projectRoot, absPath);
202649
+ return `'${srcUrl(rel, projectRoot)}'`;
202650
+ });
202556
202651
  return result;
202557
202652
  }, HOOK_NAMES, REFRESH_PREAMBLE, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
202558
202653
  const imports = [];
@@ -205600,5 +205695,5 @@ export {
205600
205695
  ANGULAR_INIT_TIMEOUT_MS
205601
205696
  };
205602
205697
 
205603
- //# debugId=E99B445C59288BB764756E2164756E21
205698
+ //# debugId=C36DB9885EF5426164756E2164756E21
205604
205699
  //# sourceMappingURL=index.js.map