@next-core/brick-utils 2.37.13 → 2.37.16
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/CHANGELOG.md +18 -71
- package/dist/index.bundle.js +40 -33
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +36 -29
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -2,8 +2,8 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
|
2
2
|
import { uniq, get, cloneDeep, set, isEmpty, escapeRegExp } from 'lodash';
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
5
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
6
5
|
import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
|
|
6
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
7
7
|
import { processPipes, utils } from '@next-core/pipes';
|
|
8
8
|
export { pipes } from '@next-core/pipes';
|
|
9
9
|
import yaml from 'js-yaml';
|
|
@@ -21022,7 +21022,7 @@ function lexer(str) {
|
|
|
21022
21022
|
break;
|
|
21023
21023
|
}
|
|
21024
21024
|
|
|
21025
|
-
if (!name) throw new TypeError("Missing parameter name at "
|
|
21025
|
+
if (!name) throw new TypeError("Missing parameter name at ".concat(i));
|
|
21026
21026
|
tokens.push({
|
|
21027
21027
|
type: "NAME",
|
|
21028
21028
|
index: i,
|
|
@@ -21038,7 +21038,7 @@ function lexer(str) {
|
|
|
21038
21038
|
var j = i + 1;
|
|
21039
21039
|
|
|
21040
21040
|
if (str[j] === "?") {
|
|
21041
|
-
throw new TypeError("Pattern cannot start with \"?\" at "
|
|
21041
|
+
throw new TypeError("Pattern cannot start with \"?\" at ".concat(j));
|
|
21042
21042
|
}
|
|
21043
21043
|
|
|
21044
21044
|
while (j < str.length) {
|
|
@@ -21058,15 +21058,15 @@ function lexer(str) {
|
|
|
21058
21058
|
count++;
|
|
21059
21059
|
|
|
21060
21060
|
if (str[j + 1] !== "?") {
|
|
21061
|
-
throw new TypeError("Capturing groups are not allowed at "
|
|
21061
|
+
throw new TypeError("Capturing groups are not allowed at ".concat(j));
|
|
21062
21062
|
}
|
|
21063
21063
|
}
|
|
21064
21064
|
|
|
21065
21065
|
pattern += str[j++];
|
|
21066
21066
|
}
|
|
21067
21067
|
|
|
21068
|
-
if (count) throw new TypeError("Unbalanced pattern at "
|
|
21069
|
-
if (!pattern) throw new TypeError("Missing pattern at "
|
|
21068
|
+
if (count) throw new TypeError("Unbalanced pattern at ".concat(i));
|
|
21069
|
+
if (!pattern) throw new TypeError("Missing pattern at ".concat(i));
|
|
21070
21070
|
tokens.push({
|
|
21071
21071
|
type: "PATTERN",
|
|
21072
21072
|
index: i,
|
|
@@ -21103,7 +21103,7 @@ function parse(str, options) {
|
|
|
21103
21103
|
var tokens = lexer(str);
|
|
21104
21104
|
var _a = options.prefixes,
|
|
21105
21105
|
prefixes = _a === void 0 ? "./" : _a;
|
|
21106
|
-
var defaultPattern = "[^"
|
|
21106
|
+
var defaultPattern = "[^".concat(escapeString(options.delimiter || "/#?"), "]+?");
|
|
21107
21107
|
var result = [];
|
|
21108
21108
|
var key = 0;
|
|
21109
21109
|
var i = 0;
|
|
@@ -21119,12 +21119,12 @@ function parse(str, options) {
|
|
|
21119
21119
|
var _a = tokens[i],
|
|
21120
21120
|
nextType = _a.type,
|
|
21121
21121
|
index = _a.index;
|
|
21122
|
-
throw new TypeError("Unexpected "
|
|
21122
|
+
throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
|
|
21123
21123
|
};
|
|
21124
21124
|
|
|
21125
21125
|
var consumeText = function () {
|
|
21126
21126
|
var result = "";
|
|
21127
|
-
var value;
|
|
21127
|
+
var value;
|
|
21128
21128
|
|
|
21129
21129
|
while (value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
|
|
21130
21130
|
result += value;
|
|
@@ -21222,7 +21222,7 @@ function tokensToFunction(tokens, options) {
|
|
|
21222
21222
|
|
|
21223
21223
|
var matches = tokens.map(function (token) {
|
|
21224
21224
|
if (typeof token === "object") {
|
|
21225
|
-
return new RegExp("^(?:"
|
|
21225
|
+
return new RegExp("^(?:".concat(token.pattern, ")$"), reFlags);
|
|
21226
21226
|
}
|
|
21227
21227
|
});
|
|
21228
21228
|
return function (data) {
|
|
@@ -21242,19 +21242,19 @@ function tokensToFunction(tokens, options) {
|
|
|
21242
21242
|
|
|
21243
21243
|
if (Array.isArray(value)) {
|
|
21244
21244
|
if (!repeat) {
|
|
21245
|
-
throw new TypeError("Expected \""
|
|
21245
|
+
throw new TypeError("Expected \"".concat(token.name, "\" to not repeat, but got an array"));
|
|
21246
21246
|
}
|
|
21247
21247
|
|
|
21248
21248
|
if (value.length === 0) {
|
|
21249
21249
|
if (optional) continue;
|
|
21250
|
-
throw new TypeError("Expected \""
|
|
21250
|
+
throw new TypeError("Expected \"".concat(token.name, "\" to not be empty"));
|
|
21251
21251
|
}
|
|
21252
21252
|
|
|
21253
21253
|
for (var j = 0; j < value.length; j++) {
|
|
21254
21254
|
var segment = encode(value[j], token);
|
|
21255
21255
|
|
|
21256
21256
|
if (validate && !matches[i].test(segment)) {
|
|
21257
|
-
throw new TypeError("Expected all \""
|
|
21257
|
+
throw new TypeError("Expected all \"".concat(token.name, "\" to match \"").concat(token.pattern, "\", but got \"").concat(segment, "\""));
|
|
21258
21258
|
}
|
|
21259
21259
|
|
|
21260
21260
|
path += token.prefix + segment + token.suffix;
|
|
@@ -21267,7 +21267,7 @@ function tokensToFunction(tokens, options) {
|
|
|
21267
21267
|
var segment = encode(String(value), token);
|
|
21268
21268
|
|
|
21269
21269
|
if (validate && !matches[i].test(segment)) {
|
|
21270
|
-
throw new TypeError("Expected \""
|
|
21270
|
+
throw new TypeError("Expected \"".concat(token.name, "\" to match \"").concat(token.pattern, "\", but got \"").concat(segment, "\""));
|
|
21271
21271
|
}
|
|
21272
21272
|
|
|
21273
21273
|
path += token.prefix + segment + token.suffix;
|
|
@@ -21276,7 +21276,7 @@ function tokensToFunction(tokens, options) {
|
|
|
21276
21276
|
|
|
21277
21277
|
if (optional) continue;
|
|
21278
21278
|
var typeOfMessage = repeat ? "an array" : "a string";
|
|
21279
|
-
throw new TypeError("Expected \""
|
|
21279
|
+
throw new TypeError("Expected \"".concat(token.name, "\" to be ").concat(typeOfMessage));
|
|
21280
21280
|
}
|
|
21281
21281
|
|
|
21282
21282
|
return path;
|
|
@@ -21331,7 +21331,7 @@ function arrayToRegexp(paths, keys, options) {
|
|
|
21331
21331
|
var parts = paths.map(function (path) {
|
|
21332
21332
|
return pathToRegexp(path, keys, options).source;
|
|
21333
21333
|
});
|
|
21334
|
-
return new RegExp("(?:"
|
|
21334
|
+
return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
|
|
21335
21335
|
}
|
|
21336
21336
|
/**
|
|
21337
21337
|
* Create a path regexp from string input.
|
|
@@ -21360,9 +21360,13 @@ function tokensToRegexp(tokens, keys, options) {
|
|
|
21360
21360
|
_d = options.encode,
|
|
21361
21361
|
encode = _d === void 0 ? function (x) {
|
|
21362
21362
|
return x;
|
|
21363
|
-
} : _d
|
|
21364
|
-
|
|
21365
|
-
|
|
21363
|
+
} : _d,
|
|
21364
|
+
_e = options.delimiter,
|
|
21365
|
+
delimiter = _e === void 0 ? "/#?" : _e,
|
|
21366
|
+
_f = options.endsWith,
|
|
21367
|
+
endsWith = _f === void 0 ? "" : _f;
|
|
21368
|
+
var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
|
|
21369
|
+
var delimiterRe = "[".concat(escapeString(delimiter), "]");
|
|
21366
21370
|
var route = start ? "^" : ""; // Iterate over the tokens and create our regexp string.
|
|
21367
21371
|
|
|
21368
21372
|
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
@@ -21380,33 +21384,36 @@ function tokensToRegexp(tokens, keys, options) {
|
|
|
21380
21384
|
if (prefix || suffix) {
|
|
21381
21385
|
if (token.modifier === "+" || token.modifier === "*") {
|
|
21382
21386
|
var mod = token.modifier === "*" ? "?" : "";
|
|
21383
|
-
route += "(?:"
|
|
21387
|
+
route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
|
|
21384
21388
|
} else {
|
|
21385
|
-
route += "(?:"
|
|
21389
|
+
route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
|
|
21386
21390
|
}
|
|
21387
21391
|
} else {
|
|
21388
|
-
|
|
21392
|
+
if (token.modifier === "+" || token.modifier === "*") {
|
|
21393
|
+
route += "((?:".concat(token.pattern, ")").concat(token.modifier, ")");
|
|
21394
|
+
} else {
|
|
21395
|
+
route += "(".concat(token.pattern, ")").concat(token.modifier);
|
|
21396
|
+
}
|
|
21389
21397
|
}
|
|
21390
21398
|
} else {
|
|
21391
|
-
route += "(?:"
|
|
21399
|
+
route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
|
|
21392
21400
|
}
|
|
21393
21401
|
}
|
|
21394
21402
|
}
|
|
21395
21403
|
|
|
21396
21404
|
if (end) {
|
|
21397
|
-
if (!strict) route +=
|
|
21398
|
-
route += !options.endsWith ? "$" : "(?="
|
|
21405
|
+
if (!strict) route += "".concat(delimiterRe, "?");
|
|
21406
|
+
route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
|
|
21399
21407
|
} else {
|
|
21400
21408
|
var endToken = tokens[tokens.length - 1];
|
|
21401
|
-
var isEndDelimited = typeof endToken === "string" ?
|
|
21402
|
-
endToken === undefined;
|
|
21409
|
+
var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === undefined;
|
|
21403
21410
|
|
|
21404
21411
|
if (!strict) {
|
|
21405
|
-
route += "(?:"
|
|
21412
|
+
route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
|
|
21406
21413
|
}
|
|
21407
21414
|
|
|
21408
21415
|
if (!isEndDelimited) {
|
|
21409
|
-
route += "(?="
|
|
21416
|
+
route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
|
|
21410
21417
|
}
|
|
21411
21418
|
}
|
|
21412
21419
|
|