@absolutejs/absolute 0.19.0-beta.952 → 0.19.0-beta.953

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
@@ -11996,6 +11996,24 @@ var init_compileVue = __esm(() => {
11996
11996
  vueHmrMetadata = new Map;
11997
11997
  });
11998
11998
 
11999
+ // src/build/rewriteProvideRouter.ts
12000
+ var ROUTER_IMPORT_PATTERN, PROVIDE_ROUTER_CALL_PATTERN, CAPTURE_IMPORT_STATEMENT = `import { __abs_provideRouter } from '@absolutejs/absolute/angular';
12001
+ `, SHIM_MARKER = "__abs_provideRouter", rewriteAngularProvideRouter = (source) => {
12002
+ if (source.includes(SHIM_MARKER))
12003
+ return source;
12004
+ if (!ROUTER_IMPORT_PATTERN.test(source))
12005
+ return source;
12006
+ if (!PROVIDE_ROUTER_CALL_PATTERN.test(source))
12007
+ return source;
12008
+ PROVIDE_ROUTER_CALL_PATTERN.lastIndex = 0;
12009
+ const rewritten = source.replace(PROVIDE_ROUTER_CALL_PATTERN, "__abs_provideRouter(");
12010
+ return `${CAPTURE_IMPORT_STATEMENT}${rewritten}`;
12011
+ };
12012
+ var init_rewriteProvideRouter = __esm(() => {
12013
+ ROUTER_IMPORT_PATTERN = /import\s*(?:type\s+)?\{[^}]*\bprovideRouter\b[^}]*\}\s*from\s*['"]@angular\/router['"]/;
12014
+ PROVIDE_ROUTER_CALL_PATTERN = /\bprovideRouter\s*\(/g;
12015
+ });
12016
+
11999
12017
  // src/angular/lowerDeferSyntax.ts
