@absolutejs/absolute 0.19.0-beta.955 → 0.19.0-beta.956

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
@@ -8687,6 +8687,7 @@ var exports_devRouteRegistrationCallsite = {};
8687
8687
  __export(exports_devRouteRegistrationCallsite, {
8688
8688
  patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
8689
8689
  isPageHandler: () => isPageHandler,
8690
+ getOriginalPageHandlerSource: () => getOriginalPageHandlerSource,
8690
8691
  getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
8691
8692
  });
8692
8693
  import { AsyncLocalStorage } from "async_hooks";
@@ -8701,6 +8702,12 @@ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES,
8701
8702
  if (pageHandlerWrappers.has(fn2))
8702
8703
  return true;
8703
8704
  return handlerSourceMentionsPageHelper(fn2);
8705
+ }, getOriginalPageHandlerSource = (handler) => {
8706
+ if (typeof handler !== "function")
8707
+ return;
8708
+ const fn2 = handler;
8709
+ const info = pageHandlerWrappers.get(fn2);
8710
+ return (info?.originalHandler ?? fn2).toString();
8704
8711
  }, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", isRouteMethod = (value) => typeof value === "function", getRouteCallsiteStorage = () => {
8705
8712
  const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
8706
8713
  if (value === null || typeof value === "undefined") {
@@ -8738,7 +8745,9 @@ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES,
8738
8745
  const callsite = captureRouteRegistrationCallsite();
8739
8746
  const wrapped = wrapRouteHandlerWithCallsite(handler, callsite);
8740
8747
  if (methodName === "get" && typeof handler === "function" && typeof wrapped === "function" && handlerSourceMentionsPageHelper(handler)) {
8741
- pageHandlerWrappers.add(wrapped);
8748
+ pageHandlerWrappers.set(wrapped, {
8749
+ originalHandler: handler
8750
+ });
8742
8751
  }
8743
8752
  return Reflect.apply(originalMethod, this, [path, wrapped, ...rest]);
8744
8753
  }, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
@@ -8776,7 +8785,7 @@ var init_devRouteRegistrationCallsite = __esm(() => {
8776
8785
  "handleHTMLPageRequest",
8777
8786
  "handleHTMXPageRequest"
8778
8787
  ];
8779
- pageHandlerWrappers = new WeakSet;
8788
+ pageHandlerWrappers = new WeakMap;
8780
8789
  });
8781
8790
 
8782
8791
  // src/utils/startupBanner.ts
@@ -26390,7 +26399,38 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
26390
26399
  return true;
26391
26400
  }
26392
26401
  return false;
26393
- }, stripTrailingWildcard = (path) => path.replace(/\/\*+$/, ""), isWildcardPagePath = (path) => path.endsWith("/*") || path.endsWith("*"), discoverPageRoutes = (routes, exclude) => {
26402
+ }, stripTrailingWildcard = (path) => path.replace(/\/\*+$/, ""), isWildcardPagePath = (path) => path.endsWith("/*") || path.endsWith("*"), SITEMAP_BLOCK_PATTERN, SITEMAP_STRING_FIELD_PATTERN, SITEMAP_NUMBER_FIELD_PATTERN, VALID_CHANGEFREQ, extractSitemapMetadataFromHandlerSource = (source) => {
26403
+ const block = SITEMAP_BLOCK_PATTERN.exec(source);
26404
+ if (!block)
26405
+ return;
26406
+ const body = block[1];
26407
+ if (typeof body !== "string")
26408
+ return;
26409
+ const out = {};
26410
+ SITEMAP_STRING_FIELD_PATTERN.lastIndex = 0;
26411
+ let m;
26412
+ while ((m = SITEMAP_STRING_FIELD_PATTERN.exec(body)) !== null) {
26413
+ const key = m[1];
26414
+ const value = m[2];
26415
+ if (key === "changefreq" && VALID_CHANGEFREQ.has(value)) {
26416
+ out.changefreq = value;
26417
+ } else if (key === "lastmod") {
26418
+ out.lastmod = value;
26419
+ }
26420
+ }
26421
+ SITEMAP_NUMBER_FIELD_PATTERN.lastIndex = 0;
26422
+ while ((m = SITEMAP_NUMBER_FIELD_PATTERN.exec(body)) !== null) {
26423
+ const num = parseFloat(m[1]);
26424
+ if (!Number.isNaN(num))
26425
+ out.priority = num;
26426
+ }
26427
+ return Object.keys(out).length > 0 ? out : undefined;
26428
+ }, sitemapMetadataForRouteHandler = (handler) => {
26429
+ const source = getOriginalPageHandlerSource(handler);
26430
+ if (!source)
26431
+ return;
26432
+ return extractSitemapMetadataFromHandlerSource(source);
26433
+ }, discoverPageRoutes = (routes, exclude) => {
26394
26434
  const seen = new Set;
26395
26435
  const out = [];
26396
26436
  for (const route of routes) {
@@ -26411,7 +26451,8 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
26411
26451
  out.push({
26412
26452
  emitTopLevel: !isWildcardPagePath(route.path),
26413
26453
  mountPath,
26414
- rawPath: route.path
26454
+ rawPath: route.path,
26455
+ sitemap: sitemapMetadataForRouteHandler(route.handler)
26415
26456
  });
26416
26457
  }
26417
26458
  return out;
@@ -26430,10 +26471,11 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&").repl
26430
26471
  const normalizedBase = baseUrl.replace(/\/$/, "");
26431
26472
  const xml = [];
26432
26473
  for (const entry of entries) {
26433
- const override = config.overrides?.[entry.path];
26434
- const changefreq = override?.changefreq ?? config.defaultChangefreq ?? "weekly";
26435
- const priority = override?.priority ?? config.defaultPriority ?? DEFAULT_PRIORITY;
26436
- const lastmod = override?.lastmod;
26474
+ const configOverride = config.overrides?.[entry.path];
26475
+ const handlerOverride = entry.override;
26476
+ const changefreq = configOverride?.changefreq ?? handlerOverride?.changefreq ?? config.defaultChangefreq ?? "weekly";
26477
+ const priority = configOverride?.priority ?? handlerOverride?.priority ?? config.defaultPriority ?? DEFAULT_PRIORITY;
26478
+ const lastmod = configOverride?.lastmod ?? handlerOverride?.lastmod;
26437
26479
  const url = escapeXml(`${normalizedBase}${entry.path}`);
26438
26480
  let block = ` <url>
26439
26481
  <loc>${url}</loc>`;
@@ -26455,12 +26497,13 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&amp;").repl
26455
26497
  "</urlset>"
26456
26498
  ].join(`
26457
26499
  `);
26458
- }, collectFrameworkSpaEntries = (hosts, wildcardMounts, exclude, seenPaths) => {
26500
+ }, collectFrameworkSpaEntries = (hosts, mountOverridesByPath, exclude, seenPaths) => {
26459
26501
  const out = [];
26460
26502
  for (const host of hosts) {
26461
26503
  const mount = normalizeMountFromBaseHref(host.baseHref);
26462
- if (!wildcardMounts.has(mount))
26504
+ if (!mountOverridesByPath.has(mount))
26463
26505
  continue;
26506
+ const mountOverride = mountOverridesByPath.get(mount);
26464
26507
  for (const route of host.routes) {
26465
26508
  if (route.dynamic)
26466
26509
  continue;
@@ -26474,7 +26517,7 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&amp;").repl
26474
26517
  if (isExcluded(fullPath, exclude))
26475
26518
  continue;
26476
26519
  seenPaths.add(fullPath);
26477
- out.push({ path: fullPath });
26520
+ out.push({ override: mountOverride, path: fullPath });
26478
26521
  }
26479
26522
  }
26480
26523
  return out;
@@ -26496,9 +26539,14 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&amp;").repl
26496
26539
  if (seenPaths.has(page.mountPath))
26497
26540
  continue;
26498
26541
  seenPaths.add(page.mountPath);
26499
- entries.push({ path: page.mountPath });
26542
+ entries.push({ override: page.sitemap, path: page.mountPath });
26543
+ }
26544
+ const wildcardOverrides = new Map;
26545
+ for (const page of discoveredPages) {
26546
+ if (page.emitTopLevel)
26547
+ continue;
26548
+ wildcardOverrides.set(page.mountPath, page.sitemap);
26500
26549
  }
