@gravito/constellation 2.0.0 → 3.0.0

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.cjs CHANGED
@@ -674,10 +674,9 @@ var SitemapGenerator = class {
674
674
  baseUrl: this.options.baseUrl,
675
675
  pretty: this.options.pretty
676
676
  });
677
+ let isMultiFile = false;
677
678
  const flushShard = async () => {
678
- if (currentCount === 0) {
679
- return;
680
- }
679
+ isMultiFile = true;
681
680
  const baseName = this.options.filename?.replace(/\.xml$/, "");
682
681
  const filename = `${baseName}-${shardIndex}.xml`;
683
682
  const xml = currentStream.toXML();
@@ -718,7 +717,22 @@ var SitemapGenerator = class {
718
717
  }
719
718
  }
720
719
  }
721
- await flushShard();
720
+ if (!isMultiFile) {
721
+ const xml = currentStream.toXML();
722
+ if (this.shadowProcessor) {
723
+ await this.shadowProcessor.addOperation({
724
+ filename: this.options.filename,
725
+ content: xml
726
+ });
727
+ await this.shadowProcessor.commit();
728
+ } else {
729
+ await this.options.storage.write(this.options.filename, xml);
730
+ }
731
+ return;
732
+ }
733
+ if (currentCount > 0) {
734
+ await flushShard();
735
+ }
722
736
  const indexXml = index.toXML();
723
737
  if (this.shadowProcessor) {
724
738
  await this.shadowProcessor.addOperation({
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({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravito/constellation",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
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",