@next-core/brick-utils 2.30.3 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/index.bundle.js +135 -102
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +132 -99
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -2,9 +2,9 @@ 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';
|
|
5
6
|
import { processPipes, utils } from '@next-core/pipes';
|
|
6
7
|
export { pipes } from '@next-core/pipes';
|
|
7
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
8
8
|
import yaml from 'js-yaml';
|
|
9
9
|
|
|
10
10
|
var cache$1 = new Map();
|
|
@@ -18523,7 +18523,7 @@ function precook(rootAst) {
|
|
|
18523
18523
|
Evaluate(n);
|
|
18524
18524
|
}
|
|
18525
18525
|
} else if (node) {
|
|
18526
|
-
var _hooks$beforeVisit; // `node` maybe `null` in some cases.
|
|
18526
|
+
var _hooks$beforeVisit, _hooks$beforeVisitUnk; // `node` maybe `null` in some cases.
|
|
18527
18527
|
|
|
18528
18528
|
|
|
18529
18529
|
(_hooks$beforeVisit = hooks.beforeVisit) === null || _hooks$beforeVisit === void 0 ? void 0 : _hooks$beforeVisit.call(hooks, node);
|
|
@@ -18532,11 +18532,10 @@ function precook(rootAst) {
|
|
|
18532
18532
|
switch (node.type) {
|
|
18533
18533
|
case "Identifier":
|
|
18534
18534
|
if (!ResolveBinding(node.name)) {
|
|
18535
|
-
|
|
18535
|
+
var _hooks$beforeVisitGlo;
|
|
18536
18536
|
|
|
18537
|
-
|
|
18538
|
-
|
|
18539
|
-
}
|
|
18537
|
+
(_hooks$beforeVisitGlo = hooks.beforeVisitGlobal) === null || _hooks$beforeVisitGlo === void 0 ? void 0 : _hooks$beforeVisitGlo.call(hooks, node);
|
|
18538
|
+
attemptToVisitGlobals.add(node.name);
|
|
18540
18539
|
}
|
|
18541
18540
|
|
|
18542
18541
|
return;
|
|
@@ -18803,9 +18802,9 @@ function precook(rootAst) {
|
|
|
18803
18802
|
}
|
|
18804
18803
|
}
|
|
18805
18804
|
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
|
|
18805
|
+
var silent = (_hooks$beforeVisitUnk = hooks.beforeVisitUnknown) === null || _hooks$beforeVisitUnk === void 0 ? void 0 : _hooks$beforeVisitUnk.call(hooks, node);
|
|
18806
|
+
|
|
18807
|
+
if (!silent) {
|
|
18809
18808
|
// eslint-disable-next-line no-console
|
|
18810
18809
|
console.warn("Unsupported node type `".concat(node.type, "`"));
|
|
18811
18810
|
}
|
|
@@ -18991,93 +18990,100 @@ function lint(source) {
|
|
|
18991
18990
|
}
|
|
18992
18991
|
});
|
|
18993
18992
|
} else {
|
|
18994
|
-
var FunctionVisitor = node => {
|
|
18995
|
-
if (node.async || node.generator) {
|
|
18996
|
-
errors.push({
|
|
18997
|
-
type: "SyntaxError",
|
|
18998
|
-
message: "".concat(node.async ? "Async" : "Generator", " function is not allowed"),
|
|
18999
|
-
loc: node.loc
|
|
19000
|
-
});
|
|
19001
|
-
}
|
|
19002
|
-
};
|
|
19003
|
-
|
|
19004
18993
|
precook(func, {
|
|
19005
|
-
|
|
19006
|
-
|
|
19007
|
-
|
|
19008
|
-
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
19012
|
-
if (node.value === null) {
|
|
19013
|
-
errors.push({
|
|
19014
|
-
type: "SyntaxError",
|
|
19015
|
-
message: "Invalid regular expression",
|
|
19016
|
-
loc: node.loc
|
|
19017
|
-
});
|
|
19018
|
-
} else if (node.regex.flags.includes("u")) {
|
|
19019
|
-
errors.push({
|
|
19020
|
-
type: "SyntaxError",
|
|
19021
|
-
message: "Unsupported unicode flag in regular expression",
|
|
19022
|
-
loc: node.loc
|
|
19023
|
-
});
|
|
19024
|
-
}
|
|
19025
|
-
}
|
|
19026
|
-
},
|
|
19027
|
-
|
|
19028
|
-
ObjectExpression(node) {
|
|
19029
|
-
for (var prop of node.properties) {
|
|
19030
|
-
if (prop.type === "Property") {
|
|
19031
|
-
if (prop.kind !== "init") {
|
|
18994
|
+
hooks: {
|
|
18995
|
+
beforeVisit(node) {
|
|
18996
|
+
switch (node.type) {
|
|
18997
|
+
case "ArrowFunctionExpression":
|
|
18998
|
+
case "FunctionDeclaration":
|
|
18999
|
+
case "FunctionExpression":
|
|
19000
|
+
if (node.async || node.generator) {
|
|
19032
19001
|
errors.push({
|
|
19033
19002
|
type: "SyntaxError",
|
|
19034
|
-
message: "
|
|
19035
|
-
loc:
|
|
19003
|
+
message: "".concat(node.async ? "Async" : "Generator", " function is not allowed"),
|
|
19004
|
+
loc: node.loc
|
|
19036
19005
|
});
|
|
19037
|
-
}
|
|
19006
|
+
}
|
|
19007
|
+
|
|
19008
|
+
break;
|
|
19009
|
+
|
|
19010
|
+
case "Literal":
|
|
19011
|
+
if (node.regex) {
|
|
19012
|
+
if (node.value === null) {
|
|
19013
|
+
errors.push({
|
|
19014
|
+
type: "SyntaxError",
|
|
19015
|
+
message: "Invalid regular expression",
|
|
19016
|
+
loc: node.loc
|
|
19017
|
+
});
|
|
19018
|
+
} else if (node.regex.flags.includes("u")) {
|
|
19019
|
+
errors.push({
|
|
19020
|
+
type: "SyntaxError",
|
|
19021
|
+
message: "Unsupported unicode flag in regular expression",
|
|
19022
|
+
loc: node.loc
|
|
19023
|
+
});
|
|
19024
|
+
}
|
|
19025
|
+
}
|
|
19026
|
+
|
|
19027
|
+
break;
|
|
19028
|
+
|
|
19029
|
+
case "ObjectExpression":
|
|
19030
|
+
for (var prop of node.properties) {
|
|
19031
|
+
if (prop.type === "Property") {
|
|
19032
|
+
if (prop.kind !== "init") {
|
|
19033
|
+
errors.push({
|
|
19034
|
+
type: "SyntaxError",
|
|
19035
|
+
message: "Unsupported object getter/setter property",
|
|
19036
|
+
loc: prop.loc
|
|
19037
|
+
});
|
|
19038
|
+
} else if (!prop.computed && prop.key.type === "Identifier" && prop.key.name === "__proto__") {
|
|
19039
|
+
errors.push({
|
|
19040
|
+
type: "TypeError",
|
|
19041
|
+
message: "Setting '__proto__' property is not allowed",
|
|
19042
|
+
loc: prop.key.loc
|
|
19043
|
+
});
|
|
19044
|
+
}
|
|
19045
|
+
}
|
|
19046
|
+
}
|
|
19047
|
+
|
|
19048
|
+
break;
|
|
19049
|
+
|
|
19050
|
+
case "VariableDeclaration":
|
|
19051
|
+
if (node.kind === "var" && rules !== null && rules !== void 0 && rules.noVar) {
|
|
19038
19052
|
errors.push({
|
|
19039
|
-
type: "
|
|
19040
|
-
message: "
|
|
19041
|
-
loc:
|
|
19053
|
+
type: "SyntaxError",
|
|
19054
|
+
message: "Var declaration is not recommended, use `let` or `const` instead",
|
|
19055
|
+
loc: {
|
|
19056
|
+
start: node.loc.start,
|
|
19057
|
+
end: {
|
|
19058
|
+
line: node.loc.end.line,
|
|
19059
|
+
// Only decorate the "var".
|
|
19060
|
+
column: node.loc.start.column + 3
|
|
19061
|
+
}
|
|
19062
|
+
}
|
|
19042
19063
|
});
|
|
19043
19064
|
}
|
|
19044
|
-
|
|
19065
|
+
|
|
19066
|
+
break;
|
|
19045
19067
|
}
|
|
19046
19068
|
},
|
|
19047
19069
|
|
|
19048
|
-
|
|
19049
|
-
if (node.
|
|
19070
|
+
beforeVisitGlobal(node) {
|
|
19071
|
+
if (node.name === "arguments") {
|
|
19050
19072
|
errors.push({
|
|
19051
19073
|
type: "SyntaxError",
|
|
19052
|
-
message: "
|
|
19053
|
-
loc:
|
|
19054
|
-
start: node.loc.start,
|
|
19055
|
-
end: {
|
|
19056
|
-
line: node.loc.end.line,
|
|
19057
|
-
// Only decorate the "var".
|
|
19058
|
-
column: node.loc.start.column + 3
|
|
19059
|
-
}
|
|
19060
|
-
}
|
|
19074
|
+
message: "Use the rest parameters instead of 'arguments'",
|
|
19075
|
+
loc: node.loc
|
|
19061
19076
|
});
|
|
19062
19077
|
}
|
|
19063
19078
|
},
|
|
19064
19079
|
|
|
19065
|
-
|
|
19080
|
+
beforeVisitUnknown(node) {
|
|
19066
19081
|
errors.push({
|
|
19067
19082
|
type: "SyntaxError",
|
|
19068
19083
|
message: "Unsupported syntax: `".concat(node.type, "`"),
|
|
19069
19084
|
loc: node.loc
|
|
19070
19085
|
});
|
|
19071
|
-
|
|
19072
|
-
|
|
19073
|
-
__GlobalVariable(node) {
|
|
19074
|
-
if (node.name === "arguments") {
|
|
19075
|
-
errors.push({
|
|
19076
|
-
type: "SyntaxError",
|
|
19077
|
-
message: "Use the rest parameters instead of 'arguments'",
|
|
19078
|
-
loc: node.loc
|
|
19079
|
-
});
|
|
19080
|
-
}
|
|
19086
|
+
return true;
|
|
19081
19087
|
}
|
|
19082
19088
|
|
|
19083
19089
|
}
|
|
@@ -20056,39 +20062,45 @@ function collectRouteAliasInRouteConfs(routes, collection) {
|
|
|
20056
20062
|
|
|
20057
20063
|
var I18N = "I18N";
|
|
20058
20064
|
function scanI18NInStoryboard(storyboard) {
|
|
20059
|
-
|
|
20060
|
-
|
|
20065
|
+
var _storyboard$meta;
|
|
20066
|
+
|
|
20067
|
+
var collection = new Map();
|
|
20068
|
+
var beforeVisit = beforeVisitFactory(collection); // Notice: `menus` may contain evaluations of I18N too.
|
|
20069
|
+
|
|
20070
|
+
var {
|
|
20071
|
+
customTemplates,
|
|
20072
|
+
menus,
|
|
20073
|
+
functions
|
|
20074
|
+
} = (_storyboard$meta = storyboard.meta) !== null && _storyboard$meta !== void 0 ? _storyboard$meta : {};
|
|
20075
|
+
collectI18N([storyboard.routes, customTemplates, menus], beforeVisit);
|
|
20076
|
+
|
|
20077
|
+
if (Array.isArray(functions)) {
|
|
20078
|
+
for (var fn of functions) {
|
|
20079
|
+
precookFunction(fn.source, {
|
|
20080
|
+
typescript: fn.typescript,
|
|
20081
|
+
hooks: {
|
|
20082
|
+
beforeVisit
|
|
20083
|
+
}
|
|
20084
|
+
});
|
|
20085
|
+
}
|
|
20086
|
+
}
|
|
20087
|
+
|
|
20088
|
+
return collection;
|
|
20061
20089
|
}
|
|
20062
20090
|
function scanI18NInAny(data) {
|
|
20063
20091
|
var collection = new Map();
|
|
20064
|
-
collectI18N(data, collection);
|
|
20092
|
+
collectI18N(data, beforeVisitFactory(collection));
|
|
20065
20093
|
return collection;
|
|
20066
20094
|
}
|
|
20067
20095
|
|
|
20068
|
-
function collectI18N(data,
|
|
20096
|
+
function collectI18N(data, beforeVisit) {
|
|
20069
20097
|
var memo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakSet();
|
|
20070
20098
|
|
|
20071
20099
|
if (typeof data === "string") {
|
|
20072
20100
|
if (data.includes(I18N) && isEvaluable(data)) {
|
|
20073
20101
|
preevaluate(data, {
|
|
20074
|
-
|
|
20075
|
-
|
|
20076
|
-
var [keyNode, defaultNode] = node.arguments;
|
|
20077
|
-
|
|
20078
|
-
if (node.callee.type === "Identifier" && node.callee.name === I18N && keyNode && keyNode.type === "Literal" && typeof keyNode.value === "string") {
|
|
20079
|
-
var valueSet = collection.get(keyNode.value);
|
|
20080
|
-
|
|
20081
|
-
if (!valueSet) {
|
|
20082
|
-
valueSet = new Set();
|
|
20083
|
-
collection.set(keyNode.value, valueSet);
|
|
20084
|
-
}
|
|
20085
|
-
|
|
20086
|
-
if (defaultNode && defaultNode.type === "Literal" && typeof defaultNode.value === "string") {
|
|
20087
|
-
valueSet.add(defaultNode.value);
|
|
20088
|
-
}
|
|
20089
|
-
}
|
|
20090
|
-
}
|
|
20091
|
-
|
|
20102
|
+
hooks: {
|
|
20103
|
+
beforeVisit
|
|
20092
20104
|
}
|
|
20093
20105
|
});
|
|
20094
20106
|
}
|
|
@@ -20102,16 +20114,37 @@ function collectI18N(data, collection) {
|
|
|
20102
20114
|
|
|
20103
20115
|
if (Array.isArray(data)) {
|
|
20104
20116
|
for (var item of data) {
|
|
20105
|
-
collectI18N(item,
|
|
20117
|
+
collectI18N(item, beforeVisit, memo);
|
|
20106
20118
|
}
|
|
20107
20119
|
} else {
|
|
20108
20120
|
for (var _item of Object.values(data)) {
|
|
20109
|
-
collectI18N(_item,
|
|
20121
|
+
collectI18N(_item, beforeVisit, memo);
|
|
20110
20122
|
}
|
|
20111
20123
|
}
|
|
20112
20124
|
}
|
|
20113
20125
|
}
|
|
20114
20126
|
|
|
20127
|
+
function beforeVisitFactory(collection) {
|
|
20128
|
+
return function beforeVisit(node) {
|
|
20129
|
+
if (node.type === "CallExpression") {
|
|
20130
|
+
var [keyNode, defaultNode] = node.arguments;
|
|
20131
|
+
|
|
20132
|
+
if (node.callee.type === "Identifier" && node.callee.name === I18N && keyNode && keyNode.type === "Literal" && typeof keyNode.value === "string") {
|
|
20133
|
+
var valueSet = collection.get(keyNode.value);
|
|
20134
|
+
|
|
20135
|
+
if (!valueSet) {
|
|
20136
|
+
valueSet = new Set();
|
|
20137
|
+
collection.set(keyNode.value, valueSet);
|
|
20138
|
+
}
|
|
20139
|
+
|
|
20140
|
+
if (defaultNode && defaultNode.type === "Literal" && typeof defaultNode.value === "string") {
|
|
20141
|
+
valueSet.add(defaultNode.value);
|
|
20142
|
+
}
|
|
20143
|
+
}
|
|
20144
|
+
}
|
|
20145
|
+
};
|
|
20146
|
+
}
|
|
20147
|
+
|
|
20115
20148
|
var LexicalStatus;
|
|
20116
20149
|
|
|
20117
20150
|
(function (LexicalStatus) {
|