12000
12018
  var isInterpolatedExpressionStart = (value, index) => value[index] === "{" && value[index + 1] === "{", skipInterpolatedExpression = (value, start) => {
12001
12019
  const cursor = start + 2;
@@ -12691,9 +12709,11 @@ var traceAngularPhase = async (name, fn2, metadata2) => {
12691
12709
  return candidates.map((candidate) => resolve24(candidate)).find((candidate) => existsSync18(candidate) && !candidate.endsWith(".d.ts")) ?? null;
12692
12710
  }, readFileForAotTransform = async (fileName, readFile6) => {
12693
12711
  const hostSource = readFile6?.(fileName);
12694
- if (typeof hostSource === "string")
12695
- return hostSource;
12696
- return fs.readFile(fileName, "utf-8");
12712
+ if (typeof hostSource === "string") {
12713
+ return rewriteAngularProvideRouter(hostSource);
12714
+ }
12715
+ const raw = await fs.readFile(fileName, "utf-8");
12716
+ return rewriteAngularProvideRouter(raw);
12697
12717
  }, safeStableStringify = (value) => {
12698
12718
  const seen = new WeakSet;
12699
12719
  return JSON.stringify(value, (_key, entry) => {
@@ -13287,6 +13307,7 @@ ${fields}
13287
13307
  if (!existsSync18(actualPath))
13288
13308
  return;
13289
13309
  let sourceCode = await fs.readFile(actualPath, "utf-8");
13310
+ sourceCode = rewriteAngularProvideRouter(sourceCode);
13290
13311
  const inlined = await inlineResources(sourceCode, dirname15(actualPath), stylePreprocessors);
13291
13312
  sourceCode = inlineTemplateAndLowerDeferSync(inlined.source, dirname15(actualPath)).source;
13292
13313
  const inputDir = dirname15(actualPath);
@@ -13660,6 +13681,7 @@ if (pageHasRawStreamingSlots) {
13660
13681
  };
13661
13682
  };
13662
13683
  var init_compileAngular = __esm(() => {
13684
+ init_rewriteProvideRouter();
13663
13685
  init_constants();
13664
13686
  init_sourceMetadata();
13665
13687
  init_lowerDeferSyntax();
@@ -25598,6 +25620,29 @@ var init_imageOptimizer = __esm(() => {
25598
25620
  avifInProgress = new Set;
25599
25621
  });
25600
25622
 
25623
+ // src/utils/spaRouteEnumeration.ts
25624
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
25625
+ var STORAGE_KEY, isObjectRecord4 = (value) => Boolean(value) && typeof value === "object", isStorage = (value) => isObjectRecord4(value) && typeof value.getStore === "function" && typeof value.run === "function", getStorage = () => {
25626
+ const existing = Reflect.get(globalThis, STORAGE_KEY);
25627
+ if (isStorage(existing))
25628
+ return existing;
25629
+ const fresh = new AsyncLocalStorage2;
25630
+ Reflect.set(globalThis, STORAGE_KEY, fresh);
25631
+ return fresh;
25632
+ }, isCollectingSpaRoutes = () => getStorage().getStore() !== undefined, recordSpaRoutes = (entries) => {
25633
+ const store = getStorage().getStore();
25634
+ if (!store)
25635
+ return;
25636
+ store.entries.push(...entries);
25637
+ }, collectSpaRoutes = async (task) => {
25638
+ const store = { entries: [] };
25639
+ await getStorage().run(store, task);
25640
+ return store.entries;
25641
+ };
25642
+ var init_spaRouteEnumeration = __esm(() => {
25643
+ STORAGE_KEY = Symbol.for("absolutejs.spaRouteEnumerationStorage");
25644
+ });
25645
+
25601
25646
  // src/utils/generateSitemap.ts
25602
25647
  var exports_generateSitemap = {};
25603
25648
  __export(exports_generateSitemap, {
@@ -25627,48 +25672,105 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
25627
25672
  return false;
25628
25673
  seen.add(route.path);
25629
25674
  return true;
25630
- }).map((route) => route.path);
25631
- }, buildSitemapXml = (pageRoutes, baseUrl, config) => {
25675
+ });
25676
+ }, joinMountAndSubPath = (mount, sub) => {
25677
+ const trimmedMount = mount.replace(/\/+$/, "");
25678
+ const trimmedSub = sub.replace(/^\/+/, "");
25679
+ if (!trimmedSub)
25680
+ return trimmedMount || "/";
25681
+ if (!trimmedMount)
25682
+ return `/${trimmedSub}`;
25683
+ return `${trimmedMount}/${trimmedSub}`;
25684
+ }, buildSitemapXml = (entries, baseUrl, config) => {
25632
25685
  const normalizedBase = baseUrl.replace(/\/$/, "");
25633
- const entries = [];
25634
- for (const path of pageRoutes) {
25635
- const override = config.overrides?.[path];
25636
- const changefreq = override?.changefreq ?? config.defaultChangefreq ?? "weekly";
25637
- const priority = override?.priority ?? config.defaultPriority ?? DEFAULT_PRIORITY;
25638
- const lastmod = override?.lastmod;
25639
- const url = escapeXml(`${normalizedBase}${path}`);
25640
- let entry = ` <url>
25686
+ const xml = [];
25687
+ for (const entry of entries) {
25688
+ const override = config.overrides?.[entry.path];
25689
+ const changefreq = override?.changefreq ?? entry.changefreq ?? config.defaultChangefreq ?? "weekly";
25690
+ const priority = override?.priority ?? entry.priority ?? config.defaultPriority ?? DEFAULT_PRIORITY;
25691
+ const lastmod = override?.lastmod ?? entry.lastmod;
25692
+ const url = escapeXml(`${normalizedBase}${entry.path}`);
25693
+ let urlBlock = ` <url>
25641
25694
  <loc>${url}</loc>`;
25642
25695
  if (lastmod)
25643
- entry += `
25696
+ urlBlock += `
25644
25697
  <lastmod>${lastmod}</lastmod>`;
25645
- entry += `
25698
+ urlBlock += `
25646
25699
  <changefreq>${changefreq}</changefreq>`;
25647
- entry += `
25700
+ urlBlock += `
25648
25701
  <priority>${priority}</priority>`;
25649
- entry += `
25702
+ urlBlock += `
25650
25703
  </url>`;
25651
- entries.push(entry);
25704
+ xml.push(urlBlock);
25652
25705
  }
25653
25706
  return [
25654
25707
  '<?xml version="1.0" encoding="UTF-8"?>',
25655
25708
  '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
25656
- ...entries,
25709
+ ...xml,
25657
25710
  "</urlset>"
25658
25711
  ].join(`
25659
25712
  `);
25660
- }, generateSitemap = async (routes, serverUrl, outDir, config = {}) => {
25713
+ }, resolveSpaEntryMetadata = (entry) => {
25714
+ if (!entry.sitemap || typeof entry.sitemap !== "object")
25715
+ return {};
25716
+ return {
25717
+ changefreq: entry.sitemap.changefreq,
25718
+ lastmod: entry.sitemap.lastmod,
25719
+ priority: entry.sitemap.priority
25720
+ };
25721
+ }, collectPageSubRoutes = async (app, route, serverUrl) => {
25722
+ const request = new Request(`${serverUrl}${route.path}`, {
25723
+ headers: { "x-absolutejs-enumeration": "1" },
25724
+ method: "GET"
25725
+ });
25726
+ return collectSpaRoutes(async () => {
25727
+ try {
25728
+ await app.handle(request);
25729
+ } catch (err) {
25730
+ console.warn(`[sitemap] enumeration request failed for ${route.path}:`, err);
25731
+ }
25732
+ });
25733
+ }, generateSitemap = async (app, serverUrl, outDir, config = {}) => {
25661
25734
  const exclude = config.exclude ?? [];
25662
- const discoveredRoutes = discoverPageRoutes(routes, exclude);
25663
- const dynamicRoutes = config.routes ? await config.routes() : [];
25664
- const filteredDynamic = dynamicRoutes.filter((path) => !isExcluded(path, exclude));
25665
- const allRoutes = [...discoveredRoutes, ...filteredDynamic];
25735
+ const pageRoutes = discoverPageRoutes(app.routes, exclude);
25736
+ const entries = [];
25737
+ const seenPaths = new Set;
25738
+ for (const route of pageRoutes) {
25739
+ if (!seenPaths.has(route.path)) {
25740
+ entries.push({ path: route.path });
25741
+ seenPaths.add(route.path);
25742
+ }
25743
+ const subRoutes = await collectPageSubRoutes(app, route, serverUrl);
25744
+ for (const sub of subRoutes) {
25745
+ if (sub.dynamic)
25746
+ continue;
25747
+ if (sub.sitemap === "exclude")
25748
+ continue;
25749
+ const fullPath = joinMountAndSubPath(route.path, sub.path);
25750
+ if (seenPaths.has(fullPath))
25751
+ continue;
25752
+ if (isExcluded(fullPath, exclude))
25753
+ continue;
25754
+ entries.push({ path: fullPath, ...resolveSpaEntryMetadata(sub) });
25755
+ seenPaths.add(fullPath);
25756
+ }
25757
+ }
25758
+ const dynamicConfigRoutes = config.routes ? await config.routes() : [];
25759
+ for (const path of dynamicConfigRoutes) {
25760
+ if (seenPaths.has(path))
25761
+ continue;
25762
+ if (isExcluded(path, exclude))
25763
+ continue;
25764
+ entries.push({ path });
25765
+ seenPaths.add(path);
25766
+ }
25666
25767
  const baseUrl = config.baseUrl ?? serverUrl;
25667
- const xml = buildSitemapXml(allRoutes, baseUrl, config);
25768
+ const xml = buildSitemapXml(entries, baseUrl, config);
25668
25769
  await write4(`${outDir}/sitemap.xml`, xml);
25669
25770
  };
25670
25771
  var init_generateSitemap = __esm(() => {
25671
25772
  init_devRouteRegistrationCallsite();
25773
+ init_spaRouteEnumeration();
25672
25774
  });
25673
25775
 
25674
25776
  // src/core/prerender.ts
@@ -27069,7 +27171,7 @@ var createSitemapPlugin = (buildDir, sitemapConfig) => new Elysia5({ name: "abso
27069
27171
  const { server } = started;
27070
27172
  if (!server)
27071
27173
  return;
27072
- Promise.resolve().then(() => (init_generateSitemap(), exports_generateSitemap)).then(({ generateSitemap: generateSitemap2 }) => generateSitemap2(started.routes, server.url.origin, buildDir, sitemapConfig)).catch((err) => console.error("[sitemap] Generation failed:", err));
27174
+ Promise.resolve().then(() => (init_generateSitemap(), exports_generateSitemap)).then(({ generateSitemap: generateSitemap2 }) => generateSitemap2(started, server.url.origin, buildDir, sitemapConfig)).catch((err) => console.error("[sitemap] Generation failed:", err));
27073
27175
  });
27074
27176
  var createNotFoundPlugin = () => new Elysia5({ name: "absolutejs-not-found" }).onError({ as: "global" }, async ({ code }) => {
27075
27177
  if (code !== "NOT_FOUND")
@@ -33873,5 +33975,5 @@ export {
33873
33975
  ANGULAR_INIT_TIMEOUT_MS
33874
33976
  };
33875
33977
 
33876
- //# debugId=62528314180FB57664756E2164756E21
33978
+ //# debugId=27DB5119E1E545AE64756E2164756E21
33877
33979
  //# sourceMappingURL=index.js.map