26501
- const wildcardMounts = new Set(discoveredPages.filter((page) => !page.emitTopLevel).map((page) => page.mountPath));
26502
26550
  const analyzerJobs = [];
26503
26551
  if (pipelineConfig.angularDirectory) {
26504
26552
  analyzerJobs.push(runAnalyzer("Angular", () => analyzeAngularSpaRoutes(pipelineConfig.angularDirectory)));
@@ -26513,7 +26561,7 @@ var DEFAULT_PRIORITY = 0.8, escapeXml = (str) => str.replace(/&/g, "&amp;").repl
26513
26561
  analyzerJobs.push(runAnalyzer("Vue", () => analyzeVueSpaRoutes(pipelineConfig.vueDirectory)));
26514
26562
  }
26515
26563
  const allHosts = (await Promise.all(analyzerJobs)).flat();
26516
- const spaEntries = collectFrameworkSpaEntries(allHosts, wildcardMounts, exclude, seenPaths);
26564
+ const spaEntries = collectFrameworkSpaEntries(allHosts, wildcardOverrides, exclude, seenPaths);
26517
26565
  entries.push(...spaEntries);
26518
26566
  const dynamicRoutes = config.routes ? await config.routes() : [];
26519
26567
  for (const path of dynamicRoutes) {
@@ -26534,6 +26582,18 @@ var init_generateSitemap = __esm(() => {
26534
26582
  init_staticAnalyzeSpaRoutes2();
26535
26583
  init_staticAnalyzeSpaRoutes3();
26536
26584
  init_staticAnalyzeSpaRoutes4();
26585
+ SITEMAP_BLOCK_PATTERN = /\bsitemap\s*:\s*\{([^{}]*)\}/;
26586
+ SITEMAP_STRING_FIELD_PATTERN = /\b(changefreq|lastmod)\s*:\s*['"]([^'"]+)['"]/g;
26587
+ SITEMAP_NUMBER_FIELD_PATTERN = /\bpriority\s*:\s*([+-]?\d+(?:\.\d+)?)/g;
26588
+ VALID_CHANGEFREQ = new Set([
26589
+ "always",
26590
+ "hourly",
26591
+ "daily",
26592
+ "weekly",
26593
+ "monthly",
26594
+ "yearly",
26595
+ "never"
26596
+ ]);
26537
26597
  });
26538
26598
 
26539
26599
  // src/core/prerender.ts
@@ -34753,5 +34813,5 @@ export {
34753
34813
  ANGULAR_INIT_TIMEOUT_MS
34754
34814
  };
34755
34815
 
34756
- //# debugId=8CC7B20D34E950DD64756E2164756E21
34816
+ //# debugId=59AB0936D112E70F64756E2164756E21
34757
34817
  //# sourceMappingURL=index.js.map