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.cjs CHANGED
@@ -50,7 +50,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
50
50
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
51
51
  PERFORMANCE OF THIS SOFTWARE.
52
52
  ***************************************************************************** */
53
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
53
+ /* global Reflect, Promise, SuppressedError, Symbol */
54
54
 
55
55
  var __assign = function () {
56
56
  __assign = Object.assign || function __assign(t) {
@@ -102,8 +102,12 @@ function __generator(thisArg, body) {
102
102
  f,
103
103
  y,
104
104
  t,
105
- g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
106
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () {
105
+ g;
106
+ return g = {
107
+ next: verb(0),
108
+ "throw": verb(1),
109
+ "return": verb(2)
110
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
107
111
  return this;
108
112
  }), g;
109
113
  function verb(n) {
@@ -1069,7 +1073,7 @@ function splitTrailingInlineText(value) {
1069
1073
  */
1070
1074
  function checkNeedSplit(str) {
1071
1075
  // 检查字符串中是否包含需要切割的特殊字符
1072
- return str.includes('\\') || str.includes('>') || str.includes('<');
1076
+ return str.includes('\\') || /<\/?[A-Za-z][^>]*>/.test(str);
1073
1077
  }
1074
1078
 
1075
1079
  /**
@@ -1078,49 +1082,29 @@ function checkNeedSplit(str) {
1078
1082
  * @return {types.CallExpression} - babel的深度扫描的表达式
1079
1083
  */
1080
1084
  function convertToTemplateLiteral(strArray, option) {
1081
- const quasis = [];
1085
+ const quasis = [types__namespace.templateElement({
1086
+ raw: '',
1087
+ cooked: ''
1088
+ }, false)];
1082
1089
  const expressions = [];
1083
- strArray.forEach((str, index) => {
1084
- if (index === 0) {
1085
- if (getOriginRegex().test(str)) {
1086
- quasis.push(types__namespace.templateElement({
1087
- raw: '',
1088
- cooked: ''
1089
- }, false));
1090
- expressions.push(createI18nTranslator({
1091
- value: str,
1092
- isExpression: true,
1093
- insertOption: option
1094
- }));
1095
- } else {
1096
- quasis.push(types__namespace.templateElement({
1097
- raw: str,
1098
- cooked: str
1099
- }, false));
1100
- }
1090
+ strArray.forEach(str => {
1091
+ if (getOriginRegex().test(str)) {
1092
+ expressions.push(createI18nTranslator({
1093
+ value: str,
1094
+ isExpression: true,
1095
+ insertOption: option
1096
+ }));
1097
+ quasis.push(types__namespace.templateElement({
1098
+ raw: '',
1099
+ cooked: ''
1100
+ }, false));
1101
1101
  } else {
1102
- if (getOriginRegex().test(str)) {
1103
- expressions.push(createI18nTranslator({
1104
- value: str,
1105
- isExpression: true,
1106
- insertOption: option
1107
- }));
1108
- } else {
1109
- quasis.push(types__namespace.templateElement({
1110
- raw: str,
1111
- cooked: str
1112
- }, false));
1113
- }
1102
+ const quasi = quasis[quasis.length - 1];
1103
+ quasi.value.raw += str;
1104
+ quasi.value.cooked = `${quasi.value.cooked || ''}${str}`;
1114
1105
  }
1115
1106
  });
1116
- if (quasis.length === expressions.length) {
1117
- quasis.push(types__namespace.templateElement({
1118
- raw: '',
1119
- cooked: ''
1120
- }, true));
1121
- } else if (quasis.length > expressions.length) {
1122
- quasis[quasis.length - 1].tail = true;
1123
- }
1107
+ quasis[quasis.length - 1].tail = true;
1124
1108
  const templateLiteral = types__namespace.templateLiteral(quasis, expressions);
1125
1109
  const deepScanCall = types__namespace.callExpression(types__namespace.identifier('$deepScan'), [templateLiteral]);
1126
1110
  // 打印转换结果