@intlify/message-compiler 9.10.1 → 9.11.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/dist/message-compiler.cjs +35 -14
- package/dist/message-compiler.d.ts +1 -0
- package/dist/message-compiler.esm-browser.js +35 -14
- package/dist/message-compiler.esm-browser.prod.js +2 -2
- package/dist/message-compiler.global.js +35 -14
- package/dist/message-compiler.global.prod.js +2 -2
- package/dist/message-compiler.mjs +35 -14
- package/dist/message-compiler.node.mjs +35 -14
- package/dist/message-compiler.prod.cjs +35 -14
- package/dist/vitest.config.d.ts +4 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.e2e.config.d.ts +4 -0
- package/dist/vitest.e2e.config.d.ts.map +1 -0
- package/dist/vitest.unit.config.d.ts +4 -0
- package/dist/vitest.unit.config.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.11.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -112,6 +112,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
112
112
|
throw error;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
// eslint-disable-next-line no-useless-escape
|
|
115
116
|
const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/;
|
|
116
117
|
const detectHtmlTag = (source) => RE_HTML_TAG.test(source);
|
|
117
118
|
|
|
@@ -485,6 +486,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
485
486
|
}
|
|
486
487
|
function readText(scnr) {
|
|
487
488
|
let buf = '';
|
|
489
|
+
// eslint-disable-next-line no-constant-condition
|
|
488
490
|
while (true) {
|
|
489
491
|
const ch = scnr.currentChar();
|
|
490
492
|
if (ch === "{" /* TokenChars.BraceLeft */ ||
|
|
@@ -552,6 +554,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
552
554
|
}
|
|
553
555
|
function readLiteral(scnr) {
|
|
554
556
|
skipSpaces(scnr);
|
|
557
|
+
// eslint-disable-next-line no-useless-escape
|
|
555
558
|
eat(scnr, `\'`);
|
|
556
559
|
let ch = '';
|
|
557
560
|
let literal = '';
|
|
@@ -570,10 +573,12 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
570
573
|
// TODO: Is it correct really?
|
|
571
574
|
if (current === CHAR_LF) {
|
|
572
575
|
scnr.next();
|
|
576
|
+
// eslint-disable-next-line no-useless-escape
|
|
573
577
|
eat(scnr, `\'`);
|
|
574
578
|
}
|
|
575
579
|
return literal;
|
|
576
580
|
}
|
|
581
|
+
// eslint-disable-next-line no-useless-escape
|
|
577
582
|
eat(scnr, `\'`);
|
|
578
583
|
return literal;
|
|
579
584
|
}
|
|
@@ -581,7 +586,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
581
586
|
const ch = scnr.currentChar();
|
|
582
587
|
switch (ch) {
|
|
583
588
|
case '\\':
|
|
584
|
-
case `\'`:
|
|
589
|
+
case `\'`: // eslint-disable-line no-useless-escape
|
|
585
590
|
scnr.next();
|
|
586
591
|
return `\\${ch}`;
|
|
587
592
|
case 'u':
|
|
@@ -695,7 +700,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
695
700
|
token = readTokenInLinked(scnr, context) || getEndToken(context);
|
|
696
701
|
context.braceNest = 0;
|
|
697
702
|
return token;
|
|
698
|
-
default:
|
|
703
|
+
default: {
|
|
699
704
|
let validNamedIdentifier = true;
|
|
700
705
|
let validListIdentifier = true;
|
|
701
706
|
let validLiteral = true;
|
|
@@ -740,6 +745,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
740
745
|
return token;
|
|
741
746
|
}
|
|
742
747
|
break;
|
|
748
|
+
}
|
|
743
749
|
}
|
|
744
750
|
return token;
|
|
745
751
|
}
|
|
@@ -823,7 +829,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
823
829
|
return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */);
|
|
824
830
|
case "@" /* TokenChars.LinkedAlias */:
|
|
825
831
|
return readTokenInLinked(scnr, context) || getEndToken(context);
|
|
826
|
-
default:
|
|
832
|
+
default: {
|
|
827
833
|
if (isPluralStart(scnr)) {
|
|
828
834
|
token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr));
|
|
829
835
|
// reset
|
|
@@ -841,6 +847,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
841
847
|
return getToken(context, 0 /* TokenTypes.Text */, readText(scnr));
|
|
842
848
|
}
|
|
843
849
|
break;
|
|
850
|
+
}
|
|
844
851
|
}
|
|
845
852
|
return token;
|
|
846
853
|
}
|
|
@@ -872,7 +879,9 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
872
879
|
switch (match) {
|
|
873
880
|
case `\\\\`:
|
|
874
881
|
return `\\`;
|
|
882
|
+
// eslint-disable-next-line no-useless-escape
|
|
875
883
|
case `\\\'`:
|
|
884
|
+
// eslint-disable-next-line no-useless-escape
|
|
876
885
|
return `\'`;
|
|
877
886
|
default: {
|
|
878
887
|
const codePoint = parseInt(codePoint4 || codePoint6, 16);
|
|
@@ -1030,7 +1039,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1030
1039
|
}
|
|
1031
1040
|
linkedNode.key = parseLiteral(tokenizer, token.value || '');
|
|
1032
1041
|
break;
|
|
1033
|
-
default:
|
|
1042
|
+
default: {
|
|
1034
1043
|
// empty key
|
|
1035
1044
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0);
|
|
1036
1045
|
const nextContext = tokenizer.context();
|
|
@@ -1043,6 +1052,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1043
1052
|
nextConsumeToken: token,
|
|
1044
1053
|
node: linkedNode
|
|
1045
1054
|
};
|
|
1055
|
+
}
|
|
1046
1056
|
}
|
|
1047
1057
|
endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1048
1058
|
return {
|
|
@@ -1088,11 +1098,12 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1088
1098
|
}
|
|
1089
1099
|
node.items.push(parseLiteral(tokenizer, token.value || ''));
|
|
1090
1100
|
break;
|
|
1091
|
-
case 8 /* TokenTypes.LinkedAlias */:
|
|
1101
|
+
case 8 /* TokenTypes.LinkedAlias */: {
|
|
1092
1102
|
const parsed = parseLinked(tokenizer);
|
|
1093
1103
|
node.items.push(parsed.node);
|
|
1094
1104
|
nextToken = parsed.nextConsumeToken || null;
|
|
1095
1105
|
break;
|
|
1106
|
+
}
|
|
1096
1107
|
}
|
|
1097
1108
|
} while (context.currentType !== 14 /* TokenTypes.EOF */ &&
|
|
1098
1109
|
context.currentType !== 1 /* TokenTypes.Pipe */);
|
|
@@ -1192,12 +1203,13 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1192
1203
|
case 2 /* NodeTypes.Message */:
|
|
1193
1204
|
traverseNodes(node.items, transformer);
|
|
1194
1205
|
break;
|
|
1195
|
-
case 6 /* NodeTypes.Linked */:
|
|
1206
|
+
case 6 /* NodeTypes.Linked */: {
|
|
1196
1207
|
const linked = node;
|
|
1197
1208
|
traverseNode(linked.key, transformer);
|
|
1198
1209
|
transformer.helper("linked" /* HelperNameMap.LINKED */);
|
|
1199
1210
|
transformer.helper("type" /* HelperNameMap.TYPE */);
|
|
1200
1211
|
break;
|
|
1212
|
+
}
|
|
1201
1213
|
case 5 /* NodeTypes.List */:
|
|
1202
1214
|
transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */);
|
|
1203
1215
|
transformer.helper("list" /* HelperNameMap.LIST */);
|
|
@@ -1268,13 +1280,14 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1268
1280
|
function minify(node) {
|
|
1269
1281
|
node.t = node.type;
|
|
1270
1282
|
switch (node.type) {
|
|
1271
|
-
case 0 /* NodeTypes.Resource */:
|
|
1283
|
+
case 0 /* NodeTypes.Resource */: {
|
|
1272
1284
|
const resource = node;
|
|
1273
1285
|
minify(resource.body);
|
|
1274
1286
|
resource.b = resource.body;
|
|
1275
1287
|
delete resource.body;
|
|
1276
1288
|
break;
|
|
1277
|
-
|
|
1289
|
+
}
|
|
1290
|
+
case 1 /* NodeTypes.Plural */: {
|
|
1278
1291
|
const plural = node;
|
|
1279
1292
|
const cases = plural.cases;
|
|
1280
1293
|
for (let i = 0; i < cases.length; i++) {
|
|
@@ -1283,7 +1296,8 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1283
1296
|
plural.c = cases;
|
|
1284
1297
|
delete plural.cases;
|
|
1285
1298
|
break;
|
|
1286
|
-
|
|
1299
|
+
}
|
|
1300
|
+
case 2 /* NodeTypes.Message */: {
|
|
1287
1301
|
const message = node;
|
|
1288
1302
|
const items = message.items;
|
|
1289
1303
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -1296,17 +1310,19 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1296
1310
|
delete message.static;
|
|
1297
1311
|
}
|
|
1298
1312
|
break;
|
|
1313
|
+
}
|
|
1299
1314
|
case 3 /* NodeTypes.Text */:
|
|
1300
1315
|
case 9 /* NodeTypes.Literal */:
|
|
1301
1316
|
case 8 /* NodeTypes.LinkedModifier */:
|
|
1302
|
-
case 7 /* NodeTypes.LinkedKey */:
|
|
1317
|
+
case 7 /* NodeTypes.LinkedKey */: {
|
|
1303
1318
|
const valueNode = node;
|
|
1304
1319
|
if (valueNode.value) {
|
|
1305
1320
|
valueNode.v = valueNode.value;
|
|
1306
1321
|
delete valueNode.value;
|
|
1307
1322
|
}
|
|
1308
1323
|
break;
|
|
1309
|
-
|
|
1324
|
+
}
|
|
1325
|
+
case 6 /* NodeTypes.Linked */: {
|
|
1310
1326
|
const linked = node;
|
|
1311
1327
|
minify(linked.key);
|
|
1312
1328
|
linked.k = linked.key;
|
|
@@ -1317,16 +1333,19 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1317
1333
|
delete linked.modifier;
|
|
1318
1334
|
}
|
|
1319
1335
|
break;
|
|
1320
|
-
|
|
1336
|
+
}
|
|
1337
|
+
case 5 /* NodeTypes.List */: {
|
|
1321
1338
|
const list = node;
|
|
1322
1339
|
list.i = list.index;
|
|
1323
1340
|
delete list.index;
|
|
1324
1341
|
break;
|
|
1325
|
-
|
|
1342
|
+
}
|
|
1343
|
+
case 4 /* NodeTypes.Named */: {
|
|
1326
1344
|
const named = node;
|
|
1327
1345
|
named.k = named.key;
|
|
1328
1346
|
delete named.key;
|
|
1329
1347
|
break;
|
|
1348
|
+
}
|
|
1330
1349
|
default:
|
|
1331
1350
|
{
|
|
1332
1351
|
throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, {
|
|
@@ -1339,6 +1358,8 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
1339
1358
|
}
|
|
1340
1359
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
1341
1360
|
|
|
1361
|
+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
1362
|
+
/// <reference types="source-map-js" />
|
|
1342
1363
|
const ERROR_DOMAIN = 'parser';
|
|
1343
1364
|
function createCodeGenerator(ast, options) {
|
|
1344
1365
|
const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.11.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var IntlifyMessageCompiler=function(e){"use strict";function t(e,t,n){return{line:e,column:t,offset:n}}function n(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const r=Object.assign,c=e=>"string"==typeof e;function o(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const s={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17},u={[s.EXPECTED_TOKEN]:"Expected token: '{0}'",[s.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[s.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[s.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[s.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[s.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[s.EMPTY_PLACEHOLDER]:"Empty placeholder",[s.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[s.INVALID_LINKED_FORMAT]:"Invalid linked format",[s.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[s.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[s.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[s.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[s.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[s.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function a(e,t,n={}){const{domain:r,messages:c,args:o}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}const i=/<\/?[\w\s="/.':;#-\/]+>/,l=" ",E="\r",f="\n",d=String.fromCharCode(8232),L=String.fromCharCode(8233);function N(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>t[e]===E&&t[e+1]===f,u=e=>t[e]===L,a=e=>t[e]===d,i=e=>s(e)||(e=>t[e]===f)(e)||u(e)||a(e),l=e=>s(e)||u(e)||a(e)?f:t[e];function N(){return o=0,i(n)&&(r++,c=0),s(n)&&n++,n++,c++,t[n]}return{index:()=>n,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+o),next:N,peek:function(){return s(n+o)&&o++,o++,t[n+o]},reset:function(){n=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=n+o;for(;e!==n;)N();o=0}}}const _=void 0,p=".",C="'";function T(e,r={}){const c=!1!==r.location,o=N(e),u=()=>o.index(),a=()=>t(o.line(),o.column(),o.index()),i=a(),E=u(),d={currentType:14,offset:E,startLoc:i,endLoc:i,lastType:14,lastOffset:E,lastStartLoc:i,lastEndLoc:i,braceNest:0,inLinked:!1,text:""},L=()=>d,{onError:T}=r;function k(e,t,r){e.endLoc=a(),e.currentType=t;const o={type:t};return c&&(o.loc=n(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const A=e=>k(e,14);function I(e,t){return e.currentChar()===t?(e.next(),t):(s.EXPECTED_TOKEN,a(),"")}function h(e){let t="";for(;e.currentPeek()===l||e.currentPeek()===f;)t+=e.currentPeek(),e.peek();return t}function P(e){const t=h(e);return e.skipToPeek(),t}function S(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function y(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=function(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function D(e){h(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function O(e,t=!0){const n=(t=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&t:"@"!==o&&o?"%"===o?(e.peek(),n(t,"%",!0)):"|"===o?!("%"!==r&&!c)||!(r===l||r===f):o===l?(e.peek(),n(!0,l,c)):o!==f||(e.peek(),n(!0,f,c)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function m(e,t){const n=e.currentChar();return n===_?_:t(n)?(e.next(),n):null}function b(e){return m(e,(e=>{const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}))}function x(e){return m(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}))}function U(e){return m(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}))}function v(e){let t="",n="";for(;t=x(e);)n+=t;return n}function R(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!O(e))break;t+=n,e.next()}else if(n===l||n===f)if(O(e))t+=n,e.next();else{if(D(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function M(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return g(e,t,4);case"U":return g(e,t,6);default:return s.UNKNOWN_ESCAPE_SEQUENCE,a(),""}}function g(e,t,n){I(e,t);let r="";for(let c=0;c<n;c++){const t=U(e);if(!t){s.INVALID_UNICODE_ESCAPE_SEQUENCE,a(),e.currentChar();break}r+=t}return`\\${t}${r}`}function X(e){P(e);const t=I(e,"|");return P(e),t}function Y(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(s.NOT_ALLOW_NEST_PLACEHOLDER,a()),e.next(),n=k(t,2,"{"),P(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(s.EMPTY_PLACEHOLDER,a()),e.next(),n=k(t,3,"}"),t.braceNest--,t.braceNest>0&&P(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=K(e,t)||A(t),t.braceNest=0,n;default:let r=!0,c=!0,o=!0;if(D(e))return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=k(t,1,X(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return s.UNTERMINATED_CLOSING_BRACE,a(),t.braceNest=0,w(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=S(e.currentPeek());return e.resetPeek(),r}(e,t))return n=k(t,5,function(e){P(e);let t="",n="";for(;t=b(e);)n+=t;return e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),n}(e)),P(e),n;if(c=y(e,t))return n=k(t,6,function(e){P(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${v(e)}`):t+=v(e),e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),t}(e)),P(e),n;if(o=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=e.currentPeek()===C;return e.resetPeek(),r}(e,t))return n=k(t,7,function(e){P(e),I(e,"'");let t="",n="";const r=e=>e!==C&&e!==f;for(;t=m(e,r);)n+="\\"===t?M(e):t;const c=e.currentChar();return c===f||c===_?(s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,a(),c===f&&(e.next(),I(e,"'")),n):(I(e,"'"),n)}(e)),P(e),n;if(!r&&!c&&!o)return n=k(t,13,function(e){P(e);let t="",n="";const r=e=>"{"!==e&&"}"!==e&&e!==l&&e!==f;for(;t=m(e,r);)n+=t;return n}(e)),s.INVALID_TOKEN_IN_PLACEHOLDER,a(),n.value,P(e),n}return n}function K(e,t){const{currentType:n}=t;let r=null;const c=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||c!==f&&c!==l||(s.INVALID_LINKED_FORMAT,a()),c){case"@":return e.next(),r=k(t,8,"@"),t.inLinked=!0,r;case".":return P(e),e.next(),k(t,9,".");case":":return P(e),e.next(),k(t,10,":");default:return D(e)?(r=k(t,1,X(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;h(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;h(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(P(e),K(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;h(e);const r=S(e.currentPeek());return e.resetPeek(),r}(e,t)?(P(e),k(t,12,function(e){let t="",n="";for(;t=b(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?S(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===l||!t)&&(t===f?(e.peek(),r()):S(t))},c=r();return e.resetPeek(),c}(e,t)?(P(e),"{"===c?Y(e,t)||r:k(t,11,function(e){const t=(n=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&"("!==c&&")"!==c&&c?c===l?r:c===f||c===p?(r+=c,e.next(),t(n,r)):(r+=c,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&(s.INVALID_LINKED_FORMAT,a()),t.braceNest=0,t.inLinked=!1,w(e,t))}}function w(e,t){let n={type:14};if(t.braceNest>0)return Y(e,t)||A(t);if(t.inLinked)return K(e,t)||A(t);switch(e.currentChar()){case"{":return Y(e,t)||A(t);case"}":return s.UNBALANCED_CLOSING_BRACE,a(),e.next(),k(t,3,"}");case"@":return K(e,t)||A(t);default:if(D(e))return n=k(t,1,X(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:c}=function(e){const t=h(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return c?k(t,0,R(e)):k(t,4,function(e){P(e);const t=e.currentChar();return"%"!==t&&(s.EXPECTED_TOKEN,a()),e.next(),"%"}(e));if(O(e))return k(t,0,R(e))}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:r}=d;return d.lastType=e,d.lastOffset=t,d.lastStartLoc=n,d.lastEndLoc=r,d.offset=u(),d.startLoc=a(),o.currentChar()===_?k(d,14):w(o,d)},currentOffset:u,currentPosition:a,context:L}}const k="parser",A=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function I(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function h(e={}){const t=!1!==e.location,{onError:n}=e;function c(e,n,r){const c={type:e};return t&&(c.start=n,c.end=n,c.loc={start:r,end:r}),c}function o(e,n,r,c){c&&(e.type=c),t&&(e.end=n,e.loc&&(e.loc.end=r))}function u(e,t){const n=e.context(),r=c(3,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(5,r,s);return u.index=parseInt(t,10),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function i(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(4,r,s);return u.key=t,e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function l(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(9,r,s);return u.value=t.replace(A,I),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function E(e){const t=e.context(),n=c(6,t.offset,t.startLoc);let r=e.nextToken();if(9===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:u}=n,a=c(8,r,u);return 12!==t.type?(s.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",o(a,r,u),{nextConsumeToken:t,node:a}):(null==t.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,P(t)),a.value=t.value||"",o(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=function(e,t){const n=e.context(),r=c(7,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=i(e,r.value||"");break;case 6:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=a(e,r.value||"");break;case 7:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=l(e,r.value||"");break;default:s.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const u=e.context(),E=c(7,u.offset,u.startLoc);return E.value="",o(E,u.offset,u.startLoc),n.key=E,o(n,u.offset,u.startLoc),{nextConsumeToken:r,node:n}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function f(e){const t=e.context(),n=c(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null;do{const c=r||e.nextToken();switch(r=null,c.type){case 0:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(u(e,c.value||""));break;case 6:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(a(e,c.value||""));break;case 5:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(i(e,c.value||""));break;case 7:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(l(e,c.value||""));break;case 8:const o=E(e);n.items.push(o.node),r=o.nextConsumeToken||null}}while(14!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function d(e){const t=e.context(),{offset:n,startLoc:r}=t,u=f(e);return 14===t.currentType?u:function(e,t,n,r){const u=e.context();let a=0===r.items.length;const i=c(1,t,n);i.cases=[],i.cases.push(r);do{const t=f(e);a||(a=0===t.items.length),i.cases.push(t)}while(14!==u.currentType);return a&&s.MUST_HAVE_MESSAGES_IN_PLURAL,o(i,e.currentOffset(),e.currentPosition()),i}(e,n,r,u)}return{parse:function(n){const u=T(n,r({},e)),a=u.context(),i=c(0,a.offset,a.startLoc);return t&&i.loc&&(i.loc.source=n),i.body=d(u),e.onCacheKey&&(i.cacheKey=e.onCacheKey(n)),14!==a.currentType&&(s.UNEXPECTED_LEXICAL_ANALYSIS,a.lastStartLoc,n[a.offset]),o(i,u.currentOffset(),u.currentPosition()),i}}}function P(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function S(e,t){for(let n=0;n<e.length;n++)y(e[n],t)}function y(e,t){switch(e.type){case 1:S(e.cases,t),t.helper("plural");break;case 2:S(e.items,t);break;case 6:y(e.key,t),t.helper("linked"),t.helper("type");break;case 5:t.helper("interpolate"),t.helper("list");break;case 4:t.helper("interpolate"),t.helper("named")}}function D(e,t={}){const n=function(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:e=>(n.helpers.add(e),e)}}(e);n.helper("normalize"),e.body&&y(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function O(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;n<e.items.length;n++){const r=e.items[n];if(3!==r.type&&9!==r.type)break;if(null==r.value)break;t.push(r.value)}if(t.length===e.items.length){e.static=o(t);for(let t=0;t<e.items.length;t++){const n=e.items[t];3!==n.type&&9!==n.type||delete n.value}}}}function m(e){switch(e.t=e.type,e.type){case 0:const t=e;m(t.body),t.b=t.body,delete t.body;break;case 1:const n=e,r=n.cases;for(let e=0;e<r.length;e++)m(r[e]);n.c=r,delete n.cases;break;case 2:const c=e,o=c.items;for(let e=0;e<o.length;e++)m(o[e]);c.i=o,delete c.items,c.static&&(c.s=c.static,delete c.static);break;case 3:case 9:case 8:case 7:const s=e;s.value&&(s.v=s.value,delete s.value);break;case 6:const u=e;m(u.key),u.k=u.key,delete u.key,u.modifier&&(m(u.modifier),u.m=u.modifier,delete u.modifier);break;case 5:const a=e;a.i=a.index,delete a.index;break;case 4:const i=e;i.k=i.key,delete i.key}delete e.type}function b(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?b(e,t.body):e.push("null")}(e,t);break;case 1:!function(e,t){const{helper:n,needIndent:r}=e;if(t.cases.length>1){e.push(`${n("plural")}([`),e.indent(r());const c=t.cases.length;for(let n=0;n<c&&(b(e,t.cases[n]),n!==c-1);n++)e.push(", ");e.deindent(r()),e.push("])")}}(e,t);break;case 2:!function(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const c=t.items.length;for(let o=0;o<c&&(b(e,t.items[o]),o!==c-1);o++)e.push(", ");e.deindent(r()),e.push("])")}(e,t);break;case 6:!function(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),b(e,t.key),t.modifier?(e.push(", "),b(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}(e,t);break;case 8:case 7:case 9:case 3:e.push(JSON.stringify(t.value),t);break;case 5:e.push(`${n("interpolate")}(${n("list")}(${t.index}))`,t);break;case 4:e.push(`${n("interpolate")}(${n("named")}(${JSON.stringify(t.key)}))`,t)}}return e.CompileErrorCodes=s,e.ERROR_DOMAIN=k,e.LOCATION_STUB={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}},e.baseCompile=function(e,t={}){const n=r({},t),s=!!n.jit,u=!!n.minify,a=null==n.optimize||n.optimize,i=h(n).parse(e);return s?(a&&function(e){const t=e.body;2===t.type?O(t):t.cases.forEach((e=>O(e)))}(i),u&&m(i),{ast:i,code:""}):(D(i,n),((e,t={})=>{const n=c(t.mode)?t.mode:"normal",r=c(t.filename)?t.filename:"message.intl",s=!!t.sourceMap,u=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",a=t.needIndent?t.needIndent:"arrow"!==n,i=e.helpers||[],l=function(e,t){const{sourceMap:n,filename:r,breakLineCode:c,needIndent:o}=t,s=!1!==t.location,u={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:c,needIndent:o,indentLevel:0};function a(e,t){u.code+=e}function i(e,t=!0){const n=t?c:"";a(o?n+" ".repeat(e):n)}return s&&e.loc&&(u.source=e.loc.source),{context:()=>u,push:a,indent:function(e=!0){const t=++u.indentLevel;e&&i(t)},deindent:function(e=!0){const t=--u.indentLevel;e&&i(t)},newline:function(){i(u.indentLevel)},helper:e=>`_${e}`,needIndent:()=>u.needIndent}}(e,{mode:n,filename:r,sourceMap:s,breakLineCode:u,needIndent:a});l.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(a),i.length>0&&(l.push(`const { ${o(i.map((e=>`${e}: _${e}`)),", ")} } = ctx`),l.newline()),l.push("return "),b(l,e),l.deindent(a),l.push("}"),delete e.helpers;const{code:E,map:f}=l.context();return{ast:e,code:E,map:f?f.toJSON():void 0}})(i,n))},e.createCompileError=a,e.createLocation=n,e.createParser=h,e.createPosition=t,e.defaultOnError=function(e){throw e},e.detectHtmlTag=e=>i.test(e),e.errorMessages=u,e}({});
|
|
6
|
+
var IntlifyMessageCompiler=function(e){"use strict";function t(e,t,n){return{line:e,column:t,offset:n}}function n(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const r=Object.assign,c=e=>"string"==typeof e;function o(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const s={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17},u={[s.EXPECTED_TOKEN]:"Expected token: '{0}'",[s.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[s.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[s.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[s.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[s.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[s.EMPTY_PLACEHOLDER]:"Empty placeholder",[s.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[s.INVALID_LINKED_FORMAT]:"Invalid linked format",[s.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[s.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[s.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[s.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[s.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[s.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function a(e,t,n={}){const{domain:r,messages:c,args:o}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}const i=/<\/?[\w\s="/.':;#-\/]+>/,l=" ",E="\r",f="\n",d=String.fromCharCode(8232),L=String.fromCharCode(8233);function N(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>t[e]===E&&t[e+1]===f,u=e=>t[e]===L,a=e=>t[e]===d,i=e=>s(e)||(e=>t[e]===f)(e)||u(e)||a(e),l=e=>s(e)||u(e)||a(e)?f:t[e];function N(){return o=0,i(n)&&(r++,c=0),s(n)&&n++,n++,c++,t[n]}return{index:()=>n,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+o),next:N,peek:function(){return s(n+o)&&o++,o++,t[n+o]},reset:function(){n=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=n+o;for(;e!==n;)N();o=0}}}const _=void 0,p=".",C="'";function k(e,r={}){const c=!1!==r.location,o=N(e),u=()=>o.index(),a=()=>t(o.line(),o.column(),o.index()),i=a(),E=u(),d={currentType:14,offset:E,startLoc:i,endLoc:i,lastType:14,lastOffset:E,lastStartLoc:i,lastEndLoc:i,braceNest:0,inLinked:!1,text:""},L=()=>d,{onError:k}=r;function T(e,t,r){e.endLoc=a(),e.currentType=t;const o={type:t};return c&&(o.loc=n(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const A=e=>T(e,14);function I(e,t){return e.currentChar()===t?(e.next(),t):(s.EXPECTED_TOKEN,a(),"")}function h(e){let t="";for(;e.currentPeek()===l||e.currentPeek()===f;)t+=e.currentPeek(),e.peek();return t}function P(e){const t=h(e);return e.skipToPeek(),t}function S(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function y(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=function(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function D(e){h(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function O(e,t=!0){const n=(t=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&t:"@"!==o&&o?"%"===o?(e.peek(),n(t,"%",!0)):"|"===o?!("%"!==r&&!c)||!(r===l||r===f):o===l?(e.peek(),n(!0,l,c)):o!==f||(e.peek(),n(!0,f,c)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function m(e,t){const n=e.currentChar();return n===_?_:t(n)?(e.next(),n):null}function b(e){return m(e,(e=>{const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}))}function x(e){return m(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}))}function U(e){return m(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}))}function v(e){let t="",n="";for(;t=x(e);)n+=t;return n}function R(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!O(e))break;t+=n,e.next()}else if(n===l||n===f)if(O(e))t+=n,e.next();else{if(D(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function M(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return g(e,t,4);case"U":return g(e,t,6);default:return s.UNKNOWN_ESCAPE_SEQUENCE,a(),""}}function g(e,t,n){I(e,t);let r="";for(let c=0;c<n;c++){const t=U(e);if(!t){s.INVALID_UNICODE_ESCAPE_SEQUENCE,a(),e.currentChar();break}r+=t}return`\\${t}${r}`}function X(e){P(e);const t=I(e,"|");return P(e),t}function Y(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(s.NOT_ALLOW_NEST_PLACEHOLDER,a()),e.next(),n=T(t,2,"{"),P(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(s.EMPTY_PLACEHOLDER,a()),e.next(),n=T(t,3,"}"),t.braceNest--,t.braceNest>0&&P(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=K(e,t)||A(t),t.braceNest=0,n;default:{let r=!0,c=!0,o=!0;if(D(e))return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=T(t,1,X(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return s.UNTERMINATED_CLOSING_BRACE,a(),t.braceNest=0,w(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=S(e.currentPeek());return e.resetPeek(),r}(e,t))return n=T(t,5,function(e){P(e);let t="",n="";for(;t=b(e);)n+=t;return e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),n}(e)),P(e),n;if(c=y(e,t))return n=T(t,6,function(e){P(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${v(e)}`):t+=v(e),e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),t}(e)),P(e),n;if(o=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=e.currentPeek()===C;return e.resetPeek(),r}(e,t))return n=T(t,7,function(e){P(e),I(e,"'");let t="",n="";const r=e=>e!==C&&e!==f;for(;t=m(e,r);)n+="\\"===t?M(e):t;const c=e.currentChar();return c===f||c===_?(s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,a(),c===f&&(e.next(),I(e,"'")),n):(I(e,"'"),n)}(e)),P(e),n;if(!r&&!c&&!o)return n=T(t,13,function(e){P(e);let t="",n="";const r=e=>"{"!==e&&"}"!==e&&e!==l&&e!==f;for(;t=m(e,r);)n+=t;return n}(e)),s.INVALID_TOKEN_IN_PLACEHOLDER,a(),n.value,P(e),n;break}}return n}function K(e,t){const{currentType:n}=t;let r=null;const c=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||c!==f&&c!==l||(s.INVALID_LINKED_FORMAT,a()),c){case"@":return e.next(),r=T(t,8,"@"),t.inLinked=!0,r;case".":return P(e),e.next(),T(t,9,".");case":":return P(e),e.next(),T(t,10,":");default:return D(e)?(r=T(t,1,X(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;h(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(8!==n&&12!==n)return!1;h(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(P(e),K(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;h(e);const r=S(e.currentPeek());return e.resetPeek(),r}(e,t)?(P(e),T(t,12,function(e){let t="",n="";for(;t=b(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(10!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?S(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===l||!t)&&(t===f?(e.peek(),r()):S(t))},c=r();return e.resetPeek(),c}(e,t)?(P(e),"{"===c?Y(e,t)||r:T(t,11,function(e){const t=(n=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&"("!==c&&")"!==c&&c?c===l?r:c===f||c===p?(r+=c,e.next(),t(n,r)):(r+=c,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&(s.INVALID_LINKED_FORMAT,a()),t.braceNest=0,t.inLinked=!1,w(e,t))}}function w(e,t){let n={type:14};if(t.braceNest>0)return Y(e,t)||A(t);if(t.inLinked)return K(e,t)||A(t);switch(e.currentChar()){case"{":return Y(e,t)||A(t);case"}":return s.UNBALANCED_CLOSING_BRACE,a(),e.next(),T(t,3,"}");case"@":return K(e,t)||A(t);default:{if(D(e))return n=T(t,1,X(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:c}=function(e){const t=h(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return c?T(t,0,R(e)):T(t,4,function(e){P(e);const t=e.currentChar();return"%"!==t&&(s.EXPECTED_TOKEN,a()),e.next(),"%"}(e));if(O(e))return T(t,0,R(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:r}=d;return d.lastType=e,d.lastOffset=t,d.lastStartLoc=n,d.lastEndLoc=r,d.offset=u(),d.startLoc=a(),o.currentChar()===_?T(d,14):w(o,d)},currentOffset:u,currentPosition:a,context:L}}const T="parser",A=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function I(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(t||n,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function h(e={}){const t=!1!==e.location,{onError:n}=e;function c(e,n,r){const c={type:e};return t&&(c.start=n,c.end=n,c.loc={start:r,end:r}),c}function o(e,n,r,c){c&&(e.type=c),t&&(e.end=n,e.loc&&(e.loc.end=r))}function u(e,t){const n=e.context(),r=c(3,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(5,r,s);return u.index=parseInt(t,10),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function i(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(4,r,s);return u.key=t,e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function l(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(9,r,s);return u.value=t.replace(A,I),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function E(e){const t=e.context(),n=c(6,t.offset,t.startLoc);let r=e.nextToken();if(9===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:u}=n,a=c(8,r,u);return 12!==t.type?(s.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",o(a,r,u),{nextConsumeToken:t,node:a}):(null==t.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,P(t)),a.value=t.value||"",o(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=function(e,t){const n=e.context(),r=c(7,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=i(e,r.value||"");break;case 6:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=a(e,r.value||"");break;case 7:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(r)),n.key=l(e,r.value||"");break;default:{s.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const u=e.context(),a=c(7,u.offset,u.startLoc);return a.value="",o(a,u.offset,u.startLoc),n.key=a,o(n,u.offset,u.startLoc),{nextConsumeToken:r,node:n}}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function f(e){const t=e.context(),n=c(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null;do{const c=r||e.nextToken();switch(r=null,c.type){case 0:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(u(e,c.value||""));break;case 6:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(a(e,c.value||""));break;case 5:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(i(e,c.value||""));break;case 7:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,P(c)),n.items.push(l(e,c.value||""));break;case 8:{const t=E(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function d(e){const t=e.context(),{offset:n,startLoc:r}=t,u=f(e);return 14===t.currentType?u:function(e,t,n,r){const u=e.context();let a=0===r.items.length;const i=c(1,t,n);i.cases=[],i.cases.push(r);do{const t=f(e);a||(a=0===t.items.length),i.cases.push(t)}while(14!==u.currentType);return a&&s.MUST_HAVE_MESSAGES_IN_PLURAL,o(i,e.currentOffset(),e.currentPosition()),i}(e,n,r,u)}return{parse:function(n){const u=k(n,r({},e)),a=u.context(),i=c(0,a.offset,a.startLoc);return t&&i.loc&&(i.loc.source=n),i.body=d(u),e.onCacheKey&&(i.cacheKey=e.onCacheKey(n)),14!==a.currentType&&(s.UNEXPECTED_LEXICAL_ANALYSIS,a.lastStartLoc,n[a.offset]),o(i,u.currentOffset(),u.currentPosition()),i}}}function P(e){if(14===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function S(e,t){for(let n=0;n<e.length;n++)y(e[n],t)}function y(e,t){switch(e.type){case 1:S(e.cases,t),t.helper("plural");break;case 2:S(e.items,t);break;case 6:y(e.key,t),t.helper("linked"),t.helper("type");break;case 5:t.helper("interpolate"),t.helper("list");break;case 4:t.helper("interpolate"),t.helper("named")}}function D(e,t={}){const n=function(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:e=>(n.helpers.add(e),e)}}(e);n.helper("normalize"),e.body&&y(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function O(e){if(1===e.items.length){const t=e.items[0];3!==t.type&&9!==t.type||(e.static=t.value,delete t.value)}else{const t=[];for(let n=0;n<e.items.length;n++){const r=e.items[n];if(3!==r.type&&9!==r.type)break;if(null==r.value)break;t.push(r.value)}if(t.length===e.items.length){e.static=o(t);for(let t=0;t<e.items.length;t++){const n=e.items[t];3!==n.type&&9!==n.type||delete n.value}}}}function m(e){switch(e.t=e.type,e.type){case 0:{const t=e;m(t.body),t.b=t.body,delete t.body;break}case 1:{const t=e,n=t.cases;for(let e=0;e<n.length;e++)m(n[e]);t.c=n,delete t.cases;break}case 2:{const t=e,n=t.items;for(let e=0;e<n.length;e++)m(n[e]);t.i=n,delete t.items,t.static&&(t.s=t.static,delete t.static);break}case 3:case 9:case 8:case 7:{const t=e;t.value&&(t.v=t.value,delete t.value);break}case 6:{const t=e;m(t.key),t.k=t.key,delete t.key,t.modifier&&(m(t.modifier),t.m=t.modifier,delete t.modifier);break}case 5:{const t=e;t.i=t.index,delete t.index;break}case 4:{const t=e;t.k=t.key,delete t.key;break}}delete e.type}function b(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?b(e,t.body):e.push("null")}(e,t);break;case 1:!function(e,t){const{helper:n,needIndent:r}=e;if(t.cases.length>1){e.push(`${n("plural")}([`),e.indent(r());const c=t.cases.length;for(let n=0;n<c&&(b(e,t.cases[n]),n!==c-1);n++)e.push(", ");e.deindent(r()),e.push("])")}}(e,t);break;case 2:!function(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const c=t.items.length;for(let o=0;o<c&&(b(e,t.items[o]),o!==c-1);o++)e.push(", ");e.deindent(r()),e.push("])")}(e,t);break;case 6:!function(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),b(e,t.key),t.modifier?(e.push(", "),b(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}(e,t);break;case 8:case 7:case 9:case 3:e.push(JSON.stringify(t.value),t);break;case 5:e.push(`${n("interpolate")}(${n("list")}(${t.index}))`,t);break;case 4:e.push(`${n("interpolate")}(${n("named")}(${JSON.stringify(t.key)}))`,t)}}return e.CompileErrorCodes=s,e.ERROR_DOMAIN=T,e.LOCATION_STUB={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}},e.baseCompile=function(e,t={}){const n=r({},t),s=!!n.jit,u=!!n.minify,a=null==n.optimize||n.optimize,i=h(n).parse(e);return s?(a&&function(e){const t=e.body;2===t.type?O(t):t.cases.forEach((e=>O(e)))}(i),u&&m(i),{ast:i,code:""}):(D(i,n),((e,t={})=>{const n=c(t.mode)?t.mode:"normal",r=c(t.filename)?t.filename:"message.intl",s=!!t.sourceMap,u=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",a=t.needIndent?t.needIndent:"arrow"!==n,i=e.helpers||[],l=function(e,t){const{sourceMap:n,filename:r,breakLineCode:c,needIndent:o}=t,s=!1!==t.location,u={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:c,needIndent:o,indentLevel:0};function a(e,t){u.code+=e}function i(e,t=!0){const n=t?c:"";a(o?n+" ".repeat(e):n)}return s&&e.loc&&(u.source=e.loc.source),{context:()=>u,push:a,indent:function(e=!0){const t=++u.indentLevel;e&&i(t)},deindent:function(e=!0){const t=--u.indentLevel;e&&i(t)},newline:function(){i(u.indentLevel)},helper:e=>`_${e}`,needIndent:()=>u.needIndent}}(e,{mode:n,filename:r,sourceMap:s,breakLineCode:u,needIndent:a});l.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(a),i.length>0&&(l.push(`const { ${o(i.map((e=>`${e}: _${e}`)),", ")} } = ctx`),l.newline()),l.push("return "),b(l,e),l.deindent(a),l.push("}"),delete e.helpers;const{code:E,map:f}=l.context();return{ast:e,code:E,map:f?f.toJSON():void 0}})(i,n))},e.createCompileError=a,e.createLocation=n,e.createParser=h,e.createPosition=t,e.defaultOnError=function(e){throw e},e.detectHtmlTag=e=>i.test(e),e.errorMessages=u,e}({});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.11.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -87,6 +87,7 @@ function defaultOnError(error) {
|
|
|
87
87
|
throw error;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// eslint-disable-next-line no-useless-escape
|
|
90
91
|
const RE_HTML_TAG = /<\/?[\w\s="/.':;#-\/]+>/;
|
|
91
92
|
const detectHtmlTag = (source) => RE_HTML_TAG.test(source);
|
|
92
93
|
|
|
@@ -460,6 +461,7 @@ function createTokenizer(source, options = {}) {
|
|
|
460
461
|
}
|
|
461
462
|
function readText(scnr) {
|
|
462
463
|
let buf = '';
|
|
464
|
+
// eslint-disable-next-line no-constant-condition
|
|
463
465
|
while (true) {
|
|
464
466
|
const ch = scnr.currentChar();
|
|
465
467
|
if (ch === "{" /* TokenChars.BraceLeft */ ||
|
|
@@ -527,6 +529,7 @@ function createTokenizer(source, options = {}) {
|
|
|
527
529
|
}
|
|
528
530
|
function readLiteral(scnr) {
|
|
529
531
|
skipSpaces(scnr);
|
|
532
|
+
// eslint-disable-next-line no-useless-escape
|
|
530
533
|
eat(scnr, `\'`);
|
|
531
534
|
let ch = '';
|
|
532
535
|
let literal = '';
|
|
@@ -545,10 +548,12 @@ function createTokenizer(source, options = {}) {
|
|
|
545
548
|
// TODO: Is it correct really?
|
|
546
549
|
if (current === CHAR_LF) {
|
|
547
550
|
scnr.next();
|
|
551
|
+
// eslint-disable-next-line no-useless-escape
|
|
548
552
|
eat(scnr, `\'`);
|
|
549
553
|
}
|
|
550
554
|
return literal;
|
|
551
555
|
}
|
|
556
|
+
// eslint-disable-next-line no-useless-escape
|
|
552
557
|
eat(scnr, `\'`);
|
|
553
558
|
return literal;
|
|
554
559
|
}
|
|
@@ -556,7 +561,7 @@ function createTokenizer(source, options = {}) {
|
|
|
556
561
|
const ch = scnr.currentChar();
|
|
557
562
|
switch (ch) {
|
|
558
563
|
case '\\':
|
|
559
|
-
case `\'`:
|
|
564
|
+
case `\'`: // eslint-disable-line no-useless-escape
|
|
560
565
|
scnr.next();
|
|
561
566
|
return `\\${ch}`;
|
|
562
567
|
case 'u':
|
|
@@ -670,7 +675,7 @@ function createTokenizer(source, options = {}) {
|
|
|
670
675
|
token = readTokenInLinked(scnr, context) || getEndToken(context);
|
|
671
676
|
context.braceNest = 0;
|
|
672
677
|
return token;
|
|
673
|
-
default:
|
|
678
|
+
default: {
|
|
674
679
|
let validNamedIdentifier = true;
|
|
675
680
|
let validListIdentifier = true;
|
|
676
681
|
let validLiteral = true;
|
|
@@ -715,6 +720,7 @@ function createTokenizer(source, options = {}) {
|
|
|
715
720
|
return token;
|
|
716
721
|
}
|
|
717
722
|
break;
|
|
723
|
+
}
|
|
718
724
|
}
|
|
719
725
|
return token;
|
|
720
726
|
}
|
|
@@ -798,7 +804,7 @@ function createTokenizer(source, options = {}) {
|
|
|
798
804
|
return getToken(context, 3 /* TokenTypes.BraceRight */, "}" /* TokenChars.BraceRight */);
|
|
799
805
|
case "@" /* TokenChars.LinkedAlias */:
|
|
800
806
|
return readTokenInLinked(scnr, context) || getEndToken(context);
|
|
801
|
-
default:
|
|
807
|
+
default: {
|
|
802
808
|
if (isPluralStart(scnr)) {
|
|
803
809
|
token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr));
|
|
804
810
|
// reset
|
|
@@ -816,6 +822,7 @@ function createTokenizer(source, options = {}) {
|
|
|
816
822
|
return getToken(context, 0 /* TokenTypes.Text */, readText(scnr));
|
|
817
823
|
}
|
|
818
824
|
break;
|
|
825
|
+
}
|
|
819
826
|
}
|
|
820
827
|
return token;
|
|
821
828
|
}
|
|
@@ -847,7 +854,9 @@ function fromEscapeSequence(match, codePoint4, codePoint6) {
|
|
|
847
854
|
switch (match) {
|
|
848
855
|
case `\\\\`:
|
|
849
856
|
return `\\`;
|
|
857
|
+
// eslint-disable-next-line no-useless-escape
|
|
850
858
|
case `\\\'`:
|
|
859
|
+
// eslint-disable-next-line no-useless-escape
|
|
851
860
|
return `\'`;
|
|
852
861
|
default: {
|
|
853
862
|
const codePoint = parseInt(codePoint4 || codePoint6, 16);
|
|
@@ -1005,7 +1014,7 @@ function createParser(options = {}) {
|
|
|
1005
1014
|
}
|
|
1006
1015
|
linkedNode.key = parseLiteral(tokenizer, token.value || '');
|
|
1007
1016
|
break;
|
|
1008
|
-
default:
|
|
1017
|
+
default: {
|
|
1009
1018
|
// empty key
|
|
1010
1019
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY, context.lastStartLoc, 0);
|
|
1011
1020
|
const nextContext = tokenizer.context();
|
|
@@ -1018,6 +1027,7 @@ function createParser(options = {}) {
|
|
|
1018
1027
|
nextConsumeToken: token,
|
|
1019
1028
|
node: linkedNode
|
|
1020
1029
|
};
|
|
1030
|
+
}
|
|
1021
1031
|
}
|
|
1022
1032
|
endNode(linkedNode, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1023
1033
|
return {
|
|
@@ -1063,11 +1073,12 @@ function createParser(options = {}) {
|
|
|
1063
1073
|
}
|
|
1064
1074
|
node.items.push(parseLiteral(tokenizer, token.value || ''));
|
|
1065
1075
|
break;
|
|
1066
|
-
case 8 /* TokenTypes.LinkedAlias */:
|
|
1076
|
+
case 8 /* TokenTypes.LinkedAlias */: {
|
|
1067
1077
|
const parsed = parseLinked(tokenizer);
|
|
1068
1078
|
node.items.push(parsed.node);
|
|
1069
1079
|
nextToken = parsed.nextConsumeToken || null;
|
|
1070
1080
|
break;
|
|
1081
|
+
}
|
|
1071
1082
|
}
|
|
1072
1083
|
} while (context.currentType !== 14 /* TokenTypes.EOF */ &&
|
|
1073
1084
|
context.currentType !== 1 /* TokenTypes.Pipe */);
|
|
@@ -1167,12 +1178,13 @@ function traverseNode(node, transformer) {
|
|
|
1167
1178
|
case 2 /* NodeTypes.Message */:
|
|
1168
1179
|
traverseNodes(node.items, transformer);
|
|
1169
1180
|
break;
|
|
1170
|
-
case 6 /* NodeTypes.Linked */:
|
|
1181
|
+
case 6 /* NodeTypes.Linked */: {
|
|
1171
1182
|
const linked = node;
|
|
1172
1183
|
traverseNode(linked.key, transformer);
|
|
1173
1184
|
transformer.helper("linked" /* HelperNameMap.LINKED */);
|
|
1174
1185
|
transformer.helper("type" /* HelperNameMap.TYPE */);
|
|
1175
1186
|
break;
|
|
1187
|
+
}
|
|
1176
1188
|
case 5 /* NodeTypes.List */:
|
|
1177
1189
|
transformer.helper("interpolate" /* HelperNameMap.INTERPOLATE */);
|
|
1178
1190
|
transformer.helper("list" /* HelperNameMap.LIST */);
|
|
@@ -1243,13 +1255,14 @@ const ERROR_DOMAIN$1 = 'minifier';
|
|
|
1243
1255
|
function minify(node) {
|
|
1244
1256
|
node.t = node.type;
|
|
1245
1257
|
switch (node.type) {
|
|
1246
|
-
case 0 /* NodeTypes.Resource */:
|
|
1258
|
+
case 0 /* NodeTypes.Resource */: {
|
|
1247
1259
|
const resource = node;
|
|
1248
1260
|
minify(resource.body);
|
|
1249
1261
|
resource.b = resource.body;
|
|
1250
1262
|
delete resource.body;
|
|
1251
1263
|
break;
|
|
1252
|
-
|
|
1264
|
+
}
|
|
1265
|
+
case 1 /* NodeTypes.Plural */: {
|
|
1253
1266
|
const plural = node;
|
|
1254
1267
|
const cases = plural.cases;
|
|
1255
1268
|
for (let i = 0; i < cases.length; i++) {
|
|
@@ -1258,7 +1271,8 @@ function minify(node) {
|
|
|
1258
1271
|
plural.c = cases;
|
|
1259
1272
|
delete plural.cases;
|
|
1260
1273
|
break;
|
|
1261
|
-
|
|
1274
|
+
}
|
|
1275
|
+
case 2 /* NodeTypes.Message */: {
|
|
1262
1276
|
const message = node;
|
|
1263
1277
|
const items = message.items;
|
|
1264
1278
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -1271,17 +1285,19 @@ function minify(node) {
|
|
|
1271
1285
|
delete message.static;
|
|
1272
1286
|
}
|
|
1273
1287
|
break;
|
|
1288
|
+
}
|
|
1274
1289
|
case 3 /* NodeTypes.Text */:
|
|
1275
1290
|
case 9 /* NodeTypes.Literal */:
|
|
1276
1291
|
case 8 /* NodeTypes.LinkedModifier */:
|
|
1277
|
-
case 7 /* NodeTypes.LinkedKey */:
|
|
1292
|
+
case 7 /* NodeTypes.LinkedKey */: {
|
|
1278
1293
|
const valueNode = node;
|
|
1279
1294
|
if (valueNode.value) {
|
|
1280
1295
|
valueNode.v = valueNode.value;
|
|
1281
1296
|
delete valueNode.value;
|
|
1282
1297
|
}
|
|
1283
1298
|
break;
|
|
1284
|
-
|
|
1299
|
+
}
|
|
1300
|
+
case 6 /* NodeTypes.Linked */: {
|
|
1285
1301
|
const linked = node;
|
|
1286
1302
|
minify(linked.key);
|
|
1287
1303
|
linked.k = linked.key;
|
|
@@ -1292,16 +1308,19 @@ function minify(node) {
|
|
|
1292
1308
|
delete linked.modifier;
|
|
1293
1309
|
}
|
|
1294
1310
|
break;
|
|
1295
|
-
|
|
1311
|
+
}
|
|
1312
|
+
case 5 /* NodeTypes.List */: {
|
|
1296
1313
|
const list = node;
|
|
1297
1314
|
list.i = list.index;
|
|
1298
1315
|
delete list.index;
|
|
1299
1316
|
break;
|
|
1300
|
-
|
|
1317
|
+
}
|
|
1318
|
+
case 4 /* NodeTypes.Named */: {
|
|
1301
1319
|
const named = node;
|
|
1302
1320
|
named.k = named.key;
|
|
1303
1321
|
delete named.key;
|
|
1304
1322
|
break;
|
|
1323
|
+
}
|
|
1305
1324
|
default:
|
|
1306
1325
|
if ((process.env.NODE_ENV !== 'production')) {
|
|
1307
1326
|
throw createCompileError(CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE, null, {
|
|
@@ -1314,6 +1333,8 @@ function minify(node) {
|
|
|
1314
1333
|
}
|
|
1315
1334
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
1316
1335
|
|
|
1336
|
+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
1337
|
+
/// <reference types="source-map-js" />
|
|
1317
1338
|
const ERROR_DOMAIN = 'parser';
|
|
1318
1339
|
function createCodeGenerator(ast, options) {
|
|
1319
1340
|
const { sourceMap, filename, breakLineCode, needIndent: _needIndent } = options;
|