vite-plugin-sitemap 0.5.3 → 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 CHANGED
@@ -38,11 +38,11 @@ export default {
38
38
  Now, run `npm build` and this will generate sitemap.xml and robots.txt files on your dist folder.
39
39
 
40
40
  ### To generate all pages of your app, you can:
41
+
41
42
  - Use dynamicRoutes to send routes paths.
42
43
  - Read [`MPA docs`](https://vitejs.dev/guide/build.html#multi-page-app) from Vite documentation.
43
44
  - Use MPA with [`vite-plugin-mpa`](https://github.com/IndexXuan/vite-plugin-mpa).
44
45
 
45
-
46
46
  ## Configuration options
47
47
 
48
48
  ### hostname
@@ -58,6 +58,7 @@ Base URI.
58
58
  - **Default:** `[]`
59
59
 
60
60
  Array of strings with manual dynamic routes.
61
+
61
62
  ```js
62
63
  const names = [
63
64
  'John',
@@ -83,6 +84,7 @@ You can find a working example in example folder.
83
84
  - **Default:** `[]`
84
85
 
85
86
  Array of strings with excluded routes.
87
+
86
88
  ```js
87
89
  export default {
88
90
  plugins: [
@@ -100,6 +102,7 @@ You can find a working example in example folder.
100
102
  - **Default:** `[]`
101
103
 
102
104
  Array of strings with other sitemaps paths or urls.
105
+
103
106
  ```js
104
107
  generateSitemap({
105
108
  externalSitemaps: ['sitemap_1', 'sitemap_2', 'subpath/sitemap_3', 'https://site.com/sitemap.xml']
@@ -156,6 +159,14 @@ The (optional) route `'*'` is used as default.
156
159
 
157
160
  Converts XML into a human readable format
158
161
 
162
+ ### i18n
163
+
164
+ - **Type:** `{ defaultLanguage?: string, languages: string[] }`
165
+ - **Default:** `undefined`
166
+
167
+ Add i18n support defining alternate links.
168
+ defaultLanguage will use this language with / and languages with /language
169
+
159
170
  ### generateRobotsTxt
160
171
 
161
172
  - **Type:** `boolean`
@@ -169,6 +180,7 @@ Enables robots.txt file generation
169
180
  - **Default:** `[{ userAgent: '*', allow: '/' }]`
170
181
 
171
182
  RobotOption:
183
+
172
184
  - **userAgent**: `string`
173
185
  - **allow**?: `string | string[]`
174
186
  - **disallow**?: `string | string[]`
package/dist/index.d.ts CHANGED
@@ -49,6 +49,18 @@ interface Options {
49
49
  * @default []
50
50
  */
51
51
  exclude: string[];
52
+ /**
53
+ * Array of i18n languages.
54
+ * Example: {
55
+ * defaultLanguage: 'fr'
56
+ * languages: ['fr', 'en', 'es']
57
+ * }
58
+ * @default undefined
59
+ */
60
+ i18n?: {
61
+ defaultLanguage?: string;
62
+ languages: string[];
63
+ };
52
64
  /**
53
65
  * Other sitemaps paths
54
66
  * Example: ['sitemap_1.xml', 'path/sitemap_2.xml', 'https://site.com/sitemap.xml']
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 = '';
@@ -4223,11 +4220,11 @@ const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
4223
4220
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
4224
4221
  /**
4225
4222
  * All non-escaped special characters.
4226
- * Posix: ()*?[\]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
4227
- * Windows: (){}, !+@ before (, ! at the beginning.
4223
+ * Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
4224
+ * Windows: (){}[], !+@ before (, ! at the beginning.
4228
4225
  */
4229
4226
  const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
4230
- const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g;
4227
+ const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
4231
4228
  /**
4232
4229
  * The device path (\\.\ or \\?\).
4233
4230
  * https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
@@ -4238,7 +4235,7 @@ const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
4238
4235
  * Windows: !()+@{}
4239
4236
  * https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
4240
4237
  */
4241
- const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
4238
+ const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
4242
4239
  /**
4243
4240
  * Designed to work only with simple paths: `dir\\file`.
4244
4241
  */
@@ -4533,7 +4530,7 @@ var utils$j = {};
4533
4530
  */
4534
4531
 
4535
4532
  exports.escapeNode = (block, n = 0, type) => {
4536
- let node = block.nodes[n];
4533
+ const node = block.nodes[n];
4537
4534
  if (!node) return;
4538
4535
 
4539
4536
  if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
@@ -4602,13 +4599,23 @@ var utils$j = {};
4602
4599
 
4603
4600
  exports.flatten = (...args) => {
4604
4601
  const result = [];
4602
+
4605
4603
  const flat = arr => {
4606
4604
  for (let i = 0; i < arr.length; i++) {
4607
- let ele = arr[i];
4608
- 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
+ }
4609
4615
  }
4610
4616
  return result;
4611
4617
  };
4618
+
4612
4619
  flat(args);
4613
4620
  return result;
4614
4621
  };
@@ -4617,9 +4624,9 @@ var utils$j = {};
4617
4624
  const utils$i = utils$j;
4618
4625
 
4619
4626
  var stringify$4 = (ast, options = {}) => {
4620
- let stringify = (node, parent = {}) => {
4621
- let invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
4622
- 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;
4623
4630
  let output = '';
4624
4631
 
4625
4632
  if (node.value) {
@@ -4634,7 +4641,7 @@ var stringify$4 = (ast, options = {}) => {
4634
4641
  }
4635
4642
 
4636
4643
  if (node.nodes) {
4637
- for (let child of node.nodes) {
4644
+ for (const child of node.nodes) {
4638
4645
  output += stringify(child);
4639
4646
  }
4640
4647
  }
@@ -5008,7 +5015,7 @@ const toMaxLen = (input, maxLength) => {
5008
5015
  return negative ? ('-' + input) : input;
5009
5016
  };
5010
5017
 
5011
- const toSequence = (parts, options) => {
5018
+ const toSequence = (parts, options, maxLen) => {
5012
5019
  parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
5013
5020
  parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
5014
5021
 
@@ -5018,11 +5025,11 @@ const toSequence = (parts, options) => {
5018
5025
  let result;
5019
5026
 
5020
5027
  if (parts.positives.length) {
5021
- positives = parts.positives.join('|');
5028
+ positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
5022
5029
  }
5023
5030
 
5024
5031
  if (parts.negatives.length) {
5025
- negatives = `-(${prefix}${parts.negatives.join('|')})`;
5032
+ negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
5026
5033
  }
5027
5034
 
5028
5035
  if (positives && negatives) {
@@ -5120,7 +5127,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
5120
5127
 
5121
5128
  if (options.toRegex === true) {
5122
5129
  return step > 1
5123
- ? toSequence(parts, options)
5130
+ ? toSequence(parts, options, maxLen)
5124
5131
  : toRegex(range, null, { wrap: false, ...options });
5125
5132
  }
5126
5133
 
@@ -5132,7 +5139,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
5132
5139
  return invalidRange(start, end, options);
5133
5140
  }
5134
5141
 
5135
-
5136
5142
  let format = options.transform || (val => String.fromCharCode(val));
5137
5143
  let a = `${start}`.charCodeAt(0);
5138
5144
  let b = `${end}`.charCodeAt(0);
@@ -5200,30 +5206,32 @@ const fill$1 = fillRange;
5200
5206
  const utils$h = utils$j;
5201
5207
 
5202
5208
  const compile$1 = (ast, options = {}) => {
5203
- let walk = (node, parent = {}) => {
5204
- let invalidBlock = utils$h.isInvalidBrace(parent);
5205
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
5206
- let invalid = invalidBlock === true || invalidNode === true;
5207
- 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 ? '\\' : '';
5208
5214
  let output = '';
5209
5215
 
5210
5216
  if (node.isOpen === true) {
5211
5217
  return prefix + node.value;
5212
5218
  }
5219
+
5213
5220
  if (node.isClose === true) {
5221
+ console.log('node.isClose', prefix, node.value);
5214
5222
  return prefix + node.value;
5215
5223
  }
5216
5224
 
5217
5225
  if (node.type === 'open') {
5218
- return invalid ? (prefix + node.value) : '(';
5226
+ return invalid ? prefix + node.value : '(';
5219
5227
  }
5220
5228
 
5221
5229
  if (node.type === 'close') {
5222
- return invalid ? (prefix + node.value) : ')';
5230
+ return invalid ? prefix + node.value : ')';
5223
5231
  }
5224
5232
 
5225
5233
  if (node.type === 'comma') {
5226
- return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
5234
+ return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
5227
5235
  }
5228
5236
 
5229
5237
  if (node.value) {
@@ -5231,8 +5239,8 @@ const compile$1 = (ast, options = {}) => {
5231
5239
  }
5232
5240
 
5233
5241
  if (node.nodes && node.ranges > 0) {
5234
- let args = utils$h.reduce(node.nodes);
5235
- 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 });
5236
5244
 
5237
5245
  if (range.length !== 0) {
5238
5246
  return args.length > 1 && range.length > 1 ? `(${range})` : range;
@@ -5240,10 +5248,11 @@ const compile$1 = (ast, options = {}) => {
5240
5248
  }
5241
5249
 
5242
5250
  if (node.nodes) {
5243
- for (let child of node.nodes) {
5251
+ for (const child of node.nodes) {
5244
5252
  output += walk(child, node);
5245
5253
  }
5246
5254
  }
5255
+
5247
5256
  return output;
5248
5257
  };
5249
5258
 
@@ -5257,7 +5266,7 @@ const stringify$2 = stringify$4;
5257
5266
  const utils$g = utils$j;
5258
5267
 
5259
5268
  const append = (queue = '', stash = '', enclose = false) => {
5260
- let result = [];
5269
+ const result = [];
5261
5270
 
5262
5271
  queue = [].concat(queue);
5263
5272
  stash = [].concat(stash);
@@ -5267,15 +5276,15 @@ const append = (queue = '', stash = '', enclose = false) => {
5267
5276
  return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
5268
5277
  }
5269
5278
 
5270
- for (let item of queue) {
5279
+ for (const item of queue) {
5271
5280
  if (Array.isArray(item)) {
5272
- for (let value of item) {
5281
+ for (const value of item) {
5273
5282
  result.push(append(value, stash, enclose));
5274
5283
  }
5275
5284
  } else {
5276
5285
  for (let ele of stash) {
5277
5286
  if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
5278
- result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
5287
+ result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
5279
5288
  }
5280
5289
  }
5281
5290
  }
@@ -5283,9 +5292,9 @@ const append = (queue = '', stash = '', enclose = false) => {
5283
5292
  };
5284
5293
 
5285
5294
  const expand$1 = (ast, options = {}) => {
5286
- let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
5295
+ const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
5287
5296
 
5288
- let walk = (node, parent = {}) => {
5297
+ const walk = (node, parent = {}) => {
5289
5298
  node.queue = [];
5290
5299
 
5291
5300
  let p = parent;
@@ -5307,7 +5316,7 @@ const expand$1 = (ast, options = {}) => {
5307
5316
  }
5308
5317
 
5309
5318
  if (node.nodes && node.ranges > 0) {
5310
- let args = utils$g.reduce(node.nodes);
5319
+ const args = utils$g.reduce(node.nodes);
5311
5320
 
5312
5321
  if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
5313
5322
  throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
@@ -5323,7 +5332,7 @@ const expand$1 = (ast, options = {}) => {
5323
5332
  return;
5324
5333
  }
5325
5334
 
5326
- let enclose = utils$g.encloseBrace(node);
5335
+ const enclose = utils$g.encloseBrace(node);
5327
5336
  let queue = node.queue;
5328
5337
  let block = node;
5329
5338
 
@@ -5333,7 +5342,7 @@ const expand$1 = (ast, options = {}) => {
5333
5342
  }
5334
5343
 
5335
5344
  for (let i = 0; i < node.nodes.length; i++) {
5336
- let child = node.nodes[i];
5345
+ const child = node.nodes[i];
5337
5346
 
5338
5347
  if (child.type === 'comma' && node.type === 'brace') {
5339
5348
  if (i === 1) queue.push('');
@@ -5365,7 +5374,7 @@ const expand$1 = (ast, options = {}) => {
5365
5374
  var expand_1 = expand$1;
5366
5375
 
5367
5376
  var constants$4 = {
5368
- MAX_LENGTH: 1024 * 64,
5377
+ MAX_LENGTH: 10000,
5369
5378
 
5370
5379
  // Digits
5371
5380
  CHAR_0: '0', /* 0 */
@@ -5453,18 +5462,18 @@ const parse$3 = (input, options = {}) => {
5453
5462
  throw new TypeError('Expected a string');
5454
5463
  }
5455
5464
 
5456
- let opts = options || {};
5457
- 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;
5458
5467
  if (input.length > max) {
5459
5468
  throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
5460
5469
  }
5461
5470
 
5462
- let ast = { type: 'root', input, nodes: [] };
5463
- let stack = [ast];
5471
+ const ast = { type: 'root', input, nodes: [] };
5472
+ const stack = [ast];
5464
5473
  let block = ast;
5465
5474
  let prev = ast;
5466
5475
  let brackets = 0;
5467
- let length = input.length;
5476
+ const length = input.length;
5468
5477
  let index = 0;
5469
5478
  let depth = 0;
5470
5479
  let value;
@@ -5529,6 +5538,7 @@ const parse$3 = (input, options = {}) => {
5529
5538
 
5530
5539
  if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
5531
5540
  brackets++;
5541
+
5532
5542
  let next;
5533
5543
 
5534
5544
  while (index < length && (next = advance())) {
@@ -5584,7 +5594,7 @@ const parse$3 = (input, options = {}) => {
5584
5594
  */
5585
5595
 
5586
5596
  if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
5587
- let open = value;
5597
+ const open = value;
5588
5598
  let next;
5589
5599
 
5590
5600
  if (options.keepQuotes !== true) {
@@ -5616,8 +5626,8 @@ const parse$3 = (input, options = {}) => {
5616
5626
  if (value === CHAR_LEFT_CURLY_BRACE$1) {
5617
5627
  depth++;
5618
5628
 
5619
- let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
5620
- let brace = {
5629
+ const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
5630
+ const brace = {
5621
5631
  type: 'brace',
5622
5632
  open: true,
5623
5633
  close: false,
@@ -5644,7 +5654,7 @@ const parse$3 = (input, options = {}) => {
5644
5654
  continue;
5645
5655
  }
5646
5656
 
5647
- let type = 'close';
5657
+ const type = 'close';
5648
5658
  block = stack.pop();
5649
5659
  block.close = true;
5650
5660
 
@@ -5662,7 +5672,7 @@ const parse$3 = (input, options = {}) => {
5662
5672
  if (value === CHAR_COMMA$1 && depth > 0) {
5663
5673
  if (block.ranges > 0) {
5664
5674
  block.ranges = 0;
5665
- let open = block.nodes.shift();
5675
+ const open = block.nodes.shift();
5666
5676
  block.nodes = [open, { type: 'text', value: stringify$1(block) }];
5667
5677
  }
5668
5678
 
@@ -5676,7 +5686,7 @@ const parse$3 = (input, options = {}) => {
5676
5686
  */
5677
5687
 
5678
5688
  if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
5679
- let siblings = block.nodes;
5689
+ const siblings = block.nodes;
5680
5690
 
5681
5691
  if (depth === 0 || siblings.length === 0) {
5682
5692
  push({ type: 'text', value });
@@ -5703,7 +5713,7 @@ const parse$3 = (input, options = {}) => {
5703
5713
  if (prev.type === 'range') {
5704
5714
  siblings.pop();
5705
5715
 
5706
- let before = siblings[siblings.length - 1];
5716
+ const before = siblings[siblings.length - 1];
5707
5717
  before.value += prev.value + value;
5708
5718
  prev = before;
5709
5719
  block.ranges--;
@@ -5736,8 +5746,8 @@ const parse$3 = (input, options = {}) => {
5736
5746
  });
5737
5747
 
5738
5748
  // get the location of the block on parent.nodes (block's siblings)
5739
- let parent = stack[stack.length - 1];
5740
- let index = parent.nodes.indexOf(block);
5749
+ const parent = stack[stack.length - 1];
5750
+ const index = parent.nodes.indexOf(block);
5741
5751
  // replace the (invalid) block with it's nodes
5742
5752
  parent.nodes.splice(index, 1, ...block.nodes);
5743
5753
  }
@@ -5772,8 +5782,8 @@ const braces$1 = (input, options = {}) => {
5772
5782
  let output = [];
5773
5783
 
5774
5784
  if (Array.isArray(input)) {
5775
- for (let pattern of input) {
5776
- let result = braces$1.create(pattern, options);
5785
+ for (const pattern of input) {
5786
+ const result = braces$1.create(pattern, options);
5777
5787
  if (Array.isArray(result)) {
5778
5788
  output.push(...result);
5779
5789
  } else {
@@ -5907,7 +5917,7 @@ braces$1.create = (input, options = {}) => {
5907
5917
  return [input];
5908
5918
  }
5909
5919
 
5910
- return options.expand !== true
5920
+ return options.expand !== true
5911
5921
  ? braces$1.compile(input, options)
5912
5922
  : braces$1.expand(input, options);
5913
5923
  };
@@ -8588,7 +8598,7 @@ function expandPatternsWithBraceExpansion(patterns) {
8588
8598
  }
8589
8599
  pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
8590
8600
  function expandBraceExpansion(pattern) {
8591
- const patterns = micromatch.braces(pattern, { expand: true, nodupes: true });
8601
+ const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true });
8592
8602
  /**
8593
8603
  * Sort the patterns by length so that the same depth patterns are processed side by side.
8594
8604
  * `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
@@ -9487,15 +9497,15 @@ var reusify_1 = reusify$1;
9487
9497
 
9488
9498
  var reusify = reusify_1;
9489
9499
 
9490
- function fastqueue (context, worker, concurrency) {
9500
+ function fastqueue (context, worker, _concurrency) {
9491
9501
  if (typeof context === 'function') {
9492
- concurrency = worker;
9502
+ _concurrency = worker;
9493
9503
  worker = context;
9494
9504
  context = null;
9495
9505
  }
9496
9506
 
9497
- if (concurrency < 1) {
9498
- 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')
9499
9509
  }
9500
9510
 
9501
9511
  var cache = reusify(Task);
@@ -9510,7 +9520,23 @@ function fastqueue (context, worker, concurrency) {
9510
9520
  saturated: noop,
9511
9521
  pause: pause,
9512
9522
  paused: false,
9513
- 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
+
9514
9540
  running: running,
9515
9541
  resume: resume,
9516
9542
  idle: idle,
@@ -9560,7 +9586,12 @@ function fastqueue (context, worker, concurrency) {
9560
9586
  function resume () {
9561
9587
  if (!self.paused) return
9562
9588
  self.paused = false;
9563
- for (var i = 0; i < self.concurrency; i++) {
9589
+ if (queueHead === null) {
9590
+ _running++;
9591
+ release();
9592
+ return
9593
+ }
9594
+ for (; queueHead && _running < _concurrency;) {
9564
9595
  _running++;
9565
9596
  release();
9566
9597
  }
@@ -9579,7 +9610,7 @@ function fastqueue (context, worker, concurrency) {
9579
9610
  current.callback = done || noop;
9580
9611
  current.errorHandler = errorHandler;
9581
9612
 
9582
- if (_running === self.concurrency || self.paused) {
9613
+ if (_running >= _concurrency || self.paused) {
9583
9614
  if (queueTail) {
9584
9615
  queueTail.next = current;
9585
9616
  queueTail = current;
@@ -9601,8 +9632,9 @@ function fastqueue (context, worker, concurrency) {
9601
9632
  current.release = release;
9602
9633
  current.value = value;
9603
9634
  current.callback = done || noop;
9635
+ current.errorHandler = errorHandler;
9604
9636
 
9605
- if (_running === self.concurrency || self.paused) {
9637
+ if (_running >= _concurrency || self.paused) {
9606
9638
  if (queueHead) {
9607
9639
  current.next = queueHead;
9608
9640
  queueHead = current;
@@ -9622,7 +9654,7 @@ function fastqueue (context, worker, concurrency) {
9622
9654
  cache.release(holder);
9623
9655
  }
9624
9656
  var next = queueHead;
9625
- if (next) {
9657
+ if (next && _running <= _concurrency) {
9626
9658
  if (!self.paused) {
9627
9659
  if (queueTail === queueHead) {
9628
9660
  queueTail = null;
@@ -9685,9 +9717,9 @@ function Task () {
9685
9717
  };
9686
9718
  }
9687
9719
 
9688
- function queueAsPromised (context, worker, concurrency) {
9720
+ function queueAsPromised (context, worker, _concurrency) {
9689
9721
  if (typeof context === 'function') {
9690
- concurrency = worker;
9722
+ _concurrency = worker;
9691
9723
  worker = context;
9692
9724
  context = null;
9693
9725
  }
@@ -9699,7 +9731,7 @@ function queueAsPromised (context, worker, concurrency) {
9699
9731
  }, cb);
9700
9732
  }
9701
9733
 
9702
- var queue = fastqueue(context, asyncWrapper, concurrency);
9734
+ var queue = fastqueue(context, asyncWrapper, _concurrency);
9703
9735
 
9704
9736
  var pushCb = queue.push;
9705
9737
  var unshiftCb = queue.unshift;
@@ -10848,8 +10880,6 @@ function assertPatternsInput(input) {
10848
10880
  }
10849
10881
  var out = FastGlob;
10850
10882
 
10851
- var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
10852
-
10853
10883
  const defaultOptions = {
10854
10884
  hostname: "http://localhost/",
10855
10885
  dynamicRoutes: [],
@@ -10877,9 +10907,9 @@ function resolveOptions(userOptions) {
10877
10907
  }
10878
10908
 
10879
10909
  function getResolvedPath(file, resolvedOptions) {
10880
- if (node_path.isAbsolute(resolvedOptions.outDir))
10881
- return node_path.resolve(`${resolvedOptions.outDir}/${file}`);
10882
- return node_path.resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
10910
+ if (isAbsolute(resolvedOptions.outDir))
10911
+ return resolve(`${resolvedOptions.outDir}/${file}`);
10912
+ return resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
10883
10913
  }
10884
10914
  function removeMaybeSuffix(suffix, str) {
10885
10915
  if (!str.endsWith(suffix))
@@ -10925,16 +10955,16 @@ 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
- ...fg.sync(strExt, { cwd: options.outDir }).map((route) => {
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");
10932
10962
  r = r.replace(regex, "");
10933
10963
  });
10934
- const parsedRoute = node_path.parse(r);
10935
- 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));
10936
10966
  }),
10937
- ...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))))
10938
10968
  ].filter((route) => !options.exclude.includes(route));
10939
10969
  }
10940
10970
  function getOptionByRoute(options, route) {
@@ -10948,12 +10978,18 @@ function getOptionByRoute(options, route) {
10948
10978
  return void 0;
10949
10979
  }
10950
10980
  function getFormattedSitemap(options, routes) {
10951
- return routes.map((route) => ({
10952
- url: new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href,
10953
- changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
10954
- priority: getOptionByRoute(options.priority, route) ?? defaultOptions.priority,
10955
- lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
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 = {}) {
@@ -10961,7 +10997,7 @@ function generateSitemap(options = {}) {
10961
10997
  if (resolvedOptions.generateRobotsTxt) {
10962
10998
  const robotRules = getRules(resolvedOptions.robots);
10963
10999
  const robotContent = getContent(robotRules, resolvedOptions.hostname, resolvedOptions.externalSitemaps);
10964
- node_fs.writeFileSync(getResolvedPath("robots.txt", resolvedOptions), robotContent);
11000
+ writeFileSync(getResolvedPath("robots.txt", resolvedOptions), robotContent);
10965
11001
  }
10966
11002
  const routes = getRoutes(resolvedOptions);
10967
11003
  if (!routes.length)
@@ -10972,7 +11008,7 @@ function generateSitemap(options = {}) {
10972
11008
  distExports.streamToPromise(stream).then((sitemap) => {
10973
11009
  const utfSitemap = sitemap.toString("utf-8");
10974
11010
  const formattedSitemap2 = resolvedOptions.readable ? format(utfSitemap) : utfSitemap;
10975
- node_fs.writeFileSync(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
11011
+ writeFileSync(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
10976
11012
  });
10977
11013
  stream.end();
10978
11014
  }
@@ -11000,4 +11036,4 @@ function sitemapPlugin(options = {}) {
11000
11036
  };
11001
11037
  }
11002
11038
 
11003
- module.exports = sitemapPlugin;
11039
+ export { sitemapPlugin as default };
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 = '';
@@ -4220,11 +4220,11 @@ const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
4220
4220
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
4221
4221
  /**
4222
4222
  * All non-escaped special characters.
4223
- * Posix: ()*?[\]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
4224
- * Windows: (){}, !+@ before (, ! at the beginning.
4223
+ * Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
4224
+ * Windows: (){}[], !+@ before (, ! at the beginning.
4225
4225
  */
4226
4226
  const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
4227
- const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g;
4227
+ const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
4228
4228
  /**
4229
4229
  * The device path (\\.\ or \\?\).
4230
4230
  * https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
@@ -4235,7 +4235,7 @@ const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
4235
4235
  * Windows: !()+@{}
4236
4236
  * https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
4237
4237
  */
4238
- const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
4238
+ const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
4239
4239
  /**
4240
4240
  * Designed to work only with simple paths: `dir\\file`.
4241
4241
  */
@@ -4530,7 +4530,7 @@ var utils$j = {};
4530
4530
  */
4531
4531
 
4532
4532
  exports.escapeNode = (block, n = 0, type) => {
4533
- let node = block.nodes[n];
4533
+ const node = block.nodes[n];
4534
4534
  if (!node) return;
4535
4535
 
4536
4536
  if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
@@ -4599,13 +4599,23 @@ var utils$j = {};
4599
4599
 
4600
4600
  exports.flatten = (...args) => {
4601
4601
  const result = [];
4602
+
4602
4603
  const flat = arr => {
4603
4604
  for (let i = 0; i < arr.length; i++) {
4604
- let ele = arr[i];
4605
- 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
+ }
4606
4615
  }
4607
4616
  return result;
4608
4617
  };
4618
+
4609
4619
  flat(args);
4610
4620
  return result;
4611
4621
  };
@@ -4614,9 +4624,9 @@ var utils$j = {};
4614
4624
  const utils$i = utils$j;
4615
4625
 
4616
4626
  var stringify$4 = (ast, options = {}) => {
4617
- let stringify = (node, parent = {}) => {
4618
- let invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
4619
- 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;
4620
4630
  let output = '';
4621
4631
 
4622
4632
  if (node.value) {
@@ -4631,7 +4641,7 @@ var stringify$4 = (ast, options = {}) => {
4631
4641
  }
4632
4642
 
4633
4643
  if (node.nodes) {
4634
- for (let child of node.nodes) {
4644
+ for (const child of node.nodes) {
4635
4645
  output += stringify(child);
4636
4646
  }
4637
4647
  }
@@ -5005,7 +5015,7 @@ const toMaxLen = (input, maxLength) => {
5005
5015
  return negative ? ('-' + input) : input;
5006
5016
  };
5007
5017
 
5008
- const toSequence = (parts, options) => {
5018
+ const toSequence = (parts, options, maxLen) => {
5009
5019
  parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
5010
5020
  parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
5011
5021
 
@@ -5015,11 +5025,11 @@ const toSequence = (parts, options) => {
5015
5025
  let result;
5016
5026
 
5017
5027
  if (parts.positives.length) {
5018
- positives = parts.positives.join('|');
5028
+ positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
5019
5029
  }
5020
5030
 
5021
5031
  if (parts.negatives.length) {
5022
- negatives = `-(${prefix}${parts.negatives.join('|')})`;
5032
+ negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
5023
5033
  }
5024
5034
 
5025
5035
  if (positives && negatives) {
@@ -5117,7 +5127,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
5117
5127
 
5118
5128
  if (options.toRegex === true) {
5119
5129
  return step > 1
5120
- ? toSequence(parts, options)
5130
+ ? toSequence(parts, options, maxLen)
5121
5131
  : toRegex(range, null, { wrap: false, ...options });
5122
5132
  }
5123
5133
 
@@ -5129,7 +5139,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
5129
5139
  return invalidRange(start, end, options);
5130
5140
  }
5131
5141
 
5132
-
5133
5142
  let format = options.transform || (val => String.fromCharCode(val));
5134
5143
  let a = `${start}`.charCodeAt(0);
5135
5144
  let b = `${end}`.charCodeAt(0);
@@ -5197,30 +5206,32 @@ const fill$1 = fillRange;
5197
5206
  const utils$h = utils$j;
5198
5207
 
5199
5208
  const compile$1 = (ast, options = {}) => {
5200
- let walk = (node, parent = {}) => {
5201
- let invalidBlock = utils$h.isInvalidBrace(parent);
5202
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
5203
- let invalid = invalidBlock === true || invalidNode === true;
5204
- 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 ? '\\' : '';
5205
5214
  let output = '';
5206
5215
 
5207
5216
  if (node.isOpen === true) {
5208
5217
  return prefix + node.value;
5209
5218
  }
5219
+
5210
5220
  if (node.isClose === true) {
5221
+ console.log('node.isClose', prefix, node.value);
5211
5222
  return prefix + node.value;
5212
5223
  }
5213
5224
 
5214
5225
  if (node.type === 'open') {
5215
- return invalid ? (prefix + node.value) : '(';
5226
+ return invalid ? prefix + node.value : '(';
5216
5227
  }
5217
5228
 
5218
5229
  if (node.type === 'close') {
5219
- return invalid ? (prefix + node.value) : ')';
5230
+ return invalid ? prefix + node.value : ')';
5220
5231
  }
5221
5232
 
5222
5233
  if (node.type === 'comma') {
5223
- return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
5234
+ return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
5224
5235
  }
5225
5236
 
5226
5237
  if (node.value) {
@@ -5228,8 +5239,8 @@ const compile$1 = (ast, options = {}) => {
5228
5239
  }
5229
5240
 
5230
5241
  if (node.nodes && node.ranges > 0) {
5231
- let args = utils$h.reduce(node.nodes);
5232
- 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 });
5233
5244
 
5234
5245
  if (range.length !== 0) {
5235
5246
  return args.length > 1 && range.length > 1 ? `(${range})` : range;
@@ -5237,10 +5248,11 @@ const compile$1 = (ast, options = {}) => {
5237
5248
  }
5238
5249
 
5239
5250
  if (node.nodes) {
5240
- for (let child of node.nodes) {
5251
+ for (const child of node.nodes) {
5241
5252
  output += walk(child, node);
5242
5253
  }
5243
5254
  }
5255
+
5244
5256
  return output;
5245
5257
  };
5246
5258
 
@@ -5254,7 +5266,7 @@ const stringify$2 = stringify$4;
5254
5266
  const utils$g = utils$j;
5255
5267
 
5256
5268
  const append = (queue = '', stash = '', enclose = false) => {
5257
- let result = [];
5269
+ const result = [];
5258
5270
 
5259
5271
  queue = [].concat(queue);
5260
5272
  stash = [].concat(stash);
@@ -5264,15 +5276,15 @@ const append = (queue = '', stash = '', enclose = false) => {
5264
5276
  return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
5265
5277
  }
5266
5278
 
5267
- for (let item of queue) {
5279
+ for (const item of queue) {
5268
5280
  if (Array.isArray(item)) {
5269
- for (let value of item) {
5281
+ for (const value of item) {
5270
5282
  result.push(append(value, stash, enclose));
5271
5283
  }
5272
5284
  } else {
5273
5285
  for (let ele of stash) {
5274
5286
  if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
5275
- result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
5287
+ result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
5276
5288
  }
5277
5289
  }
5278
5290
  }
@@ -5280,9 +5292,9 @@ const append = (queue = '', stash = '', enclose = false) => {
5280
5292
  };
5281
5293
 
5282
5294
  const expand$1 = (ast, options = {}) => {
5283
- let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
5295
+ const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
5284
5296
 
5285
- let walk = (node, parent = {}) => {
5297
+ const walk = (node, parent = {}) => {
5286
5298
  node.queue = [];
5287
5299
 
5288
5300
  let p = parent;
@@ -5304,7 +5316,7 @@ const expand$1 = (ast, options = {}) => {
5304
5316
  }
5305
5317
 
5306
5318
  if (node.nodes && node.ranges > 0) {
5307
- let args = utils$g.reduce(node.nodes);
5319
+ const args = utils$g.reduce(node.nodes);
5308
5320
 
5309
5321
  if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
5310
5322
  throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
@@ -5320,7 +5332,7 @@ const expand$1 = (ast, options = {}) => {
5320
5332
  return;
5321
5333
  }
5322
5334
 
5323
- let enclose = utils$g.encloseBrace(node);
5335
+ const enclose = utils$g.encloseBrace(node);
5324
5336
  let queue = node.queue;
5325
5337
  let block = node;
5326
5338
 
@@ -5330,7 +5342,7 @@ const expand$1 = (ast, options = {}) => {
5330
5342
  }
5331
5343
 
5332
5344
  for (let i = 0; i < node.nodes.length; i++) {
5333
- let child = node.nodes[i];
5345
+ const child = node.nodes[i];
5334
5346
 
5335
5347
  if (child.type === 'comma' && node.type === 'brace') {
5336
5348
  if (i === 1) queue.push('');
@@ -5362,7 +5374,7 @@ const expand$1 = (ast, options = {}) => {
5362
5374
  var expand_1 = expand$1;
5363
5375
 
5364
5376
  var constants$4 = {
5365
- MAX_LENGTH: 1024 * 64,
5377
+ MAX_LENGTH: 10000,
5366
5378
 
5367
5379
  // Digits
5368
5380
  CHAR_0: '0', /* 0 */
@@ -5450,18 +5462,18 @@ const parse$3 = (input, options = {}) => {
5450
5462
  throw new TypeError('Expected a string');
5451
5463
  }
5452
5464
 
5453
- let opts = options || {};
5454
- 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;
5455
5467
  if (input.length > max) {
5456
5468
  throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
5457
5469
  }
5458
5470
 
5459
- let ast = { type: 'root', input, nodes: [] };
5460
- let stack = [ast];
5471
+ const ast = { type: 'root', input, nodes: [] };
5472
+ const stack = [ast];
5461
5473
  let block = ast;
5462
5474
  let prev = ast;
5463
5475
  let brackets = 0;
5464
- let length = input.length;
5476
+ const length = input.length;
5465
5477
  let index = 0;
5466
5478
  let depth = 0;
5467
5479
  let value;
@@ -5526,6 +5538,7 @@ const parse$3 = (input, options = {}) => {
5526
5538
 
5527
5539
  if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
5528
5540
  brackets++;
5541
+
5529
5542
  let next;
5530
5543
 
5531
5544
  while (index < length && (next = advance())) {
@@ -5581,7 +5594,7 @@ const parse$3 = (input, options = {}) => {
5581
5594
  */
5582
5595
 
5583
5596
  if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
5584
- let open = value;
5597
+ const open = value;
5585
5598
  let next;
5586
5599
 
5587
5600
  if (options.keepQuotes !== true) {
@@ -5613,8 +5626,8 @@ const parse$3 = (input, options = {}) => {
5613
5626
  if (value === CHAR_LEFT_CURLY_BRACE$1) {
5614
5627
  depth++;
5615
5628
 
5616
- let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
5617
- let brace = {
5629
+ const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
5630
+ const brace = {
5618
5631
  type: 'brace',
5619
5632
  open: true,
5620
5633
  close: false,
@@ -5641,7 +5654,7 @@ const parse$3 = (input, options = {}) => {
5641
5654
  continue;
5642
5655
  }
5643
5656
 
5644
- let type = 'close';
5657
+ const type = 'close';
5645
5658
  block = stack.pop();
5646
5659
  block.close = true;
5647
5660
 
@@ -5659,7 +5672,7 @@ const parse$3 = (input, options = {}) => {
5659
5672
  if (value === CHAR_COMMA$1 && depth > 0) {
5660
5673
  if (block.ranges > 0) {
5661
5674
  block.ranges = 0;
5662
- let open = block.nodes.shift();
5675
+ const open = block.nodes.shift();
5663
5676
  block.nodes = [open, { type: 'text', value: stringify$1(block) }];
5664
5677
  }
5665
5678
 
@@ -5673,7 +5686,7 @@ const parse$3 = (input, options = {}) => {
5673
5686
  */
5674
5687
 
5675
5688
  if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
5676
- let siblings = block.nodes;
5689
+ const siblings = block.nodes;
5677
5690
 
5678
5691
  if (depth === 0 || siblings.length === 0) {
5679
5692
  push({ type: 'text', value });
@@ -5700,7 +5713,7 @@ const parse$3 = (input, options = {}) => {
5700
5713
  if (prev.type === 'range') {
5701
5714
  siblings.pop();
5702
5715
 
5703
- let before = siblings[siblings.length - 1];
5716
+ const before = siblings[siblings.length - 1];
5704
5717
  before.value += prev.value + value;
5705
5718
  prev = before;
5706
5719
  block.ranges--;
@@ -5733,8 +5746,8 @@ const parse$3 = (input, options = {}) => {
5733
5746
  });
5734
5747
 
5735
5748
  // get the location of the block on parent.nodes (block's siblings)
5736
- let parent = stack[stack.length - 1];
5737
- let index = parent.nodes.indexOf(block);
5749
+ const parent = stack[stack.length - 1];
5750
+ const index = parent.nodes.indexOf(block);
5738
5751
  // replace the (invalid) block with it's nodes
5739
5752
  parent.nodes.splice(index, 1, ...block.nodes);
5740
5753
  }
@@ -5769,8 +5782,8 @@ const braces$1 = (input, options = {}) => {
5769
5782
  let output = [];
5770
5783
 
5771
5784
  if (Array.isArray(input)) {
5772
- for (let pattern of input) {
5773
- let result = braces$1.create(pattern, options);
5785
+ for (const pattern of input) {
5786
+ const result = braces$1.create(pattern, options);
5774
5787
  if (Array.isArray(result)) {
5775
5788
  output.push(...result);
5776
5789
  } else {
@@ -5904,7 +5917,7 @@ braces$1.create = (input, options = {}) => {
5904
5917
  return [input];
5905
5918
  }
5906
5919
 
5907
- return options.expand !== true
5920
+ return options.expand !== true
5908
5921
  ? braces$1.compile(input, options)
5909
5922
  : braces$1.expand(input, options);
5910
5923
  };
@@ -8585,7 +8598,7 @@ function expandPatternsWithBraceExpansion(patterns) {
8585
8598
  }
8586
8599
  pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
8587
8600
  function expandBraceExpansion(pattern) {
8588
- const patterns = micromatch.braces(pattern, { expand: true, nodupes: true });
8601
+ const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true });
8589
8602
  /**
8590
8603
  * Sort the patterns by length so that the same depth patterns are processed side by side.
8591
8604
  * `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
@@ -9484,15 +9497,15 @@ var reusify_1 = reusify$1;
9484
9497
 
9485
9498
  var reusify = reusify_1;
9486
9499
 
9487
- function fastqueue (context, worker, concurrency) {
9500
+ function fastqueue (context, worker, _concurrency) {
9488
9501
  if (typeof context === 'function') {
9489
- concurrency = worker;
9502
+ _concurrency = worker;
9490
9503
  worker = context;
9491
9504
  context = null;
9492
9505
  }
9493
9506
 
9494
- if (concurrency < 1) {
9495
- 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')
9496
9509
  }
9497
9510
 
9498
9511
  var cache = reusify(Task);
@@ -9507,7 +9520,23 @@ function fastqueue (context, worker, concurrency) {
9507
9520
  saturated: noop,
9508
9521
  pause: pause,
9509
9522
  paused: false,
9510
- 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
+
9511
9540
  running: running,
9512
9541
  resume: resume,
9513
9542
  idle: idle,
@@ -9557,7 +9586,12 @@ function fastqueue (context, worker, concurrency) {
9557
9586
  function resume () {
9558
9587
  if (!self.paused) return
9559
9588
  self.paused = false;
9560
- for (var i = 0; i < self.concurrency; i++) {
9589
+ if (queueHead === null) {
9590
+ _running++;
9591
+ release();
9592
+ return
9593
+ }
9594
+ for (; queueHead && _running < _concurrency;) {
9561
9595
  _running++;
9562
9596
  release();
9563
9597
  }
@@ -9576,7 +9610,7 @@ function fastqueue (context, worker, concurrency) {
9576
9610
  current.callback = done || noop;
9577
9611
  current.errorHandler = errorHandler;
9578
9612
 
9579
- if (_running === self.concurrency || self.paused) {
9613
+ if (_running >= _concurrency || self.paused) {
9580
9614
  if (queueTail) {
9581
9615
  queueTail.next = current;
9582
9616
  queueTail = current;
@@ -9598,8 +9632,9 @@ function fastqueue (context, worker, concurrency) {
9598
9632
  current.release = release;
9599
9633
  current.value = value;
9600
9634
  current.callback = done || noop;
9635
+ current.errorHandler = errorHandler;
9601
9636
 
9602
- if (_running === self.concurrency || self.paused) {
9637
+ if (_running >= _concurrency || self.paused) {
9603
9638
  if (queueHead) {
9604
9639
  current.next = queueHead;
9605
9640
  queueHead = current;
@@ -9619,7 +9654,7 @@ function fastqueue (context, worker, concurrency) {
9619
9654
  cache.release(holder);
9620
9655
  }
9621
9656
  var next = queueHead;
9622
- if (next) {
9657
+ if (next && _running <= _concurrency) {
9623
9658
  if (!self.paused) {
9624
9659
  if (queueTail === queueHead) {
9625
9660
  queueTail = null;
@@ -9682,9 +9717,9 @@ function Task () {
9682
9717
  };
9683
9718
  }
9684
9719
 
9685
- function queueAsPromised (context, worker, concurrency) {
9720
+ function queueAsPromised (context, worker, _concurrency) {
9686
9721
  if (typeof context === 'function') {
9687
- concurrency = worker;
9722
+ _concurrency = worker;
9688
9723
  worker = context;
9689
9724
  context = null;
9690
9725
  }
@@ -9696,7 +9731,7 @@ function queueAsPromised (context, worker, concurrency) {
9696
9731
  }, cb);
9697
9732
  }
9698
9733
 
9699
- var queue = fastqueue(context, asyncWrapper, concurrency);
9734
+ var queue = fastqueue(context, asyncWrapper, _concurrency);
9700
9735
 
9701
9736
  var pushCb = queue.push;
9702
9737
  var unshiftCb = queue.unshift;
@@ -10845,8 +10880,6 @@ function assertPatternsInput(input) {
10845
10880
  }
10846
10881
  var out = FastGlob;
10847
10882
 
10848
- var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
10849
-
10850
10883
  const defaultOptions = {
10851
10884
  hostname: "http://localhost/",
10852
10885
  dynamicRoutes: [],
@@ -10922,7 +10955,7 @@ function getRoutes(options) {
10922
10955
  const ext = typeof options.extensions === "string" ? [options.extensions] : options.extensions;
10923
10956
  const strExt = ext.map((e) => `**/*.${e}`);
10924
10957
  return [
10925
- ...fg.sync(strExt, { cwd: options.outDir }).map((route) => {
10958
+ ...out.sync(strExt, { cwd: options.outDir }).map((route) => {
10926
10959
  let r = route;
10927
10960
  ext.forEach((e) => {
10928
10961
  const regex = new RegExp(`index.${e}`, "g");
@@ -10945,12 +10978,18 @@ function getOptionByRoute(options, route) {
10945
10978
  return void 0;
10946
10979
  }
10947
10980
  function getFormattedSitemap(options, routes) {
10948
- return routes.map((route) => ({
10949
- url: new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href,
10950
- changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
10951
- priority: getOptionByRoute(options.priority, route) ?? defaultOptions.priority,
10952
- lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
10953
- }));
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
+ });
10954
10993
  }
10955
10994
 
10956
10995
  function generateSitemap(options = {}) {
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "vite-plugin-sitemap",
3
- "version": "0.5.3",
4
- "packageManager": "pnpm@8.9.2",
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": "0.43.1",
23
- "@types/node": "18.18.6",
24
- "eslint": "8.51.0",
25
- "pkgroll": "2.0.1",
26
- "pnpm": "8.9.2",
27
- "sitemap-ts": "1.6.1",
28
- "typescript": "5.2.2",
29
- "vite": "4.5.0",
30
- "vite-plugin-pages": "0.31.0",
31
- "vue-tsc": "1.8.19"
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
  }