@gravito/constellation 2.0.0 → 3.0.1

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
@@ -553,10 +553,9 @@ var SitemapGenerator = class {
553
553
  baseUrl: this.options.baseUrl,
554
554
  pretty: this.options.pretty
555
555
  });
556
+ let isMultiFile = false;
556
557
  const flushShard = async () => {
557
- if (currentCount === 0) {
558
- return;
559
- }
558
+ isMultiFile = true;
560
559
  const baseName = this.options.filename?.replace(/\.xml$/, "");
561
560
  const filename = `${baseName}-${shardIndex}.xml`;
562
561
  const xml = currentStream.toXML();
@@ -597,7 +596,22 @@ var SitemapGenerator = class {
597
596
  }
598
597
  }
599
598
  }
600
- await flushShard();
599
+ if (!isMultiFile) {
600
+ const xml = currentStream.toXML();
601
+ if (this.shadowProcessor) {
602
+ await this.shadowProcessor.addOperation({
603
+ filename: this.options.filename,
604
+ content: xml
605
+ });
606
+ await this.shadowProcessor.commit();
607
+ } else {
608
+ await this.options.storage.write(this.options.filename, xml);
609
+ }
610
+ return;
611
+ }
612
+ if (currentCount > 0) {
613
+ await flushShard();
614
+ }
601
615
  const indexXml = index.toXML();
602
616
  if (this.shadowProcessor) {
603
617
  await this.shadowProcessor.addOperation({
@@ -841,7 +855,7 @@ var GenerateSitemapJob = class extends Job {
841
855
  this.generator = new SitemapGenerator(options.generatorOptions);
842
856
  }
843
857
  async handle() {
844
- const { progressTracker, shadowProcessor, onProgress, onComplete, onError } = this.options;
858
+ const { progressTracker, onComplete, onError } = this.options;
845
859
  try {
846
860
  if (progressTracker) {
847
861
  const total = await this.calculateTotal();
@@ -849,8 +863,8 @@ var GenerateSitemapJob = class extends Job {
849
863
  this.totalEntries = total;
850
864
  }
851
865
  await this.generateWithProgress();
852
- if (shadowProcessor) {
853
- await shadowProcessor.commit();
866
+ if (this.options.shadowProcessor) {
867
+ await this.options.shadowProcessor.commit();
854
868
  }
855
869
  if (progressTracker) {
856
870
  await progressTracker.complete();
@@ -891,15 +905,7 @@ var GenerateSitemapJob = class extends Job {
891
905
  * 帶進度追蹤的生成
892
906
  */
893
907
  async generateWithProgress() {
894
- const { progressTracker, shadowProcessor, onProgress } = this.options;
895
- const {
896
- providers,
897
- maxEntriesPerFile = 5e4,
898
- storage,
899
- baseUrl,
900
- pretty,
901
- filename
902
- } = this.options.generatorOptions;
908
+ const { progressTracker, onProgress } = this.options;
903
909
  await this.generator.run();
904
910
  this.processedEntries = this.totalEntries;
905
911
  if (progressTracker) {
@@ -1138,7 +1144,7 @@ var OrbitSitemap = class _OrbitSitemap {
1138
1144
  if (this.mode === "dynamic") {
1139
1145
  this.installDynamic(core);
1140
1146
  } else {
1141
- console.log("[OrbitSitemap] Static mode configured. Use generate() to build sitemaps.");
1147
+ core.logger.info("[OrbitSitemap] Static mode configured. Use generate() to build sitemaps.");
1142
1148
  }
1143
1149
  }
1144
1150
  installDynamic(core) {
@@ -1404,6 +1410,11 @@ var RouteScanner = class {
1404
1410
  ...options
1405
1411
  };
1406
1412
  }
1413
+ /**
1414
+ * Scan the router and return discovered entries.
1415
+ *
1416
+ * @returns An array of sitemap entries.
1417
+ */
1407
1418
  getEntries() {
1408
1419
  const entries = [];
1409
1420
  const routes = this.extractRoutes(this.router);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/constellation",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Powerful sitemap generation for Gravito applications with dynamic/static support, sharding, and caching.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",