🆙 Add cms i using 🆙

This commit is contained in:
Remco
2025-11-25 22:42:56 +01:00
parent 94704e0925
commit d44196149e
35591 changed files with 3601123 additions and 0 deletions
@@ -0,0 +1,263 @@
"use strict";
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
/*!
* XRegExp.build 5.1.1
* <xregexp.com>
* Steven Levithan (c) 2012-present MIT License
*/
var _default = function _default(XRegExp) {
var REGEX_DATA = 'xregexp';
var subParts = /(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g;
var parts = XRegExp.union([/\({{([\w$]+)}}\)|{{([\w$]+)}}/, subParts], 'g', {
conjunction: 'or'
});
/**
* Strips a leading `^` and trailing unescaped `$`, if both are present.
*
* @private
* @param {String} pattern Pattern to process.
* @returns {String} Pattern with edge anchors removed.
*/
function deanchor(pattern) {
// Allow any number of empty noncapturing groups before/after anchors, because regexes
// built/generated by XRegExp sometimes include them
var leadingAnchor = /^(?:\(\?:\))*\^/;
var trailingAnchor = /\$(?:\(\?:\))*$/;
if (leadingAnchor.test(pattern) && trailingAnchor.test(pattern) && // Ensure that the trailing `$` isn't escaped
trailingAnchor.test(pattern.replace(/\\[\s\S]/g, ''))) {
return pattern.replace(leadingAnchor, '').replace(trailingAnchor, '');
}
return pattern;
}
/**
* Converts the provided value to an XRegExp. Native RegExp flags are not preserved.
*
* @private
* @param {String|RegExp} value Value to convert.
* @param {Boolean} [addFlagX] Whether to apply the `x` flag in cases when `value` is not
* already a regex generated by XRegExp
* @returns {RegExp} XRegExp object with XRegExp syntax applied.
*/
function asXRegExp(value, addFlagX) {
var flags = addFlagX ? 'x' : '';
return XRegExp.isRegExp(value) ? value[REGEX_DATA] && value[REGEX_DATA].captureNames ? // Don't recompile, to preserve capture names
value : // Recompile as XRegExp
XRegExp(value.source, flags) : // Compile string as XRegExp
XRegExp(value, flags);
}
function interpolate(substitution) {
return substitution instanceof RegExp ? substitution : XRegExp.escape(substitution);
}
function reduceToSubpatternsObject(subpatterns, interpolated, subpatternIndex) {
subpatterns["subpattern".concat(subpatternIndex)] = interpolated;
return subpatterns;
}
function embedSubpatternAfter(raw, subpatternIndex, rawLiterals) {
var hasSubpattern = subpatternIndex < rawLiterals.length - 1;
return raw + (hasSubpattern ? "{{subpattern".concat(subpatternIndex, "}}") : '');
}
/**
* Provides tagged template literals that create regexes with XRegExp syntax and flags. The
* provided pattern is handled as a raw string, so backslashes don't need to be escaped.
*
* Interpolation of strings and regexes shares the features of `XRegExp.build`. Interpolated
* patterns are treated as atomic units when quantified, interpolated strings have their special
* characters escaped, a leading `^` and trailing unescaped `$` are stripped from interpolated
* regexes if both are present, and any backreferences within an interpolated regex are
* rewritten to work within the overall pattern.
*
* @memberOf XRegExp
* @param {String} [flags] Any combination of XRegExp flags.
* @returns {Function} Handler for template literals that construct regexes with XRegExp syntax.
* @example
*
* XRegExp.tag()`\b\w+\b`.test('word'); // -> true
*
* const hours = /1[0-2]|0?[1-9]/;
* const minutes = /(?<minutes>[0-5][0-9])/;
* const time = XRegExp.tag('x')`\b ${hours} : ${minutes} \b`;
* time.test('10:59'); // -> true
* XRegExp.exec('10:59', time).groups.minutes; // -> '59'
*
* const backref1 = /(a)\1/;
* const backref2 = /(b)\1/;
* XRegExp.tag()`${backref1}${backref2}`.test('aabb'); // -> true
*/
XRegExp.tag = function (flags) {
return function (literals) {
var _context, _context2;
for (var _len = arguments.length, substitutions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
substitutions[_key - 1] = arguments[_key];
}
var subpatterns = (0, _reduce["default"])(_context = (0, _map["default"])(substitutions).call(substitutions, interpolate)).call(_context, reduceToSubpatternsObject, {});
var pattern = (0, _map["default"])(_context2 = literals.raw).call(_context2, embedSubpatternAfter).join('');
return XRegExp.build(pattern, subpatterns, flags);
};
};
/**
* Builds regexes using named subpatterns, for readability and pattern reuse. Backreferences in
* the outer pattern and provided subpatterns are automatically renumbered to work correctly.
* Native flags used by provided subpatterns are ignored in favor of the `flags` argument.
*
* @memberOf XRegExp
* @param {String} pattern XRegExp pattern using `{{name}}` for embedded subpatterns. Allows
* `({{name}})` as shorthand for `(?<name>{{name}})`. Patterns cannot be embedded within
* character classes.
* @param {Object} subs Lookup object for named subpatterns. Values can be strings or regexes. A
* leading `^` and trailing unescaped `$` are stripped from subpatterns, if both are present.
* @param {String} [flags] Any combination of XRegExp flags.
* @returns {RegExp} Regex with interpolated subpatterns.
* @example
*
* const time = XRegExp.build('(?x)^ {{hours}} ({{minutes}}) $', {
* hours: XRegExp.build('{{h12}} : | {{h24}}', {
* h12: /1[0-2]|0?[1-9]/,
* h24: /2[0-3]|[01][0-9]/
* }, 'x'),
* minutes: /^[0-5][0-9]$/
* });
* time.test('10:59'); // -> true
* XRegExp.exec('10:59', time).groups.minutes; // -> '59'
*/
XRegExp.build = function (pattern, subs, flags) {
flags = flags || ''; // Used with `asXRegExp` calls for `pattern` and subpatterns in `subs`, to work around how
// some browsers convert `RegExp('\n')` to a regex that contains the literal characters `\`
// and `n`. See more details at <https://github.com/slevithan/xregexp/pull/163>.
var addFlagX = (0, _indexOf["default"])(flags).call(flags, 'x') !== -1;
var inlineFlags = /^\(\?([\w$]+)\)/.exec(pattern); // Add flags within a leading mode modifier to the overall pattern's flags
if (inlineFlags) {
flags = XRegExp._clipDuplicates(flags + inlineFlags[1]);
}
var data = {};
for (var p in subs) {
if (subs.hasOwnProperty(p)) {
// Passing to XRegExp enables extended syntax and ensures independent validity,
// lest an unescaped `(`, `)`, `[`, or trailing `\` breaks the `(?:)` wrapper. For
// subpatterns provided as native regexes, it dies on octals and adds the property
// used to hold extended regex instance data, for simplicity.
var sub = asXRegExp(subs[p], addFlagX);
data[p] = {
// Deanchoring allows embedding independently useful anchored regexes. If you
// really need to keep your anchors, double them (i.e., `^^...$$`).
pattern: deanchor(sub.source),
names: sub[REGEX_DATA].captureNames || []
};
}
} // Passing to XRegExp dies on octals and ensures the outer pattern is independently valid;
// helps keep this simple. Named captures will be put back.
var patternAsRegex = asXRegExp(pattern, addFlagX); // 'Caps' is short for 'captures'
var numCaps = 0;
var numPriorCaps;
var numOuterCaps = 0;
var outerCapsMap = [0];
var outerCapNames = patternAsRegex[REGEX_DATA].captureNames || [];
var output = patternAsRegex.source.replace(parts, function ($0, $1, $2, $3, $4) {
var subName = $1 || $2;
var capName;
var intro;
var localCapIndex; // Named subpattern
if (subName) {
var _context3;
if (!data.hasOwnProperty(subName)) {
throw new ReferenceError("Undefined property ".concat($0));
} // Named subpattern was wrapped in a capturing group
if ($1) {
capName = outerCapNames[numOuterCaps];
outerCapsMap[++numOuterCaps] = ++numCaps; // If it's a named group, preserve the name. Otherwise, use the subpattern name
// as the capture name
intro = "(?<".concat(capName || subName, ">");
} else {
intro = '(?:';
}
numPriorCaps = numCaps;
var rewrittenSubpattern = data[subName].pattern.replace(subParts, function (match, paren, backref) {
// Capturing group
if (paren) {
capName = data[subName].names[numCaps - numPriorCaps];
++numCaps; // If the current capture has a name, preserve the name
if (capName) {
return "(?<".concat(capName, ">");
} // Backreference
} else if (backref) {
localCapIndex = +backref - 1; // Rewrite the backreference
return data[subName].names[localCapIndex] ? // Need to preserve the backreference name in case using flag `n`
"\\k<".concat(data[subName].names[localCapIndex], ">") : "\\".concat(+backref + numPriorCaps);
}
return match;
});
return (0, _concat["default"])(_context3 = "".concat(intro)).call(_context3, rewrittenSubpattern, ")");
} // Capturing group
if ($3) {
capName = outerCapNames[numOuterCaps];
outerCapsMap[++numOuterCaps] = ++numCaps; // If the current capture has a name, preserve the name
if (capName) {
return "(?<".concat(capName, ">");
} // Backreference
} else if ($4) {
localCapIndex = +$4 - 1; // Rewrite the backreference
return outerCapNames[localCapIndex] ? // Need to preserve the backreference name in case using flag `n`
"\\k<".concat(outerCapNames[localCapIndex], ">") : "\\".concat(outerCapsMap[+$4]);
}
return $0;
});
return XRegExp(output, flags);
};
};
exports["default"] = _default;
module.exports = exports.default;
@@ -0,0 +1,281 @@
"use strict";
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
/*!
* XRegExp.matchRecursive 5.1.1
* <xregexp.com>
* Steven Levithan (c) 2009-present MIT License
*/
var _default = function _default(XRegExp) {
/**
* Returns a match detail object composed of the provided values.
*
* @private
*/
function row(name, value, start, end) {
return {
name: name,
value: value,
start: start,
end: end
};
}
/**
* Returns an array of match strings between outermost left and right delimiters, or an array of
* objects with detailed match parts and position data. By default, an error is thrown if
* delimiters are unbalanced within the subject string.
*
* @memberOf XRegExp
* @param {String} str String to search.
* @param {String} left Left delimiter as an XRegExp pattern.
* @param {String} right Right delimiter as an XRegExp pattern.
* @param {String} [flags] Any combination of XRegExp flags, used for the left and right delimiters.
* @param {Object} [options] Options object with optional properties:
* - `valueNames` {Array} Providing `valueNames` changes the return value from an array of
* matched strings to an array of objects that provide the value and start/end positions
* for the matched strings as well as the matched delimiters and unmatched string segments.
* To use this extended information mode, provide an array of 4 strings that name the parts
* to be returned:
* 1. String segments outside of (before, between, and after) matches.
* 2. Matched outermost left delimiters.
* 3. Matched text between the outermost left and right delimiters.
* 4. Matched outermost right delimiters.
* Taken together, these parts include the entire subject string if used with flag g.
* Use `null` for any of these values to omit unneeded parts from the returned results.
* - `escapeChar` {String} Single char used to escape delimiters within the subject string.
* - `unbalanced` {String} Handling mode for unbalanced delimiters. Options are:
* - 'error' - throw (default)
* - 'skip' - unbalanced delimiters are treated as part of the text between delimiters, and
* searches continue at the end of the unbalanced delimiter.
* - 'skip-lazy' - unbalanced delimiters are treated as part of the text between delimiters,
* and searches continue one character after the start of the unbalanced delimiter.
* @returns {Array} Array of matches, or an empty array.
* @example
*
* // Basic usage
* const str1 = '(t((e))s)t()(ing)';
* XRegExp.matchRecursive(str1, '\\(', '\\)', 'g');
* // -> ['t((e))s', '', 'ing']
*
* // Extended information mode with valueNames
* const str2 = 'Here is <div> <div>an</div></div> example';
* XRegExp.matchRecursive(str2, '<div\\s*>', '</div>', 'gi', {
* valueNames: ['between', 'left', 'match', 'right']
* });
* // -> [
* // {name: 'between', value: 'Here is ', start: 0, end: 8},
* // {name: 'left', value: '<div>', start: 8, end: 13},
* // {name: 'match', value: ' <div>an</div>', start: 13, end: 27},
* // {name: 'right', value: '</div>', start: 27, end: 33},
* // {name: 'between', value: ' example', start: 33, end: 41}
* // ]
*
* // Omitting unneeded parts with null valueNames, and using escapeChar
* const str3 = '...{1}.\\{{function(x,y){return {y:x}}}';
* XRegExp.matchRecursive(str3, '{', '}', 'g', {
* valueNames: ['literal', null, 'value', null],
* escapeChar: '\\'
* });
* // -> [
* // {name: 'literal', value: '...', start: 0, end: 3},
* // {name: 'value', value: '1', start: 4, end: 5},
* // {name: 'literal', value: '.\\{', start: 6, end: 9},
* // {name: 'value', value: 'function(x,y){return {y:x}}', start: 10, end: 37}
* // ]
*
* // Sticky mode via flag y
* const str4 = '<1><<<2>>><3>4<5>';
* XRegExp.matchRecursive(str4, '<', '>', 'gy');
* // -> ['1', '<<2>>', '3']
*
* // Skipping unbalanced delimiters instead of erroring
* const str5 = 'Here is <div> <div>an</div> unbalanced example';
* XRegExp.matchRecursive(str5, '<div\\s*>', '</div>', 'gi', {
* unbalanced: 'skip'
* });
* // -> ['an']
*/
XRegExp.matchRecursive = function (str, left, right, flags, options) {
flags = flags || '';
options = options || {};
var global = (0, _indexOf["default"])(flags).call(flags, 'g') !== -1;
var sticky = (0, _indexOf["default"])(flags).call(flags, 'y') !== -1; // Flag `y` is handled manually
var basicFlags = flags.replace(/y/g, '');
left = XRegExp(left, basicFlags);
right = XRegExp(right, basicFlags);
var esc;
var _options = options,
escapeChar = _options.escapeChar;
if (escapeChar) {
var _context, _context2;
if (escapeChar.length > 1) {
throw new Error('Cannot use more than one escape character');
}
escapeChar = XRegExp.escape(escapeChar); // Example of concatenated `esc` regex:
// `escapeChar`: '%'
// `left`: '<'
// `right`: '>'
// Regex is: /(?:%[\S\s]|(?:(?!<|>)[^%])+)+/
esc = new RegExp((0, _concat["default"])(_context = (0, _concat["default"])(_context2 = "(?:".concat(escapeChar, "[\\S\\s]|(?:(?!")).call(_context2, // Using `XRegExp.union` safely rewrites backreferences in `left` and `right`.
// Intentionally not passing `basicFlags` to `XRegExp.union` since any syntax
// transformation resulting from those flags was already applied to `left` and
// `right` when they were passed through the XRegExp constructor above.
XRegExp.union([left, right], '', {
conjunction: 'or'
}).source, ")[^")).call(_context, escapeChar, "])+)+"), // Flags `dgy` not needed here
flags.replace(XRegExp._hasNativeFlag('s') ? /[^imsu]/g : /[^imu]/g, ''));
}
var openTokens = 0;
var delimStart = 0;
var delimEnd = 0;
var lastOuterEnd = 0;
var outerStart;
var innerStart;
var leftMatch;
var rightMatch;
var vN = options.valueNames;
var output = [];
while (true) {
// If using an escape character, advance to the delimiter's next starting position,
// skipping any escaped characters in between
if (escapeChar) {
delimEnd += (XRegExp.exec(str, esc, delimEnd, 'sticky') || [''])[0].length;
}
leftMatch = XRegExp.exec(str, left, delimEnd);
rightMatch = XRegExp.exec(str, right, delimEnd); // Keep the leftmost match only
if (leftMatch && rightMatch) {
if (leftMatch.index <= rightMatch.index) {
rightMatch = null;
} else {
leftMatch = null;
}
} // Paths (LM: leftMatch, RM: rightMatch, OT: openTokens):
// LM | RM | OT | Result
// 1 | 0 | 1 | loop
// 1 | 0 | 0 | loop
// 0 | 1 | 1 | loop
// 0 | 1 | 0 | throw
// 0 | 0 | 1 | throw
// 0 | 0 | 0 | break
// The paths above don't include the sticky mode special case. The loop ends after the
// first completed match if not `global`.
if (leftMatch || rightMatch) {
delimStart = (leftMatch || rightMatch).index;
delimEnd = delimStart + (leftMatch || rightMatch)[0].length;
} else if (!openTokens) {
break;
}
if (sticky && !openTokens && delimStart > lastOuterEnd) {
break;
}
if (leftMatch) {
if (!openTokens) {
outerStart = delimStart;
innerStart = delimEnd;
}
openTokens += 1;
} else if (rightMatch && openTokens) {
openTokens -= 1;
if (!openTokens) {
if (vN) {
if (vN[0] && outerStart > lastOuterEnd) {
output.push(row(vN[0], (0, _slice["default"])(str).call(str, lastOuterEnd, outerStart), lastOuterEnd, outerStart));
}
if (vN[1]) {
output.push(row(vN[1], (0, _slice["default"])(str).call(str, outerStart, innerStart), outerStart, innerStart));
}
if (vN[2]) {
output.push(row(vN[2], (0, _slice["default"])(str).call(str, innerStart, delimStart), innerStart, delimStart));
}
if (vN[3]) {
output.push(row(vN[3], (0, _slice["default"])(str).call(str, delimStart, delimEnd), delimStart, delimEnd));
}
} else {
output.push((0, _slice["default"])(str).call(str, innerStart, delimStart));
}
lastOuterEnd = delimEnd;
if (!global) {
break;
}
} // Found unbalanced delimiter
} else {
var unbalanced = options.unbalanced || 'error';
if (unbalanced === 'skip' || unbalanced === 'skip-lazy') {
if (rightMatch) {
rightMatch = null; // No `leftMatch` for unbalanced left delimiter because we've reached the string end
} else {
if (unbalanced === 'skip') {
var outerStartDelimLength = XRegExp.exec(str, left, outerStart, 'sticky')[0].length;
delimEnd = outerStart + (outerStartDelimLength || 1);
} else {
delimEnd = outerStart + 1;
}
openTokens = 0;
}
} else if (unbalanced === 'error') {
var _context3;
var delimSide = rightMatch ? 'right' : 'left';
var errorPos = rightMatch ? delimStart : outerStart;
throw new Error((0, _concat["default"])(_context3 = "Unbalanced ".concat(delimSide, " delimiter found in string at position ")).call(_context3, errorPos));
} else {
throw new Error("Unsupported value for unbalanced: ".concat(unbalanced));
}
} // If the delimiter matched an empty string, avoid an infinite loop
if (delimStart === delimEnd) {
delimEnd += 1;
}
}
if (global && output.length > 0 && !sticky && vN && vN[0] && str.length > lastOuterEnd) {
output.push(row(vN[0], (0, _slice["default"])(str).call(str, lastOuterEnd), lastOuterEnd, str.length));
}
return output;
};
};
exports["default"] = _default;
module.exports = exports.default;
@@ -0,0 +1,334 @@
"use strict";
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
var _Array$isArray = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { var _context4; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context4 = Object.prototype.toString.call(o)).call(_context4, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/*!
* XRegExp Unicode Base 5.1.1
* <xregexp.com>
* Steven Levithan (c) 2008-present MIT License
*/
var _default = function _default(XRegExp) {
/**
* Adds base support for Unicode matching:
* - Adds syntax `\p{..}` for matching Unicode tokens. Tokens can be inverted using `\P{..}` or
* `\p{^..}`. Token names ignore case, spaces, hyphens, and underscores. You can omit the
* braces for token names that are a single letter (e.g. `\pL` or `PL`).
* - Adds flag A (astral), which enables 21-bit Unicode support.
* - Adds the `XRegExp.addUnicodeData` method used by other addons to provide character data.
*
* Unicode Base relies on externally provided Unicode character data. Official addons are
* available to provide data for Unicode categories, scripts, and properties.
*
* @requires XRegExp
*/
// ==--------------------------==
// Private stuff
// ==--------------------------==
// Storage for Unicode data
var unicode = {};
var unicodeTypes = {}; // Reuse utils
var dec = XRegExp._dec;
var hex = XRegExp._hex;
var pad4 = XRegExp._pad4; // Generates a token lookup name: lowercase, with hyphens, spaces, and underscores removed
function normalize(name) {
return name.replace(/[- _]+/g, '').toLowerCase();
} // Gets the decimal code of a literal code unit, \xHH, \uHHHH, or a backslash-escaped literal
function charCode(chr) {
var esc = /^\\[xu](.+)/.exec(chr);
return esc ? dec(esc[1]) : chr.charCodeAt(chr[0] === '\\' ? 1 : 0);
} // Inverts a list of ordered BMP characters and ranges
function invertBmp(range) {
var output = '';
var lastEnd = -1;
(0, _forEach["default"])(XRegExp).call(XRegExp, range, /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/, function (m) {
var start = charCode(m[1]);
if (start > lastEnd + 1) {
output += "\\u".concat(pad4(hex(lastEnd + 1)));
if (start > lastEnd + 2) {
output += "-\\u".concat(pad4(hex(start - 1)));
}
}
lastEnd = charCode(m[2] || m[1]);
});
if (lastEnd < 0xFFFF) {
output += "\\u".concat(pad4(hex(lastEnd + 1)));
if (lastEnd < 0xFFFE) {
output += '-\\uFFFF';
}
}
return output;
} // Generates an inverted BMP range on first use
function cacheInvertedBmp(slug) {
var prop = 'b!';
return unicode[slug][prop] || (unicode[slug][prop] = invertBmp(unicode[slug].bmp));
} // Combines and optionally negates BMP and astral data
function buildAstral(slug, isNegated) {
var item = unicode[slug];
var combined = '';
if (item.bmp && !item.isBmpLast) {
var _context;
combined = (0, _concat["default"])(_context = "[".concat(item.bmp, "]")).call(_context, item.astral ? '|' : '');
}
if (item.astral) {
combined += item.astral;
}
if (item.isBmpLast && item.bmp) {
var _context2;
combined += (0, _concat["default"])(_context2 = "".concat(item.astral ? '|' : '', "[")).call(_context2, item.bmp, "]");
} // Astral Unicode tokens always match a code point, never a code unit
return isNegated ? "(?:(?!".concat(combined, ")(?:[\uD800-\uDBFF][\uDC00-\uDFFF]|[\0-\uFFFF]))") : "(?:".concat(combined, ")");
} // Builds a complete astral pattern on first use
function cacheAstral(slug, isNegated) {
var prop = isNegated ? 'a!' : 'a=';
return unicode[slug][prop] || (unicode[slug][prop] = buildAstral(slug, isNegated));
} // ==--------------------------==
// Core functionality
// ==--------------------------==
/*
* Add astral mode (flag A) and Unicode token syntax: `\p{..}`, `\P{..}`, `\p{^..}`, `\pC`.
*/
XRegExp.addToken( // Use `*` instead of `+` to avoid capturing `^` as the token name in `\p{^}`
/\\([pP])(?:{(\^?)(?:(\w+)=)?([^}]*)}|([A-Za-z]))/, function (match, scope, flags) {
var ERR_DOUBLE_NEG = 'Invalid double negation ';
var ERR_UNKNOWN_NAME = 'Unknown Unicode token ';
var ERR_UNKNOWN_REF = 'Unicode token missing data ';
var ERR_ASTRAL_ONLY = 'Astral mode required for Unicode token ';
var ERR_ASTRAL_IN_CLASS = 'Astral mode does not support Unicode tokens within character classes';
var _match = (0, _slicedToArray2["default"])(match, 6),
fullToken = _match[0],
pPrefix = _match[1],
caretNegation = _match[2],
typePrefix = _match[3],
tokenName = _match[4],
tokenSingleCharName = _match[5]; // Negated via \P{..} or \p{^..}
var isNegated = pPrefix === 'P' || !!caretNegation; // Switch from BMP (0-FFFF) to astral (0-10FFFF) mode via flag A
var isAstralMode = (0, _indexOf["default"])(flags).call(flags, 'A') !== -1; // Token lookup name. Check `tokenSingleCharName` first to avoid passing `undefined`
// via `\p{}`
var slug = normalize(tokenSingleCharName || tokenName); // Token data object
var item = unicode[slug];
if (pPrefix === 'P' && caretNegation) {
throw new SyntaxError(ERR_DOUBLE_NEG + fullToken);
}
if (!unicode.hasOwnProperty(slug)) {
throw new SyntaxError(ERR_UNKNOWN_NAME + fullToken);
}
if (typePrefix) {
if (!(unicodeTypes[typePrefix] && unicodeTypes[typePrefix][slug])) {
throw new SyntaxError(ERR_UNKNOWN_NAME + fullToken);
}
} // Switch to the negated form of the referenced Unicode token
if (item.inverseOf) {
slug = normalize(item.inverseOf);
if (!unicode.hasOwnProperty(slug)) {
var _context3;
throw new ReferenceError((0, _concat["default"])(_context3 = "".concat(ERR_UNKNOWN_REF + fullToken, " -> ")).call(_context3, item.inverseOf));
}
item = unicode[slug];
isNegated = !isNegated;
}
if (!(item.bmp || isAstralMode)) {
throw new SyntaxError(ERR_ASTRAL_ONLY + fullToken);
}
if (isAstralMode) {
if (scope === 'class') {
throw new SyntaxError(ERR_ASTRAL_IN_CLASS);
}
return cacheAstral(slug, isNegated);
}
return scope === 'class' ? isNegated ? cacheInvertedBmp(slug) : item.bmp : "".concat((isNegated ? '[^' : '[') + item.bmp, "]");
}, {
scope: 'all',
optionalFlags: 'A',
leadChar: '\\'
});
/**
* Adds to the list of Unicode tokens that XRegExp regexes can match via `\p` or `\P`.
*
* @memberOf XRegExp
* @param {Array} data Objects with named character ranges. Each object may have properties
* `name`, `alias`, `isBmpLast`, `inverseOf`, `bmp`, and `astral`. All but `name` are
* optional, although one of `bmp` or `astral` is required (unless `inverseOf` is set). If
* `astral` is absent, the `bmp` data is used for BMP and astral modes. If `bmp` is absent,
* the name errors in BMP mode but works in astral mode. If both `bmp` and `astral` are
* provided, the `bmp` data only is used in BMP mode, and the combination of `bmp` and
* `astral` data is used in astral mode. `isBmpLast` is needed when a token matches orphan
* high surrogates *and* uses surrogate pairs to match astral code points. The `bmp` and
* `astral` data should be a combination of literal characters and `\xHH` or `\uHHHH` escape
* sequences, with hyphens to create ranges. Any regex metacharacters in the data should be
* escaped, apart from range-creating hyphens. The `astral` data can additionally use
* character classes and alternation, and should use surrogate pairs to represent astral code
* points. `inverseOf` can be used to avoid duplicating character data if a Unicode token is
* defined as the exact inverse of another token.
* @param {String} [typePrefix] Enables optionally using this type as a prefix for all of the
* provided Unicode tokens, e.g. if given `'Type'`, then `\p{TokenName}` can also be written
* as `\p{Type=TokenName}`.
* @example
*
* // Basic use
* XRegExp.addUnicodeData([{
* name: 'XDigit',
* alias: 'Hexadecimal',
* bmp: '0-9A-Fa-f'
* }]);
* XRegExp('\\p{XDigit}:\\p{Hexadecimal}+').test('0:3D'); // -> true
*/
XRegExp.addUnicodeData = function (data, typePrefix) {
var ERR_NO_NAME = 'Unicode token requires name';
var ERR_NO_DATA = 'Unicode token has no character data ';
if (typePrefix) {
// Case sensitive to match ES2018
unicodeTypes[typePrefix] = {};
}
var _iterator = _createForOfIteratorHelper(data),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
if (!item.name) {
throw new Error(ERR_NO_NAME);
}
if (!(item.inverseOf || item.bmp || item.astral)) {
throw new Error(ERR_NO_DATA + item.name);
}
var normalizedName = normalize(item.name);
unicode[normalizedName] = item;
if (typePrefix) {
unicodeTypes[typePrefix][normalizedName] = true;
}
if (item.alias) {
var normalizedAlias = normalize(item.alias);
unicode[normalizedAlias] = item;
if (typePrefix) {
unicodeTypes[typePrefix][normalizedAlias] = true;
}
}
} // Reset the pattern cache used by the `XRegExp` constructor, since the same pattern and
// flags might now produce different results
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
XRegExp.cache.flush('patterns');
};
/**
* @ignore
*
* Return a reference to the internal Unicode definition structure for the given Unicode
* Property if the given name is a legal Unicode Property for use in XRegExp `\p` or `\P` regex
* constructs.
*
* @memberOf XRegExp
* @param {String} name Name by which the Unicode Property may be recognized (case-insensitive),
* e.g. `'N'` or `'Number'`. The given name is matched against all registered Unicode
* Properties and Property Aliases.
* @returns {Object} Reference to definition structure when the name matches a Unicode Property.
*
* @note
* For more info on Unicode Properties, see also http://unicode.org/reports/tr18/#Categories.
*
* @note
* This method is *not* part of the officially documented API and may change or be removed in
* the future. It is meant for userland code that wishes to reuse the (large) internal Unicode
* structures set up by XRegExp.
*/
XRegExp._getUnicodeProperty = function (name) {
var slug = normalize(name);
return unicode[slug];
};
};
exports["default"] = _default;
module.exports = exports.default;
@@ -0,0 +1,39 @@
"use strict";
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _categories = _interopRequireDefault(require("../../tools/output/categories"));
/*!
* XRegExp Unicode Categories 5.1.1
* <xregexp.com>
* Steven Levithan (c) 2010-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
var _default = function _default(XRegExp) {
/**
* Adds support for Unicode's general categories. E.g., `\p{Lu}` or `\p{Uppercase Letter}`. See
* category descriptions in UAX #44 <http://unicode.org/reports/tr44/#GC_Values_Table>. Token
* names are case insensitive, and any spaces, hyphens, and underscores are ignored.
*
* Uses Unicode 14.0.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Categories');
}
XRegExp.addUnicodeData(_categories["default"]);
};
exports["default"] = _default;
module.exports = exports.default;
@@ -0,0 +1,76 @@
"use strict";
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _properties = _interopRequireDefault(require("../../tools/output/properties"));
/*!
* XRegExp Unicode Properties 5.1.1
* <xregexp.com>
* Steven Levithan (c) 2012-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
var _default = function _default(XRegExp) {
/**
* Adds properties to meet the UTS #18 Level 1 RL1.2 requirements for Unicode regex support. See
* <http://unicode.org/reports/tr18/#RL1.2>. Following are definitions of these properties from
* UAX #44 <http://unicode.org/reports/tr44/>:
*
* - Alphabetic
* Characters with the Alphabetic property. Generated from: Lowercase + Uppercase + Lt + Lm +
* Lo + Nl + Other_Alphabetic.
*
* - Default_Ignorable_Code_Point
* For programmatic determination of default ignorable code points. New characters that should
* be ignored in rendering (unless explicitly supported) will be assigned in these ranges,
* permitting programs to correctly handle the default rendering of such characters when not
* otherwise supported.
*
* - Lowercase
* Characters with the Lowercase property. Generated from: Ll + Other_Lowercase.
*
* - Noncharacter_Code_Point
* Code points permanently reserved for internal use.
*
* - Uppercase
* Characters with the Uppercase property. Generated from: Lu + Other_Uppercase.
*
* - White_Space
* Spaces, separator characters and other control characters which should be treated by
* programming languages as "white space" for the purpose of parsing elements.
*
* The properties ASCII, Any, and Assigned are also included but are not defined in UAX #44. UTS
* #18 RL1.2 additionally requires support for Unicode scripts and general categories. These are
* included in XRegExp's Unicode Categories and Unicode Scripts addons.
*
* Token names are case insensitive, and any spaces, hyphens, and underscores are ignored.
*
* Uses Unicode 14.0.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Properties');
}
var unicodeData = _properties["default"]; // Add non-generated data
unicodeData.push({
name: 'Assigned',
// Since this is defined as the inverse of Unicode category Cn (Unassigned), the Unicode
// Categories addon is required to use this property
inverseOf: 'Cn'
});
XRegExp.addUnicodeData(unicodeData);
};
exports["default"] = _default;
module.exports = exports.default;
@@ -0,0 +1,38 @@
"use strict";
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _scripts = _interopRequireDefault(require("../../tools/output/scripts"));
/*!
* XRegExp Unicode Scripts 5.1.1
* <xregexp.com>
* Steven Levithan (c) 2010-present MIT License
* Unicode data by Mathias Bynens <mathiasbynens.be>
*/
var _default = function _default(XRegExp) {
/**
* Adds support for all Unicode scripts. E.g., `\p{Latin}`. Token names are case insensitive,
* and any spaces, hyphens, and underscores are ignored.
*
* Uses Unicode 14.0.0.
*
* @requires XRegExp, Unicode Base
*/
if (!XRegExp.addUnicodeData) {
throw new ReferenceError('Unicode Base must be loaded before Unicode Scripts');
}
XRegExp.addUnicodeData(_scripts["default"], 'Script');
};
exports["default"] = _default;
module.exports = exports.default;
+35
View File
@@ -0,0 +1,35 @@
"use strict";
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _xregexp = _interopRequireDefault(require("./xregexp"));
var _build = _interopRequireDefault(require("./addons/build"));
var _matchrecursive = _interopRequireDefault(require("./addons/matchrecursive"));
var _unicodeBase = _interopRequireDefault(require("./addons/unicode-base"));
var _unicodeCategories = _interopRequireDefault(require("./addons/unicode-categories"));
var _unicodeProperties = _interopRequireDefault(require("./addons/unicode-properties"));
var _unicodeScripts = _interopRequireDefault(require("./addons/unicode-scripts"));
(0, _build["default"])(_xregexp["default"]);
(0, _matchrecursive["default"])(_xregexp["default"]);
(0, _unicodeBase["default"])(_xregexp["default"]);
(0, _unicodeCategories["default"])(_xregexp["default"]);
(0, _unicodeProperties["default"])(_xregexp["default"]);
(0, _unicodeScripts["default"])(_xregexp["default"]);
var _default = _xregexp["default"];
exports["default"] = _default;
module.exports = exports.default;
File diff suppressed because one or more lines are too long