@intlify/message-compiler 10.0.0-alpha.3 → 10.0.0-alpha.5

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -43,12 +43,12 @@ const CompileErrorCodes = {
43
43
  // generator error codes
44
44
  UNHANDLED_CODEGEN_NODE_TYPE: 15,
45
45
  // minifier error codes
46
- UNHANDLED_MINIFIER_NODE_TYPE: 16,
47
- // Special value for higher-order compilers to pick up the last code
48
- // to avoid collision of error codes. This should always be kept as the last
49
- // item.
50
- __EXTEND_POINT__: 17
46
+ UNHANDLED_MINIFIER_NODE_TYPE: 16
51
47
  };
48
+ // Special value for higher-order compilers to pick up the last code
49
+ // to avoid collision of error codes.
50
+ // This should always be kept as the last item.
51
+ const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
52
52
  /** @internal */
53
53
  const errorMessages = {
54
54
  // tokenizer error messages
@@ -1576,6 +1576,7 @@ function baseCompile(source, options = {}) {
1576
1576
  }
1577
1577
  }
1578
1578
 
1579
+ exports.COMPILE_ERROR_CODES_EXTEND_POINT = COMPILE_ERROR_CODES_EXTEND_POINT;
1579
1580
  exports.CompileErrorCodes = CompileErrorCodes;
1580
1581
  exports.ERROR_DOMAIN = ERROR_DOMAIN$2;
1581
1582
  exports.LOCATION_STUB = LOCATION_STUB;
@@ -23,6 +23,8 @@ declare interface CodeGenResult {
23
23
  map?: RawSourceMap;
24
24
  }
25
25
 
26
+ export declare const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
27
+
26
28
  export declare type CompileDomain = 'tokenizer' | 'parser' | 'generator' | 'transformer' | 'optimizer' | 'minifier';
27
29
 
