vite-plugin-sitemap 0.5.3 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +456 -295
- package/dist/index.mjs +431 -267
- package/package.json +17 -13
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import require$$0$2 from 'path';
|
|
|
7
7
|
import require$$1 from 'child_process';
|
|
8
8
|
import { createRequire } from 'module';
|
|
9
9
|
import require$$1$1 from 'string_decoder';
|
|
10
|
-
import require$$1
|
|
10
|
+
import require$$3$1 from 'zlib';
|
|
11
11
|
import require$$0$3 from 'util';
|
|
12
12
|
import { isAbsolute, resolve, parse as parse$4, join } from 'node:path';
|
|
13
13
|
import require$$0$4 from 'os';
|
|
@@ -1083,8 +1083,12 @@ utils$l.normalizeURL = normalizeURL;
|
|
|
1083
1083
|
this.hasHeadOutput = true;
|
|
1084
1084
|
this.push(getURLSetNs(this.xmlNS, this.xslUrl));
|
|
1085
1085
|
}
|
|
1086
|
-
this.smiStream.write((0, utils_1.validateSMIOptions)((0, utils_1.normalizeURL)(item, this.hostname, this.lastmodDateOnly), this.level, this.errorHandler))
|
|
1087
|
-
|
|
1086
|
+
if (!this.smiStream.write((0, utils_1.validateSMIOptions)((0, utils_1.normalizeURL)(item, this.hostname, this.lastmodDateOnly), this.level, this.errorHandler))) {
|
|
1087
|
+
this.smiStream.once('drain', callback);
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
process.nextTick(callback);
|
|
1091
|
+
}
|
|
1088
1092
|
}
|
|
1089
1093
|
_flush(cb) {
|
|
1090
1094
|
if (!this.hasHeadOutput) {
|
|
@@ -1098,19 +1102,31 @@ utils$l.normalizeURL = normalizeURL;
|
|
|
1098
1102
|
}
|
|
1099
1103
|
exports.SitemapStream = SitemapStream;
|
|
1100
1104
|
/**
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1105
|
+
* Converts a readable stream into a promise that resolves with the concatenated data from the stream.
|
|
1106
|
+
*
|
|
1107
|
+
* The function listens for 'data' events from the stream, and when the stream ends, it resolves the promise with the concatenated data. If an error occurs while reading from the stream, the promise is rejected with the error.
|
|
1108
|
+
*
|
|
1109
|
+
* ⚠️ CAUTION: This function should not generally be used in production / when writing to files as it holds a copy of the entire file contents in memory until finished.
|
|
1110
|
+
*
|
|
1111
|
+
* @param {Readable} stream - The readable stream to convert to a promise.
|
|
1112
|
+
* @returns {Promise<Buffer>} A promise that resolves with the concatenated data from the stream as a Buffer, or rejects with an error if one occurred while reading from the stream. If the stream is empty, the promise is rejected with an EmptyStream error.
|
|
1113
|
+
* @throws {EmptyStream} If the stream is empty.
|
|
1103
1114
|
*/
|
|
1104
1115
|
function streamToPromise(stream) {
|
|
1105
1116
|
return new Promise((resolve, reject) => {
|
|
1106
1117
|
const drain = [];
|
|
1107
1118
|
stream
|
|
1119
|
+
// Error propagation is not automatic
|
|
1120
|
+
// Bubble up errors on the read stream
|
|
1121
|
+
.on('error', reject)
|
|
1108
1122
|
.pipe(new stream_1.Writable({
|
|
1109
1123
|
write(chunk, enc, next) {
|
|
1110
1124
|
drain.push(chunk);
|
|
1111
1125
|
next();
|
|
1112
1126
|
},
|
|
1113
1127
|
}))
|
|
1128
|
+
// This bubbles up errors when writing to the internal buffer
|
|
1129
|
+
// This is unlikely to happen, but we have this for completeness
|
|
1114
1130
|
.on('error', reject)
|
|
1115
1131
|
.on('finish', () => {
|
|
1116
1132
|
if (!drain.length) {
|
|
@@ -1142,7 +1158,27 @@ utils$l.normalizeURL = normalizeURL;
|
|
|
1142
1158
|
const sitemapIndexTagStart = '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
|
1143
1159
|
const closetag = '</sitemapindex>';
|
|
1144
1160
|
const defaultStreamOpts = {};
|
|
1161
|
+
/**
|
|
1162
|
+
* `SitemapIndexStream` is a Transform stream that takes `IndexItem`s or sitemap URL strings and outputs a stream of sitemap index XML.
|
|
1163
|
+
*
|
|
1164
|
+
* It automatically handles the XML declaration and the opening and closing tags for the sitemap index.
|
|
1165
|
+
*
|
|
1166
|
+
* ⚠️ CAUTION: This object is `readable` and must be read (e.g. piped to a file or to /dev/null)
|
|
1167
|
+
* before `finish` will be emitted. Failure to read the stream will result in hangs.
|
|
1168
|
+
*
|
|
1169
|
+
* @extends {Transform}
|
|
1170
|
+
*/
|
|
1145
1171
|
class SitemapIndexStream extends stream_1.Transform {
|
|
1172
|
+
/**
|
|
1173
|
+
* `SitemapIndexStream` is a Transform stream that takes `IndexItem`s or sitemap URL strings and outputs a stream of sitemap index XML.
|
|
1174
|
+
*
|
|
1175
|
+
* It automatically handles the XML declaration and the opening and closing tags for the sitemap index.
|
|
1176
|
+
*
|
|
1177
|
+
* ⚠️ CAUTION: This object is `readable` and must be read (e.g. piped to a file or to /dev/null)
|
|
1178
|
+
* before `finish` will be emitted. Failure to read the stream will result in hangs.
|
|
1179
|
+
*
|
|
1180
|
+
* @param {SitemapIndexStreamOptions} [opts=defaultStreamOpts] - Stream options.
|
|
1181
|
+
*/
|
|
1146
1182
|
constructor(opts = defaultStreamOpts) {
|
|
1147
1183
|
var _a;
|
|
1148
1184
|
opts.objectMode = true;
|
|
@@ -1152,14 +1188,17 @@ utils$l.normalizeURL = normalizeURL;
|
|
|
1152
1188
|
this.level = (_a = opts.level) !== null && _a !== void 0 ? _a : types_1.ErrorLevel.WARN;
|
|
1153
1189
|
this.xslUrl = opts.xslUrl;
|
|
1154
1190
|
}
|
|
1191
|
+
writeHeadOutput() {
|
|
1192
|
+
this.hasHeadOutput = true;
|
|
1193
|
+
let stylesheet = '';
|
|
1194
|
+
if (this.xslUrl) {
|
|
1195
|
+
stylesheet = (0, sitemap_stream_1.stylesheetInclude)(this.xslUrl);
|
|
1196
|
+
}
|
|
1197
|
+
this.push(xmlDec + stylesheet + sitemapIndexTagStart);
|
|
1198
|
+
}
|
|
1155
1199
|
_transform(item, encoding, callback) {
|
|
1156
1200
|
if (!this.hasHeadOutput) {
|
|
1157
|
-
this.
|
|
1158
|
-
let stylesheet = '';
|
|
1159
|
-
if (this.xslUrl) {
|
|
1160
|
-
stylesheet = (0, sitemap_stream_1.stylesheetInclude)(this.xslUrl);
|
|
1161
|
-
}
|
|
1162
|
-
this.push(xmlDec + stylesheet + sitemapIndexTagStart);
|
|
1201
|
+
this.writeHeadOutput();
|
|
1163
1202
|
}
|
|
1164
1203
|
this.push((0, sitemap_xml_1.otag)(IndexTagNames.sitemap));
|
|
1165
1204
|
if (typeof item === 'string') {
|
|
@@ -1176,55 +1215,143 @@ utils$l.normalizeURL = normalizeURL;
|
|
|
1176
1215
|
callback();
|
|
1177
1216
|
}
|
|
1178
1217
|
_flush(cb) {
|
|
1218
|
+
if (!this.hasHeadOutput) {
|
|
1219
|
+
this.writeHeadOutput();
|
|
1220
|
+
}
|
|
1179
1221
|
this.push(closetag);
|
|
1180
1222
|
cb();
|
|
1181
1223
|
}
|
|
1182
1224
|
}
|
|
1183
1225
|
exports.SitemapIndexStream = SitemapIndexStream;
|
|
1184
|
-
|
|
1226
|
+
/**
|
|
1227
|
+
* `SitemapAndIndexStream` is a Transform stream that takes in sitemap items,
|
|
1228
|
+
* writes them to sitemap files, adds the sitemap files to a sitemap index,
|
|
1229
|
+
* and creates new sitemap files when the count limit is reached.
|
|
1230
|
+
*
|
|
1231
|
+
* It waits for the target stream of the current sitemap file to finish before
|
|
1232
|
+
* moving on to the next if the target stream is returned by the `getSitemapStream`
|
|
1233
|
+
* callback in the 3rd position of the tuple.
|
|
1234
|
+
*
|
|
1235
|
+
* ⚠️ CAUTION: This object is `readable` and must be read (e.g. piped to a file or to /dev/null)
|
|
1236
|
+
* before `finish` will be emitted. Failure to read the stream will result in hangs.
|
|
1237
|
+
*
|
|
1238
|
+
* @extends {SitemapIndexStream}
|
|
1239
|
+
*/
|
|
1185
1240
|
class SitemapAndIndexStream extends SitemapIndexStream {
|
|
1241
|
+
/**
|
|
1242
|
+
* `SitemapAndIndexStream` is a Transform stream that takes in sitemap items,
|
|
1243
|
+
* writes them to sitemap files, adds the sitemap files to a sitemap index,
|
|
1244
|
+
* and creates new sitemap files when the count limit is reached.
|
|
1245
|
+
*
|
|
1246
|
+
* It waits for the target stream of the current sitemap file to finish before
|
|
1247
|
+
* moving on to the next if the target stream is returned by the `getSitemapStream`
|
|
1248
|
+
* callback in the 3rd position of the tuple.
|
|
1249
|
+
*
|
|
1250
|
+
* ⚠️ CAUTION: This object is `readable` and must be read (e.g. piped to a file or to /dev/null)
|
|
1251
|
+
* before `finish` will be emitted. Failure to read the stream will result in hangs.
|
|
1252
|
+
*
|
|
1253
|
+
* @param {SitemapAndIndexStreamOptions} opts - Stream options.
|
|
1254
|
+
*/
|
|
1186
1255
|
constructor(opts) {
|
|
1187
1256
|
var _a;
|
|
1188
1257
|
opts.objectMode = true;
|
|
1189
1258
|
super(opts);
|
|
1190
|
-
this.
|
|
1259
|
+
this.itemsWritten = 0;
|
|
1191
1260
|
this.getSitemapStream = opts.getSitemapStream;
|
|
1192
|
-
[this.idxItem, this.currentSitemap, this.currentSitemapPipeline] =
|
|
1193
|
-
this.getSitemapStream(0);
|
|
1194
1261
|
this.limit = (_a = opts.limit) !== null && _a !== void 0 ? _a : 45000;
|
|
1195
1262
|
}
|
|
1196
|
-
_writeSMI(item) {
|
|
1197
|
-
this.currentSitemap.write(item);
|
|
1198
|
-
this.i++;
|
|
1199
|
-
}
|
|
1200
1263
|
_transform(item, encoding, callback) {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1264
|
+
if (this.itemsWritten % this.limit === 0) {
|
|
1265
|
+
if (this.currentSitemap) {
|
|
1266
|
+
const onFinish = new Promise((resolve, reject) => {
|
|
1267
|
+
var _a, _b, _c;
|
|
1268
|
+
(_a = this.currentSitemap) === null || _a === void 0 ? void 0 : _a.on('finish', resolve);
|
|
1269
|
+
(_b = this.currentSitemap) === null || _b === void 0 ? void 0 : _b.on('error', reject);
|
|
1270
|
+
(_c = this.currentSitemap) === null || _c === void 0 ? void 0 : _c.end();
|
|
1271
|
+
});
|
|
1272
|
+
const onPipelineFinish = this.currentSitemapPipeline
|
|
1273
|
+
? new Promise((resolve, reject) => {
|
|
1274
|
+
var _a, _b;
|
|
1275
|
+
(_a = this.currentSitemapPipeline) === null || _a === void 0 ? void 0 : _a.on('finish', resolve);
|
|
1276
|
+
(_b = this.currentSitemapPipeline) === null || _b === void 0 ? void 0 : _b.on('error', reject);
|
|
1277
|
+
})
|
|
1278
|
+
: Promise.resolve();
|
|
1279
|
+
Promise.all([onFinish, onPipelineFinish])
|
|
1280
|
+
.then(() => {
|
|
1281
|
+
this.createSitemap(encoding);
|
|
1282
|
+
this.writeItem(item, callback);
|
|
1283
|
+
})
|
|
1284
|
+
.catch(callback);
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
else {
|
|
1288
|
+
this.createSitemap(encoding);
|
|
1289
|
+
}
|
|
1205
1290
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
(_a = this.currentSitemapPipeline) === null || _a === void 0 ? void 0 : _a.on('finish', onFinish);
|
|
1216
|
-
this.currentSitemap.end(!this.currentSitemapPipeline ? onFinish : undefined);
|
|
1291
|
+
this.writeItem(item, callback);
|
|
1292
|
+
}
|
|
1293
|
+
writeItem(item, callback) {
|
|
1294
|
+
if (!this.currentSitemap) {
|
|
1295
|
+
callback(new Error('No sitemap stream available'));
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
if (!this.currentSitemap.write(item)) {
|
|
1299
|
+
this.currentSitemap.once('drain', callback);
|
|
1217
1300
|
}
|
|
1218
1301
|
else {
|
|
1219
|
-
|
|
1220
|
-
callback();
|
|
1302
|
+
process.nextTick(callback);
|
|
1221
1303
|
}
|
|
1304
|
+
// Increment the count of items written
|
|
1305
|
+
this.itemsWritten++;
|
|
1222
1306
|
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Called when the stream is finished.
|
|
1309
|
+
* If there is a current sitemap, we wait for it to finish before calling the callback.
|
|
1310
|
+
*
|
|
1311
|
+
* @param cb
|
|
1312
|
+
*/
|
|
1223
1313
|
_flush(cb) {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1314
|
+
const onFinish = new Promise((resolve, reject) => {
|
|
1315
|
+
if (this.currentSitemap) {
|
|
1316
|
+
this.currentSitemap.on('finish', resolve);
|
|
1317
|
+
this.currentSitemap.on('error', reject);
|
|
1318
|
+
this.currentSitemap.end();
|
|
1319
|
+
}
|
|
1320
|
+
else {
|
|
1321
|
+
resolve();
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
const onPipelineFinish = new Promise((resolve, reject) => {
|
|
1325
|
+
if (this.currentSitemapPipeline) {
|
|
1326
|
+
this.currentSitemapPipeline.on('finish', resolve);
|
|
1327
|
+
this.currentSitemapPipeline.on('error', reject);
|
|
1328
|
+
// The pipeline (pipe target) will get it's end() call
|
|
1329
|
+
// from the sitemap stream ending.
|
|
1330
|
+
}
|
|
1331
|
+
else {
|
|
1332
|
+
resolve();
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
Promise.all([onFinish, onPipelineFinish])
|
|
1336
|
+
.then(() => {
|
|
1337
|
+
super._flush(cb);
|
|
1338
|
+
})
|
|
1339
|
+
.catch((err) => {
|
|
1340
|
+
cb(err);
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
createSitemap(encoding) {
|
|
1344
|
+
const [idxItem, currentSitemap, currentSitemapPipeline] = this.getSitemapStream(this.itemsWritten / this.limit);
|
|
1345
|
+
currentSitemap.on('error', (err) => this.emit('error', err));
|
|
1346
|
+
this.currentSitemap = currentSitemap;
|
|
1347
|
+
this.currentSitemapPipeline = currentSitemapPipeline;
|
|
1348
|
+
super._transform(idxItem, encoding, () => {
|
|
1349
|
+
// We are not too fussed about waiting for the index item to be written
|
|
1350
|
+
// we we'll wait for the file to finish at the end
|
|
1351
|
+
// and index file write volume tends to be small in comprarison to sitemap
|
|
1352
|
+
// writes.
|
|
1353
|
+
// noop
|
|
1354
|
+
});
|
|
1228
1355
|
}
|
|
1229
1356
|
}
|
|
1230
1357
|
exports.SitemapAndIndexStream = SitemapAndIndexStream;
|
|
@@ -3283,12 +3410,17 @@ class XMLToSitemapItemStream extends stream_1$7.Transform {
|
|
|
3283
3410
|
}
|
|
3284
3411
|
_transform(data, encoding, callback) {
|
|
3285
3412
|
try {
|
|
3413
|
+
const cb = () => callback(this.level === types_1$1.ErrorLevel.THROW ? this.error : null);
|
|
3286
3414
|
// correcting the type here can be done without making it a breaking change
|
|
3287
3415
|
// TODO fix this
|
|
3288
3416
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3289
3417
|
// @ts-ignore
|
|
3290
|
-
this.saxStream.write(data, encoding)
|
|
3291
|
-
|
|
3418
|
+
if (!this.saxStream.write(data, encoding)) {
|
|
3419
|
+
this.saxStream.once('drain', cb);
|
|
3420
|
+
}
|
|
3421
|
+
else {
|
|
3422
|
+
process.nextTick(cb);
|
|
3423
|
+
}
|
|
3292
3424
|
}
|
|
3293
3425
|
catch (error) {
|
|
3294
3426
|
callback(error);
|
|
@@ -3557,152 +3689,138 @@ sitemapIndexParser.IndexObjectStreamToJSON = IndexObjectStreamToJSON;
|
|
|
3557
3689
|
|
|
3558
3690
|
var sitemapSimple = {};
|
|
3559
3691
|
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
}
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
Object.defineProperty(exports, "parseSitemap", { enumerable: true, get: function () { return sitemap_parser_1.parseSitemap; } });
|
|
3693
|
-
Object.defineProperty(exports, "XMLToSitemapItemStream", { enumerable: true, get: function () { return sitemap_parser_1.XMLToSitemapItemStream; } });
|
|
3694
|
-
Object.defineProperty(exports, "ObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_parser_1.ObjectStreamToJSON; } });
|
|
3695
|
-
var sitemap_index_parser_1 = sitemapIndexParser;
|
|
3696
|
-
Object.defineProperty(exports, "parseSitemapIndex", { enumerable: true, get: function () { return sitemap_index_parser_1.parseSitemapIndex; } });
|
|
3697
|
-
Object.defineProperty(exports, "XMLToSitemapIndexStream", { enumerable: true, get: function () { return sitemap_index_parser_1.XMLToSitemapIndexStream; } });
|
|
3698
|
-
Object.defineProperty(exports, "IndexObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_index_parser_1.IndexObjectStreamToJSON; } });
|
|
3699
|
-
var sitemap_simple_1 = requireSitemapSimple();
|
|
3700
|
-
Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function () { return sitemap_simple_1.simpleSitemapAndIndex; } });
|
|
3701
|
-
} (dist));
|
|
3702
|
-
return dist;
|
|
3703
|
-
}
|
|
3704
|
-
|
|
3705
|
-
var distExports = requireDist();
|
|
3692
|
+
(function (exports) {
|
|
3693
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3694
|
+
exports.simpleSitemapAndIndex = void 0;
|
|
3695
|
+
const sitemap_index_stream_1 = sitemapIndexStream;
|
|
3696
|
+
const sitemap_stream_1 = sitemapStream;
|
|
3697
|
+
const utils_1 = utils$l;
|
|
3698
|
+
const zlib_1 = require$$3$1;
|
|
3699
|
+
const fs_1 = require$$0$1;
|
|
3700
|
+
const path_1 = require$$0$2;
|
|
3701
|
+
const stream_1 = require$$0;
|
|
3702
|
+
const util_1 = require$$0$3;
|
|
3703
|
+
const url_1 = require$$3;
|
|
3704
|
+
const pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
3705
|
+
/**
|
|
3706
|
+
*
|
|
3707
|
+
* @param {object} options -
|
|
3708
|
+
* @param {string} options.hostname - The hostname for all URLs
|
|
3709
|
+
* @param {string} [options.sitemapHostname] - The hostname for the sitemaps if different than hostname
|
|
3710
|
+
* @param {SitemapItemLoose[] | string | Readable | string[]} options.sourceData - The urls you want to make a sitemap out of.
|
|
3711
|
+
* @param {string} options.destinationDir - where to write the sitemaps and index
|
|
3712
|
+
* @param {string} [options.publicBasePath] - where the sitemaps are relative to the hostname. Defaults to root.
|
|
3713
|
+
* @param {number} [options.limit] - how many URLs to write before switching to a new file. Defaults to 50k
|
|
3714
|
+
* @param {boolean} [options.gzip] - whether to compress the written files. Defaults to true
|
|
3715
|
+
* @returns {Promise<void>} an empty promise that resolves when everything is done
|
|
3716
|
+
*/
|
|
3717
|
+
const simpleSitemapAndIndex = async ({ hostname, sitemapHostname = hostname, // if different
|
|
3718
|
+
/**
|
|
3719
|
+
* Pass a line separated list of sitemap items or a stream or an array
|
|
3720
|
+
*/
|
|
3721
|
+
sourceData, destinationDir, limit = 50000, gzip = true, publicBasePath = './', }) => {
|
|
3722
|
+
await fs_1.promises.mkdir(destinationDir, { recursive: true });
|
|
3723
|
+
const sitemapAndIndexStream = new sitemap_index_stream_1.SitemapAndIndexStream({
|
|
3724
|
+
limit,
|
|
3725
|
+
getSitemapStream: (i) => {
|
|
3726
|
+
const sitemapStream = new sitemap_stream_1.SitemapStream({
|
|
3727
|
+
hostname,
|
|
3728
|
+
});
|
|
3729
|
+
const path = `./sitemap-${i}.xml`;
|
|
3730
|
+
const writePath = (0, path_1.resolve)(destinationDir, path + (gzip ? '.gz' : ''));
|
|
3731
|
+
if (!publicBasePath.endsWith('/')) {
|
|
3732
|
+
publicBasePath += '/';
|
|
3733
|
+
}
|
|
3734
|
+
const publicPath = (0, path_1.normalize)(publicBasePath + path);
|
|
3735
|
+
let pipeline;
|
|
3736
|
+
if (gzip) {
|
|
3737
|
+
pipeline = sitemapStream
|
|
3738
|
+
.pipe((0, zlib_1.createGzip)()) // compress the output of the sitemap
|
|
3739
|
+
.pipe((0, fs_1.createWriteStream)(writePath)); // write it to sitemap-NUMBER.xml
|
|
3740
|
+
}
|
|
3741
|
+
else {
|
|
3742
|
+
pipeline = sitemapStream.pipe((0, fs_1.createWriteStream)(writePath)); // write it to sitemap-NUMBER.xml
|
|
3743
|
+
}
|
|
3744
|
+
return [
|
|
3745
|
+
new url_1.URL(`${publicPath}${gzip ? '.gz' : ''}`, sitemapHostname).toString(),
|
|
3746
|
+
sitemapStream,
|
|
3747
|
+
pipeline,
|
|
3748
|
+
];
|
|
3749
|
+
},
|
|
3750
|
+
});
|
|
3751
|
+
let src;
|
|
3752
|
+
if (typeof sourceData === 'string') {
|
|
3753
|
+
src = (0, utils_1.lineSeparatedURLsToSitemapOptions)((0, fs_1.createReadStream)(sourceData));
|
|
3754
|
+
}
|
|
3755
|
+
else if (sourceData instanceof stream_1.Readable) {
|
|
3756
|
+
src = sourceData;
|
|
3757
|
+
}
|
|
3758
|
+
else if (Array.isArray(sourceData)) {
|
|
3759
|
+
src = stream_1.Readable.from(sourceData);
|
|
3760
|
+
}
|
|
3761
|
+
else {
|
|
3762
|
+
throw new Error("unhandled source type. You've passed in data that is not supported");
|
|
3763
|
+
}
|
|
3764
|
+
const writePath = (0, path_1.resolve)(destinationDir, `./sitemap-index.xml${gzip ? '.gz' : ''}`);
|
|
3765
|
+
if (gzip) {
|
|
3766
|
+
return pipeline(src, sitemapAndIndexStream, (0, zlib_1.createGzip)(), (0, fs_1.createWriteStream)(writePath));
|
|
3767
|
+
}
|
|
3768
|
+
else {
|
|
3769
|
+
return pipeline(src, sitemapAndIndexStream, (0, fs_1.createWriteStream)(writePath));
|
|
3770
|
+
}
|
|
3771
|
+
};
|
|
3772
|
+
exports.simpleSitemapAndIndex = simpleSitemapAndIndex;
|
|
3773
|
+
exports.default = exports.simpleSitemapAndIndex;
|
|
3774
|
+
} (sitemapSimple));
|
|
3775
|
+
|
|
3776
|
+
(function (exports) {
|
|
3777
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3778
|
+
if (k2 === undefined) k2 = k;
|
|
3779
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
3780
|
+
}) : (function(o, m, k, k2) {
|
|
3781
|
+
if (k2 === undefined) k2 = k;
|
|
3782
|
+
o[k2] = m[k];
|
|
3783
|
+
}));
|
|
3784
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
3785
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3786
|
+
};
|
|
3787
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3788
|
+
exports.simpleSitemapAndIndex = exports.IndexObjectStreamToJSON = exports.XMLToSitemapIndexStream = exports.parseSitemapIndex = exports.ObjectStreamToJSON = exports.XMLToSitemapItemStream = exports.parseSitemap = exports.xmlLint = exports.ReadlineStream = exports.normalizeURL = exports.validateSMIOptions = exports.mergeStreams = exports.lineSeparatedURLsToSitemapOptions = exports.SitemapStream = exports.streamToPromise = exports.SitemapAndIndexStream = exports.SitemapIndexStream = exports.IndexTagNames = exports.SitemapItemStream = void 0;
|
|
3789
|
+
/*!
|
|
3790
|
+
* Sitemap
|
|
3791
|
+
* Copyright(c) 2011 Eugene Kalinin
|
|
3792
|
+
* MIT Licensed
|
|
3793
|
+
*/
|
|
3794
|
+
var sitemap_item_stream_1 = sitemapItemStream;
|
|
3795
|
+
Object.defineProperty(exports, "SitemapItemStream", { enumerable: true, get: function () { return sitemap_item_stream_1.SitemapItemStream; } });
|
|
3796
|
+
var sitemap_index_stream_1 = sitemapIndexStream;
|
|
3797
|
+
Object.defineProperty(exports, "IndexTagNames", { enumerable: true, get: function () { return sitemap_index_stream_1.IndexTagNames; } });
|
|
3798
|
+
Object.defineProperty(exports, "SitemapIndexStream", { enumerable: true, get: function () { return sitemap_index_stream_1.SitemapIndexStream; } });
|
|
3799
|
+
Object.defineProperty(exports, "SitemapAndIndexStream", { enumerable: true, get: function () { return sitemap_index_stream_1.SitemapAndIndexStream; } });
|
|
3800
|
+
var sitemap_stream_1 = sitemapStream;
|
|
3801
|
+
Object.defineProperty(exports, "streamToPromise", { enumerable: true, get: function () { return sitemap_stream_1.streamToPromise; } });
|
|
3802
|
+
Object.defineProperty(exports, "SitemapStream", { enumerable: true, get: function () { return sitemap_stream_1.SitemapStream; } });
|
|
3803
|
+
__exportStar(errors, exports);
|
|
3804
|
+
__exportStar(types, exports);
|
|
3805
|
+
var utils_1 = utils$l;
|
|
3806
|
+
Object.defineProperty(exports, "lineSeparatedURLsToSitemapOptions", { enumerable: true, get: function () { return utils_1.lineSeparatedURLsToSitemapOptions; } });
|
|
3807
|
+
Object.defineProperty(exports, "mergeStreams", { enumerable: true, get: function () { return utils_1.mergeStreams; } });
|
|
3808
|
+
Object.defineProperty(exports, "validateSMIOptions", { enumerable: true, get: function () { return utils_1.validateSMIOptions; } });
|
|
3809
|
+
Object.defineProperty(exports, "normalizeURL", { enumerable: true, get: function () { return utils_1.normalizeURL; } });
|
|
3810
|
+
Object.defineProperty(exports, "ReadlineStream", { enumerable: true, get: function () { return utils_1.ReadlineStream; } });
|
|
3811
|
+
var xmllint_1 = xmllint;
|
|
3812
|
+
Object.defineProperty(exports, "xmlLint", { enumerable: true, get: function () { return xmllint_1.xmlLint; } });
|
|
3813
|
+
var sitemap_parser_1 = sitemapParser;
|
|
3814
|
+
Object.defineProperty(exports, "parseSitemap", { enumerable: true, get: function () { return sitemap_parser_1.parseSitemap; } });
|
|
3815
|
+
Object.defineProperty(exports, "XMLToSitemapItemStream", { enumerable: true, get: function () { return sitemap_parser_1.XMLToSitemapItemStream; } });
|
|
3816
|
+
Object.defineProperty(exports, "ObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_parser_1.ObjectStreamToJSON; } });
|
|
3817
|
+
var sitemap_index_parser_1 = sitemapIndexParser;
|
|
3818
|
+
Object.defineProperty(exports, "parseSitemapIndex", { enumerable: true, get: function () { return sitemap_index_parser_1.parseSitemapIndex; } });
|
|
3819
|
+
Object.defineProperty(exports, "XMLToSitemapIndexStream", { enumerable: true, get: function () { return sitemap_index_parser_1.XMLToSitemapIndexStream; } });
|
|
3820
|
+
Object.defineProperty(exports, "IndexObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_index_parser_1.IndexObjectStreamToJSON; } });
|
|
3821
|
+
var sitemap_simple_1 = sitemapSimple;
|
|
3822
|
+
Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function () { return sitemap_simple_1.simpleSitemapAndIndex; } });
|
|
3823
|
+
} (dist));
|
|
3706
3824
|
|
|
3707
3825
|
var cjs$1 = {exports: {}};
|
|
3708
3826
|
|
|
@@ -4049,7 +4167,7 @@ var cjsExports$1 = cjs.exports;
|
|
|
4049
4167
|
containsTextNodesWithLineBreaks = true;
|
|
4050
4168
|
child.content = child.content.trim();
|
|
4051
4169
|
}
|
|
4052
|
-
else if (index === 0 || index === nodeChildren.length - 1) {
|
|
4170
|
+
else if ((index === 0 || index === nodeChildren.length - 1) && !preserveSpace) {
|
|
4053
4171
|
if (child.content.trim().length === 0) {
|
|
4054
4172
|
// If the text node is at the start or end and is empty, it should be ignored when formatting
|
|
4055
4173
|
child.content = '';
|
|
@@ -4220,11 +4338,11 @@ const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
|
|
|
4220
4338
|
const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
|
|
4221
4339
|
/**
|
|
4222
4340
|
* All non-escaped special characters.
|
|
4223
|
-
* Posix: ()*?[
|
|
4224
|
-
* Windows: (){}, !+@ before (, ! at the beginning.
|
|
4341
|
+
* Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
|
|
4342
|
+
* Windows: (){}[], !+@ before (, ! at the beginning.
|
|
4225
4343
|
*/
|
|
4226
4344
|
const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
4227
|
-
const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([(){}]|^!|[!+@](?=\())/g;
|
|
4345
|
+
const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
4228
4346
|
/**
|
|
4229
4347
|
* The device path (\\.\ or \\?\).
|
|
4230
4348
|
* https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
|
|
@@ -4235,7 +4353,7 @@ const DOS_DEVICE_PATH_RE = /^\\\\([.?])/;
|
|
|
4235
4353
|
* Windows: !()+@{}
|
|
4236
4354
|
* https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
|
4237
4355
|
*/
|
|
4238
|
-
const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@{}])/g;
|
|
4356
|
+
const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
|
|
4239
4357
|
/**
|
|
4240
4358
|
* Designed to work only with simple paths: `dir\\file`.
|
|
4241
4359
|
*/
|
|
@@ -4530,7 +4648,7 @@ var utils$j = {};
|
|
|
4530
4648
|
*/
|
|
4531
4649
|
|
|
4532
4650
|
exports.escapeNode = (block, n = 0, type) => {
|
|
4533
|
-
|
|
4651
|
+
const node = block.nodes[n];
|
|
4534
4652
|
if (!node) return;
|
|
4535
4653
|
|
|
4536
4654
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
|
@@ -4599,13 +4717,23 @@ var utils$j = {};
|
|
|
4599
4717
|
|
|
4600
4718
|
exports.flatten = (...args) => {
|
|
4601
4719
|
const result = [];
|
|
4720
|
+
|
|
4602
4721
|
const flat = arr => {
|
|
4603
4722
|
for (let i = 0; i < arr.length; i++) {
|
|
4604
|
-
|
|
4605
|
-
|
|
4723
|
+
const ele = arr[i];
|
|
4724
|
+
|
|
4725
|
+
if (Array.isArray(ele)) {
|
|
4726
|
+
flat(ele);
|
|
4727
|
+
continue;
|
|
4728
|
+
}
|
|
4729
|
+
|
|
4730
|
+
if (ele !== undefined) {
|
|
4731
|
+
result.push(ele);
|
|
4732
|
+
}
|
|
4606
4733
|
}
|
|
4607
4734
|
return result;
|
|
4608
4735
|
};
|
|
4736
|
+
|
|
4609
4737
|
flat(args);
|
|
4610
4738
|
return result;
|
|
4611
4739
|
};
|
|
@@ -4614,9 +4742,9 @@ var utils$j = {};
|
|
|
4614
4742
|
const utils$i = utils$j;
|
|
4615
4743
|
|
|
4616
4744
|
var stringify$4 = (ast, options = {}) => {
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4745
|
+
const stringify = (node, parent = {}) => {
|
|
4746
|
+
const invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
|
|
4747
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
4620
4748
|
let output = '';
|
|
4621
4749
|
|
|
4622
4750
|
if (node.value) {
|
|
@@ -4631,7 +4759,7 @@ var stringify$4 = (ast, options = {}) => {
|
|
|
4631
4759
|
}
|
|
4632
4760
|
|
|
4633
4761
|
if (node.nodes) {
|
|
4634
|
-
for (
|
|
4762
|
+
for (const child of node.nodes) {
|
|
4635
4763
|
output += stringify(child);
|
|
4636
4764
|
}
|
|
4637
4765
|
}
|
|
@@ -5005,7 +5133,7 @@ const toMaxLen = (input, maxLength) => {
|
|
|
5005
5133
|
return negative ? ('-' + input) : input;
|
|
5006
5134
|
};
|
|
5007
5135
|
|
|
5008
|
-
const toSequence = (parts, options) => {
|
|
5136
|
+
const toSequence = (parts, options, maxLen) => {
|
|
5009
5137
|
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
5010
5138
|
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
5011
5139
|
|
|
@@ -5015,11 +5143,11 @@ const toSequence = (parts, options) => {
|
|
|
5015
5143
|
let result;
|
|
5016
5144
|
|
|
5017
5145
|
if (parts.positives.length) {
|
|
5018
|
-
positives = parts.positives.join('|');
|
|
5146
|
+
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
|
|
5019
5147
|
}
|
|
5020
5148
|
|
|
5021
5149
|
if (parts.negatives.length) {
|
|
5022
|
-
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
|
5150
|
+
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
|
|
5023
5151
|
}
|
|
5024
5152
|
|
|
5025
5153
|
if (positives && negatives) {
|
|
@@ -5117,7 +5245,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
|
|
|
5117
5245
|
|
|
5118
5246
|
if (options.toRegex === true) {
|
|
5119
5247
|
return step > 1
|
|
5120
|
-
? toSequence(parts, options)
|
|
5248
|
+
? toSequence(parts, options, maxLen)
|
|
5121
5249
|
: toRegex(range, null, { wrap: false, ...options });
|
|
5122
5250
|
}
|
|
5123
5251
|
|
|
@@ -5129,7 +5257,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
|
|
|
5129
5257
|
return invalidRange(start, end, options);
|
|
5130
5258
|
}
|
|
5131
5259
|
|
|
5132
|
-
|
|
5133
5260
|
let format = options.transform || (val => String.fromCharCode(val));
|
|
5134
5261
|
let a = `${start}`.charCodeAt(0);
|
|
5135
5262
|
let b = `${end}`.charCodeAt(0);
|
|
@@ -5197,30 +5324,32 @@ const fill$1 = fillRange;
|
|
|
5197
5324
|
const utils$h = utils$j;
|
|
5198
5325
|
|
|
5199
5326
|
const compile$1 = (ast, options = {}) => {
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5327
|
+
const walk = (node, parent = {}) => {
|
|
5328
|
+
const invalidBlock = utils$h.isInvalidBrace(parent);
|
|
5329
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
5330
|
+
const invalid = invalidBlock === true || invalidNode === true;
|
|
5331
|
+
const prefix = options.escapeInvalid === true ? '\\' : '';
|
|
5205
5332
|
let output = '';
|
|
5206
5333
|
|
|
5207
5334
|
if (node.isOpen === true) {
|
|
5208
5335
|
return prefix + node.value;
|
|
5209
5336
|
}
|
|
5337
|
+
|
|
5210
5338
|
if (node.isClose === true) {
|
|
5339
|
+
console.log('node.isClose', prefix, node.value);
|
|
5211
5340
|
return prefix + node.value;
|
|
5212
5341
|
}
|
|
5213
5342
|
|
|
5214
5343
|
if (node.type === 'open') {
|
|
5215
|
-
return invalid ?
|
|
5344
|
+
return invalid ? prefix + node.value : '(';
|
|
5216
5345
|
}
|
|
5217
5346
|
|
|
5218
5347
|
if (node.type === 'close') {
|
|
5219
|
-
return invalid ?
|
|
5348
|
+
return invalid ? prefix + node.value : ')';
|
|
5220
5349
|
}
|
|
5221
5350
|
|
|
5222
5351
|
if (node.type === 'comma') {
|
|
5223
|
-
return node.prev.type === 'comma' ? '' :
|
|
5352
|
+
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
|
5224
5353
|
}
|
|
5225
5354
|
|
|
5226
5355
|
if (node.value) {
|
|
@@ -5228,8 +5357,8 @@ const compile$1 = (ast, options = {}) => {
|
|
|
5228
5357
|
}
|
|
5229
5358
|
|
|
5230
5359
|
if (node.nodes && node.ranges > 0) {
|
|
5231
|
-
|
|
5232
|
-
|
|
5360
|
+
const args = utils$h.reduce(node.nodes);
|
|
5361
|
+
const range = fill$1(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
|
5233
5362
|
|
|
5234
5363
|
if (range.length !== 0) {
|
|
5235
5364
|
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
|
@@ -5237,10 +5366,11 @@ const compile$1 = (ast, options = {}) => {
|
|
|
5237
5366
|
}
|
|
5238
5367
|
|
|
5239
5368
|
if (node.nodes) {
|
|
5240
|
-
for (
|
|
5369
|
+
for (const child of node.nodes) {
|
|
5241
5370
|
output += walk(child, node);
|
|
5242
5371
|
}
|
|
5243
5372
|
}
|
|
5373
|
+
|
|
5244
5374
|
return output;
|
|
5245
5375
|
};
|
|
5246
5376
|
|
|
@@ -5254,7 +5384,7 @@ const stringify$2 = stringify$4;
|
|
|
5254
5384
|
const utils$g = utils$j;
|
|
5255
5385
|
|
|
5256
5386
|
const append = (queue = '', stash = '', enclose = false) => {
|
|
5257
|
-
|
|
5387
|
+
const result = [];
|
|
5258
5388
|
|
|
5259
5389
|
queue = [].concat(queue);
|
|
5260
5390
|
stash = [].concat(stash);
|
|
@@ -5264,15 +5394,15 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
5264
5394
|
return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
|
|
5265
5395
|
}
|
|
5266
5396
|
|
|
5267
|
-
for (
|
|
5397
|
+
for (const item of queue) {
|
|
5268
5398
|
if (Array.isArray(item)) {
|
|
5269
|
-
for (
|
|
5399
|
+
for (const value of item) {
|
|
5270
5400
|
result.push(append(value, stash, enclose));
|
|
5271
5401
|
}
|
|
5272
5402
|
} else {
|
|
5273
5403
|
for (let ele of stash) {
|
|
5274
5404
|
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
|
5275
|
-
result.push(Array.isArray(ele) ? append(item, ele, enclose) :
|
|
5405
|
+
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
|
5276
5406
|
}
|
|
5277
5407
|
}
|
|
5278
5408
|
}
|
|
@@ -5280,9 +5410,9 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
5280
5410
|
};
|
|
5281
5411
|
|
|
5282
5412
|
const expand$1 = (ast, options = {}) => {
|
|
5283
|
-
|
|
5413
|
+
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
|
|
5284
5414
|
|
|
5285
|
-
|
|
5415
|
+
const walk = (node, parent = {}) => {
|
|
5286
5416
|
node.queue = [];
|
|
5287
5417
|
|
|
5288
5418
|
let p = parent;
|
|
@@ -5304,7 +5434,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5304
5434
|
}
|
|
5305
5435
|
|
|
5306
5436
|
if (node.nodes && node.ranges > 0) {
|
|
5307
|
-
|
|
5437
|
+
const args = utils$g.reduce(node.nodes);
|
|
5308
5438
|
|
|
5309
5439
|
if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
|
|
5310
5440
|
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
|
@@ -5320,7 +5450,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5320
5450
|
return;
|
|
5321
5451
|
}
|
|
5322
5452
|
|
|
5323
|
-
|
|
5453
|
+
const enclose = utils$g.encloseBrace(node);
|
|
5324
5454
|
let queue = node.queue;
|
|
5325
5455
|
let block = node;
|
|
5326
5456
|
|
|
@@ -5330,7 +5460,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5330
5460
|
}
|
|
5331
5461
|
|
|
5332
5462
|
for (let i = 0; i < node.nodes.length; i++) {
|
|
5333
|
-
|
|
5463
|
+
const child = node.nodes[i];
|
|
5334
5464
|
|
|
5335
5465
|
if (child.type === 'comma' && node.type === 'brace') {
|
|
5336
5466
|
if (i === 1) queue.push('');
|
|
@@ -5362,7 +5492,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
5362
5492
|
var expand_1 = expand$1;
|
|
5363
5493
|
|
|
5364
5494
|
var constants$4 = {
|
|
5365
|
-
MAX_LENGTH:
|
|
5495
|
+
MAX_LENGTH: 10000,
|
|
5366
5496
|
|
|
5367
5497
|
// Digits
|
|
5368
5498
|
CHAR_0: '0', /* 0 */
|
|
@@ -5450,18 +5580,18 @@ const parse$3 = (input, options = {}) => {
|
|
|
5450
5580
|
throw new TypeError('Expected a string');
|
|
5451
5581
|
}
|
|
5452
5582
|
|
|
5453
|
-
|
|
5454
|
-
|
|
5583
|
+
const opts = options || {};
|
|
5584
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
|
|
5455
5585
|
if (input.length > max) {
|
|
5456
5586
|
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
|
5457
5587
|
}
|
|
5458
5588
|
|
|
5459
|
-
|
|
5460
|
-
|
|
5589
|
+
const ast = { type: 'root', input, nodes: [] };
|
|
5590
|
+
const stack = [ast];
|
|
5461
5591
|
let block = ast;
|
|
5462
5592
|
let prev = ast;
|
|
5463
5593
|
let brackets = 0;
|
|
5464
|
-
|
|
5594
|
+
const length = input.length;
|
|
5465
5595
|
let index = 0;
|
|
5466
5596
|
let depth = 0;
|
|
5467
5597
|
let value;
|
|
@@ -5526,6 +5656,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5526
5656
|
|
|
5527
5657
|
if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
|
|
5528
5658
|
brackets++;
|
|
5659
|
+
|
|
5529
5660
|
let next;
|
|
5530
5661
|
|
|
5531
5662
|
while (index < length && (next = advance())) {
|
|
@@ -5581,7 +5712,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5581
5712
|
*/
|
|
5582
5713
|
|
|
5583
5714
|
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
|
5584
|
-
|
|
5715
|
+
const open = value;
|
|
5585
5716
|
let next;
|
|
5586
5717
|
|
|
5587
5718
|
if (options.keepQuotes !== true) {
|
|
@@ -5613,8 +5744,8 @@ const parse$3 = (input, options = {}) => {
|
|
|
5613
5744
|
if (value === CHAR_LEFT_CURLY_BRACE$1) {
|
|
5614
5745
|
depth++;
|
|
5615
5746
|
|
|
5616
|
-
|
|
5617
|
-
|
|
5747
|
+
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
|
5748
|
+
const brace = {
|
|
5618
5749
|
type: 'brace',
|
|
5619
5750
|
open: true,
|
|
5620
5751
|
close: false,
|
|
@@ -5641,7 +5772,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5641
5772
|
continue;
|
|
5642
5773
|
}
|
|
5643
5774
|
|
|
5644
|
-
|
|
5775
|
+
const type = 'close';
|
|
5645
5776
|
block = stack.pop();
|
|
5646
5777
|
block.close = true;
|
|
5647
5778
|
|
|
@@ -5659,7 +5790,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5659
5790
|
if (value === CHAR_COMMA$1 && depth > 0) {
|
|
5660
5791
|
if (block.ranges > 0) {
|
|
5661
5792
|
block.ranges = 0;
|
|
5662
|
-
|
|
5793
|
+
const open = block.nodes.shift();
|
|
5663
5794
|
block.nodes = [open, { type: 'text', value: stringify$1(block) }];
|
|
5664
5795
|
}
|
|
5665
5796
|
|
|
@@ -5673,7 +5804,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5673
5804
|
*/
|
|
5674
5805
|
|
|
5675
5806
|
if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
|
|
5676
|
-
|
|
5807
|
+
const siblings = block.nodes;
|
|
5677
5808
|
|
|
5678
5809
|
if (depth === 0 || siblings.length === 0) {
|
|
5679
5810
|
push({ type: 'text', value });
|
|
@@ -5700,7 +5831,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
5700
5831
|
if (prev.type === 'range') {
|
|
5701
5832
|
siblings.pop();
|
|
5702
5833
|
|
|
5703
|
-
|
|
5834
|
+
const before = siblings[siblings.length - 1];
|
|
5704
5835
|
before.value += prev.value + value;
|
|
5705
5836
|
prev = before;
|
|
5706
5837
|
block.ranges--;
|
|
@@ -5733,8 +5864,8 @@ const parse$3 = (input, options = {}) => {
|
|
|
5733
5864
|
});
|
|
5734
5865
|
|
|
5735
5866
|
// get the location of the block on parent.nodes (block's siblings)
|
|
5736
|
-
|
|
5737
|
-
|
|
5867
|
+
const parent = stack[stack.length - 1];
|
|
5868
|
+
const index = parent.nodes.indexOf(block);
|
|
5738
5869
|
// replace the (invalid) block with it's nodes
|
|
5739
5870
|
parent.nodes.splice(index, 1, ...block.nodes);
|
|
5740
5871
|
}
|
|
@@ -5769,8 +5900,8 @@ const braces$1 = (input, options = {}) => {
|
|
|
5769
5900
|
let output = [];
|
|
5770
5901
|
|
|
5771
5902
|
if (Array.isArray(input)) {
|
|
5772
|
-
for (
|
|
5773
|
-
|
|
5903
|
+
for (const pattern of input) {
|
|
5904
|
+
const result = braces$1.create(pattern, options);
|
|
5774
5905
|
if (Array.isArray(result)) {
|
|
5775
5906
|
output.push(...result);
|
|
5776
5907
|
} else {
|
|
@@ -5904,7 +6035,7 @@ braces$1.create = (input, options = {}) => {
|
|
|
5904
6035
|
return [input];
|
|
5905
6036
|
}
|
|
5906
6037
|
|
|
5907
|
-
|
|
6038
|
+
return options.expand !== true
|
|
5908
6039
|
? braces$1.compile(input, options)
|
|
5909
6040
|
: braces$1.expand(input, options);
|
|
5910
6041
|
};
|
|
@@ -8585,7 +8716,7 @@ function expandPatternsWithBraceExpansion(patterns) {
|
|
|
8585
8716
|
}
|
|
8586
8717
|
pattern$1.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
|
|
8587
8718
|
function expandBraceExpansion(pattern) {
|
|
8588
|
-
const patterns = micromatch.braces(pattern, { expand: true, nodupes: true });
|
|
8719
|
+
const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true });
|
|
8589
8720
|
/**
|
|
8590
8721
|
* Sort the patterns by length so that the same depth patterns are processed side by side.
|
|
8591
8722
|
* `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
|
|
@@ -9484,15 +9615,15 @@ var reusify_1 = reusify$1;
|
|
|
9484
9615
|
|
|
9485
9616
|
var reusify = reusify_1;
|
|
9486
9617
|
|
|
9487
|
-
function fastqueue (context, worker,
|
|
9618
|
+
function fastqueue (context, worker, _concurrency) {
|
|
9488
9619
|
if (typeof context === 'function') {
|
|
9489
|
-
|
|
9620
|
+
_concurrency = worker;
|
|
9490
9621
|
worker = context;
|
|
9491
9622
|
context = null;
|
|
9492
9623
|
}
|
|
9493
9624
|
|
|
9494
|
-
if (
|
|
9495
|
-
throw new Error('fastqueue concurrency must be greater than 1')
|
|
9625
|
+
if (!(_concurrency >= 1)) {
|
|
9626
|
+
throw new Error('fastqueue concurrency must be equal to or greater than 1')
|
|
9496
9627
|
}
|
|
9497
9628
|
|
|
9498
9629
|
var cache = reusify(Task);
|
|
@@ -9507,7 +9638,23 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9507
9638
|
saturated: noop,
|
|
9508
9639
|
pause: pause,
|
|
9509
9640
|
paused: false,
|
|
9510
|
-
|
|
9641
|
+
|
|
9642
|
+
get concurrency () {
|
|
9643
|
+
return _concurrency
|
|
9644
|
+
},
|
|
9645
|
+
set concurrency (value) {
|
|
9646
|
+
if (!(value >= 1)) {
|
|
9647
|
+
throw new Error('fastqueue concurrency must be equal to or greater than 1')
|
|
9648
|
+
}
|
|
9649
|
+
_concurrency = value;
|
|
9650
|
+
|
|
9651
|
+
if (self.paused) return
|
|
9652
|
+
for (; queueHead && _running < _concurrency;) {
|
|
9653
|
+
_running++;
|
|
9654
|
+
release();
|
|
9655
|
+
}
|
|
9656
|
+
},
|
|
9657
|
+
|
|
9511
9658
|
running: running,
|
|
9512
9659
|
resume: resume,
|
|
9513
9660
|
idle: idle,
|
|
@@ -9557,7 +9704,12 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9557
9704
|
function resume () {
|
|
9558
9705
|
if (!self.paused) return
|
|
9559
9706
|
self.paused = false;
|
|
9560
|
-
|
|
9707
|
+
if (queueHead === null) {
|
|
9708
|
+
_running++;
|
|
9709
|
+
release();
|
|
9710
|
+
return
|
|
9711
|
+
}
|
|
9712
|
+
for (; queueHead && _running < _concurrency;) {
|
|
9561
9713
|
_running++;
|
|
9562
9714
|
release();
|
|
9563
9715
|
}
|
|
@@ -9576,7 +9728,7 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9576
9728
|
current.callback = done || noop;
|
|
9577
9729
|
current.errorHandler = errorHandler;
|
|
9578
9730
|
|
|
9579
|
-
if (_running
|
|
9731
|
+
if (_running >= _concurrency || self.paused) {
|
|
9580
9732
|
if (queueTail) {
|
|
9581
9733
|
queueTail.next = current;
|
|
9582
9734
|
queueTail = current;
|
|
@@ -9598,8 +9750,9 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9598
9750
|
current.release = release;
|
|
9599
9751
|
current.value = value;
|
|
9600
9752
|
current.callback = done || noop;
|
|
9753
|
+
current.errorHandler = errorHandler;
|
|
9601
9754
|
|
|
9602
|
-
if (_running
|
|
9755
|
+
if (_running >= _concurrency || self.paused) {
|
|
9603
9756
|
if (queueHead) {
|
|
9604
9757
|
current.next = queueHead;
|
|
9605
9758
|
queueHead = current;
|
|
@@ -9619,7 +9772,7 @@ function fastqueue (context, worker, concurrency) {
|
|
|
9619
9772
|
cache.release(holder);
|
|
9620
9773
|
}
|
|
9621
9774
|
var next = queueHead;
|
|
9622
|
-
if (next) {
|
|
9775
|
+
if (next && _running <= _concurrency) {
|
|
9623
9776
|
if (!self.paused) {
|
|
9624
9777
|
if (queueTail === queueHead) {
|
|
9625
9778
|
queueTail = null;
|
|
@@ -9682,9 +9835,9 @@ function Task () {
|
|
|
9682
9835
|
};
|
|
9683
9836
|
}
|
|
9684
9837
|
|
|
9685
|
-
function queueAsPromised (context, worker,
|
|
9838
|
+
function queueAsPromised (context, worker, _concurrency) {
|
|
9686
9839
|
if (typeof context === 'function') {
|
|
9687
|
-
|
|
9840
|
+
_concurrency = worker;
|
|
9688
9841
|
worker = context;
|
|
9689
9842
|
context = null;
|
|
9690
9843
|
}
|
|
@@ -9696,7 +9849,7 @@ function queueAsPromised (context, worker, concurrency) {
|
|
|
9696
9849
|
}, cb);
|
|
9697
9850
|
}
|
|
9698
9851
|
|
|
9699
|
-
var queue = fastqueue(context, asyncWrapper,
|
|
9852
|
+
var queue = fastqueue(context, asyncWrapper, _concurrency);
|
|
9700
9853
|
|
|
9701
9854
|
var pushCb = queue.push;
|
|
9702
9855
|
var unshiftCb = queue.unshift;
|
|
@@ -10845,8 +10998,6 @@ function assertPatternsInput(input) {
|
|
|
10845
10998
|
}
|
|
10846
10999
|
var out = FastGlob;
|
|
10847
11000
|
|
|
10848
|
-
var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
|
|
10849
|
-
|
|
10850
11001
|
const defaultOptions = {
|
|
10851
11002
|
hostname: "http://localhost/",
|
|
10852
11003
|
dynamicRoutes: [],
|
|
@@ -10922,7 +11073,7 @@ function getRoutes(options) {
|
|
|
10922
11073
|
const ext = typeof options.extensions === "string" ? [options.extensions] : options.extensions;
|
|
10923
11074
|
const strExt = ext.map((e) => `**/*.${e}`);
|
|
10924
11075
|
return [
|
|
10925
|
-
...
|
|
11076
|
+
...out.sync(strExt, { cwd: options.outDir }).map((route) => {
|
|
10926
11077
|
let r = route;
|
|
10927
11078
|
ext.forEach((e) => {
|
|
10928
11079
|
const regex = new RegExp(`index.${e}`, "g");
|
|
@@ -10945,12 +11096,25 @@ function getOptionByRoute(options, route) {
|
|
|
10945
11096
|
return void 0;
|
|
10946
11097
|
}
|
|
10947
11098
|
function getFormattedSitemap(options, routes) {
|
|
10948
|
-
return routes.map((route) =>
|
|
10949
|
-
url
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
11099
|
+
return routes.map((route) => {
|
|
11100
|
+
const url = new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", route), removeMaybeSuffix("/", options.hostname)).href;
|
|
11101
|
+
const formattedSitemap = {
|
|
11102
|
+
url,
|
|
11103
|
+
changefreq: getOptionByRoute(options.changefreq, route) ?? defaultOptions.changefreq,
|
|
11104
|
+
priority: getOptionByRoute(options.priority, route) ?? defaultOptions.priority,
|
|
11105
|
+
lastmod: getOptionByRoute(options.lastmod, route) ?? defaultOptions.lastmod
|
|
11106
|
+
};
|
|
11107
|
+
if (options.i18n) {
|
|
11108
|
+
const languages = options.i18n.languages.map((str) => ({
|
|
11109
|
+
lang: str,
|
|
11110
|
+
url: str === options.i18n?.defaultLanguage ? url : `${url}/${str}`
|
|
11111
|
+
}));
|
|
11112
|
+
return Object.assign(formattedSitemap, {
|
|
11113
|
+
links: options.i18n.defaultLanguage ? [...languages, { lang: "x-default", url }] : languages
|
|
11114
|
+
});
|
|
11115
|
+
}
|
|
11116
|
+
return formattedSitemap;
|
|
11117
|
+
});
|
|
10954
11118
|
}
|
|
10955
11119
|
|
|
10956
11120
|
function generateSitemap(options = {}) {
|
|
@@ -10964,9 +11128,9 @@ function generateSitemap(options = {}) {
|
|
|
10964
11128
|
if (!routes.length)
|
|
10965
11129
|
return;
|
|
10966
11130
|
const formattedSitemap = getFormattedSitemap(resolvedOptions, routes);
|
|
10967
|
-
const stream = new
|
|
11131
|
+
const stream = new dist.SitemapStream();
|
|
10968
11132
|
formattedSitemap.forEach((item) => stream.write(item));
|
|
10969
|
-
|
|
11133
|
+
dist.streamToPromise(stream).then((sitemap) => {
|
|
10970
11134
|
const utfSitemap = sitemap.toString("utf-8");
|
|
10971
11135
|
const formattedSitemap2 = resolvedOptions.readable ? format(utfSitemap) : utfSitemap;
|
|
10972
11136
|
writeFileSync(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
|