@intlify/message-compiler 9.12.0 → 9.13.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 +48 -31
- package/dist/message-compiler.esm-browser.js +48 -31
- package/dist/message-compiler.esm-browser.prod.js +2 -2
- package/dist/message-compiler.global.js +48 -31
- package/dist/message-compiler.global.prod.js +2 -2
- package/dist/message-compiler.mjs +48 -31
- package/dist/message-compiler.node.mjs +48 -31
- package/dist/message-compiler.prod.cjs +48 -31
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -433,33 +433,46 @@ function createTokenizer(source, options = {}) {
|
|
|
433
433
|
}
|
|
434
434
|
return null;
|
|
435
435
|
}
|
|
436
|
+
function isIdentifier(ch) {
|
|
437
|
+
const cc = ch.charCodeAt(0);
|
|
438
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
439
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
440
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
441
|
+
cc === 95 || // _
|
|
442
|
+
cc === 36 // $
|
|
443
|
+
);
|
|
444
|
+
}
|
|
436
445
|
function takeIdentifierChar(scnr) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
return takeChar(scnr, isIdentifier);
|
|
447
|
+
}
|
|
448
|
+
function isNamedIdentifier(ch) {
|
|
449
|
+
const cc = ch.charCodeAt(0);
|
|
450
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
451
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
452
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
453
|
+
cc === 95 || // _
|
|
454
|
+
cc === 36 || // $
|
|
455
|
+
cc === 45 // -
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
function takeNamedIdentifierChar(scnr) {
|
|
459
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
460
|
+
}
|
|
461
|
+
function isDigit(ch) {
|
|
462
|
+
const cc = ch.charCodeAt(0);
|
|
463
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
447
464
|
}
|
|
448
465
|
function takeDigit(scnr) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
return
|
|
466
|
+
return takeChar(scnr, isDigit);
|
|
467
|
+
}
|
|
468
|
+
function isHexDigit(ch) {
|
|
469
|
+
const cc = ch.charCodeAt(0);
|
|
470
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
471
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
472
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
454
473
|
}
|
|
455
474
|
function takeHexDigit(scnr) {
|
|
456
|
-
|
|
457
|
-
const cc = ch.charCodeAt(0);
|
|
458
|
-
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
459
|
-
(cc >= 65 && cc <= 70) || // A-F
|
|
460
|
-
(cc >= 97 && cc <= 102)); // a-f
|
|
461
|
-
};
|
|
462
|
-
return takeChar(scnr, closure);
|
|
475
|
+
return takeChar(scnr, isHexDigit);
|
|
463
476
|
}
|
|
464
477
|
function getDigits(scnr) {
|
|
465
478
|
let ch = '';
|
|
@@ -523,7 +536,7 @@ function createTokenizer(source, options = {}) {
|
|
|
523
536
|
skipSpaces(scnr);
|
|
524
537
|
let ch = '';
|
|
525
538
|
let name = '';
|
|
526
|
-
while ((ch =
|
|
539
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
527
540
|
name += ch;
|
|
528
541
|
}
|
|
529
542
|
if (scnr.currentChar() === EOF) {
|
|
@@ -546,14 +559,16 @@ function createTokenizer(source, options = {}) {
|
|
|
546
559
|
}
|
|
547
560
|
return value;
|
|
548
561
|
}
|
|
562
|
+
function isLiteral(ch) {
|
|
563
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
564
|
+
}
|
|
549
565
|
function readLiteral(scnr) {
|
|
550
566
|
skipSpaces(scnr);
|
|
551
567
|
// eslint-disable-next-line no-useless-escape
|
|
552
568
|
eat(scnr, `\'`);
|
|
553
569
|
let ch = '';
|
|
554
570
|
let literal = '';
|
|
555
|
-
|
|
556
|
-
while ((ch = takeChar(scnr, fn))) {
|
|
571
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
557
572
|
if (ch === '\\') {
|
|
558
573
|
literal += readEscapeSequence(scnr);
|
|
559
574
|
}
|
|
@@ -605,15 +620,17 @@ function createTokenizer(source, options = {}) {
|
|
|
605
620
|
}
|
|
606
621
|
return `\\${unicode}${sequence}`;
|
|
607
622
|
}
|
|
623
|
+
function isInvalidIdentifier(ch) {
|
|
624
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
625
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
626
|
+
ch !== CHAR_SP &&
|
|
627
|
+
ch !== CHAR_LF);
|
|
628
|
+
}
|
|
608
629
|
function readInvalidIdentifier(scnr) {
|
|
609
630
|
skipSpaces(scnr);
|
|
610
631
|
let ch = '';
|
|
611
632
|
let identifiers = '';
|
|
612
|
-
|
|
613
|
-
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
614
|
-
ch !== CHAR_SP &&
|
|
615
|
-
ch !== CHAR_LF;
|
|
616
|
-
while ((ch = takeChar(scnr, closure))) {
|
|
633
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
617
634
|
identifiers += ch;
|
|
618
635
|
}
|
|
619
636
|
return identifiers;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -453,33 +453,46 @@ function createTokenizer(source, options = {}) {
|
|
|
453
453
|
}
|
|
454
454
|
return null;
|
|
455
455
|
}
|
|
456
|
+
function isIdentifier(ch) {
|
|
457
|
+
const cc = ch.charCodeAt(0);
|
|
458
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
459
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
460
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
461
|
+
cc === 95 || // _
|
|
462
|
+
cc === 36 // $
|
|
463
|
+
);
|
|
464
|
+
}
|
|
456
465
|
function takeIdentifierChar(scnr) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
466
|
+
return takeChar(scnr, isIdentifier);
|
|
467
|
+
}
|
|
468
|
+
function isNamedIdentifier(ch) {
|
|
469
|
+
const cc = ch.charCodeAt(0);
|
|
470
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
471
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
472
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
473
|
+
cc === 95 || // _
|
|
474
|
+
cc === 36 || // $
|
|
475
|
+
cc === 45 // -
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
function takeNamedIdentifierChar(scnr) {
|
|
479
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
480
|
+
}
|
|
481
|
+
function isDigit(ch) {
|
|
482
|
+
const cc = ch.charCodeAt(0);
|
|
483
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
467
484
|
}
|
|
468
485
|
function takeDigit(scnr) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
return
|
|
486
|
+
return takeChar(scnr, isDigit);
|
|
487
|
+
}
|
|
488
|
+
function isHexDigit(ch) {
|
|
489
|
+
const cc = ch.charCodeAt(0);
|
|
490
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
491
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
492
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
474
493
|
}
|
|
475
494
|
function takeHexDigit(scnr) {
|
|
476
|
-
|
|
477
|
-
const cc = ch.charCodeAt(0);
|
|
478
|
-
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
479
|
-
(cc >= 65 && cc <= 70) || // A-F
|
|
480
|
-
(cc >= 97 && cc <= 102)); // a-f
|
|
481
|
-
};
|
|
482
|
-
return takeChar(scnr, closure);
|
|
495
|
+
return takeChar(scnr, isHexDigit);
|
|
483
496
|
}
|
|
484
497
|
function getDigits(scnr) {
|
|
485
498
|
let ch = '';
|
|
@@ -543,7 +556,7 @@ function createTokenizer(source, options = {}) {
|
|
|
543
556
|
skipSpaces(scnr);
|
|
544
557
|
let ch = '';
|
|
545
558
|
let name = '';
|
|
546
|
-
while ((ch =
|
|
559
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
547
560
|
name += ch;
|
|
548
561
|
}
|
|
549
562
|
if (scnr.currentChar() === EOF) {
|
|
@@ -566,14 +579,16 @@ function createTokenizer(source, options = {}) {
|
|
|
566
579
|
}
|
|
567
580
|
return value;
|
|
568
581
|
}
|
|
582
|
+
function isLiteral(ch) {
|
|
583
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
584
|
+
}
|
|
569
585
|
function readLiteral(scnr) {
|
|
570
586
|
skipSpaces(scnr);
|
|
571
587
|
// eslint-disable-next-line no-useless-escape
|
|
572
588
|
eat(scnr, `\'`);
|
|
573
589
|
let ch = '';
|
|
574
590
|
let literal = '';
|
|
575
|
-
|
|
576
|
-
while ((ch = takeChar(scnr, fn))) {
|
|
591
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
577
592
|
if (ch === '\\') {
|
|
578
593
|
literal += readEscapeSequence(scnr);
|
|
579
594
|
}
|
|
@@ -625,15 +640,17 @@ function createTokenizer(source, options = {}) {
|
|
|
625
640
|
}
|
|
626
641
|
return `\\${unicode}${sequence}`;
|
|
627
642
|
}
|
|
643
|
+
function isInvalidIdentifier(ch) {
|
|
644
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
645
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
646
|
+
ch !== CHAR_SP &&
|
|
647
|
+
ch !== CHAR_LF);
|
|
648
|
+
}
|
|
628
649
|
function readInvalidIdentifier(scnr) {
|
|
629
650
|
skipSpaces(scnr);
|
|
630
651
|
let ch = '';
|
|
631
652
|
let identifiers = '';
|
|
632
|
-
|
|
633
|
-
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
634
|
-
ch !== CHAR_SP &&
|
|
635
|
-
ch !== CHAR_LF;
|
|
636
|
-
while ((ch = takeChar(scnr, closure))) {
|
|
653
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
637
654
|
identifiers += ch;
|
|
638
655
|
}
|
|
639
656
|
return identifiers;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
const LOCATION_STUB={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}};function createPosition(e,t,n){return{line:e,column:t,offset:n}}function createLocation(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const assign=Object.assign,isString=e=>"string"==typeof e;function join(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const CompileWarnCodes={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2},warnMessages={[CompileWarnCodes.USE_MODULO_SYNTAX]:"Use modulo before '{{0}}'."};function createCompileWarn(e,t,...n){const r={message:String(e),code:e};return t&&(r.location=t),r}const CompileErrorCodes={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},errorMessages={[CompileErrorCodes.EXPECTED_TOKEN]:"Expected token: '{0}'",[CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[CompileErrorCodes.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[CompileErrorCodes.EMPTY_PLACEHOLDER]:"Empty placeholder",[CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[CompileErrorCodes.INVALID_LINKED_FORMAT]:"Invalid linked format",[CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function createCompileError(e,t,n={}){const{domain:r,messages:o,args:s}=n,c=new SyntaxError(String(e));return c.code=e,t&&(c.location=t),c.domain=r,c}function defaultOnError(e){throw e}const RE_HTML_TAG=/<\/?[\w\s="/.':;#-\/]+>/,detectHtmlTag=e=>RE_HTML_TAG.test(e),CHAR_SP=" ",CHAR_CR="\r",CHAR_LF="\n",CHAR_LS=String.fromCharCode(8232),CHAR_PS=String.fromCharCode(8233);function createScanner(e){const t=e;let n=0,r=1,o=1,s=0;const c=e=>t[e]===CHAR_CR&&t[e+1]===CHAR_LF,a=e=>t[e]===CHAR_PS,i=e=>t[e]===CHAR_LS,u=e=>c(e)||(e=>t[e]===CHAR_LF)(e)||a(e)||i(e),l=e=>c(e)||a(e)||i(e)?CHAR_LF:t[e];function E(){return s=0,u(n)&&(r++,o=0),c(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>s,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+s),next:E,peek:function(){return c(n+s)&&s++,s++,t[n+s]},reset:function(){n=0,r=1,o=1,s=0},resetPeek:function(e=0){s=e},skipToPeek:function(){const e=n+s;for(;e!==n;)E();s=0}}}const EOF=void 0,DOT=".",LITERAL_DELIMITER="'",ERROR_DOMAIN$1="tokenizer";function createTokenizer(e,t={}){const n=!1!==t.location,r=createScanner(e),o=()=>r.index(),s=()=>createPosition(r.line(),r.column(),r.index()),c=s(),a=o(),i={currentType:14,offset:a,startLoc:c,endLoc:c,lastType:14,lastOffset:a,lastStartLoc:c,lastEndLoc:c,braceNest:0,inLinked:!1,text:""},u=()=>i,{onError:l}=t;function E(e,t,r){e.endLoc=s(),e.currentType=t;const o={type:t};return n&&(o.loc=createLocation(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const C=e=>E(e,14);function d(e,t){return e.currentChar()===t?(e.next(),t):(CompileErrorCodes.EXPECTED_TOKEN,s(),"")}function f(e){let t="";for(;e.currentPeek()===CHAR_SP||e.currentPeek()===CHAR_LF;)t+=e.currentPeek(),e.peek();return t}function p(e){const t=f(e);return e.skipToPeek(),t}function _(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function L(e,t){const{currentType:n}=t;if(2!==n)return!1;f(e);const r=function(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function N(e){f(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function A(e,t=!0){const n=(t=!1,r="",o=!1)=>{const s=e.currentPeek();return"{"===s?"%"!==r&&t:"@"!==s&&s?"%"===s?(e.peek(),n(t,"%",!0)):"|"===s?!("%"!==r&&!o)||!(r===CHAR_SP||r===CHAR_LF):s===CHAR_SP?(e.peek(),n(!0,CHAR_SP,o)):s!==CHAR_LF||(e.peek(),n(!0,CHAR_LF,o)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function T(e,t){const n=e.currentChar();return n===EOF?EOF:t(n)?(e.next(),n):null}function m(e){return T(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 k(e){return T(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}))}function I(e){return T(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}))}function S(e){let t="",n="";for(;t=k(e);)n+=t;return n}function P(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!A(e))break;t+=n,e.next()}else if(n===CHAR_SP||n===CHAR_LF)if(A(e))t+=n,e.next();else{if(N(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function O(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return h(e,t,4);case"U":return h(e,t,6);default:return CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE,s(),""}}function h(e,t,n){d(e,t);let r="";for(let o=0;o<n;o++){const t=I(e);if(!t){CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE,s(),e.currentChar();break}r+=t}return`\\${t}${r}`}function D(e){p(e);const t=d(e,"|");return p(e),t}function y(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER,s()),e.next(),n=E(t,2,"{"),p(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(CompileErrorCodes.EMPTY_PLACEHOLDER,s()),e.next(),n=E(t,3,"}"),t.braceNest--,t.braceNest>0&&p(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n=R(e,t)||C(t),t.braceNest=0,n;default:{let r=!0,o=!0,c=!0;if(N(e))return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n=E(t,1,D(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s(),t.braceNest=0,g(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;f(e);const r=_(e.currentPeek());return e.resetPeek(),r}(e,t))return n=E(t,5,function(e){p(e);let t="",n="";for(;t=m(e);)n+=t;return e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n}(e)),p(e),n;if(o=L(e,t))return n=E(t,6,function(e){p(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${S(e)}`):t+=S(e),e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),t}(e)),p(e),n;if(c=function(e,t){const{currentType:n}=t;if(2!==n)return!1;f(e);const r=e.currentPeek()===LITERAL_DELIMITER;return e.resetPeek(),r}(e,t))return n=E(t,7,function(e){p(e),d(e,"'");let t="",n="";const r=e=>e!==LITERAL_DELIMITER&&e!==CHAR_LF;for(;t=T(e,r);)n+="\\"===t?O(e):t;const o=e.currentChar();return o===CHAR_LF||o===EOF?(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,s(),o===CHAR_LF&&(e.next(),d(e,"'")),n):(d(e,"'"),n)}(e)),p(e),n;if(!r&&!o&&!c)return n=E(t,13,function(e){p(e);let t="",n="";const r=e=>"{"!==e&&"}"!==e&&e!==CHAR_SP&&e!==CHAR_LF;for(;t=T(e,r);)n+=t;return n}(e)),CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,s(),n.value,p(e),n;break}}return n}function R(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||o!==CHAR_LF&&o!==CHAR_SP||(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),o){case"@":return e.next(),r=E(t,8,"@"),t.inLinked=!0,r;case".":return p(e),e.next(),E(t,9,".");case":":return p(e),e.next(),E(t,10,":");default:return N(e)?(r=E(t,1,D(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;f(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;f(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(p(e),R(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;f(e);const r=_(e.currentPeek());return e.resetPeek(),r}(e,t)?(p(e),E(t,12,function(e){let t="",n="";for(;t=m(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?_(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===CHAR_SP||!t)&&(t===CHAR_LF?(e.peek(),r()):_(t))},o=r();return e.resetPeek(),o}(e,t)?(p(e),"{"===o?y(e,t)||r:E(t,11,function(e){const t=(n=!1,r)=>{const o=e.currentChar();return"{"!==o&&"%"!==o&&"@"!==o&&"|"!==o&&"("!==o&&")"!==o&&o?o===CHAR_SP?r:o===CHAR_LF||o===DOT?(r+=o,e.next(),t(n,r)):(r+=o,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),t.braceNest=0,t.inLinked=!1,g(e,t))}}function g(e,t){let n={type:14};if(t.braceNest>0)return y(e,t)||C(t);if(t.inLinked)return R(e,t)||C(t);switch(e.currentChar()){case"{":return y(e,t)||C(t);case"}":return CompileErrorCodes.UNBALANCED_CLOSING_BRACE,s(),e.next(),E(t,3,"}");case"@":return R(e,t)||C(t);default:{if(N(e))return n=E(t,1,D(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:o}=function(e){const t=f(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return o?E(t,0,P(e)):E(t,4,function(e){p(e);const t=e.currentChar();return"%"!==t&&(CompileErrorCodes.EXPECTED_TOKEN,s()),e.next(),"%"}(e));if(A(e))return E(t,0,P(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:c}=i;return i.lastType=e,i.lastOffset=t,i.lastStartLoc=n,i.lastEndLoc=c,i.offset=o(),i.startLoc=s(),r.currentChar()===EOF?E(i,14):g(r,i)},currentOffset:o,currentPosition:s,context:u}}const ERROR_DOMAIN="parser",KNOWN_ESCAPES=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function fromEscapeSequence(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 createParser(e={}){const t=!1!==e.location,{onError:n,onWarn:r}=e;function o(e,n,r){const o={type:e};return t&&(o.start=n,o.end=n,o.loc={start:r,end:r}),o}function s(e,n,r,o){o&&(e.type=o),t&&(e.end=n,e.loc&&(e.loc.end=r))}function c(e,t){const n=e.context(),r=o(3,n.offset,n.startLoc);return r.value=t,s(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,a=o(5,r,c);return a.index=parseInt(t,10),e.nextToken(),s(a,e.currentOffset(),e.currentPosition()),a}function i(e,t,n){const r=e.context(),{lastOffset:c,lastStartLoc:a}=r,i=o(4,c,a);return i.key=t,!0===n&&(i.modulo=!0),e.nextToken(),s(i,e.currentOffset(),e.currentPosition()),i}function u(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,a=o(9,r,c);return a.value=t.replace(KNOWN_ESCAPES,fromEscapeSequence),e.nextToken(),s(a,e.currentOffset(),e.currentPosition()),a}function l(e){const t=e.context(),n=o(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:c}=n,a=o(8,r,c);return 12!==t.type?(CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",s(a,r,c),{nextConsumeToken:t,node:a}):(null==t.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,getTokenCaption(t)),a.value=t.value||"",s(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=function(e,t){const n=e.context(),r=o(7,n.offset,n.startLoc);return r.value=t,s(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=i(e,r.value||"");break;case 6:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=a(e,r.value||"");break;case 7:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=u(e,r.value||"");break;default:{CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const c=e.context(),a=o(7,c.offset,c.startLoc);return a.value="",s(a,c.offset,c.startLoc),n.key=a,s(n,c.offset,c.startLoc),{nextConsumeToken:r,node:n}}}return s(n,e.currentOffset(),e.currentPosition()),{node:n}}function E(e){const t=e.context(),n=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,E=null;do{const o=r||e.nextToken();switch(r=null,o.type){case 0:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(c(e,o.value||""));break;case 6:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(a(e,o.value||""));break;case 4:E=!0;break;case 5:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(i(e,o.value||"",!!E)),E&&(CompileWarnCodes.USE_MODULO_SYNTAX,t.lastStartLoc,getTokenCaption(o),E=null);break;case 7:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(u(e,o.value||""));break;case 8:{const t=l(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return s(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function C(e){const t=e.context(),{offset:n,startLoc:r}=t,c=E(e);return 14===t.currentType?c:function(e,t,n,r){const c=e.context();let a=0===r.items.length;const i=o(1,t,n);i.cases=[],i.cases.push(r);do{const t=E(e);a||(a=0===t.items.length),i.cases.push(t)}while(14!==c.currentType);return a&&CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL,s(i,e.currentOffset(),e.currentPosition()),i}(e,n,r,c)}return{parse:function(n){const r=createTokenizer(n,assign({},e)),c=r.context(),a=o(0,c.offset,c.startLoc);return t&&a.loc&&(a.loc.source=n),a.body=C(r),e.onCacheKey&&(a.cacheKey=e.onCacheKey(n)),14!==c.currentType&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,c.lastStartLoc,n[c.offset]),s(a,r.currentOffset(),r.currentPosition()),a}}}function getTokenCaption(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 createTransformer(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:e=>(n.helpers.add(e),e)}}function traverseNodes(e,t){for(let n=0;n<e.length;n++)traverseNode(e[n],t)}function traverseNode(e,t){switch(e.type){case 1:traverseNodes(e.cases,t),t.helper("plural");break;case 2:traverseNodes(e.items,t);break;case 6:traverseNode(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 transform(e,t={}){const n=createTransformer(e);n.helper("normalize"),e.body&&traverseNode(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function optimize(e){const t=e.body;return 2===t.type?optimizeMessageNode(t):t.cases.forEach((e=>optimizeMessageNode(e))),e}function optimizeMessageNode(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=join(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 minify(e){switch(e.t=e.type,e.type){case 0:{const t=e;minify(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++)minify(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++)minify(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;minify(t.key),t.k=t.key,delete t.key,t.modifier&&(minify(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 createCodeGenerator(e,t){const{sourceMap:n,filename:r,breakLineCode:o,needIndent:s}=t,c=!1!==t.location,a={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:o,needIndent:s,indentLevel:0};c&&e.loc&&(a.source=e.loc.source);function i(e,t){a.code+=e}function u(e,t=!0){const n=t?o:"";i(s?n+" ".repeat(e):n)}return{context:()=>a,push:i,indent:function(e=!0){const t=++a.indentLevel;e&&u(t)},deindent:function(e=!0){const t=--a.indentLevel;e&&u(t)},newline:function(){u(a.indentLevel)},helper:e=>`_${e}`,needIndent:()=>a.needIndent}}function generateLinkedNode(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),generateNode(e,t.key),t.modifier?(e.push(", "),generateNode(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}function generateMessageNode(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const o=t.items.length;for(let s=0;s<o&&(generateNode(e,t.items[s]),s!==o-1);s++)e.push(", ");e.deindent(r()),e.push("])")}function generatePluralNode(e,t){const{helper:n,needIndent:r}=e;if(t.cases.length>1){e.push(`${n("plural")}([`),e.indent(r());const o=t.cases.length;for(let n=0;n<o&&(generateNode(e,t.cases[n]),n!==o-1);n++)e.push(", ");e.deindent(r()),e.push("])")}}function generateResource(e,t){t.body?generateNode(e,t.body):e.push("null")}function generateNode(e,t){const{helper:n}=e;switch(t.type){case 0:generateResource(e,t);break;case 1:generatePluralNode(e,t);break;case 2:generateMessageNode(e,t);break;case 6:generateLinkedNode(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)}}const generate=(e,t={})=>{const n=isString(t.mode)?t.mode:"normal",r=isString(t.filename)?t.filename:"message.intl",o=!!t.sourceMap,s=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",c=t.needIndent?t.needIndent:"arrow"!==n,a=e.helpers||[],i=createCodeGenerator(e,{mode:n,filename:r,sourceMap:o,breakLineCode:s,needIndent:c});i.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),i.indent(c),a.length>0&&(i.push(`const { ${join(a.map((e=>`${e}: _${e}`)),", ")} } = ctx`),i.newline()),i.push("return "),generateNode(i,e),i.deindent(c),i.push("}"),delete e.helpers;const{code:u,map:l}=i.context();return{ast:e,code:u,map:l?l.toJSON():void 0}};function baseCompile(e,t={}){const n=assign({},t),r=!!n.jit,o=!!n.minify,s=null==n.optimize||n.optimize,c=createParser(n).parse(e);return r?(s&&optimize(c),o&&minify(c),{ast:c,code:""}):(transform(c,n),generate(c,n))}export{CompileErrorCodes,CompileWarnCodes,ERROR_DOMAIN,LOCATION_STUB,baseCompile,createCompileError,createCompileWarn,createLocation,createParser,createPosition,defaultOnError,detectHtmlTag,errorMessages,warnMessages};
|
|
6
|
+
const LOCATION_STUB={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}};function createPosition(e,t,n){return{line:e,column:t,offset:n}}function createLocation(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const assign=Object.assign,isString=e=>"string"==typeof e;function join(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const CompileWarnCodes={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2},warnMessages={[CompileWarnCodes.USE_MODULO_SYNTAX]:"Use modulo before '{{0}}'."};function createCompileWarn(e,t,...n){const r={message:String(e),code:e};return t&&(r.location=t),r}const CompileErrorCodes={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},errorMessages={[CompileErrorCodes.EXPECTED_TOKEN]:"Expected token: '{0}'",[CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[CompileErrorCodes.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[CompileErrorCodes.EMPTY_PLACEHOLDER]:"Empty placeholder",[CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[CompileErrorCodes.INVALID_LINKED_FORMAT]:"Invalid linked format",[CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function createCompileError(e,t,n={}){const{domain:r,messages:o,args:s}=n,c=new SyntaxError(String(e));return c.code=e,t&&(c.location=t),c.domain=r,c}function defaultOnError(e){throw e}const RE_HTML_TAG=/<\/?[\w\s="/.':;#-\/]+>/,detectHtmlTag=e=>RE_HTML_TAG.test(e),CHAR_SP=" ",CHAR_CR="\r",CHAR_LF="\n",CHAR_LS=String.fromCharCode(8232),CHAR_PS=String.fromCharCode(8233);function createScanner(e){const t=e;let n=0,r=1,o=1,s=0;const c=e=>t[e]===CHAR_CR&&t[e+1]===CHAR_LF,a=e=>t[e]===CHAR_PS,i=e=>t[e]===CHAR_LS,u=e=>c(e)||(e=>t[e]===CHAR_LF)(e)||a(e)||i(e),l=e=>c(e)||a(e)||i(e)?CHAR_LF:t[e];function E(){return s=0,u(n)&&(r++,o=0),c(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>s,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+s),next:E,peek:function(){return c(n+s)&&s++,s++,t[n+s]},reset:function(){n=0,r=1,o=1,s=0},resetPeek:function(e=0){s=e},skipToPeek:function(){const e=n+s;for(;e!==n;)E();s=0}}}const EOF=void 0,DOT=".",LITERAL_DELIMITER="'",ERROR_DOMAIN$1="tokenizer";function createTokenizer(e,t={}){const n=!1!==t.location,r=createScanner(e),o=()=>r.index(),s=()=>createPosition(r.line(),r.column(),r.index()),c=s(),a=o(),i={currentType:14,offset:a,startLoc:c,endLoc:c,lastType:14,lastOffset:a,lastStartLoc:c,lastEndLoc:c,braceNest:0,inLinked:!1,text:""},u=()=>i,{onError:l}=t;function E(e,t,r){e.endLoc=s(),e.currentType=t;const o={type:t};return n&&(o.loc=createLocation(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const C=e=>E(e,14);function f(e,t){return e.currentChar()===t?(e.next(),t):(CompileErrorCodes.EXPECTED_TOKEN,s(),"")}function d(e){let t="";for(;e.currentPeek()===CHAR_SP||e.currentPeek()===CHAR_LF;)t+=e.currentPeek(),e.peek();return t}function p(e){const t=d(e);return e.skipToPeek(),t}function _(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function L(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=function(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function N(e){d(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function A(e,t=!0){const n=(t=!1,r="",o=!1)=>{const s=e.currentPeek();return"{"===s?"%"!==r&&t:"@"!==s&&s?"%"===s?(e.peek(),n(t,"%",!0)):"|"===s?!("%"!==r&&!o)||!(r===CHAR_SP||r===CHAR_LF):s===CHAR_SP?(e.peek(),n(!0,CHAR_SP,o)):s!==CHAR_LF||(e.peek(),n(!0,CHAR_LF,o)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function T(e,t){const n=e.currentChar();return n===EOF?EOF:t(n)?(e.next(),n):null}function m(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function k(e){return T(e,m)}function I(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function S(e){return T(e,I)}function P(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function h(e){return T(e,P)}function O(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function D(e){return T(e,O)}function y(e){let t="",n="";for(;t=h(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(!A(e))break;t+=n,e.next()}else if(n===CHAR_SP||n===CHAR_LF)if(A(e))t+=n,e.next();else{if(N(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function g(e){return e!==LITERAL_DELIMITER&&e!==CHAR_LF}function U(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return b(e,t,4);case"U":return b(e,t,6);default:return CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE,s(),""}}function b(e,t,n){f(e,t);let r="";for(let o=0;o<n;o++){const t=D(e);if(!t){CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE,s(),e.currentChar();break}r+=t}return`\\${t}${r}`}function x(e){return"{"!==e&&"}"!==e&&e!==CHAR_SP&&e!==CHAR_LF}function M(e){p(e);const t=f(e,"|");return p(e),t}function v(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER,s()),e.next(),n=E(t,2,"{"),p(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(CompileErrorCodes.EMPTY_PLACEHOLDER,s()),e.next(),n=E(t,3,"}"),t.braceNest--,t.braceNest>0&&p(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n=H(e,t)||C(t),t.braceNest=0,n;default:{let r=!0,o=!0,c=!0;if(N(e))return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n=E(t,1,M(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s(),t.braceNest=0,X(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=_(e.currentPeek());return e.resetPeek(),r}(e,t))return n=E(t,5,function(e){p(e);let t="",n="";for(;t=S(e);)n+=t;return e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),n}(e)),p(e),n;if(o=L(e,t))return n=E(t,6,function(e){p(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${y(e)}`):t+=y(e),e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,s()),t}(e)),p(e),n;if(c=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=e.currentPeek()===LITERAL_DELIMITER;return e.resetPeek(),r}(e,t))return n=E(t,7,function(e){p(e),f(e,"'");let t="",n="";for(;t=T(e,g);)n+="\\"===t?U(e):t;const r=e.currentChar();return r===CHAR_LF||r===EOF?(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,s(),r===CHAR_LF&&(e.next(),f(e,"'")),n):(f(e,"'"),n)}(e)),p(e),n;if(!r&&!o&&!c)return n=E(t,13,function(e){p(e);let t="",n="";for(;t=T(e,x);)n+=t;return n}(e)),CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,s(),n.value,p(e),n;break}}return n}function H(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||o!==CHAR_LF&&o!==CHAR_SP||(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),o){case"@":return e.next(),r=E(t,8,"@"),t.inLinked=!0,r;case".":return p(e),e.next(),E(t,9,".");case":":return p(e),e.next(),E(t,10,":");default:return N(e)?(r=E(t,1,M(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(8!==n)return!1;d(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;d(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(p(e),H(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;d(e);const r=_(e.currentPeek());return e.resetPeek(),r}(e,t)?(p(e),E(t,12,function(e){let t="",n="";for(;t=k(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?_(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===CHAR_SP||!t)&&(t===CHAR_LF?(e.peek(),r()):_(t))},o=r();return e.resetPeek(),o}(e,t)?(p(e),"{"===o?v(e,t)||r:E(t,11,function(e){const t=(n=!1,r)=>{const o=e.currentChar();return"{"!==o&&"%"!==o&&"@"!==o&&"|"!==o&&"("!==o&&")"!==o&&o?o===CHAR_SP?r:o===CHAR_LF||o===DOT?(r+=o,e.next(),t(n,r)):(r+=o,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&(CompileErrorCodes.INVALID_LINKED_FORMAT,s()),t.braceNest=0,t.inLinked=!1,X(e,t))}}function X(e,t){let n={type:14};if(t.braceNest>0)return v(e,t)||C(t);if(t.inLinked)return H(e,t)||C(t);switch(e.currentChar()){case"{":return v(e,t)||C(t);case"}":return CompileErrorCodes.UNBALANCED_CLOSING_BRACE,s(),e.next(),E(t,3,"}");case"@":return H(e,t)||C(t);default:{if(N(e))return n=E(t,1,M(e)),t.braceNest=0,t.inLinked=!1,n;const{isModulo:r,hasSpace:o}=function(e){const t=d(e),n="%"===e.currentPeek()&&"{"===e.peek();return e.resetPeek(),{isModulo:n,hasSpace:t.length>0}}(e);if(r)return o?E(t,0,R(e)):E(t,4,function(e){p(e);const t=e.currentChar();return"%"!==t&&(CompileErrorCodes.EXPECTED_TOKEN,s()),e.next(),"%"}(e));if(A(e))return E(t,0,R(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:c}=i;return i.lastType=e,i.lastOffset=t,i.lastStartLoc=n,i.lastEndLoc=c,i.offset=o(),i.startLoc=s(),r.currentChar()===EOF?E(i,14):X(r,i)},currentOffset:o,currentPosition:s,context:u}}const ERROR_DOMAIN="parser",KNOWN_ESCAPES=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function fromEscapeSequence(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 createParser(e={}){const t=!1!==e.location,{onError:n,onWarn:r}=e;function o(e,n,r){const o={type:e};return t&&(o.start=n,o.end=n,o.loc={start:r,end:r}),o}function s(e,n,r,o){o&&(e.type=o),t&&(e.end=n,e.loc&&(e.loc.end=r))}function c(e,t){const n=e.context(),r=o(3,n.offset,n.startLoc);return r.value=t,s(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,a=o(5,r,c);return a.index=parseInt(t,10),e.nextToken(),s(a,e.currentOffset(),e.currentPosition()),a}function i(e,t,n){const r=e.context(),{lastOffset:c,lastStartLoc:a}=r,i=o(4,c,a);return i.key=t,!0===n&&(i.modulo=!0),e.nextToken(),s(i,e.currentOffset(),e.currentPosition()),i}function u(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,a=o(9,r,c);return a.value=t.replace(KNOWN_ESCAPES,fromEscapeSequence),e.nextToken(),s(a,e.currentOffset(),e.currentPosition()),a}function l(e){const t=e.context(),n=o(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:c}=n,a=o(8,r,c);return 12!==t.type?(CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",s(a,r,c),{nextConsumeToken:t,node:a}):(null==t.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,getTokenCaption(t)),a.value=t.value||"",s(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=function(e,t){const n=e.context(),r=o(7,n.offset,n.startLoc);return r.value=t,s(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=i(e,r.value||"");break;case 6:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=a(e,r.value||"");break;case 7:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.key=u(e,r.value||"");break;default:{CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const c=e.context(),a=o(7,c.offset,c.startLoc);return a.value="",s(a,c.offset,c.startLoc),n.key=a,s(n,c.offset,c.startLoc),{nextConsumeToken:r,node:n}}}return s(n,e.currentOffset(),e.currentPosition()),{node:n}}function E(e){const t=e.context(),n=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,E=null;do{const o=r||e.nextToken();switch(r=null,o.type){case 0:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(c(e,o.value||""));break;case 6:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(a(e,o.value||""));break;case 4:E=!0;break;case 5:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(i(e,o.value||"",!!E)),E&&(CompileWarnCodes.USE_MODULO_SYNTAX,t.lastStartLoc,getTokenCaption(o),E=null);break;case 7:null==o.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(o)),n.items.push(u(e,o.value||""));break;case 8:{const t=l(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return s(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function C(e){const t=e.context(),{offset:n,startLoc:r}=t,c=E(e);return 14===t.currentType?c:function(e,t,n,r){const c=e.context();let a=0===r.items.length;const i=o(1,t,n);i.cases=[],i.cases.push(r);do{const t=E(e);a||(a=0===t.items.length),i.cases.push(t)}while(14!==c.currentType);return a&&CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL,s(i,e.currentOffset(),e.currentPosition()),i}(e,n,r,c)}return{parse:function(n){const r=createTokenizer(n,assign({},e)),c=r.context(),a=o(0,c.offset,c.startLoc);return t&&a.loc&&(a.loc.source=n),a.body=C(r),e.onCacheKey&&(a.cacheKey=e.onCacheKey(n)),14!==c.currentType&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,c.lastStartLoc,n[c.offset]),s(a,r.currentOffset(),r.currentPosition()),a}}}function getTokenCaption(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 createTransformer(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:e=>(n.helpers.add(e),e)}}function traverseNodes(e,t){for(let n=0;n<e.length;n++)traverseNode(e[n],t)}function traverseNode(e,t){switch(e.type){case 1:traverseNodes(e.cases,t),t.helper("plural");break;case 2:traverseNodes(e.items,t);break;case 6:traverseNode(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 transform(e,t={}){const n=createTransformer(e);n.helper("normalize"),e.body&&traverseNode(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function optimize(e){const t=e.body;return 2===t.type?optimizeMessageNode(t):t.cases.forEach((e=>optimizeMessageNode(e))),e}function optimizeMessageNode(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=join(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 minify(e){switch(e.t=e.type,e.type){case 0:{const t=e;minify(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++)minify(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++)minify(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;minify(t.key),t.k=t.key,delete t.key,t.modifier&&(minify(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 createCodeGenerator(e,t){const{sourceMap:n,filename:r,breakLineCode:o,needIndent:s}=t,c=!1!==t.location,a={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:o,needIndent:s,indentLevel:0};c&&e.loc&&(a.source=e.loc.source);function i(e,t){a.code+=e}function u(e,t=!0){const n=t?o:"";i(s?n+" ".repeat(e):n)}return{context:()=>a,push:i,indent:function(e=!0){const t=++a.indentLevel;e&&u(t)},deindent:function(e=!0){const t=--a.indentLevel;e&&u(t)},newline:function(){u(a.indentLevel)},helper:e=>`_${e}`,needIndent:()=>a.needIndent}}function generateLinkedNode(e,t){const{helper:n}=e;e.push(`${n("linked")}(`),generateNode(e,t.key),t.modifier?(e.push(", "),generateNode(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}function generateMessageNode(e,t){const{helper:n,needIndent:r}=e;e.push(`${n("normalize")}([`),e.indent(r());const o=t.items.length;for(let s=0;s<o&&(generateNode(e,t.items[s]),s!==o-1);s++)e.push(", ");e.deindent(r()),e.push("])")}function generatePluralNode(e,t){const{helper:n,needIndent:r}=e;if(t.cases.length>1){e.push(`${n("plural")}([`),e.indent(r());const o=t.cases.length;for(let n=0;n<o&&(generateNode(e,t.cases[n]),n!==o-1);n++)e.push(", ");e.deindent(r()),e.push("])")}}function generateResource(e,t){t.body?generateNode(e,t.body):e.push("null")}function generateNode(e,t){const{helper:n}=e;switch(t.type){case 0:generateResource(e,t);break;case 1:generatePluralNode(e,t);break;case 2:generateMessageNode(e,t);break;case 6:generateLinkedNode(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)}}const generate=(e,t={})=>{const n=isString(t.mode)?t.mode:"normal",r=isString(t.filename)?t.filename:"message.intl",o=!!t.sourceMap,s=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",c=t.needIndent?t.needIndent:"arrow"!==n,a=e.helpers||[],i=createCodeGenerator(e,{mode:n,filename:r,sourceMap:o,breakLineCode:s,needIndent:c});i.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),i.indent(c),a.length>0&&(i.push(`const { ${join(a.map((e=>`${e}: _${e}`)),", ")} } = ctx`),i.newline()),i.push("return "),generateNode(i,e),i.deindent(c),i.push("}"),delete e.helpers;const{code:u,map:l}=i.context();return{ast:e,code:u,map:l?l.toJSON():void 0}};function baseCompile(e,t={}){const n=assign({},t),r=!!n.jit,o=!!n.minify,s=null==n.optimize||n.optimize,c=createParser(n).parse(e);return r?(s&&optimize(c),o&&minify(c),{ast:c,code:""}):(transform(c,n),generate(c,n))}export{CompileErrorCodes,CompileWarnCodes,ERROR_DOMAIN,LOCATION_STUB,baseCompile,createCompileError,createCompileWarn,createLocation,createParser,createPosition,defaultOnError,detectHtmlTag,errorMessages,warnMessages};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -456,33 +456,46 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
456
456
|
}
|
|
457
457
|
return null;
|
|
458
458
|
}
|
|
459
|
+
function isIdentifier(ch) {
|
|
460
|
+
const cc = ch.charCodeAt(0);
|
|
461
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
462
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
463
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
464
|
+
cc === 95 || // _
|
|
465
|
+
cc === 36 // $
|
|
466
|
+
);
|
|
467
|
+
}
|
|
459
468
|
function takeIdentifierChar(scnr) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
469
|
+
return takeChar(scnr, isIdentifier);
|
|
470
|
+
}
|
|
471
|
+
function isNamedIdentifier(ch) {
|
|
472
|
+
const cc = ch.charCodeAt(0);
|
|
473
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
474
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
475
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
476
|
+
cc === 95 || // _
|
|
477
|
+
cc === 36 || // $
|
|
478
|
+
cc === 45 // -
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
function takeNamedIdentifierChar(scnr) {
|
|
482
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
483
|
+
}
|
|
484
|
+
function isDigit(ch) {
|
|
485
|
+
const cc = ch.charCodeAt(0);
|
|
486
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
470
487
|
}
|
|
471
488
|
function takeDigit(scnr) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
return
|
|
489
|
+
return takeChar(scnr, isDigit);
|
|
490
|
+
}
|
|
491
|
+
function isHexDigit(ch) {
|
|
492
|
+
const cc = ch.charCodeAt(0);
|
|
493
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
494
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
495
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
477
496
|
}
|
|
478
497
|
function takeHexDigit(scnr) {
|
|
479
|
-
|
|
480
|
-
const cc = ch.charCodeAt(0);
|
|
481
|
-
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
482
|
-
(cc >= 65 && cc <= 70) || // A-F
|
|
483
|
-
(cc >= 97 && cc <= 102)); // a-f
|
|
484
|
-
};
|
|
485
|
-
return takeChar(scnr, closure);
|
|
498
|
+
return takeChar(scnr, isHexDigit);
|
|
486
499
|
}
|
|
487
500
|
function getDigits(scnr) {
|
|
488
501
|
let ch = '';
|
|
@@ -546,7 +559,7 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
546
559
|
skipSpaces(scnr);
|
|
547
560
|
let ch = '';
|
|
548
561
|
let name = '';
|
|
549
|
-
while ((ch =
|
|
562
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
550
563
|
name += ch;
|
|
551
564
|
}
|
|
552
565
|
if (scnr.currentChar() === EOF) {
|
|
@@ -569,14 +582,16 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
569
582
|
}
|
|
570
583
|
return value;
|
|
571
584
|
}
|
|
585
|
+
function isLiteral(ch) {
|
|
586
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
587
|
+
}
|
|
572
588
|
function readLiteral(scnr) {
|
|
573
589
|
skipSpaces(scnr);
|
|
574
590
|
// eslint-disable-next-line no-useless-escape
|
|
575
591
|
eat(scnr, `\'`);
|
|
576
592
|
let ch = '';
|
|
577
593
|
let literal = '';
|
|
578
|
-
|
|
579
|
-
while ((ch = takeChar(scnr, fn))) {
|
|
594
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
580
595
|
if (ch === '\\') {
|
|
581
596
|
literal += readEscapeSequence(scnr);
|
|
582
597
|
}
|
|
@@ -628,15 +643,17 @@ var IntlifyMessageCompiler = (function (exports) {
|
|
|
628
643
|
}
|
|
629
644
|
return `\\${unicode}${sequence}`;
|
|
630
645
|
}
|
|
646
|
+
function isInvalidIdentifier(ch) {
|
|
647
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
648
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
649
|
+
ch !== CHAR_SP &&
|
|
650
|
+
ch !== CHAR_LF);
|
|
651
|
+
}
|
|
631
652
|
function readInvalidIdentifier(scnr) {
|
|
632
653
|
skipSpaces(scnr);
|
|
633
654
|
let ch = '';
|
|
634
655
|
let identifiers = '';
|
|
635
|
-
|
|
636
|
-
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
637
|
-
ch !== CHAR_SP &&
|
|
638
|
-
ch !== CHAR_LF;
|
|
639
|
-
while ((ch = takeChar(scnr, closure))) {
|
|
656
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
640
657
|
identifiers += ch;
|
|
641
658
|
}
|
|
642
659
|
return identifiers;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.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={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2},u={[s.USE_MODULO_SYNTAX]:"Use modulo before '{{0}}'."};function a(e,t,...n){const r={message:String(e),code:e};return t&&(r.location=t),r}const i={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},l={[i.EXPECTED_TOKEN]:"Expected token: '{0}'",[i.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[i.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[i.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[i.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[i.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[i.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[i.EMPTY_PLACEHOLDER]:"Empty placeholder",[i.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[i.INVALID_LINKED_FORMAT]:"Invalid linked format",[i.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[i.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[i.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[i.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[i.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[i.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function E(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 f=/<\/?[\w\s="/.':;#-\/]+>/,d=" ",L="\r",N="\n",_=String.fromCharCode(8232),p=String.fromCharCode(8233);function C(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>t[e]===L&&t[e+1]===N,u=e=>t[e]===p,a=e=>t[e]===_,i=e=>s(e)||(e=>t[e]===N)(e)||u(e)||a(e),l=e=>s(e)||u(e)||a(e)?N:t[e];function E(){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:E,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;)E();o=0}}}const T=void 0,k=".",A="'";function I(e,r={}){const c=!1!==r.location,o=C(e),s=()=>o.index(),u=()=>t(o.line(),o.column(),o.index()),a=u(),l=s(),E={currentType:14,offset:l,startLoc:a,endLoc:a,lastType:14,lastOffset:l,lastStartLoc:a,lastEndLoc:a,braceNest:0,inLinked:!1,text:""},f=()=>E,{onError:L}=r;function _(e,t,r){e.endLoc=u(),e.currentType=t;const o={type:t};return c&&(o.loc=n(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const p=e=>_(e,14);function I(e,t){return e.currentChar()===t?(e.next(),t):(i.EXPECTED_TOKEN,u(),"")}function h(e){let t="";for(;e.currentPeek()===d||e.currentPeek()===N;)t+=e.currentPeek(),e.peek();return t}function S(e){const t=h(e);return e.skipToPeek(),t}function P(e){if(e===T)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function O(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=function(e){if(e===T)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 y(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===d||r===N):o===d?(e.peek(),n(!0,d,c)):o!==N||(e.peek(),n(!0,N,c)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function m(e,t){const n=e.currentChar();return n===T?T:t(n)?(e.next(),n):null}function U(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 b(e){return m(e,(e=>{const t=e.charCodeAt(0);return t>=48&&t<=57}))}function x(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=b(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(!y(e))break;t+=n,e.next()}else if(n===d||n===N)if(y(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 i.UNKNOWN_ESCAPE_SEQUENCE,u(),""}}function g(e,t,n){I(e,t);let r="";for(let c=0;c<n;c++){const t=x(e);if(!t){i.INVALID_UNICODE_ESCAPE_SEQUENCE,u(),e.currentChar();break}r+=t}return`\\${t}${r}`}function X(e){S(e);const t=I(e,"|");return S(e),t}function Y(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(i.NOT_ALLOW_NEST_PLACEHOLDER,u()),e.next(),n=_(t,2,"{"),S(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(i.EMPTY_PLACEHOLDER,u()),e.next(),n=_(t,3,"}"),t.braceNest--,t.braceNest>0&&S(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(i.UNTERMINATED_CLOSING_BRACE,u()),n=K(e,t)||p(t),t.braceNest=0,n;default:{let r=!0,c=!0,o=!0;if(D(e))return t.braceNest>0&&(i.UNTERMINATED_CLOSING_BRACE,u()),n=_(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 i.UNTERMINATED_CLOSING_BRACE,u(),t.braceNest=0,w(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t))return n=_(t,5,function(e){S(e);let t="",n="";for(;t=U(e);)n+=t;return e.currentChar()===T&&(i.UNTERMINATED_CLOSING_BRACE,u()),n}(e)),S(e),n;if(c=O(e,t))return n=_(t,6,function(e){S(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${v(e)}`):t+=v(e),e.currentChar()===T&&(i.UNTERMINATED_CLOSING_BRACE,u()),t}(e)),S(e),n;if(o=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=e.currentPeek()===A;return e.resetPeek(),r}(e,t))return n=_(t,7,function(e){S(e),I(e,"'");let t="",n="";const r=e=>e!==A&&e!==N;for(;t=m(e,r);)n+="\\"===t?M(e):t;const c=e.currentChar();return c===N||c===T?(i.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,u(),c===N&&(e.next(),I(e,"'")),n):(I(e,"'"),n)}(e)),S(e),n;if(!r&&!c&&!o)return n=_(t,13,function(e){S(e);let t="",n="";const r=e=>"{"!==e&&"}"!==e&&e!==d&&e!==N;for(;t=m(e,r);)n+=t;return n}(e)),i.INVALID_TOKEN_IN_PLACEHOLDER,u(),n.value,S(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!==N&&c!==d||(i.INVALID_LINKED_FORMAT,u()),c){case"@":return e.next(),r=_(t,8,"@"),t.inLinked=!0,r;case".":return S(e),e.next(),_(t,9,".");case":":return S(e),e.next(),_(t,10,":");default:return D(e)?(r=_(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)?(S(e),K(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;h(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t)?(S(e),_(t,12,function(e){let t="",n="";for(;t=U(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?P(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===d||!t)&&(t===N?(e.peek(),r()):P(t))},c=r();return e.resetPeek(),c}(e,t)?(S(e),"{"===c?Y(e,t)||r:_(t,11,function(e){const t=(n=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&"("!==c&&")"!==c&&c?c===d?r:c===N||c===k?(r+=c,e.next(),t(n,r)):(r+=c,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&(i.INVALID_LINKED_FORMAT,u()),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)||p(t);if(t.inLinked)return K(e,t)||p(t);switch(e.currentChar()){case"{":return Y(e,t)||p(t);case"}":return i.UNBALANCED_CLOSING_BRACE,u(),e.next(),_(t,3,"}");case"@":return K(e,t)||p(t);default:{if(D(e))return n=_(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,0,R(e)):_(t,4,function(e){S(e);const t=e.currentChar();return"%"!==t&&(i.EXPECTED_TOKEN,u()),e.next(),"%"}(e));if(y(e))return _(t,0,R(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:r}=E;return E.lastType=e,E.lastOffset=t,E.lastStartLoc=n,E.lastEndLoc=r,E.offset=s(),E.startLoc=u(),o.currentChar()===T?_(E,14):w(o,E)},currentOffset:s,currentPosition:u,context:f}}const h="parser",S=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function P(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 O(e={}){const t=!1!==e.location,{onError:n,onWarn:c}=e;function o(e,n,r){const c={type:e};return t&&(c.start=n,c.end=n,c.loc={start:r,end:r}),c}function u(e,n,r,c){c&&(e.type=c),t&&(e.end=n,e.loc&&(e.loc.end=r))}function a(e,t){const n=e.context(),r=o(3,n.offset,n.startLoc);return r.value=t,u(r,e.currentOffset(),e.currentPosition()),r}function l(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,s=o(5,r,c);return s.index=parseInt(t,10),e.nextToken(),u(s,e.currentOffset(),e.currentPosition()),s}function E(e,t,n){const r=e.context(),{lastOffset:c,lastStartLoc:s}=r,a=o(4,c,s);return a.key=t,!0===n&&(a.modulo=!0),e.nextToken(),u(a,e.currentOffset(),e.currentPosition()),a}function f(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,s=o(9,r,c);return s.value=t.replace(S,P),e.nextToken(),u(s,e.currentOffset(),e.currentPosition()),s}function d(e){const t=e.context(),n=o(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:c}=n,s=o(8,r,c);return 12!==t.type?(i.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,s.value="",u(s,r,c),{nextConsumeToken:t,node:s}):(null==t.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,D(t)),s.value=t.value||"",u(s,e.currentOffset(),e.currentPosition()),{node:s})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=function(e,t){const n=e.context(),r=o(7,n.offset,n.startLoc);return r.value=t,u(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=E(e,r.value||"");break;case 6:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=l(e,r.value||"");break;case 7:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=f(e,r.value||"");break;default:{i.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const c=e.context(),s=o(7,c.offset,c.startLoc);return s.value="",u(s,c.offset,c.startLoc),n.key=s,u(n,c.offset,c.startLoc),{nextConsumeToken:r,node:n}}}return u(n,e.currentOffset(),e.currentPosition()),{node:n}}function L(e){const t=e.context(),n=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,c=null;do{const o=r||e.nextToken();switch(r=null,o.type){case 0:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(a(e,o.value||""));break;case 6:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(l(e,o.value||""));break;case 4:c=!0;break;case 5:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(E(e,o.value||"",!!c)),c&&(s.USE_MODULO_SYNTAX,t.lastStartLoc,D(o),c=null);break;case 7:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(f(e,o.value||""));break;case 8:{const t=d(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return u(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function N(e){const t=e.context(),{offset:n,startLoc:r}=t,c=L(e);return 14===t.currentType?c:function(e,t,n,r){const c=e.context();let s=0===r.items.length;const a=o(1,t,n);a.cases=[],a.cases.push(r);do{const t=L(e);s||(s=0===t.items.length),a.cases.push(t)}while(14!==c.currentType);return s&&i.MUST_HAVE_MESSAGES_IN_PLURAL,u(a,e.currentOffset(),e.currentPosition()),a}(e,n,r,c)}return{parse:function(n){const c=I(n,r({},e)),s=c.context(),a=o(0,s.offset,s.startLoc);return t&&a.loc&&(a.loc.source=n),a.body=N(c),e.onCacheKey&&(a.cacheKey=e.onCacheKey(n)),14!==s.currentType&&(i.UNEXPECTED_LEXICAL_ANALYSIS,s.lastStartLoc,n[s.offset]),u(a,c.currentOffset(),c.currentPosition()),a}}}function D(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 y(e,t){for(let n=0;n<e.length;n++)m(e[n],t)}function m(e,t){switch(e.type){case 1:y(e.cases,t),t.helper("plural");break;case 2:y(e.items,t);break;case 6:m(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 U(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&&m(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function b(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 x(e){switch(e.t=e.type,e.type){case 0:{const t=e;x(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++)x(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++)x(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;x(t.key),t.k=t.key,delete t.key,t.modifier&&(x(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 v(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?v(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&&(v(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&&(v(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")}(`),v(e,t.key),t.modifier?(e.push(", "),v(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=i,e.CompileWarnCodes=s,e.ERROR_DOMAIN=h,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=O(n).parse(e);return s?(a&&function(e){const t=e.body;2===t.type?b(t):t.cases.forEach((e=>b(e)))}(i),u&&x(i),{ast:i,code:""}):(U(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 "),v(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=E,e.createCompileWarn=a,e.createLocation=n,e.createParser=O,e.createPosition=t,e.defaultOnError=function(e){throw e},e.detectHtmlTag=e=>f.test(e),e.errorMessages=l,e.warnMessages=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={USE_MODULO_SYNTAX:1,__EXTEND_POINT__:2},u={[s.USE_MODULO_SYNTAX]:"Use modulo before '{{0}}'."};function a(e,t,...n){const r={message:String(e),code:e};return t&&(r.location=t),r}const i={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},l={[i.EXPECTED_TOKEN]:"Expected token: '{0}'",[i.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[i.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[i.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[i.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[i.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[i.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[i.EMPTY_PLACEHOLDER]:"Empty placeholder",[i.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[i.INVALID_LINKED_FORMAT]:"Invalid linked format",[i.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[i.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[i.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[i.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[i.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[i.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function E(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 f=/<\/?[\w\s="/.':;#-\/]+>/,d=" ",L="\r",N="\n",_=String.fromCharCode(8232),p=String.fromCharCode(8233);function C(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>t[e]===L&&t[e+1]===N,u=e=>t[e]===p,a=e=>t[e]===_,i=e=>s(e)||(e=>t[e]===N)(e)||u(e)||a(e),l=e=>s(e)||u(e)||a(e)?N:t[e];function E(){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:E,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;)E();o=0}}}const T=void 0,k=".",A="'";function I(e,r={}){const c=!1!==r.location,o=C(e),s=()=>o.index(),u=()=>t(o.line(),o.column(),o.index()),a=u(),l=s(),E={currentType:14,offset:l,startLoc:a,endLoc:a,lastType:14,lastOffset:l,lastStartLoc:a,lastEndLoc:a,braceNest:0,inLinked:!1,text:""},f=()=>E,{onError:L}=r;function _(e,t,r){e.endLoc=u(),e.currentType=t;const o={type:t};return c&&(o.loc=n(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const p=e=>_(e,14);function I(e,t){return e.currentChar()===t?(e.next(),t):(i.EXPECTED_TOKEN,u(),"")}function h(e){let t="";for(;e.currentPeek()===d||e.currentPeek()===N;)t+=e.currentPeek(),e.peek();return t}function S(e){const t=h(e);return e.skipToPeek(),t}function P(e){if(e===T)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function O(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=function(e){if(e===T)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 y(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===d||r===N):o===d?(e.peek(),n(!0,d,c)):o!==N||(e.peek(),n(!0,N,c)):"%"===r||t},r=n();return t&&e.resetPeek(),r}function m(e,t){const n=e.currentChar();return n===T?T:t(n)?(e.next(),n):null}function U(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t}function b(e){return m(e,U)}function x(e){const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||t>=48&&t<=57||95===t||36===t||45===t}function v(e){return m(e,x)}function R(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function M(e){return m(e,R)}function g(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function X(e){return m(e,g)}function Y(e){let t="",n="";for(;t=M(e);)n+=t;return n}function K(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if("%"===n){if(!y(e))break;t+=n,e.next()}else if(n===d||n===N)if(y(e))t+=n,e.next();else{if(D(e))break;t+=n,e.next()}else t+=n,e.next()}return t}function w(e){return e!==A&&e!==N}function H(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 i.UNKNOWN_ESCAPE_SEQUENCE,u(),""}}function G(e,t,n){I(e,t);let r="";for(let c=0;c<n;c++){const t=X(e);if(!t){i.INVALID_UNICODE_ESCAPE_SEQUENCE,u(),e.currentChar();break}r+=t}return`\\${t}${r}`}function $(e){return"{"!==e&&"}"!==e&&e!==d&&e!==N}function B(e){S(e);const t=I(e,"|");return S(e),t}function V(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(i.NOT_ALLOW_NEST_PLACEHOLDER,u()),e.next(),n=_(t,2,"{"),S(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(i.EMPTY_PLACEHOLDER,u()),e.next(),n=_(t,3,"}"),t.braceNest--,t.braceNest>0&&S(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(i.UNTERMINATED_CLOSING_BRACE,u()),n=F(e,t)||p(t),t.braceNest=0,n;default:{let r=!0,c=!0,o=!0;if(D(e))return t.braceNest>0&&(i.UNTERMINATED_CLOSING_BRACE,u()),n=_(t,1,B(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(5===t.currentType||6===t.currentType||7===t.currentType))return i.UNTERMINATED_CLOSING_BRACE,u(),t.braceNest=0,Q(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t))return n=_(t,5,function(e){S(e);let t="",n="";for(;t=v(e);)n+=t;return e.currentChar()===T&&(i.UNTERMINATED_CLOSING_BRACE,u()),n}(e)),S(e),n;if(c=O(e,t))return n=_(t,6,function(e){S(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${Y(e)}`):t+=Y(e),e.currentChar()===T&&(i.UNTERMINATED_CLOSING_BRACE,u()),t}(e)),S(e),n;if(o=function(e,t){const{currentType:n}=t;if(2!==n)return!1;h(e);const r=e.currentPeek()===A;return e.resetPeek(),r}(e,t))return n=_(t,7,function(e){S(e),I(e,"'");let t="",n="";for(;t=m(e,w);)n+="\\"===t?H(e):t;const r=e.currentChar();return r===N||r===T?(i.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,u(),r===N&&(e.next(),I(e,"'")),n):(I(e,"'"),n)}(e)),S(e),n;if(!r&&!c&&!o)return n=_(t,13,function(e){S(e);let t="",n="";for(;t=m(e,$);)n+=t;return n}(e)),i.INVALID_TOKEN_IN_PLACEHOLDER,u(),n.value,S(e),n;break}}return n}function F(e,t){const{currentType:n}=t;let r=null;const c=e.currentChar();switch(8!==n&&9!==n&&12!==n&&10!==n||c!==N&&c!==d||(i.INVALID_LINKED_FORMAT,u()),c){case"@":return e.next(),r=_(t,8,"@"),t.inLinked=!0,r;case".":return S(e),e.next(),_(t,9,".");case":":return S(e),e.next(),_(t,10,":");default:return D(e)?(r=_(t,1,B(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)?(S(e),F(e,t)):function(e,t){const{currentType:n}=t;if(9!==n)return!1;h(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t)?(S(e),_(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?P(e.peek()):!("@"===t||"%"===t||"|"===t||":"===t||"."===t||t===d||!t)&&(t===N?(e.peek(),r()):P(t))},c=r();return e.resetPeek(),c}(e,t)?(S(e),"{"===c?V(e,t)||r:_(t,11,function(e){const t=(n=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&"("!==c&&")"!==c&&c?c===d?r:c===N||c===k?(r+=c,e.next(),t(n,r)):(r+=c,e.next(),t(!0,r)):r};return t(!1,"")}(e))):(8===n&&(i.INVALID_LINKED_FORMAT,u()),t.braceNest=0,t.inLinked=!1,Q(e,t))}}function Q(e,t){let n={type:14};if(t.braceNest>0)return V(e,t)||p(t);if(t.inLinked)return F(e,t)||p(t);switch(e.currentChar()){case"{":return V(e,t)||p(t);case"}":return i.UNBALANCED_CLOSING_BRACE,u(),e.next(),_(t,3,"}");case"@":return F(e,t)||p(t);default:{if(D(e))return n=_(t,1,B(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,0,K(e)):_(t,4,function(e){S(e);const t=e.currentChar();return"%"!==t&&(i.EXPECTED_TOKEN,u()),e.next(),"%"}(e));if(y(e))return _(t,0,K(e));break}}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:r}=E;return E.lastType=e,E.lastOffset=t,E.lastStartLoc=n,E.lastEndLoc=r,E.offset=s(),E.startLoc=u(),o.currentChar()===T?_(E,14):Q(o,E)},currentOffset:s,currentPosition:u,context:f}}const h="parser",S=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function P(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 O(e={}){const t=!1!==e.location,{onError:n,onWarn:c}=e;function o(e,n,r){const c={type:e};return t&&(c.start=n,c.end=n,c.loc={start:r,end:r}),c}function u(e,n,r,c){c&&(e.type=c),t&&(e.end=n,e.loc&&(e.loc.end=r))}function a(e,t){const n=e.context(),r=o(3,n.offset,n.startLoc);return r.value=t,u(r,e.currentOffset(),e.currentPosition()),r}function l(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,s=o(5,r,c);return s.index=parseInt(t,10),e.nextToken(),u(s,e.currentOffset(),e.currentPosition()),s}function E(e,t,n){const r=e.context(),{lastOffset:c,lastStartLoc:s}=r,a=o(4,c,s);return a.key=t,!0===n&&(a.modulo=!0),e.nextToken(),u(a,e.currentOffset(),e.currentPosition()),a}function f(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:c}=n,s=o(9,r,c);return s.value=t.replace(S,P),e.nextToken(),u(s,e.currentOffset(),e.currentPosition()),s}function d(e){const t=e.context(),n=o(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:c}=n,s=o(8,r,c);return 12!==t.type?(i.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,s.value="",u(s,r,c),{nextConsumeToken:t,node:s}):(null==t.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,D(t)),s.value=t.value||"",u(s,e.currentOffset(),e.currentPosition()),{node:s})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(10!==r.type&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 11:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=function(e,t){const n=e.context(),r=o(7,n.offset,n.startLoc);return r.value=t,u(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 5:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=E(e,r.value||"");break;case 6:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=l(e,r.value||"");break;case 7:null==r.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(r)),n.key=f(e,r.value||"");break;default:{i.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const c=e.context(),s=o(7,c.offset,c.startLoc);return s.value="",u(s,c.offset,c.startLoc),n.key=s,u(n,c.offset,c.startLoc),{nextConsumeToken:r,node:n}}}return u(n,e.currentOffset(),e.currentPosition()),{node:n}}function L(e){const t=e.context(),n=o(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null,c=null;do{const o=r||e.nextToken();switch(r=null,o.type){case 0:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(a(e,o.value||""));break;case 6:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(l(e,o.value||""));break;case 4:c=!0;break;case 5:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(E(e,o.value||"",!!c)),c&&(s.USE_MODULO_SYNTAX,t.lastStartLoc,D(o),c=null);break;case 7:null==o.value&&(i.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,D(o)),n.items.push(f(e,o.value||""));break;case 8:{const t=d(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(14!==t.currentType&&1!==t.currentType);return u(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function N(e){const t=e.context(),{offset:n,startLoc:r}=t,c=L(e);return 14===t.currentType?c:function(e,t,n,r){const c=e.context();let s=0===r.items.length;const a=o(1,t,n);a.cases=[],a.cases.push(r);do{const t=L(e);s||(s=0===t.items.length),a.cases.push(t)}while(14!==c.currentType);return s&&i.MUST_HAVE_MESSAGES_IN_PLURAL,u(a,e.currentOffset(),e.currentPosition()),a}(e,n,r,c)}return{parse:function(n){const c=I(n,r({},e)),s=c.context(),a=o(0,s.offset,s.startLoc);return t&&a.loc&&(a.loc.source=n),a.body=N(c),e.onCacheKey&&(a.cacheKey=e.onCacheKey(n)),14!==s.currentType&&(i.UNEXPECTED_LEXICAL_ANALYSIS,s.lastStartLoc,n[s.offset]),u(a,c.currentOffset(),c.currentPosition()),a}}}function D(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 y(e,t){for(let n=0;n<e.length;n++)m(e[n],t)}function m(e,t){switch(e.type){case 1:y(e.cases,t),t.helper("plural");break;case 2:y(e.items,t);break;case 6:m(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 U(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&&m(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function b(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 x(e){switch(e.t=e.type,e.type){case 0:{const t=e;x(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++)x(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++)x(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;x(t.key),t.k=t.key,delete t.key,t.modifier&&(x(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 v(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?v(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&&(v(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&&(v(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")}(`),v(e,t.key),t.modifier?(e.push(", "),v(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=i,e.CompileWarnCodes=s,e.ERROR_DOMAIN=h,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=O(n).parse(e);return s?(a&&function(e){const t=e.body;2===t.type?b(t):t.cases.forEach((e=>b(e)))}(i),u&&x(i),{ast:i,code:""}):(U(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 "),v(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=E,e.createCompileWarn=a,e.createLocation=n,e.createParser=O,e.createPosition=t,e.defaultOnError=function(e){throw e},e.detectHtmlTag=e=>f.test(e),e.errorMessages=l,e.warnMessages=u,e}({});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -431,33 +431,46 @@ function createTokenizer(source, options = {}) {
|
|
|
431
431
|
}
|
|
432
432
|
return null;
|
|
433
433
|
}
|
|
434
|
+
function isIdentifier(ch) {
|
|
435
|
+
const cc = ch.charCodeAt(0);
|
|
436
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
437
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
438
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
439
|
+
cc === 95 || // _
|
|
440
|
+
cc === 36 // $
|
|
441
|
+
);
|
|
442
|
+
}
|
|
434
443
|
function takeIdentifierChar(scnr) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
444
|
+
return takeChar(scnr, isIdentifier);
|
|
445
|
+
}
|
|
446
|
+
function isNamedIdentifier(ch) {
|
|
447
|
+
const cc = ch.charCodeAt(0);
|
|
448
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
449
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
450
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
451
|
+
cc === 95 || // _
|
|
452
|
+
cc === 36 || // $
|
|
453
|
+
cc === 45 // -
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
function takeNamedIdentifierChar(scnr) {
|
|
457
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
458
|
+
}
|
|
459
|
+
function isDigit(ch) {
|
|
460
|
+
const cc = ch.charCodeAt(0);
|
|
461
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
445
462
|
}
|
|
446
463
|
function takeDigit(scnr) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
return
|
|
464
|
+
return takeChar(scnr, isDigit);
|
|
465
|
+
}
|
|
466
|
+
function isHexDigit(ch) {
|
|
467
|
+
const cc = ch.charCodeAt(0);
|
|
468
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
469
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
470
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
452
471
|
}
|
|
453
472
|
function takeHexDigit(scnr) {
|
|
454
|
-
|
|
455
|
-
const cc = ch.charCodeAt(0);
|
|
456
|
-
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
457
|
-
(cc >= 65 && cc <= 70) || // A-F
|
|
458
|
-
(cc >= 97 && cc <= 102)); // a-f
|
|
459
|
-
};
|
|
460
|
-
return takeChar(scnr, closure);
|
|
473
|
+
return takeChar(scnr, isHexDigit);
|
|
461
474
|
}
|
|
462
475
|
function getDigits(scnr) {
|
|
463
476
|
let ch = '';
|
|
@@ -521,7 +534,7 @@ function createTokenizer(source, options = {}) {
|
|
|
521
534
|
skipSpaces(scnr);
|
|
522
535
|
let ch = '';
|
|
523
536
|
let name = '';
|
|
524
|
-
while ((ch =
|
|
537
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
525
538
|
name += ch;
|
|
526
539
|
}
|
|
527
540
|
if (scnr.currentChar() === EOF) {
|
|
@@ -544,14 +557,16 @@ function createTokenizer(source, options = {}) {
|
|
|
544
557
|
}
|
|
545
558
|
return value;
|
|
546
559
|
}
|
|
560
|
+
function isLiteral(ch) {
|
|
561
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
562
|
+
}
|
|
547
563
|
function readLiteral(scnr) {
|
|
548
564
|
skipSpaces(scnr);
|
|
549
565
|
// eslint-disable-next-line no-useless-escape
|
|
550
566
|
eat(scnr, `\'`);
|
|
551
567
|
let ch = '';
|
|
552
568
|
let literal = '';
|
|
553
|
-
|
|
554
|
-
while ((ch = takeChar(scnr, fn))) {
|
|
569
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
555
570
|
if (ch === '\\') {
|
|
556
571
|
literal += readEscapeSequence(scnr);
|
|
557
572
|
}
|
|
@@ -603,15 +618,17 @@ function createTokenizer(source, options = {}) {
|
|
|
603
618
|
}
|
|
604
619
|
return `\\${unicode}${sequence}`;
|
|
605
620
|
}
|
|
621
|
+
function isInvalidIdentifier(ch) {
|
|
622
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
623
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
624
|
+
ch !== CHAR_SP &&
|
|
625
|
+
ch !== CHAR_LF);
|
|
626
|
+
}
|
|
606
627
|
function readInvalidIdentifier(scnr) {
|
|
607
628
|
skipSpaces(scnr);
|
|
608
629
|
let ch = '';
|
|
609
630
|
let identifiers = '';
|
|
610
|
-
|
|
611
|
-
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
612
|
-
ch !== CHAR_SP &&
|
|
613
|
-
ch !== CHAR_LF;
|
|
614
|
-
while ((ch = takeChar(scnr, closure))) {
|
|
631
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
615
632
|
identifiers += ch;
|
|
616
633
|
}
|
|
617
634
|
return identifiers;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -432,33 +432,46 @@ function createTokenizer(source, options = {}) {
|
|
|
432
432
|
}
|
|
433
433
|
return null;
|
|
434
434
|
}
|
|
435
|
+
function isIdentifier(ch) {
|
|
436
|
+
const cc = ch.charCodeAt(0);
|
|
437
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
438
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
439
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
440
|
+
cc === 95 || // _
|
|
441
|
+
cc === 36 // $
|
|
442
|
+
);
|
|
443
|
+
}
|
|
435
444
|
function takeIdentifierChar(scnr) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
return takeChar(scnr, isIdentifier);
|
|
446
|
+
}
|
|
447
|
+
function isNamedIdentifier(ch) {
|
|
448
|
+
const cc = ch.charCodeAt(0);
|
|
449
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
450
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
451
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
452
|
+
cc === 95 || // _
|
|
453
|
+
cc === 36 || // $
|
|
454
|
+
cc === 45 // -
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
function takeNamedIdentifierChar(scnr) {
|
|
458
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
459
|
+
}
|
|
460
|
+
function isDigit(ch) {
|
|
461
|
+
const cc = ch.charCodeAt(0);
|
|
462
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
446
463
|
}
|
|
447
464
|
function takeDigit(scnr) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return
|
|
465
|
+
return takeChar(scnr, isDigit);
|
|
466
|
+
}
|
|
467
|
+
function isHexDigit(ch) {
|
|
468
|
+
const cc = ch.charCodeAt(0);
|
|
469
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
470
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
471
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
453
472
|
}
|
|
454
473
|
function takeHexDigit(scnr) {
|
|
455
|
-
|
|
456
|
-
const cc = ch.charCodeAt(0);
|
|
457
|
-
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
458
|
-
(cc >= 65 && cc <= 70) || // A-F
|
|
459
|
-
(cc >= 97 && cc <= 102)); // a-f
|
|
460
|
-
};
|
|
461
|
-
return takeChar(scnr, closure);
|
|
474
|
+
return takeChar(scnr, isHexDigit);
|
|
462
475
|
}
|
|
463
476
|
function getDigits(scnr) {
|
|
464
477
|
let ch = '';
|
|
@@ -522,7 +535,7 @@ function createTokenizer(source, options = {}) {
|
|
|
522
535
|
skipSpaces(scnr);
|
|
523
536
|
let ch = '';
|
|
524
537
|
let name = '';
|
|
525
|
-
while ((ch =
|
|
538
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
526
539
|
name += ch;
|
|
527
540
|
}
|
|
528
541
|
if (scnr.currentChar() === EOF) {
|
|
@@ -545,14 +558,16 @@ function createTokenizer(source, options = {}) {
|
|
|
545
558
|
}
|
|
546
559
|
return value;
|
|
547
560
|
}
|
|
561
|
+
function isLiteral(ch) {
|
|
562
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
563
|
+
}
|
|
548
564
|
function readLiteral(scnr) {
|
|
549
565
|
skipSpaces(scnr);
|
|
550
566
|
// eslint-disable-next-line no-useless-escape
|
|
551
567
|
eat(scnr, `\'`);
|
|
552
568
|
let ch = '';
|
|
553
569
|
let literal = '';
|
|
554
|
-
|
|
555
|
-
while ((ch = takeChar(scnr, fn))) {
|
|
570
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
556
571
|
if (ch === '\\') {
|
|
557
572
|
literal += readEscapeSequence(scnr);
|
|
558
573
|
}
|
|
@@ -604,15 +619,17 @@ function createTokenizer(source, options = {}) {
|
|
|
604
619
|
}
|
|
605
620
|
return `\\${unicode}${sequence}`;
|
|
606
621
|
}
|
|
622
|
+
function isInvalidIdentifier(ch) {
|
|
623
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
624
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
625
|
+
ch !== CHAR_SP &&
|
|
626
|
+
ch !== CHAR_LF);
|
|
627
|
+
}
|
|
607
628
|
function readInvalidIdentifier(scnr) {
|
|
608
629
|
skipSpaces(scnr);
|
|
609
630
|
let ch = '';
|
|
610
631
|
let identifiers = '';
|
|
611
|
-
|
|
612
|
-
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
613
|
-
ch !== CHAR_SP &&
|
|
614
|
-
ch !== CHAR_LF;
|
|
615
|
-
while ((ch = takeChar(scnr, closure))) {
|
|
632
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
616
633
|
identifiers += ch;
|
|
617
634
|
}
|
|
618
635
|
return identifiers;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* message-compiler v9.
|
|
2
|
+
* message-compiler v9.13.0
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -432,33 +432,46 @@ function createTokenizer(source, options = {}) {
|
|
|
432
432
|
}
|
|
433
433
|
return null;
|
|
434
434
|
}
|
|
435
|
+
function isIdentifier(ch) {
|
|
436
|
+
const cc = ch.charCodeAt(0);
|
|
437
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
438
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
439
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
440
|
+
cc === 95 || // _
|
|
441
|
+
cc === 36 // $
|
|
442
|
+
);
|
|
443
|
+
}
|
|
435
444
|
function takeIdentifierChar(scnr) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
return takeChar(scnr, isIdentifier);
|
|
446
|
+
}
|
|
447
|
+
function isNamedIdentifier(ch) {
|
|
448
|
+
const cc = ch.charCodeAt(0);
|
|
449
|
+
return ((cc >= 97 && cc <= 122) || // a-z
|
|
450
|
+
(cc >= 65 && cc <= 90) || // A-Z
|
|
451
|
+
(cc >= 48 && cc <= 57) || // 0-9
|
|
452
|
+
cc === 95 || // _
|
|
453
|
+
cc === 36 || // $
|
|
454
|
+
cc === 45 // -
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
function takeNamedIdentifierChar(scnr) {
|
|
458
|
+
return takeChar(scnr, isNamedIdentifier);
|
|
459
|
+
}
|
|
460
|
+
function isDigit(ch) {
|
|
461
|
+
const cc = ch.charCodeAt(0);
|
|
462
|
+
return cc >= 48 && cc <= 57; // 0-9
|
|
446
463
|
}
|
|
447
464
|
function takeDigit(scnr) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return
|
|
465
|
+
return takeChar(scnr, isDigit);
|
|
466
|
+
}
|
|
467
|
+
function isHexDigit(ch) {
|
|
468
|
+
const cc = ch.charCodeAt(0);
|
|
469
|
+
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
470
|
+
(cc >= 65 && cc <= 70) || // A-F
|
|
471
|
+
(cc >= 97 && cc <= 102)); // a-f
|
|
453
472
|
}
|
|
454
473
|
function takeHexDigit(scnr) {
|
|
455
|
-
|
|
456
|
-
const cc = ch.charCodeAt(0);
|
|
457
|
-
return ((cc >= 48 && cc <= 57) || // 0-9
|
|
458
|
-
(cc >= 65 && cc <= 70) || // A-F
|
|
459
|
-
(cc >= 97 && cc <= 102)); // a-f
|
|
460
|
-
};
|
|
461
|
-
return takeChar(scnr, closure);
|
|
474
|
+
return takeChar(scnr, isHexDigit);
|
|
462
475
|
}
|
|
463
476
|
function getDigits(scnr) {
|
|
464
477
|
let ch = '';
|
|
@@ -522,7 +535,7 @@ function createTokenizer(source, options = {}) {
|
|
|
522
535
|
skipSpaces(scnr);
|
|
523
536
|
let ch = '';
|
|
524
537
|
let name = '';
|
|
525
|
-
while ((ch =
|
|
538
|
+
while ((ch = takeNamedIdentifierChar(scnr))) {
|
|
526
539
|
name += ch;
|
|
527
540
|
}
|
|
528
541
|
if (scnr.currentChar() === EOF) {
|
|
@@ -545,14 +558,16 @@ function createTokenizer(source, options = {}) {
|
|
|
545
558
|
}
|
|
546
559
|
return value;
|
|
547
560
|
}
|
|
561
|
+
function isLiteral(ch) {
|
|
562
|
+
return ch !== LITERAL_DELIMITER && ch !== CHAR_LF;
|
|
563
|
+
}
|
|
548
564
|
function readLiteral(scnr) {
|
|
549
565
|
skipSpaces(scnr);
|
|
550
566
|
// eslint-disable-next-line no-useless-escape
|
|
551
567
|
eat(scnr, `\'`);
|
|
552
568
|
let ch = '';
|
|
553
569
|
let literal = '';
|
|
554
|
-
|
|
555
|
-
while ((ch = takeChar(scnr, fn))) {
|
|
570
|
+
while ((ch = takeChar(scnr, isLiteral))) {
|
|
556
571
|
if (ch === '\\') {
|
|
557
572
|
literal += readEscapeSequence(scnr);
|
|
558
573
|
}
|
|
@@ -604,15 +619,17 @@ function createTokenizer(source, options = {}) {
|
|
|
604
619
|
}
|
|
605
620
|
return `\\${unicode}${sequence}`;
|
|
606
621
|
}
|
|
622
|
+
function isInvalidIdentifier(ch) {
|
|
623
|
+
return (ch !== "{" /* TokenChars.BraceLeft */ &&
|
|
624
|
+
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
625
|
+
ch !== CHAR_SP &&
|
|
626
|
+
ch !== CHAR_LF);
|
|
627
|
+
}
|
|
607
628
|
function readInvalidIdentifier(scnr) {
|
|
608
629
|
skipSpaces(scnr);
|
|
609
630
|
let ch = '';
|
|
610
631
|
let identifiers = '';
|
|
611
|
-
|
|
612
|
-
ch !== "}" /* TokenChars.BraceRight */ &&
|
|
613
|
-
ch !== CHAR_SP &&
|
|
614
|
-
ch !== CHAR_LF;
|
|
615
|
-
while ((ch = takeChar(scnr, closure))) {
|
|
632
|
+
while ((ch = takeChar(scnr, isInvalidIdentifier))) {
|
|
616
633
|
identifiers += ch;
|
|
617
634
|
}
|
|
618
635
|
return identifiers;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/message-compiler",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.13.0",
|
|
4
4
|
"description": "@intlify/message-compiler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"types": "dist/message-compiler.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"source-map-js": "^1.0.2",
|
|
37
|
-
"@intlify/shared": "9.
|
|
37
|
+
"@intlify/shared": "9.13.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">= 16"
|