Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 89 additions & 24 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13003,6 +13003,61 @@ const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
module.exports = sort


/***/ }),

/***/ 6114:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {



const parse = __nccwpck_require__(6353)
const constants = __nccwpck_require__(5101)
const SemVer = __nccwpck_require__(7163)

const truncate = (version, truncation, options) => {
if (!constants.RELEASE_TYPES.includes(truncation)) {
return null
}

const clonedVersion = cloneInputVersion(version, options)
return clonedVersion && doTruncation(clonedVersion, truncation)
}

const cloneInputVersion = (version, options) => {
const versionStringToParse = (
version instanceof SemVer ? version.version : version
)

return parse(versionStringToParse, options)
}

const doTruncation = (version, truncation) => {
if (isPrerelease(truncation)) {
return version.version
}

version.prerelease = []

switch (truncation) {
case 'major':
version.minor = 0
version.patch = 0
break
case 'minor':
version.patch = 0
break
}

return version.format()
}

const isPrerelease = (type) => {
return type.startsWith('pre')
}

module.exports = truncate


/***/ }),

/***/ 8780:
Expand Down Expand Up @@ -13053,6 +13108,7 @@ const gte = __nccwpck_require__(1236)
const lte = __nccwpck_require__(6717)
const cmp = __nccwpck_require__(8646)
const coerce = __nccwpck_require__(5385)
const truncate = __nccwpck_require__(6114)
const Comparator = __nccwpck_require__(9379)
const Range = __nccwpck_require__(6782)
const satisfies = __nccwpck_require__(8011)
Expand Down Expand Up @@ -13091,6 +13147,7 @@ module.exports = {
lte,
cmp,
coerce,
truncate,
Comparator,
Range,
satisfies,
Expand Down Expand Up @@ -13430,7 +13487,7 @@ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
createToken('GTLT', '((?:<|>)?=?)')

// Something like "2.*" or "1.2.x".
// Note that "x.x" is a valid xRange identifer, meaning "any version"
// Note that "x.x" is a valid xRange identifier, meaning "any version"
// Only the first item is strictly required.
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
Expand Down Expand Up @@ -66967,11 +67024,15 @@ class XmlNode {


class DocTypeReader {
constructor(options) {
constructor(options, xmlVersion) {
this.suppressValidationErr = !options;
this.options = options;
this.xmlVersion = xmlVersion || 1.0;
}

setXmlVersion(xmlVersion = 1.0) {
this.xmlVersion = xmlVersion;
}
readDocType(xmlData, i) {
const entities = Object.create(null);
let entityCount = 0;
Expand Down Expand Up @@ -67069,7 +67130,7 @@ class DocTypeReader {
}
let entityName = xmlData.substring(startIndex, i);

validateEntityName(entityName);
validateEntityName(entityName, { xmlVersion: this.xmlVersion });

// Skip whitespace after entity name
i = skipWhitespace(xmlData, i);
Expand Down Expand Up @@ -67112,7 +67173,7 @@ class DocTypeReader {
}
let notationName = xmlData.substring(startIndex, i);

!this.suppressValidationErr && validateEntityName(notationName);
!this.suppressValidationErr && validateEntityName(notationName, { xmlVersion: this.xmlVersion });

// Skip whitespace after notation name
i = skipWhitespace(xmlData, i);
Expand Down Expand Up @@ -67192,7 +67253,7 @@ class DocTypeReader {
let elementName = xmlData.substring(startIndex, i);

// Validate element name
if (!this.suppressValidationErr && !isName(elementName)) {
if (!this.suppressValidationErr && !qName(elementName, { xmlVersion: this.xmlVersion })) {
throw new Error(`Invalid element name: "${elementName}"`);
}

Expand Down Expand Up @@ -67239,7 +67300,7 @@ class DocTypeReader {
let elementName = xmlData.substring(startIndex, i);

// Validate element name
validateEntityName(elementName)
validateEntityName(elementName, { xmlVersion: this.xmlVersion })

// Skip whitespace after element name
i = skipWhitespace(xmlData, i);
Expand All @@ -67252,7 +67313,7 @@ class DocTypeReader {
let attributeName = xmlData.substring(startIndex, i);

// Validate attribute name
if (!validateEntityName(attributeName)) {
if (!validateEntityName(attributeName, { xmlVersion: this.xmlVersion })) {
throw new Error(`Invalid attribute name: "${attributeName}"`);
}

Expand Down Expand Up @@ -67287,7 +67348,7 @@ class DocTypeReader {

// Validate notation name
notation = notation.trim();
if (!validateEntityName(notation)) {
if (!validateEntityName(notation, { xmlVersion: this.xmlVersion })) {
throw new Error(`Invalid notation name: "${notation}"`);
}

Expand Down Expand Up @@ -67365,22 +67426,22 @@ function hasSeq(data, seq, i) {
return true;
}

function validateEntityName(name) {
if (isName(name))
function validateEntityName(name, xmlVersion) {
if (qName(name, { xmlVersion: xmlVersion }))
return name;
else
throw new Error(`Invalid entity name ${name}`);
}
;// CONCATENATED MODULE: ./node_modules/strnum/strnum.js
const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
const binRegex = /^0b[01]+$/;
const octRegex = /^0o[0-7]+$/;
const numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
// const octRegex = /^0x[a-z0-9]+/;
// const binRegex = /0x[a-z0-9]+/;


const consider = {
hex: true,
// oct: false,
binary: false,
octal: false,
leadingZeros: true,
decimalPoint: "\.",
eNotation: true,
Expand All @@ -67399,14 +67460,14 @@ function toNumber(str, options = {}) {
else if (trimmedStr === "0") return 0;
else if (options.hex && hexRegex.test(trimmedStr)) {
return parse_int(trimmedStr, 16);
// }else if (options.oct && octRegex.test(str)) {
// return Number.parseInt(val, 8);
} else if (options.binary && binRegex.test(trimmedStr)) {
return parse_int(trimmedStr, 2);
} else if (options.octal && octRegex.test(trimmedStr)) {
return parse_int(trimmedStr, 8);
} else if (!isFinite(trimmedStr)) { //Infinity
return handleInfinity(str, Number(trimmedStr), options);
} else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
return resolveEnotation(str, trimmedStr, options);
// }else if (options.parseBin && binRegex.test(str)) {
// return Number.parseInt(val, 2);
} else {
//separate negative sign, leading zeros, and rest number
const match = numRegex.exec(trimmedStr);
Expand Down Expand Up @@ -67504,11 +67565,13 @@ function trimZeros(numStr) {
}

function parse_int(numStr, base) {
//polyfill
const str = numStr.trim();
if (base === 2 || base === 8) numStr = str.substring(2);

if (parseInt) return parseInt(numStr, base);
else if (Number.parseInt) return Number.parseInt(numStr, base);
else if (window && window.parseInt) return window.parseInt(numStr, base);
else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")
else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
}

/**
Expand Down Expand Up @@ -69593,9 +69656,6 @@ class OrderedObjParser {

// Initialize path matcher for path-expression-matcher
this.matcher = new Matcher();

// Live read-only proxy of matcher — PEM creates and caches this internally.
// All user callbacks receive this instead of the mutable matcher.
this.readonlyMatcher = this.matcher.readOnly();

// Flag to track if current node is a stop node (optimization)
Expand Down Expand Up @@ -69831,6 +69891,7 @@ const parseXml = function (xmlData) {
if (attsMap) {
const ver = attsMap[this.options.attributeNamePrefix + "version"];
this.entityDecoder.setXmlVersion(Number(ver) || 1.0);
docTypeReader.setXmlVersion(Number(ver) || 1.0);
}
if ((options.ignoreDeclaration && tagData.tagName === "?xml") || options.ignorePiTags) {
//do nothing
Expand Down Expand Up @@ -70264,7 +70325,7 @@ function readStopNodeData(xmlData, tagName, i) {
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
i = closeIndex;
} else {
const tagData = readTagExp(xmlData, i, '>')
const tagData = readTagExp(xmlData, i, false)

if (tagData) {
const openTagName = tagData && tagData.tagName;
Expand Down Expand Up @@ -70400,6 +70461,10 @@ function compress(arr, options, matcher, readonlyMatcher) {
let val = compress(tagObj[property], options, matcher, readonlyMatcher);
const isLeaf = isLeafTag(val, options);

if (Object.keys(val).length === 0 && options.alwaysCreateTextNode) {
val[options.textNodeName] = "";
}

if (tagObj[":@"]) {
assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode) {
Expand Down
10 changes: 5 additions & 5 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading