vite-plugin-sitemap 0.5.1 → 0.6.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.js CHANGED
@@ -1,21 +1,18 @@
1
- 'use strict';
2
-
3
- var node_fs = require('node:fs');
4
- var require$$0 = require('stream');
5
- var require$$0$1 = require('fs');
6
- var require$$2 = require('readline');
7
- var require$$3 = require('url');
8
- var require$$0$2 = require('path');
9
- var require$$1 = require('child_process');
10
- var module$1 = require('module');
11
- var require$$1$1 = require('string_decoder');
12
- var require$$1$2 = require('zlib');
13
- var require$$0$3 = require('util');
14
- var node_path = require('node:path');
15
- var require$$0$4 = require('os');
16
- var require$$0$5 = require('events');
17
-
18
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
1
+ import { writeFileSync } from 'node:fs';
2
+ import require$$0 from 'stream';
3
+ import require$$0$1 from 'fs';
4
+ import require$$2 from 'readline';
5
+ import require$$3 from 'url';
6
+ import require$$0$2 from 'path';
7
+ import require$$1 from 'child_process';
8
+ import { createRequire } from 'module';
9
+ import require$$1$1 from 'string_decoder';
10
+ import require$$1$2 from 'zlib';
11
+ import require$$0$3 from 'util';
12
+ import { isAbsolute, resolve, parse as parse$4, join } from 'node:path';
13
+ import require$$0$4 from 'os';
14
+ import require$$0$5 from 'events';
15
+
19
16
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
20
17
 
21
18
  function getDefaultExportFromCjs (x) {
@@ -1281,8 +1278,8 @@ xmllint.xmlLint = xmlLint;
1281
1278
  var sitemapParser = {};
1282
1279
 
1283
1280
  var require$1 = (
1284
- false
1285
- ? /* @__PURE__ */ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)))
1281
+ true
1282
+ ? /* @__PURE__ */ createRequire(import.meta.url)
1286
1283
  : require
1287
1284
  );
1288
1285
 
@@ -4052,7 +4049,7 @@ var cjsExports$1 = cjs.exports;
4052
4049
  containsTextNodesWithLineBreaks = true;
4053
4050
  child.content = child.content.trim();
4054
4051
  }
