vite-plugin-sitemap 0.3.0 → 0.4.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 +7 -0
- package/dist/index.d.ts +13 -2
- package/dist/index.js +454 -492
- package/dist/index.mjs +452 -490
- package/package.json +12 -11
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
2
|
import require$$0 from 'stream';
|
|
3
|
+
import require$$0$1 from 'fs';
|
|
3
4
|
import require$$2 from 'readline';
|
|
4
5
|
import require$$3 from 'url';
|
|
5
|
-
import require$$0$2
|
|
6
|
+
import require$$0$2 from 'path';
|
|
6
7
|
import require$$1 from 'child_process';
|
|
7
8
|
import { createRequire } from 'module';
|
|
8
9
|
import require$$1$1 from 'string_decoder';
|
|
9
10
|
import require$$1$2 from 'zlib';
|
|
10
11
|
import require$$0$3 from 'util';
|
|
12
|
+
import { isAbsolute, resolve, parse as parse$4, join } from 'node:path';
|
|
11
13
|
import require$$2$1 from 'os';
|
|
12
14
|
import require$$0$4 from 'events';
|
|
13
15
|
|
|
14
16
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
15
17
|
|
|
18
|
+
function getDefaultExportFromCjs (x) {
|
|
19
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
var dist = {};
|
|
17
23
|
|
|
18
24
|
var sitemapItemStream = {};
|
|
@@ -400,7 +406,7 @@ var types = {};
|
|
|
400
406
|
IndexTagNames["sitemapindex"] = "sitemapindex";
|
|
401
407
|
IndexTagNames["loc"] = "loc";
|
|
402
408
|
IndexTagNames["lastmod"] = "lastmod";
|
|
403
|
-
})(exports.IndexTagNames || (exports.IndexTagNames = {}));
|
|
409
|
+
})(exports.IndexTagNames || (exports.IndexTagNames = {}));
|
|
404
410
|
} (types));
|
|
405
411
|
|
|
406
412
|
var sitemapXml = {};
|
|
@@ -1116,7 +1122,7 @@ utils$l.normalizeURL = normalizeURL;
|
|
|
1116
1122
|
});
|
|
1117
1123
|
});
|
|
1118
1124
|
}
|
|
1119
|
-
exports.streamToPromise = streamToPromise;
|
|
1125
|
+
exports.streamToPromise = streamToPromise;
|
|
1120
1126
|
} (sitemapStream));
|
|
1121
1127
|
|
|
1122
1128
|
(function (exports) {
|
|
@@ -1221,7 +1227,7 @@ utils$l.normalizeURL = normalizeURL;
|
|
|
1221
1227
|
this.currentSitemap.end(!this.currentSitemapPipeline ? onFinish : undefined);
|
|
1222
1228
|
}
|
|
1223
1229
|
}
|
|
1224
|
-
exports.SitemapAndIndexStream = SitemapAndIndexStream;
|
|
1230
|
+
exports.SitemapAndIndexStream = SitemapAndIndexStream;
|
|
1225
1231
|
} (sitemapIndexStream));
|
|
1226
1232
|
|
|
1227
1233
|
var xmllint = {};
|
|
@@ -2842,7 +2848,7 @@ var sax = {};
|
|
|
2842
2848
|
}
|
|
2843
2849
|
}());
|
|
2844
2850
|
}
|
|
2845
|
-
})(exports);
|
|
2851
|
+
})(exports);
|
|
2846
2852
|
} (sax));
|
|
2847
2853
|
|
|
2848
2854
|
var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
@@ -3626,8 +3632,8 @@ function requireSitemapSimple () {
|
|
|
3626
3632
|
}
|
|
3627
3633
|
};
|
|
3628
3634
|
exports.simpleSitemapAndIndex = simpleSitemapAndIndex;
|
|
3629
|
-
exports.default = exports.simpleSitemapAndIndex;
|
|
3630
|
-
} (sitemapSimple));
|
|
3635
|
+
exports.default = exports.simpleSitemapAndIndex;
|
|
3636
|
+
} (sitemapSimple));
|
|
3631
3637
|
return sitemapSimple;
|
|
3632
3638
|
}
|
|
3633
3639
|
|
|
@@ -3682,472 +3688,434 @@ function requireDist () {
|
|
|
3682
3688
|
Object.defineProperty(exports, "XMLToSitemapIndexStream", { enumerable: true, get: function () { return sitemap_index_parser_1.XMLToSitemapIndexStream; } });
|
|
3683
3689
|
Object.defineProperty(exports, "IndexObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_index_parser_1.IndexObjectStreamToJSON; } });
|
|
3684
3690
|
var sitemap_simple_1 = requireSitemapSimple();
|
|
3685
|
-
Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function () { return sitemap_simple_1.simpleSitemapAndIndex; } });
|
|
3686
|
-
} (dist));
|
|
3691
|
+
Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function () { return sitemap_simple_1.simpleSitemapAndIndex; } });
|
|
3692
|
+
} (dist));
|
|
3687
3693
|
return dist;
|
|
3688
3694
|
}
|
|
3689
3695
|
|
|
3690
3696
|
var distExports = requireDist();
|
|
3691
3697
|
|
|
3692
|
-
|
|
3693
|
-
* @typedef {Object} ParsingOptions
|
|
3694
|
-
* @property {function(node)} filter Returns false to exclude a node. Default is true.
|
|
3695
|
-
*/
|
|
3696
|
-
|
|
3697
|
-
var xmlParserXo;
|
|
3698
|
-
var hasRequiredXmlParserXo;
|
|
3698
|
+
var cjs$1 = {exports: {}};
|
|
3699
3699
|
|
|
3700
|
-
|
|
3701
|
-
if (hasRequiredXmlParserXo) return xmlParserXo;
|
|
3702
|
-
hasRequiredXmlParserXo = 1;
|
|
3703
|
-
/**
|
|
3704
|
-
* Parse the given XML string into an object.
|
|
3705
|
-
*
|
|
3706
|
-
* @param {String} xml
|
|
3707
|
-
* @param {ParsingOptions} [options]
|
|
3708
|
-
* @return {Object}
|
|
3709
|
-
* @api public
|
|
3710
|
-
*/
|
|
3711
|
-
function parse(xml, options = {}) {
|
|
3700
|
+
var cjs = {exports: {}};
|
|
3712
3701
|
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
function nextChild() {
|
|
3716
|
-
return tag() || content() || comment() || cdata();
|
|
3717
|
-
}
|
|
3702
|
+
cjs.exports;
|
|
3718
3703
|
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3704
|
+
(function (module, exports) {
|
|
3705
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3706
|
+
exports.ParsingError = void 0;
|
|
3707
|
+
class ParsingError extends Error {
|
|
3708
|
+
constructor(message, cause) {
|
|
3709
|
+
super(message);
|
|
3710
|
+
this.cause = cause;
|
|
3722
3711
|
}
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3712
|
+
}
|
|
3713
|
+
exports.ParsingError = ParsingError;
|
|
3714
|
+
let parsingState;
|
|
3715
|
+
function nextChild() {
|
|
3716
|
+
return element(false) || text() || comment() || cdata();
|
|
3717
|
+
}
|
|
3718
|
+
function nextRootChild() {
|
|
3719
|
+
match(/\s*/);
|
|
3720
|
+
return element(true) || comment() || doctype() || processingInstruction(false);
|
|
3721
|
+
}
|
|
3722
|
+
function parseDocument() {
|
|
3723
|
+
const declaration = processingInstruction(true);
|
|
3724
|
+
const children = [];
|
|
3725
|
+
let documentRootNode;
|
|
3726
|
+
let child = nextRootChild();
|
|
3727
|
+
while (child) {
|
|
3728
|
+
if (child.node.type === 'Element') {
|
|
3729
|
+
if (documentRootNode) {
|
|
3730
|
+
throw new Error('Found multiple root nodes');
|
|
3740
3731
|
}
|
|
3741
|
-
|
|
3742
|
-
child = nextRootChild();
|
|
3732
|
+
documentRootNode = child.node;
|
|
3743
3733
|
}
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
throw new Error('Failed to parse XML');
|
|
3734
|
+
if (!child.excluded) {
|
|
3735
|
+
children.push(child.node);
|
|
3747
3736
|
}
|
|
3748
|
-
|
|
3749
|
-
return {
|
|
3750
|
-
declaration: decl ? decl.node : null,
|
|
3751
|
-
root: documentRootNode,
|
|
3752
|
-
children
|
|
3753
|
-
};
|
|
3737
|
+
child = nextRootChild();
|
|
3754
3738
|
}
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
return processingInstruction(true);
|
|
3739
|
+
if (!documentRootNode) {
|
|
3740
|
+
throw new ParsingError('Failed to parse XML', 'Root Element not found');
|
|
3758
3741
|
}
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3742
|
+
if (parsingState.xml.length !== 0) {
|
|
3743
|
+
throw new ParsingError('Failed to parse XML', 'Not Well-Formed XML');
|
|
3744
|
+
}
|
|
3745
|
+
return {
|
|
3746
|
+
declaration: declaration ? declaration.node : null,
|
|
3747
|
+
root: documentRootNode,
|
|
3748
|
+
children
|
|
3749
|
+
};
|
|
3750
|
+
}
|
|
3751
|
+
function processingInstruction(matchDeclaration) {
|
|
3752
|
+
const m = matchDeclaration ? match(/^<\?(xml)\s*/) : match(/^<\?([\w-:.]+)\s*/);
|
|
3753
|
+
if (!m)
|
|
3754
|
+
return;
|
|
3755
|
+
// tag
|
|
3756
|
+
const node = {
|
|
3757
|
+
name: m[1],
|
|
3758
|
+
type: 'ProcessingInstruction',
|
|
3759
|
+
attributes: {}
|
|
3760
|
+
};
|
|
3761
|
+
// attributes
|
|
3762
|
+
while (!(eos() || is('?>'))) {
|
|
3763
|
+
const attr = attribute();
|
|
3764
|
+
if (attr) {
|
|
3775
3765
|
node.attributes[attr.name] = attr.value;
|
|
3776
3766
|
}
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
return {
|
|
3781
|
-
excluded: matchDeclaration ? false : options.filter(node) === false,
|
|
3782
|
-
node
|
|
3783
|
-
};
|
|
3767
|
+
else {
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3784
3770
|
}
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3771
|
+
match(/\?>/);
|
|
3772
|
+
return {
|
|
3773
|
+
excluded: matchDeclaration ? false : parsingState.options.filter(node) === false,
|
|
3774
|
+
node
|
|
3775
|
+
};
|
|
3776
|
+
}
|
|
3777
|
+
function element(matchRoot) {
|
|
3778
|
+
const m = match(/^<([^?!</>\s]+)\s*/);
|
|
3779
|
+
if (!m)
|
|
3780
|
+
return;
|
|
3781
|
+
// name
|
|
3782
|
+
const node = {
|
|
3783
|
+
type: 'Element',
|
|
3784
|
+
name: m[1],
|
|
3785
|
+
attributes: {},
|
|
3786
|
+
children: []
|
|
3787
|
+
};
|
|
3788
|
+
const excluded = matchRoot ? false : parsingState.options.filter(node) === false;
|
|
3789
|
+
// attributes
|
|
3790
|
+
while (!(eos() || is('>') || is('?>') || is('/>'))) {
|
|
3791
|
+
const attr = attribute();
|
|
3792
|
+
if (attr) {
|
|
3802
3793
|
node.attributes[attr.name] = attr.value;
|
|
3803
3794
|
}
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
// self closing tag
|
|
3808
|
-
if (match(/^\s*\/>/)) {
|
|
3809
|
-
node.children = null;
|
|
3810
|
-
return {
|
|
3811
|
-
excluded,
|
|
3812
|
-
node
|
|
3813
|
-
};
|
|
3814
|
-
}
|
|
3815
|
-
|
|
3816
|
-
match(/\??>/);
|
|
3817
|
-
|
|
3818
|
-
if (!excluded) {
|
|
3819
|
-
// children
|
|
3820
|
-
let child = nextChild();
|
|
3821
|
-
while (child) {
|
|
3822
|
-
if (!child.excluded) {
|
|
3823
|
-
node.children.push(child.node);
|
|
3824
|
-
}
|
|
3825
|
-
child = nextChild();
|
|
3826
|
-
}
|
|
3795
|
+
else {
|
|
3796
|
+
return;
|
|
3827
3797
|
}
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3798
|
+
}
|
|
3799
|
+
// self closing tag
|
|
3800
|
+
if (match(/^\s*\/>/)) {
|
|
3801
|
+
node.children = null;
|
|
3832
3802
|
return {
|
|
3833
3803
|
excluded,
|
|
3834
3804
|
node
|
|
3835
3805
|
};
|
|
3836
3806
|
}
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
content: m[0]
|
|
3844
|
-
};
|
|
3845
|
-
return {
|
|
3846
|
-
excluded: options.filter(node) === false,
|
|
3847
|
-
node
|
|
3848
|
-
};
|
|
3807
|
+
match(/\??>/);
|
|
3808
|
+
// children
|
|
3809
|
+
let child = nextChild();
|
|
3810
|
+
while (child) {
|
|
3811
|
+
if (!child.excluded) {
|
|
3812
|
+
node.children.push(child.node);
|
|
3849
3813
|
}
|
|
3814
|
+
child = nextChild();
|
|
3850
3815
|
}
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3816
|
+
// closing
|
|
3817
|
+
match(/^<\/\s*[\w-:.\u00C0-\u00FF]+>/);
|
|
3818
|
+
return {
|
|
3819
|
+
excluded,
|
|
3820
|
+
node
|
|
3821
|
+
};
|
|
3822
|
+
}
|
|
3823
|
+
function doctype() {
|
|
3824
|
+
const m = match(/^<!DOCTYPE\s+[^>]*>/);
|
|
3825
|
+
if (m) {
|
|
3826
|
+
const node = {
|
|
3827
|
+
type: 'DocumentType',
|
|
3828
|
+
content: m[0]
|
|
3829
|
+
};
|
|
3830
|
+
return {
|
|
3831
|
+
excluded: parsingState.options.filter(node) === false,
|
|
3832
|
+
node
|
|
3833
|
+
};
|
|
3868
3834
|
}
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3835
|
+
}
|
|
3836
|
+
function cdata() {
|
|
3837
|
+
if (parsingState.xml.startsWith('<![CDATA[')) {
|
|
3838
|
+
const endPositionStart = parsingState.xml.indexOf(']]>');
|
|
3839
|
+
if (endPositionStart > -1) {
|
|
3840
|
+
const endPositionFinish = endPositionStart + 3;
|
|
3873
3841
|
const node = {
|
|
3874
|
-
type: '
|
|
3875
|
-
content:
|
|
3842
|
+
type: 'CDATA',
|
|
3843
|
+
content: parsingState.xml.substring(0, endPositionFinish)
|
|
3876
3844
|
};
|
|
3845
|
+
parsingState.xml = parsingState.xml.slice(endPositionFinish);
|
|
3877
3846
|
return {
|
|
3878
|
-
excluded: options.filter(node) === false,
|
|
3847
|
+
excluded: parsingState.options.filter(node) === false,
|
|
3879
3848
|
node
|
|
3880
3849
|
};
|
|
3881
3850
|
}
|
|
3882
3851
|
}
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
}
|
|
3852
|
+
}
|
|
3853
|
+
function comment() {
|
|
3854
|
+
const m = match(/^<!--[\s\S]*?-->/);
|
|
3855
|
+
if (m) {
|
|
3856
|
+
const node = {
|
|
3857
|
+
type: 'Comment',
|
|
3858
|
+
content: m[0]
|
|
3859
|
+
};
|
|
3860
|
+
return {
|
|
3861
|
+
excluded: parsingState.options.filter(node) === false,
|
|
3862
|
+
node
|
|
3863
|
+
};
|
|
3896
3864
|
}
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3865
|
+
}
|
|
3866
|
+
function text() {
|
|
3867
|
+
const m = match(/^([^<]+)/);
|
|
3868
|
+
if (m) {
|
|
3869
|
+
const node = {
|
|
3870
|
+
type: 'Text',
|
|
3871
|
+
content: m[1]
|
|
3872
|
+
};
|
|
3873
|
+
return {
|
|
3874
|
+
excluded: parsingState.options.filter(node) === false,
|
|
3875
|
+
node
|
|
3876
|
+
};
|
|
3902
3877
|
}
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3878
|
+
}
|
|
3879
|
+
function attribute() {
|
|
3880
|
+
const m = match(/([^=]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)\s*/);
|
|
3881
|
+
if (m) {
|
|
3882
|
+
return {
|
|
3883
|
+
name: m[1].trim(),
|
|
3884
|
+
value: stripQuotes(m[2].trim())
|
|
3885
|
+
};
|
|
3909
3886
|
}
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3887
|
+
}
|
|
3888
|
+
function stripQuotes(val) {
|
|
3889
|
+
return val.replace(/^['"]|['"]$/g, '');
|
|
3890
|
+
}
|
|
3891
|
+
/**
|
|
3892
|
+
* Match `re` and advance the string.
|
|
3893
|
+
*/
|
|
3894
|
+
function match(re) {
|
|
3895
|
+
const m = parsingState.xml.match(re);
|
|
3896
|
+
if (m) {
|
|
3897
|
+
parsingState.xml = parsingState.xml.slice(m[0].length);
|
|
3918
3898
|
return m;
|
|
3919
3899
|
}
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3900
|
+
}
|
|
3901
|
+
/**
|
|
3902
|
+
* End-of-source.
|
|
3903
|
+
*/
|
|
3904
|
+
function eos() {
|
|
3905
|
+
return 0 === parsingState.xml.length;
|
|
3906
|
+
}
|
|
3907
|
+
/**
|
|
3908
|
+
* Check for `prefix`.
|
|
3909
|
+
*/
|
|
3910
|
+
function is(prefix) {
|
|
3911
|
+
return 0 === parsingState.xml.indexOf(prefix);
|
|
3912
|
+
}
|
|
3913
|
+
/**
|
|
3914
|
+
* Parse the given XML string into an object.
|
|
3915
|
+
*/
|
|
3916
|
+
function parseXml(xml, options = {}) {
|
|
3935
3917
|
xml = xml.trim();
|
|
3936
|
-
|
|
3937
|
-
|
|
3918
|
+
const filter = options.filter || (() => true);
|
|
3919
|
+
parsingState = {
|
|
3920
|
+
xml,
|
|
3921
|
+
options: Object.assign(Object.assign({}, options), { filter })
|
|
3922
|
+
};
|
|
3923
|
+
return parseDocument();
|
|
3938
3924
|
}
|
|
3925
|
+
{
|
|
3926
|
+
module.exports = parseXml;
|
|
3927
|
+
}
|
|
3928
|
+
exports.default = parseXml;
|
|
3929
|
+
|
|
3930
|
+
} (cjs, cjs.exports));
|
|
3939
3931
|
|
|
3940
|
-
|
|
3941
|
-
return xmlParserXo;
|
|
3942
|
-
}
|
|
3943
|
-
|
|
3944
|
-
/**
|
|
3945
|
-
* @typedef {Object} XMLFormatterOptions
|
|
3946
|
-
* @property {String} [indentation=' '] The value used for indentation
|
|
3947
|
-
* @property {function(node): boolean} [filter] Return false to exclude the node.
|
|
3948
|
-
* @property {Boolean} [collapseContent=false] True to keep content in the same line as the element. Only works if element contains at least one text node
|
|
3949
|
-
* @property {String} [lineSeparator='\r\n'] The line separator to use
|
|
3950
|
-
* @property {String} [whiteSpaceAtEndOfSelfclosingTag=false] to either end ad self closing tag with `<tag/>` or `<tag />`
|
|
3951
|
-
*/
|
|
3952
|
-
|
|
3953
|
-
/**
|
|
3954
|
-
* @typedef {Object} XMLFormatterState
|
|
3955
|
-
* @param {String} content
|
|
3956
|
-
* @param {Number} level
|
|
3957
|
-
* @param {XMLFormatterOptions} options
|
|
3958
|
-
*/
|
|
3959
|
-
|
|
3960
|
-
/**
|
|
3961
|
-
* @param {XMLFormatterState} state
|
|
3962
|
-
* @return {void}
|
|
3963
|
-
*/
|
|
3964
|
-
function newLine(state) {
|
|
3965
|
-
if (!state.options.indentation && !state.options.lineSeparator) return;
|
|
3966
|
-
state.content += state.options.lineSeparator;
|
|
3967
|
-
let i;
|
|
3968
|
-
for (i = 0; i < state.level; i++) {
|
|
3969
|
-
state.content += state.options.indentation;
|
|
3970
|
-
}
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3973
|
-
/**
|
|
3974
|
-
* @param {XMLFormatterState} state
|
|
3975
|
-
* @param {String} content
|
|
3976
|
-
* @return {void}
|
|
3977
|
-
*/
|
|
3978
|
-
function appendContent(state, content) {
|
|
3979
|
-
state.content += content;
|
|
3980
|
-
}
|
|
3981
|
-
|
|
3982
|
-
/**
|
|
3983
|
-
* @param {Object} node
|
|
3984
|
-
* @param {XMLFormatterState} state
|
|
3985
|
-
* @param {Boolean} preserveSpace
|
|
3986
|
-
* @return {void}
|
|
3987
|
-
*/
|
|
3988
|
-
function processNode(node, state, preserveSpace) {
|
|
3989
|
-
if (typeof node.content === 'string') {
|
|
3990
|
-
processContentNode(node, state, preserveSpace);
|
|
3991
|
-
} else if (node.type === 'Element') {
|
|
3992
|
-
processElementNode(node, state, preserveSpace);
|
|
3993
|
-
} else if (node.type === 'ProcessingInstruction') {
|
|
3994
|
-
processProcessingIntruction(node, state);
|
|
3995
|
-
} else {
|
|
3996
|
-
throw new Error('Unknown node type: ' + node.type);
|
|
3997
|
-
}
|
|
3998
|
-
}
|
|
3999
|
-
|
|
4000
|
-
/**
|
|
4001
|
-
* @param {Object} node
|
|
4002
|
-
* @param {XMLFormatterState} state
|
|
4003
|
-
* @param {Boolean} preserveSpace
|
|
4004
|
-
* @return {void}
|
|
4005
|
-
*/
|
|
4006
|
-
function processContentNode(node, state, preserveSpace) {
|
|
4007
|
-
if (!preserveSpace) {
|
|
4008
|
-
node.content = node.content.trim();
|
|
4009
|
-
}
|
|
4010
|
-
if (node.content.length > 0) {
|
|
4011
|
-
if (!preserveSpace && state.content.length > 0) {
|
|
4012
|
-
newLine(state);
|
|
4013
|
-
}
|
|
4014
|
-
appendContent(state, node.content);
|
|
4015
|
-
}
|
|
4016
|
-
}
|
|
4017
|
-
|
|
4018
|
-
/**
|
|
4019
|
-
* @param {Object} node
|
|
4020
|
-
* @param {XMLFormatterState} state
|
|
4021
|
-
* @param {Boolean} preserveSpace
|
|
4022
|
-
* @return {void}
|
|
4023
|
-
*/
|
|
4024
|
-
function processElementNode(node, state, preserveSpace) {
|
|
4025
|
-
if (!preserveSpace && state.content.length > 0) {
|
|
4026
|
-
newLine(state);
|
|
4027
|
-
}
|
|
4028
|
-
|
|
4029
|
-
appendContent(state, '<' + node.name);
|
|
4030
|
-
processAttributes(state, node.attributes);
|
|
4031
|
-
|
|
4032
|
-
if (node.children === null) {
|
|
4033
|
-
const selfClosingNodeClosingTag = state.options.whiteSpaceAtEndOfSelfclosingTag ? ' />' : '/>';
|
|
4034
|
-
// self-closing node
|
|
4035
|
-
appendContent(state, selfClosingNodeClosingTag);
|
|
4036
|
-
} else if (node.children.length === 0) {
|
|
4037
|
-
// empty node
|
|
4038
|
-
appendContent(state, '></' + node.name + '>');
|
|
4039
|
-
} else {
|
|
4040
|
-
|
|
4041
|
-
appendContent(state, '>');
|
|
4042
|
-
|
|
4043
|
-
state.level++;
|
|
4044
|
-
|
|
4045
|
-
let nodePreserveSpace = node.attributes['xml:space'] === 'preserve';
|
|
4046
|
-
|
|
4047
|
-
if (!nodePreserveSpace && state.options.collapseContent) {
|
|
4048
|
-
let containsTextNodes = false;
|
|
4049
|
-
let containsTextNodesWithLineBreaks = false;
|
|
4050
|
-
let containsNonTextNodes = false;
|
|
4051
|
-
|
|
4052
|
-
node.children.forEach(function(child, index) {
|
|
4053
|
-
if (child.type === 'Text') {
|
|
4054
|
-
if (child.content.includes('\n')) {
|
|
4055
|
-
containsTextNodesWithLineBreaks = true;
|
|
4056
|
-
child.content = child.content.trim();
|
|
4057
|
-
} else if (index === 0 || index === node.children.length - 1) {
|
|
4058
|
-
if (child.content.trim().length === 0) {
|
|
4059
|
-
// If the text node is at the start or end and is empty, it should be ignored when formatting
|
|
4060
|
-
child.content = '';
|
|
4061
|
-
}
|
|
4062
|
-
}
|
|
4063
|
-
if (child.content.length > 0) {
|
|
4064
|
-
containsTextNodes = true;
|
|
4065
|
-
}
|
|
4066
|
-
} else if (child.type === 'CDATA') {
|
|
4067
|
-
containsTextNodes = true;
|
|
4068
|
-
} else {
|
|
4069
|
-
containsNonTextNodes = true;
|
|
4070
|
-
}
|
|
4071
|
-
});
|
|
4072
|
-
|
|
4073
|
-
if (containsTextNodes && (!containsNonTextNodes || !containsTextNodesWithLineBreaks)) {
|
|
4074
|
-
nodePreserveSpace = true;
|
|
4075
|
-
}
|
|
4076
|
-
}
|
|
3932
|
+
var cjsExports$1 = cjs.exports;
|
|
4077
3933
|
|
|
4078
|
-
|
|
4079
|
-
processNode(child, state, preserveSpace || nodePreserveSpace, state.options);
|
|
4080
|
-
});
|
|
3934
|
+
cjs$1.exports;
|
|
4081
3935
|
|
|
4082
|
-
|
|
3936
|
+
(function (module, exports) {
|
|
3937
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
3938
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3939
|
+
};
|
|
3940
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3941
|
+
const xml_parser_xo_1 = __importDefault(cjsExports$1);
|
|
3942
|
+
function newLine(state) {
|
|
3943
|
+
if (!state.options.indentation && !state.options.lineSeparator)
|
|
3944
|
+
return;
|
|
3945
|
+
state.content += state.options.lineSeparator;
|
|
3946
|
+
let i;
|
|
3947
|
+
for (i = 0; i < state.level; i++) {
|
|
3948
|
+
state.content += state.options.indentation;
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
function appendContent(state, content) {
|
|
3952
|
+
state.content += content;
|
|
3953
|
+
}
|
|
3954
|
+
function processNode(node, state, preserveSpace) {
|
|
3955
|
+
if (typeof node.content === 'string') {
|
|
3956
|
+
processContent(node.content, state, preserveSpace);
|
|
3957
|
+
}
|
|
3958
|
+
else if (node.type === 'Element') {
|
|
3959
|
+
processElementNode(node, state, preserveSpace);
|
|
3960
|
+
}
|
|
3961
|
+
else if (node.type === 'ProcessingInstruction') {
|
|
3962
|
+
processProcessingIntruction(node, state);
|
|
3963
|
+
}
|
|
3964
|
+
else {
|
|
3965
|
+
throw new Error('Unknown node type: ' + node.type);
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
function processContent(content, state, preserveSpace) {
|
|
3969
|
+
if (!preserveSpace) {
|
|
3970
|
+
const trimmedContent = content.trim();
|
|
3971
|
+
if (state.options.lineSeparator) {
|
|
3972
|
+
content = trimmedContent;
|
|
3973
|
+
}
|
|
3974
|
+
else if (trimmedContent.length === 0) {
|
|
3975
|
+
content = trimmedContent;
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3978
|
+
if (content.length > 0) {
|
|
3979
|
+
if (!preserveSpace && state.content.length > 0) {
|
|
3980
|
+
newLine(state);
|
|
3981
|
+
}
|
|
3982
|
+
appendContent(state, content);
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
function processElementNode(node, state, preserveSpace) {
|
|
3986
|
+
if (!preserveSpace && state.content.length > 0) {
|
|
3987
|
+
newLine(state);
|
|
3988
|
+
}
|
|
3989
|
+
appendContent(state, '<' + node.name);
|
|
3990
|
+
processAttributes(state, node.attributes);
|
|
3991
|
+
if (node.children === null) {
|
|
3992
|
+
const selfClosingNodeClosingTag = state.options.whiteSpaceAtEndOfSelfclosingTag ? ' />' : '/>';
|
|
3993
|
+
// self-closing node
|
|
3994
|
+
appendContent(state, selfClosingNodeClosingTag);
|
|
3995
|
+
}
|
|
3996
|
+
else if (node.children.length === 0) {
|
|
3997
|
+
// empty node
|
|
3998
|
+
appendContent(state, '></' + node.name + '>');
|
|
3999
|
+
}
|
|
4000
|
+
else {
|
|
4001
|
+
const nodeChildren = node.children;
|
|
4002
|
+
appendContent(state, '>');
|
|
4003
|
+
state.level++;
|
|
4004
|
+
let nodePreserveSpace = node.attributes['xml:space'] === 'preserve';
|
|
4005
|
+
if (!nodePreserveSpace && state.options.collapseContent) {
|
|
4006
|
+
let containsTextNodes = false;
|
|
4007
|
+
let containsTextNodesWithLineBreaks = false;
|
|
4008
|
+
let containsNonTextNodes = false;
|
|
4009
|
+
nodeChildren.forEach(function (child, index) {
|
|
4010
|
+
if (child.type === 'Text') {
|
|
4011
|
+
if (child.content.includes('\n')) {
|
|
4012
|
+
containsTextNodesWithLineBreaks = true;
|
|
4013
|
+
child.content = child.content.trim();
|
|
4014
|
+
}
|
|
4015
|
+
else if (index === 0 || index === nodeChildren.length - 1) {
|
|
4016
|
+
if (child.content.trim().length === 0) {
|
|
4017
|
+
// If the text node is at the start or end and is empty, it should be ignored when formatting
|
|
4018
|
+
child.content = '';
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
if (child.content.trim().length > 0) {
|
|
4022
|
+
containsTextNodes = true;
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
else if (child.type === 'CDATA') {
|
|
4026
|
+
containsTextNodes = true;
|
|
4027
|
+
}
|
|
4028
|
+
else {
|
|
4029
|
+
containsNonTextNodes = true;
|
|
4030
|
+
}
|
|
4031
|
+
});
|
|
4032
|
+
if (containsTextNodes && (!containsNonTextNodes || !containsTextNodesWithLineBreaks)) {
|
|
4033
|
+
nodePreserveSpace = true;
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
nodeChildren.forEach(function (child) {
|
|
4037
|
+
processNode(child, state, preserveSpace || nodePreserveSpace);
|
|
4038
|
+
});
|
|
4039
|
+
state.level--;
|
|
4040
|
+
if (!preserveSpace && !nodePreserveSpace) {
|
|
4041
|
+
newLine(state);
|
|
4042
|
+
}
|
|
4043
|
+
appendContent(state, '</' + node.name + '>');
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
function processAttributes(state, attributes) {
|
|
4047
|
+
Object.keys(attributes).forEach(function (attr) {
|
|
4048
|
+
const escaped = attributes[attr].replace(/"/g, '"');
|
|
4049
|
+
appendContent(state, ' ' + attr + '="' + escaped + '"');
|
|
4050
|
+
});
|
|
4051
|
+
}
|
|
4052
|
+
function processProcessingIntruction(node, state) {
|
|
4053
|
+
if (state.content.length > 0) {
|
|
4054
|
+
newLine(state);
|
|
4055
|
+
}
|
|
4056
|
+
appendContent(state, '<?' + node.name);
|
|
4057
|
+
processAttributes(state, node.attributes);
|
|
4058
|
+
appendContent(state, '?>');
|
|
4059
|
+
}
|
|
4060
|
+
/**
|
|
4061
|
+
* Converts the given XML into human readable format.
|
|
4062
|
+
*/
|
|
4063
|
+
function formatXml(xml, options = {}) {
|
|
4064
|
+
options.indentation = 'indentation' in options ? options.indentation : ' ';
|
|
4065
|
+
options.collapseContent = options.collapseContent === true;
|
|
4066
|
+
options.lineSeparator = 'lineSeparator' in options ? options.lineSeparator : '\r\n';
|
|
4067
|
+
options.whiteSpaceAtEndOfSelfclosingTag = options.whiteSpaceAtEndOfSelfclosingTag === true;
|
|
4068
|
+
options.throwOnFailure = options.throwOnFailure !== false;
|
|
4069
|
+
try {
|
|
4070
|
+
const parsedXml = (0, xml_parser_xo_1.default)(xml, { filter: options.filter });
|
|
4071
|
+
const state = { content: '', level: 0, options: options };
|
|
4072
|
+
if (parsedXml.declaration) {
|
|
4073
|
+
processProcessingIntruction(parsedXml.declaration, state);
|
|
4074
|
+
}
|
|
4075
|
+
parsedXml.children.forEach(function (child) {
|
|
4076
|
+
processNode(child, state, false);
|
|
4077
|
+
});
|
|
4078
|
+
if (!options.lineSeparator) {
|
|
4079
|
+
return state.content;
|
|
4080
|
+
}
|
|
4081
|
+
return state.content
|
|
4082
|
+
.replace(/\r\n/g, '\n')
|
|
4083
|
+
.replace(/\n/g, options.lineSeparator);
|
|
4084
|
+
}
|
|
4085
|
+
catch (err) {
|
|
4086
|
+
if (options.throwOnFailure) {
|
|
4087
|
+
throw err;
|
|
4088
|
+
}
|
|
4089
|
+
return xml;
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
formatXml.minify = (xml, options = {}) => {
|
|
4093
|
+
return formatXml(xml, Object.assign(Object.assign({}, options), { indentation: '', lineSeparator: '' }));
|
|
4094
|
+
};
|
|
4095
|
+
{
|
|
4096
|
+
module.exports = formatXml;
|
|
4097
|
+
}
|
|
4098
|
+
exports.default = formatXml;
|
|
4099
|
+
|
|
4100
|
+
} (cjs$1, cjs$1.exports));
|
|
4083
4101
|
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
}
|
|
4087
|
-
appendContent(state, '</' + node.name + '>');
|
|
4088
|
-
}
|
|
4089
|
-
}
|
|
4102
|
+
var cjsExports = cjs$1.exports;
|
|
4103
|
+
var format = /*@__PURE__*/getDefaultExportFromCjs(cjsExports);
|
|
4090
4104
|
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
* @param {Record<String, String>} attributes
|
|
4094
|
-
* @return {void}
|
|
4095
|
-
*/
|
|
4096
|
-
function processAttributes(state, attributes) {
|
|
4097
|
-
Object.keys(attributes).forEach(function(attr) {
|
|
4098
|
-
const escaped = attributes[attr].replace(/"/g, '"');
|
|
4099
|
-
appendContent(state, ' ' + attr + '="' + escaped + '"');
|
|
4100
|
-
});
|
|
4105
|
+
function slash$1(str) {
|
|
4106
|
+
return str.replace(/\\/g, "/");
|
|
4101
4107
|
}
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
* @return {void}
|
|
4107
|
-
*/
|
|
4108
|
-
function processProcessingIntruction(node, state) {
|
|
4109
|
-
if (state.content.length > 0) {
|
|
4110
|
-
newLine(state);
|
|
4111
|
-
}
|
|
4112
|
-
appendContent(state, '<?' + node.name);
|
|
4113
|
-
processAttributes(state, node.attributes);
|
|
4114
|
-
appendContent(state, '?>');
|
|
4108
|
+
function ensurePrefix(prefix, str) {
|
|
4109
|
+
if (!str.startsWith(prefix))
|
|
4110
|
+
return prefix + str;
|
|
4111
|
+
return str;
|
|
4115
4112
|
}
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
*
|
|
4121
|
-
* @param {String} xml
|
|
4122
|
-
* @param {XMLFormatterOptions} options
|
|
4123
|
-
* @returns {string}
|
|
4124
|
-
*/
|
|
4125
|
-
function format(xml, options = {}) {
|
|
4126
|
-
options.indentation = 'indentation' in options ? options.indentation : ' ';
|
|
4127
|
-
options.collapseContent = options.collapseContent === true;
|
|
4128
|
-
options.lineSeparator = 'lineSeparator' in options ? options.lineSeparator : '\r\n';
|
|
4129
|
-
options.whiteSpaceAtEndOfSelfclosingTag = !!options.whiteSpaceAtEndOfSelfclosingTag;
|
|
4130
|
-
|
|
4131
|
-
const parser = requireXmlParserXo();
|
|
4132
|
-
const parsedXml = parser(xml, {filter: options.filter});
|
|
4133
|
-
const state = {content: '', level: 0, options: options};
|
|
4134
|
-
|
|
4135
|
-
if (parsedXml.declaration) {
|
|
4136
|
-
processProcessingIntruction(parsedXml.declaration, state);
|
|
4137
|
-
}
|
|
4138
|
-
|
|
4139
|
-
parsedXml.children.forEach(function(child) {
|
|
4140
|
-
processNode(child, state, false);
|
|
4141
|
-
});
|
|
4142
|
-
|
|
4143
|
-
return state.content
|
|
4144
|
-
.replace(/\r\n/g, '\n')
|
|
4145
|
-
.replace(/\n/g, options.lineSeparator);
|
|
4113
|
+
function ensureSuffix(suffix, str) {
|
|
4114
|
+
if (!str.endsWith(suffix))
|
|
4115
|
+
return str + suffix;
|
|
4116
|
+
return str;
|
|
4146
4117
|
}
|
|
4147
4118
|
|
|
4148
|
-
|
|
4149
|
-
var xmlFormatter = format;
|
|
4150
|
-
|
|
4151
4119
|
var tasks = {};
|
|
4152
4120
|
|
|
4153
4121
|
var utils$k = {};
|
|
@@ -4419,7 +4387,7 @@ var isGlob = isGlob$1;
|
|
|
4419
4387
|
var pathPosixDirname = require$$0$2.posix.dirname;
|
|
4420
4388
|
var isWin32 = require$$2$1.platform() === 'win32';
|
|
4421
4389
|
|
|
4422
|
-
var slash
|
|
4390
|
+
var slash = '/';
|
|
4423
4391
|
var backslash = /\\/g;
|
|
4424
4392
|
var enclosure = /[\{\[].*[\}\]]$/;
|
|
4425
4393
|
var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
|
|
@@ -4435,13 +4403,13 @@ var globParent$1 = function globParent(str, opts) {
|
|
|
4435
4403
|
var options = Object.assign({ flipBackslashes: true }, opts);
|
|
4436
4404
|
|
|
4437
4405
|
// flip windows path separators
|
|
4438
|
-
if (options.flipBackslashes && isWin32 && str.indexOf(slash
|
|
4439
|
-
str = str.replace(backslash, slash
|
|
4406
|
+
if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) {
|
|
4407
|
+
str = str.replace(backslash, slash);
|
|
4440
4408
|
}
|
|
4441
4409
|
|
|
4442
4410
|
// special case for strings ending in enclosure containing path separator
|
|
4443
4411
|
if (enclosure.test(str)) {
|
|
4444
|
-
str += slash
|
|
4412
|
+
str += slash;
|
|
4445
4413
|
}
|
|
4446
4414
|
|
|
4447
4415
|
// preserves full path in case of trailing path separator
|
|
@@ -4569,7 +4537,7 @@ var utils$j = {};
|
|
|
4569
4537
|
};
|
|
4570
4538
|
flat(args);
|
|
4571
4539
|
return result;
|
|
4572
|
-
};
|
|
4540
|
+
};
|
|
4573
4541
|
} (utils$j));
|
|
4574
4542
|
|
|
4575
4543
|
const utils$i = utils$j;
|
|
@@ -5876,8 +5844,6 @@ braces$1.create = (input, options = {}) => {
|
|
|
5876
5844
|
|
|
5877
5845
|
var braces_1 = braces$1;
|
|
5878
5846
|
|
|
5879
|
-
var picomatch$2 = {exports: {}};
|
|
5880
|
-
|
|
5881
5847
|
var utils$f = {};
|
|
5882
5848
|
|
|
5883
5849
|
const path$7 = require$$0$2;
|
|
@@ -6121,7 +6087,7 @@ var constants$3 = {
|
|
|
6121
6087
|
output = `(?:^(?!${output}).*$)`;
|
|
6122
6088
|
}
|
|
6123
6089
|
return output;
|
|
6124
|
-
};
|
|
6090
|
+
};
|
|
6125
6091
|
} (utils$f));
|
|
6126
6092
|
|
|
6127
6093
|
const utils$e = utils$f;
|
|
@@ -7633,9 +7599,9 @@ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
|
7633
7599
|
* @api public
|
|
7634
7600
|
*/
|
|
7635
7601
|
|
|
7636
|
-
const picomatch$
|
|
7602
|
+
const picomatch$2 = (glob, options, returnState = false) => {
|
|
7637
7603
|
if (Array.isArray(glob)) {
|
|
7638
|
-
const fns = glob.map(input => picomatch$
|
|
7604
|
+
const fns = glob.map(input => picomatch$2(input, options, returnState));
|
|
7639
7605
|
const arrayMatcher = str => {
|
|
7640
7606
|
for (const isMatch of fns) {
|
|
7641
7607
|
const state = isMatch(str);
|
|
@@ -7655,8 +7621,8 @@ const picomatch$1 = (glob, options, returnState = false) => {
|
|
|
7655
7621
|
const opts = options || {};
|
|
7656
7622
|
const posix = utils$c.isWindows(options);
|
|
7657
7623
|
const regex = isState
|
|
7658
|
-
? picomatch$
|
|
7659
|
-
: picomatch$
|
|
7624
|
+
? picomatch$2.compileRe(glob, options)
|
|
7625
|
+
: picomatch$2.makeRe(glob, options, false, true);
|
|
7660
7626
|
|
|
7661
7627
|
const state = regex.state;
|
|
7662
7628
|
delete regex.state;
|
|
@@ -7664,11 +7630,11 @@ const picomatch$1 = (glob, options, returnState = false) => {
|
|
|
7664
7630
|
let isIgnored = () => false;
|
|
7665
7631
|
if (opts.ignore) {
|
|
7666
7632
|
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
7667
|
-
isIgnored = picomatch$
|
|
7633
|
+
isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
|
|
7668
7634
|
}
|
|
7669
7635
|
|
|
7670
7636
|
const matcher = (input, returnObject = false) => {
|
|
7671
|
-
const { isMatch, match, output } = picomatch$
|
|
7637
|
+
const { isMatch, match, output } = picomatch$2.test(input, regex, options, { glob, posix });
|
|
7672
7638
|
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
7673
7639
|
|
|
7674
7640
|
if (typeof opts.onResult === 'function') {
|
|
@@ -7718,7 +7684,7 @@ const picomatch$1 = (glob, options, returnState = false) => {
|
|
|
7718
7684
|
* @api public
|
|
7719
7685
|
*/
|
|
7720
7686
|
|
|
7721
|
-
picomatch$
|
|
7687
|
+
picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
7722
7688
|
if (typeof input !== 'string') {
|
|
7723
7689
|
throw new TypeError('Expected input to be a string');
|
|
7724
7690
|
}
|
|
@@ -7739,7 +7705,7 @@ picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
|
|
|
7739
7705
|
|
|
7740
7706
|
if (match === false || opts.capture === true) {
|
|
7741
7707
|
if (opts.matchBase === true || opts.basename === true) {
|
|
7742
|
-
match = picomatch$
|
|
7708
|
+
match = picomatch$2.matchBase(input, regex, options, posix);
|
|
7743
7709
|
} else {
|
|
7744
7710
|
match = regex.exec(output);
|
|
7745
7711
|
}
|
|
@@ -7762,8 +7728,8 @@ picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
|
|
|
7762
7728
|
* @api public
|
|
7763
7729
|
*/
|
|
7764
7730
|
|
|
7765
|
-
picomatch$
|
|
7766
|
-
const regex = glob instanceof RegExp ? glob : picomatch$
|
|
7731
|
+
picomatch$2.matchBase = (input, glob, options, posix = utils$c.isWindows(options)) => {
|
|
7732
|
+
const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
|
|
7767
7733
|
return regex.test(path$6.basename(input));
|
|
7768
7734
|
};
|
|
7769
7735
|
|
|
@@ -7784,7 +7750,7 @@ picomatch$1.matchBase = (input, glob, options, posix = utils$c.isWindows(options
|
|
|
7784
7750
|
* @api public
|
|
7785
7751
|
*/
|
|
7786
7752
|
|
|
7787
|
-
picomatch$
|
|
7753
|
+
picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
|
|
7788
7754
|
|
|
7789
7755
|
/**
|
|
7790
7756
|
* Parse a glob pattern to create the source string for a regular
|
|
@@ -7800,8 +7766,8 @@ picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)
|
|
|
7800
7766
|
* @api public
|
|
7801
7767
|
*/
|
|
7802
7768
|
|
|
7803
|
-
picomatch$
|
|
7804
|
-
if (Array.isArray(pattern)) return pattern.map(p => picomatch$
|
|
7769
|
+
picomatch$2.parse = (pattern, options) => {
|
|
7770
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch$2.parse(p, options));
|
|
7805
7771
|
return parse(pattern, { ...options, fastpaths: false });
|
|
7806
7772
|
};
|
|
7807
7773
|
|
|
@@ -7832,7 +7798,7 @@ picomatch$1.parse = (pattern, options) => {
|
|
|
7832
7798
|
* @api public
|
|
7833
7799
|
*/
|
|
7834
7800
|
|
|
7835
|
-
picomatch$
|
|
7801
|
+
picomatch$2.scan = (input, options) => scan(input, options);
|
|
7836
7802
|
|
|
7837
7803
|
/**
|
|
7838
7804
|
* Compile a regular expression from the `state` object returned by the
|
|
@@ -7846,7 +7812,7 @@ picomatch$1.scan = (input, options) => scan(input, options);
|
|
|
7846
7812
|
* @api public
|
|
7847
7813
|
*/
|
|
7848
7814
|
|
|
7849
|
-
picomatch$
|
|
7815
|
+
picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
7850
7816
|
if (returnOutput === true) {
|
|
7851
7817
|
return state.output;
|
|
7852
7818
|
}
|
|
@@ -7860,7 +7826,7 @@ picomatch$1.compileRe = (state, options, returnOutput = false, returnState = fal
|
|
|
7860
7826
|
source = `^(?!${source}).*$`;
|
|
7861
7827
|
}
|
|
7862
7828
|
|
|
7863
|
-
const regex = picomatch$
|
|
7829
|
+
const regex = picomatch$2.toRegex(source, options);
|
|
7864
7830
|
if (returnState === true) {
|
|
7865
7831
|
regex.state = state;
|
|
7866
7832
|
}
|
|
@@ -7887,7 +7853,7 @@ picomatch$1.compileRe = (state, options, returnOutput = false, returnState = fal
|
|
|
7887
7853
|
* @api public
|
|
7888
7854
|
*/
|
|
7889
7855
|
|
|
7890
|
-
picomatch$
|
|
7856
|
+
picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
7891
7857
|
if (!input || typeof input !== 'string') {
|
|
7892
7858
|
throw new TypeError('Expected a non-empty string');
|
|
7893
7859
|
}
|
|
@@ -7902,7 +7868,7 @@ picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = f
|
|
|
7902
7868
|
parsed = parse(input, options);
|
|
7903
7869
|
}
|
|
7904
7870
|
|
|
7905
|
-
return picomatch$
|
|
7871
|
+
return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
|
|
7906
7872
|
};
|
|
7907
7873
|
|
|
7908
7874
|
/**
|
|
@@ -7922,7 +7888,7 @@ picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = f
|
|
|
7922
7888
|
* @api public
|
|
7923
7889
|
*/
|
|
7924
7890
|
|
|
7925
|
-
picomatch$
|
|
7891
|
+
picomatch$2.toRegex = (source, options) => {
|
|
7926
7892
|
try {
|
|
7927
7893
|
const opts = options || {};
|
|
7928
7894
|
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
@@ -7937,22 +7903,19 @@ picomatch$1.toRegex = (source, options) => {
|
|
|
7937
7903
|
* @return {Object}
|
|
7938
7904
|
*/
|
|
7939
7905
|
|
|
7940
|
-
picomatch$
|
|
7906
|
+
picomatch$2.constants = constants$1;
|
|
7941
7907
|
|
|
7942
7908
|
/**
|
|
7943
7909
|
* Expose "picomatch"
|
|
7944
7910
|
*/
|
|
7945
7911
|
|
|
7946
|
-
var picomatch_1 = picomatch$
|
|
7947
|
-
|
|
7948
|
-
(function (module) {
|
|
7912
|
+
var picomatch_1 = picomatch$2;
|
|
7949
7913
|
|
|
7950
|
-
|
|
7951
|
-
} (picomatch$2));
|
|
7914
|
+
var picomatch$1 = picomatch_1;
|
|
7952
7915
|
|
|
7953
7916
|
const util = require$$0$3;
|
|
7954
7917
|
const braces = braces_1;
|
|
7955
|
-
const picomatch = picomatch$
|
|
7918
|
+
const picomatch = picomatch$1;
|
|
7956
7919
|
const utils$b = utils$f;
|
|
7957
7920
|
const isEmptyString = val => val === '' || val === './';
|
|
7958
7921
|
|
|
@@ -8980,7 +8943,7 @@ var fs$5 = {};
|
|
|
8980
8943
|
}
|
|
8981
8944
|
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
|
8982
8945
|
}
|
|
8983
|
-
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
8946
|
+
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
8984
8947
|
} (fs$5));
|
|
8985
8948
|
|
|
8986
8949
|
Object.defineProperty(settings$3, "__esModule", { value: true });
|
|
@@ -9333,7 +9296,7 @@ var fs$1 = {};
|
|
|
9333
9296
|
}
|
|
9334
9297
|
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
|
9335
9298
|
}
|
|
9336
|
-
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
9299
|
+
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
9337
9300
|
} (fs$1));
|
|
9338
9301
|
|
|
9339
9302
|
Object.defineProperty(settings$2, "__esModule", { value: true });
|
|
@@ -9702,6 +9665,8 @@ function queueAsPromised (context, worker, concurrency) {
|
|
|
9702
9665
|
queue.exports = fastqueue;
|
|
9703
9666
|
queue.exports.promise = queueAsPromised;
|
|
9704
9667
|
|
|
9668
|
+
var queueExports = queue.exports;
|
|
9669
|
+
|
|
9705
9670
|
var common$3 = {};
|
|
9706
9671
|
|
|
9707
9672
|
Object.defineProperty(common$3, "__esModule", { value: true });
|
|
@@ -9751,7 +9716,7 @@ reader$1.default = Reader$1;
|
|
|
9751
9716
|
Object.defineProperty(async$4, "__esModule", { value: true });
|
|
9752
9717
|
const events_1 = require$$0$4;
|
|
9753
9718
|
const fsScandir$2 = out$2;
|
|
9754
|
-
const fastq =
|
|
9719
|
+
const fastq = queueExports;
|
|
9755
9720
|
const common$1 = common$3;
|
|
9756
9721
|
const reader_1$4 = reader$1;
|
|
9757
9722
|
class AsyncReader extends reader_1$4.default {
|
|
@@ -10678,7 +10643,7 @@ var settings = {};
|
|
|
10678
10643
|
return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
|
|
10679
10644
|
}
|
|
10680
10645
|
}
|
|
10681
|
-
exports.default = Settings;
|
|
10646
|
+
exports.default = Settings;
|
|
10682
10647
|
} (settings));
|
|
10683
10648
|
|
|
10684
10649
|
const taskManager = tasks;
|
|
@@ -10749,18 +10714,22 @@ function assertPatternsInput(input) {
|
|
|
10749
10714
|
}
|
|
10750
10715
|
var out = FastGlob;
|
|
10751
10716
|
|
|
10717
|
+
var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
|
|
10718
|
+
|
|
10752
10719
|
function resolveOptions(userOptions) {
|
|
10753
10720
|
return Object.assign(
|
|
10754
10721
|
{
|
|
10755
10722
|
hostname: "http://localhost/",
|
|
10756
10723
|
dynamicRoutes: [],
|
|
10757
10724
|
exclude: [],
|
|
10725
|
+
basePath: "",
|
|
10758
10726
|
outDir: "dist",
|
|
10759
10727
|
extensions: "html",
|
|
10760
10728
|
changefreq: "daily",
|
|
10761
10729
|
priority: 1,
|
|
10762
|
-
lastmod: new Date(),
|
|
10730
|
+
lastmod: /* @__PURE__ */ new Date(),
|
|
10763
10731
|
readable: false,
|
|
10732
|
+
generateRobotsTxt: true,
|
|
10764
10733
|
robots: [{
|
|
10765
10734
|
userAgent: "*",
|
|
10766
10735
|
allow: "/"
|
|
@@ -10770,20 +10739,6 @@ function resolveOptions(userOptions) {
|
|
|
10770
10739
|
);
|
|
10771
10740
|
}
|
|
10772
10741
|
|
|
10773
|
-
function slash(str) {
|
|
10774
|
-
return str.replace(/\\/g, "/");
|
|
10775
|
-
}
|
|
10776
|
-
function ensurePrefix(prefix, str) {
|
|
10777
|
-
if (!str.startsWith(prefix))
|
|
10778
|
-
return prefix + str;
|
|
10779
|
-
return str;
|
|
10780
|
-
}
|
|
10781
|
-
function ensureSuffix(suffix, str) {
|
|
10782
|
-
if (!str.endsWith(suffix))
|
|
10783
|
-
return str + suffix;
|
|
10784
|
-
return str;
|
|
10785
|
-
}
|
|
10786
|
-
|
|
10787
10742
|
var RobotCorrespondences = /* @__PURE__ */ ((RobotCorrespondences2) => {
|
|
10788
10743
|
RobotCorrespondences2["userAgent"] = "User-agent";
|
|
10789
10744
|
RobotCorrespondences2["allow"] = "Allow";
|
|
@@ -10817,42 +10772,49 @@ function getFinalSitemapPath(hostname) {
|
|
|
10817
10772
|
return `${ensureSuffix("/", hostname)}sitemap.xml`;
|
|
10818
10773
|
}
|
|
10819
10774
|
|
|
10775
|
+
function getResolvedPath(file, resolvedOptions) {
|
|
10776
|
+
if (isAbsolute(resolvedOptions.outDir))
|
|
10777
|
+
return resolve(`${resolvedOptions.outDir}/${file}`);
|
|
10778
|
+
return resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
|
|
10779
|
+
}
|
|
10780
|
+
function removeMaybeSuffix(suffix, str) {
|
|
10781
|
+
if (!str.endsWith(suffix))
|
|
10782
|
+
return str;
|
|
10783
|
+
return str.slice(0, -suffix.length);
|
|
10784
|
+
}
|
|
10785
|
+
|
|
10820
10786
|
function getRoutes(options) {
|
|
10821
10787
|
const ext = typeof options.extensions === "string" ? [options.extensions] : options.extensions;
|
|
10822
10788
|
const strExt = ext.map((e) => `**/*.${e}`);
|
|
10823
10789
|
return [
|
|
10824
|
-
...
|
|
10790
|
+
...fg.sync(strExt, { cwd: options.outDir }).map((route) => {
|
|
10825
10791
|
let r = route;
|
|
10826
10792
|
ext.forEach((e) => {
|
|
10827
10793
|
const regex = new RegExp(`index.${e}`, "g");
|
|
10828
10794
|
r = r.replace(regex, "");
|
|
10829
10795
|
});
|
|
10830
10796
|
const parsedRoute = parse$4(r);
|
|
10831
|
-
return slash(join("/", parsedRoute.dir, parsedRoute.name));
|
|
10797
|
+
return slash$1(join("/", parsedRoute.dir, parsedRoute.name));
|
|
10832
10798
|
}),
|
|
10833
|
-
...options.dynamicRoutes.map((route) => slash(join("/", join(parse$4(route).dir, parse$4(route).name))))
|
|
10799
|
+
...options.dynamicRoutes.map((route) => slash$1(join("/", join(parse$4(route).dir, parse$4(route).name))))
|
|
10834
10800
|
].filter((route) => !options.exclude.includes(route));
|
|
10835
10801
|
}
|
|
10836
10802
|
function getFormattedSitemap(options, routes) {
|
|
10837
10803
|
return routes.map((route) => ({
|
|
10838
|
-
url: new URL(route, options.hostname).href,
|
|
10804
|
+
url: new URL(options.basePath ? ensurePrefix("/", options.basePath) + ensurePrefix("/", route) : ensurePrefix("/", "/route"), removeMaybeSuffix("/", options.hostname)).href,
|
|
10839
10805
|
changefreq: options.changefreq,
|
|
10840
10806
|
priority: options.priority,
|
|
10841
10807
|
lastmod: options.lastmod
|
|
10842
10808
|
}));
|
|
10843
10809
|
}
|
|
10844
10810
|
|
|
10845
|
-
function getResolvedPath(file, resolvedOptions) {
|
|
10846
|
-
if (isAbsolute(resolvedOptions.outDir))
|
|
10847
|
-
return resolve(`${resolvedOptions.outDir}/${file}`);
|
|
10848
|
-
return resolve(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
|
|
10849
|
-
}
|
|
10850
|
-
|
|
10851
10811
|
function generateSitemap(options = {}) {
|
|
10852
10812
|
const resolvedOptions = resolveOptions(options);
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10813
|
+
if (resolvedOptions.generateRobotsTxt) {
|
|
10814
|
+
const robotRules = getRules(resolvedOptions.robots);
|
|
10815
|
+
const robotContent = getContent(robotRules, resolvedOptions.hostname);
|
|
10816
|
+
writeFileSync(getResolvedPath("robots.txt", resolvedOptions), robotContent);
|
|
10817
|
+
}
|
|
10856
10818
|
const routes = getRoutes(resolvedOptions);
|
|
10857
10819
|
if (!routes.length)
|
|
10858
10820
|
return;
|
|
@@ -10861,7 +10823,7 @@ function generateSitemap(options = {}) {
|
|
|
10861
10823
|
formattedSitemap.forEach((item) => stream.write(item));
|
|
10862
10824
|
distExports.streamToPromise(stream).then((sitemap) => {
|
|
10863
10825
|
const utfSitemap = sitemap.toString("utf-8");
|
|
10864
|
-
const formattedSitemap2 = resolvedOptions.readable ?
|
|
10826
|
+
const formattedSitemap2 = resolvedOptions.readable ? format(utfSitemap) : utfSitemap;
|
|
10865
10827
|
writeFileSync(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
|
|
10866
10828
|
});
|
|
10867
10829
|
stream.end();
|