vite-plugin-sitemap 0.1.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/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +3870 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3872 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +39 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3870 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __esm = (fn, res) => function __init() {
|
|
25
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
26
|
+
};
|
|
27
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
28
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
29
|
+
};
|
|
30
|
+
var __export = (target, all) => {
|
|
31
|
+
for (var name in all)
|
|
32
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
33
|
+
};
|
|
34
|
+
var __copyProps = (to, from, except, desc) => {
|
|
35
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
36
|
+
for (let key of __getOwnPropNames(from))
|
|
37
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
38
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
39
|
+
}
|
|
40
|
+
return to;
|
|
41
|
+
};
|
|
42
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
43
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => {
|
|
45
|
+
if (!member.has(obj))
|
|
46
|
+
throw TypeError("Cannot " + msg);
|
|
47
|
+
};
|
|
48
|
+
var __privateGet = (obj, member, getter) => {
|
|
49
|
+
__accessCheck(obj, member, "read from private field");
|
|
50
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
51
|
+
};
|
|
52
|
+
var __privateAdd = (obj, member, value) => {
|
|
53
|
+
if (member.has(obj))
|
|
54
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
55
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
56
|
+
};
|
|
57
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
58
|
+
__accessCheck(obj, member, "write to private field");
|
|
59
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
60
|
+
return value;
|
|
61
|
+
};
|
|
62
|
+
var __privateWrapper = (obj, member, setter, getter) => {
|
|
63
|
+
return {
|
|
64
|
+
set _(value) {
|
|
65
|
+
__privateSet(obj, member, value, setter);
|
|
66
|
+
},
|
|
67
|
+
get _() {
|
|
68
|
+
return __privateGet(obj, member, getter);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// node_modules/.pnpm/tsup@5.12.6_typescript@4.6.3/node_modules/tsup/assets/cjs_shims.js
|
|
74
|
+
var init_cjs_shims = __esm({
|
|
75
|
+
"node_modules/.pnpm/tsup@5.12.6_typescript@4.6.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/errors.js
|
|
80
|
+
var require_errors = __commonJS({
|
|
81
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/errors.js"(exports) {
|
|
82
|
+
"use strict";
|
|
83
|
+
init_cjs_shims();
|
|
84
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
|
+
exports.EmptySitemap = exports.EmptyStream = exports.InvalidVideoPriceCurrency = exports.InvalidVideoResolution = exports.InvalidVideoPriceType = exports.InvalidVideoRestrictionRelationship = exports.InvalidVideoRestriction = exports.InvalidVideoFamilyFriendly = exports.InvalidVideoCategory = exports.InvalidVideoTagCount = exports.InvalidVideoViewCount = exports.InvalidVideoTitle = exports.XMLLintUnavailable = exports.InvalidNewsAccessValue = exports.InvalidNewsFormat = exports.InvalidAttr = exports.InvalidAttrValue = exports.InvalidVideoRating = exports.InvalidVideoDescription = exports.InvalidVideoDuration = exports.InvalidVideoFormat = exports.UndefinedTargetFolder = exports.PriorityInvalidError = exports.ChangeFreqInvalidError = exports.NoConfigError = exports.NoURLError = void 0;
|
|
86
|
+
var NoURLError = class extends Error {
|
|
87
|
+
constructor(message) {
|
|
88
|
+
super(message || "URL is required");
|
|
89
|
+
this.name = "NoURLError";
|
|
90
|
+
Error.captureStackTrace(this, NoURLError);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
exports.NoURLError = NoURLError;
|
|
94
|
+
var NoConfigError = class extends Error {
|
|
95
|
+
constructor(message) {
|
|
96
|
+
super(message || "SitemapItem requires a configuration");
|
|
97
|
+
this.name = "NoConfigError";
|
|
98
|
+
Error.captureStackTrace(this, NoConfigError);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.NoConfigError = NoConfigError;
|
|
102
|
+
var ChangeFreqInvalidError = class extends Error {
|
|
103
|
+
constructor(url, changefreq) {
|
|
104
|
+
super(`${url}: changefreq "${changefreq}" is invalid`);
|
|
105
|
+
this.name = "ChangeFreqInvalidError";
|
|
106
|
+
Error.captureStackTrace(this, ChangeFreqInvalidError);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
exports.ChangeFreqInvalidError = ChangeFreqInvalidError;
|
|
110
|
+
var PriorityInvalidError = class extends Error {
|
|
111
|
+
constructor(url, priority) {
|
|
112
|
+
super(`${url}: priority "${priority}" must be a number between 0 and 1 inclusive`);
|
|
113
|
+
this.name = "PriorityInvalidError";
|
|
114
|
+
Error.captureStackTrace(this, PriorityInvalidError);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
exports.PriorityInvalidError = PriorityInvalidError;
|
|
118
|
+
var UndefinedTargetFolder = class extends Error {
|
|
119
|
+
constructor(message) {
|
|
120
|
+
super(message || "Target folder must exist");
|
|
121
|
+
this.name = "UndefinedTargetFolder";
|
|
122
|
+
Error.captureStackTrace(this, UndefinedTargetFolder);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.UndefinedTargetFolder = UndefinedTargetFolder;
|
|
126
|
+
var InvalidVideoFormat = class extends Error {
|
|
127
|
+
constructor(url) {
|
|
128
|
+
super(`${url} video must include thumbnail_loc, title and description fields for videos`);
|
|
129
|
+
this.name = "InvalidVideoFormat";
|
|
130
|
+
Error.captureStackTrace(this, InvalidVideoFormat);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
exports.InvalidVideoFormat = InvalidVideoFormat;
|
|
134
|
+
var InvalidVideoDuration = class extends Error {
|
|
135
|
+
constructor(url, duration) {
|
|
136
|
+
super(`${url} duration "${duration}" must be an integer of seconds between 0 and 28800`);
|
|
137
|
+
this.name = "InvalidVideoDuration";
|
|
138
|
+
Error.captureStackTrace(this, InvalidVideoDuration);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
exports.InvalidVideoDuration = InvalidVideoDuration;
|
|
142
|
+
var InvalidVideoDescription = class extends Error {
|
|
143
|
+
constructor(url, length) {
|
|
144
|
+
const message = `${url}: video description is too long ${length} vs limit of 2048 characters.`;
|
|
145
|
+
super(message);
|
|
146
|
+
this.name = "InvalidVideoDescription";
|
|
147
|
+
Error.captureStackTrace(this, InvalidVideoDescription);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
exports.InvalidVideoDescription = InvalidVideoDescription;
|
|
151
|
+
var InvalidVideoRating = class extends Error {
|
|
152
|
+
constructor(url, title, rating) {
|
|
153
|
+
super(`${url}: video "${title}" rating "${rating}" must be between 0 and 5 inclusive`);
|
|
154
|
+
this.name = "InvalidVideoRating";
|
|
155
|
+
Error.captureStackTrace(this, InvalidVideoRating);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
exports.InvalidVideoRating = InvalidVideoRating;
|
|
159
|
+
var InvalidAttrValue = class extends Error {
|
|
160
|
+
constructor(key, val, validator) {
|
|
161
|
+
super('"' + val + '" tested against: ' + validator + ' is not a valid value for attr: "' + key + '"');
|
|
162
|
+
this.name = "InvalidAttrValue";
|
|
163
|
+
Error.captureStackTrace(this, InvalidAttrValue);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
exports.InvalidAttrValue = InvalidAttrValue;
|
|
167
|
+
var InvalidAttr = class extends Error {
|
|
168
|
+
constructor(key) {
|
|
169
|
+
super('"' + key + '" is malformed');
|
|
170
|
+
this.name = "InvalidAttr";
|
|
171
|
+
Error.captureStackTrace(this, InvalidAttr);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
exports.InvalidAttr = InvalidAttr;
|
|
175
|
+
var InvalidNewsFormat = class extends Error {
|
|
176
|
+
constructor(url) {
|
|
177
|
+
super(`${url} News must include publication, publication name, publication language, title, and publication_date for news`);
|
|
178
|
+
this.name = "InvalidNewsFormat";
|
|
179
|
+
Error.captureStackTrace(this, InvalidNewsFormat);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
exports.InvalidNewsFormat = InvalidNewsFormat;
|
|
183
|
+
var InvalidNewsAccessValue = class extends Error {
|
|
184
|
+
constructor(url, access) {
|
|
185
|
+
super(`${url} News access "${access}" must be either Registration, Subscription or not be present`);
|
|
186
|
+
this.name = "InvalidNewsAccessValue";
|
|
187
|
+
Error.captureStackTrace(this, InvalidNewsAccessValue);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
exports.InvalidNewsAccessValue = InvalidNewsAccessValue;
|
|
191
|
+
var XMLLintUnavailable = class extends Error {
|
|
192
|
+
constructor(message) {
|
|
193
|
+
super(message || "xmlLint is not installed. XMLLint is required to validate");
|
|
194
|
+
this.name = "XMLLintUnavailable";
|
|
195
|
+
Error.captureStackTrace(this, XMLLintUnavailable);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
exports.XMLLintUnavailable = XMLLintUnavailable;
|
|
199
|
+
var InvalidVideoTitle = class extends Error {
|
|
200
|
+
constructor(url, length) {
|
|
201
|
+
super(`${url}: video title is too long ${length} vs 100 character limit`);
|
|
202
|
+
this.name = "InvalidVideoTitle";
|
|
203
|
+
Error.captureStackTrace(this, InvalidVideoTitle);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
exports.InvalidVideoTitle = InvalidVideoTitle;
|
|
207
|
+
var InvalidVideoViewCount = class extends Error {
|
|
208
|
+
constructor(url, count) {
|
|
209
|
+
super(`${url}: video view count must be positive, view count was ${count}`);
|
|
210
|
+
this.name = "InvalidVideoViewCount";
|
|
211
|
+
Error.captureStackTrace(this, InvalidVideoViewCount);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
exports.InvalidVideoViewCount = InvalidVideoViewCount;
|
|
215
|
+
var InvalidVideoTagCount = class extends Error {
|
|
216
|
+
constructor(url, count) {
|
|
217
|
+
super(`${url}: video can have no more than 32 tags, this has ${count}`);
|
|
218
|
+
this.name = "InvalidVideoTagCount";
|
|
219
|
+
Error.captureStackTrace(this, InvalidVideoTagCount);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
exports.InvalidVideoTagCount = InvalidVideoTagCount;
|
|
223
|
+
var InvalidVideoCategory = class extends Error {
|
|
224
|
+
constructor(url, count) {
|
|
225
|
+
super(`${url}: video category can only be 256 characters but was passed ${count}`);
|
|
226
|
+
this.name = "InvalidVideoCategory";
|
|
227
|
+
Error.captureStackTrace(this, InvalidVideoCategory);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
exports.InvalidVideoCategory = InvalidVideoCategory;
|
|
231
|
+
var InvalidVideoFamilyFriendly = class extends Error {
|
|
232
|
+
constructor(url, fam) {
|
|
233
|
+
super(`${url}: video family friendly must be yes or no, was passed "${fam}"`);
|
|
234
|
+
this.name = "InvalidVideoFamilyFriendly";
|
|
235
|
+
Error.captureStackTrace(this, InvalidVideoFamilyFriendly);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
exports.InvalidVideoFamilyFriendly = InvalidVideoFamilyFriendly;
|
|
239
|
+
var InvalidVideoRestriction = class extends Error {
|
|
240
|
+
constructor(url, code) {
|
|
241
|
+
super(`${url}: video restriction must be one or more two letter country codes. Was passed "${code}"`);
|
|
242
|
+
this.name = "InvalidVideoRestriction";
|
|
243
|
+
Error.captureStackTrace(this, InvalidVideoRestriction);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
exports.InvalidVideoRestriction = InvalidVideoRestriction;
|
|
247
|
+
var InvalidVideoRestrictionRelationship = class extends Error {
|
|
248
|
+
constructor(url, val) {
|
|
249
|
+
super(`${url}: video restriction relationship must be either allow or deny. Was passed "${val}"`);
|
|
250
|
+
this.name = "InvalidVideoRestrictionRelationship";
|
|
251
|
+
Error.captureStackTrace(this, InvalidVideoRestrictionRelationship);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
exports.InvalidVideoRestrictionRelationship = InvalidVideoRestrictionRelationship;
|
|
255
|
+
var InvalidVideoPriceType = class extends Error {
|
|
256
|
+
constructor(url, priceType, price) {
|
|
257
|
+
super(priceType === void 0 && price === "" ? `${url}: video priceType is required when price is not provided` : `${url}: video price type "${priceType}" is not "rent" or "purchase"`);
|
|
258
|
+
this.name = "InvalidVideoPriceType";
|
|
259
|
+
Error.captureStackTrace(this, InvalidVideoPriceType);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
exports.InvalidVideoPriceType = InvalidVideoPriceType;
|
|
263
|
+
var InvalidVideoResolution = class extends Error {
|
|
264
|
+
constructor(url, resolution) {
|
|
265
|
+
super(`${url}: video price resolution "${resolution}" is not hd or sd`);
|
|
266
|
+
this.name = "InvalidVideoResolution";
|
|
267
|
+
Error.captureStackTrace(this, InvalidVideoResolution);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
exports.InvalidVideoResolution = InvalidVideoResolution;
|
|
271
|
+
var InvalidVideoPriceCurrency = class extends Error {
|
|
272
|
+
constructor(url, currency) {
|
|
273
|
+
super(`${url}: video price currency "${currency}" must be a three capital letter abbrieviation for the country currency`);
|
|
274
|
+
this.name = "InvalidVideoPriceCurrency";
|
|
275
|
+
Error.captureStackTrace(this, InvalidVideoPriceCurrency);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
exports.InvalidVideoPriceCurrency = InvalidVideoPriceCurrency;
|
|
279
|
+
var EmptyStream = class extends Error {
|
|
280
|
+
constructor() {
|
|
281
|
+
super("You have ended the stream before anything was written. streamToPromise MUST be called before ending the stream.");
|
|
282
|
+
this.name = "EmptyStream";
|
|
283
|
+
Error.captureStackTrace(this, EmptyStream);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
exports.EmptyStream = EmptyStream;
|
|
287
|
+
var EmptySitemap = class extends Error {
|
|
288
|
+
constructor() {
|
|
289
|
+
super("You ended the stream without writing anything.");
|
|
290
|
+
this.name = "EmptySitemap";
|
|
291
|
+
Error.captureStackTrace(this, EmptyStream);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
exports.EmptySitemap = EmptySitemap;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/types.js
|
|
299
|
+
var require_types = __commonJS({
|
|
300
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/types.js"(exports) {
|
|
301
|
+
"use strict";
|
|
302
|
+
init_cjs_shims();
|
|
303
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
304
|
+
exports.IndexTagNames = exports.TagNames = exports.ErrorLevel = exports.isAllowDeny = exports.EnumAllowDeny = exports.isValidYesNo = exports.EnumYesNo = exports.isValidChangeFreq = exports.CHANGEFREQ = exports.isResolution = exports.isPriceType = exports.validators = exports.EnumChangefreq = void 0;
|
|
305
|
+
var EnumChangefreq;
|
|
306
|
+
(function(EnumChangefreq2) {
|
|
307
|
+
EnumChangefreq2["DAILY"] = "daily";
|
|
308
|
+
EnumChangefreq2["MONTHLY"] = "monthly";
|
|
309
|
+
EnumChangefreq2["ALWAYS"] = "always";
|
|
310
|
+
EnumChangefreq2["HOURLY"] = "hourly";
|
|
311
|
+
EnumChangefreq2["WEEKLY"] = "weekly";
|
|
312
|
+
EnumChangefreq2["YEARLY"] = "yearly";
|
|
313
|
+
EnumChangefreq2["NEVER"] = "never";
|
|
314
|
+
})(EnumChangefreq = exports.EnumChangefreq || (exports.EnumChangefreq = {}));
|
|
315
|
+
var allowDeny = /^(?:allow|deny)$/;
|
|
316
|
+
exports.validators = {
|
|
317
|
+
"price:currency": /^[A-Z]{3}$/,
|
|
318
|
+
"price:type": /^(?:rent|purchase|RENT|PURCHASE)$/,
|
|
319
|
+
"price:resolution": /^(?:HD|hd|sd|SD)$/,
|
|
320
|
+
"platform:relationship": allowDeny,
|
|
321
|
+
"restriction:relationship": allowDeny,
|
|
322
|
+
restriction: /^([A-Z]{2}( +[A-Z]{2})*)?$/,
|
|
323
|
+
platform: /^((web|mobile|tv)( (web|mobile|tv))*)?$/,
|
|
324
|
+
language: /^zh-cn|zh-tw|([a-z]{2,3})$/,
|
|
325
|
+
genres: /^(PressRelease|Satire|Blog|OpEd|Opinion|UserGenerated)(, *(PressRelease|Satire|Blog|OpEd|Opinion|UserGenerated))*$/,
|
|
326
|
+
stock_tickers: /^(\w+:\w+(, *\w+:\w+){0,4})?$/
|
|
327
|
+
};
|
|
328
|
+
function isPriceType(pt) {
|
|
329
|
+
return exports.validators["price:type"].test(pt);
|
|
330
|
+
}
|
|
331
|
+
exports.isPriceType = isPriceType;
|
|
332
|
+
function isResolution(res) {
|
|
333
|
+
return exports.validators["price:resolution"].test(res);
|
|
334
|
+
}
|
|
335
|
+
exports.isResolution = isResolution;
|
|
336
|
+
exports.CHANGEFREQ = Object.values(EnumChangefreq);
|
|
337
|
+
function isValidChangeFreq(freq) {
|
|
338
|
+
return exports.CHANGEFREQ.includes(freq);
|
|
339
|
+
}
|
|
340
|
+
exports.isValidChangeFreq = isValidChangeFreq;
|
|
341
|
+
var EnumYesNo;
|
|
342
|
+
(function(EnumYesNo2) {
|
|
343
|
+
EnumYesNo2["YES"] = "YES";
|
|
344
|
+
EnumYesNo2["NO"] = "NO";
|
|
345
|
+
EnumYesNo2["Yes"] = "Yes";
|
|
346
|
+
EnumYesNo2["No"] = "No";
|
|
347
|
+
EnumYesNo2["yes"] = "yes";
|
|
348
|
+
EnumYesNo2["no"] = "no";
|
|
349
|
+
})(EnumYesNo = exports.EnumYesNo || (exports.EnumYesNo = {}));
|
|
350
|
+
function isValidYesNo(yn) {
|
|
351
|
+
return /^YES|NO|[Yy]es|[Nn]o$/.test(yn);
|
|
352
|
+
}
|
|
353
|
+
exports.isValidYesNo = isValidYesNo;
|
|
354
|
+
var EnumAllowDeny;
|
|
355
|
+
(function(EnumAllowDeny2) {
|
|
356
|
+
EnumAllowDeny2["ALLOW"] = "allow";
|
|
357
|
+
EnumAllowDeny2["DENY"] = "deny";
|
|
358
|
+
})(EnumAllowDeny = exports.EnumAllowDeny || (exports.EnumAllowDeny = {}));
|
|
359
|
+
function isAllowDeny(ad) {
|
|
360
|
+
return allowDeny.test(ad);
|
|
361
|
+
}
|
|
362
|
+
exports.isAllowDeny = isAllowDeny;
|
|
363
|
+
var ErrorLevel;
|
|
364
|
+
(function(ErrorLevel2) {
|
|
365
|
+
ErrorLevel2["SILENT"] = "silent";
|
|
366
|
+
ErrorLevel2["WARN"] = "warn";
|
|
367
|
+
ErrorLevel2["THROW"] = "throw";
|
|
368
|
+
})(ErrorLevel = exports.ErrorLevel || (exports.ErrorLevel = {}));
|
|
369
|
+
var TagNames;
|
|
370
|
+
(function(TagNames2) {
|
|
371
|
+
TagNames2["url"] = "url";
|
|
372
|
+
TagNames2["loc"] = "loc";
|
|
373
|
+
TagNames2["urlset"] = "urlset";
|
|
374
|
+
TagNames2["lastmod"] = "lastmod";
|
|
375
|
+
TagNames2["changefreq"] = "changefreq";
|
|
376
|
+
TagNames2["priority"] = "priority";
|
|
377
|
+
TagNames2["video:thumbnail_loc"] = "video:thumbnail_loc";
|
|
378
|
+
TagNames2["video:video"] = "video:video";
|
|
379
|
+
TagNames2["video:title"] = "video:title";
|
|
380
|
+
TagNames2["video:description"] = "video:description";
|
|
381
|
+
TagNames2["video:tag"] = "video:tag";
|
|
382
|
+
TagNames2["video:duration"] = "video:duration";
|
|
383
|
+
TagNames2["video:player_loc"] = "video:player_loc";
|
|
384
|
+
TagNames2["video:content_loc"] = "video:content_loc";
|
|
385
|
+
TagNames2["image:image"] = "image:image";
|
|
386
|
+
TagNames2["image:loc"] = "image:loc";
|
|
387
|
+
TagNames2["image:geo_location"] = "image:geo_location";
|
|
388
|
+
TagNames2["image:license"] = "image:license";
|
|
389
|
+
TagNames2["image:title"] = "image:title";
|
|
390
|
+
TagNames2["image:caption"] = "image:caption";
|
|
391
|
+
TagNames2["video:requires_subscription"] = "video:requires_subscription";
|
|
392
|
+
TagNames2["video:publication_date"] = "video:publication_date";
|
|
393
|
+
TagNames2["video:id"] = "video:id";
|
|
394
|
+
TagNames2["video:restriction"] = "video:restriction";
|
|
395
|
+
TagNames2["video:family_friendly"] = "video:family_friendly";
|
|
396
|
+
TagNames2["video:view_count"] = "video:view_count";
|
|
397
|
+
TagNames2["video:uploader"] = "video:uploader";
|
|
398
|
+
TagNames2["video:expiration_date"] = "video:expiration_date";
|
|
399
|
+
TagNames2["video:platform"] = "video:platform";
|
|
400
|
+
TagNames2["video:price"] = "video:price";
|
|
401
|
+
TagNames2["video:rating"] = "video:rating";
|
|
402
|
+
TagNames2["video:category"] = "video:category";
|
|
403
|
+
TagNames2["video:live"] = "video:live";
|
|
404
|
+
TagNames2["video:gallery_loc"] = "video:gallery_loc";
|
|
405
|
+
TagNames2["news:news"] = "news:news";
|
|
406
|
+
TagNames2["news:publication"] = "news:publication";
|
|
407
|
+
TagNames2["news:name"] = "news:name";
|
|
408
|
+
TagNames2["news:access"] = "news:access";
|
|
409
|
+
TagNames2["news:genres"] = "news:genres";
|
|
410
|
+
TagNames2["news:publication_date"] = "news:publication_date";
|
|
411
|
+
TagNames2["news:title"] = "news:title";
|
|
412
|
+
TagNames2["news:keywords"] = "news:keywords";
|
|
413
|
+
TagNames2["news:stock_tickers"] = "news:stock_tickers";
|
|
414
|
+
TagNames2["news:language"] = "news:language";
|
|
415
|
+
TagNames2["mobile:mobile"] = "mobile:mobile";
|
|
416
|
+
TagNames2["xhtml:link"] = "xhtml:link";
|
|
417
|
+
TagNames2["expires"] = "expires";
|
|
418
|
+
})(TagNames = exports.TagNames || (exports.TagNames = {}));
|
|
419
|
+
var IndexTagNames;
|
|
420
|
+
(function(IndexTagNames2) {
|
|
421
|
+
IndexTagNames2["sitemap"] = "sitemap";
|
|
422
|
+
IndexTagNames2["sitemapindex"] = "sitemapindex";
|
|
423
|
+
IndexTagNames2["loc"] = "loc";
|
|
424
|
+
IndexTagNames2["lastmod"] = "lastmod";
|
|
425
|
+
})(IndexTagNames = exports.IndexTagNames || (exports.IndexTagNames = {}));
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-xml.js
|
|
430
|
+
var require_sitemap_xml = __commonJS({
|
|
431
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-xml.js"(exports) {
|
|
432
|
+
"use strict";
|
|
433
|
+
init_cjs_shims();
|
|
434
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
435
|
+
exports.element = exports.ctag = exports.otag = exports.text = void 0;
|
|
436
|
+
var invalidXMLUnicodeRegex = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u0084\u0086-\u009F\uD800-\uDFFF\uFDD0-\uFDDF\u{1FFFE}-\u{1FFFF}\u{2FFFE}-\u{2FFFF}\u{3FFFE}-\u{3FFFF}\u{4FFFE}-\u{4FFFF}\u{5FFFE}-\u{5FFFF}\u{6FFFE}-\u{6FFFF}\u{7FFFE}-\u{7FFFF}\u{8FFFE}-\u{8FFFF}\u{9FFFE}-\u{9FFFF}\u{AFFFE}-\u{AFFFF}\u{BFFFE}-\u{BFFFF}\u{CFFFE}-\u{CFFFF}\u{DFFFE}-\u{DFFFF}\u{EFFFE}-\u{EFFFF}\u{FFFFE}-\u{FFFFF}\u{10FFFE}-\u{10FFFF}]/gu;
|
|
437
|
+
var amp = /&/g;
|
|
438
|
+
var lt = /</g;
|
|
439
|
+
var apos = /'/g;
|
|
440
|
+
var quot = /"/g;
|
|
441
|
+
function text(txt) {
|
|
442
|
+
return txt.replace(amp, "&").replace(lt, "<").replace(invalidXMLUnicodeRegex, "");
|
|
443
|
+
}
|
|
444
|
+
exports.text = text;
|
|
445
|
+
function otag(nodeName, attrs, selfClose = false) {
|
|
446
|
+
let attrstr = "";
|
|
447
|
+
for (const k in attrs) {
|
|
448
|
+
const val = attrs[k].replace(amp, "&").replace(lt, "<").replace(apos, "'").replace(quot, """).replace(invalidXMLUnicodeRegex, "");
|
|
449
|
+
attrstr += ` ${k}="${val}"`;
|
|
450
|
+
}
|
|
451
|
+
return `<${nodeName}${attrstr}${selfClose ? "/" : ""}>`;
|
|
452
|
+
}
|
|
453
|
+
exports.otag = otag;
|
|
454
|
+
function ctag(nodeName) {
|
|
455
|
+
return `</${nodeName}>`;
|
|
456
|
+
}
|
|
457
|
+
exports.ctag = ctag;
|
|
458
|
+
function element(nodeName, attrs, innerText) {
|
|
459
|
+
if (typeof attrs === "string") {
|
|
460
|
+
return otag(nodeName) + text(attrs) + ctag(nodeName);
|
|
461
|
+
} else if (innerText) {
|
|
462
|
+
return otag(nodeName, attrs) + text(innerText) + ctag(nodeName);
|
|
463
|
+
} else {
|
|
464
|
+
return otag(nodeName, attrs, true);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
exports.element = element;
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-item-stream.js
|
|
472
|
+
var require_sitemap_item_stream = __commonJS({
|
|
473
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-item-stream.js"(exports) {
|
|
474
|
+
"use strict";
|
|
475
|
+
init_cjs_shims();
|
|
476
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
477
|
+
exports.SitemapItemStream = void 0;
|
|
478
|
+
var stream_1 = require("stream");
|
|
479
|
+
var errors_1 = require_errors();
|
|
480
|
+
var types_1 = require_types();
|
|
481
|
+
var sitemap_xml_1 = require_sitemap_xml();
|
|
482
|
+
function attrBuilder(conf, keys) {
|
|
483
|
+
if (typeof keys === "string") {
|
|
484
|
+
keys = [keys];
|
|
485
|
+
}
|
|
486
|
+
const iv = {};
|
|
487
|
+
return keys.reduce((attrs, key) => {
|
|
488
|
+
if (conf[key] !== void 0) {
|
|
489
|
+
const keyAr = key.split(":");
|
|
490
|
+
if (keyAr.length !== 2) {
|
|
491
|
+
throw new errors_1.InvalidAttr(key);
|
|
492
|
+
}
|
|
493
|
+
attrs[keyAr[1]] = conf[key];
|
|
494
|
+
}
|
|
495
|
+
return attrs;
|
|
496
|
+
}, iv);
|
|
497
|
+
}
|
|
498
|
+
var SitemapItemStream = class extends stream_1.Transform {
|
|
499
|
+
constructor(opts = { level: types_1.ErrorLevel.WARN }) {
|
|
500
|
+
opts.objectMode = true;
|
|
501
|
+
super(opts);
|
|
502
|
+
this.level = opts.level || types_1.ErrorLevel.WARN;
|
|
503
|
+
}
|
|
504
|
+
_transform(item, encoding, callback) {
|
|
505
|
+
this.push((0, sitemap_xml_1.otag)(types_1.TagNames.url));
|
|
506
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames.loc, item.url));
|
|
507
|
+
if (item.lastmod) {
|
|
508
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames.lastmod, item.lastmod));
|
|
509
|
+
}
|
|
510
|
+
if (item.changefreq) {
|
|
511
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames.changefreq, item.changefreq));
|
|
512
|
+
}
|
|
513
|
+
if (item.priority !== void 0 && item.priority !== null) {
|
|
514
|
+
if (item.fullPrecisionPriority) {
|
|
515
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames.priority, item.priority.toString()));
|
|
516
|
+
} else {
|
|
517
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames.priority, item.priority.toFixed(1)));
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
item.video.forEach((video) => {
|
|
521
|
+
this.push((0, sitemap_xml_1.otag)(types_1.TagNames["video:video"]));
|
|
522
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:thumbnail_loc"], video.thumbnail_loc));
|
|
523
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:title"], video.title));
|
|
524
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:description"], video.description));
|
|
525
|
+
if (video.content_loc) {
|
|
526
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:content_loc"], video.content_loc));
|
|
527
|
+
}
|
|
528
|
+
if (video.player_loc) {
|
|
529
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:player_loc"], attrBuilder(video, [
|
|
530
|
+
"player_loc:autoplay",
|
|
531
|
+
"player_loc:allow_embed"
|
|
532
|
+
]), video.player_loc));
|
|
533
|
+
}
|
|
534
|
+
if (video.duration) {
|
|
535
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:duration"], video.duration.toString()));
|
|
536
|
+
}
|
|
537
|
+
if (video.expiration_date) {
|
|
538
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:expiration_date"], video.expiration_date));
|
|
539
|
+
}
|
|
540
|
+
if (video.rating !== void 0) {
|
|
541
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:rating"], video.rating.toString()));
|
|
542
|
+
}
|
|
543
|
+
if (video.view_count !== void 0) {
|
|
544
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:view_count"], video.view_count.toString()));
|
|
545
|
+
}
|
|
546
|
+
if (video.publication_date) {
|
|
547
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:publication_date"], video.publication_date));
|
|
548
|
+
}
|
|
549
|
+
for (const tag of video.tag) {
|
|
550
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:tag"], tag));
|
|
551
|
+
}
|
|
552
|
+
if (video.category) {
|
|
553
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:category"], video.category));
|
|
554
|
+
}
|
|
555
|
+
if (video.family_friendly) {
|
|
556
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:family_friendly"], video.family_friendly));
|
|
557
|
+
}
|
|
558
|
+
if (video.restriction) {
|
|
559
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:restriction"], attrBuilder(video, "restriction:relationship"), video.restriction));
|
|
560
|
+
}
|
|
561
|
+
if (video.gallery_loc) {
|
|
562
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:gallery_loc"], { title: video["gallery_loc:title"] }, video.gallery_loc));
|
|
563
|
+
}
|
|
564
|
+
if (video.price) {
|
|
565
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:price"], attrBuilder(video, [
|
|
566
|
+
"price:resolution",
|
|
567
|
+
"price:currency",
|
|
568
|
+
"price:type"
|
|
569
|
+
]), video.price));
|
|
570
|
+
}
|
|
571
|
+
if (video.requires_subscription) {
|
|
572
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:requires_subscription"], video.requires_subscription));
|
|
573
|
+
}
|
|
574
|
+
if (video.uploader) {
|
|
575
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:uploader"], attrBuilder(video, "uploader:info"), video.uploader));
|
|
576
|
+
}
|
|
577
|
+
if (video.platform) {
|
|
578
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:platform"], attrBuilder(video, "platform:relationship"), video.platform));
|
|
579
|
+
}
|
|
580
|
+
if (video.live) {
|
|
581
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:live"], video.live));
|
|
582
|
+
}
|
|
583
|
+
if (video.id) {
|
|
584
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["video:id"], { type: "url" }, video.id));
|
|
585
|
+
}
|
|
586
|
+
this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["video:video"]));
|
|
587
|
+
});
|
|
588
|
+
item.links.forEach((link) => {
|
|
589
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["xhtml:link"], {
|
|
590
|
+
rel: "alternate",
|
|
591
|
+
hreflang: link.lang || link.hreflang,
|
|
592
|
+
href: link.url
|
|
593
|
+
}));
|
|
594
|
+
});
|
|
595
|
+
if (item.expires) {
|
|
596
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames.expires, new Date(item.expires).toISOString()));
|
|
597
|
+
}
|
|
598
|
+
if (item.androidLink) {
|
|
599
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["xhtml:link"], {
|
|
600
|
+
rel: "alternate",
|
|
601
|
+
href: item.androidLink
|
|
602
|
+
}));
|
|
603
|
+
}
|
|
604
|
+
if (item.ampLink) {
|
|
605
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["xhtml:link"], {
|
|
606
|
+
rel: "amphtml",
|
|
607
|
+
href: item.ampLink
|
|
608
|
+
}));
|
|
609
|
+
}
|
|
610
|
+
if (item.news) {
|
|
611
|
+
this.push((0, sitemap_xml_1.otag)(types_1.TagNames["news:news"]));
|
|
612
|
+
this.push((0, sitemap_xml_1.otag)(types_1.TagNames["news:publication"]));
|
|
613
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:name"], item.news.publication.name));
|
|
614
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:language"], item.news.publication.language));
|
|
615
|
+
this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["news:publication"]));
|
|
616
|
+
if (item.news.access) {
|
|
617
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:access"], item.news.access));
|
|
618
|
+
}
|
|
619
|
+
if (item.news.genres) {
|
|
620
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:genres"], item.news.genres));
|
|
621
|
+
}
|
|
622
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:publication_date"], item.news.publication_date));
|
|
623
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:title"], item.news.title));
|
|
624
|
+
if (item.news.keywords) {
|
|
625
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:keywords"], item.news.keywords));
|
|
626
|
+
}
|
|
627
|
+
if (item.news.stock_tickers) {
|
|
628
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["news:stock_tickers"], item.news.stock_tickers));
|
|
629
|
+
}
|
|
630
|
+
this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["news:news"]));
|
|
631
|
+
}
|
|
632
|
+
item.img.forEach((image) => {
|
|
633
|
+
this.push((0, sitemap_xml_1.otag)(types_1.TagNames["image:image"]));
|
|
634
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:loc"], image.url));
|
|
635
|
+
if (image.caption) {
|
|
636
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:caption"], image.caption));
|
|
637
|
+
}
|
|
638
|
+
if (image.geoLocation) {
|
|
639
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:geo_location"], image.geoLocation));
|
|
640
|
+
}
|
|
641
|
+
if (image.title) {
|
|
642
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:title"], image.title));
|
|
643
|
+
}
|
|
644
|
+
if (image.license) {
|
|
645
|
+
this.push((0, sitemap_xml_1.element)(types_1.TagNames["image:license"], image.license));
|
|
646
|
+
}
|
|
647
|
+
this.push((0, sitemap_xml_1.ctag)(types_1.TagNames["image:image"]));
|
|
648
|
+
});
|
|
649
|
+
this.push((0, sitemap_xml_1.ctag)(types_1.TagNames.url));
|
|
650
|
+
callback();
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
exports.SitemapItemStream = SitemapItemStream;
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/utils.js
|
|
658
|
+
var require_utils = __commonJS({
|
|
659
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/utils.js"(exports) {
|
|
660
|
+
"use strict";
|
|
661
|
+
init_cjs_shims();
|
|
662
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
663
|
+
exports.normalizeURL = exports.chunk = exports.lineSeparatedURLsToSitemapOptions = exports.ReadlineStream = exports.mergeStreams = exports.validateSMIOptions = void 0;
|
|
664
|
+
var fs_1 = require("fs");
|
|
665
|
+
var stream_1 = require("stream");
|
|
666
|
+
var readline_1 = require("readline");
|
|
667
|
+
var url_1 = require("url");
|
|
668
|
+
var types_1 = require_types();
|
|
669
|
+
var errors_1 = require_errors();
|
|
670
|
+
var types_2 = require_types();
|
|
671
|
+
function validate(subject, name, url, level) {
|
|
672
|
+
Object.keys(subject).forEach((key) => {
|
|
673
|
+
const val = subject[key];
|
|
674
|
+
if (types_2.validators[key] && !types_2.validators[key].test(val)) {
|
|
675
|
+
if (level === types_1.ErrorLevel.THROW) {
|
|
676
|
+
throw new errors_1.InvalidAttrValue(key, val, types_2.validators[key]);
|
|
677
|
+
} else {
|
|
678
|
+
console.warn(`${url}: ${name} key ${key} has invalid value: ${val}`);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
function handleError(error, level) {
|
|
684
|
+
if (level === types_1.ErrorLevel.THROW) {
|
|
685
|
+
throw error;
|
|
686
|
+
} else if (level === types_1.ErrorLevel.WARN) {
|
|
687
|
+
console.warn(error.name, error.message);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
function validateSMIOptions(conf, level = types_1.ErrorLevel.WARN, errorHandler = handleError) {
|
|
691
|
+
if (!conf) {
|
|
692
|
+
throw new errors_1.NoConfigError();
|
|
693
|
+
}
|
|
694
|
+
if (level === types_1.ErrorLevel.SILENT) {
|
|
695
|
+
return conf;
|
|
696
|
+
}
|
|
697
|
+
const { url, changefreq, priority, news, video } = conf;
|
|
698
|
+
if (!url) {
|
|
699
|
+
errorHandler(new errors_1.NoURLError(), level);
|
|
700
|
+
}
|
|
701
|
+
if (changefreq) {
|
|
702
|
+
if (!(0, types_1.isValidChangeFreq)(changefreq)) {
|
|
703
|
+
errorHandler(new errors_1.ChangeFreqInvalidError(url, changefreq), level);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
if (priority) {
|
|
707
|
+
if (!(priority >= 0 && priority <= 1)) {
|
|
708
|
+
errorHandler(new errors_1.PriorityInvalidError(url, priority), level);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (news) {
|
|
712
|
+
if (news.access && news.access !== "Registration" && news.access !== "Subscription") {
|
|
713
|
+
errorHandler(new errors_1.InvalidNewsAccessValue(url, news.access), level);
|
|
714
|
+
}
|
|
715
|
+
if (!news.publication || !news.publication.name || !news.publication.language || !news.publication_date || !news.title) {
|
|
716
|
+
errorHandler(new errors_1.InvalidNewsFormat(url), level);
|
|
717
|
+
}
|
|
718
|
+
validate(news, "news", url, level);
|
|
719
|
+
validate(news.publication, "publication", url, level);
|
|
720
|
+
}
|
|
721
|
+
if (video) {
|
|
722
|
+
video.forEach((vid) => {
|
|
723
|
+
var _a;
|
|
724
|
+
if (vid.duration !== void 0) {
|
|
725
|
+
if (vid.duration < 0 || vid.duration > 28800) {
|
|
726
|
+
errorHandler(new errors_1.InvalidVideoDuration(url, vid.duration), level);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
if (vid.rating !== void 0 && (vid.rating < 0 || vid.rating > 5)) {
|
|
730
|
+
errorHandler(new errors_1.InvalidVideoRating(url, vid.title, vid.rating), level);
|
|
731
|
+
}
|
|
732
|
+
if (typeof vid !== "object" || !vid.thumbnail_loc || !vid.title || !vid.description) {
|
|
733
|
+
errorHandler(new errors_1.InvalidVideoFormat(url), level);
|
|
734
|
+
}
|
|
735
|
+
if (vid.title.length > 100) {
|
|
736
|
+
errorHandler(new errors_1.InvalidVideoTitle(url, vid.title.length), level);
|
|
737
|
+
}
|
|
738
|
+
if (vid.description.length > 2048) {
|
|
739
|
+
errorHandler(new errors_1.InvalidVideoDescription(url, vid.description.length), level);
|
|
740
|
+
}
|
|
741
|
+
if (vid.view_count !== void 0 && vid.view_count < 0) {
|
|
742
|
+
errorHandler(new errors_1.InvalidVideoViewCount(url, vid.view_count), level);
|
|
743
|
+
}
|
|
744
|
+
if (vid.tag.length > 32) {
|
|
745
|
+
errorHandler(new errors_1.InvalidVideoTagCount(url, vid.tag.length), level);
|
|
746
|
+
}
|
|
747
|
+
if (vid.category !== void 0 && ((_a = vid.category) === null || _a === void 0 ? void 0 : _a.length) > 256) {
|
|
748
|
+
errorHandler(new errors_1.InvalidVideoCategory(url, vid.category.length), level);
|
|
749
|
+
}
|
|
750
|
+
if (vid.family_friendly !== void 0 && !(0, types_1.isValidYesNo)(vid.family_friendly)) {
|
|
751
|
+
errorHandler(new errors_1.InvalidVideoFamilyFriendly(url, vid.family_friendly), level);
|
|
752
|
+
}
|
|
753
|
+
if (vid.restriction) {
|
|
754
|
+
if (!types_2.validators.restriction.test(vid.restriction)) {
|
|
755
|
+
errorHandler(new errors_1.InvalidVideoRestriction(url, vid.restriction), level);
|
|
756
|
+
}
|
|
757
|
+
if (!vid["restriction:relationship"] || !(0, types_1.isAllowDeny)(vid["restriction:relationship"])) {
|
|
758
|
+
errorHandler(new errors_1.InvalidVideoRestrictionRelationship(url, vid["restriction:relationship"]), level);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (vid.price === "" && vid["price:type"] === void 0 || vid["price:type"] !== void 0 && !(0, types_1.isPriceType)(vid["price:type"])) {
|
|
762
|
+
errorHandler(new errors_1.InvalidVideoPriceType(url, vid["price:type"], vid.price), level);
|
|
763
|
+
}
|
|
764
|
+
if (vid["price:resolution"] !== void 0 && !(0, types_1.isResolution)(vid["price:resolution"])) {
|
|
765
|
+
errorHandler(new errors_1.InvalidVideoResolution(url, vid["price:resolution"]), level);
|
|
766
|
+
}
|
|
767
|
+
if (vid["price:currency"] !== void 0 && !types_2.validators["price:currency"].test(vid["price:currency"])) {
|
|
768
|
+
errorHandler(new errors_1.InvalidVideoPriceCurrency(url, vid["price:currency"]), level);
|
|
769
|
+
}
|
|
770
|
+
validate(vid, "video", url, level);
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
return conf;
|
|
774
|
+
}
|
|
775
|
+
exports.validateSMIOptions = validateSMIOptions;
|
|
776
|
+
function mergeStreams(streams, options) {
|
|
777
|
+
let pass = new stream_1.PassThrough(options);
|
|
778
|
+
let waiting = streams.length;
|
|
779
|
+
for (const stream of streams) {
|
|
780
|
+
pass = stream.pipe(pass, { end: false });
|
|
781
|
+
stream.once("end", () => --waiting === 0 && pass.emit("end"));
|
|
782
|
+
}
|
|
783
|
+
return pass;
|
|
784
|
+
}
|
|
785
|
+
exports.mergeStreams = mergeStreams;
|
|
786
|
+
var ReadlineStream = class extends stream_1.Readable {
|
|
787
|
+
constructor(options) {
|
|
788
|
+
if (options.autoDestroy === void 0) {
|
|
789
|
+
options.autoDestroy = true;
|
|
790
|
+
}
|
|
791
|
+
options.objectMode = true;
|
|
792
|
+
super(options);
|
|
793
|
+
this._source = (0, readline_1.createInterface)({
|
|
794
|
+
input: options.input,
|
|
795
|
+
terminal: false,
|
|
796
|
+
crlfDelay: Infinity
|
|
797
|
+
});
|
|
798
|
+
this._source.on("line", (chunk2) => {
|
|
799
|
+
if (!this.push(chunk2))
|
|
800
|
+
this._source.pause();
|
|
801
|
+
});
|
|
802
|
+
this._source.on("close", () => {
|
|
803
|
+
this.push(null);
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
_read(size) {
|
|
807
|
+
this._source.resume();
|
|
808
|
+
}
|
|
809
|
+
};
|
|
810
|
+
exports.ReadlineStream = ReadlineStream;
|
|
811
|
+
function lineSeparatedURLsToSitemapOptions(stream, { isJSON } = {}) {
|
|
812
|
+
return new ReadlineStream({ input: stream }).pipe(new stream_1.Transform({
|
|
813
|
+
objectMode: true,
|
|
814
|
+
transform: (line, encoding, cb) => {
|
|
815
|
+
if (isJSON || isJSON === void 0 && line[0] === "{") {
|
|
816
|
+
cb(null, JSON.parse(line));
|
|
817
|
+
} else {
|
|
818
|
+
cb(null, line);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}));
|
|
822
|
+
}
|
|
823
|
+
exports.lineSeparatedURLsToSitemapOptions = lineSeparatedURLsToSitemapOptions;
|
|
824
|
+
function chunk(array, size = 1) {
|
|
825
|
+
size = Math.max(Math.trunc(size), 0);
|
|
826
|
+
const length = array ? array.length : 0;
|
|
827
|
+
if (!length || size < 1) {
|
|
828
|
+
return [];
|
|
829
|
+
}
|
|
830
|
+
const result = Array(Math.ceil(length / size));
|
|
831
|
+
let index = 0, resIndex = 0;
|
|
832
|
+
while (index < length) {
|
|
833
|
+
result[resIndex++] = array.slice(index, index += size);
|
|
834
|
+
}
|
|
835
|
+
return result;
|
|
836
|
+
}
|
|
837
|
+
exports.chunk = chunk;
|
|
838
|
+
function boolToYESNO(bool) {
|
|
839
|
+
if (bool === void 0) {
|
|
840
|
+
return bool;
|
|
841
|
+
}
|
|
842
|
+
if (typeof bool === "boolean") {
|
|
843
|
+
return bool ? types_1.EnumYesNo.yes : types_1.EnumYesNo.no;
|
|
844
|
+
}
|
|
845
|
+
return bool;
|
|
846
|
+
}
|
|
847
|
+
function normalizeURL(elem, hostname, lastmodDateOnly = false) {
|
|
848
|
+
let smi = {
|
|
849
|
+
img: [],
|
|
850
|
+
video: [],
|
|
851
|
+
links: [],
|
|
852
|
+
url: ""
|
|
853
|
+
};
|
|
854
|
+
let smiLoose;
|
|
855
|
+
if (typeof elem === "string") {
|
|
856
|
+
smi.url = elem;
|
|
857
|
+
smiLoose = { url: elem };
|
|
858
|
+
} else {
|
|
859
|
+
smiLoose = elem;
|
|
860
|
+
}
|
|
861
|
+
smi.url = new url_1.URL(smiLoose.url, hostname).toString();
|
|
862
|
+
let img = [];
|
|
863
|
+
if (smiLoose.img) {
|
|
864
|
+
if (typeof smiLoose.img === "string") {
|
|
865
|
+
smiLoose.img = [{ url: smiLoose.img }];
|
|
866
|
+
} else if (!Array.isArray(smiLoose.img)) {
|
|
867
|
+
smiLoose.img = [smiLoose.img];
|
|
868
|
+
}
|
|
869
|
+
img = smiLoose.img.map((el) => typeof el === "string" ? { url: el } : el);
|
|
870
|
+
}
|
|
871
|
+
smi.img = img.map((el) => __spreadProps(__spreadValues({}, el), {
|
|
872
|
+
url: new url_1.URL(el.url, hostname).toString()
|
|
873
|
+
}));
|
|
874
|
+
let links = [];
|
|
875
|
+
if (smiLoose.links) {
|
|
876
|
+
links = smiLoose.links;
|
|
877
|
+
}
|
|
878
|
+
smi.links = links.map((link) => {
|
|
879
|
+
return __spreadProps(__spreadValues({}, link), { url: new url_1.URL(link.url, hostname).toString() });
|
|
880
|
+
});
|
|
881
|
+
if (smiLoose.video) {
|
|
882
|
+
if (!Array.isArray(smiLoose.video)) {
|
|
883
|
+
smiLoose.video = [smiLoose.video];
|
|
884
|
+
}
|
|
885
|
+
smi.video = smiLoose.video.map((video) => {
|
|
886
|
+
const nv = __spreadProps(__spreadValues({}, video), {
|
|
887
|
+
family_friendly: boolToYESNO(video.family_friendly),
|
|
888
|
+
live: boolToYESNO(video.live),
|
|
889
|
+
requires_subscription: boolToYESNO(video.requires_subscription),
|
|
890
|
+
tag: [],
|
|
891
|
+
rating: void 0
|
|
892
|
+
});
|
|
893
|
+
if (video.tag !== void 0) {
|
|
894
|
+
nv.tag = !Array.isArray(video.tag) ? [video.tag] : video.tag;
|
|
895
|
+
}
|
|
896
|
+
if (video.rating !== void 0) {
|
|
897
|
+
if (typeof video.rating === "string") {
|
|
898
|
+
nv.rating = parseFloat(video.rating);
|
|
899
|
+
} else {
|
|
900
|
+
nv.rating = video.rating;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
if (typeof video.view_count === "string") {
|
|
904
|
+
nv.view_count = parseInt(video.view_count, 10);
|
|
905
|
+
} else if (typeof video.view_count === "number") {
|
|
906
|
+
nv.view_count = video.view_count;
|
|
907
|
+
}
|
|
908
|
+
return nv;
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
if (smiLoose.lastmodfile) {
|
|
912
|
+
const { mtime } = (0, fs_1.statSync)(smiLoose.lastmodfile);
|
|
913
|
+
smi.lastmod = new Date(mtime).toISOString();
|
|
914
|
+
} else if (smiLoose.lastmodISO) {
|
|
915
|
+
smi.lastmod = new Date(smiLoose.lastmodISO).toISOString();
|
|
916
|
+
} else if (smiLoose.lastmod) {
|
|
917
|
+
smi.lastmod = new Date(smiLoose.lastmod).toISOString();
|
|
918
|
+
}
|
|
919
|
+
if (lastmodDateOnly && smi.lastmod) {
|
|
920
|
+
smi.lastmod = smi.lastmod.slice(0, 10);
|
|
921
|
+
}
|
|
922
|
+
delete smiLoose.lastmodfile;
|
|
923
|
+
delete smiLoose.lastmodISO;
|
|
924
|
+
smi = __spreadValues(__spreadValues({}, smiLoose), smi);
|
|
925
|
+
return smi;
|
|
926
|
+
}
|
|
927
|
+
exports.normalizeURL = normalizeURL;
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
|
|
931
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-stream.js
|
|
932
|
+
var require_sitemap_stream = __commonJS({
|
|
933
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-stream.js"(exports) {
|
|
934
|
+
"use strict";
|
|
935
|
+
init_cjs_shims();
|
|
936
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
937
|
+
exports.streamToPromise = exports.SitemapStream = exports.closetag = exports.stylesheetInclude = void 0;
|
|
938
|
+
var stream_1 = require("stream");
|
|
939
|
+
var types_1 = require_types();
|
|
940
|
+
var utils_1 = require_utils();
|
|
941
|
+
var sitemap_item_stream_1 = require_sitemap_item_stream();
|
|
942
|
+
var errors_1 = require_errors();
|
|
943
|
+
var xmlDec = '<?xml version="1.0" encoding="UTF-8"?>';
|
|
944
|
+
var stylesheetInclude = (url) => {
|
|
945
|
+
return `<?xml-stylesheet type="text/xsl" href="${url}"?>`;
|
|
946
|
+
};
|
|
947
|
+
exports.stylesheetInclude = stylesheetInclude;
|
|
948
|
+
var urlsetTagStart = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
|
|
949
|
+
var getURLSetNs = ({ news, video, image, xhtml, custom }, xslURL) => {
|
|
950
|
+
let ns = xmlDec;
|
|
951
|
+
if (xslURL) {
|
|
952
|
+
ns += (0, exports.stylesheetInclude)(xslURL);
|
|
953
|
+
}
|
|
954
|
+
ns += urlsetTagStart;
|
|
955
|
+
if (news) {
|
|
956
|
+
ns += ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"';
|
|
957
|
+
}
|
|
958
|
+
if (xhtml) {
|
|
959
|
+
ns += ' xmlns:xhtml="http://www.w3.org/1999/xhtml"';
|
|
960
|
+
}
|
|
961
|
+
if (image) {
|
|
962
|
+
ns += ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"';
|
|
963
|
+
}
|
|
964
|
+
if (video) {
|
|
965
|
+
ns += ' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"';
|
|
966
|
+
}
|
|
967
|
+
if (custom) {
|
|
968
|
+
ns += " " + custom.join(" ");
|
|
969
|
+
}
|
|
970
|
+
return ns + ">";
|
|
971
|
+
};
|
|
972
|
+
exports.closetag = "</urlset>";
|
|
973
|
+
var defaultXMLNS = {
|
|
974
|
+
news: true,
|
|
975
|
+
xhtml: true,
|
|
976
|
+
image: true,
|
|
977
|
+
video: true
|
|
978
|
+
};
|
|
979
|
+
var defaultStreamOpts = {
|
|
980
|
+
xmlns: defaultXMLNS
|
|
981
|
+
};
|
|
982
|
+
var SitemapStream2 = class extends stream_1.Transform {
|
|
983
|
+
constructor(opts = defaultStreamOpts) {
|
|
984
|
+
opts.objectMode = true;
|
|
985
|
+
super(opts);
|
|
986
|
+
this.hasHeadOutput = false;
|
|
987
|
+
this.hostname = opts.hostname;
|
|
988
|
+
this.level = opts.level || types_1.ErrorLevel.WARN;
|
|
989
|
+
this.errorHandler = opts.errorHandler;
|
|
990
|
+
this.smiStream = new sitemap_item_stream_1.SitemapItemStream({ level: opts.level });
|
|
991
|
+
this.smiStream.on("data", (data) => this.push(data));
|
|
992
|
+
this.lastmodDateOnly = opts.lastmodDateOnly || false;
|
|
993
|
+
this.xmlNS = opts.xmlns || defaultXMLNS;
|
|
994
|
+
this.xslUrl = opts.xslUrl;
|
|
995
|
+
}
|
|
996
|
+
_transform(item, encoding, callback) {
|
|
997
|
+
if (!this.hasHeadOutput) {
|
|
998
|
+
this.hasHeadOutput = true;
|
|
999
|
+
this.push(getURLSetNs(this.xmlNS, this.xslUrl));
|
|
1000
|
+
}
|
|
1001
|
+
this.smiStream.write((0, utils_1.validateSMIOptions)((0, utils_1.normalizeURL)(item, this.hostname, this.lastmodDateOnly), this.level, this.errorHandler));
|
|
1002
|
+
callback();
|
|
1003
|
+
}
|
|
1004
|
+
_flush(cb) {
|
|
1005
|
+
if (!this.hasHeadOutput) {
|
|
1006
|
+
cb(new errors_1.EmptySitemap());
|
|
1007
|
+
} else {
|
|
1008
|
+
this.push(exports.closetag);
|
|
1009
|
+
cb();
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
exports.SitemapStream = SitemapStream2;
|
|
1014
|
+
function streamToPromise2(stream) {
|
|
1015
|
+
return new Promise((resolve2, reject) => {
|
|
1016
|
+
const drain = [];
|
|
1017
|
+
stream.pipe(new stream_1.Writable({
|
|
1018
|
+
write(chunk, enc, next) {
|
|
1019
|
+
drain.push(chunk);
|
|
1020
|
+
next();
|
|
1021
|
+
}
|
|
1022
|
+
})).on("error", reject).on("finish", () => {
|
|
1023
|
+
if (!drain.length) {
|
|
1024
|
+
reject(new errors_1.EmptyStream());
|
|
1025
|
+
} else {
|
|
1026
|
+
resolve2(Buffer.concat(drain));
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
exports.streamToPromise = streamToPromise2;
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-stream.js
|
|
1036
|
+
var require_sitemap_index_stream = __commonJS({
|
|
1037
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-stream.js"(exports) {
|
|
1038
|
+
"use strict";
|
|
1039
|
+
init_cjs_shims();
|
|
1040
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1041
|
+
exports.SitemapAndIndexStream = exports.SitemapIndexStream = exports.IndexTagNames = void 0;
|
|
1042
|
+
var stream_1 = require("stream");
|
|
1043
|
+
var types_1 = require_types();
|
|
1044
|
+
var sitemap_stream_1 = require_sitemap_stream();
|
|
1045
|
+
var sitemap_xml_1 = require_sitemap_xml();
|
|
1046
|
+
var IndexTagNames;
|
|
1047
|
+
(function(IndexTagNames2) {
|
|
1048
|
+
IndexTagNames2["sitemap"] = "sitemap";
|
|
1049
|
+
IndexTagNames2["loc"] = "loc";
|
|
1050
|
+
IndexTagNames2["lastmod"] = "lastmod";
|
|
1051
|
+
})(IndexTagNames = exports.IndexTagNames || (exports.IndexTagNames = {}));
|
|
1052
|
+
var xmlDec = '<?xml version="1.0" encoding="UTF-8"?>';
|
|
1053
|
+
var sitemapIndexTagStart = '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
|
1054
|
+
var closetag = "</sitemapindex>";
|
|
1055
|
+
var defaultStreamOpts = {};
|
|
1056
|
+
var SitemapIndexStream = class extends stream_1.Transform {
|
|
1057
|
+
constructor(opts = defaultStreamOpts) {
|
|
1058
|
+
var _a;
|
|
1059
|
+
opts.objectMode = true;
|
|
1060
|
+
super(opts);
|
|
1061
|
+
this.hasHeadOutput = false;
|
|
1062
|
+
this.lastmodDateOnly = opts.lastmodDateOnly || false;
|
|
1063
|
+
this.level = (_a = opts.level) !== null && _a !== void 0 ? _a : types_1.ErrorLevel.WARN;
|
|
1064
|
+
this.xslUrl = opts.xslUrl;
|
|
1065
|
+
}
|
|
1066
|
+
_transform(item, encoding, callback) {
|
|
1067
|
+
if (!this.hasHeadOutput) {
|
|
1068
|
+
this.hasHeadOutput = true;
|
|
1069
|
+
let stylesheet = "";
|
|
1070
|
+
if (this.xslUrl) {
|
|
1071
|
+
stylesheet = (0, sitemap_stream_1.stylesheetInclude)(this.xslUrl);
|
|
1072
|
+
}
|
|
1073
|
+
this.push(xmlDec + stylesheet + sitemapIndexTagStart);
|
|
1074
|
+
}
|
|
1075
|
+
this.push((0, sitemap_xml_1.otag)(IndexTagNames.sitemap));
|
|
1076
|
+
if (typeof item === "string") {
|
|
1077
|
+
this.push((0, sitemap_xml_1.element)(IndexTagNames.loc, item));
|
|
1078
|
+
} else {
|
|
1079
|
+
this.push((0, sitemap_xml_1.element)(IndexTagNames.loc, item.url));
|
|
1080
|
+
if (item.lastmod) {
|
|
1081
|
+
const lastmod = new Date(item.lastmod).toISOString();
|
|
1082
|
+
this.push((0, sitemap_xml_1.element)(IndexTagNames.lastmod, this.lastmodDateOnly ? lastmod.slice(0, 10) : lastmod));
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
this.push((0, sitemap_xml_1.ctag)(IndexTagNames.sitemap));
|
|
1086
|
+
callback();
|
|
1087
|
+
}
|
|
1088
|
+
_flush(cb) {
|
|
1089
|
+
this.push(closetag);
|
|
1090
|
+
cb();
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
exports.SitemapIndexStream = SitemapIndexStream;
|
|
1094
|
+
var SitemapAndIndexStream = class extends SitemapIndexStream {
|
|
1095
|
+
constructor(opts) {
|
|
1096
|
+
var _a;
|
|
1097
|
+
opts.objectMode = true;
|
|
1098
|
+
super(opts);
|
|
1099
|
+
this.i = 0;
|
|
1100
|
+
this.getSitemapStream = opts.getSitemapStream;
|
|
1101
|
+
[this.idxItem, this.currentSitemap, this.currentSitemapPipeline] = this.getSitemapStream(0);
|
|
1102
|
+
this.limit = (_a = opts.limit) !== null && _a !== void 0 ? _a : 45e3;
|
|
1103
|
+
}
|
|
1104
|
+
_writeSMI(item) {
|
|
1105
|
+
this.currentSitemap.write(item);
|
|
1106
|
+
this.i++;
|
|
1107
|
+
}
|
|
1108
|
+
_transform(item, encoding, callback) {
|
|
1109
|
+
var _a;
|
|
1110
|
+
if (this.i === 0) {
|
|
1111
|
+
this._writeSMI(item);
|
|
1112
|
+
super._transform(this.idxItem, encoding, callback);
|
|
1113
|
+
} else if (this.i % this.limit === 0) {
|
|
1114
|
+
const onFinish = () => {
|
|
1115
|
+
const [idxItem, currentSitemap, currentSitemapPipeline] = this.getSitemapStream(this.i / this.limit);
|
|
1116
|
+
this.currentSitemap = currentSitemap;
|
|
1117
|
+
this.currentSitemapPipeline = currentSitemapPipeline;
|
|
1118
|
+
this._writeSMI(item);
|
|
1119
|
+
super._transform(idxItem, encoding, callback);
|
|
1120
|
+
};
|
|
1121
|
+
(_a = this.currentSitemapPipeline) === null || _a === void 0 ? void 0 : _a.on("finish", onFinish);
|
|
1122
|
+
this.currentSitemap.end(!this.currentSitemapPipeline ? onFinish : void 0);
|
|
1123
|
+
} else {
|
|
1124
|
+
this._writeSMI(item);
|
|
1125
|
+
callback();
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
_flush(cb) {
|
|
1129
|
+
var _a;
|
|
1130
|
+
const onFinish = () => super._flush(cb);
|
|
1131
|
+
(_a = this.currentSitemapPipeline) === null || _a === void 0 ? void 0 : _a.on("finish", onFinish);
|
|
1132
|
+
this.currentSitemap.end(!this.currentSitemapPipeline ? onFinish : void 0);
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
exports.SitemapAndIndexStream = SitemapAndIndexStream;
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/xmllint.js
|
|
1140
|
+
var require_xmllint = __commonJS({
|
|
1141
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/xmllint.js"(exports) {
|
|
1142
|
+
"use strict";
|
|
1143
|
+
init_cjs_shims();
|
|
1144
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1145
|
+
exports.xmlLint = void 0;
|
|
1146
|
+
var path_1 = require("path");
|
|
1147
|
+
var child_process_1 = require("child_process");
|
|
1148
|
+
var errors_1 = require_errors();
|
|
1149
|
+
function xmlLint(xml) {
|
|
1150
|
+
const args = [
|
|
1151
|
+
"--schema",
|
|
1152
|
+
(0, path_1.resolve)(__dirname, "..", "..", "schema", "all.xsd"),
|
|
1153
|
+
"--noout",
|
|
1154
|
+
"-"
|
|
1155
|
+
];
|
|
1156
|
+
if (typeof xml === "string") {
|
|
1157
|
+
args[args.length - 1] = xml;
|
|
1158
|
+
}
|
|
1159
|
+
return new Promise((resolve2, reject) => {
|
|
1160
|
+
(0, child_process_1.execFile)("which", ["xmllint"], (error, stdout, stderr) => {
|
|
1161
|
+
if (error) {
|
|
1162
|
+
reject([new errors_1.XMLLintUnavailable()]);
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1165
|
+
const xmllint = (0, child_process_1.execFile)("xmllint", args, (error2, stdout2, stderr2) => {
|
|
1166
|
+
if (error2) {
|
|
1167
|
+
reject([error2, stderr2]);
|
|
1168
|
+
}
|
|
1169
|
+
resolve2();
|
|
1170
|
+
});
|
|
1171
|
+
if (xmllint.stdout) {
|
|
1172
|
+
xmllint.stdout.unpipe();
|
|
1173
|
+
if (typeof xml !== "string" && xml && xmllint.stdin) {
|
|
1174
|
+
xml.pipe(xmllint.stdin);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
exports.xmlLint = xmlLint;
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
// node_modules/.pnpm/sax@1.2.4/node_modules/sax/lib/sax.js
|
|
1185
|
+
var require_sax = __commonJS({
|
|
1186
|
+
"node_modules/.pnpm/sax@1.2.4/node_modules/sax/lib/sax.js"(exports) {
|
|
1187
|
+
init_cjs_shims();
|
|
1188
|
+
(function(sax) {
|
|
1189
|
+
sax.parser = function(strict, opt) {
|
|
1190
|
+
return new SAXParser(strict, opt);
|
|
1191
|
+
};
|
|
1192
|
+
sax.SAXParser = SAXParser;
|
|
1193
|
+
sax.SAXStream = SAXStream;
|
|
1194
|
+
sax.createStream = createStream;
|
|
1195
|
+
sax.MAX_BUFFER_LENGTH = 64 * 1024;
|
|
1196
|
+
var buffers = [
|
|
1197
|
+
"comment",
|
|
1198
|
+
"sgmlDecl",
|
|
1199
|
+
"textNode",
|
|
1200
|
+
"tagName",
|
|
1201
|
+
"doctype",
|
|
1202
|
+
"procInstName",
|
|
1203
|
+
"procInstBody",
|
|
1204
|
+
"entity",
|
|
1205
|
+
"attribName",
|
|
1206
|
+
"attribValue",
|
|
1207
|
+
"cdata",
|
|
1208
|
+
"script"
|
|
1209
|
+
];
|
|
1210
|
+
sax.EVENTS = [
|
|
1211
|
+
"text",
|
|
1212
|
+
"processinginstruction",
|
|
1213
|
+
"sgmldeclaration",
|
|
1214
|
+
"doctype",
|
|
1215
|
+
"comment",
|
|
1216
|
+
"opentagstart",
|
|
1217
|
+
"attribute",
|
|
1218
|
+
"opentag",
|
|
1219
|
+
"closetag",
|
|
1220
|
+
"opencdata",
|
|
1221
|
+
"cdata",
|
|
1222
|
+
"closecdata",
|
|
1223
|
+
"error",
|
|
1224
|
+
"end",
|
|
1225
|
+
"ready",
|
|
1226
|
+
"script",
|
|
1227
|
+
"opennamespace",
|
|
1228
|
+
"closenamespace"
|
|
1229
|
+
];
|
|
1230
|
+
function SAXParser(strict, opt) {
|
|
1231
|
+
if (!(this instanceof SAXParser)) {
|
|
1232
|
+
return new SAXParser(strict, opt);
|
|
1233
|
+
}
|
|
1234
|
+
var parser = this;
|
|
1235
|
+
clearBuffers(parser);
|
|
1236
|
+
parser.q = parser.c = "";
|
|
1237
|
+
parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH;
|
|
1238
|
+
parser.opt = opt || {};
|
|
1239
|
+
parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags;
|
|
1240
|
+
parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase";
|
|
1241
|
+
parser.tags = [];
|
|
1242
|
+
parser.closed = parser.closedRoot = parser.sawRoot = false;
|
|
1243
|
+
parser.tag = parser.error = null;
|
|
1244
|
+
parser.strict = !!strict;
|
|
1245
|
+
parser.noscript = !!(strict || parser.opt.noscript);
|
|
1246
|
+
parser.state = S.BEGIN;
|
|
1247
|
+
parser.strictEntities = parser.opt.strictEntities;
|
|
1248
|
+
parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES);
|
|
1249
|
+
parser.attribList = [];
|
|
1250
|
+
if (parser.opt.xmlns) {
|
|
1251
|
+
parser.ns = Object.create(rootNS);
|
|
1252
|
+
}
|
|
1253
|
+
parser.trackPosition = parser.opt.position !== false;
|
|
1254
|
+
if (parser.trackPosition) {
|
|
1255
|
+
parser.position = parser.line = parser.column = 0;
|
|
1256
|
+
}
|
|
1257
|
+
emit(parser, "onready");
|
|
1258
|
+
}
|
|
1259
|
+
if (!Object.create) {
|
|
1260
|
+
Object.create = function(o) {
|
|
1261
|
+
function F() {
|
|
1262
|
+
}
|
|
1263
|
+
F.prototype = o;
|
|
1264
|
+
var newf = new F();
|
|
1265
|
+
return newf;
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
if (!Object.keys) {
|
|
1269
|
+
Object.keys = function(o) {
|
|
1270
|
+
var a = [];
|
|
1271
|
+
for (var i in o)
|
|
1272
|
+
if (o.hasOwnProperty(i))
|
|
1273
|
+
a.push(i);
|
|
1274
|
+
return a;
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
function checkBufferLength(parser) {
|
|
1278
|
+
var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10);
|
|
1279
|
+
var maxActual = 0;
|
|
1280
|
+
for (var i = 0, l = buffers.length; i < l; i++) {
|
|
1281
|
+
var len = parser[buffers[i]].length;
|
|
1282
|
+
if (len > maxAllowed) {
|
|
1283
|
+
switch (buffers[i]) {
|
|
1284
|
+
case "textNode":
|
|
1285
|
+
closeText(parser);
|
|
1286
|
+
break;
|
|
1287
|
+
case "cdata":
|
|
1288
|
+
emitNode(parser, "oncdata", parser.cdata);
|
|
1289
|
+
parser.cdata = "";
|
|
1290
|
+
break;
|
|
1291
|
+
case "script":
|
|
1292
|
+
emitNode(parser, "onscript", parser.script);
|
|
1293
|
+
parser.script = "";
|
|
1294
|
+
break;
|
|
1295
|
+
default:
|
|
1296
|
+
error(parser, "Max buffer length exceeded: " + buffers[i]);
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
maxActual = Math.max(maxActual, len);
|
|
1300
|
+
}
|
|
1301
|
+
var m = sax.MAX_BUFFER_LENGTH - maxActual;
|
|
1302
|
+
parser.bufferCheckPosition = m + parser.position;
|
|
1303
|
+
}
|
|
1304
|
+
function clearBuffers(parser) {
|
|
1305
|
+
for (var i = 0, l = buffers.length; i < l; i++) {
|
|
1306
|
+
parser[buffers[i]] = "";
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
function flushBuffers(parser) {
|
|
1310
|
+
closeText(parser);
|
|
1311
|
+
if (parser.cdata !== "") {
|
|
1312
|
+
emitNode(parser, "oncdata", parser.cdata);
|
|
1313
|
+
parser.cdata = "";
|
|
1314
|
+
}
|
|
1315
|
+
if (parser.script !== "") {
|
|
1316
|
+
emitNode(parser, "onscript", parser.script);
|
|
1317
|
+
parser.script = "";
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
SAXParser.prototype = {
|
|
1321
|
+
end: function() {
|
|
1322
|
+
end(this);
|
|
1323
|
+
},
|
|
1324
|
+
write,
|
|
1325
|
+
resume: function() {
|
|
1326
|
+
this.error = null;
|
|
1327
|
+
return this;
|
|
1328
|
+
},
|
|
1329
|
+
close: function() {
|
|
1330
|
+
return this.write(null);
|
|
1331
|
+
},
|
|
1332
|
+
flush: function() {
|
|
1333
|
+
flushBuffers(this);
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
var Stream;
|
|
1337
|
+
try {
|
|
1338
|
+
Stream = require("stream").Stream;
|
|
1339
|
+
} catch (ex) {
|
|
1340
|
+
Stream = function() {
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
var streamWraps = sax.EVENTS.filter(function(ev) {
|
|
1344
|
+
return ev !== "error" && ev !== "end";
|
|
1345
|
+
});
|
|
1346
|
+
function createStream(strict, opt) {
|
|
1347
|
+
return new SAXStream(strict, opt);
|
|
1348
|
+
}
|
|
1349
|
+
function SAXStream(strict, opt) {
|
|
1350
|
+
if (!(this instanceof SAXStream)) {
|
|
1351
|
+
return new SAXStream(strict, opt);
|
|
1352
|
+
}
|
|
1353
|
+
Stream.apply(this);
|
|
1354
|
+
this._parser = new SAXParser(strict, opt);
|
|
1355
|
+
this.writable = true;
|
|
1356
|
+
this.readable = true;
|
|
1357
|
+
var me = this;
|
|
1358
|
+
this._parser.onend = function() {
|
|
1359
|
+
me.emit("end");
|
|
1360
|
+
};
|
|
1361
|
+
this._parser.onerror = function(er) {
|
|
1362
|
+
me.emit("error", er);
|
|
1363
|
+
me._parser.error = null;
|
|
1364
|
+
};
|
|
1365
|
+
this._decoder = null;
|
|
1366
|
+
streamWraps.forEach(function(ev) {
|
|
1367
|
+
Object.defineProperty(me, "on" + ev, {
|
|
1368
|
+
get: function() {
|
|
1369
|
+
return me._parser["on" + ev];
|
|
1370
|
+
},
|
|
1371
|
+
set: function(h) {
|
|
1372
|
+
if (!h) {
|
|
1373
|
+
me.removeAllListeners(ev);
|
|
1374
|
+
me._parser["on" + ev] = h;
|
|
1375
|
+
return h;
|
|
1376
|
+
}
|
|
1377
|
+
me.on(ev, h);
|
|
1378
|
+
},
|
|
1379
|
+
enumerable: true,
|
|
1380
|
+
configurable: false
|
|
1381
|
+
});
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
SAXStream.prototype = Object.create(Stream.prototype, {
|
|
1385
|
+
constructor: {
|
|
1386
|
+
value: SAXStream
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
SAXStream.prototype.write = function(data) {
|
|
1390
|
+
if (typeof Buffer === "function" && typeof Buffer.isBuffer === "function" && Buffer.isBuffer(data)) {
|
|
1391
|
+
if (!this._decoder) {
|
|
1392
|
+
var SD = require("string_decoder").StringDecoder;
|
|
1393
|
+
this._decoder = new SD("utf8");
|
|
1394
|
+
}
|
|
1395
|
+
data = this._decoder.write(data);
|
|
1396
|
+
}
|
|
1397
|
+
this._parser.write(data.toString());
|
|
1398
|
+
this.emit("data", data);
|
|
1399
|
+
return true;
|
|
1400
|
+
};
|
|
1401
|
+
SAXStream.prototype.end = function(chunk) {
|
|
1402
|
+
if (chunk && chunk.length) {
|
|
1403
|
+
this.write(chunk);
|
|
1404
|
+
}
|
|
1405
|
+
this._parser.end();
|
|
1406
|
+
return true;
|
|
1407
|
+
};
|
|
1408
|
+
SAXStream.prototype.on = function(ev, handler) {
|
|
1409
|
+
var me = this;
|
|
1410
|
+
if (!me._parser["on" + ev] && streamWraps.indexOf(ev) !== -1) {
|
|
1411
|
+
me._parser["on" + ev] = function() {
|
|
1412
|
+
var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
|
|
1413
|
+
args.splice(0, 0, ev);
|
|
1414
|
+
me.emit.apply(me, args);
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
return Stream.prototype.on.call(me, ev, handler);
|
|
1418
|
+
};
|
|
1419
|
+
var CDATA = "[CDATA[";
|
|
1420
|
+
var DOCTYPE = "DOCTYPE";
|
|
1421
|
+
var XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
|
|
1422
|
+
var XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
|
|
1423
|
+
var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE };
|
|
1424
|
+
var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|
1425
|
+
var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|
1426
|
+
var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|
1427
|
+
var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|
1428
|
+
function isWhitespace(c) {
|
|
1429
|
+
return c === " " || c === "\n" || c === "\r" || c === " ";
|
|
1430
|
+
}
|
|
1431
|
+
function isQuote(c) {
|
|
1432
|
+
return c === '"' || c === "'";
|
|
1433
|
+
}
|
|
1434
|
+
function isAttribEnd(c) {
|
|
1435
|
+
return c === ">" || isWhitespace(c);
|
|
1436
|
+
}
|
|
1437
|
+
function isMatch(regex, c) {
|
|
1438
|
+
return regex.test(c);
|
|
1439
|
+
}
|
|
1440
|
+
function notMatch(regex, c) {
|
|
1441
|
+
return !isMatch(regex, c);
|
|
1442
|
+
}
|
|
1443
|
+
var S = 0;
|
|
1444
|
+
sax.STATE = {
|
|
1445
|
+
BEGIN: S++,
|
|
1446
|
+
BEGIN_WHITESPACE: S++,
|
|
1447
|
+
TEXT: S++,
|
|
1448
|
+
TEXT_ENTITY: S++,
|
|
1449
|
+
OPEN_WAKA: S++,
|
|
1450
|
+
SGML_DECL: S++,
|
|
1451
|
+
SGML_DECL_QUOTED: S++,
|
|
1452
|
+
DOCTYPE: S++,
|
|
1453
|
+
DOCTYPE_QUOTED: S++,
|
|
1454
|
+
DOCTYPE_DTD: S++,
|
|
1455
|
+
DOCTYPE_DTD_QUOTED: S++,
|
|
1456
|
+
COMMENT_STARTING: S++,
|
|
1457
|
+
COMMENT: S++,
|
|
1458
|
+
COMMENT_ENDING: S++,
|
|
1459
|
+
COMMENT_ENDED: S++,
|
|
1460
|
+
CDATA: S++,
|
|
1461
|
+
CDATA_ENDING: S++,
|
|
1462
|
+
CDATA_ENDING_2: S++,
|
|
1463
|
+
PROC_INST: S++,
|
|
1464
|
+
PROC_INST_BODY: S++,
|
|
1465
|
+
PROC_INST_ENDING: S++,
|
|
1466
|
+
OPEN_TAG: S++,
|
|
1467
|
+
OPEN_TAG_SLASH: S++,
|
|
1468
|
+
ATTRIB: S++,
|
|
1469
|
+
ATTRIB_NAME: S++,
|
|
1470
|
+
ATTRIB_NAME_SAW_WHITE: S++,
|
|
1471
|
+
ATTRIB_VALUE: S++,
|
|
1472
|
+
ATTRIB_VALUE_QUOTED: S++,
|
|
1473
|
+
ATTRIB_VALUE_CLOSED: S++,
|
|
1474
|
+
ATTRIB_VALUE_UNQUOTED: S++,
|
|
1475
|
+
ATTRIB_VALUE_ENTITY_Q: S++,
|
|
1476
|
+
ATTRIB_VALUE_ENTITY_U: S++,
|
|
1477
|
+
CLOSE_TAG: S++,
|
|
1478
|
+
CLOSE_TAG_SAW_WHITE: S++,
|
|
1479
|
+
SCRIPT: S++,
|
|
1480
|
+
SCRIPT_ENDING: S++
|
|
1481
|
+
};
|
|
1482
|
+
sax.XML_ENTITIES = {
|
|
1483
|
+
"amp": "&",
|
|
1484
|
+
"gt": ">",
|
|
1485
|
+
"lt": "<",
|
|
1486
|
+
"quot": '"',
|
|
1487
|
+
"apos": "'"
|
|
1488
|
+
};
|
|
1489
|
+
sax.ENTITIES = {
|
|
1490
|
+
"amp": "&",
|
|
1491
|
+
"gt": ">",
|
|
1492
|
+
"lt": "<",
|
|
1493
|
+
"quot": '"',
|
|
1494
|
+
"apos": "'",
|
|
1495
|
+
"AElig": 198,
|
|
1496
|
+
"Aacute": 193,
|
|
1497
|
+
"Acirc": 194,
|
|
1498
|
+
"Agrave": 192,
|
|
1499
|
+
"Aring": 197,
|
|
1500
|
+
"Atilde": 195,
|
|
1501
|
+
"Auml": 196,
|
|
1502
|
+
"Ccedil": 199,
|
|
1503
|
+
"ETH": 208,
|
|
1504
|
+
"Eacute": 201,
|
|
1505
|
+
"Ecirc": 202,
|
|
1506
|
+
"Egrave": 200,
|
|
1507
|
+
"Euml": 203,
|
|
1508
|
+
"Iacute": 205,
|
|
1509
|
+
"Icirc": 206,
|
|
1510
|
+
"Igrave": 204,
|
|
1511
|
+
"Iuml": 207,
|
|
1512
|
+
"Ntilde": 209,
|
|
1513
|
+
"Oacute": 211,
|
|
1514
|
+
"Ocirc": 212,
|
|
1515
|
+
"Ograve": 210,
|
|
1516
|
+
"Oslash": 216,
|
|
1517
|
+
"Otilde": 213,
|
|
1518
|
+
"Ouml": 214,
|
|
1519
|
+
"THORN": 222,
|
|
1520
|
+
"Uacute": 218,
|
|
1521
|
+
"Ucirc": 219,
|
|
1522
|
+
"Ugrave": 217,
|
|
1523
|
+
"Uuml": 220,
|
|
1524
|
+
"Yacute": 221,
|
|
1525
|
+
"aacute": 225,
|
|
1526
|
+
"acirc": 226,
|
|
1527
|
+
"aelig": 230,
|
|
1528
|
+
"agrave": 224,
|
|
1529
|
+
"aring": 229,
|
|
1530
|
+
"atilde": 227,
|
|
1531
|
+
"auml": 228,
|
|
1532
|
+
"ccedil": 231,
|
|
1533
|
+
"eacute": 233,
|
|
1534
|
+
"ecirc": 234,
|
|
1535
|
+
"egrave": 232,
|
|
1536
|
+
"eth": 240,
|
|
1537
|
+
"euml": 235,
|
|
1538
|
+
"iacute": 237,
|
|
1539
|
+
"icirc": 238,
|
|
1540
|
+
"igrave": 236,
|
|
1541
|
+
"iuml": 239,
|
|
1542
|
+
"ntilde": 241,
|
|
1543
|
+
"oacute": 243,
|
|
1544
|
+
"ocirc": 244,
|
|
1545
|
+
"ograve": 242,
|
|
1546
|
+
"oslash": 248,
|
|
1547
|
+
"otilde": 245,
|
|
1548
|
+
"ouml": 246,
|
|
1549
|
+
"szlig": 223,
|
|
1550
|
+
"thorn": 254,
|
|
1551
|
+
"uacute": 250,
|
|
1552
|
+
"ucirc": 251,
|
|
1553
|
+
"ugrave": 249,
|
|
1554
|
+
"uuml": 252,
|
|
1555
|
+
"yacute": 253,
|
|
1556
|
+
"yuml": 255,
|
|
1557
|
+
"copy": 169,
|
|
1558
|
+
"reg": 174,
|
|
1559
|
+
"nbsp": 160,
|
|
1560
|
+
"iexcl": 161,
|
|
1561
|
+
"cent": 162,
|
|
1562
|
+
"pound": 163,
|
|
1563
|
+
"curren": 164,
|
|
1564
|
+
"yen": 165,
|
|
1565
|
+
"brvbar": 166,
|
|
1566
|
+
"sect": 167,
|
|
1567
|
+
"uml": 168,
|
|
1568
|
+
"ordf": 170,
|
|
1569
|
+
"laquo": 171,
|
|
1570
|
+
"not": 172,
|
|
1571
|
+
"shy": 173,
|
|
1572
|
+
"macr": 175,
|
|
1573
|
+
"deg": 176,
|
|
1574
|
+
"plusmn": 177,
|
|
1575
|
+
"sup1": 185,
|
|
1576
|
+
"sup2": 178,
|
|
1577
|
+
"sup3": 179,
|
|
1578
|
+
"acute": 180,
|
|
1579
|
+
"micro": 181,
|
|
1580
|
+
"para": 182,
|
|
1581
|
+
"middot": 183,
|
|
1582
|
+
"cedil": 184,
|
|
1583
|
+
"ordm": 186,
|
|
1584
|
+
"raquo": 187,
|
|
1585
|
+
"frac14": 188,
|
|
1586
|
+
"frac12": 189,
|
|
1587
|
+
"frac34": 190,
|
|
1588
|
+
"iquest": 191,
|
|
1589
|
+
"times": 215,
|
|
1590
|
+
"divide": 247,
|
|
1591
|
+
"OElig": 338,
|
|
1592
|
+
"oelig": 339,
|
|
1593
|
+
"Scaron": 352,
|
|
1594
|
+
"scaron": 353,
|
|
1595
|
+
"Yuml": 376,
|
|
1596
|
+
"fnof": 402,
|
|
1597
|
+
"circ": 710,
|
|
1598
|
+
"tilde": 732,
|
|
1599
|
+
"Alpha": 913,
|
|
1600
|
+
"Beta": 914,
|
|
1601
|
+
"Gamma": 915,
|
|
1602
|
+
"Delta": 916,
|
|
1603
|
+
"Epsilon": 917,
|
|
1604
|
+
"Zeta": 918,
|
|
1605
|
+
"Eta": 919,
|
|
1606
|
+
"Theta": 920,
|
|
1607
|
+
"Iota": 921,
|
|
1608
|
+
"Kappa": 922,
|
|
1609
|
+
"Lambda": 923,
|
|
1610
|
+
"Mu": 924,
|
|
1611
|
+
"Nu": 925,
|
|
1612
|
+
"Xi": 926,
|
|
1613
|
+
"Omicron": 927,
|
|
1614
|
+
"Pi": 928,
|
|
1615
|
+
"Rho": 929,
|
|
1616
|
+
"Sigma": 931,
|
|
1617
|
+
"Tau": 932,
|
|
1618
|
+
"Upsilon": 933,
|
|
1619
|
+
"Phi": 934,
|
|
1620
|
+
"Chi": 935,
|
|
1621
|
+
"Psi": 936,
|
|
1622
|
+
"Omega": 937,
|
|
1623
|
+
"alpha": 945,
|
|
1624
|
+
"beta": 946,
|
|
1625
|
+
"gamma": 947,
|
|
1626
|
+
"delta": 948,
|
|
1627
|
+
"epsilon": 949,
|
|
1628
|
+
"zeta": 950,
|
|
1629
|
+
"eta": 951,
|
|
1630
|
+
"theta": 952,
|
|
1631
|
+
"iota": 953,
|
|
1632
|
+
"kappa": 954,
|
|
1633
|
+
"lambda": 955,
|
|
1634
|
+
"mu": 956,
|
|
1635
|
+
"nu": 957,
|
|
1636
|
+
"xi": 958,
|
|
1637
|
+
"omicron": 959,
|
|
1638
|
+
"pi": 960,
|
|
1639
|
+
"rho": 961,
|
|
1640
|
+
"sigmaf": 962,
|
|
1641
|
+
"sigma": 963,
|
|
1642
|
+
"tau": 964,
|
|
1643
|
+
"upsilon": 965,
|
|
1644
|
+
"phi": 966,
|
|
1645
|
+
"chi": 967,
|
|
1646
|
+
"psi": 968,
|
|
1647
|
+
"omega": 969,
|
|
1648
|
+
"thetasym": 977,
|
|
1649
|
+
"upsih": 978,
|
|
1650
|
+
"piv": 982,
|
|
1651
|
+
"ensp": 8194,
|
|
1652
|
+
"emsp": 8195,
|
|
1653
|
+
"thinsp": 8201,
|
|
1654
|
+
"zwnj": 8204,
|
|
1655
|
+
"zwj": 8205,
|
|
1656
|
+
"lrm": 8206,
|
|
1657
|
+
"rlm": 8207,
|
|
1658
|
+
"ndash": 8211,
|
|
1659
|
+
"mdash": 8212,
|
|
1660
|
+
"lsquo": 8216,
|
|
1661
|
+
"rsquo": 8217,
|
|
1662
|
+
"sbquo": 8218,
|
|
1663
|
+
"ldquo": 8220,
|
|
1664
|
+
"rdquo": 8221,
|
|
1665
|
+
"bdquo": 8222,
|
|
1666
|
+
"dagger": 8224,
|
|
1667
|
+
"Dagger": 8225,
|
|
1668
|
+
"bull": 8226,
|
|
1669
|
+
"hellip": 8230,
|
|
1670
|
+
"permil": 8240,
|
|
1671
|
+
"prime": 8242,
|
|
1672
|
+
"Prime": 8243,
|
|
1673
|
+
"lsaquo": 8249,
|
|
1674
|
+
"rsaquo": 8250,
|
|
1675
|
+
"oline": 8254,
|
|
1676
|
+
"frasl": 8260,
|
|
1677
|
+
"euro": 8364,
|
|
1678
|
+
"image": 8465,
|
|
1679
|
+
"weierp": 8472,
|
|
1680
|
+
"real": 8476,
|
|
1681
|
+
"trade": 8482,
|
|
1682
|
+
"alefsym": 8501,
|
|
1683
|
+
"larr": 8592,
|
|
1684
|
+
"uarr": 8593,
|
|
1685
|
+
"rarr": 8594,
|
|
1686
|
+
"darr": 8595,
|
|
1687
|
+
"harr": 8596,
|
|
1688
|
+
"crarr": 8629,
|
|
1689
|
+
"lArr": 8656,
|
|
1690
|
+
"uArr": 8657,
|
|
1691
|
+
"rArr": 8658,
|
|
1692
|
+
"dArr": 8659,
|
|
1693
|
+
"hArr": 8660,
|
|
1694
|
+
"forall": 8704,
|
|
1695
|
+
"part": 8706,
|
|
1696
|
+
"exist": 8707,
|
|
1697
|
+
"empty": 8709,
|
|
1698
|
+
"nabla": 8711,
|
|
1699
|
+
"isin": 8712,
|
|
1700
|
+
"notin": 8713,
|
|
1701
|
+
"ni": 8715,
|
|
1702
|
+
"prod": 8719,
|
|
1703
|
+
"sum": 8721,
|
|
1704
|
+
"minus": 8722,
|
|
1705
|
+
"lowast": 8727,
|
|
1706
|
+
"radic": 8730,
|
|
1707
|
+
"prop": 8733,
|
|
1708
|
+
"infin": 8734,
|
|
1709
|
+
"ang": 8736,
|
|
1710
|
+
"and": 8743,
|
|
1711
|
+
"or": 8744,
|
|
1712
|
+
"cap": 8745,
|
|
1713
|
+
"cup": 8746,
|
|
1714
|
+
"int": 8747,
|
|
1715
|
+
"there4": 8756,
|
|
1716
|
+
"sim": 8764,
|
|
1717
|
+
"cong": 8773,
|
|
1718
|
+
"asymp": 8776,
|
|
1719
|
+
"ne": 8800,
|
|
1720
|
+
"equiv": 8801,
|
|
1721
|
+
"le": 8804,
|
|
1722
|
+
"ge": 8805,
|
|
1723
|
+
"sub": 8834,
|
|
1724
|
+
"sup": 8835,
|
|
1725
|
+
"nsub": 8836,
|
|
1726
|
+
"sube": 8838,
|
|
1727
|
+
"supe": 8839,
|
|
1728
|
+
"oplus": 8853,
|
|
1729
|
+
"otimes": 8855,
|
|
1730
|
+
"perp": 8869,
|
|
1731
|
+
"sdot": 8901,
|
|
1732
|
+
"lceil": 8968,
|
|
1733
|
+
"rceil": 8969,
|
|
1734
|
+
"lfloor": 8970,
|
|
1735
|
+
"rfloor": 8971,
|
|
1736
|
+
"lang": 9001,
|
|
1737
|
+
"rang": 9002,
|
|
1738
|
+
"loz": 9674,
|
|
1739
|
+
"spades": 9824,
|
|
1740
|
+
"clubs": 9827,
|
|
1741
|
+
"hearts": 9829,
|
|
1742
|
+
"diams": 9830
|
|
1743
|
+
};
|
|
1744
|
+
Object.keys(sax.ENTITIES).forEach(function(key) {
|
|
1745
|
+
var e = sax.ENTITIES[key];
|
|
1746
|
+
var s2 = typeof e === "number" ? String.fromCharCode(e) : e;
|
|
1747
|
+
sax.ENTITIES[key] = s2;
|
|
1748
|
+
});
|
|
1749
|
+
for (var s in sax.STATE) {
|
|
1750
|
+
sax.STATE[sax.STATE[s]] = s;
|
|
1751
|
+
}
|
|
1752
|
+
S = sax.STATE;
|
|
1753
|
+
function emit(parser, event, data) {
|
|
1754
|
+
parser[event] && parser[event](data);
|
|
1755
|
+
}
|
|
1756
|
+
function emitNode(parser, nodeType, data) {
|
|
1757
|
+
if (parser.textNode)
|
|
1758
|
+
closeText(parser);
|
|
1759
|
+
emit(parser, nodeType, data);
|
|
1760
|
+
}
|
|
1761
|
+
function closeText(parser) {
|
|
1762
|
+
parser.textNode = textopts(parser.opt, parser.textNode);
|
|
1763
|
+
if (parser.textNode)
|
|
1764
|
+
emit(parser, "ontext", parser.textNode);
|
|
1765
|
+
parser.textNode = "";
|
|
1766
|
+
}
|
|
1767
|
+
function textopts(opt, text) {
|
|
1768
|
+
if (opt.trim)
|
|
1769
|
+
text = text.trim();
|
|
1770
|
+
if (opt.normalize)
|
|
1771
|
+
text = text.replace(/\s+/g, " ");
|
|
1772
|
+
return text;
|
|
1773
|
+
}
|
|
1774
|
+
function error(parser, er) {
|
|
1775
|
+
closeText(parser);
|
|
1776
|
+
if (parser.trackPosition) {
|
|
1777
|
+
er += "\nLine: " + parser.line + "\nColumn: " + parser.column + "\nChar: " + parser.c;
|
|
1778
|
+
}
|
|
1779
|
+
er = new Error(er);
|
|
1780
|
+
parser.error = er;
|
|
1781
|
+
emit(parser, "onerror", er);
|
|
1782
|
+
return parser;
|
|
1783
|
+
}
|
|
1784
|
+
function end(parser) {
|
|
1785
|
+
if (parser.sawRoot && !parser.closedRoot)
|
|
1786
|
+
strictFail(parser, "Unclosed root tag");
|
|
1787
|
+
if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
|
|
1788
|
+
error(parser, "Unexpected end");
|
|
1789
|
+
}
|
|
1790
|
+
closeText(parser);
|
|
1791
|
+
parser.c = "";
|
|
1792
|
+
parser.closed = true;
|
|
1793
|
+
emit(parser, "onend");
|
|
1794
|
+
SAXParser.call(parser, parser.strict, parser.opt);
|
|
1795
|
+
return parser;
|
|
1796
|
+
}
|
|
1797
|
+
function strictFail(parser, message) {
|
|
1798
|
+
if (typeof parser !== "object" || !(parser instanceof SAXParser)) {
|
|
1799
|
+
throw new Error("bad call to strictFail");
|
|
1800
|
+
}
|
|
1801
|
+
if (parser.strict) {
|
|
1802
|
+
error(parser, message);
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
function newTag(parser) {
|
|
1806
|
+
if (!parser.strict)
|
|
1807
|
+
parser.tagName = parser.tagName[parser.looseCase]();
|
|
1808
|
+
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
1809
|
+
var tag = parser.tag = { name: parser.tagName, attributes: {} };
|
|
1810
|
+
if (parser.opt.xmlns) {
|
|
1811
|
+
tag.ns = parent.ns;
|
|
1812
|
+
}
|
|
1813
|
+
parser.attribList.length = 0;
|
|
1814
|
+
emitNode(parser, "onopentagstart", tag);
|
|
1815
|
+
}
|
|
1816
|
+
function qname(name, attribute) {
|
|
1817
|
+
var i = name.indexOf(":");
|
|
1818
|
+
var qualName = i < 0 ? ["", name] : name.split(":");
|
|
1819
|
+
var prefix = qualName[0];
|
|
1820
|
+
var local = qualName[1];
|
|
1821
|
+
if (attribute && name === "xmlns") {
|
|
1822
|
+
prefix = "xmlns";
|
|
1823
|
+
local = "";
|
|
1824
|
+
}
|
|
1825
|
+
return { prefix, local };
|
|
1826
|
+
}
|
|
1827
|
+
function attrib(parser) {
|
|
1828
|
+
if (!parser.strict) {
|
|
1829
|
+
parser.attribName = parser.attribName[parser.looseCase]();
|
|
1830
|
+
}
|
|
1831
|
+
if (parser.attribList.indexOf(parser.attribName) !== -1 || parser.tag.attributes.hasOwnProperty(parser.attribName)) {
|
|
1832
|
+
parser.attribName = parser.attribValue = "";
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
if (parser.opt.xmlns) {
|
|
1836
|
+
var qn = qname(parser.attribName, true);
|
|
1837
|
+
var prefix = qn.prefix;
|
|
1838
|
+
var local = qn.local;
|
|
1839
|
+
if (prefix === "xmlns") {
|
|
1840
|
+
if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
|
|
1841
|
+
strictFail(parser, "xml: prefix must be bound to " + XML_NAMESPACE + "\nActual: " + parser.attribValue);
|
|
1842
|
+
} else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
|
|
1843
|
+
strictFail(parser, "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\nActual: " + parser.attribValue);
|
|
1844
|
+
} else {
|
|
1845
|
+
var tag = parser.tag;
|
|
1846
|
+
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
1847
|
+
if (tag.ns === parent.ns) {
|
|
1848
|
+
tag.ns = Object.create(parent.ns);
|
|
1849
|
+
}
|
|
1850
|
+
tag.ns[local] = parser.attribValue;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
parser.attribList.push([parser.attribName, parser.attribValue]);
|
|
1854
|
+
} else {
|
|
1855
|
+
parser.tag.attributes[parser.attribName] = parser.attribValue;
|
|
1856
|
+
emitNode(parser, "onattribute", {
|
|
1857
|
+
name: parser.attribName,
|
|
1858
|
+
value: parser.attribValue
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
parser.attribName = parser.attribValue = "";
|
|
1862
|
+
}
|
|
1863
|
+
function openTag(parser, selfClosing) {
|
|
1864
|
+
if (parser.opt.xmlns) {
|
|
1865
|
+
var tag = parser.tag;
|
|
1866
|
+
var qn = qname(parser.tagName);
|
|
1867
|
+
tag.prefix = qn.prefix;
|
|
1868
|
+
tag.local = qn.local;
|
|
1869
|
+
tag.uri = tag.ns[qn.prefix] || "";
|
|
1870
|
+
if (tag.prefix && !tag.uri) {
|
|
1871
|
+
strictFail(parser, "Unbound namespace prefix: " + JSON.stringify(parser.tagName));
|
|
1872
|
+
tag.uri = qn.prefix;
|
|
1873
|
+
}
|
|
1874
|
+
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
1875
|
+
if (tag.ns && parent.ns !== tag.ns) {
|
|
1876
|
+
Object.keys(tag.ns).forEach(function(p) {
|
|
1877
|
+
emitNode(parser, "onopennamespace", {
|
|
1878
|
+
prefix: p,
|
|
1879
|
+
uri: tag.ns[p]
|
|
1880
|
+
});
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
for (var i = 0, l = parser.attribList.length; i < l; i++) {
|
|
1884
|
+
var nv = parser.attribList[i];
|
|
1885
|
+
var name = nv[0];
|
|
1886
|
+
var value = nv[1];
|
|
1887
|
+
var qualName = qname(name, true);
|
|
1888
|
+
var prefix = qualName.prefix;
|
|
1889
|
+
var local = qualName.local;
|
|
1890
|
+
var uri = prefix === "" ? "" : tag.ns[prefix] || "";
|
|
1891
|
+
var a = {
|
|
1892
|
+
name,
|
|
1893
|
+
value,
|
|
1894
|
+
prefix,
|
|
1895
|
+
local,
|
|
1896
|
+
uri
|
|
1897
|
+
};
|
|
1898
|
+
if (prefix && prefix !== "xmlns" && !uri) {
|
|
1899
|
+
strictFail(parser, "Unbound namespace prefix: " + JSON.stringify(prefix));
|
|
1900
|
+
a.uri = prefix;
|
|
1901
|
+
}
|
|
1902
|
+
parser.tag.attributes[name] = a;
|
|
1903
|
+
emitNode(parser, "onattribute", a);
|
|
1904
|
+
}
|
|
1905
|
+
parser.attribList.length = 0;
|
|
1906
|
+
}
|
|
1907
|
+
parser.tag.isSelfClosing = !!selfClosing;
|
|
1908
|
+
parser.sawRoot = true;
|
|
1909
|
+
parser.tags.push(parser.tag);
|
|
1910
|
+
emitNode(parser, "onopentag", parser.tag);
|
|
1911
|
+
if (!selfClosing) {
|
|
1912
|
+
if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
|
|
1913
|
+
parser.state = S.SCRIPT;
|
|
1914
|
+
} else {
|
|
1915
|
+
parser.state = S.TEXT;
|
|
1916
|
+
}
|
|
1917
|
+
parser.tag = null;
|
|
1918
|
+
parser.tagName = "";
|
|
1919
|
+
}
|
|
1920
|
+
parser.attribName = parser.attribValue = "";
|
|
1921
|
+
parser.attribList.length = 0;
|
|
1922
|
+
}
|
|
1923
|
+
function closeTag(parser) {
|
|
1924
|
+
if (!parser.tagName) {
|
|
1925
|
+
strictFail(parser, "Weird empty close tag.");
|
|
1926
|
+
parser.textNode += "</>";
|
|
1927
|
+
parser.state = S.TEXT;
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
if (parser.script) {
|
|
1931
|
+
if (parser.tagName !== "script") {
|
|
1932
|
+
parser.script += "</" + parser.tagName + ">";
|
|
1933
|
+
parser.tagName = "";
|
|
1934
|
+
parser.state = S.SCRIPT;
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
emitNode(parser, "onscript", parser.script);
|
|
1938
|
+
parser.script = "";
|
|
1939
|
+
}
|
|
1940
|
+
var t = parser.tags.length;
|
|
1941
|
+
var tagName = parser.tagName;
|
|
1942
|
+
if (!parser.strict) {
|
|
1943
|
+
tagName = tagName[parser.looseCase]();
|
|
1944
|
+
}
|
|
1945
|
+
var closeTo = tagName;
|
|
1946
|
+
while (t--) {
|
|
1947
|
+
var close = parser.tags[t];
|
|
1948
|
+
if (close.name !== closeTo) {
|
|
1949
|
+
strictFail(parser, "Unexpected close tag");
|
|
1950
|
+
} else {
|
|
1951
|
+
break;
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
if (t < 0) {
|
|
1955
|
+
strictFail(parser, "Unmatched closing tag: " + parser.tagName);
|
|
1956
|
+
parser.textNode += "</" + parser.tagName + ">";
|
|
1957
|
+
parser.state = S.TEXT;
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
parser.tagName = tagName;
|
|
1961
|
+
var s2 = parser.tags.length;
|
|
1962
|
+
while (s2-- > t) {
|
|
1963
|
+
var tag = parser.tag = parser.tags.pop();
|
|
1964
|
+
parser.tagName = parser.tag.name;
|
|
1965
|
+
emitNode(parser, "onclosetag", parser.tagName);
|
|
1966
|
+
var x = {};
|
|
1967
|
+
for (var i in tag.ns) {
|
|
1968
|
+
x[i] = tag.ns[i];
|
|
1969
|
+
}
|
|
1970
|
+
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
1971
|
+
if (parser.opt.xmlns && tag.ns !== parent.ns) {
|
|
1972
|
+
Object.keys(tag.ns).forEach(function(p) {
|
|
1973
|
+
var n = tag.ns[p];
|
|
1974
|
+
emitNode(parser, "onclosenamespace", { prefix: p, uri: n });
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
if (t === 0)
|
|
1979
|
+
parser.closedRoot = true;
|
|
1980
|
+
parser.tagName = parser.attribValue = parser.attribName = "";
|
|
1981
|
+
parser.attribList.length = 0;
|
|
1982
|
+
parser.state = S.TEXT;
|
|
1983
|
+
}
|
|
1984
|
+
function parseEntity(parser) {
|
|
1985
|
+
var entity = parser.entity;
|
|
1986
|
+
var entityLC = entity.toLowerCase();
|
|
1987
|
+
var num;
|
|
1988
|
+
var numStr = "";
|
|
1989
|
+
if (parser.ENTITIES[entity]) {
|
|
1990
|
+
return parser.ENTITIES[entity];
|
|
1991
|
+
}
|
|
1992
|
+
if (parser.ENTITIES[entityLC]) {
|
|
1993
|
+
return parser.ENTITIES[entityLC];
|
|
1994
|
+
}
|
|
1995
|
+
entity = entityLC;
|
|
1996
|
+
if (entity.charAt(0) === "#") {
|
|
1997
|
+
if (entity.charAt(1) === "x") {
|
|
1998
|
+
entity = entity.slice(2);
|
|
1999
|
+
num = parseInt(entity, 16);
|
|
2000
|
+
numStr = num.toString(16);
|
|
2001
|
+
} else {
|
|
2002
|
+
entity = entity.slice(1);
|
|
2003
|
+
num = parseInt(entity, 10);
|
|
2004
|
+
numStr = num.toString(10);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
entity = entity.replace(/^0+/, "");
|
|
2008
|
+
if (isNaN(num) || numStr.toLowerCase() !== entity) {
|
|
2009
|
+
strictFail(parser, "Invalid character entity");
|
|
2010
|
+
return "&" + parser.entity + ";";
|
|
2011
|
+
}
|
|
2012
|
+
return String.fromCodePoint(num);
|
|
2013
|
+
}
|
|
2014
|
+
function beginWhiteSpace(parser, c) {
|
|
2015
|
+
if (c === "<") {
|
|
2016
|
+
parser.state = S.OPEN_WAKA;
|
|
2017
|
+
parser.startTagPosition = parser.position;
|
|
2018
|
+
} else if (!isWhitespace(c)) {
|
|
2019
|
+
strictFail(parser, "Non-whitespace before first tag.");
|
|
2020
|
+
parser.textNode = c;
|
|
2021
|
+
parser.state = S.TEXT;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
function charAt(chunk, i) {
|
|
2025
|
+
var result = "";
|
|
2026
|
+
if (i < chunk.length) {
|
|
2027
|
+
result = chunk.charAt(i);
|
|
2028
|
+
}
|
|
2029
|
+
return result;
|
|
2030
|
+
}
|
|
2031
|
+
function write(chunk) {
|
|
2032
|
+
var parser = this;
|
|
2033
|
+
if (this.error) {
|
|
2034
|
+
throw this.error;
|
|
2035
|
+
}
|
|
2036
|
+
if (parser.closed) {
|
|
2037
|
+
return error(parser, "Cannot write after close. Assign an onready handler.");
|
|
2038
|
+
}
|
|
2039
|
+
if (chunk === null) {
|
|
2040
|
+
return end(parser);
|
|
2041
|
+
}
|
|
2042
|
+
if (typeof chunk === "object") {
|
|
2043
|
+
chunk = chunk.toString();
|
|
2044
|
+
}
|
|
2045
|
+
var i = 0;
|
|
2046
|
+
var c = "";
|
|
2047
|
+
while (true) {
|
|
2048
|
+
c = charAt(chunk, i++);
|
|
2049
|
+
parser.c = c;
|
|
2050
|
+
if (!c) {
|
|
2051
|
+
break;
|
|
2052
|
+
}
|
|
2053
|
+
if (parser.trackPosition) {
|
|
2054
|
+
parser.position++;
|
|
2055
|
+
if (c === "\n") {
|
|
2056
|
+
parser.line++;
|
|
2057
|
+
parser.column = 0;
|
|
2058
|
+
} else {
|
|
2059
|
+
parser.column++;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
switch (parser.state) {
|
|
2063
|
+
case S.BEGIN:
|
|
2064
|
+
parser.state = S.BEGIN_WHITESPACE;
|
|
2065
|
+
if (c === "\uFEFF") {
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
beginWhiteSpace(parser, c);
|
|
2069
|
+
continue;
|
|
2070
|
+
case S.BEGIN_WHITESPACE:
|
|
2071
|
+
beginWhiteSpace(parser, c);
|
|
2072
|
+
continue;
|
|
2073
|
+
case S.TEXT:
|
|
2074
|
+
if (parser.sawRoot && !parser.closedRoot) {
|
|
2075
|
+
var starti = i - 1;
|
|
2076
|
+
while (c && c !== "<" && c !== "&") {
|
|
2077
|
+
c = charAt(chunk, i++);
|
|
2078
|
+
if (c && parser.trackPosition) {
|
|
2079
|
+
parser.position++;
|
|
2080
|
+
if (c === "\n") {
|
|
2081
|
+
parser.line++;
|
|
2082
|
+
parser.column = 0;
|
|
2083
|
+
} else {
|
|
2084
|
+
parser.column++;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
parser.textNode += chunk.substring(starti, i - 1);
|
|
2089
|
+
}
|
|
2090
|
+
if (c === "<" && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
|
|
2091
|
+
parser.state = S.OPEN_WAKA;
|
|
2092
|
+
parser.startTagPosition = parser.position;
|
|
2093
|
+
} else {
|
|
2094
|
+
if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
|
|
2095
|
+
strictFail(parser, "Text data outside of root node.");
|
|
2096
|
+
}
|
|
2097
|
+
if (c === "&") {
|
|
2098
|
+
parser.state = S.TEXT_ENTITY;
|
|
2099
|
+
} else {
|
|
2100
|
+
parser.textNode += c;
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
continue;
|
|
2104
|
+
case S.SCRIPT:
|
|
2105
|
+
if (c === "<") {
|
|
2106
|
+
parser.state = S.SCRIPT_ENDING;
|
|
2107
|
+
} else {
|
|
2108
|
+
parser.script += c;
|
|
2109
|
+
}
|
|
2110
|
+
continue;
|
|
2111
|
+
case S.SCRIPT_ENDING:
|
|
2112
|
+
if (c === "/") {
|
|
2113
|
+
parser.state = S.CLOSE_TAG;
|
|
2114
|
+
} else {
|
|
2115
|
+
parser.script += "<" + c;
|
|
2116
|
+
parser.state = S.SCRIPT;
|
|
2117
|
+
}
|
|
2118
|
+
continue;
|
|
2119
|
+
case S.OPEN_WAKA:
|
|
2120
|
+
if (c === "!") {
|
|
2121
|
+
parser.state = S.SGML_DECL;
|
|
2122
|
+
parser.sgmlDecl = "";
|
|
2123
|
+
} else if (isWhitespace(c)) {
|
|
2124
|
+
} else if (isMatch(nameStart, c)) {
|
|
2125
|
+
parser.state = S.OPEN_TAG;
|
|
2126
|
+
parser.tagName = c;
|
|
2127
|
+
} else if (c === "/") {
|
|
2128
|
+
parser.state = S.CLOSE_TAG;
|
|
2129
|
+
parser.tagName = "";
|
|
2130
|
+
} else if (c === "?") {
|
|
2131
|
+
parser.state = S.PROC_INST;
|
|
2132
|
+
parser.procInstName = parser.procInstBody = "";
|
|
2133
|
+
} else {
|
|
2134
|
+
strictFail(parser, "Unencoded <");
|
|
2135
|
+
if (parser.startTagPosition + 1 < parser.position) {
|
|
2136
|
+
var pad = parser.position - parser.startTagPosition;
|
|
2137
|
+
c = new Array(pad).join(" ") + c;
|
|
2138
|
+
}
|
|
2139
|
+
parser.textNode += "<" + c;
|
|
2140
|
+
parser.state = S.TEXT;
|
|
2141
|
+
}
|
|
2142
|
+
continue;
|
|
2143
|
+
case S.SGML_DECL:
|
|
2144
|
+
if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
|
|
2145
|
+
emitNode(parser, "onopencdata");
|
|
2146
|
+
parser.state = S.CDATA;
|
|
2147
|
+
parser.sgmlDecl = "";
|
|
2148
|
+
parser.cdata = "";
|
|
2149
|
+
} else if (parser.sgmlDecl + c === "--") {
|
|
2150
|
+
parser.state = S.COMMENT;
|
|
2151
|
+
parser.comment = "";
|
|
2152
|
+
parser.sgmlDecl = "";
|
|
2153
|
+
} else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
|
|
2154
|
+
parser.state = S.DOCTYPE;
|
|
2155
|
+
if (parser.doctype || parser.sawRoot) {
|
|
2156
|
+
strictFail(parser, "Inappropriately located doctype declaration");
|
|
2157
|
+
}
|
|
2158
|
+
parser.doctype = "";
|
|
2159
|
+
parser.sgmlDecl = "";
|
|
2160
|
+
} else if (c === ">") {
|
|
2161
|
+
emitNode(parser, "onsgmldeclaration", parser.sgmlDecl);
|
|
2162
|
+
parser.sgmlDecl = "";
|
|
2163
|
+
parser.state = S.TEXT;
|
|
2164
|
+
} else if (isQuote(c)) {
|
|
2165
|
+
parser.state = S.SGML_DECL_QUOTED;
|
|
2166
|
+
parser.sgmlDecl += c;
|
|
2167
|
+
} else {
|
|
2168
|
+
parser.sgmlDecl += c;
|
|
2169
|
+
}
|
|
2170
|
+
continue;
|
|
2171
|
+
case S.SGML_DECL_QUOTED:
|
|
2172
|
+
if (c === parser.q) {
|
|
2173
|
+
parser.state = S.SGML_DECL;
|
|
2174
|
+
parser.q = "";
|
|
2175
|
+
}
|
|
2176
|
+
parser.sgmlDecl += c;
|
|
2177
|
+
continue;
|
|
2178
|
+
case S.DOCTYPE:
|
|
2179
|
+
if (c === ">") {
|
|
2180
|
+
parser.state = S.TEXT;
|
|
2181
|
+
emitNode(parser, "ondoctype", parser.doctype);
|
|
2182
|
+
parser.doctype = true;
|
|
2183
|
+
} else {
|
|
2184
|
+
parser.doctype += c;
|
|
2185
|
+
if (c === "[") {
|
|
2186
|
+
parser.state = S.DOCTYPE_DTD;
|
|
2187
|
+
} else if (isQuote(c)) {
|
|
2188
|
+
parser.state = S.DOCTYPE_QUOTED;
|
|
2189
|
+
parser.q = c;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
continue;
|
|
2193
|
+
case S.DOCTYPE_QUOTED:
|
|
2194
|
+
parser.doctype += c;
|
|
2195
|
+
if (c === parser.q) {
|
|
2196
|
+
parser.q = "";
|
|
2197
|
+
parser.state = S.DOCTYPE;
|
|
2198
|
+
}
|
|
2199
|
+
continue;
|
|
2200
|
+
case S.DOCTYPE_DTD:
|
|
2201
|
+
parser.doctype += c;
|
|
2202
|
+
if (c === "]") {
|
|
2203
|
+
parser.state = S.DOCTYPE;
|
|
2204
|
+
} else if (isQuote(c)) {
|
|
2205
|
+
parser.state = S.DOCTYPE_DTD_QUOTED;
|
|
2206
|
+
parser.q = c;
|
|
2207
|
+
}
|
|
2208
|
+
continue;
|
|
2209
|
+
case S.DOCTYPE_DTD_QUOTED:
|
|
2210
|
+
parser.doctype += c;
|
|
2211
|
+
if (c === parser.q) {
|
|
2212
|
+
parser.state = S.DOCTYPE_DTD;
|
|
2213
|
+
parser.q = "";
|
|
2214
|
+
}
|
|
2215
|
+
continue;
|
|
2216
|
+
case S.COMMENT:
|
|
2217
|
+
if (c === "-") {
|
|
2218
|
+
parser.state = S.COMMENT_ENDING;
|
|
2219
|
+
} else {
|
|
2220
|
+
parser.comment += c;
|
|
2221
|
+
}
|
|
2222
|
+
continue;
|
|
2223
|
+
case S.COMMENT_ENDING:
|
|
2224
|
+
if (c === "-") {
|
|
2225
|
+
parser.state = S.COMMENT_ENDED;
|
|
2226
|
+
parser.comment = textopts(parser.opt, parser.comment);
|
|
2227
|
+
if (parser.comment) {
|
|
2228
|
+
emitNode(parser, "oncomment", parser.comment);
|
|
2229
|
+
}
|
|
2230
|
+
parser.comment = "";
|
|
2231
|
+
} else {
|
|
2232
|
+
parser.comment += "-" + c;
|
|
2233
|
+
parser.state = S.COMMENT;
|
|
2234
|
+
}
|
|
2235
|
+
continue;
|
|
2236
|
+
case S.COMMENT_ENDED:
|
|
2237
|
+
if (c !== ">") {
|
|
2238
|
+
strictFail(parser, "Malformed comment");
|
|
2239
|
+
parser.comment += "--" + c;
|
|
2240
|
+
parser.state = S.COMMENT;
|
|
2241
|
+
} else {
|
|
2242
|
+
parser.state = S.TEXT;
|
|
2243
|
+
}
|
|
2244
|
+
continue;
|
|
2245
|
+
case S.CDATA:
|
|
2246
|
+
if (c === "]") {
|
|
2247
|
+
parser.state = S.CDATA_ENDING;
|
|
2248
|
+
} else {
|
|
2249
|
+
parser.cdata += c;
|
|
2250
|
+
}
|
|
2251
|
+
continue;
|
|
2252
|
+
case S.CDATA_ENDING:
|
|
2253
|
+
if (c === "]") {
|
|
2254
|
+
parser.state = S.CDATA_ENDING_2;
|
|
2255
|
+
} else {
|
|
2256
|
+
parser.cdata += "]" + c;
|
|
2257
|
+
parser.state = S.CDATA;
|
|
2258
|
+
}
|
|
2259
|
+
continue;
|
|
2260
|
+
case S.CDATA_ENDING_2:
|
|
2261
|
+
if (c === ">") {
|
|
2262
|
+
if (parser.cdata) {
|
|
2263
|
+
emitNode(parser, "oncdata", parser.cdata);
|
|
2264
|
+
}
|
|
2265
|
+
emitNode(parser, "onclosecdata");
|
|
2266
|
+
parser.cdata = "";
|
|
2267
|
+
parser.state = S.TEXT;
|
|
2268
|
+
} else if (c === "]") {
|
|
2269
|
+
parser.cdata += "]";
|
|
2270
|
+
} else {
|
|
2271
|
+
parser.cdata += "]]" + c;
|
|
2272
|
+
parser.state = S.CDATA;
|
|
2273
|
+
}
|
|
2274
|
+
continue;
|
|
2275
|
+
case S.PROC_INST:
|
|
2276
|
+
if (c === "?") {
|
|
2277
|
+
parser.state = S.PROC_INST_ENDING;
|
|
2278
|
+
} else if (isWhitespace(c)) {
|
|
2279
|
+
parser.state = S.PROC_INST_BODY;
|
|
2280
|
+
} else {
|
|
2281
|
+
parser.procInstName += c;
|
|
2282
|
+
}
|
|
2283
|
+
continue;
|
|
2284
|
+
case S.PROC_INST_BODY:
|
|
2285
|
+
if (!parser.procInstBody && isWhitespace(c)) {
|
|
2286
|
+
continue;
|
|
2287
|
+
} else if (c === "?") {
|
|
2288
|
+
parser.state = S.PROC_INST_ENDING;
|
|
2289
|
+
} else {
|
|
2290
|
+
parser.procInstBody += c;
|
|
2291
|
+
}
|
|
2292
|
+
continue;
|
|
2293
|
+
case S.PROC_INST_ENDING:
|
|
2294
|
+
if (c === ">") {
|
|
2295
|
+
emitNode(parser, "onprocessinginstruction", {
|
|
2296
|
+
name: parser.procInstName,
|
|
2297
|
+
body: parser.procInstBody
|
|
2298
|
+
});
|
|
2299
|
+
parser.procInstName = parser.procInstBody = "";
|
|
2300
|
+
parser.state = S.TEXT;
|
|
2301
|
+
} else {
|
|
2302
|
+
parser.procInstBody += "?" + c;
|
|
2303
|
+
parser.state = S.PROC_INST_BODY;
|
|
2304
|
+
}
|
|
2305
|
+
continue;
|
|
2306
|
+
case S.OPEN_TAG:
|
|
2307
|
+
if (isMatch(nameBody, c)) {
|
|
2308
|
+
parser.tagName += c;
|
|
2309
|
+
} else {
|
|
2310
|
+
newTag(parser);
|
|
2311
|
+
if (c === ">") {
|
|
2312
|
+
openTag(parser);
|
|
2313
|
+
} else if (c === "/") {
|
|
2314
|
+
parser.state = S.OPEN_TAG_SLASH;
|
|
2315
|
+
} else {
|
|
2316
|
+
if (!isWhitespace(c)) {
|
|
2317
|
+
strictFail(parser, "Invalid character in tag name");
|
|
2318
|
+
}
|
|
2319
|
+
parser.state = S.ATTRIB;
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
continue;
|
|
2323
|
+
case S.OPEN_TAG_SLASH:
|
|
2324
|
+
if (c === ">") {
|
|
2325
|
+
openTag(parser, true);
|
|
2326
|
+
closeTag(parser);
|
|
2327
|
+
} else {
|
|
2328
|
+
strictFail(parser, "Forward-slash in opening tag not followed by >");
|
|
2329
|
+
parser.state = S.ATTRIB;
|
|
2330
|
+
}
|
|
2331
|
+
continue;
|
|
2332
|
+
case S.ATTRIB:
|
|
2333
|
+
if (isWhitespace(c)) {
|
|
2334
|
+
continue;
|
|
2335
|
+
} else if (c === ">") {
|
|
2336
|
+
openTag(parser);
|
|
2337
|
+
} else if (c === "/") {
|
|
2338
|
+
parser.state = S.OPEN_TAG_SLASH;
|
|
2339
|
+
} else if (isMatch(nameStart, c)) {
|
|
2340
|
+
parser.attribName = c;
|
|
2341
|
+
parser.attribValue = "";
|
|
2342
|
+
parser.state = S.ATTRIB_NAME;
|
|
2343
|
+
} else {
|
|
2344
|
+
strictFail(parser, "Invalid attribute name");
|
|
2345
|
+
}
|
|
2346
|
+
continue;
|
|
2347
|
+
case S.ATTRIB_NAME:
|
|
2348
|
+
if (c === "=") {
|
|
2349
|
+
parser.state = S.ATTRIB_VALUE;
|
|
2350
|
+
} else if (c === ">") {
|
|
2351
|
+
strictFail(parser, "Attribute without value");
|
|
2352
|
+
parser.attribValue = parser.attribName;
|
|
2353
|
+
attrib(parser);
|
|
2354
|
+
openTag(parser);
|
|
2355
|
+
} else if (isWhitespace(c)) {
|
|
2356
|
+
parser.state = S.ATTRIB_NAME_SAW_WHITE;
|
|
2357
|
+
} else if (isMatch(nameBody, c)) {
|
|
2358
|
+
parser.attribName += c;
|
|
2359
|
+
} else {
|
|
2360
|
+
strictFail(parser, "Invalid attribute name");
|
|
2361
|
+
}
|
|
2362
|
+
continue;
|
|
2363
|
+
case S.ATTRIB_NAME_SAW_WHITE:
|
|
2364
|
+
if (c === "=") {
|
|
2365
|
+
parser.state = S.ATTRIB_VALUE;
|
|
2366
|
+
} else if (isWhitespace(c)) {
|
|
2367
|
+
continue;
|
|
2368
|
+
} else {
|
|
2369
|
+
strictFail(parser, "Attribute without value");
|
|
2370
|
+
parser.tag.attributes[parser.attribName] = "";
|
|
2371
|
+
parser.attribValue = "";
|
|
2372
|
+
emitNode(parser, "onattribute", {
|
|
2373
|
+
name: parser.attribName,
|
|
2374
|
+
value: ""
|
|
2375
|
+
});
|
|
2376
|
+
parser.attribName = "";
|
|
2377
|
+
if (c === ">") {
|
|
2378
|
+
openTag(parser);
|
|
2379
|
+
} else if (isMatch(nameStart, c)) {
|
|
2380
|
+
parser.attribName = c;
|
|
2381
|
+
parser.state = S.ATTRIB_NAME;
|
|
2382
|
+
} else {
|
|
2383
|
+
strictFail(parser, "Invalid attribute name");
|
|
2384
|
+
parser.state = S.ATTRIB;
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
continue;
|
|
2388
|
+
case S.ATTRIB_VALUE:
|
|
2389
|
+
if (isWhitespace(c)) {
|
|
2390
|
+
continue;
|
|
2391
|
+
} else if (isQuote(c)) {
|
|
2392
|
+
parser.q = c;
|
|
2393
|
+
parser.state = S.ATTRIB_VALUE_QUOTED;
|
|
2394
|
+
} else {
|
|
2395
|
+
strictFail(parser, "Unquoted attribute value");
|
|
2396
|
+
parser.state = S.ATTRIB_VALUE_UNQUOTED;
|
|
2397
|
+
parser.attribValue = c;
|
|
2398
|
+
}
|
|
2399
|
+
continue;
|
|
2400
|
+
case S.ATTRIB_VALUE_QUOTED:
|
|
2401
|
+
if (c !== parser.q) {
|
|
2402
|
+
if (c === "&") {
|
|
2403
|
+
parser.state = S.ATTRIB_VALUE_ENTITY_Q;
|
|
2404
|
+
} else {
|
|
2405
|
+
parser.attribValue += c;
|
|
2406
|
+
}
|
|
2407
|
+
continue;
|
|
2408
|
+
}
|
|
2409
|
+
attrib(parser);
|
|
2410
|
+
parser.q = "";
|
|
2411
|
+
parser.state = S.ATTRIB_VALUE_CLOSED;
|
|
2412
|
+
continue;
|
|
2413
|
+
case S.ATTRIB_VALUE_CLOSED:
|
|
2414
|
+
if (isWhitespace(c)) {
|
|
2415
|
+
parser.state = S.ATTRIB;
|
|
2416
|
+
} else if (c === ">") {
|
|
2417
|
+
openTag(parser);
|
|
2418
|
+
} else if (c === "/") {
|
|
2419
|
+
parser.state = S.OPEN_TAG_SLASH;
|
|
2420
|
+
} else if (isMatch(nameStart, c)) {
|
|
2421
|
+
strictFail(parser, "No whitespace between attributes");
|
|
2422
|
+
parser.attribName = c;
|
|
2423
|
+
parser.attribValue = "";
|
|
2424
|
+
parser.state = S.ATTRIB_NAME;
|
|
2425
|
+
} else {
|
|
2426
|
+
strictFail(parser, "Invalid attribute name");
|
|
2427
|
+
}
|
|
2428
|
+
continue;
|
|
2429
|
+
case S.ATTRIB_VALUE_UNQUOTED:
|
|
2430
|
+
if (!isAttribEnd(c)) {
|
|
2431
|
+
if (c === "&") {
|
|
2432
|
+
parser.state = S.ATTRIB_VALUE_ENTITY_U;
|
|
2433
|
+
} else {
|
|
2434
|
+
parser.attribValue += c;
|
|
2435
|
+
}
|
|
2436
|
+
continue;
|
|
2437
|
+
}
|
|
2438
|
+
attrib(parser);
|
|
2439
|
+
if (c === ">") {
|
|
2440
|
+
openTag(parser);
|
|
2441
|
+
} else {
|
|
2442
|
+
parser.state = S.ATTRIB;
|
|
2443
|
+
}
|
|
2444
|
+
continue;
|
|
2445
|
+
case S.CLOSE_TAG:
|
|
2446
|
+
if (!parser.tagName) {
|
|
2447
|
+
if (isWhitespace(c)) {
|
|
2448
|
+
continue;
|
|
2449
|
+
} else if (notMatch(nameStart, c)) {
|
|
2450
|
+
if (parser.script) {
|
|
2451
|
+
parser.script += "</" + c;
|
|
2452
|
+
parser.state = S.SCRIPT;
|
|
2453
|
+
} else {
|
|
2454
|
+
strictFail(parser, "Invalid tagname in closing tag.");
|
|
2455
|
+
}
|
|
2456
|
+
} else {
|
|
2457
|
+
parser.tagName = c;
|
|
2458
|
+
}
|
|
2459
|
+
} else if (c === ">") {
|
|
2460
|
+
closeTag(parser);
|
|
2461
|
+
} else if (isMatch(nameBody, c)) {
|
|
2462
|
+
parser.tagName += c;
|
|
2463
|
+
} else if (parser.script) {
|
|
2464
|
+
parser.script += "</" + parser.tagName;
|
|
2465
|
+
parser.tagName = "";
|
|
2466
|
+
parser.state = S.SCRIPT;
|
|
2467
|
+
} else {
|
|
2468
|
+
if (!isWhitespace(c)) {
|
|
2469
|
+
strictFail(parser, "Invalid tagname in closing tag");
|
|
2470
|
+
}
|
|
2471
|
+
parser.state = S.CLOSE_TAG_SAW_WHITE;
|
|
2472
|
+
}
|
|
2473
|
+
continue;
|
|
2474
|
+
case S.CLOSE_TAG_SAW_WHITE:
|
|
2475
|
+
if (isWhitespace(c)) {
|
|
2476
|
+
continue;
|
|
2477
|
+
}
|
|
2478
|
+
if (c === ">") {
|
|
2479
|
+
closeTag(parser);
|
|
2480
|
+
} else {
|
|
2481
|
+
strictFail(parser, "Invalid characters in closing tag");
|
|
2482
|
+
}
|
|
2483
|
+
continue;
|
|
2484
|
+
case S.TEXT_ENTITY:
|
|
2485
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
2486
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
|
2487
|
+
var returnState;
|
|
2488
|
+
var buffer;
|
|
2489
|
+
switch (parser.state) {
|
|
2490
|
+
case S.TEXT_ENTITY:
|
|
2491
|
+
returnState = S.TEXT;
|
|
2492
|
+
buffer = "textNode";
|
|
2493
|
+
break;
|
|
2494
|
+
case S.ATTRIB_VALUE_ENTITY_Q:
|
|
2495
|
+
returnState = S.ATTRIB_VALUE_QUOTED;
|
|
2496
|
+
buffer = "attribValue";
|
|
2497
|
+
break;
|
|
2498
|
+
case S.ATTRIB_VALUE_ENTITY_U:
|
|
2499
|
+
returnState = S.ATTRIB_VALUE_UNQUOTED;
|
|
2500
|
+
buffer = "attribValue";
|
|
2501
|
+
break;
|
|
2502
|
+
}
|
|
2503
|
+
if (c === ";") {
|
|
2504
|
+
parser[buffer] += parseEntity(parser);
|
|
2505
|
+
parser.entity = "";
|
|
2506
|
+
parser.state = returnState;
|
|
2507
|
+
} else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
|
|
2508
|
+
parser.entity += c;
|
|
2509
|
+
} else {
|
|
2510
|
+
strictFail(parser, "Invalid character in entity name");
|
|
2511
|
+
parser[buffer] += "&" + parser.entity + c;
|
|
2512
|
+
parser.entity = "";
|
|
2513
|
+
parser.state = returnState;
|
|
2514
|
+
}
|
|
2515
|
+
continue;
|
|
2516
|
+
default:
|
|
2517
|
+
throw new Error(parser, "Unknown state: " + parser.state);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
if (parser.position >= parser.bufferCheckPosition) {
|
|
2521
|
+
checkBufferLength(parser);
|
|
2522
|
+
}
|
|
2523
|
+
return parser;
|
|
2524
|
+
}
|
|
2525
|
+
if (!String.fromCodePoint) {
|
|
2526
|
+
(function() {
|
|
2527
|
+
var stringFromCharCode = String.fromCharCode;
|
|
2528
|
+
var floor = Math.floor;
|
|
2529
|
+
var fromCodePoint = function() {
|
|
2530
|
+
var MAX_SIZE = 16384;
|
|
2531
|
+
var codeUnits = [];
|
|
2532
|
+
var highSurrogate;
|
|
2533
|
+
var lowSurrogate;
|
|
2534
|
+
var index = -1;
|
|
2535
|
+
var length = arguments.length;
|
|
2536
|
+
if (!length) {
|
|
2537
|
+
return "";
|
|
2538
|
+
}
|
|
2539
|
+
var result = "";
|
|
2540
|
+
while (++index < length) {
|
|
2541
|
+
var codePoint = Number(arguments[index]);
|
|
2542
|
+
if (!isFinite(codePoint) || codePoint < 0 || codePoint > 1114111 || floor(codePoint) !== codePoint) {
|
|
2543
|
+
throw RangeError("Invalid code point: " + codePoint);
|
|
2544
|
+
}
|
|
2545
|
+
if (codePoint <= 65535) {
|
|
2546
|
+
codeUnits.push(codePoint);
|
|
2547
|
+
} else {
|
|
2548
|
+
codePoint -= 65536;
|
|
2549
|
+
highSurrogate = (codePoint >> 10) + 55296;
|
|
2550
|
+
lowSurrogate = codePoint % 1024 + 56320;
|
|
2551
|
+
codeUnits.push(highSurrogate, lowSurrogate);
|
|
2552
|
+
}
|
|
2553
|
+
if (index + 1 === length || codeUnits.length > MAX_SIZE) {
|
|
2554
|
+
result += stringFromCharCode.apply(null, codeUnits);
|
|
2555
|
+
codeUnits.length = 0;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
return result;
|
|
2559
|
+
};
|
|
2560
|
+
if (Object.defineProperty) {
|
|
2561
|
+
Object.defineProperty(String, "fromCodePoint", {
|
|
2562
|
+
value: fromCodePoint,
|
|
2563
|
+
configurable: true,
|
|
2564
|
+
writable: true
|
|
2565
|
+
});
|
|
2566
|
+
} else {
|
|
2567
|
+
String.fromCodePoint = fromCodePoint;
|
|
2568
|
+
}
|
|
2569
|
+
})();
|
|
2570
|
+
}
|
|
2571
|
+
})(typeof exports === "undefined" ? exports.sax = {} : exports);
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
|
|
2575
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-parser.js
|
|
2576
|
+
var require_sitemap_parser = __commonJS({
|
|
2577
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-parser.js"(exports) {
|
|
2578
|
+
"use strict";
|
|
2579
|
+
init_cjs_shims();
|
|
2580
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
2581
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
2582
|
+
};
|
|
2583
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2584
|
+
exports.ObjectStreamToJSON = exports.parseSitemap = exports.XMLToSitemapItemStream = void 0;
|
|
2585
|
+
var sax_1 = __importDefault(require_sax());
|
|
2586
|
+
var stream_1 = require("stream");
|
|
2587
|
+
var types_1 = require_types();
|
|
2588
|
+
function isValidTagName(tagName) {
|
|
2589
|
+
return tagName in types_1.TagNames;
|
|
2590
|
+
}
|
|
2591
|
+
function tagTemplate() {
|
|
2592
|
+
return {
|
|
2593
|
+
img: [],
|
|
2594
|
+
video: [],
|
|
2595
|
+
links: [],
|
|
2596
|
+
url: ""
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function videoTemplate() {
|
|
2600
|
+
return {
|
|
2601
|
+
tag: [],
|
|
2602
|
+
thumbnail_loc: "",
|
|
2603
|
+
title: "",
|
|
2604
|
+
description: ""
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
var imageTemplate = {
|
|
2608
|
+
url: ""
|
|
2609
|
+
};
|
|
2610
|
+
var linkTemplate = {
|
|
2611
|
+
lang: "",
|
|
2612
|
+
url: ""
|
|
2613
|
+
};
|
|
2614
|
+
function newsTemplate() {
|
|
2615
|
+
return {
|
|
2616
|
+
publication: { name: "", language: "" },
|
|
2617
|
+
publication_date: "",
|
|
2618
|
+
title: ""
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2621
|
+
var defaultLogger = (level, ...message) => console[level](...message);
|
|
2622
|
+
var defaultStreamOpts = {
|
|
2623
|
+
logger: defaultLogger
|
|
2624
|
+
};
|
|
2625
|
+
var XMLToSitemapItemStream = class extends stream_1.Transform {
|
|
2626
|
+
constructor(opts = defaultStreamOpts) {
|
|
2627
|
+
var _a;
|
|
2628
|
+
opts.objectMode = true;
|
|
2629
|
+
super(opts);
|
|
2630
|
+
this.error = null;
|
|
2631
|
+
this.saxStream = sax_1.default.createStream(true, {
|
|
2632
|
+
xmlns: true,
|
|
2633
|
+
strictEntities: true,
|
|
2634
|
+
trim: true
|
|
2635
|
+
});
|
|
2636
|
+
this.level = opts.level || types_1.ErrorLevel.WARN;
|
|
2637
|
+
if (this.level !== types_1.ErrorLevel.SILENT && opts.logger !== false) {
|
|
2638
|
+
this.logger = (_a = opts.logger) !== null && _a !== void 0 ? _a : defaultLogger;
|
|
2639
|
+
} else {
|
|
2640
|
+
this.logger = () => void 0;
|
|
2641
|
+
}
|
|
2642
|
+
let currentItem = tagTemplate();
|
|
2643
|
+
let currentTag;
|
|
2644
|
+
let currentVideo = videoTemplate();
|
|
2645
|
+
let currentImage = __spreadValues({}, imageTemplate);
|
|
2646
|
+
let currentLink = __spreadValues({}, linkTemplate);
|
|
2647
|
+
let dontpushCurrentLink = false;
|
|
2648
|
+
this.saxStream.on("opentagstart", (tag) => {
|
|
2649
|
+
currentTag = tag.name;
|
|
2650
|
+
if (currentTag.startsWith("news:") && !currentItem.news) {
|
|
2651
|
+
currentItem.news = newsTemplate();
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
this.saxStream.on("opentag", (tag) => {
|
|
2655
|
+
if (isValidTagName(tag.name)) {
|
|
2656
|
+
if (tag.name === "xhtml:link") {
|
|
2657
|
+
if (typeof tag.attributes.rel === "string" || typeof tag.attributes.href === "string") {
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
if (tag.attributes.rel.value === "alternate" && tag.attributes.hreflang) {
|
|
2661
|
+
currentLink.url = tag.attributes.href.value;
|
|
2662
|
+
if (typeof tag.attributes.hreflang === "string")
|
|
2663
|
+
return;
|
|
2664
|
+
currentLink.lang = tag.attributes.hreflang.value;
|
|
2665
|
+
} else if (tag.attributes.rel.value === "alternate") {
|
|
2666
|
+
dontpushCurrentLink = true;
|
|
2667
|
+
currentItem.androidLink = tag.attributes.href.value;
|
|
2668
|
+
} else if (tag.attributes.rel.value === "amphtml") {
|
|
2669
|
+
dontpushCurrentLink = true;
|
|
2670
|
+
currentItem.ampLink = tag.attributes.href.value;
|
|
2671
|
+
} else {
|
|
2672
|
+
this.logger("log", "unhandled attr for xhtml:link", tag.attributes);
|
|
2673
|
+
this.err(`unhandled attr for xhtml:link ${tag.attributes}`);
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
} else {
|
|
2677
|
+
this.logger("warn", "unhandled tag", tag.name);
|
|
2678
|
+
this.err(`unhandled tag: ${tag.name}`);
|
|
2679
|
+
}
|
|
2680
|
+
});
|
|
2681
|
+
this.saxStream.on("text", (text) => {
|
|
2682
|
+
switch (currentTag) {
|
|
2683
|
+
case "mobile:mobile":
|
|
2684
|
+
break;
|
|
2685
|
+
case types_1.TagNames.loc:
|
|
2686
|
+
currentItem.url = text;
|
|
2687
|
+
break;
|
|
2688
|
+
case types_1.TagNames.changefreq:
|
|
2689
|
+
if ((0, types_1.isValidChangeFreq)(text)) {
|
|
2690
|
+
currentItem.changefreq = text;
|
|
2691
|
+
}
|
|
2692
|
+
break;
|
|
2693
|
+
case types_1.TagNames.priority:
|
|
2694
|
+
currentItem.priority = parseFloat(text);
|
|
2695
|
+
break;
|
|
2696
|
+
case types_1.TagNames.lastmod:
|
|
2697
|
+
currentItem.lastmod = text;
|
|
2698
|
+
break;
|
|
2699
|
+
case types_1.TagNames["video:thumbnail_loc"]:
|
|
2700
|
+
currentVideo.thumbnail_loc = text;
|
|
2701
|
+
break;
|
|
2702
|
+
case types_1.TagNames["video:tag"]:
|
|
2703
|
+
currentVideo.tag.push(text);
|
|
2704
|
+
break;
|
|
2705
|
+
case types_1.TagNames["video:duration"]:
|
|
2706
|
+
currentVideo.duration = parseInt(text, 10);
|
|
2707
|
+
break;
|
|
2708
|
+
case types_1.TagNames["video:player_loc"]:
|
|
2709
|
+
currentVideo.player_loc = text;
|
|
2710
|
+
break;
|
|
2711
|
+
case types_1.TagNames["video:content_loc"]:
|
|
2712
|
+
currentVideo.content_loc = text;
|
|
2713
|
+
break;
|
|
2714
|
+
case types_1.TagNames["video:requires_subscription"]:
|
|
2715
|
+
if ((0, types_1.isValidYesNo)(text)) {
|
|
2716
|
+
currentVideo.requires_subscription = text;
|
|
2717
|
+
}
|
|
2718
|
+
break;
|
|
2719
|
+
case types_1.TagNames["video:publication_date"]:
|
|
2720
|
+
currentVideo.publication_date = text;
|
|
2721
|
+
break;
|
|
2722
|
+
case types_1.TagNames["video:id"]:
|
|
2723
|
+
currentVideo.id = text;
|
|
2724
|
+
break;
|
|
2725
|
+
case types_1.TagNames["video:restriction"]:
|
|
2726
|
+
currentVideo.restriction = text;
|
|
2727
|
+
break;
|
|
2728
|
+
case types_1.TagNames["video:view_count"]:
|
|
2729
|
+
currentVideo.view_count = parseInt(text, 10);
|
|
2730
|
+
break;
|
|
2731
|
+
case types_1.TagNames["video:uploader"]:
|
|
2732
|
+
currentVideo.uploader = text;
|
|
2733
|
+
break;
|
|
2734
|
+
case types_1.TagNames["video:family_friendly"]:
|
|
2735
|
+
if ((0, types_1.isValidYesNo)(text)) {
|
|
2736
|
+
currentVideo.family_friendly = text;
|
|
2737
|
+
}
|
|
2738
|
+
break;
|
|
2739
|
+
case types_1.TagNames["video:expiration_date"]:
|
|
2740
|
+
currentVideo.expiration_date = text;
|
|
2741
|
+
break;
|
|
2742
|
+
case types_1.TagNames["video:platform"]:
|
|
2743
|
+
currentVideo.platform = text;
|
|
2744
|
+
break;
|
|
2745
|
+
case types_1.TagNames["video:price"]:
|
|
2746
|
+
currentVideo.price = text;
|
|
2747
|
+
break;
|
|
2748
|
+
case types_1.TagNames["video:rating"]:
|
|
2749
|
+
currentVideo.rating = parseFloat(text);
|
|
2750
|
+
break;
|
|
2751
|
+
case types_1.TagNames["video:category"]:
|
|
2752
|
+
currentVideo.category = text;
|
|
2753
|
+
break;
|
|
2754
|
+
case types_1.TagNames["video:live"]:
|
|
2755
|
+
if ((0, types_1.isValidYesNo)(text)) {
|
|
2756
|
+
currentVideo.live = text;
|
|
2757
|
+
}
|
|
2758
|
+
break;
|
|
2759
|
+
case types_1.TagNames["video:gallery_loc"]:
|
|
2760
|
+
currentVideo.gallery_loc = text;
|
|
2761
|
+
break;
|
|
2762
|
+
case types_1.TagNames["image:loc"]:
|
|
2763
|
+
currentImage.url = text;
|
|
2764
|
+
break;
|
|
2765
|
+
case types_1.TagNames["image:geo_location"]:
|
|
2766
|
+
currentImage.geoLocation = text;
|
|
2767
|
+
break;
|
|
2768
|
+
case types_1.TagNames["image:license"]:
|
|
2769
|
+
currentImage.license = text;
|
|
2770
|
+
break;
|
|
2771
|
+
case types_1.TagNames["news:access"]:
|
|
2772
|
+
if (!currentItem.news) {
|
|
2773
|
+
currentItem.news = newsTemplate();
|
|
2774
|
+
}
|
|
2775
|
+
currentItem.news.access = text;
|
|
2776
|
+
break;
|
|
2777
|
+
case types_1.TagNames["news:genres"]:
|
|
2778
|
+
if (!currentItem.news) {
|
|
2779
|
+
currentItem.news = newsTemplate();
|
|
2780
|
+
}
|
|
2781
|
+
currentItem.news.genres = text;
|
|
2782
|
+
break;
|
|
2783
|
+
case types_1.TagNames["news:publication_date"]:
|
|
2784
|
+
if (!currentItem.news) {
|
|
2785
|
+
currentItem.news = newsTemplate();
|
|
2786
|
+
}
|
|
2787
|
+
currentItem.news.publication_date = text;
|
|
2788
|
+
break;
|
|
2789
|
+
case types_1.TagNames["news:keywords"]:
|
|
2790
|
+
if (!currentItem.news) {
|
|
2791
|
+
currentItem.news = newsTemplate();
|
|
2792
|
+
}
|
|
2793
|
+
currentItem.news.keywords = text;
|
|
2794
|
+
break;
|
|
2795
|
+
case types_1.TagNames["news:stock_tickers"]:
|
|
2796
|
+
if (!currentItem.news) {
|
|
2797
|
+
currentItem.news = newsTemplate();
|
|
2798
|
+
}
|
|
2799
|
+
currentItem.news.stock_tickers = text;
|
|
2800
|
+
break;
|
|
2801
|
+
case types_1.TagNames["news:language"]:
|
|
2802
|
+
if (!currentItem.news) {
|
|
2803
|
+
currentItem.news = newsTemplate();
|
|
2804
|
+
}
|
|
2805
|
+
currentItem.news.publication.language = text;
|
|
2806
|
+
break;
|
|
2807
|
+
case types_1.TagNames["video:title"]:
|
|
2808
|
+
currentVideo.title += text;
|
|
2809
|
+
break;
|
|
2810
|
+
case types_1.TagNames["video:description"]:
|
|
2811
|
+
currentVideo.description += text;
|
|
2812
|
+
break;
|
|
2813
|
+
case types_1.TagNames["news:name"]:
|
|
2814
|
+
if (!currentItem.news) {
|
|
2815
|
+
currentItem.news = newsTemplate();
|
|
2816
|
+
}
|
|
2817
|
+
currentItem.news.publication.name += text;
|
|
2818
|
+
break;
|
|
2819
|
+
case types_1.TagNames["news:title"]:
|
|
2820
|
+
if (!currentItem.news) {
|
|
2821
|
+
currentItem.news = newsTemplate();
|
|
2822
|
+
}
|
|
2823
|
+
currentItem.news.title += text;
|
|
2824
|
+
break;
|
|
2825
|
+
case types_1.TagNames["image:caption"]:
|
|
2826
|
+
if (!currentImage.caption) {
|
|
2827
|
+
currentImage.caption = text;
|
|
2828
|
+
} else {
|
|
2829
|
+
currentImage.caption += text;
|
|
2830
|
+
}
|
|
2831
|
+
break;
|
|
2832
|
+
case types_1.TagNames["image:title"]:
|
|
2833
|
+
if (!currentImage.title) {
|
|
2834
|
+
currentImage.title = text;
|
|
2835
|
+
} else {
|
|
2836
|
+
currentImage.title += text;
|
|
2837
|
+
}
|
|
2838
|
+
break;
|
|
2839
|
+
default:
|
|
2840
|
+
this.logger("log", "unhandled text for tag:", currentTag, `'${text}'`);
|
|
2841
|
+
this.err(`unhandled text for tag: ${currentTag} '${text}'`);
|
|
2842
|
+
break;
|
|
2843
|
+
}
|
|
2844
|
+
});
|
|
2845
|
+
this.saxStream.on("cdata", (text) => {
|
|
2846
|
+
switch (currentTag) {
|
|
2847
|
+
case types_1.TagNames["video:title"]:
|
|
2848
|
+
currentVideo.title += text;
|
|
2849
|
+
break;
|
|
2850
|
+
case types_1.TagNames["video:description"]:
|
|
2851
|
+
currentVideo.description += text;
|
|
2852
|
+
break;
|
|
2853
|
+
case types_1.TagNames["news:name"]:
|
|
2854
|
+
if (!currentItem.news) {
|
|
2855
|
+
currentItem.news = newsTemplate();
|
|
2856
|
+
}
|
|
2857
|
+
currentItem.news.publication.name += text;
|
|
2858
|
+
break;
|
|
2859
|
+
case types_1.TagNames["news:title"]:
|
|
2860
|
+
if (!currentItem.news) {
|
|
2861
|
+
currentItem.news = newsTemplate();
|
|
2862
|
+
}
|
|
2863
|
+
currentItem.news.title += text;
|
|
2864
|
+
break;
|
|
2865
|
+
case types_1.TagNames["image:caption"]:
|
|
2866
|
+
if (!currentImage.caption) {
|
|
2867
|
+
currentImage.caption = text;
|
|
2868
|
+
} else {
|
|
2869
|
+
currentImage.caption += text;
|
|
2870
|
+
}
|
|
2871
|
+
break;
|
|
2872
|
+
case types_1.TagNames["image:title"]:
|
|
2873
|
+
if (!currentImage.title) {
|
|
2874
|
+
currentImage.title = text;
|
|
2875
|
+
} else {
|
|
2876
|
+
currentImage.title += text;
|
|
2877
|
+
}
|
|
2878
|
+
break;
|
|
2879
|
+
default:
|
|
2880
|
+
this.logger("log", "unhandled cdata for tag:", currentTag);
|
|
2881
|
+
this.err(`unhandled cdata for tag: ${currentTag}`);
|
|
2882
|
+
break;
|
|
2883
|
+
}
|
|
2884
|
+
});
|
|
2885
|
+
this.saxStream.on("attribute", (attr) => {
|
|
2886
|
+
switch (currentTag) {
|
|
2887
|
+
case types_1.TagNames["urlset"]:
|
|
2888
|
+
case types_1.TagNames["xhtml:link"]:
|
|
2889
|
+
case types_1.TagNames["video:id"]:
|
|
2890
|
+
break;
|
|
2891
|
+
case types_1.TagNames["video:restriction"]:
|
|
2892
|
+
if (attr.name === "relationship" && (0, types_1.isAllowDeny)(attr.value)) {
|
|
2893
|
+
currentVideo["restriction:relationship"] = attr.value;
|
|
2894
|
+
} else {
|
|
2895
|
+
this.logger("log", "unhandled attr", currentTag, attr.name);
|
|
2896
|
+
this.err(`unhandled attr: ${currentTag} ${attr.name}`);
|
|
2897
|
+
}
|
|
2898
|
+
break;
|
|
2899
|
+
case types_1.TagNames["video:price"]:
|
|
2900
|
+
if (attr.name === "type" && (0, types_1.isPriceType)(attr.value)) {
|
|
2901
|
+
currentVideo["price:type"] = attr.value;
|
|
2902
|
+
} else if (attr.name === "currency") {
|
|
2903
|
+
currentVideo["price:currency"] = attr.value;
|
|
2904
|
+
} else if (attr.name === "resolution" && (0, types_1.isResolution)(attr.value)) {
|
|
2905
|
+
currentVideo["price:resolution"] = attr.value;
|
|
2906
|
+
} else {
|
|
2907
|
+
this.logger("log", "unhandled attr for video:price", attr.name);
|
|
2908
|
+
this.err(`unhandled attr: ${currentTag} ${attr.name}`);
|
|
2909
|
+
}
|
|
2910
|
+
break;
|
|
2911
|
+
case types_1.TagNames["video:player_loc"]:
|
|
2912
|
+
if (attr.name === "autoplay") {
|
|
2913
|
+
currentVideo["player_loc:autoplay"] = attr.value;
|
|
2914
|
+
} else if (attr.name === "allow_embed" && (0, types_1.isValidYesNo)(attr.value)) {
|
|
2915
|
+
currentVideo["player_loc:allow_embed"] = attr.value;
|
|
2916
|
+
} else {
|
|
2917
|
+
this.logger("log", "unhandled attr for video:player_loc", attr.name);
|
|
2918
|
+
this.err(`unhandled attr: ${currentTag} ${attr.name}`);
|
|
2919
|
+
}
|
|
2920
|
+
break;
|
|
2921
|
+
case types_1.TagNames["video:platform"]:
|
|
2922
|
+
if (attr.name === "relationship" && (0, types_1.isAllowDeny)(attr.value)) {
|
|
2923
|
+
currentVideo["platform:relationship"] = attr.value;
|
|
2924
|
+
} else {
|
|
2925
|
+
this.logger("log", "unhandled attr for video:platform", attr.name, attr.value);
|
|
2926
|
+
this.err(`unhandled attr: ${currentTag} ${attr.name} ${attr.value}`);
|
|
2927
|
+
}
|
|
2928
|
+
break;
|
|
2929
|
+
case types_1.TagNames["video:gallery_loc"]:
|
|
2930
|
+
if (attr.name === "title") {
|
|
2931
|
+
currentVideo["gallery_loc:title"] = attr.value;
|
|
2932
|
+
} else {
|
|
2933
|
+
this.logger("log", "unhandled attr for video:galler_loc", attr.name);
|
|
2934
|
+
this.err(`unhandled attr: ${currentTag} ${attr.name}`);
|
|
2935
|
+
}
|
|
2936
|
+
break;
|
|
2937
|
+
case types_1.TagNames["video:uploader"]:
|
|
2938
|
+
if (attr.name === "info") {
|
|
2939
|
+
currentVideo["uploader:info"] = attr.value;
|
|
2940
|
+
} else {
|
|
2941
|
+
this.logger("log", "unhandled attr for video:uploader", attr.name);
|
|
2942
|
+
this.err(`unhandled attr: ${currentTag} ${attr.name}`);
|
|
2943
|
+
}
|
|
2944
|
+
break;
|
|
2945
|
+
default:
|
|
2946
|
+
this.logger("log", "unhandled attr", currentTag, attr.name);
|
|
2947
|
+
this.err(`unhandled attr: ${currentTag} ${attr.name}`);
|
|
2948
|
+
}
|
|
2949
|
+
});
|
|
2950
|
+
this.saxStream.on("closetag", (tag) => {
|
|
2951
|
+
switch (tag) {
|
|
2952
|
+
case types_1.TagNames.url:
|
|
2953
|
+
this.push(currentItem);
|
|
2954
|
+
currentItem = tagTemplate();
|
|
2955
|
+
break;
|
|
2956
|
+
case types_1.TagNames["video:video"]:
|
|
2957
|
+
currentItem.video.push(currentVideo);
|
|
2958
|
+
currentVideo = videoTemplate();
|
|
2959
|
+
break;
|
|
2960
|
+
case types_1.TagNames["image:image"]:
|
|
2961
|
+
currentItem.img.push(currentImage);
|
|
2962
|
+
currentImage = __spreadValues({}, imageTemplate);
|
|
2963
|
+
break;
|
|
2964
|
+
case types_1.TagNames["xhtml:link"]:
|
|
2965
|
+
if (!dontpushCurrentLink) {
|
|
2966
|
+
currentItem.links.push(currentLink);
|
|
2967
|
+
}
|
|
2968
|
+
currentLink = __spreadValues({}, linkTemplate);
|
|
2969
|
+
break;
|
|
2970
|
+
default:
|
|
2971
|
+
break;
|
|
2972
|
+
}
|
|
2973
|
+
});
|
|
2974
|
+
}
|
|
2975
|
+
_transform(data, encoding, callback) {
|
|
2976
|
+
try {
|
|
2977
|
+
this.saxStream.write(data, encoding);
|
|
2978
|
+
callback(this.level === types_1.ErrorLevel.THROW ? this.error : null);
|
|
2979
|
+
} catch (error) {
|
|
2980
|
+
callback(error);
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
err(msg) {
|
|
2984
|
+
if (!this.error)
|
|
2985
|
+
this.error = new Error(msg);
|
|
2986
|
+
}
|
|
2987
|
+
};
|
|
2988
|
+
exports.XMLToSitemapItemStream = XMLToSitemapItemStream;
|
|
2989
|
+
async function parseSitemap(xml) {
|
|
2990
|
+
const urls = [];
|
|
2991
|
+
return new Promise((resolve2, reject) => {
|
|
2992
|
+
xml.pipe(new XMLToSitemapItemStream()).on("data", (smi) => urls.push(smi)).on("end", () => {
|
|
2993
|
+
resolve2(urls);
|
|
2994
|
+
}).on("error", (error) => {
|
|
2995
|
+
reject(error);
|
|
2996
|
+
});
|
|
2997
|
+
});
|
|
2998
|
+
}
|
|
2999
|
+
exports.parseSitemap = parseSitemap;
|
|
3000
|
+
var defaultObjectStreamOpts = {
|
|
3001
|
+
lineSeparated: false
|
|
3002
|
+
};
|
|
3003
|
+
var ObjectStreamToJSON = class extends stream_1.Transform {
|
|
3004
|
+
constructor(opts = defaultObjectStreamOpts) {
|
|
3005
|
+
opts.writableObjectMode = true;
|
|
3006
|
+
super(opts);
|
|
3007
|
+
this.lineSeparated = opts.lineSeparated;
|
|
3008
|
+
this.firstWritten = false;
|
|
3009
|
+
}
|
|
3010
|
+
_transform(chunk, encoding, cb) {
|
|
3011
|
+
if (!this.firstWritten) {
|
|
3012
|
+
this.firstWritten = true;
|
|
3013
|
+
if (!this.lineSeparated) {
|
|
3014
|
+
this.push("[");
|
|
3015
|
+
}
|
|
3016
|
+
} else if (this.lineSeparated) {
|
|
3017
|
+
this.push("\n");
|
|
3018
|
+
} else {
|
|
3019
|
+
this.push(",");
|
|
3020
|
+
}
|
|
3021
|
+
if (chunk) {
|
|
3022
|
+
this.push(JSON.stringify(chunk));
|
|
3023
|
+
}
|
|
3024
|
+
cb();
|
|
3025
|
+
}
|
|
3026
|
+
_flush(cb) {
|
|
3027
|
+
if (!this.lineSeparated) {
|
|
3028
|
+
this.push("]");
|
|
3029
|
+
}
|
|
3030
|
+
cb();
|
|
3031
|
+
}
|
|
3032
|
+
};
|
|
3033
|
+
exports.ObjectStreamToJSON = ObjectStreamToJSON;
|
|
3034
|
+
}
|
|
3035
|
+
});
|
|
3036
|
+
|
|
3037
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-parser.js
|
|
3038
|
+
var require_sitemap_index_parser = __commonJS({
|
|
3039
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-index-parser.js"(exports) {
|
|
3040
|
+
"use strict";
|
|
3041
|
+
init_cjs_shims();
|
|
3042
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
3043
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
3044
|
+
};
|
|
3045
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3046
|
+
exports.IndexObjectStreamToJSON = exports.parseSitemapIndex = exports.XMLToSitemapIndexStream = void 0;
|
|
3047
|
+
var sax_1 = __importDefault(require_sax());
|
|
3048
|
+
var stream_1 = require("stream");
|
|
3049
|
+
var types_1 = require_types();
|
|
3050
|
+
function isValidTagName(tagName) {
|
|
3051
|
+
return tagName in types_1.IndexTagNames;
|
|
3052
|
+
}
|
|
3053
|
+
function tagTemplate() {
|
|
3054
|
+
return {
|
|
3055
|
+
url: ""
|
|
3056
|
+
};
|
|
3057
|
+
}
|
|
3058
|
+
var defaultLogger = (level, ...message) => console[level](...message);
|
|
3059
|
+
var defaultStreamOpts = {
|
|
3060
|
+
logger: defaultLogger
|
|
3061
|
+
};
|
|
3062
|
+
var XMLToSitemapIndexStream = class extends stream_1.Transform {
|
|
3063
|
+
constructor(opts = defaultStreamOpts) {
|
|
3064
|
+
var _a;
|
|
3065
|
+
opts.objectMode = true;
|
|
3066
|
+
super(opts);
|
|
3067
|
+
this.saxStream = sax_1.default.createStream(true, {
|
|
3068
|
+
xmlns: true,
|
|
3069
|
+
strictEntities: true,
|
|
3070
|
+
trim: true
|
|
3071
|
+
});
|
|
3072
|
+
this.level = opts.level || types_1.ErrorLevel.WARN;
|
|
3073
|
+
if (this.level !== types_1.ErrorLevel.SILENT && opts.logger !== false) {
|
|
3074
|
+
this.logger = (_a = opts.logger) !== null && _a !== void 0 ? _a : defaultLogger;
|
|
3075
|
+
} else {
|
|
3076
|
+
this.logger = () => void 0;
|
|
3077
|
+
}
|
|
3078
|
+
let currentItem = tagTemplate();
|
|
3079
|
+
let currentTag;
|
|
3080
|
+
this.saxStream.on("opentagstart", (tag) => {
|
|
3081
|
+
currentTag = tag.name;
|
|
3082
|
+
});
|
|
3083
|
+
this.saxStream.on("opentag", (tag) => {
|
|
3084
|
+
if (!isValidTagName(tag.name)) {
|
|
3085
|
+
this.logger("warn", "unhandled tag", tag.name);
|
|
3086
|
+
}
|
|
3087
|
+
});
|
|
3088
|
+
this.saxStream.on("text", (text) => {
|
|
3089
|
+
switch (currentTag) {
|
|
3090
|
+
case types_1.IndexTagNames.loc:
|
|
3091
|
+
currentItem.url = text;
|
|
3092
|
+
break;
|
|
3093
|
+
case types_1.IndexTagNames.lastmod:
|
|
3094
|
+
currentItem.lastmod = text;
|
|
3095
|
+
break;
|
|
3096
|
+
default:
|
|
3097
|
+
this.logger("log", "unhandled text for tag:", currentTag, `'${text}'`);
|
|
3098
|
+
break;
|
|
3099
|
+
}
|
|
3100
|
+
});
|
|
3101
|
+
this.saxStream.on("cdata", (_text) => {
|
|
3102
|
+
switch (currentTag) {
|
|
3103
|
+
default:
|
|
3104
|
+
this.logger("log", "unhandled cdata for tag:", currentTag);
|
|
3105
|
+
break;
|
|
3106
|
+
}
|
|
3107
|
+
});
|
|
3108
|
+
this.saxStream.on("attribute", (attr) => {
|
|
3109
|
+
switch (currentTag) {
|
|
3110
|
+
case types_1.IndexTagNames.sitemapindex:
|
|
3111
|
+
break;
|
|
3112
|
+
default:
|
|
3113
|
+
this.logger("log", "unhandled attr", currentTag, attr.name);
|
|
3114
|
+
}
|
|
3115
|
+
});
|
|
3116
|
+
this.saxStream.on("closetag", (tag) => {
|
|
3117
|
+
switch (tag) {
|
|
3118
|
+
case types_1.IndexTagNames.sitemap:
|
|
3119
|
+
this.push(currentItem);
|
|
3120
|
+
currentItem = tagTemplate();
|
|
3121
|
+
break;
|
|
3122
|
+
default:
|
|
3123
|
+
break;
|
|
3124
|
+
}
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3127
|
+
_transform(data, encoding, callback) {
|
|
3128
|
+
try {
|
|
3129
|
+
this.saxStream.write(data, encoding);
|
|
3130
|
+
callback();
|
|
3131
|
+
} catch (error) {
|
|
3132
|
+
callback(error);
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
};
|
|
3136
|
+
exports.XMLToSitemapIndexStream = XMLToSitemapIndexStream;
|
|
3137
|
+
async function parseSitemapIndex(xml) {
|
|
3138
|
+
const urls = [];
|
|
3139
|
+
return new Promise((resolve2, reject) => {
|
|
3140
|
+
xml.pipe(new XMLToSitemapIndexStream()).on("data", (smi) => urls.push(smi)).on("end", () => {
|
|
3141
|
+
resolve2(urls);
|
|
3142
|
+
}).on("error", (error) => {
|
|
3143
|
+
reject(error);
|
|
3144
|
+
});
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
exports.parseSitemapIndex = parseSitemapIndex;
|
|
3148
|
+
var defaultObjectStreamOpts = {
|
|
3149
|
+
lineSeparated: false
|
|
3150
|
+
};
|
|
3151
|
+
var IndexObjectStreamToJSON = class extends stream_1.Transform {
|
|
3152
|
+
constructor(opts = defaultObjectStreamOpts) {
|
|
3153
|
+
opts.writableObjectMode = true;
|
|
3154
|
+
super(opts);
|
|
3155
|
+
this.lineSeparated = opts.lineSeparated;
|
|
3156
|
+
this.firstWritten = false;
|
|
3157
|
+
}
|
|
3158
|
+
_transform(chunk, encoding, cb) {
|
|
3159
|
+
if (!this.firstWritten) {
|
|
3160
|
+
this.firstWritten = true;
|
|
3161
|
+
if (!this.lineSeparated) {
|
|
3162
|
+
this.push("[");
|
|
3163
|
+
}
|
|
3164
|
+
} else if (this.lineSeparated) {
|
|
3165
|
+
this.push("\n");
|
|
3166
|
+
} else {
|
|
3167
|
+
this.push(",");
|
|
3168
|
+
}
|
|
3169
|
+
if (chunk) {
|
|
3170
|
+
this.push(JSON.stringify(chunk));
|
|
3171
|
+
}
|
|
3172
|
+
cb();
|
|
3173
|
+
}
|
|
3174
|
+
_flush(cb) {
|
|
3175
|
+
if (!this.lineSeparated) {
|
|
3176
|
+
this.push("]");
|
|
3177
|
+
}
|
|
3178
|
+
cb();
|
|
3179
|
+
}
|
|
3180
|
+
};
|
|
3181
|
+
exports.IndexObjectStreamToJSON = IndexObjectStreamToJSON;
|
|
3182
|
+
}
|
|
3183
|
+
});
|
|
3184
|
+
|
|
3185
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-simple.js
|
|
3186
|
+
var require_sitemap_simple = __commonJS({
|
|
3187
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/lib/sitemap-simple.js"(exports) {
|
|
3188
|
+
"use strict";
|
|
3189
|
+
init_cjs_shims();
|
|
3190
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3191
|
+
exports.simpleSitemapAndIndex = void 0;
|
|
3192
|
+
var index_1 = require_dist();
|
|
3193
|
+
var zlib_1 = require("zlib");
|
|
3194
|
+
var fs_1 = require("fs");
|
|
3195
|
+
var path_1 = require("path");
|
|
3196
|
+
var stream_1 = require("stream");
|
|
3197
|
+
var util_1 = require("util");
|
|
3198
|
+
var url_1 = require("url");
|
|
3199
|
+
var pipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
3200
|
+
var simpleSitemapAndIndex = async ({
|
|
3201
|
+
hostname,
|
|
3202
|
+
sitemapHostname = hostname,
|
|
3203
|
+
sourceData,
|
|
3204
|
+
destinationDir,
|
|
3205
|
+
limit = 5e4,
|
|
3206
|
+
gzip = true,
|
|
3207
|
+
publicBasePath = "./"
|
|
3208
|
+
}) => {
|
|
3209
|
+
await fs_1.promises.mkdir(destinationDir, { recursive: true });
|
|
3210
|
+
const sitemapAndIndexStream = new index_1.SitemapAndIndexStream({
|
|
3211
|
+
limit,
|
|
3212
|
+
getSitemapStream: (i) => {
|
|
3213
|
+
const sitemapStream = new index_1.SitemapStream({
|
|
3214
|
+
hostname
|
|
3215
|
+
});
|
|
3216
|
+
const path = `./sitemap-${i}.xml`;
|
|
3217
|
+
const writePath2 = (0, path_1.resolve)(destinationDir, path + (gzip ? ".gz" : ""));
|
|
3218
|
+
if (!publicBasePath.endsWith("/")) {
|
|
3219
|
+
publicBasePath += "/";
|
|
3220
|
+
}
|
|
3221
|
+
const publicPath = (0, path_1.normalize)(publicBasePath + path);
|
|
3222
|
+
let pipeline2;
|
|
3223
|
+
if (gzip) {
|
|
3224
|
+
pipeline2 = sitemapStream.pipe((0, zlib_1.createGzip)()).pipe((0, fs_1.createWriteStream)(writePath2));
|
|
3225
|
+
} else {
|
|
3226
|
+
pipeline2 = sitemapStream.pipe((0, fs_1.createWriteStream)(writePath2));
|
|
3227
|
+
}
|
|
3228
|
+
return [
|
|
3229
|
+
new url_1.URL(`${publicPath}${gzip ? ".gz" : ""}`, sitemapHostname).toString(),
|
|
3230
|
+
sitemapStream,
|
|
3231
|
+
pipeline2
|
|
3232
|
+
];
|
|
3233
|
+
}
|
|
3234
|
+
});
|
|
3235
|
+
let src;
|
|
3236
|
+
if (typeof sourceData === "string") {
|
|
3237
|
+
src = (0, index_1.lineSeparatedURLsToSitemapOptions)((0, fs_1.createReadStream)(sourceData));
|
|
3238
|
+
} else if (sourceData instanceof stream_1.Readable) {
|
|
3239
|
+
src = sourceData;
|
|
3240
|
+
} else if (Array.isArray(sourceData)) {
|
|
3241
|
+
src = stream_1.Readable.from(sourceData);
|
|
3242
|
+
} else {
|
|
3243
|
+
throw new Error("unhandled source type. You've passed in data that is not supported");
|
|
3244
|
+
}
|
|
3245
|
+
const writePath = (0, path_1.resolve)(destinationDir, `./sitemap-index.xml${gzip ? ".gz" : ""}`);
|
|
3246
|
+
if (gzip) {
|
|
3247
|
+
return pipeline(src, sitemapAndIndexStream, (0, zlib_1.createGzip)(), (0, fs_1.createWriteStream)(writePath));
|
|
3248
|
+
} else {
|
|
3249
|
+
return pipeline(src, sitemapAndIndexStream, (0, fs_1.createWriteStream)(writePath));
|
|
3250
|
+
}
|
|
3251
|
+
};
|
|
3252
|
+
exports.simpleSitemapAndIndex = simpleSitemapAndIndex;
|
|
3253
|
+
exports.default = exports.simpleSitemapAndIndex;
|
|
3254
|
+
}
|
|
3255
|
+
});
|
|
3256
|
+
|
|
3257
|
+
// node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/index.js
|
|
3258
|
+
var require_dist = __commonJS({
|
|
3259
|
+
"node_modules/.pnpm/sitemap@7.1.1/node_modules/sitemap/dist/index.js"(exports) {
|
|
3260
|
+
"use strict";
|
|
3261
|
+
init_cjs_shims();
|
|
3262
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3263
|
+
if (k2 === void 0)
|
|
3264
|
+
k2 = k;
|
|
3265
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() {
|
|
3266
|
+
return m[k];
|
|
3267
|
+
} });
|
|
3268
|
+
} : function(o, m, k, k2) {
|
|
3269
|
+
if (k2 === void 0)
|
|
3270
|
+
k2 = k;
|
|
3271
|
+
o[k2] = m[k];
|
|
3272
|
+
});
|
|
3273
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
3274
|
+
for (var p in m)
|
|
3275
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
3276
|
+
__createBinding(exports2, m, p);
|
|
3277
|
+
};
|
|
3278
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3279
|
+
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;
|
|
3280
|
+
var sitemap_item_stream_1 = require_sitemap_item_stream();
|
|
3281
|
+
Object.defineProperty(exports, "SitemapItemStream", { enumerable: true, get: function() {
|
|
3282
|
+
return sitemap_item_stream_1.SitemapItemStream;
|
|
3283
|
+
} });
|
|
3284
|
+
var sitemap_index_stream_1 = require_sitemap_index_stream();
|
|
3285
|
+
Object.defineProperty(exports, "IndexTagNames", { enumerable: true, get: function() {
|
|
3286
|
+
return sitemap_index_stream_1.IndexTagNames;
|
|
3287
|
+
} });
|
|
3288
|
+
Object.defineProperty(exports, "SitemapIndexStream", { enumerable: true, get: function() {
|
|
3289
|
+
return sitemap_index_stream_1.SitemapIndexStream;
|
|
3290
|
+
} });
|
|
3291
|
+
Object.defineProperty(exports, "SitemapAndIndexStream", { enumerable: true, get: function() {
|
|
3292
|
+
return sitemap_index_stream_1.SitemapAndIndexStream;
|
|
3293
|
+
} });
|
|
3294
|
+
var sitemap_stream_1 = require_sitemap_stream();
|
|
3295
|
+
Object.defineProperty(exports, "streamToPromise", { enumerable: true, get: function() {
|
|
3296
|
+
return sitemap_stream_1.streamToPromise;
|
|
3297
|
+
} });
|
|
3298
|
+
Object.defineProperty(exports, "SitemapStream", { enumerable: true, get: function() {
|
|
3299
|
+
return sitemap_stream_1.SitemapStream;
|
|
3300
|
+
} });
|
|
3301
|
+
__exportStar(require_errors(), exports);
|
|
3302
|
+
__exportStar(require_types(), exports);
|
|
3303
|
+
var utils_1 = require_utils();
|
|
3304
|
+
Object.defineProperty(exports, "lineSeparatedURLsToSitemapOptions", { enumerable: true, get: function() {
|
|
3305
|
+
return utils_1.lineSeparatedURLsToSitemapOptions;
|
|
3306
|
+
} });
|
|
3307
|
+
Object.defineProperty(exports, "mergeStreams", { enumerable: true, get: function() {
|
|
3308
|
+
return utils_1.mergeStreams;
|
|
3309
|
+
} });
|
|
3310
|
+
Object.defineProperty(exports, "validateSMIOptions", { enumerable: true, get: function() {
|
|
3311
|
+
return utils_1.validateSMIOptions;
|
|
3312
|
+
} });
|
|
3313
|
+
Object.defineProperty(exports, "normalizeURL", { enumerable: true, get: function() {
|
|
3314
|
+
return utils_1.normalizeURL;
|
|
3315
|
+
} });
|
|
3316
|
+
Object.defineProperty(exports, "ReadlineStream", { enumerable: true, get: function() {
|
|
3317
|
+
return utils_1.ReadlineStream;
|
|
3318
|
+
} });
|
|
3319
|
+
var xmllint_1 = require_xmllint();
|
|
3320
|
+
Object.defineProperty(exports, "xmlLint", { enumerable: true, get: function() {
|
|
3321
|
+
return xmllint_1.xmlLint;
|
|
3322
|
+
} });
|
|
3323
|
+
var sitemap_parser_1 = require_sitemap_parser();
|
|
3324
|
+
Object.defineProperty(exports, "parseSitemap", { enumerable: true, get: function() {
|
|
3325
|
+
return sitemap_parser_1.parseSitemap;
|
|
3326
|
+
} });
|
|
3327
|
+
Object.defineProperty(exports, "XMLToSitemapItemStream", { enumerable: true, get: function() {
|
|
3328
|
+
return sitemap_parser_1.XMLToSitemapItemStream;
|
|
3329
|
+
} });
|
|
3330
|
+
Object.defineProperty(exports, "ObjectStreamToJSON", { enumerable: true, get: function() {
|
|
3331
|
+
return sitemap_parser_1.ObjectStreamToJSON;
|
|
3332
|
+
} });
|
|
3333
|
+
var sitemap_index_parser_1 = require_sitemap_index_parser();
|
|
3334
|
+
Object.defineProperty(exports, "parseSitemapIndex", { enumerable: true, get: function() {
|
|
3335
|
+
return sitemap_index_parser_1.parseSitemapIndex;
|
|
3336
|
+
} });
|
|
3337
|
+
Object.defineProperty(exports, "XMLToSitemapIndexStream", { enumerable: true, get: function() {
|
|
3338
|
+
return sitemap_index_parser_1.XMLToSitemapIndexStream;
|
|
3339
|
+
} });
|
|
3340
|
+
Object.defineProperty(exports, "IndexObjectStreamToJSON", { enumerable: true, get: function() {
|
|
3341
|
+
return sitemap_index_parser_1.IndexObjectStreamToJSON;
|
|
3342
|
+
} });
|
|
3343
|
+
var sitemap_simple_1 = require_sitemap_simple();
|
|
3344
|
+
Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function() {
|
|
3345
|
+
return sitemap_simple_1.simpleSitemapAndIndex;
|
|
3346
|
+
} });
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
|
|
3350
|
+
// node_modules/.pnpm/xml-parser-xo@3.2.0/node_modules/xml-parser-xo/index.js
|
|
3351
|
+
var require_xml_parser_xo = __commonJS({
|
|
3352
|
+
"node_modules/.pnpm/xml-parser-xo@3.2.0/node_modules/xml-parser-xo/index.js"(exports, module2) {
|
|
3353
|
+
init_cjs_shims();
|
|
3354
|
+
function parse2(xml, options = {}) {
|
|
3355
|
+
options.filter = options.filter || (() => true);
|
|
3356
|
+
function nextChild() {
|
|
3357
|
+
return tag() || content() || comment() || cdata();
|
|
3358
|
+
}
|
|
3359
|
+
function nextRootChild() {
|
|
3360
|
+
match(/\s*/);
|
|
3361
|
+
return tag(true) || comment() || doctype() || processingInstruction(false);
|
|
3362
|
+
}
|
|
3363
|
+
function document2() {
|
|
3364
|
+
const decl = declaration();
|
|
3365
|
+
const children = [];
|
|
3366
|
+
let documentRootNode;
|
|
3367
|
+
let child = nextRootChild();
|
|
3368
|
+
while (child) {
|
|
3369
|
+
if (child.node.type === "Element") {
|
|
3370
|
+
if (documentRootNode) {
|
|
3371
|
+
throw new Error("Found multiple root nodes");
|
|
3372
|
+
}
|
|
3373
|
+
documentRootNode = child.node;
|
|
3374
|
+
}
|
|
3375
|
+
if (!child.excluded) {
|
|
3376
|
+
children.push(child.node);
|
|
3377
|
+
}
|
|
3378
|
+
child = nextRootChild();
|
|
3379
|
+
}
|
|
3380
|
+
if (!documentRootNode) {
|
|
3381
|
+
throw new Error("Failed to parse XML");
|
|
3382
|
+
}
|
|
3383
|
+
return {
|
|
3384
|
+
declaration: decl ? decl.node : null,
|
|
3385
|
+
root: documentRootNode,
|
|
3386
|
+
children
|
|
3387
|
+
};
|
|
3388
|
+
}
|
|
3389
|
+
function declaration() {
|
|
3390
|
+
return processingInstruction(true);
|
|
3391
|
+
}
|
|
3392
|
+
function processingInstruction(matchDeclaration) {
|
|
3393
|
+
const m = matchDeclaration ? match(/^<\?(xml)\s*/) : match(/^<\?([\w-:.]+)\s*/);
|
|
3394
|
+
if (!m)
|
|
3395
|
+
return;
|
|
3396
|
+
const node = {
|
|
3397
|
+
name: m[1],
|
|
3398
|
+
type: "ProcessingInstruction",
|
|
3399
|
+
attributes: {}
|
|
3400
|
+
};
|
|
3401
|
+
while (!(eos() || is("?>"))) {
|
|
3402
|
+
const attr = attribute();
|
|
3403
|
+
if (!attr)
|
|
3404
|
+
return node;
|
|
3405
|
+
node.attributes[attr.name] = attr.value;
|
|
3406
|
+
}
|
|
3407
|
+
match(/\?>/);
|
|
3408
|
+
return {
|
|
3409
|
+
excluded: matchDeclaration ? false : options.filter(node) === false,
|
|
3410
|
+
node
|
|
3411
|
+
};
|
|
3412
|
+
}
|
|
3413
|
+
function tag(matchRoot) {
|
|
3414
|
+
const m = match(/^<([\w-:.]+)\s*/);
|
|
3415
|
+
if (!m)
|
|
3416
|
+
return;
|
|
3417
|
+
const node = {
|
|
3418
|
+
type: "Element",
|
|
3419
|
+
name: m[1],
|
|
3420
|
+
attributes: {},
|
|
3421
|
+
children: []
|
|
3422
|
+
};
|
|
3423
|
+
while (!(eos() || is(">") || is("?>") || is("/>"))) {
|
|
3424
|
+
const attr = attribute();
|
|
3425
|
+
if (!attr)
|
|
3426
|
+
return node;
|
|
3427
|
+
node.attributes[attr.name] = attr.value;
|
|
3428
|
+
}
|
|
3429
|
+
const excluded = matchRoot ? false : options.filter(node) === false;
|
|
3430
|
+
if (match(/^\s*\/>/)) {
|
|
3431
|
+
node.children = null;
|
|
3432
|
+
return {
|
|
3433
|
+
excluded,
|
|
3434
|
+
node
|
|
3435
|
+
};
|
|
3436
|
+
}
|
|
3437
|
+
match(/\??>/);
|
|
3438
|
+
if (!excluded) {
|
|
3439
|
+
let child = nextChild();
|
|
3440
|
+
while (child) {
|
|
3441
|
+
if (!child.excluded) {
|
|
3442
|
+
node.children.push(child.node);
|
|
3443
|
+
}
|
|
3444
|
+
child = nextChild();
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
match(/^<\/[\w-:.]+>/);
|
|
3448
|
+
return {
|
|
3449
|
+
excluded,
|
|
3450
|
+
node
|
|
3451
|
+
};
|
|
3452
|
+
}
|
|
3453
|
+
function doctype() {
|
|
3454
|
+
const m = match(/^<!DOCTYPE\s+[^>]*>/);
|
|
3455
|
+
if (m) {
|
|
3456
|
+
const node = {
|
|
3457
|
+
type: "DocumentType",
|
|
3458
|
+
content: m[0]
|
|
3459
|
+
};
|
|
3460
|
+
return {
|
|
3461
|
+
excluded: options.filter(node) === false,
|
|
3462
|
+
node
|
|
3463
|
+
};
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
function cdata() {
|
|
3467
|
+
if (xml.startsWith("<![CDATA[")) {
|
|
3468
|
+
const endPositionStart = xml.indexOf("]]>");
|
|
3469
|
+
if (endPositionStart > -1) {
|
|
3470
|
+
const endPositionFinish = endPositionStart + 3;
|
|
3471
|
+
const node = {
|
|
3472
|
+
type: "CDATA",
|
|
3473
|
+
content: xml.substring(0, endPositionFinish)
|
|
3474
|
+
};
|
|
3475
|
+
xml = xml.slice(endPositionFinish);
|
|
3476
|
+
return {
|
|
3477
|
+
excluded: options.filter(node) === false,
|
|
3478
|
+
node
|
|
3479
|
+
};
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
function comment() {
|
|
3484
|
+
const m = match(/^<!--[\s\S]*?-->/);
|
|
3485
|
+
if (m) {
|
|
3486
|
+
const node = {
|
|
3487
|
+
type: "Comment",
|
|
3488
|
+
content: m[0]
|
|
3489
|
+
};
|
|
3490
|
+
return {
|
|
3491
|
+
excluded: options.filter(node) === false,
|
|
3492
|
+
node
|
|
3493
|
+
};
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
function content() {
|
|
3497
|
+
const m = match(/^([^<]+)/);
|
|
3498
|
+
if (m) {
|
|
3499
|
+
const node = {
|
|
3500
|
+
type: "Text",
|
|
3501
|
+
content: m[1]
|
|
3502
|
+
};
|
|
3503
|
+
return {
|
|
3504
|
+
excluded: options.filter(node) === false,
|
|
3505
|
+
node
|
|
3506
|
+
};
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
function attribute() {
|
|
3510
|
+
const m = match(/([\w-:.]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);
|
|
3511
|
+
if (!m)
|
|
3512
|
+
return;
|
|
3513
|
+
return { name: m[1], value: strip(m[2]) };
|
|
3514
|
+
}
|
|
3515
|
+
function strip(val) {
|
|
3516
|
+
return val.replace(/^['"]|['"]$/g, "");
|
|
3517
|
+
}
|
|
3518
|
+
function match(re) {
|
|
3519
|
+
const m = xml.match(re);
|
|
3520
|
+
if (!m)
|
|
3521
|
+
return;
|
|
3522
|
+
xml = xml.slice(m[0].length);
|
|
3523
|
+
return m;
|
|
3524
|
+
}
|
|
3525
|
+
function eos() {
|
|
3526
|
+
return xml.length === 0;
|
|
3527
|
+
}
|
|
3528
|
+
function is(prefix) {
|
|
3529
|
+
return xml.indexOf(prefix) === 0;
|
|
3530
|
+
}
|
|
3531
|
+
xml = xml.trim();
|
|
3532
|
+
return document2();
|
|
3533
|
+
}
|
|
3534
|
+
module2.exports = parse2;
|
|
3535
|
+
}
|
|
3536
|
+
});
|
|
3537
|
+
|
|
3538
|
+
// node_modules/.pnpm/xml-formatter@2.6.1/node_modules/xml-formatter/index.js
|
|
3539
|
+
var require_xml_formatter = __commonJS({
|
|
3540
|
+
"node_modules/.pnpm/xml-formatter@2.6.1/node_modules/xml-formatter/index.js"(exports, module2) {
|
|
3541
|
+
init_cjs_shims();
|
|
3542
|
+
function newLine(state) {
|
|
3543
|
+
if (!state.options.indentation && !state.options.lineSeparator)
|
|
3544
|
+
return;
|
|
3545
|
+
state.content += state.options.lineSeparator;
|
|
3546
|
+
let i;
|
|
3547
|
+
for (i = 0; i < state.level; i++) {
|
|
3548
|
+
state.content += state.options.indentation;
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
function appendContent(state, content) {
|
|
3552
|
+
state.content += content;
|
|
3553
|
+
}
|
|
3554
|
+
function processNode(node, state, preserveSpace) {
|
|
3555
|
+
if (typeof node.content === "string") {
|
|
3556
|
+
processContentNode(node, state, preserveSpace);
|
|
3557
|
+
} else if (node.type === "Element") {
|
|
3558
|
+
processElementNode(node, state, preserveSpace);
|
|
3559
|
+
} else if (node.type === "ProcessingInstruction") {
|
|
3560
|
+
processProcessingIntruction(node, state, preserveSpace);
|
|
3561
|
+
} else {
|
|
3562
|
+
throw new Error("Unknown node type: " + node.type);
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
function processContentNode(node, state, preserveSpace) {
|
|
3566
|
+
if (!preserveSpace) {
|
|
3567
|
+
node.content = node.content.trim();
|
|
3568
|
+
}
|
|
3569
|
+
if (node.content.length > 0) {
|
|
3570
|
+
if (!preserveSpace && state.content.length > 0) {
|
|
3571
|
+
newLine(state);
|
|
3572
|
+
}
|
|
3573
|
+
appendContent(state, node.content);
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
function processElementNode(node, state, preserveSpace) {
|
|
3577
|
+
if (!preserveSpace && state.content.length > 0) {
|
|
3578
|
+
newLine(state);
|
|
3579
|
+
}
|
|
3580
|
+
appendContent(state, "<" + node.name);
|
|
3581
|
+
processAttributes(state, node.attributes);
|
|
3582
|
+
if (node.children === null) {
|
|
3583
|
+
const selfClosingNodeClosingTag = state.options.whiteSpaceAtEndOfSelfclosingTag ? " />" : "/>";
|
|
3584
|
+
appendContent(state, selfClosingNodeClosingTag);
|
|
3585
|
+
} else if (node.children.length === 0) {
|
|
3586
|
+
appendContent(state, "></" + node.name + ">");
|
|
3587
|
+
} else {
|
|
3588
|
+
appendContent(state, ">");
|
|
3589
|
+
state.level++;
|
|
3590
|
+
let nodePreserveSpace = node.attributes["xml:space"] === "preserve";
|
|
3591
|
+
if (!nodePreserveSpace && state.options.collapseContent) {
|
|
3592
|
+
let containsTextNodes = false;
|
|
3593
|
+
let containsTextNodesWithLineBreaks = false;
|
|
3594
|
+
let containsNonTextNodes = false;
|
|
3595
|
+
node.children.forEach(function(child, index) {
|
|
3596
|
+
if (child.type === "Text") {
|
|
3597
|
+
if (child.content.includes("\n")) {
|
|
3598
|
+
containsTextNodesWithLineBreaks = true;
|
|
3599
|
+
child.content = child.content.trim();
|
|
3600
|
+
} else if (index === 0 || index === node.children.length - 1) {
|
|
3601
|
+
if (child.content.trim().length === 0) {
|
|
3602
|
+
child.content = "";
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
if (child.content.length > 0) {
|
|
3606
|
+
containsTextNodes = true;
|
|
3607
|
+
}
|
|
3608
|
+
} else if (child.type === "CDATA") {
|
|
3609
|
+
containsTextNodes = true;
|
|
3610
|
+
} else {
|
|
3611
|
+
containsNonTextNodes = true;
|
|
3612
|
+
}
|
|
3613
|
+
});
|
|
3614
|
+
if (containsTextNodes && (!containsNonTextNodes || !containsTextNodesWithLineBreaks)) {
|
|
3615
|
+
nodePreserveSpace = true;
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
node.children.forEach(function(child) {
|
|
3619
|
+
processNode(child, state, preserveSpace || nodePreserveSpace, state.options);
|
|
3620
|
+
});
|
|
3621
|
+
state.level--;
|
|
3622
|
+
if (!preserveSpace && !nodePreserveSpace) {
|
|
3623
|
+
newLine(state);
|
|
3624
|
+
}
|
|
3625
|
+
appendContent(state, "</" + node.name + ">");
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
function processAttributes(state, attributes) {
|
|
3629
|
+
Object.keys(attributes).forEach(function(attr) {
|
|
3630
|
+
const escaped = attributes[attr].replace(/"/g, """);
|
|
3631
|
+
appendContent(state, " " + attr + '="' + escaped + '"');
|
|
3632
|
+
});
|
|
3633
|
+
}
|
|
3634
|
+
function processProcessingIntruction(node, state) {
|
|
3635
|
+
if (state.content.length > 0) {
|
|
3636
|
+
newLine(state);
|
|
3637
|
+
}
|
|
3638
|
+
appendContent(state, "<?" + node.name);
|
|
3639
|
+
processAttributes(state, node.attributes);
|
|
3640
|
+
appendContent(state, "?>");
|
|
3641
|
+
}
|
|
3642
|
+
function format2(xml, options = {}) {
|
|
3643
|
+
options.indentation = "indentation" in options ? options.indentation : " ";
|
|
3644
|
+
options.collapseContent = options.collapseContent === true;
|
|
3645
|
+
options.lineSeparator = "lineSeparator" in options ? options.lineSeparator : "\r\n";
|
|
3646
|
+
options.whiteSpaceAtEndOfSelfclosingTag = !!options.whiteSpaceAtEndOfSelfclosingTag;
|
|
3647
|
+
const parser = require_xml_parser_xo();
|
|
3648
|
+
const parsedXml = parser(xml, { filter: options.filter });
|
|
3649
|
+
const state = { content: "", level: 0, options };
|
|
3650
|
+
if (parsedXml.declaration) {
|
|
3651
|
+
processProcessingIntruction(parsedXml.declaration, state);
|
|
3652
|
+
}
|
|
3653
|
+
parsedXml.children.forEach(function(child) {
|
|
3654
|
+
processNode(child, state, false);
|
|
3655
|
+
});
|
|
3656
|
+
return state.content.replace(/\r\n/g, "\n").replace(/\n/g, options.lineSeparator);
|
|
3657
|
+
}
|
|
3658
|
+
module2.exports = format2;
|
|
3659
|
+
}
|
|
3660
|
+
});
|
|
3661
|
+
|
|
3662
|
+
// src/index.ts
|
|
3663
|
+
var src_exports = {};
|
|
3664
|
+
__export(src_exports, {
|
|
3665
|
+
default: () => src_default,
|
|
3666
|
+
generateSitemap: () => generateSitemap
|
|
3667
|
+
});
|
|
3668
|
+
module.exports = __toCommonJS(src_exports);
|
|
3669
|
+
init_cjs_shims();
|
|
3670
|
+
var import_fs = require("fs");
|
|
3671
|
+
var import_sitemap = __toESM(require_dist());
|
|
3672
|
+
var import_xml_formatter = __toESM(require_xml_formatter());
|
|
3673
|
+
|
|
3674
|
+
// src/options.ts
|
|
3675
|
+
init_cjs_shims();
|
|
3676
|
+
function resolveOptions(userOptions) {
|
|
3677
|
+
return Object.assign({
|
|
3678
|
+
hostname: "http://localhost/",
|
|
3679
|
+
dynamicRoutes: [],
|
|
3680
|
+
outDir: "dist",
|
|
3681
|
+
changefreq: "daily",
|
|
3682
|
+
priority: 1,
|
|
3683
|
+
lastmod: new Date(),
|
|
3684
|
+
readable: false,
|
|
3685
|
+
robots: [{
|
|
3686
|
+
userAgent: "*",
|
|
3687
|
+
allow: "/"
|
|
3688
|
+
}]
|
|
3689
|
+
}, userOptions);
|
|
3690
|
+
}
|
|
3691
|
+
|
|
3692
|
+
// src/robots.ts
|
|
3693
|
+
init_cjs_shims();
|
|
3694
|
+
|
|
3695
|
+
// node_modules/.pnpm/@antfu+utils@0.5.1/node_modules/@antfu/utils/dist/index.mjs
|
|
3696
|
+
init_cjs_shims();
|
|
3697
|
+
function slash(str) {
|
|
3698
|
+
return str.replace(/\\/g, "/");
|
|
3699
|
+
}
|
|
3700
|
+
function ensurePrefix(prefix, str) {
|
|
3701
|
+
if (!str.startsWith(prefix))
|
|
3702
|
+
return prefix + str;
|
|
3703
|
+
return str;
|
|
3704
|
+
}
|
|
3705
|
+
function ensureSuffix(suffix, str) {
|
|
3706
|
+
if (!str.endsWith(suffix))
|
|
3707
|
+
return str + suffix;
|
|
3708
|
+
return str;
|
|
3709
|
+
}
|
|
3710
|
+
var Node = class {
|
|
3711
|
+
value;
|
|
3712
|
+
next;
|
|
3713
|
+
constructor(value) {
|
|
3714
|
+
this.value = value;
|
|
3715
|
+
}
|
|
3716
|
+
};
|
|
3717
|
+
var _head, _tail, _size;
|
|
3718
|
+
var Queue = class {
|
|
3719
|
+
constructor() {
|
|
3720
|
+
__privateAdd(this, _head, void 0);
|
|
3721
|
+
__privateAdd(this, _tail, void 0);
|
|
3722
|
+
__privateAdd(this, _size, void 0);
|
|
3723
|
+
this.clear();
|
|
3724
|
+
}
|
|
3725
|
+
enqueue(value) {
|
|
3726
|
+
const node = new Node(value);
|
|
3727
|
+
if (__privateGet(this, _head)) {
|
|
3728
|
+
__privateGet(this, _tail).next = node;
|
|
3729
|
+
__privateSet(this, _tail, node);
|
|
3730
|
+
} else {
|
|
3731
|
+
__privateSet(this, _head, node);
|
|
3732
|
+
__privateSet(this, _tail, node);
|
|
3733
|
+
}
|
|
3734
|
+
__privateWrapper(this, _size)._++;
|
|
3735
|
+
}
|
|
3736
|
+
dequeue() {
|
|
3737
|
+
const current = __privateGet(this, _head);
|
|
3738
|
+
if (!current) {
|
|
3739
|
+
return;
|
|
3740
|
+
}
|
|
3741
|
+
__privateSet(this, _head, __privateGet(this, _head).next);
|
|
3742
|
+
__privateWrapper(this, _size)._--;
|
|
3743
|
+
return current.value;
|
|
3744
|
+
}
|
|
3745
|
+
clear() {
|
|
3746
|
+
__privateSet(this, _head, void 0);
|
|
3747
|
+
__privateSet(this, _tail, void 0);
|
|
3748
|
+
__privateSet(this, _size, 0);
|
|
3749
|
+
}
|
|
3750
|
+
get size() {
|
|
3751
|
+
return __privateGet(this, _size);
|
|
3752
|
+
}
|
|
3753
|
+
*[Symbol.iterator]() {
|
|
3754
|
+
let current = __privateGet(this, _head);
|
|
3755
|
+
while (current) {
|
|
3756
|
+
yield current.value;
|
|
3757
|
+
current = current.next;
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
};
|
|
3761
|
+
_head = new WeakMap();
|
|
3762
|
+
_tail = new WeakMap();
|
|
3763
|
+
_size = new WeakMap();
|
|
3764
|
+
var VOID = Symbol("p-void");
|
|
3765
|
+
|
|
3766
|
+
// src/robots.ts
|
|
3767
|
+
var RobotCorrespondences = /* @__PURE__ */ ((RobotCorrespondences2) => {
|
|
3768
|
+
RobotCorrespondences2["userAgent"] = "User-agent";
|
|
3769
|
+
RobotCorrespondences2["allow"] = "Allow";
|
|
3770
|
+
RobotCorrespondences2["disallow"] = "Disallow";
|
|
3771
|
+
RobotCorrespondences2["crawlDelay"] = "Crawl-delay";
|
|
3772
|
+
RobotCorrespondences2["cleanParam"] = "Clean-param";
|
|
3773
|
+
return RobotCorrespondences2;
|
|
3774
|
+
})(RobotCorrespondences || {});
|
|
3775
|
+
function getRules(options) {
|
|
3776
|
+
const rules = [];
|
|
3777
|
+
options.forEach((rule) => {
|
|
3778
|
+
const keys = Object.keys(RobotCorrespondences).filter((key) => typeof rule[key] !== "undefined");
|
|
3779
|
+
keys.forEach((key) => {
|
|
3780
|
+
const values = Array.isArray(rule[key]) ? rule[key] : [rule[key]];
|
|
3781
|
+
values.forEach((value) => {
|
|
3782
|
+
rules.push({
|
|
3783
|
+
key: RobotCorrespondences[key],
|
|
3784
|
+
value
|
|
3785
|
+
});
|
|
3786
|
+
});
|
|
3787
|
+
});
|
|
3788
|
+
});
|
|
3789
|
+
return rules;
|
|
3790
|
+
}
|
|
3791
|
+
function getContent(rules, hostname) {
|
|
3792
|
+
return rules.map((rule) => `${rule.key}: ${String(rule.value).trim()}`).join("\n").concat(`
|
|
3793
|
+
|
|
3794
|
+
Sitemap: ${getFinalSitemapPath(hostname)}`);
|
|
3795
|
+
}
|
|
3796
|
+
function getFinalSitemapPath(hostname) {
|
|
3797
|
+
return `${ensureSuffix("/", hostname)}sitemap.xml`;
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
// src/sitemap.ts
|
|
3801
|
+
init_cjs_shims();
|
|
3802
|
+
var import_path = require("path");
|
|
3803
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
3804
|
+
function getRoutes(options) {
|
|
3805
|
+
return [
|
|
3806
|
+
...import_fast_glob.default.sync("**/*.html", { cwd: options.outDir }).map((route) => {
|
|
3807
|
+
const parsedRoute = (0, import_path.parse)(route.replace(/index\.html/g, ""));
|
|
3808
|
+
return slash((0, import_path.join)("/", parsedRoute.dir, parsedRoute.name));
|
|
3809
|
+
}),
|
|
3810
|
+
...options.dynamicRoutes.map((route) => slash((0, import_path.join)("/", (0, import_path.join)((0, import_path.parse)(route).dir, (0, import_path.parse)(route).name))))
|
|
3811
|
+
];
|
|
3812
|
+
}
|
|
3813
|
+
function getFormattedSitemap(options, routes) {
|
|
3814
|
+
return routes.map((route) => ({
|
|
3815
|
+
url: new URL(route, options.hostname).href,
|
|
3816
|
+
changefreq: options.changefreq,
|
|
3817
|
+
priority: options.priority,
|
|
3818
|
+
lastmod: options.lastmod
|
|
3819
|
+
}));
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
// src/utils.ts
|
|
3823
|
+
init_cjs_shims();
|
|
3824
|
+
var import_path2 = require("path");
|
|
3825
|
+
function getResolvedPath(file, resolvedOptions) {
|
|
3826
|
+
return (0, import_path2.resolve)(`${ensurePrefix("./", resolvedOptions.outDir)}/${file}`);
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3829
|
+
// src/types.ts
|
|
3830
|
+
init_cjs_shims();
|
|
3831
|
+
|
|
3832
|
+
// src/index.ts
|
|
3833
|
+
function generateSitemap(options = {}) {
|
|
3834
|
+
const resolvedOptions = resolveOptions(options);
|
|
3835
|
+
const robotRules = getRules(resolvedOptions.robots);
|
|
3836
|
+
const robotContent = getContent(robotRules, resolvedOptions.hostname);
|
|
3837
|
+
(0, import_fs.writeFileSync)(getResolvedPath("robots.txt", resolvedOptions), robotContent);
|
|
3838
|
+
const routes = getRoutes(resolvedOptions);
|
|
3839
|
+
if (!routes.length)
|
|
3840
|
+
return;
|
|
3841
|
+
const formattedSitemap = getFormattedSitemap(resolvedOptions, routes);
|
|
3842
|
+
const stream = new import_sitemap.SitemapStream();
|
|
3843
|
+
formattedSitemap.forEach((item) => stream.write(item));
|
|
3844
|
+
(0, import_sitemap.streamToPromise)(stream).then((sitemap) => {
|
|
3845
|
+
const utfSitemap = sitemap.toString("utf-8");
|
|
3846
|
+
const formattedSitemap2 = resolvedOptions.readable ? (0, import_xml_formatter.default)(utfSitemap) : utfSitemap;
|
|
3847
|
+
(0, import_fs.writeFileSync)(getResolvedPath("sitemap.xml", resolvedOptions), formattedSitemap2);
|
|
3848
|
+
});
|
|
3849
|
+
stream.end();
|
|
3850
|
+
}
|
|
3851
|
+
function sitemapPlugin(options = {}) {
|
|
3852
|
+
return {
|
|
3853
|
+
name: "vite-plugin-sitemap",
|
|
3854
|
+
closeBundle() {
|
|
3855
|
+
generateSitemap(options);
|
|
3856
|
+
}
|
|
3857
|
+
};
|
|
3858
|
+
}
|
|
3859
|
+
var src_default = sitemapPlugin;
|
|
3860
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3861
|
+
0 && (module.exports = {
|
|
3862
|
+
generateSitemap
|
|
3863
|
+
});
|
|
3864
|
+
/*!
|
|
3865
|
+
* Sitemap
|
|
3866
|
+
* Copyright(c) 2011 Eugene Kalinin
|
|
3867
|
+
* MIT Licensed
|
|
3868
|
+
*/
|
|
3869
|
+
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
|
3870
|
+
//# sourceMappingURL=index.js.map
|