4055
- else if (index === 0 || index === nodeChildren.length - 1) {
4052
+ else if ((index === 0 || index === nodeChildren.length - 1) && !preserveSpace) {
4056
4053
  if (child.content.trim().length === 0) {
4057
4054
  // If the text node is at the start or end and is empty, it should be ignored when formatting
4058
4055
  child.content = '';
@@ -4154,11 +4151,6 @@ function ensurePrefix(prefix, str) {
4154
4151
  return prefix + str;
4155
4152
  return str;
4156
4153
  }
4157
- function ensureSuffix(suffix, str) {
4158
- if (!str.endsWith(suffix))
4159
- return str + suffix;
4160
- return str;
4161
- }
4162
4154
 
4163
4155
  var tasks = {};
4164
4156
 
@@ -4228,11 +4220,11 @@ const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
4228
4220
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
4229
4221
  /**
4230
4222
  * All non-escaped special characters.
4231
- * Posix: ()*?[\]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
4232
- * Windows: (){}, !+@ before (, ! at the beginning.
4223
+ * Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
4224
+ * Windows: (){}[], !+@ before (, ! at the beginning.
4233
4225
  */
4234
4226
  const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
4235
- const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g;
4227
+ const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
4236
4228
  /**
4237
4229
  * The device path (\\.\ or \\?\).
4238
4230
  * https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
@@ -4243,7 +4235,7 @@ const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
4243
4235
  * Windows: !()+@{}
4244
4236
  * https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
4245
4237
  */
4246
- const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
4238
+ const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
4247
4239
  /**
4248
4240
  * Designed to work only with simple paths: `dir\\file`.
4249
4241
  */
@@ -4538,7 +4530,7 @@ var utils$j = {};
4538
4530
  */
4539
4531
 
4540
4532
  exports.escapeNode = (block, n = 0, type) => {
4541
- let node = block.nodes[n];
4533
+ const node = block.nodes[n];
4542
4534
  if (!node) return;
4543
4535
 
4544
4536
  if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
@@ -4607,13 +4599,23 @@ var utils$j = {};
4607
4599
 
4608
4600
  exports.flatten = (...args) => {
4609
4601
  const result = [];
4602
+
4610
4603
  const flat = arr => {
4611
4604
  for (let i = 0; i < arr.length; i++) {
4612
- let ele = arr[i];
4613
- Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
4605
+ const ele = arr[i];
4606
+
4607
+ if (Array.isArray(ele)) {
4608
+ flat(ele);
4609
+ continue;
4610
+ }
4611
+
4612
+ if (ele !== undefined) {
4613
+ result.push(ele);
4614
+ }
4614
4615
  }
4615
4616
  return result;
4616
4617
  };
4618
+
4617
4619
  flat(args);
4618
4620
  return result;
4619
4621
  };
@@ -4622,9 +4624,9 @@ var utils$j = {};
4622
4624
  const utils$i = utils$j;
4623
4625
 
4624
4626
  var stringify$4 = (ast, options = {}) => {
4625
- let stringify = (node, parent = {}) => {
4626
- let invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
4627
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
4627
+ const stringify = (node, parent = {}) => {
4628
+ const invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
4629
+ const invalidNode = node.invalid === true && options.escapeInvalid === true;
4628
4630
  let output = '';
4629
4631
 
4630
4632
  if (node.value) {
@@ -4639,7 +4641,7 @@ var stringify$4 = (ast, options = {}) => {
4639
4641
  }
4640
4642
 
4641
4643
  if (node.nodes) {
4642
- for (let child of node.nodes) {
4644
+ for (const child of node.nodes) {
4643
4645
  output += stringify(child);
4644
4646
  }
4645
4647
  }
@@ -5013,7 +5015,7 @@ const toMaxLen = (input, maxLength) => {
5013
5015
  return negative ? ('-' + input) : input;
5014
5016
  };
5015
5017
 
5016
- const toSequence = (parts, options) => {
5018
+ const toSequence = (parts, options, maxLen) => {
5017
5019
  parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
5018
5020
  parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
5019
5021
 
@@ -5023,11 +5025,11 @@ const toSequence = (parts, options) => {
5023
5025
  let result;
5024
5026
 
5025
5027
  if (parts.positives.length) {
5026
- positives = parts.positives.join('|');
5028
+ positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
5027
5029
  }
5028
5030
 
5029
5031
  if (parts.negatives.length) {
5030
- negatives = `-(${prefix}${parts.negatives.join('|')})`;
5032
+ negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
5031
5033
  }
5032
5034
 
5033
5035
  if (positives && negatives) {
@@ -5125,7 +5127,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
5125
5127
 
5126
5128
  if (options.toRegex === true) {
5127
5129
  return step > 1
5128
- ? toSequence(parts, options)
5130
+ ? toSequence(parts, options, maxLen)
5129
5131
  : toRegex(range, null, { wrap: false, ...options });
5130
5132
  }
5131
5133
 
@@ -5137,7 +5139,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
5137
5139
  return invalidRange(start, end, options);
5138
5140
  }
5139
5141
 
5140
-
5141
5142
  let format = options.transform || (val => String.fromCharCode(val));
5142
5143
  let a = `${start}`.charCodeAt(0);
5143
5144
  let b = `${end}`.charCodeAt(0);
@@ -5205,30 +5206,32 @@ const fill$1 = fillRange;
5205
5206
  const utils$h = utils$j;
5206
5207
 
5207
5208
  const compile$1 = (ast, options = {}) => {
5208
- let walk = (node, parent = {}) => {
5209
- let invalidBlock = utils$h.isInvalidBrace(parent);
5210
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
5211
- let invalid = invalidBlock === true || invalidNode === true;
5212
- let prefix = options.escapeInvalid === true ? '\\' : '';
5209
+ const walk = (node, parent = {}) => {
5210
+ const invalidBlock = utils$h.isInvalidBrace(parent);
5211
+ const invalidNode = node.invalid === true && options.escapeInvalid === true;
5212
+ const invalid = invalidBlock === true || invalidNode === true;
5213
+ const prefix = options.escapeInvalid === true ? '\\' : '';
5213
5214
  let output = '';
5214
5215
 
5215
5216
  if (node.isOpen === true) {
5216
5217
  return prefix + node.value;
5217
5218
  }
5219
+
5218
5220
  if (node.isClose === true) {
5221
+ console.log('node.isClose', prefix, node.value);
5219
5222
  return prefix + node.value;
5220
5223
  }
5221
5224
 
5222
5225
  if (node.type === 'open') {
5223
- return invalid ? (prefix + node.value) : '(';
5226
+ return invalid ? prefix + node.value : '(';
5224
5227
  }
5225
5228
 
5226
5229
  if (node.type === 'close') {
5227
- return invalid ? (prefix + node.value) : ')';
5230
+ return invalid ? prefix + node.value : ')';
5228
5231
  }
5229
5232
 
5230
5233
  if (node.type === 'comma') {
5231
- return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
5234
+ return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
5232
5235
  }
5233
5236
 
5234
5237
  if (node.value) {
@@ -5236,8 +5239,8 @@ const compile$1 = (ast, options = {}) => {
5236
5239
  }
5237
5240
 
5238
5241
  if (node.nodes && node.ranges > 0) {
5239
- let args = utils$h.reduce(node.nodes);
5240
- let range = fill$1(...args, { ...options, wrap: false, toRegex: true });
5242
+ const args = utils$h.reduce(node.nodes);
5243
+ const range = fill$1(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
5241
5244
 
5242
5245
  if (range.length !== 0) {
5243
5246
  return args.length > 1 && range.length > 1 ? `(${range})` : range;
@@ -5245,10 +5248,11 @@ const compile$1 = (ast, options = {}) => {
5245
5248
  }
5246
5249
 
5247
5250
  if (node.nodes) {
5248
- for (let child of node.nodes) {
5251
+ for (const child of node.nodes) {
5249
5252
  output += walk(child, node);
5250
5253
  }
5251
5254
  }
5255
+
5252
5256
  return output;
5253
5257
  };
5254
5258
 
@@ -5262,7 +5266,7 @@ const stringify$2 = stringify$4;
5262
5266
  const utils$g = utils$j;
5263
5267
 
5264
5268
  const append = (queue = '', stash = '', enclose = false) => {
5265
- let result = [];
5269
+ const result = [];
5266
5270
 
5267
5271
  queue = [].concat(queue);
5268
5272
  stash = [].concat(stash);
@@ -5272,15 +5276,15 @@ const append = (queue = '', stash = '', enclose = false) => {
5272
5276
  return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
5273
5277
  }
5274
5278
 
5275
- for (let item of queue) {
5279
+ for (const item of queue) {
5276
5280
  if (Array.isArray(item)) {
5277
- for (let value of item) {
5281
+ for (const value of item) {
5278
5282
  result.push(append(value, stash, enclose));
5279
5283
  }
5280
5284
  } else {
5281
5285
  for (let ele of stash) {
5282
5286
  if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
5283
- result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
5287
+ result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
5284
5288
  }
5285
5289
  }
5286
5290
  }
@@ -5288,9 +5292,9 @@ const append = (queue = '', stash = '', enclose = false) => {
5288
5292
  };
5289
5293
 
5290
5294
  const expand$1 = (ast, options = {}) => {
5291
- let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
5295
+ const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
5292
5296
 
5293
- let walk = (node, parent = {}) => {
5297
+ const walk = (node, parent = {}) => {
5294
5298
  node.queue = [];
5295
5299
 
5296
5300
  let p = parent;
@@ -5312,7 +5316,7 @@ const expand$1 = (ast, options = {}) => {
5312
5316
  }
5313
5317
 
5314
5318
  if (node.nodes && node.ranges > 0) {
5315
- let args = utils$g.reduce(node.nodes);
5319
+ const args = utils$g.reduce(node.nodes);
5316
5320
 
5317
5321
  if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
5318
5322
  throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
@@ -5328,7 +5332,7 @@ const expand$1 = (ast, options = {}) => {
5328
5332
  return;
5329
5333
  }
5330
5334
 
5331
- let enclose = utils$g.encloseBrace(node);
5335
+ const enclose = utils$g.encloseBrace(node);
5332
5336
  let queue = node.queue;
5333
5337
  let block = node;
5334
5338
 
@@ -5338,7 +5342,7 @@ const expand$1 = (ast, options = {}) => {
5338
5342
  }
5339
5343
 
5340
5344
  for (let i = 0; i < node.nodes.length; i++) {
5341
- let child = node.nodes[i];
5345
+ const child = node.nodes[i];
5342
5346
 
5343
5347
  if (child.type === 'comma' && node.type === 'brace') {
5344
5348
  if (i === 1) queue.push('');
@@ -5370,7 +5374,7 @@ const expand$1 = (ast, options = {}) => {
5370
5374
  var expand_1 = expand$1;
5371
5375
 
5372
5376
  var constants$4 = {
5373
- MAX_LENGTH: 1024 * 64,
5377
+ MAX_LENGTH: 10000,
5374
5378
 
5375
5379
  // Digits
5376
5380
  CHAR_0: '0', /* 0 */
@@ -5458,18 +5462,18 @@ const parse$3 = (input, options = {}) => {
5458
5462
  throw new TypeError('Expected a string');
5459
5463
  }
5460
5464
 
5461
- let opts = options || {};
5462
- let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
5465
+ const opts = options || {};
5466
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
5463
5467
  if (input.length > max) {
5464
5468
  throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
5465
5469
  }
5466
5470
 
5467
- let ast = { type: 'root', input, nodes: [] };
5468
- let stack = [ast];
5471
+ const ast = { type: 'root', input, nodes: [] };
5472
+ const stack = [ast];
5469
5473
  let block = ast;
5470
5474
  let prev = ast;
5471
5475
  let brackets = 0;
5472
- let length = input.length;
5476
+ const length = input.length;
5473
5477
  let index = 0;
5474
5478
  let depth = 0;
5475
5479
  let value;
@@ -5534,6 +5538,7 @@ const parse$3 = (input, options = {}) => {
5534
5538
 
5535
5539
  if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
5536
5540
  brackets++;
5541
+
5537
5542
  let next;
5538
5543
 
5539
5544
  while (index < length && (next = advance())) {
@@ -5589,7 +5594,7 @@ const parse$3 = (input, options = {}) => {
5589
5594
  */
5590
5595
 
5591
5596
  if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
5592
- let open = value;
5597
+ const open = value;
5593
5598
  let next;
5594
5599
 
5595
5600
  if (options.keepQuotes !== true) {
@@ -5621,8 +5626,8 @@ const parse$3 = (input, options = {}) => {
5621
5626
  if (value === CHAR_LEFT_CURLY_BRACE$1) {
5622
5627
  depth++;
5623
5628
 
5624
- let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
5625
- let brace = {
5629
+ const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
5630
+ const brace = {
5626
5631
  type: 'brace',
5627
5632
  open: true,
5628
5633
  close: false,
@@ -5649,7 +5654,7 @@ const parse$3 = (input, options = {}) => {
5649
5654
  continue;
5650
5655
  }
5651
5656
 
5652
- let type = 'close';
5657
+ const type = 'close';
5653
5658
  block = stack.pop();
5654
5659
  block.close = true;
5655
5660
 
@@ -5667,7 +5672,7 @@ const parse$3 = (input, options = {}) => {
5667
5672
  if (value === CHAR_COMMA$1 && depth > 0) {
5668
5673
  if (block.ranges > 0) {
5669
5674
  block.ranges = 0;
5670
- let open = block.nodes.shift();
5675
+ const open = block.nodes.shift();
5671
5676
  block.nodes = [open, { type: 'text', value: stringify$1(block) }];
5672
5677
  }
5673
5678
 
@@ -5681,7 +5686,7 @@ const parse$3 = (input, options = {}) => {
5681
5686
  */
5682
5687
 
5683
5688
  if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
5684
- let siblings = block.nodes;
5689
+ const siblings = block.nodes;
5685
5690
 
5686
5691
  if (depth === 0 || siblings.length === 0) {
5687
5692
  push({ type: 'text', value });
@@ -5708,7 +5713,7 @@ const parse$3 = (input, options = {}) => {
5708
5713
  if (prev.type === 'range') {
5709
5714
  siblings.pop();
5710
5715
 
5711
- let before = siblings[siblings.length - 1];
5716
+ const before = siblings[siblings.length - 1];
5712
5717
  before.value += prev.value + value;
5713
5718
  prev = before;
5714
5719
  block.ranges--;
@@ -5741,8 +5746,8 @@ const parse$3 = (input, options = {}) => {
5741
5746
  });
5742
5747
 
5743
5748
  // get the location of the block on parent.nodes (block's siblings)
5744
- let parent = stack[stack.length - 1];
5745
- let index = parent.nodes.indexOf(block);
5749
+ const parent = stack[stack.length - 1];
5750
+ const index = parent.nodes.indexOf(block);
5746
5751
  // replace the (invalid) block with it's nodes
5747
5752
  parent.nodes.splice(index, 1, ...block.nodes);
5748
5753
  }
@@ -5777,8 +5782,8 @@ const braces$1 = (input, options = {}) => {
5777
5782
  let output = [];
5778
5783
 
5779
5784
  if (Array.isArray(input)) {
5780
- for (let pattern of input) {
5781
- let result = braces$1.create(pattern, options);
5785
+ for (const pattern of input) {
5786
+ const result = braces$1.create(pattern, options);
5782
5787
  if (Array.isArray(result)) {
5783
5788
  output.push(...result);
5784
5789
  } else {
@@ -5912,7 +5917,7 @@ braces$1.create = (input, options = {}) => {
5912
5917
  return [input];
5913
5918
  }
5914
5919
 
5915
- return options.expand !== true
5920
+ return options.expand !== true
5916
5921
  ? braces$1.compile(input, options)
5917
5922
  : braces$1.expand(input, options);
5918
5923
  };
@@ -8593,7 +8598,7 @@ function expandPatternsWithBraceExpansion(patterns) {
8593
8598
  }
8594
8599
  pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
8595
8600
  function expandBraceExpansion(pattern) {
8596
- const patterns = micromatch.braces(pattern, { expand: true, nodupes: true });
8601
+ const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true });
8597
8602
  /**
8598
8603
  * Sort the patterns by length so that the same depth patterns are processed side by side.
8599
8604
  * `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
@@ -9492,15 +9497,15 @@ var reusify_1 = reusify$1;
9492
9497
 
9493
9498
  var reusify = reusify_1;
9494
9499
 
9495
- function fastqueue (context, worker, concurrency) {
9500
+ function fastqueue (context, worker, _concurrency) {
9496
9501
  if (typeof context === 'function') {
9497
- concurrency = worker;
9502
+ _concurrency = worker;
9498
9503
  worker = context;
9499
9504
  context = null;
9500
9505
  }
9501
9506
 
9502
- if (concurrency < 1) {
9503
- throw new Error('fastqueue concurrency must be greater than 1')
9507
+ if (!(_concurrency >= 1)) {
9508
+ throw new Error('fastqueue concurrency must be equal to or greater than 1')
9504
9509
  }
9505
9510
 
9506
9511
  var cache = reusify(Task);
@@ -9515,7 +9520,23 @@ function fastqueue (context, worker, concurrency) {
9515
9520
  saturated: noop,
9516
9521
  pause: pause,
9517
9522
  paused: false,
9518
- concurrency: concurrency,
9523
+
9524
+ get concurrency () {
9525
+ return _concurrency
9526
+ },
9527
+ set concurrency (value) {
9528
+ if (!(value >= 1)) {
9529
+ throw new Error('fastqueue concurrency must be equal to or greater than 1')
9530
+ }
9531
+ _concurrency = value;
9532
+
9533
+ if (self.paused) return
9534
+ for (; queueHead && _running < _concurrency;) {
9535
+ _running++;
9536
+ release();
9537
+ }
9538
+ },
9539
+
9519
9540
  running: running,
9520
9541
  resume: resume,
9521
9542
  idle: idle,
@@ -9565,7 +9586,12 @@ function fastqueue (context, worker, concurrency) {
9565
9586
  function resume () {
9566
9587
  if (!self.paused) return
9567
9588
  self.paused = false;
9568
- for (var i = 0; i < self.concurrency; i++) {
9589
+ if (queueHead === null) {
9590
+ _running++;
9591
+ release();
9592
+ return
9593
+ }
9594
+ for (; queueHead && _running < _concurrency;) {
9569
9595
  _running++;
9570
9596
  release();
9571
9597
  }
@@ -9584,7 +9610,7 @@ function fastqueue (context, worker, concurrency) {
9584
9610
  current.callback = done || noop;
9585
9611
  current.errorHandler = errorHandler;
9586
9612
 
9587
- if (_running === self.concurrency || self.paused) {
9613
+ if (_running >= _concurrency || self.paused) {
9588
9614
  if (queueTail) {
9589
9615
  queueTail.next = current;
9590
9616
  queueTail = current;
@@ -9606,8 +9632,9 @@ function fastqueue (context, worker, concurrency) {
9606
9632
  current.release = release;
9607
9633
  current.value = value;
9608
9634
  current.callback = done || noop;
9635
+ current.errorHandler = errorHandler;
9609
9636
 
9610
- if (_running === self.concurrency || self.paused) {
9637
+ if (_running >= _concurrency || self.paused) {
9611
9638
  if (queueHead) {
9612
9639
  current.next = queueHead;
9613
9640
  queueHead = current;
@@ -9627,7 +9654,7 @@ function fastqueue (context, worker, concurrency) {
9627
9654
  cache.release(holder);
9628
9655
  }
9629
9656
  var next = queueHead;
9630
- if (next) {
9657
+ if (next && _running <= _concurrency) {
9631
9658
  if (!self.paused) {
9632
9659
  if (queueTail === queueHead) {
9633
9660
  queueTail = null;
@@ -9690,9 +9717,9 @@ function Task () {
9690
9717
  };
9691
9718
  }
9692
9719
 
9693
- function queueAsPromised (context, worker, concurrency) {
9720
+ function queueAsPromised (context, worker, _concurrency) {
9694
9721
  if (typeof context === 'function') {
9695
- concurrency = worker;
9722
+ _concurrency = worker;
9696
9723
  worker = context;
9697
9724
  context = null;
9698
9725
  }
@@ -9704,7 +9731,7 @@ function queueAsPromised (context, worker, concurrency) {
9704
9731
  }, cb);
9705
9732
  }
9706
9733
 
9707
- var queue = fastqueue(context, asyncWrapper, concurrency);
9734
+ var queue = fastqueue(context, asyncWrapper, _concurrency);
9708
9735
 
9709
9736
  var pushCb = queue.push;
9710
9737
  var unshiftCb = queue.unshift;
@@ -10853,12 +10880,11 @@ function assertPatternsInput(input) {
10853
10880
  }
10854
10881
  var out = FastGlob;
10855
10882
 
10856
- var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
10857
-
10858
10883
  const defaultOptions = {
10859
10884
  hostname: "http://localhost/",
10860
10885
  dynamicRoutes: [],
10861
10886
  exclude: [],
10887
+ externalSitemaps: [],
10862
10888
  basePath: "",
10863
10889
  outDir: "dist",
10864
10890
  extensions: "html",
@@ -10880,6 +10906,17 @@ function resolveOptions(userOptions) {
10880
10906
  );
10881
10907
  }
10882
10908
 
10909
+ function getResolvedPath(file, resolvedOptions) {
10910
+ if (isAbsolute(resolvedOptions.outDir))
10911
+ return resolve(`${resolvedOptions.outDir}/${file}`);
10912
+ return resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
10913
+ }
10914
+ function removeMaybeSuffix(suffix, str) {
10915
+ if (!str.endsWith(suffix))
10916
+ return str;
10917
+ return str.slice(0, -suffix.length);
10918
+ }
10919
+
10883
10920
  var RobotCorrespondences = /* @__PURE__ */ ((RobotCorrespondences2) => {
10884
10921
  RobotCorrespondences2["userAgent"] = "User-agent";
10885
10922
  RobotCorrespondences2["allow"] = "Allow";
@@ -10904,40 +10941,30 @@ function getRules(options) {
10904
10941
  });
10905
10942
  return rules;
10906
10943
  }
10907
- function getContent(rules, hostname) {
10944
+ function getContent(rules, hostname, externalSitemaps) {
10908
10945
  return rules.map((rule) => `${rule.key}: ${String(rule.value).trim()}`).join("\n").concat(`
10909
10946
 
10910
- Sitemap: ${getFinalSitemapPath(hostname)}`);
10911
- }
10912
- function getFinalSitemapPath(hostname) {
10913
- return `${ensureSuffix("/", hostname)}sitemap.xml`;
10914
- }
10915
-
10916
- function getResolvedPath(file, resolvedOptions) {
10917
- if (node_path.isAbsolute(resolvedOptions.outDir))
10918
- return node_path.resolve(`${resolvedOptions.outDir}/${file}`);
10919
- return node_path.resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
10947
+ Sitemap: ${getFinalSitemapPath(hostname)}`).concat(externalSitemaps.map((s) => `
10948
+ Sitemap: ${s.startsWith("http") ? s : getFinalSitemapPath(hostname, s)}`).join(""));
10920
10949
  }
10921
- function removeMaybeSuffix(suffix, str) {
10922
- if (!str.endsWith(suffix))
10923
- return str;
10924
- return str.slice(0, -suffix.length);
10950
+ function getFinalSitemapPath(hostname, file = "/sitemap.xml") {
10951
+ return `${removeMaybeSuffix("/", hostname)}${ensurePrefix("/", file)}`;
10925
10952
  }
10926
10953
 
10927
10954
  function getRoutes(options) {
10928
10955
  const ext = typeof options.extensions === "string" ? [options.extensions] : options.extensions;
10929
10956
  const strExt = ext.map((e) => `**/*.${e}`);
10930
10957
  return [
10931
- ...fg.sync(strExt, { cwd: options.outDir }).map((route) => {
10958
+ ...out.sync(strExt, { cwd: options.outDir }).map((route) => {
10932
10959
  let r = route;
10933
10960
  ext.forEach((e) => {
10934
10961
  const regex = new RegExp(`index.${e}`, "g");
10935
10962
  r = r.replace(regex, "");
10936
10963
  });
10937
- const parsedRoute = node_path.parse(r);
10938
- return slash$1(node_path.join("/", parsedRoute.dir, parsedRoute.name));
10964
+ const parsedRoute = parse$4(r);
10965
+ return slash$1(join("/", parsedRoute.dir, parsedRoute.name));
10939
10966
  }),
10940
- ...options.dynamicRoutes.map((route) => slash$1(node_path.join("/", node_path.join(node_path.parse(route).dir, node_path.parse(route).name))))
10967
+ ...options.dynamicRoutes.map((route) => slash$1(join("/", join(parse$4(route).dir, parse$4(route).name))))
10941
10968
  ].filter((route) => !options.exclude.includes(route));
10942
10969
  }
10943
10970
  function getOptionByRoute(options, route) {
@@ -10951,20 +10978,26 @@ function getOptionByRoute(options, route) {
10951
10978
  return void 0;
10952
10979
  }
10953
10980
  function getFormattedSitemap(options, routes) {
10954
- return routes.map((route) => ({
10955
- url: new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href,
10956
- changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
10957
- priority: getOptionByRoute(options.priority, route) ?? defaultOptions.priority,
10958
- lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
10959
- }));
10981
+ return routes.map((route) => {
10982
+ const url = new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href;
10983
+ const formattedSitemap = {
10984
+ url,
10985
+ changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
10986
+ priority: getOptionByRoute(options.priority, route) ?? defaultOptions.priority,
10987
+ lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
10988
+ };
10989
+ if (options.i18n)
10990
+ return Object.assign(formattedSitemap, { link: options.i18n.languages.map((str) => ({ lang: str, url: str === options.i18n?.defaultLanguage ? url : `${url}/${str}` })) });
10991
+ return formattedSitemap;
10992
+ });
10960
10993
  }
10961
10994
 
10962
10995
  function generateSitemap(options = {}) {
10963
10996
  const resolvedOptions = resolveOptions(options);
10964
10997
  if (resolvedOptions.generateRobotsTxt) {
10965
10998
  const robotRules = getRules(resolvedOptions.robots);
10966
- const robotContent = getContent(robotRules, resolvedOptions.hostname);
10967
- node_fs.writeFileSync(getResolvedPath("robots.txt", resolvedOptions), robotContent);
10999
+ const robotContent = getContent(robotRules, resolvedOptions.hostname, resolvedOptions.externalSitemaps);
11000
+ writeFileSync(getResolvedPath("robots.txt", resolvedOptions), robotContent);
10968
11001
  }
10969
11002
  const routes = getRoutes(resolvedOptions);
10970
11003
  if (!routes.length)
@@ -10975,7 +11008,7 @@ function generateSitemap(options = {}) {
10975
11008
  distExports.streamToPromise(stream).then((sitemap) => {
10976
11009
  const utfSitemap = sitemap.toString("utf-8");
10977
11010
  const formattedSitemap2 = resolvedOptions.readable ? format(utfSitemap) : utfSitemap;
10978
- node_fs.writeFileSync(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
11011
+ writeFileSync(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
10979
11012
  });
10980
11013
  stream.end();
10981
11014
  }
@@ -11003,4 +11036,4 @@ function sitemapPlugin(options = {}) {
11003
11036
  };
11004
11037
  }
11005
11038
 
11006
- module.exports = sitemapPlugin;
11039
+ export { sitemapPlugin as default };