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/README.md +25 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.js +157 -124
- package/dist/index.mjs +134 -98
- package/package.json +17 -13
package/dist/index.mjs
CHANGED
|
@@ -4049,7 +4049,7 @@ var cjsExports$1 = cjs.exports;
|
|
|
4049
4049
|
containsTextNodesWithLineBreaks = true;
|
|
4050
4050
|
child.content = child.content.trim();
|
|
4051
4051
|
}
|
|
4052
|
-
else if (index === 0 || index === nodeChildren.length - 1) {
|
|
4052
|
+
else if ((index === 0 || index === nodeChildren.length - 1) && !preserveSpace) {
|
|
4053
4053
|
if (child.content.trim().length === 0) {
|
|
4054
4054
|
// If the text node is at the start or end and is empty, it should be ignored when formatting
|
|
4055
4055
|
child.content = '';
|
|
@@ -4151,11 +4151,6 @@ function ensurePrefix(prefix, str) {
|
|
|
4151
4151
|
return prefix + str;
|
|
4152
4152
|
return str;
|
|
4153
4153
|
}
|
|
4154
|
-
function ensureSuffix(suffix, str) {
|
|
4155
|
-
if (!str.endsWith(suffix))
|
|
4156
|
-
return str + suffix;
|
|
4157
|
-
return str;
|
|
4158
|
-
}
|
|
4159
4154
|
|
|
4160
4155
|
var tasks = {};
|
|
4161
4156
|
|
|
@@ -4225,11 +4220,11 @@ const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
|
4225
4220
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
4226
4221
|
/**
|
|
4227
4222
|
* All non-escaped special characters.
|
|
4228
|
-
* Posix: ()*?[
|
|
4229
|
-
* Windows: (){}, !+@ before (, ! at the beginning.
|
|
4223
|
+
* Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
|
|
4224
|
+
* Windows: (){}[], !+@ before (, ! at the beginning.
|
|
4230
4225
|
*/
|
|
4231
4226
|
const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
4232
|
-
const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g;
|
|
4227
|
+
const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
4233
4228
|
/**
|
|
4234
4229
|
* The device path (\\.\ or \\?\).
|
|
4235
4230
|
* https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
|
|
@@ -4240,7 +4235,7 @@ const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
|
|
|
4240
4235
|
* Windows: !()+@{}
|
|
4241
4236
|
* https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
|
4242
4237
|
*/
|
|
4243
|
-
const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
|
|
4238
|
+
const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
|
|
4244
4239
|
/**
|
|
4245
4240
|
* Designed to work only with simple paths: `dir\\file`.
|
|
4246
4241
|
*/
|
|
@@ -4535,7 +4530,7 @@ var utils$j = {};
|
|
|
4535
4530
|
*/
|
|
4536
4531
|
|
|
4537
4532
|
exports.escapeNode = (block, n = 0, type) => {
|
|
4538
|
-
|
|
4533
|
+
const node = block.nodes[n];
|
|
4539
4534
|
if (!node) return;
|
|
4540
4535
|
|
|
4541
4536
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
|
@@ -4604,13 +4599,23 @@ var utils$j = {};
|
|
|
4604
4599
|
|
|
4605
4600
|
exports.flatten = (...args) => {
|
|
4606
4601
|
const result = [];
|
|
4602
|
+
|
|
4607
4603
|
const flat = arr => {
|
|
4608
4604
|
for (let i = 0; i < arr.length; i++) {
|
|
4609
|
-
|
|
4610
|
-
|
|
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
|
+
}
|
|
4611
4615
|
}
|
|
4612
4616
|
return result;
|
|
4613
4617
|
};
|
|
4618
|
+
|
|
4614
4619
|
flat(args);
|
|
4615
4620
|
return result;
|
|
4616
4621
|
};
|
|
@@ -4619,9 +4624,9 @@ var utils$j = {};
|
|
|
4619
4624
|
const utils$i = utils$j;
|
|
4620
4625
|
|
|
4621
4626
|
var stringify$4 = (ast, options = {}) => {
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4627
|
+
const stringify = (node, parent = {}) => {
|
|
4628
|
+
const invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
|
|
4629
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
4625
4630
|
let output = '';
|
|
4626
4631
|
|
|
4627
4632
|
if (node.value) {
|
|
@@ -4636,7 +4641,7 @@ var stringify$4 = (ast, options = {}) => {
|
|
|
4636
4641
|
}
|
|
4637
4642
|
|
|
4638
4643
|
if (node.nodes) {
|
|
4639
|
-
for (
|
|
4644
|
+
for (const child of node.nodes) {
|
|
4640
4645
|
output += stringify(child);
|
|
4641
4646
|
}
|
|
4642
4647
|
}
|
|
@@ -5010,7 +5015,7 @@ const toMaxLen = (input, maxLength) => {
|
|
|
5010
5015
|
return negative ? ('-' + input) : input;
|
|
5011
5016
|
};
|
|
5012
5017
|
|
|
5013
|
-
const toSequence = (parts, options) => {
|
|
5018
|
+
const toSequence = (parts, options, maxLen) => {
|
|
5014
5019
|
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
5015
5020
|
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
5016
5021
|
|
|
@@ -5020,11 +5025,11 @@ const toSequence = (parts, options) => {
|
|
|
5020
5025
|
let result;
|
|
5021
5026
|
|
|
5022
5027
|
if (parts.positives.length) {
|
|
5023
|
-
positives = parts.positives.join('|');
|
|
5028
|
+
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
|
|
5024
5029
|
}
|
|
5025
5030
|
|
|
5026
5031
|
if (parts.negatives.length) {
|
|
5027
|
-
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
|
5032
|
+
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
|
|
5028
5033
|
}
|
|
5029
5034
|
|
|
5030
5035
|
if (positives && negatives) {
|
|
@@ -5122,7 +5127,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
|
|
|
5122
5127
|
|
|
5123
5128
|
if (options.toRegex === true) {
|
|
5124
5129
|
return step > 1
|
|
5125
|
-
? toSequence(parts, options)
|
|
5130
|
+
? toSequence(parts, options, maxLen)
|
|
5126
5131
|
: toRegex(range, null, { wrap: false, ...options });
|
|
5127
5132
|
}
|
|
5128
5133
|
|
|
@@ -5134,7 +5139,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
|
|
|
5134
5139
|
return invalidRange(start, end, options);
|
|
5135
5140
|
}
|
|
5136
5141
|
|
|
5137
|
-
|
|
5138
5142
|
let format = options.transform || (val => String.fromCharCode(val));
|
|
5139
5143
|
let a = `${start}`.charCodeAt(0);
|
|
5140
5144
|
let b = `${end}`.charCodeAt(0);
|
|
@@ -5202,30 +5206,32 @@ const fill$1 = fillRange;
|
|
|
5202
5206
|
const utils$h = utils$j;
|
|
5203
5207
|
|
|
5204
5208
|
const compile$1 = (ast, options = {}) => {
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
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 ? '\\' : '';
|
|
5210
5214
|
let output = '';
|
|
5211
5215
|
|
|
5212
5216
|
if (node.isOpen === true) {
|
|
5213
5217
|
return prefix + node.value;
|
|
5214
5218
|
}
|
|
5219
|
+
|
|
5215
5220
|
if (node.isClose === true) {
|
|
5221
|
+
console.log('node.isClose', prefix, node.value);
|
|
5216
5222
|
return prefix + node.value;
|
|
5217
5223
|
}
|
|
5218
5224
|
|
|
5219
5225
|
if (node.type === 'open') {
|
|
5220
|
-
return invalid ?
|
|
5226
|
+
return invalid ? prefix + node.value : '(';
|
|
5221
5227
|
}
|
|
5222
5228
|
|
|
5223
5229
|
if (node.type === 'close') {
|
|
5224
|
-
return invalid ?
|
|
5230
|
+
return invalid ? prefix + node.value : ')';
|
|
5225
5231
|
}
|
|
5226
5232
|
|
|
5227
5233
|
if (node.type === 'comma') {
|
|
5228
|
-
return node.prev.type === 'comma' ? '' :
|
|
5234
|
+
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
|
5229
5235
|
}
|
|
5230
5236
|
|
|
5231
5237
|
if (node.value) {
|
|
@@ -5233,8 +5239,8 @@ const compile$1 = (ast, options = {}) => {
|
|
|
5233
5239
|
}
|
|
5234
5240
|
|
|
5235
5241
|
if (node.nodes && node.ranges > 0) {
|
|
5236
|
-
|
|
5237
|
-
|
|
5242
|
+
const args = utils$h.reduce(node.nodes);
|
|
5243
|
+
const range = fill$1(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
|
5238
5244
|
|
|
5239
5245
|
if (range.length !== 0) {
|
|
5240
5246
|
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
|
@@ -5242,10 +5248,11 @@ const compile$1 = (ast, options = {}) => {
|
|
|
5242
5248
|
}
|
|
5243
5249
|
|
|
5244
5250
|
if (node.nodes) {
|
|
5245
|
-
for (
|
|
5251
|
+
for (const child of node.nodes) {
|
|
5246
5252
|
output += walk(child, node);
|
|
5247
5253
|
}
|
|
5248
5254
|
}
|
|
5255
|
+
|
|
5249
5256
|
return output;
|
|
5250
5257
|
};
|
|
5251
5258
|
|
|
@@ -5259,7 +5266,7 @@ const stringify$2 = stringify$4;
|
|
|
5259
5266
|
const utils$g = utils$j;
|
|
5260
5267
|
|
|
5261
5268
|
const append = (queue = '', stash = '', enclose = false) => {
|
|
5262
|
-
|
|
5269
|
+
const result = [];
|
|
5263
5270
|
|
|
5264
5271
|
queue = [].concat(queue);
|
|
5265
5272
|
stash = [].concat(stash);
|
|
@@ -5269,15 +5276,15 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
5269
5276
|
return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
|
|
5270
5277
|
}
|
|
5271
5278
|
|
|
5272
|
-
for (
|
|
5279
|
+
for (const item of queue) {
|
|
5273
5280
|
if (Array.isArray(item)) {
|
|
5274
|
-
for (
|
|
5281
|
+
for (const value of item) {
|
|
5275
5282
|
result.push(append(value, stash, enclose));
|
|
5276
5283
|
}
|
|
5277
5284
|
} else {
|
|
5278
5285
|
for (let ele of stash) {
|
|
5279
5286
|
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
|
5280
|
-
result.push(Array.isArray(ele) ? append(item, ele, enclose) :
|
|
5287
|
+
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
|
5281
5288
|
}
|
|
5282
5289
|
}
|
|
5283
5290
|
}
|
|
@@ -5285,9 +5292,9 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
5285
5292
|
};
|
|
5286
5293
|
|
|
5287
5294
|
const expand$1 = (ast, options = {}) => {
|
|
5288
|
-
|
|
5295
|
+
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
|
|
5289
5296
|
|
|
5290
|
-
|
|
5297
|
+
const walk = (node, parent = {}) => {
|
|
5291
5298
|
node.queue = [];
|
|
5292
5299
|
|
|
5293
5300
|
let p = parent;
|
|
@@ -5309,7 +5316,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5309
5316
|
}
|
|
5310
5317
|
|
|
5311
5318
|
if (node.nodes && node.ranges > 0) {
|
|
5312
|
-
|
|
5319
|
+
const args = utils$g.reduce(node.nodes);
|
|
5313
5320
|
|
|
5314
5321
|
if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
|
|
5315
5322
|
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
|
@@ -5325,7 +5332,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5325
5332
|
return;
|
|
5326
5333
|
}
|
|
5327
5334
|
|
|
5328
|
-
|
|
5335
|
+
const enclose = utils$g.encloseBrace(node);
|
|
5329
5336
|
let queue = node.queue;
|
|
5330
5337
|
let block = node;
|
|
5331
5338
|
|
|
@@ -5335,7 +5342,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5335
5342
|
}
|
|
5336
5343
|
|
|
5337
5344
|
for (let i = 0; i < node.nodes.length; i++) {
|
|
5338
|
-
|
|
5345
|
+
const child = node.nodes[i];
|
|
5339
5346
|
|
|
5340
5347
|
if (child.type === 'comma' && node.type === 'brace') {
|
|
5341
5348
|
if (i === 1) queue.push('');
|
|
@@ -5367,7 +5374,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5367
5374
|
var expand_1 = expand$1;
|
|
5368
5375
|
|
|
5369
5376
|
var constants$4 = {
|
|
5370
|
-
MAX_LENGTH:
|
|
5377
|
+
MAX_LENGTH: 10000,
|
|
5371
5378
|
|
|
5372
5379
|
// Digits
|
|
5373
5380
|
CHAR_0: '0', /* 0 */
|
|
@@ -5455,18 +5462,18 @@ const parse$3 = (input, options = {}) => {
|
|
|
5455
5462
|
throw new TypeError('Expected a string');
|
|
5456
5463
|
}
|
|
5457
5464
|
|
|
5458
|
-
|
|
5459
|
-
|
|
5465
|
+
const opts = options || {};
|
|
5466
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
|
|
5460
5467
|
if (input.length > max) {
|
|
5461
5468
|
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
|
5462
5469
|
}
|
|
5463
5470
|
|
|
5464
|
-
|
|
5465
|
-
|
|
5471
|
+
const ast = { type: 'root', input, nodes: [] };
|
|
5472
|
+
const stack = [ast];
|
|
5466
5473
|
let block = ast;
|
|
5467
5474
|
let prev = ast;
|
|
5468
5475
|
let brackets = 0;
|
|
5469
|
-
|
|
5476
|
+
const length = input.length;
|
|
5470
5477
|
let index = 0;
|
|
5471
5478
|
let depth = 0;
|
|
5472
5479
|
let value;
|
|
@@ -5531,6 +5538,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5531
5538
|
|
|
5532
5539
|
if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
|
|
5533
5540
|
brackets++;
|
|
5541
|
+
|
|
5534
5542
|
let next;
|
|
5535
5543
|
|
|
5536
5544
|
while (index < length && (next = advance())) {
|
|
@@ -5586,7 +5594,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5586
5594
|
*/
|
|
5587
5595
|
|
|
5588
5596
|
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
|
5589
|
-
|
|
5597
|
+
const open = value;
|
|
5590
5598
|
let next;
|
|
5591
5599
|
|
|
5592
5600
|
if (options.keepQuotes !== true) {
|
|
@@ -5618,8 +5626,8 @@ const parse$3 = (input, options = {}) => {
|
|
|
5618
5626
|
if (value === CHAR_LEFT_CURLY_BRACE$1) {
|
|
5619
5627
|
depth++;
|
|
5620
5628
|
|
|
5621
|
-
|
|
5622
|
-
|
|
5629
|
+
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
|
5630
|
+
const brace = {
|
|
5623
5631
|
type: 'brace',
|
|
5624
5632
|
open: true,
|
|
5625
5633
|
close: false,
|
|
@@ -5646,7 +5654,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5646
5654
|
continue;
|
|
5647
5655
|
}
|
|
5648
5656
|
|
|
5649
|
-
|
|
5657
|
+
const type = 'close';
|
|
5650
5658
|
block = stack.pop();
|
|
5651
5659
|
block.close = true;
|
|
5652
5660
|
|
|
@@ -5664,7 +5672,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5664
5672
|
if (value === CHAR_COMMA$1 && depth > 0) {
|
|
5665
5673
|
if (block.ranges > 0) {
|
|
5666
5674
|
block.ranges = 0;
|
|
5667
|
-
|
|
5675
|
+
const open = block.nodes.shift();
|
|
5668
5676
|
block.nodes = [open, { type: 'text', value: stringify$1(block) }];
|
|
5669
5677
|
}
|
|
5670
5678
|
|
|
@@ -5678,7 +5686,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5678
5686
|
*/
|
|
5679
5687
|
|
|
5680
5688
|
if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
|
|
5681
|
-
|
|
5689
|
+
const siblings = block.nodes;
|
|
5682
5690
|
|
|
5683
5691
|
if (depth === 0 || siblings.length === 0) {
|
|
5684
5692
|
push({ type: 'text', value });
|
|
@@ -5705,7 +5713,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5705
5713
|
if (prev.type === 'range') {
|
|
5706
5714
|
siblings.pop();
|
|
5707
5715
|
|
|
5708
|
-
|
|
5716
|
+
const before = siblings[siblings.length - 1];
|
|
5709
5717
|
before.value += prev.value + value;
|
|
5710
5718
|
prev = before;
|
|
5711
5719
|
block.ranges--;
|
|
@@ -5738,8 +5746,8 @@ const parse$3 = (input, options = {}) => {
|
|
|
5738
5746
|
});
|
|
5739
5747
|
|
|
5740
5748
|
// get the location of the block on parent.nodes (block's siblings)
|
|
5741
|
-
|
|
5742
|
-
|
|
5749
|
+
const parent = stack[stack.length - 1];
|
|
5750
|
+
const index = parent.nodes.indexOf(block);
|
|
5743
5751
|
// replace the (invalid) block with it's nodes
|
|
5744
5752
|
parent.nodes.splice(index, 1, ...block.nodes);
|
|
5745
5753
|
}
|
|
@@ -5774,8 +5782,8 @@ const braces$1 = (input, options = {}) => {
|
|
|
5774
5782
|
let output = [];
|
|
5775
5783
|
|
|
5776
5784
|
if (Array.isArray(input)) {
|
|
5777
|
-
for (
|
|
5778
|
-
|
|
5785
|
+
for (const pattern of input) {
|
|
5786
|
+
const result = braces$1.create(pattern, options);
|
|
5779
5787
|
if (Array.isArray(result)) {
|
|
5780
5788
|
output.push(...result);
|
|
5781
5789
|
} else {
|
|
@@ -5909,7 +5917,7 @@ braces$1.create = (input, options = {}) => {
|
|
|
5909
5917
|
return [input];
|
|
5910
5918
|
}
|
|
5911
5919
|
|
|
5912
|
-
|
|
5920
|
+
return options.expand !== true
|
|
5913
5921
|
? braces$1.compile(input, options)
|
|
5914
5922
|
: braces$1.expand(input, options);
|
|
5915
5923
|
};
|
|
@@ -8590,7 +8598,7 @@ function expandPatternsWithBraceExpansion(patterns) {
|
|
|
8590
8598
|
}
|
|
8591
8599
|
pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
|
|
8592
8600
|
function expandBraceExpansion(pattern) {
|
|
8593
|
-
const patterns = micromatch.braces(pattern, { expand: true, nodupes: true });
|
|
8601
|
+
const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true });
|
|
8594
8602
|
/**
|
|
8595
8603
|
* Sort the patterns by length so that the same depth patterns are processed side by side.
|
|
8596
8604
|
* `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
|
|
@@ -9489,15 +9497,15 @@ var reusify_1 = reusify$1;
|
|
|
9489
9497
|
|
|
9490
9498
|
var reusify = reusify_1;
|
|
9491
9499
|
|
|
9492
|
-
function fastqueue (context, worker,
|
|
9500
|
+
function fastqueue (context, worker, _concurrency) {
|
|
9493
9501
|
if (typeof context === 'function') {
|
|
9494
|
-
|
|
9502
|
+
_concurrency = worker;
|
|
9495
9503
|
worker = context;
|
|
9496
9504
|
context = null;
|
|
9497
9505
|
}
|
|
9498
9506
|
|
|
9499
|
-
if (
|
|
9500
|
-
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')
|
|
9501
9509
|
}
|
|
9502
9510
|
|
|
9503
9511
|
var cache = reusify(Task);
|
|
@@ -9512,7 +9520,23 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9512
9520
|
saturated: noop,
|
|
9513
9521
|
pause: pause,
|
|
9514
9522
|
paused: false,
|
|
9515
|
-
|
|
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
|
+
|
|
9516
9540
|
running: running,
|
|
9517
9541
|
resume: resume,
|
|
9518
9542
|
idle: idle,
|
|
@@ -9562,7 +9586,12 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9562
9586
|
function resume () {
|
|
9563
9587
|
if (!self.paused) return
|
|
9564
9588
|
self.paused = false;
|
|
9565
|
-
|
|
9589
|
+
if (queueHead === null) {
|
|
9590
|
+
_running++;
|
|
9591
|
+
release();
|
|
9592
|
+
return
|
|
9593
|
+
}
|
|
9594
|
+
for (; queueHead && _running < _concurrency;) {
|
|
9566
9595
|
_running++;
|
|
9567
9596
|
release();
|
|
9568
9597
|
}
|
|
@@ -9581,7 +9610,7 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9581
9610
|
current.callback = done || noop;
|
|
9582
9611
|
current.errorHandler = errorHandler;
|
|
9583
9612
|
|
|
9584
|
-
if (_running
|
|
9613
|
+
if (_running >= _concurrency || self.paused) {
|
|
9585
9614
|
if (queueTail) {
|
|
9586
9615
|
queueTail.next = current;
|
|
9587
9616
|
queueTail = current;
|
|
@@ -9603,8 +9632,9 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9603
9632
|
current.release = release;
|
|
9604
9633
|
current.value = value;
|
|
9605
9634
|
current.callback = done || noop;
|
|
9635
|
+
current.errorHandler = errorHandler;
|
|
9606
9636
|
|
|
9607
|
-
if (_running
|
|
9637
|
+
if (_running >= _concurrency || self.paused) {
|
|
9608
9638
|
if (queueHead) {
|
|
9609
9639
|
current.next = queueHead;
|
|
9610
9640
|
queueHead = current;
|
|
@@ -9624,7 +9654,7 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9624
9654
|
cache.release(holder);
|
|
9625
9655
|
}
|
|
9626
9656
|
var next = queueHead;
|
|
9627
|
-
if (next) {
|
|
9657
|
+
if (next && _running <= _concurrency) {
|
|
9628
9658
|
if (!self.paused) {
|
|
9629
9659
|
if (queueTail === queueHead) {
|
|
9630
9660
|
queueTail = null;
|
|
@@ -9687,9 +9717,9 @@ function Task () {
|
|
|
9687
9717
|
};
|
|
9688
9718
|
}
|
|
9689
9719
|
|
|
9690
|
-
function queueAsPromised (context, worker,
|
|
9720
|
+
function queueAsPromised (context, worker, _concurrency) {
|
|
9691
9721
|
if (typeof context === 'function') {
|
|
9692
|
-
|
|
9722
|
+
_concurrency = worker;
|
|
9693
9723
|
worker = context;
|
|
9694
9724
|
context = null;
|
|
9695
9725
|
}
|
|
@@ -9701,7 +9731,7 @@ function queueAsPromised (context, worker, concurrency) {
|
|
|
9701
9731
|
}, cb);
|
|
9702
9732
|
}
|
|
9703
9733
|
|
|
9704
|
-
var queue = fastqueue(context, asyncWrapper,
|
|
9734
|
+
var queue = fastqueue(context, asyncWrapper, _concurrency);
|
|
9705
9735
|
|
|
9706
9736
|
var pushCb = queue.push;
|
|
9707
9737
|
var unshiftCb = queue.unshift;
|
|
@@ -10850,12 +10880,11 @@ function assertPatternsInput(input) {
|
|
|
10850
10880
|
}
|
|
10851
10881
|
var out = FastGlob;
|
|
10852
10882
|
|
|
10853
|
-
var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
|
|
10854
|
-
|
|
10855
10883
|
const defaultOptions = {
|
|
10856
10884
|
hostname: "http://localhost/",
|
|
10857
10885
|
dynamicRoutes: [],
|
|
10858
10886
|
exclude: [],
|
|
10887
|
+
externalSitemaps: [],
|
|
10859
10888
|
basePath: "",
|
|
10860
10889
|
outDir: "dist",
|
|
10861
10890
|
extensions: "html",
|
|
@@ -10877,6 +10906,17 @@ function resolveOptions(userOptions) {
|
|
|
10877
10906
|
);
|
|
10878
10907
|
}
|
|
10879
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
|
+
|
|
10880
10920
|
var RobotCorrespondences = /* @__PURE__ */ ((RobotCorrespondences2) => {
|
|
10881
10921
|
RobotCorrespondences2["userAgent"] = "User-agent";
|
|
10882
10922
|
RobotCorrespondences2["allow"] = "Allow";
|
|
@@ -10901,31 +10941,21 @@ function getRules(options) {
|
|
|
10901
10941
|
});
|
|
10902
10942
|
return rules;
|
|
10903
10943
|
}
|
|
10904
|
-
function getContent(rules, hostname) {
|
|
10944
|
+
function getContent(rules, hostname, externalSitemaps) {
|
|
10905
10945
|
return rules.map((rule) => `${rule.key}: ${String(rule.value).trim()}`).join("\n").concat(`
|
|
10906
10946
|
|
|
10907
|
-
Sitemap: ${getFinalSitemapPath(hostname)}`)
|
|
10947
|
+
Sitemap: ${getFinalSitemapPath(hostname)}`).concat(externalSitemaps.map((s) => `
|
|
10948
|
+
Sitemap: ${s.startsWith("http") ? s : getFinalSitemapPath(hostname, s)}`).join(""));
|
|
10908
10949
|
}
|
|
10909
|
-
function getFinalSitemapPath(hostname) {
|
|
10910
|
-
return `${
|
|
10911
|
-
}
|
|
10912
|
-
|
|
10913
|
-
function getResolvedPath(file, resolvedOptions) {
|
|
10914
|
-
if (isAbsolute(resolvedOptions.outDir))
|
|
10915
|
-
return resolve(`${resolvedOptions.outDir}/${file}`);
|
|
10916
|
-
return resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
|
|
10917
|
-
}
|
|
10918
|
-
function removeMaybeSuffix(suffix, str) {
|
|
10919
|
-
if (!str.endsWith(suffix))
|
|
10920
|
-
return str;
|
|
10921
|
-
return str.slice(0, -suffix.length);
|
|
10950
|
+
function getFinalSitemapPath(hostname, file = "/sitemap.xml") {
|
|
10951
|
+
return `${removeMaybeSuffix("/", hostname)}${ensurePrefix("/", file)}`;
|
|
10922
10952
|
}
|
|
10923
10953
|
|
|
10924
10954
|
function getRoutes(options) {
|
|
10925
10955
|
const ext = typeof options.extensions === "string" ? [options.extensions] : options.extensions;
|
|
10926
10956
|
const strExt = ext.map((e) => `**/*.${e}`);
|
|
10927
10957
|
return [
|
|
10928
|
-
...
|
|
10958
|
+
...out.sync(strExt, { cwd: options.outDir }).map((route) => {
|
|
10929
10959
|
let r = route;
|
|
10930
10960
|
ext.forEach((e) => {
|
|
10931
10961
|
const regex = new RegExp(`index.${e}`, "g");
|
|
@@ -10948,19 +10978,25 @@ function getOptionByRoute(options, route) {
|
|
|
10948
10978
|
return void 0;
|
|
10949
10979
|
}
|
|
10950
10980
|
function getFormattedSitemap(options, routes) {
|
|
10951
|
-
return routes.map((route) =>
|
|
10952
|
-
url
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
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
|
+
});
|
|
10957
10993
|
}
|
|
10958
10994
|
|
|
10959
10995
|
function generateSitemap(options = {}) {
|
|
10960
10996
|
const resolvedOptions = resolveOptions(options);
|
|
10961
10997
|
if (resolvedOptions.generateRobotsTxt) {
|
|
10962
10998
|
const robotRules = getRules(resolvedOptions.robots);
|
|
10963
|
-
const robotContent = getContent(robotRules, resolvedOptions.hostname);
|
|
10999
|
+
const robotContent = getContent(robotRules, resolvedOptions.hostname, resolvedOptions.externalSitemaps);
|
|
10964
11000
|
writeFileSync(getResolvedPath("robots.txt", resolvedOptions), robotContent);
|
|
10965
11001
|
}
|
|
10966
11002
|
const routes = getRoutes(resolvedOptions);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-sitemap",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.6.0",
|
|
5
|
+
"packageManager": "pnpm@9.1.2",
|
|
5
6
|
"description": "Sitemap generator plugin for Vite",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"module": "dist/index.mjs",
|
|
@@ -16,18 +17,21 @@
|
|
|
16
17
|
"release": "npx bumpp --commit --tag --push && npm publish",
|
|
17
18
|
"lint": "eslint .",
|
|
18
19
|
"lint:fix": "eslint --fix .",
|
|
19
|
-
"typecheck": "vue-tsc --noEmit"
|
|
20
|
+
"typecheck": "vue-tsc --noEmit",
|
|
21
|
+
"up": "taze major -r -I"
|
|
20
22
|
},
|
|
21
23
|
"devDependencies": {
|
|
22
|
-
"@antfu/eslint-config": "
|
|
23
|
-
"@types/node": "
|
|
24
|
-
"eslint": "
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
24
|
+
"@antfu/eslint-config": "^2.18.1",
|
|
25
|
+
"@types/node": "^20.12.12",
|
|
26
|
+
"eslint": "^9.3.0",
|
|
27
|
+
"eslint-plugin-format": "^0.1.1",
|
|
28
|
+
"pkgroll": "^2.1.1",
|
|
29
|
+
"pnpm": "^9.1.2",
|
|
30
|
+
"sitemap-ts": "^1.7.0",
|
|
31
|
+
"taze": "^0.13.8",
|
|
32
|
+
"typescript": "^5.4.5",
|
|
33
|
+
"vite": "^5.2.11",
|
|
34
|
+
"vite-plugin-pages": "^0.32.1",
|
|
35
|
+
"vue-tsc": "^2.0.19"
|
|
32
36
|
}
|
|
33
37
|
}
|