webpack-gc-i18n-plugin 1.1.12 → 1.1.13

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/dist/index.mjs CHANGED
@@ -26,7 +26,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
26
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
27
  PERFORMANCE OF THIS SOFTWARE.
28
28
  ***************************************************************************** */
29
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
29
+ /* global Reflect, Promise, SuppressedError, Symbol */
30
30
 
31
31
  var __assign = function () {
32
32
  __assign = Object.assign || function __assign(t) {
@@ -78,8 +78,12 @@ function __generator(thisArg, body) {
78
78
  f,
79
79
  y,
80
80
  t,
81
- g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
82
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
81
+ g;
82
+ return g = {
83
+ next: verb(0),
84
+ "throw": verb(1),
85
+ "return": verb(2)
86
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
83
87
  return this;
84
88
  }), g;
85
89
  function verb(n) {
@@ -1045,7 +1049,7 @@ function splitTrailingInlineText(value) {
1045
1049
  */
1046
1050
  function checkNeedSplit(str) {
1047
1051
  // 检查字符串中是否包含需要切割的特殊字符
1048
- return str.includes('\\') || str.includes('>') || str.includes('<');
1052
+ return str.includes('\\') || /<\/?[A-Za-z][^>]*>/.test(str);
1049
1053
  }
1050
1054
 
1051
1055
  /**
@@ -1054,49 +1058,29 @@ function checkNeedSplit(str) {
1054
1058
  * @return {types.CallExpression} - babel的深度扫描的表达式
1055
1059
  */
1056
1060
  function convertToTemplateLiteral(strArray, option) {
1057
- const quasis = [];
1061
+ const quasis = [types.templateElement({
1062
+ raw: '',
1063
+ cooked: ''
1064
+ }, false)];
1058
1065
  const expressions = [];
1059
- strArray.forEach((str, index) => {
1060
- if (index === 0) {
1061
- if (getOriginRegex().test(str)) {
1062
- quasis.push(types.templateElement({
1063
- raw: '',
1064
- cooked: ''
1065
- }, false));
1066
- expressions.push(createI18nTranslator({
1067
- value: str,
1068
- isExpression: true,
1069
- insertOption: option
1070
- }));
1071
- } else {
1072
- quasis.push(types.templateElement({
1073
- raw: str,
1074
- cooked: str
1075
- }, false));
1076
- }
1066
+ strArray.forEach(str => {
1067
+ if (getOriginRegex().test(str)) {
1068
+ expressions.push(createI18nTranslator({
1069
+ value: str,
1070
+ isExpression: true,
1071
+ insertOption: option
1072
+ }));
1073
+ quasis.push(types.templateElement({
1074
+ raw: '',
1075
+ cooked: ''
1076
+ }, false));
1077
1077
  } else {
1078
- if (getOriginRegex().test(str)) {
1079
- expressions.push(createI18nTranslator({
1080
- value: str,
1081
- isExpression: true,
1082
- insertOption: option
1083
- }));
1084
- } else {
1085
- quasis.push(types.templateElement({
1086
- raw: str,
1087
- cooked: str
1088
- }, false));
1089
- }
1078
+ const quasi = quasis[quasis.length - 1];
1079
+ quasi.value.raw += str;
1080
+ quasi.value.cooked = `${quasi.value.cooked || ''}${str}`;
1090
1081
  }
1091
1082
  });
1092
- if (quasis.length === expressions.length) {
1093
- quasis.push(types.templateElement({
1094
- raw: '',
1095
- cooked: ''
1096
- }, true));
1097
- } else if (quasis.length > expressions.length) {
1098
- quasis[quasis.length - 1].tail = true;
1099
- }
1083
+ quasis[quasis.length - 1].tail = true;
1100
1084
  const templateLiteral = types.templateLiteral(quasis, expressions);
1101
1085
  const deepScanCall = types.callExpression(types.identifier('$deepScan'), [templateLiteral]);
1102
1086
  // 打印转换结果