28
30
  export declare interface CompileError extends BaseError, SyntaxError {
@@ -47,7 +49,6 @@ export declare const CompileErrorCodes: {
47
49
  readonly UNEXPECTED_LEXICAL_ANALYSIS: 14;
48
50
  readonly UNHANDLED_CODEGEN_NODE_TYPE: 15;
49
51
  readonly UNHANDLED_MINIFIER_NODE_TYPE: 16;
50
- readonly __EXTEND_POINT__: 17;
51
52
  };
52
53
 
53
54
  export declare type CompileErrorCodes = (typeof CompileErrorCodes)[keyof typeof CompileErrorCodes];
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -63,12 +63,12 @@ const CompileErrorCodes = {
63
63
  // generator error codes
64
64
  UNHANDLED_CODEGEN_NODE_TYPE: 15,
65
65
  // minifier error codes
66
- UNHANDLED_MINIFIER_NODE_TYPE: 16,
67
- // Special value for higher-order compilers to pick up the last code
68
- // to avoid collision of error codes. This should always be kept as the last
69
- // item.
70
- __EXTEND_POINT__: 17
66
+ UNHANDLED_MINIFIER_NODE_TYPE: 16
71
67
  };
68
+ // Special value for higher-order compilers to pick up the last code
69
+ // to avoid collision of error codes.
70
+ // This should always be kept as the last item.
71
+ const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
72
72
  /** @internal */
73
73
  const errorMessages = {
74
74
  // tokenizer error messages
@@ -1540,4 +1540,4 @@ function baseCompile(source, options = {}) {
1540
1540
  }
1541
1541
  }
1542
1542
 
1543
- export { CompileErrorCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages };
1543
+ export { COMPILE_ERROR_CODES_EXTEND_POINT, CompileErrorCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages };
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
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 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:c}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}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,c=0;const s=e=>t[e]===CHAR_CR&&t[e+1]===CHAR_LF,i=e=>t[e]===CHAR_PS,a=e=>t[e]===CHAR_LS,u=e=>s(e)||(e=>t[e]===CHAR_LF)(e)||i(e)||a(e),l=e=>s(e)||i(e)||a(e)?CHAR_LF:t[e];function E(){return c=0,u(n)&&(r++,o=0),s(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>c,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+c),next:E,peek:function(){return s(n+c)&&c++,c++,t[n+c]},reset:function(){n=0,r=1,o=1,c=0},resetPeek:function(e=0){c=e},skipToPeek:function(){const e=n+c;for(;e!==n;)E();c=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(),c=()=>createPosition(r.line(),r.column(),r.index()),s=c(),i=o(),a={currentType:13,offset:i,startLoc:s,endLoc:s,lastType:13,lastOffset:i,lastStartLoc:s,lastEndLoc:s,braceNest:0,inLinked:!1,text:""},u=()=>a,{onError:l}=t;function E(e,t,r){e.endLoc=c(),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,13);function f(e,t){return e.currentChar()===t?(e.next(),t):(CompileErrorCodes.EXPECTED_TOKEN,c(),"")}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 L(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function _(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="")=>{const o=e.currentPeek();return"{"===o?t:"@"!==o&&o?"|"===o?!(r===CHAR_SP||r===CHAR_LF):o===CHAR_SP?(e.peek(),n(!0,CHAR_SP)):o!==CHAR_LF||(e.peek(),n(!0,CHAR_LF)):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 y(e){return T(e,O)}function R(e){let t="",n="";for(;t=h(e);)n+=t;return n}function D(e){return e!==LITERAL_DELIMITER&&e!==CHAR_LF}function g(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,c(),""}}function b(e,t,n){f(e,t);let r="";for(let o=0;o<n;o++){const t=y(e);if(!t){CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE,c(),e.currentChar();break}r+=t}return`\\${t}${r}`}function U(e){return"{"!==e&&"}"!==e&&e!==CHAR_SP&&e!==CHAR_LF}function x(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,c()),e.next(),n=E(t,2,"{"),p(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(CompileErrorCodes.EMPTY_PLACEHOLDER,c()),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,c()),n=H(e,t)||C(t),t.braceNest=0,n;default:{let r=!0,o=!0,s=!0;if(N(e))return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c()),n=E(t,1,x(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(4===t.currentType||5===t.currentType||6===t.currentType))return CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c(),t.braceNest=0,M(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,t))return n=E(t,4,function(e){p(e);let t="",n="";for(;t=S(e);)n+=t;return e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c()),n}(e)),p(e),n;if(o=_(e,t))return n=E(t,5,function(e){p(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${R(e)}`):t+=R(e),e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c()),t}(e)),p(e),n;if(s=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,6,function(e){p(e),f(e,"'");let t="",n="";for(;t=T(e,D);)n+="\\"===t?g(e):t;const r=e.currentChar();return r===CHAR_LF||r===EOF?(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,c(),r===CHAR_LF&&(e.next(),f(e,"'")),n):(f(e,"'"),n)}(e)),p(e),n;if(!r&&!o&&!s)return n=E(t,12,function(e){p(e);let t="",n="";for(;t=T(e,U);)n+=t;return n}(e)),CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,c(),n.value,p(e),n;break}}return n}function H(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(7!==n&&8!==n&&11!==n&&9!==n||o!==CHAR_LF&&o!==CHAR_SP||(CompileErrorCodes.INVALID_LINKED_FORMAT,c()),o){case"@":return e.next(),r=E(t,7,"@"),t.inLinked=!0,r;case".":return p(e),e.next(),E(t,8,".");case":":return p(e),e.next(),E(t,9,":");default:return N(e)?(r=E(t,1,x(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(7!==n)return!1;d(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(7!==n&&11!==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(8!==n)return!1;d(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,t)?(p(e),E(t,11,function(e){let t="",n="";for(;t=k(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(9!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?L(e.peek()):!("@"===t||"|"===t||":"===t||"."===t||t===CHAR_SP||!t)&&(t===CHAR_LF?(e.peek(),r()):A(e,!1))},o=r();return e.resetPeek(),o}(e,t)?(p(e),"{"===o?v(e,t)||r:E(t,10,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===CHAR_SP?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(7===n&&(CompileErrorCodes.INVALID_LINKED_FORMAT,c()),t.braceNest=0,t.inLinked=!1,M(e,t))}}function M(e,t){let n={type:13};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,c(),e.next(),E(t,3,"}");case"@":return H(e,t)||C(t);default:if(N(e))return n=E(t,1,x(e)),t.braceNest=0,t.inLinked=!1,n;if(A(e))return E(t,0,function(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;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}(e))}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:s}=a;return a.lastType=e,a.lastOffset=t,a.lastStartLoc=n,a.lastEndLoc=s,a.offset=o(),a.startLoc=c(),r.currentChar()===EOF?E(a,13):M(r,a)},currentOffset:o,currentPosition:c,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}=e;function r(e,n,r){const o={type:e};return t&&(o.start=n,o.end=n,o.loc={start:r,end:r}),o}function o(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(),c=r(3,n.offset,n.startLoc);return c.value=t,o(c,e.currentOffset(),e.currentPosition()),c}function s(e,t){const n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(5,c,s);return i.index=parseInt(t,10),e.nextToken(),o(i,e.currentOffset(),e.currentPosition()),i}function i(e,t){const n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(4,c,s);return i.key=t,e.nextToken(),o(i,e.currentOffset(),e.currentPosition()),i}function a(e,t){const n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(9,c,s);return i.value=t.replace(KNOWN_ESCAPES,fromEscapeSequence),e.nextToken(),o(i,e.currentOffset(),e.currentPosition()),i}function u(e){const t=e.context(),n=r(6,t.offset,t.startLoc);let c=e.nextToken();if(8===c.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(8,c,s);return 11!==t.type?(CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,i.value="",o(i,c,s),{nextConsumeToken:t,node:i}):(null==t.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,getTokenCaption(t)),i.value=t.value||"",o(i,e.currentOffset(),e.currentPosition()),{node:i})}(e);n.modifier=t.node,c=t.nextConsumeToken||e.nextToken()}switch(9!==c.type&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),c=e.nextToken(),2===c.type&&(c=e.nextToken()),c.type){case 10:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=function(e,t){const n=e.context(),c=r(7,n.offset,n.startLoc);return c.value=t,o(c,e.currentOffset(),e.currentPosition()),c}(e,c.value||"");break;case 4:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=i(e,c.value||"");break;case 5:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=s(e,c.value||"");break;case 6:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=a(e,c.value||"");break;default:{CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const s=e.context(),i=r(7,s.offset,s.startLoc);return i.value="",o(i,s.offset,s.startLoc),n.key=i,o(n,s.offset,s.startLoc),{nextConsumeToken:c,node:n}}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function l(e){const t=e.context(),n=r(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let l=null;do{const r=l||e.nextToken();switch(l=null,r.type){case 0:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(c(e,r.value||""));break;case 5:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(s(e,r.value||""));break;case 4:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(i(e,r.value||""));break;case 6:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(a(e,r.value||""));break;case 7:{const t=u(e);n.items.push(t.node),l=t.nextConsumeToken||null;break}}}while(13!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function E(e){const t=e.context(),{offset:n,startLoc:c}=t,s=l(e);return 13===t.currentType?s:function(e,t,n,c){const s=e.context();let i=0===c.items.length;const a=r(1,t,n);a.cases=[],a.cases.push(c);do{const t=l(e);i||(i=0===t.items.length),a.cases.push(t)}while(13!==s.currentType);return i&&CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL,o(a,e.currentOffset(),e.currentPosition()),a}(e,n,c,s)}return{parse:function(n){const c=createTokenizer(n,assign({},e)),s=c.context(),i=r(0,s.offset,s.startLoc);return t&&i.loc&&(i.loc.source=n),i.body=E(c),e.onCacheKey&&(i.cacheKey=e.onCacheKey(n)),13!==s.currentType&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,s.lastStartLoc,n[s.offset]),o(i,c.currentOffset(),c.currentPosition()),i}}}function getTokenCaption(e){if(13===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:c}=t,s=!1!==t.location,i={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:o,needIndent:c,indentLevel:0};s&&e.loc&&(i.source=e.loc.source);function a(e,t){i.code+=e}function u(e,t=!0){const n=t?o:"";a(c?n+" ".repeat(e):n)}return{context:()=>i,push:a,indent:function(e=!0){const t=++i.indentLevel;e&&u(t)},deindent:function(e=!0){const t=--i.indentLevel;e&&u(t)},newline:function(){u(i.indentLevel)},helper:e=>`_${e}`,needIndent:()=>i.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 c=0;c<o&&(generateNode(e,t.items[c]),c!==o-1);c++)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,c=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",s=t.needIndent?t.needIndent:"arrow"!==n,i=e.helpers||[],a=createCodeGenerator(e,{mode:n,filename:r,sourceMap:o,breakLineCode:c,needIndent:s});a.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),a.indent(s),i.length>0&&(a.push(`const { ${join(i.map((e=>`${e}: _${e}`)),", ")} } = ctx`),a.newline()),a.push("return "),generateNode(a,e),a.deindent(s),a.push("}"),delete e.helpers;const{code:u,map:l}=a.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,c=null==n.optimize||n.optimize,s=createParser(n).parse(e);return r?(c&&optimize(s),o&&minify(s),{ast:s,code:""}):(transform(s,n),generate(s,n))}export{CompileErrorCodes,ERROR_DOMAIN,LOCATION_STUB,baseCompile,createCompileError,createLocation,createParser,createPosition,defaultOnError,detectHtmlTag,errorMessages};
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 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},COMPILE_ERROR_CODES_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:c}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}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,c=0;const s=e=>t[e]===CHAR_CR&&t[e+1]===CHAR_LF,i=e=>t[e]===CHAR_PS,a=e=>t[e]===CHAR_LS,u=e=>s(e)||(e=>t[e]===CHAR_LF)(e)||i(e)||a(e),E=e=>s(e)||i(e)||a(e)?CHAR_LF:t[e];function l(){return c=0,u(n)&&(r++,o=0),s(n)&&n++,n++,o++,t[n]}return{index:()=>n,line:()=>r,column:()=>o,peekOffset:()=>c,charAt:E,currentChar:()=>E(n),currentPeek:()=>E(n+c),next:l,peek:function(){return s(n+c)&&c++,c++,t[n+c]},reset:function(){n=0,r=1,o=1,c=0},resetPeek:function(e=0){c=e},skipToPeek:function(){const e=n+c;for(;e!==n;)l();c=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(),c=()=>createPosition(r.line(),r.column(),r.index()),s=c(),i=o(),a={currentType:13,offset:i,startLoc:s,endLoc:s,lastType:13,lastOffset:i,lastStartLoc:s,lastEndLoc:s,braceNest:0,inLinked:!1,text:""},u=()=>a,{onError:E}=t;function l(e,t,r){e.endLoc=c(),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=>l(e,13);function f(e,t){return e.currentChar()===t?(e.next(),t):(CompileErrorCodes.EXPECTED_TOKEN,c(),"")}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 L(e){if(e===EOF)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function _(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="")=>{const o=e.currentPeek();return"{"===o?t:"@"!==o&&o?"|"===o?!(r===CHAR_SP||r===CHAR_LF):o===CHAR_SP?(e.peek(),n(!0,CHAR_SP)):o!==CHAR_LF||(e.peek(),n(!0,CHAR_LF)):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 O(e){return T(e,P)}function h(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function R(e){return T(e,h)}function y(e){let t="",n="";for(;t=O(e);)n+=t;return n}function D(e){return e!==LITERAL_DELIMITER&&e!==CHAR_LF}function g(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,c(),""}}function b(e,t,n){f(e,t);let r="";for(let o=0;o<n;o++){const t=R(e);if(!t){CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE,c(),e.currentChar();break}r+=t}return`\\${t}${r}`}function U(e){return"{"!==e&&"}"!==e&&e!==CHAR_SP&&e!==CHAR_LF}function x(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,c()),e.next(),n=l(t,2,"{"),p(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(CompileErrorCodes.EMPTY_PLACEHOLDER,c()),e.next(),n=l(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,c()),n=H(e,t)||C(t),t.braceNest=0,n;default:{let r=!0,o=!0,s=!0;if(N(e))return t.braceNest>0&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c()),n=l(t,1,x(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(4===t.currentType||5===t.currentType||6===t.currentType))return CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c(),t.braceNest=0,M(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;d(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,t))return n=l(t,4,function(e){p(e);let t="",n="";for(;t=S(e);)n+=t;return e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c()),n}(e)),p(e),n;if(o=_(e,t))return n=l(t,5,function(e){p(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${y(e)}`):t+=y(e),e.currentChar()===EOF&&(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE,c()),t}(e)),p(e),n;if(s=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=l(t,6,function(e){p(e),f(e,"'");let t="",n="";for(;t=T(e,D);)n+="\\"===t?g(e):t;const r=e.currentChar();return r===CHAR_LF||r===EOF?(CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,c(),r===CHAR_LF&&(e.next(),f(e,"'")),n):(f(e,"'"),n)}(e)),p(e),n;if(!r&&!o&&!s)return n=l(t,12,function(e){p(e);let t="",n="";for(;t=T(e,U);)n+=t;return n}(e)),CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER,c(),n.value,p(e),n;break}}return n}function H(e,t){const{currentType:n}=t;let r=null;const o=e.currentChar();switch(7!==n&&8!==n&&11!==n&&9!==n||o!==CHAR_LF&&o!==CHAR_SP||(CompileErrorCodes.INVALID_LINKED_FORMAT,c()),o){case"@":return e.next(),r=l(t,7,"@"),t.inLinked=!0,r;case".":return p(e),e.next(),l(t,8,".");case":":return p(e),e.next(),l(t,9,":");default:return N(e)?(r=l(t,1,x(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(7!==n)return!1;d(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(7!==n&&11!==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(8!==n)return!1;d(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,t)?(p(e),l(t,11,function(e){let t="",n="";for(;t=k(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(9!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?L(e.peek()):!("@"===t||"|"===t||":"===t||"."===t||t===CHAR_SP||!t)&&(t===CHAR_LF?(e.peek(),r()):A(e,!1))},o=r();return e.resetPeek(),o}(e,t)?(p(e),"{"===o?v(e,t)||r:l(t,10,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===CHAR_SP?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(7===n&&(CompileErrorCodes.INVALID_LINKED_FORMAT,c()),t.braceNest=0,t.inLinked=!1,M(e,t))}}function M(e,t){let n={type:13};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,c(),e.next(),l(t,3,"}");case"@":return H(e,t)||C(t);default:if(N(e))return n=l(t,1,x(e)),t.braceNest=0,t.inLinked=!1,n;if(A(e))return l(t,0,function(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;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}(e))}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:s}=a;return a.lastType=e,a.lastOffset=t,a.lastStartLoc=n,a.lastEndLoc=s,a.offset=o(),a.startLoc=c(),r.currentChar()===EOF?l(a,13):M(r,a)},currentOffset:o,currentPosition:c,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}=e;function r(e,n,r){const o={type:e};return t&&(o.start=n,o.end=n,o.loc={start:r,end:r}),o}function o(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(),c=r(3,n.offset,n.startLoc);return c.value=t,o(c,e.currentOffset(),e.currentPosition()),c}function s(e,t){const n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(5,c,s);return i.index=parseInt(t,10),e.nextToken(),o(i,e.currentOffset(),e.currentPosition()),i}function i(e,t){const n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(4,c,s);return i.key=t,e.nextToken(),o(i,e.currentOffset(),e.currentPosition()),i}function a(e,t){const n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(9,c,s);return i.value=t.replace(KNOWN_ESCAPES,fromEscapeSequence),e.nextToken(),o(i,e.currentOffset(),e.currentPosition()),i}function u(e){const t=e.context(),n=r(6,t.offset,t.startLoc);let c=e.nextToken();if(8===c.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:c,lastStartLoc:s}=n,i=r(8,c,s);return 11!==t.type?(CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,i.value="",o(i,c,s),{nextConsumeToken:t,node:i}):(null==t.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,getTokenCaption(t)),i.value=t.value||"",o(i,e.currentOffset(),e.currentPosition()),{node:i})}(e);n.modifier=t.node,c=t.nextConsumeToken||e.nextToken()}switch(9!==c.type&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),c=e.nextToken(),2===c.type&&(c=e.nextToken()),c.type){case 10:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=function(e,t){const n=e.context(),c=r(7,n.offset,n.startLoc);return c.value=t,o(c,e.currentOffset(),e.currentPosition()),c}(e,c.value||"");break;case 4:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=i(e,c.value||"");break;case 5:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=s(e,c.value||"");break;case 6:null==c.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(c)),n.key=a(e,c.value||"");break;default:{CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const s=e.context(),i=r(7,s.offset,s.startLoc);return i.value="",o(i,s.offset,s.startLoc),n.key=i,o(n,s.offset,s.startLoc),{nextConsumeToken:c,node:n}}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function E(e){const t=e.context(),n=r(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let E=null;do{const r=E||e.nextToken();switch(E=null,r.type){case 0:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(c(e,r.value||""));break;case 5:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(s(e,r.value||""));break;case 4:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(i(e,r.value||""));break;case 6:null==r.value&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,getTokenCaption(r)),n.items.push(a(e,r.value||""));break;case 7:{const t=u(e);n.items.push(t.node),E=t.nextConsumeToken||null;break}}}while(13!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function l(e){const t=e.context(),{offset:n,startLoc:c}=t,s=E(e);return 13===t.currentType?s:function(e,t,n,c){const s=e.context();let i=0===c.items.length;const a=r(1,t,n);a.cases=[],a.cases.push(c);do{const t=E(e);i||(i=0===t.items.length),a.cases.push(t)}while(13!==s.currentType);return i&&CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL,o(a,e.currentOffset(),e.currentPosition()),a}(e,n,c,s)}return{parse:function(n){const c=createTokenizer(n,assign({},e)),s=c.context(),i=r(0,s.offset,s.startLoc);return t&&i.loc&&(i.loc.source=n),i.body=l(c),e.onCacheKey&&(i.cacheKey=e.onCacheKey(n)),13!==s.currentType&&(CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS,s.lastStartLoc,n[s.offset]),o(i,c.currentOffset(),c.currentPosition()),i}}}function getTokenCaption(e){if(13===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:c}=t,s=!1!==t.location,i={filename:r,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:o,needIndent:c,indentLevel:0};s&&e.loc&&(i.source=e.loc.source);function a(e,t){i.code+=e}function u(e,t=!0){const n=t?o:"";a(c?n+" ".repeat(e):n)}return{context:()=>i,push:a,indent:function(e=!0){const t=++i.indentLevel;e&&u(t)},deindent:function(e=!0){const t=--i.indentLevel;e&&u(t)},newline:function(){u(i.indentLevel)},helper:e=>`_${e}`,needIndent:()=>i.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 c=0;c<o&&(generateNode(e,t.items[c]),c!==o-1);c++)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,c=null!=t.breakLineCode?t.breakLineCode:"arrow"===n?";":"\n",s=t.needIndent?t.needIndent:"arrow"!==n,i=e.helpers||[],a=createCodeGenerator(e,{mode:n,filename:r,sourceMap:o,breakLineCode:c,needIndent:s});a.push("normal"===n?"function __msg__ (ctx) {":"(ctx) => {"),a.indent(s),i.length>0&&(a.push(`const { ${join(i.map((e=>`${e}: _${e}`)),", ")} } = ctx`),a.newline()),a.push("return "),generateNode(a,e),a.deindent(s),a.push("}"),delete e.helpers;const{code:u,map:E}=a.context();return{ast:e,code:u,map:E?E.toJSON():void 0}};function baseCompile(e,t={}){const n=assign({},t),r=!!n.jit,o=!!n.minify,c=null==n.optimize||n.optimize,s=createParser(n).parse(e);return r?(c&&optimize(s),o&&minify(s),{ast:s,code:""}):(transform(s,n),generate(s,n))}export{COMPILE_ERROR_CODES_EXTEND_POINT,CompileErrorCodes,ERROR_DOMAIN,LOCATION_STUB,baseCompile,createCompileError,createLocation,createParser,createPosition,defaultOnError,detectHtmlTag,errorMessages};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -66,12 +66,12 @@ var IntlifyMessageCompiler = (function (exports) {
66
66
  // generator error codes
67
67
  UNHANDLED_CODEGEN_NODE_TYPE: 15,
68
68
  // minifier error codes
69
- UNHANDLED_MINIFIER_NODE_TYPE: 16,
70
- // Special value for higher-order compilers to pick up the last code
71
- // to avoid collision of error codes. This should always be kept as the last
72
- // item.
73
- __EXTEND_POINT__: 17
69
+ UNHANDLED_MINIFIER_NODE_TYPE: 16
74
70
  };
71
+ // Special value for higher-order compilers to pick up the last code
72
+ // to avoid collision of error codes.
73
+ // This should always be kept as the last item.
74
+ const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
75
75
  /** @internal */
76
76
  const errorMessages = {
77
77
  // tokenizer error messages
@@ -1543,6 +1543,7 @@ var IntlifyMessageCompiler = (function (exports) {
1543
1543
  }
1544
1544
  }
1545
1545
 
1546
+ exports.COMPILE_ERROR_CODES_EXTEND_POINT = COMPILE_ERROR_CODES_EXTEND_POINT;
1546
1547
  exports.CompileErrorCodes = CompileErrorCodes;
1547
1548
  exports.ERROR_DOMAIN = ERROR_DOMAIN$2;
1548
1549
  exports.LOCATION_STUB = LOCATION_STUB;
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
6
- var IntlifyMessageCompiler=function(e){"use strict";function t(e,t,n){return{line:e,column:t,offset:n}}function n(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const r=Object.assign,c=e=>"string"==typeof e;function o(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const s={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16,__EXTEND_POINT__:17},u={[s.EXPECTED_TOKEN]:"Expected token: '{0}'",[s.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[s.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[s.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[s.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[s.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[s.EMPTY_PLACEHOLDER]:"Empty placeholder",[s.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[s.INVALID_LINKED_FORMAT]:"Invalid linked format",[s.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[s.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[s.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[s.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[s.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[s.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function a(e,t,n={}){const{domain:r,messages:c,args:o}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}const i=/<\/?[\w\s="/.':;#-\/]+>/,l=" ",E="\r",f="\n",L=String.fromCharCode(8232),d=String.fromCharCode(8233);function N(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>t[e]===E&&t[e+1]===f,u=e=>t[e]===d,a=e=>t[e]===L,i=e=>s(e)||(e=>t[e]===f)(e)||u(e)||a(e),l=e=>s(e)||u(e)||a(e)?f:t[e];function N(){return o=0,i(n)&&(r++,c=0),s(n)&&n++,n++,c++,t[n]}return{index:()=>n,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+o),next:N,peek:function(){return s(n+o)&&o++,o++,t[n+o]},reset:function(){n=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=n+o;for(;e!==n;)N();o=0}}}const _=void 0,p="'";function C(e,r={}){const c=!1!==r.location,o=N(e),u=()=>o.index(),a=()=>t(o.line(),o.column(),o.index()),i=a(),E=u(),L={currentType:13,offset:E,startLoc:i,endLoc:i,lastType:13,lastOffset:E,lastStartLoc:i,lastEndLoc:i,braceNest:0,inLinked:!1,text:""},d=()=>L,{onError:C}=r;function A(e,t,r){e.endLoc=a(),e.currentType=t;const o={type:t};return c&&(o.loc=n(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const T=e=>A(e,13);function k(e,t){return e.currentChar()===t?(e.next(),t):(s.EXPECTED_TOKEN,a(),"")}function I(e){let t="";for(;e.currentPeek()===l||e.currentPeek()===f;)t+=e.currentPeek(),e.peek();return t}function h(e){const t=I(e);return e.skipToPeek(),t}function P(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function S(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=function(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function y(e){I(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function D(e,t=!0){const n=(t=!1,r="")=>{const c=e.currentPeek();return"{"===c?t:"@"!==c&&c?"|"===c?!(r===l||r===f):c===l?(e.peek(),n(!0,l)):c!==f||(e.peek(),n(!0,f)):t},r=n();return t&&e.resetPeek(),r}function O(e,t){const n=e.currentChar();return n===_?_: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 b(e){return O(e,m)}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||45===t}function x(e){return O(e,U)}function v(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function R(e){return O(e,v)}function M(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function g(e){return O(e,M)}function X(e){let t="",n="";for(;t=R(e);)n+=t;return n}function Y(e){return e!==p&&e!==f}function K(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return w(e,t,4);case"U":return w(e,t,6);default:return s.UNKNOWN_ESCAPE_SEQUENCE,a(),""}}function w(e,t,n){k(e,t);let r="";for(let c=0;c<n;c++){const t=g(e);if(!t){s.INVALID_UNICODE_ESCAPE_SEQUENCE,a(),e.currentChar();break}r+=t}return`\\${t}${r}`}function H(e){return"{"!==e&&"}"!==e&&e!==l&&e!==f}function G(e){h(e);const t=k(e,"|");return h(e),t}function $(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(s.NOT_ALLOW_NEST_PLACEHOLDER,a()),e.next(),n=A(t,2,"{"),h(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(s.EMPTY_PLACEHOLDER,a()),e.next(),n=A(t,3,"}"),t.braceNest--,t.braceNest>0&&h(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=B(e,t)||T(t),t.braceNest=0,n;default:{let r=!0,c=!0,o=!0;if(y(e))return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=A(t,1,G(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(4===t.currentType||5===t.currentType||6===t.currentType))return s.UNTERMINATED_CLOSING_BRACE,a(),t.braceNest=0,V(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t))return n=A(t,4,function(e){h(e);let t="",n="";for(;t=x(e);)n+=t;return e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),n}(e)),h(e),n;if(c=S(e,t))return n=A(t,5,function(e){h(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${X(e)}`):t+=X(e),e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),t}(e)),h(e),n;if(o=function(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=e.currentPeek()===p;return e.resetPeek(),r}(e,t))return n=A(t,6,function(e){h(e),k(e,"'");let t="",n="";for(;t=O(e,Y);)n+="\\"===t?K(e):t;const r=e.currentChar();return r===f||r===_?(s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,a(),r===f&&(e.next(),k(e,"'")),n):(k(e,"'"),n)}(e)),h(e),n;if(!r&&!c&&!o)return n=A(t,12,function(e){h(e);let t="",n="";for(;t=O(e,H);)n+=t;return n}(e)),s.INVALID_TOKEN_IN_PLACEHOLDER,a(),n.value,h(e),n;break}}return n}function B(e,t){const{currentType:n}=t;let r=null;const c=e.currentChar();switch(7!==n&&8!==n&&11!==n&&9!==n||c!==f&&c!==l||(s.INVALID_LINKED_FORMAT,a()),c){case"@":return e.next(),r=A(t,7,"@"),t.inLinked=!0,r;case".":return h(e),e.next(),A(t,8,".");case":":return h(e),e.next(),A(t,9,":");default:return y(e)?(r=A(t,1,G(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(7!==n)return!1;I(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(7!==n&&11!==n)return!1;I(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(h(e),B(e,t)):function(e,t){const{currentType:n}=t;if(8!==n)return!1;I(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t)?(h(e),A(t,11,function(e){let t="",n="";for(;t=b(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(9!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?P(e.peek()):!("@"===t||"|"===t||":"===t||"."===t||t===l||!t)&&(t===f?(e.peek(),r()):D(e,!1))},c=r();return e.resetPeek(),c}(e,t)?(h(e),"{"===c?$(e,t)||r:A(t,10,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===l?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(7===n&&(s.INVALID_LINKED_FORMAT,a()),t.braceNest=0,t.inLinked=!1,V(e,t))}}function V(e,t){let n={type:13};if(t.braceNest>0)return $(e,t)||T(t);if(t.inLinked)return B(e,t)||T(t);switch(e.currentChar()){case"{":return $(e,t)||T(t);case"}":return s.UNBALANCED_CLOSING_BRACE,a(),e.next(),A(t,3,"}");case"@":return B(e,t)||T(t);default:if(y(e))return n=A(t,1,G(e)),t.braceNest=0,t.inLinked=!1,n;if(D(e))return A(t,0,function(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if(n===l||n===f)if(D(e))t+=n,e.next();else{if(y(e))break;t+=n,e.next()}else t+=n,e.next()}return t}(e))}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:r}=L;return L.lastType=e,L.lastOffset=t,L.lastStartLoc=n,L.lastEndLoc=r,L.offset=u(),L.startLoc=a(),o.currentChar()===_?A(L,13):V(o,L)},currentOffset:u,currentPosition:a,context:d}}const A="parser",T=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function k(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 I(e={}){const t=!1!==e.location,{onError:n}=e;function c(e,n,r){const c={type:e};return t&&(c.start=n,c.end=n,c.loc={start:r,end:r}),c}function o(e,n,r,c){c&&(e.type=c),t&&(e.end=n,e.loc&&(e.loc.end=r))}function u(e,t){const n=e.context(),r=c(3,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(5,r,s);return u.index=parseInt(t,10),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function i(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(4,r,s);return u.key=t,e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function l(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(9,r,s);return u.value=t.replace(T,k),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function E(e){const t=e.context(),n=c(6,t.offset,t.startLoc);let r=e.nextToken();if(8===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:u}=n,a=c(8,r,u);return 11!==t.type?(s.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",o(a,r,u),{nextConsumeToken:t,node:a}):(null==t.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,h(t)),a.value=t.value||"",o(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(9!==r.type&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 10:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=function(e,t){const n=e.context(),r=c(7,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 4:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=i(e,r.value||"");break;case 5:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=a(e,r.value||"");break;case 6:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=l(e,r.value||"");break;default:{s.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const u=e.context(),a=c(7,u.offset,u.startLoc);return a.value="",o(a,u.offset,u.startLoc),n.key=a,o(n,u.offset,u.startLoc),{nextConsumeToken:r,node:n}}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function f(e){const t=e.context(),n=c(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null;do{const c=r||e.nextToken();switch(r=null,c.type){case 0:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(u(e,c.value||""));break;case 5:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(a(e,c.value||""));break;case 4:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(i(e,c.value||""));break;case 6:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(l(e,c.value||""));break;case 7:{const t=E(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(13!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function L(e){const t=e.context(),{offset:n,startLoc:r}=t,u=f(e);return 13===t.currentType?u:function(e,t,n,r){const u=e.context();let a=0===r.items.length;const i=c(1,t,n);i.cases=[],i.cases.push(r);do{const t=f(e);a||(a=0===t.items.length),i.cases.push(t)}while(13!==u.currentType);return a&&s.MUST_HAVE_MESSAGES_IN_PLURAL,o(i,e.currentOffset(),e.currentPosition()),i}(e,n,r,u)}return{parse:function(n){const u=C(n,r({},e)),a=u.context(),i=c(0,a.offset,a.startLoc);return t&&i.loc&&(i.loc.source=n),i.body=L(u),e.onCacheKey&&(i.cacheKey=e.onCacheKey(n)),13!==a.currentType&&(s.UNEXPECTED_LEXICAL_ANALYSIS,a.lastStartLoc,n[a.offset]),o(i,u.currentOffset(),u.currentPosition()),i}}}function h(e){if(13===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function P(e,t){for(let n=0;n<e.length;n++)S(e[n],t)}function S(e,t){switch(e.type){case 1:P(e.cases,t),t.helper("plural");break;case 2:P(e.items,t);break;case 6:S(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 y(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&&S(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function D(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 O(e){switch(e.t=e.type,e.type){case 0:{const t=e;O(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++)O(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++)O(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;O(t.key),t.k=t.key,delete t.key,t.modifier&&(O(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 m(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?m(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&&(m(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&&(m(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")}(`),m(e,t.key),t.modifier?(e.push(", "),m(e,t.modifier),e.push(", _type")):e.push(", undefined, _type"),e.push(")")}(e,t);break;case 8:case 7:case 9:case 3:e.push(JSON.stringify(t.value),t);break;case 5:e.push(`${n("interpolate")}(${n("list")}(${t.index}))`,t);break;case 4:e.push(`${n("interpolate")}(${n("named")}(${JSON.stringify(t.key)}))`,t)}}return e.CompileErrorCodes=s,e.ERROR_DOMAIN=A,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=I(n).parse(e);return s?(a&&function(e){const t=e.body;2===t.type?D(t):t.cases.forEach((e=>D(e)))}(i),u&&O(i),{ast:i,code:""}):(y(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 "),m(l,e),l.deindent(a),l.push("}"),delete e.helpers;const{code:E,map:f}=l.context();return{ast:e,code:E,map:f?f.toJSON():void 0}})(i,n))},e.createCompileError=a,e.createLocation=n,e.createParser=I,e.createPosition=t,e.defaultOnError=function(e){throw e},e.detectHtmlTag=e=>i.test(e),e.errorMessages=u,e}({});
6
+ var IntlifyMessageCompiler=function(e){"use strict";function t(e,t,n){return{line:e,column:t,offset:n}}function n(e,t,n){const r={start:e,end:t};return null!=n&&(r.source=n),r}const r=Object.assign,c=e=>"string"==typeof e;function o(e,t=""){return e.reduce(((e,n,r)=>0===r?e+n:e+t+n),"")}const s={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16},u={[s.EXPECTED_TOKEN]:"Expected token: '{0}'",[s.INVALID_TOKEN_IN_PLACEHOLDER]:"Invalid token in placeholder: '{0}'",[s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]:"Unterminated single quote in placeholder",[s.UNKNOWN_ESCAPE_SEQUENCE]:"Unknown escape sequence: \\{0}",[s.INVALID_UNICODE_ESCAPE_SEQUENCE]:"Invalid unicode escape sequence: {0}",[s.UNBALANCED_CLOSING_BRACE]:"Unbalanced closing brace",[s.UNTERMINATED_CLOSING_BRACE]:"Unterminated closing brace",[s.EMPTY_PLACEHOLDER]:"Empty placeholder",[s.NOT_ALLOW_NEST_PLACEHOLDER]:"Not allowed nest placeholder",[s.INVALID_LINKED_FORMAT]:"Invalid linked format",[s.MUST_HAVE_MESSAGES_IN_PLURAL]:"Plural must have messages",[s.UNEXPECTED_EMPTY_LINKED_MODIFIER]:"Unexpected empty linked modifier",[s.UNEXPECTED_EMPTY_LINKED_KEY]:"Unexpected empty linked key",[s.UNEXPECTED_LEXICAL_ANALYSIS]:"Unexpected lexical analysis in token: '{0}'",[s.UNHANDLED_CODEGEN_NODE_TYPE]:"unhandled codegen node type: '{0}'",[s.UNHANDLED_MINIFIER_NODE_TYPE]:"unhandled mimifier node type: '{0}'"};function a(e,t,n={}){const{domain:r,messages:c,args:o}=n,s=new SyntaxError(String(e));return s.code=e,t&&(s.location=t),s.domain=r,s}const i=/<\/?[\w\s="/.':;#-\/]+>/,l=" ",E="\r",f="\n",L=String.fromCharCode(8232),d=String.fromCharCode(8233);function N(e){const t=e;let n=0,r=1,c=1,o=0;const s=e=>t[e]===E&&t[e+1]===f,u=e=>t[e]===d,a=e=>t[e]===L,i=e=>s(e)||(e=>t[e]===f)(e)||u(e)||a(e),l=e=>s(e)||u(e)||a(e)?f:t[e];function N(){return o=0,i(n)&&(r++,c=0),s(n)&&n++,n++,c++,t[n]}return{index:()=>n,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:l,currentChar:()=>l(n),currentPeek:()=>l(n+o),next:N,peek:function(){return s(n+o)&&o++,o++,t[n+o]},reset:function(){n=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=n+o;for(;e!==n;)N();o=0}}}const _=void 0,p="'";function C(e,r={}){const c=!1!==r.location,o=N(e),u=()=>o.index(),a=()=>t(o.line(),o.column(),o.index()),i=a(),E=u(),L={currentType:13,offset:E,startLoc:i,endLoc:i,lastType:13,lastOffset:E,lastStartLoc:i,lastEndLoc:i,braceNest:0,inLinked:!1,text:""},d=()=>L,{onError:C}=r;function A(e,t,r){e.endLoc=a(),e.currentType=t;const o={type:t};return c&&(o.loc=n(e.startLoc,e.endLoc)),null!=r&&(o.value=r),o}const T=e=>A(e,13);function k(e,t){return e.currentChar()===t?(e.next(),t):(s.EXPECTED_TOKEN,a(),"")}function I(e){let t="";for(;e.currentPeek()===l||e.currentPeek()===f;)t+=e.currentPeek(),e.peek();return t}function h(e){const t=I(e);return e.skipToPeek(),t}function P(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90||95===t}function S(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=function(e){if(e===_)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function y(e){I(e);const t="|"===e.currentPeek();return e.resetPeek(),t}function D(e,t=!0){const n=(t=!1,r="")=>{const c=e.currentPeek();return"{"===c?t:"@"!==c&&c?"|"===c?!(r===l||r===f):c===l?(e.peek(),n(!0,l)):c!==f||(e.peek(),n(!0,f)):t},r=n();return t&&e.resetPeek(),r}function O(e,t){const n=e.currentChar();return n===_?_: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 b(e){return O(e,m)}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||45===t}function x(e){return O(e,U)}function R(e){const t=e.charCodeAt(0);return t>=48&&t<=57}function v(e){return O(e,R)}function M(e){const t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function g(e){return O(e,M)}function X(e){let t="",n="";for(;t=v(e);)n+=t;return n}function Y(e){return e!==p&&e!==f}function K(e){const t=e.currentChar();switch(t){case"\\":case"'":return e.next(),`\\${t}`;case"u":return w(e,t,4);case"U":return w(e,t,6);default:return s.UNKNOWN_ESCAPE_SEQUENCE,a(),""}}function w(e,t,n){k(e,t);let r="";for(let c=0;c<n;c++){const t=g(e);if(!t){s.INVALID_UNICODE_ESCAPE_SEQUENCE,a(),e.currentChar();break}r+=t}return`\\${t}${r}`}function H(e){return"{"!==e&&"}"!==e&&e!==l&&e!==f}function G(e){h(e);const t=k(e,"|");return h(e),t}function $(e,t){let n=null;switch(e.currentChar()){case"{":return t.braceNest>=1&&(s.NOT_ALLOW_NEST_PLACEHOLDER,a()),e.next(),n=A(t,2,"{"),h(e),t.braceNest++,n;case"}":return t.braceNest>0&&2===t.currentType&&(s.EMPTY_PLACEHOLDER,a()),e.next(),n=A(t,3,"}"),t.braceNest--,t.braceNest>0&&h(e),t.inLinked&&0===t.braceNest&&(t.inLinked=!1),n;case"@":return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=B(e,t)||T(t),t.braceNest=0,n;default:{let r=!0,c=!0,o=!0;if(y(e))return t.braceNest>0&&(s.UNTERMINATED_CLOSING_BRACE,a()),n=A(t,1,G(e)),t.braceNest=0,t.inLinked=!1,n;if(t.braceNest>0&&(4===t.currentType||5===t.currentType||6===t.currentType))return s.UNTERMINATED_CLOSING_BRACE,a(),t.braceNest=0,V(e,t);if(r=function(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t))return n=A(t,4,function(e){h(e);let t="",n="";for(;t=x(e);)n+=t;return e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),n}(e)),h(e),n;if(c=S(e,t))return n=A(t,5,function(e){h(e);let t="";return"-"===e.currentChar()?(e.next(),t+=`-${X(e)}`):t+=X(e),e.currentChar()===_&&(s.UNTERMINATED_CLOSING_BRACE,a()),t}(e)),h(e),n;if(o=function(e,t){const{currentType:n}=t;if(2!==n)return!1;I(e);const r=e.currentPeek()===p;return e.resetPeek(),r}(e,t))return n=A(t,6,function(e){h(e),k(e,"'");let t="",n="";for(;t=O(e,Y);)n+="\\"===t?K(e):t;const r=e.currentChar();return r===f||r===_?(s.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,a(),r===f&&(e.next(),k(e,"'")),n):(k(e,"'"),n)}(e)),h(e),n;if(!r&&!c&&!o)return n=A(t,12,function(e){h(e);let t="",n="";for(;t=O(e,H);)n+=t;return n}(e)),s.INVALID_TOKEN_IN_PLACEHOLDER,a(),n.value,h(e),n;break}}return n}function B(e,t){const{currentType:n}=t;let r=null;const c=e.currentChar();switch(7!==n&&8!==n&&11!==n&&9!==n||c!==f&&c!==l||(s.INVALID_LINKED_FORMAT,a()),c){case"@":return e.next(),r=A(t,7,"@"),t.inLinked=!0,r;case".":return h(e),e.next(),A(t,8,".");case":":return h(e),e.next(),A(t,9,":");default:return y(e)?(r=A(t,1,G(e)),t.braceNest=0,t.inLinked=!1,r):function(e,t){const{currentType:n}=t;if(7!==n)return!1;I(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,t)||function(e,t){const{currentType:n}=t;if(7!==n&&11!==n)return!1;I(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,t)?(h(e),B(e,t)):function(e,t){const{currentType:n}=t;if(8!==n)return!1;I(e);const r=P(e.currentPeek());return e.resetPeek(),r}(e,t)?(h(e),A(t,11,function(e){let t="",n="";for(;t=b(e);)n+=t;return n}(e))):function(e,t){const{currentType:n}=t;if(9!==n)return!1;const r=()=>{const t=e.currentPeek();return"{"===t?P(e.peek()):!("@"===t||"|"===t||":"===t||"."===t||t===l||!t)&&(t===f?(e.peek(),r()):D(e,!1))},c=r();return e.resetPeek(),c}(e,t)?(h(e),"{"===c?$(e,t)||r:A(t,10,function(e){const t=n=>{const r=e.currentChar();return"{"!==r&&"@"!==r&&"|"!==r&&"("!==r&&")"!==r&&r?r===l?n:(n+=r,e.next(),t(n)):n};return t("")}(e))):(7===n&&(s.INVALID_LINKED_FORMAT,a()),t.braceNest=0,t.inLinked=!1,V(e,t))}}function V(e,t){let n={type:13};if(t.braceNest>0)return $(e,t)||T(t);if(t.inLinked)return B(e,t)||T(t);switch(e.currentChar()){case"{":return $(e,t)||T(t);case"}":return s.UNBALANCED_CLOSING_BRACE,a(),e.next(),A(t,3,"}");case"@":return B(e,t)||T(t);default:if(y(e))return n=A(t,1,G(e)),t.braceNest=0,t.inLinked=!1,n;if(D(e))return A(t,0,function(e){let t="";for(;;){const n=e.currentChar();if("{"===n||"}"===n||"@"===n||"|"===n||!n)break;if(n===l||n===f)if(D(e))t+=n,e.next();else{if(y(e))break;t+=n,e.next()}else t+=n,e.next()}return t}(e))}return n}return{nextToken:function(){const{currentType:e,offset:t,startLoc:n,endLoc:r}=L;return L.lastType=e,L.lastOffset=t,L.lastStartLoc=n,L.lastEndLoc=r,L.offset=u(),L.startLoc=a(),o.currentChar()===_?A(L,13):V(o,L)},currentOffset:u,currentPosition:a,context:d}}const A="parser",T=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function k(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 I(e={}){const t=!1!==e.location,{onError:n}=e;function c(e,n,r){const c={type:e};return t&&(c.start=n,c.end=n,c.loc={start:r,end:r}),c}function o(e,n,r,c){c&&(e.type=c),t&&(e.end=n,e.loc&&(e.loc.end=r))}function u(e,t){const n=e.context(),r=c(3,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}function a(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(5,r,s);return u.index=parseInt(t,10),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function i(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(4,r,s);return u.key=t,e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function l(e,t){const n=e.context(),{lastOffset:r,lastStartLoc:s}=n,u=c(9,r,s);return u.value=t.replace(T,k),e.nextToken(),o(u,e.currentOffset(),e.currentPosition()),u}function E(e){const t=e.context(),n=c(6,t.offset,t.startLoc);let r=e.nextToken();if(8===r.type){const t=function(e){const t=e.nextToken(),n=e.context(),{lastOffset:r,lastStartLoc:u}=n,a=c(8,r,u);return 11!==t.type?(s.UNEXPECTED_EMPTY_LINKED_MODIFIER,n.lastStartLoc,a.value="",o(a,r,u),{nextConsumeToken:t,node:a}):(null==t.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,n.lastStartLoc,h(t)),a.value=t.value||"",o(a,e.currentOffset(),e.currentPosition()),{node:a})}(e);n.modifier=t.node,r=t.nextConsumeToken||e.nextToken()}switch(9!==r.type&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),r=e.nextToken(),2===r.type&&(r=e.nextToken()),r.type){case 10:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=function(e,t){const n=e.context(),r=c(7,n.offset,n.startLoc);return r.value=t,o(r,e.currentOffset(),e.currentPosition()),r}(e,r.value||"");break;case 4:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=i(e,r.value||"");break;case 5:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=a(e,r.value||"");break;case 6:null==r.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(r)),n.key=l(e,r.value||"");break;default:{s.UNEXPECTED_EMPTY_LINKED_KEY,t.lastStartLoc;const u=e.context(),a=c(7,u.offset,u.startLoc);return a.value="",o(a,u.offset,u.startLoc),n.key=a,o(n,u.offset,u.startLoc),{nextConsumeToken:r,node:n}}}return o(n,e.currentOffset(),e.currentPosition()),{node:n}}function f(e){const t=e.context(),n=c(2,1===t.currentType?e.currentOffset():t.offset,1===t.currentType?t.endLoc:t.startLoc);n.items=[];let r=null;do{const c=r||e.nextToken();switch(r=null,c.type){case 0:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(u(e,c.value||""));break;case 5:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(a(e,c.value||""));break;case 4:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(i(e,c.value||""));break;case 6:null==c.value&&(s.UNEXPECTED_LEXICAL_ANALYSIS,t.lastStartLoc,h(c)),n.items.push(l(e,c.value||""));break;case 7:{const t=E(e);n.items.push(t.node),r=t.nextConsumeToken||null;break}}}while(13!==t.currentType&&1!==t.currentType);return o(n,1===t.currentType?t.lastOffset:e.currentOffset(),1===t.currentType?t.lastEndLoc:e.currentPosition()),n}function L(e){const t=e.context(),{offset:n,startLoc:r}=t,u=f(e);return 13===t.currentType?u:function(e,t,n,r){const u=e.context();let a=0===r.items.length;const i=c(1,t,n);i.cases=[],i.cases.push(r);do{const t=f(e);a||(a=0===t.items.length),i.cases.push(t)}while(13!==u.currentType);return a&&s.MUST_HAVE_MESSAGES_IN_PLURAL,o(i,e.currentOffset(),e.currentPosition()),i}(e,n,r,u)}return{parse:function(n){const u=C(n,r({},e)),a=u.context(),i=c(0,a.offset,a.startLoc);return t&&i.loc&&(i.loc.source=n),i.body=L(u),e.onCacheKey&&(i.cacheKey=e.onCacheKey(n)),13!==a.currentType&&(s.UNEXPECTED_LEXICAL_ANALYSIS,a.lastStartLoc,n[a.offset]),o(i,u.currentOffset(),u.currentPosition()),i}}}function h(e){if(13===e.type)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function P(e,t){for(let n=0;n<e.length;n++)S(e[n],t)}function S(e,t){switch(e.type){case 1:P(e.cases,t),t.helper("plural");break;case 2:P(e.items,t);break;case 6:S(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 y(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&&S(e.body,n);const r=n.context();e.helpers=Array.from(r.helpers)}function D(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 O(e){switch(e.t=e.type,e.type){case 0:{const t=e;O(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++)O(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++)O(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;O(t.key),t.k=t.key,delete t.key,t.modifier&&(O(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 m(e,t){const{helper:n}=e;switch(t.type){case 0:!function(e,t){t.body?m(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&&(m(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&&(m(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")}(`),m(e,t.key),t.modifier?(e.push(", "),m(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.COMPILE_ERROR_CODES_EXTEND_POINT=17,e.CompileErrorCodes=s,e.ERROR_DOMAIN=A,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=I(n).parse(e);return s?(a&&function(e){const t=e.body;2===t.type?D(t):t.cases.forEach((e=>D(e)))}(i),u&&O(i),{ast:i,code:""}):(y(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 "),m(l,e),l.deindent(a),l.push("}"),delete e.helpers;const{code:E,map:f}=l.context();return{ast:e,code:E,map:f?f.toJSON():void 0}})(i,n))},e.createCompileError=a,e.createLocation=n,e.createParser=I,e.createPosition=t,e.defaultOnError=function(e){throw e},e.detectHtmlTag=e=>i.test(e),e.errorMessages=u,e}({});
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -40,12 +40,12 @@ const CompileErrorCodes = {
40
40
  // generator error codes
41
41
  UNHANDLED_CODEGEN_NODE_TYPE: 15,
42
42
  // minifier error codes
43
- UNHANDLED_MINIFIER_NODE_TYPE: 16,
44
- // Special value for higher-order compilers to pick up the last code
45
- // to avoid collision of error codes. This should always be kept as the last
46
- // item.
47
- __EXTEND_POINT__: 17
43
+ UNHANDLED_MINIFIER_NODE_TYPE: 16
48
44
  };
45
+ // Special value for higher-order compilers to pick up the last code
46
+ // to avoid collision of error codes.
47
+ // This should always be kept as the last item.
48
+ const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
49
49
  /** @internal */
50
50
  const errorMessages = {
51
51
  // tokenizer error messages
@@ -1518,4 +1518,4 @@ function baseCompile(source, options = {}) {
1518
1518
  }
1519
1519
  }
1520
1520
 
1521
- export { CompileErrorCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages };
1521
+ export { COMPILE_ERROR_CODES_EXTEND_POINT, CompileErrorCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -41,12 +41,12 @@ const CompileErrorCodes = {
41
41
  // generator error codes
42
42
  UNHANDLED_CODEGEN_NODE_TYPE: 15,
43
43
  // minifier error codes
44
- UNHANDLED_MINIFIER_NODE_TYPE: 16,
45
- // Special value for higher-order compilers to pick up the last code
46
- // to avoid collision of error codes. This should always be kept as the last
47
- // item.
48
- __EXTEND_POINT__: 17
44
+ UNHANDLED_MINIFIER_NODE_TYPE: 16
49
45
  };
46
+ // Special value for higher-order compilers to pick up the last code
47
+ // to avoid collision of error codes.
48
+ // This should always be kept as the last item.
49
+ const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
50
50
  /** @internal */
51
51
  const errorMessages = {
52
52
  // tokenizer error messages
@@ -1575,4 +1575,4 @@ function baseCompile(source, options = {}) {
1575
1575
  }
1576
1576
  }
1577
1577
 
1578
- export { CompileErrorCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages };
1578
+ export { COMPILE_ERROR_CODES_EXTEND_POINT, CompileErrorCodes, ERROR_DOMAIN$2 as ERROR_DOMAIN, LOCATION_STUB, baseCompile, createCompileError, createLocation, createParser, createPosition, defaultOnError, detectHtmlTag, errorMessages };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * message-compiler v10.0.0-alpha.3
2
+ * message-compiler v10.0.0-alpha.5
3
3
  * (c) 2024 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -43,12 +43,12 @@ const CompileErrorCodes = {
43
43
  // generator error codes
44
44
  UNHANDLED_CODEGEN_NODE_TYPE: 15,
45
45
  // minifier error codes
46
- UNHANDLED_MINIFIER_NODE_TYPE: 16,
47
- // Special value for higher-order compilers to pick up the last code
48
- // to avoid collision of error codes. This should always be kept as the last
49
- // item.
50
- __EXTEND_POINT__: 17
46
+ UNHANDLED_MINIFIER_NODE_TYPE: 16
51
47
  };
48
+ // Special value for higher-order compilers to pick up the last code
49
+ // to avoid collision of error codes.
50
+ // This should always be kept as the last item.
51
+ const COMPILE_ERROR_CODES_EXTEND_POINT = 17;
52
52
  /** @internal */
53
53
  const errorMessages = {
54
54
  // tokenizer error messages
@@ -1559,6 +1559,7 @@ function baseCompile(source, options = {}) {
1559
1559
  }
1560
1560
  }
1561
1561
 
1562
+ exports.COMPILE_ERROR_CODES_EXTEND_POINT = COMPILE_ERROR_CODES_EXTEND_POINT;
1562
1563
  exports.CompileErrorCodes = CompileErrorCodes;
1563
1564
  exports.ERROR_DOMAIN = ERROR_DOMAIN;
1564
1565
  exports.LOCATION_STUB = LOCATION_STUB;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlify/message-compiler",
3
- "version": "10.0.0-alpha.3",
3
+ "version": "10.0.0-alpha.5",
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": "10.0.0-alpha.3"
37
+ "@intlify/shared": "10.0.0-alpha.5"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">= 16"
@@ -53,6 +53,7 @@
53
53
  "exports": {
54
54
  ".": {
55
55
  "types": "./dist/message-compiler.d.ts",
56
+ "import": "./dist/message-compiler.mjs",
56
57
  "browser": "./dist/message-compiler.esm-browser.js",
57
58
  "node": {
58
59
  "import": {
@@ -65,8 +66,7 @@
65
66
  "development": "./dist/message-compiler.cjs",
66
67
  "default": "./index.js"
67
68
  }
68
- },
69
- "import": "./dist/message-compiler.mjs"
69
+ }
70
70
  },
71
71
  "./dist/*": "./dist/*",
72
72
  "./package.json": "./package.json"