@intlify/message-compiler
Advanced tools
Comparing version 9.0.0-beta.15 to 9.0.0-beta.16
/*! | ||
* @intlify/message-compiler v9.0.0-beta.15 | ||
* @intlify/message-compiler v9.0.0-beta.16 | ||
* (c) 2020 kazuya kawaguchi | ||
@@ -28,3 +28,5 @@ * Released under the MIT License. | ||
[10 /* MUST_HAVE_MESSAGES_IN_PLURAL */]: `Plural must have messages`, | ||
[11 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
[11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */]: `Unexpected empty linked modifier`, | ||
[12 /* UNEXPECTED_EMPTY_LINKED_KEY */]: `Unexpected empty linked key`, | ||
[13 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
}; | ||
@@ -888,3 +890,3 @@ function createCompileError(code, loc, optinos = {}) { | ||
// empty modifier | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */, context.lastStartLoc, 0); | ||
node.value = ''; | ||
@@ -899,3 +901,3 @@ endNode(node, offset, loc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -926,3 +928,3 @@ node.value = token.value || ''; | ||
if (token.type !== 10 /* LinkedDelimiter */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -937,3 +939,3 @@ token = tokenizer.nextToken(); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -944,3 +946,3 @@ linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -951,3 +953,3 @@ linkedNode.key = parseNamed(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -958,3 +960,3 @@ linkedNode.key = parseList(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -965,3 +967,3 @@ linkedNode.key = parseLiteral(tokenizer, token.value || ''); | ||
// empty key | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 12 /* UNEXPECTED_EMPTY_LINKED_KEY */, context.lastStartLoc, 0); | ||
const nextContext = tokenizer.context(); | ||
@@ -1000,3 +1002,3 @@ const emptyLinkedKeyNode = startNode(7 /* LinkedKey */, nextContext.offset, nextContext.startLoc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1007,3 +1009,3 @@ node.items.push(parseText(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1014,3 +1016,3 @@ node.items.push(parseList(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1021,3 +1023,3 @@ node.items.push(parseNamed(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1084,3 +1086,3 @@ node.items.push(parseLiteral(tokenizer, token.value || '')); | ||
if (context.currentType !== 14 /* EOF */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, context.currentType); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, source[context.offset] || ''); | ||
} | ||
@@ -1092,2 +1094,9 @@ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); | ||
} | ||
function getTokenCaption(token) { | ||
if (token.type === 14 /* EOF */) { | ||
return 'EOF'; | ||
} | ||
const name = (token.value || '').replace(/\r?\n/gu, '\\n'); | ||
return name.length > 10 ? name.slice(0, 9) + '…' : name; | ||
} | ||
@@ -1094,0 +1103,0 @@ function createTransformer(ast, options = {} // eslint-disable-line |
/*! | ||
* @intlify/message-compiler v9.0.0-beta.15 | ||
* @intlify/message-compiler v9.0.0-beta.16 | ||
* (c) 2020 kazuya kawaguchi | ||
@@ -28,3 +28,5 @@ * Released under the MIT License. | ||
[10 /* MUST_HAVE_MESSAGES_IN_PLURAL */]: `Plural must have messages`, | ||
[11 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
[11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */]: `Unexpected empty linked modifier`, | ||
[12 /* UNEXPECTED_EMPTY_LINKED_KEY */]: `Unexpected empty linked key`, | ||
[13 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
}; | ||
@@ -887,3 +889,3 @@ function createCompileError(code, loc, optinos = {}) { | ||
// empty modifier | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */, context.lastStartLoc, 0); | ||
node.value = ''; | ||
@@ -898,3 +900,3 @@ endNode(node, offset, loc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -925,3 +927,3 @@ node.value = token.value || ''; | ||
if (token.type !== 10 /* LinkedDelimiter */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -936,3 +938,3 @@ token = tokenizer.nextToken(); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -943,3 +945,3 @@ linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -950,3 +952,3 @@ linkedNode.key = parseNamed(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -957,3 +959,3 @@ linkedNode.key = parseList(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -964,3 +966,3 @@ linkedNode.key = parseLiteral(tokenizer, token.value || ''); | ||
// empty key | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 12 /* UNEXPECTED_EMPTY_LINKED_KEY */, context.lastStartLoc, 0); | ||
const nextContext = tokenizer.context(); | ||
@@ -999,3 +1001,3 @@ const emptyLinkedKeyNode = startNode(7 /* LinkedKey */, nextContext.offset, nextContext.startLoc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1006,3 +1008,3 @@ node.items.push(parseText(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1013,3 +1015,3 @@ node.items.push(parseList(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1020,3 +1022,3 @@ node.items.push(parseNamed(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1083,3 +1085,3 @@ node.items.push(parseLiteral(tokenizer, token.value || '')); | ||
if (context.currentType !== 14 /* EOF */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, context.currentType); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, source[context.offset] || ''); | ||
} | ||
@@ -1091,2 +1093,9 @@ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); | ||
} | ||
function getTokenCaption(token) { | ||
if (token.type === 14 /* EOF */) { | ||
return 'EOF'; | ||
} | ||
const name = (token.value || '').replace(/\r?\n/gu, '\\n'); | ||
return name.length > 10 ? name.slice(0, 9) + '…' : name; | ||
} | ||
@@ -1093,0 +1102,0 @@ function createTransformer(ast, options = {} // eslint-disable-line |
@@ -42,4 +42,6 @@ import { RawSourceMap } from 'source-map'; | ||
MUST_HAVE_MESSAGES_IN_PLURAL = 10, | ||
UNEXPECTED_LEXICAL_ANALYSIS = 11, | ||
__EXTEND_POINT__ = 12 | ||
UNEXPECTED_EMPTY_LINKED_MODIFIER = 11, | ||
UNEXPECTED_EMPTY_LINKED_KEY = 12, | ||
UNEXPECTED_LEXICAL_ANALYSIS = 13, | ||
__EXTEND_POINT__ = 14 | ||
} | ||
@@ -46,0 +48,0 @@ |
/*! | ||
* @intlify/message-compiler v9.0.0-beta.15 | ||
* @intlify/message-compiler v9.0.0-beta.16 | ||
* (c) 2020 kazuya kawaguchi | ||
@@ -42,3 +42,5 @@ * Released under the MIT License. | ||
[10 /* MUST_HAVE_MESSAGES_IN_PLURAL */]: `Plural must have messages`, | ||
[11 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
[11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */]: `Unexpected empty linked modifier`, | ||
[12 /* UNEXPECTED_EMPTY_LINKED_KEY */]: `Unexpected empty linked key`, | ||
[13 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
}; | ||
@@ -902,3 +904,3 @@ function createCompileError(code, loc, optinos = {}) { | ||
// empty modifier | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */, context.lastStartLoc, 0); | ||
node.value = ''; | ||
@@ -913,3 +915,3 @@ endNode(node, offset, loc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -940,3 +942,3 @@ node.value = token.value || ''; | ||
if (token.type !== 10 /* LinkedDelimiter */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -951,3 +953,3 @@ token = tokenizer.nextToken(); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -958,3 +960,3 @@ linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -965,3 +967,3 @@ linkedNode.key = parseNamed(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -972,3 +974,3 @@ linkedNode.key = parseList(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -979,3 +981,3 @@ linkedNode.key = parseLiteral(tokenizer, token.value || ''); | ||
// empty key | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 12 /* UNEXPECTED_EMPTY_LINKED_KEY */, context.lastStartLoc, 0); | ||
const nextContext = tokenizer.context(); | ||
@@ -1014,3 +1016,3 @@ const emptyLinkedKeyNode = startNode(7 /* LinkedKey */, nextContext.offset, nextContext.startLoc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1021,3 +1023,3 @@ node.items.push(parseText(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1028,3 +1030,3 @@ node.items.push(parseList(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1035,3 +1037,3 @@ node.items.push(parseNamed(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1098,3 +1100,3 @@ node.items.push(parseLiteral(tokenizer, token.value || '')); | ||
if (context.currentType !== 14 /* EOF */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, context.currentType); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, source[context.offset] || ''); | ||
} | ||
@@ -1106,2 +1108,9 @@ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); | ||
} | ||
function getTokenCaption(token) { | ||
if (token.type === 14 /* EOF */) { | ||
return 'EOF'; | ||
} | ||
const name = (token.value || '').replace(/\r?\n/gu, '\\n'); | ||
return name.length > 10 ? name.slice(0, 9) + '…' : name; | ||
} | ||
@@ -1108,0 +1117,0 @@ function createTransformer(ast, options = {} // eslint-disable-line |
/*! | ||
* @intlify/message-compiler v9.0.0-beta.15 | ||
* @intlify/message-compiler v9.0.0-beta.16 | ||
* (c) 2020 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/ | ||
const e=e=>"string"==typeof e,n={0:"Expected token: '{0}'",1:"Invalid token in placeholder: '{0}'",2:"Unterminated single quote in placeholder",3:"Unknown escape sequence: \\{0}",4:"Invalid unicode escape sequence: {0}",5:"Unbalanced closing brace",6:"Unterminated closing brace",7:"Empty placeholder",8:"Not allowed nest placeholder",9:"Invalid linked format",10:"Plural must have messages",11:"Unexpected lexical analysis in token: '{0}'"};function t(e,n,t={}){const{domain:r}=t,c=new SyntaxError(String(e));return c.code=e,n&&(c.location=n),c.domain=r,c}function r(e){throw e}const c={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}};function o(e,n,t){return{line:e,column:n,offset:t}}function s(e,n,t){const r={start:e,end:n};return null!=t&&(r.source=t),r}const u=String.fromCharCode(8232),i=String.fromCharCode(8233);function a(e){const n=e;let t=0,r=1,c=1,o=0;const s=e=>"\r"===n[e]&&"\n"===n[e+1],a=e=>n[e]===i,f=e=>n[e]===u,l=e=>s(e)||(e=>"\n"===n[e])(e)||a(e)||f(e),d=e=>s(e)||a(e)||f(e)?"\n":n[e];function p(){return o=0,l(t)&&(r++,c=0),s(t)&&t++,t++,c++,n[t]}return{index:()=>t,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:d,currentChar:()=>d(t),currentPeek:()=>d(t+o),next:p,peek:function(){return s(t+o)&&o++,o++,n[t+o]},reset:function(){t=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=t+o;for(;e!==t;)p();o=0}}}const f=void 0;function l(e,n={}){const t=!1!==n.location,r=a(e),c=()=>r.index(),u=()=>o(r.line(),r.column(),r.index()),i=u(),l=c(),d={currentType:14,offset:l,startLoc:i,endLoc:i,lastType:14,lastOffset:l,lastStartLoc:i,lastEndLoc:i,braceNest:0,inLinked:!1,text:""},p=()=>d,{onError:k}=n;function h(e,n,r){e.endLoc=u(),e.currentType=n;const c={type:n};return t&&(c.loc=s(e.startLoc,e.endLoc)),null!=r&&(c.value=r),c}const x=e=>h(e,14);function y(e,n){return e.currentChar()===n?(e.next(),n):(u(),"")}function m(e){let n="";for(;" "===e.currentPeek()||"\n"===e.currentPeek();)n+=e.currentPeek(),e.peek();return n}function b(e){const n=m(e);return e.skipToPeek(),n}function L(e){if(e===f)return!1;const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}function T(e,n){const{currentType:t}=n;if(2!==t)return!1;m(e);const r=function(e){if(e===f)return!1;const n=e.charCodeAt(0);return n>=48&&n<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function P(e){m(e);const n="|"===e.currentPeek();return e.resetPeek(),n}function C(e,n=!0){const t=(n=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&n:"@"!==o&&o?"%"===o?(e.peek(),t(n,"%",!0)):"|"===o?!("%"!==r&&!c)||!(" "===r||"\n"===r):" "===o?(e.peek(),t(!0," ",c)):"\n"!==o||(e.peek(),t(!0,"\n",c)):"%"===r||n},r=t();return n&&e.resetPeek(),r}function v(e,n){const t=e.currentChar();return t===f?f:n(t)?(e.next(),t):null}function O(e){return v(e,(e=>{const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||95===n||36===n}))}function N(e){return v(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57}))}function g(e){return v(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102}))}function w(e){let n="",t="";for(;n=N(e);)t+=n;return t}function $(e){const n=e.currentChar();switch(n){case"\\":case"'":return e.next(),`\\${n}`;case"u":return S(e,n,4);case"U":return S(e,n,6);default:return u(),""}}function S(e,n,t){y(e,n);let r="";for(let n=0;n<t;n++){const n=g(e);if(!n){u(),e.currentChar();break}r+=n}return`\\${n}${r}`}function I(e){b(e);const n=y(e,"|");return b(e),n}function A(e,n){let t=null;switch(e.currentChar()){case"{":return n.braceNest>=1&&u(),e.next(),t=h(n,2,"{"),b(e),n.braceNest++,t;case"}":return n.braceNest>0&&2===n.currentType&&u(),e.next(),t=h(n,3,"}"),n.braceNest--,n.braceNest>0&&b(e),n.inLinked&&0===n.braceNest&&(n.inLinked=!1),t;case"@":return n.braceNest>0&&u(),t=E(e,n)||x(n),n.braceNest=0,t;default:let r=!0,c=!0,o=!0;if(P(e))return n.braceNest>0&&u(),t=h(n,1,I(e)),n.braceNest=0,n.inLinked=!1,t;if(n.braceNest>0&&(5===n.currentType||6===n.currentType||7===n.currentType))return u(),n.braceNest=0,U(e,n);if(r=function(e,n){const{currentType:t}=n;if(2!==t)return!1;m(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,n))return t=h(n,5,function(e){b(e);let n="",t="";for(;n=O(e);)t+=n;return e.currentChar()===f&&u(),t}(e)),b(e),t;if(c=T(e,n))return t=h(n,6,function(e){b(e);let n="";return"-"===e.currentChar()?(e.next(),n+=`-${w(e)}`):n+=w(e),e.currentChar()===f&&u(),n}(e)),b(e),t;if(o=function(e,n){const{currentType:t}=n;if(2!==t)return!1;m(e);const r="'"===e.currentPeek();return e.resetPeek(),r}(e,n))return t=h(n,7,function(e){b(e),y(e,"'");let n="",t="";const r=e=>"'"!==e&&"\n"!==e;for(;n=v(e,r);)t+="\\"===n?$(e):n;const c=e.currentChar();return"\n"===c||c===f?(u(),"\n"===c&&(e.next(),y(e,"'")),t):(y(e,"'"),t)}(e)),b(e),t;if(!r&&!c&&!o)return t=h(n,13,function(e){b(e);let n="",t="";const r=e=>"{"!==e&&"}"!==e&&" "!==e&&"\n"!==e;for(;n=v(e,r);)t+=n;return t}(e)),u(),b(e),t}return t}function E(e,n){const{currentType:t}=n;let r=null;const c=e.currentChar();switch(8!==t&&9!==t&&12!==t&&10!==t||"\n"!==c&&" "!==c||u(),c){case"@":return e.next(),r=h(n,8,"@"),n.inLinked=!0,r;case".":return b(e),e.next(),h(n,9,".");case":":return b(e),e.next(),h(n,10,":");default:return P(e)?(r=h(n,1,I(e)),n.braceNest=0,n.inLinked=!1,r):function(e,n){const{currentType:t}=n;if(8!==t)return!1;m(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,n)||function(e,n){const{currentType:t}=n;if(8!==t&&12!==t)return!1;m(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,n)?(b(e),E(e,n)):function(e,n){const{currentType:t}=n;if(9!==t)return!1;m(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,n)?(b(e),h(n,12,function(e){let n="",t="";for(;n=O(e);)t+=n;return t}(e))):function(e,n){const{currentType:t}=n;if(10!==t)return!1;const r=()=>{const n=e.currentPeek();return"{"===n?L(e.peek()):!("@"===n||"%"===n||"|"===n||":"===n||"."===n||" "===n||!n)&&("\n"===n?(e.peek(),r()):L(n))},c=r();return e.resetPeek(),c}(e,n)?(b(e),"{"===c?A(e,n)||r:h(n,11,function(e){const n=(t=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&c?" "===c?r:"\n"===c?(r+=c,e.next(),n(t,r)):(r+=c,e.next(),n(!0,r)):r};return n(!1,"")}(e))):(8===t&&u(),n.braceNest=0,n.inLinked=!1,U(e,n))}}function U(e,n){let t={type:14};if(n.braceNest>0)return A(e,n)||x(n);if(n.inLinked)return E(e,n)||x(n);const r=e.currentChar();switch(r){case"{":return A(e,n)||x(n);case"}":return u(),e.next(),h(n,3,"}");case"@":return E(e,n)||x(n);default:if(P(e))return t=h(n,1,I(e)),n.braceNest=0,n.inLinked=!1,t;if(C(e))return h(n,0,function(e){const n=t=>{const r=e.currentChar();return"{"!==r&&"}"!==r&&"@"!==r&&r?"%"===r?C(e)?(t+=r,e.next(),n(t)):t:"|"===r?t:" "===r||"\n"===r?C(e)?(t+=r,e.next(),n(t)):P(e)?t:(t+=r,e.next(),n(t)):(t+=r,e.next(),n(t)):t};return n("")}(e));if("%"===r)return e.next(),h(n,4,"%")}return t}return{nextToken:function(){const{currentType:e,offset:n,startLoc:t,endLoc:o}=d;return d.lastType=e,d.lastOffset=n,d.lastStartLoc=t,d.lastEndLoc=o,d.offset=c(),d.startLoc=u(),r.currentChar()===f?h(d,14):U(r,d)},currentOffset:c,currentPosition:u,context:p}}const d="parser",p=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function k(e,n,t){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(n||t,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function h(e={}){const n=!1!==e.location,{onError:t}=e;function r(e,t,r){const c={type:e,start:t,end:t};return n&&(c.loc={start:r,end:r}),c}function c(e,t,r,c){e.end=t,c&&(e.type=c),n&&e.loc&&(e.loc.end=r)}function o(e,n){const t=e.context(),o=r(3,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}function s(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(5,o,s);return u.index=parseInt(n,10),e.nextToken(),c(u,e.currentOffset(),e.currentPosition()),u}function u(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(4,o,s);return u.key=n,e.nextToken(),c(u,e.currentOffset(),e.currentPosition()),u}function i(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(9,o,s);return u.value=n.replace(p,k),e.nextToken(),c(u,e.currentOffset(),e.currentPosition()),u}function a(e){const n=e.context(),t=r(6,n.offset,n.startLoc);let o=e.nextToken();if(9===o.type){const n=function(e){const n=e.nextToken(),t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(8,o,s);return 12!==n.type?(u.value="",c(u,o,s),{nextConsumeToken:n,node:u}):(u.value=n.value||"",c(u,e.currentOffset(),e.currentPosition()),{node:u})}(e);t.modifier=n.node,o=n.nextConsumeToken||e.nextToken()}switch(o=e.nextToken(),2===o.type&&(o=e.nextToken()),o.type){case 11:t.key=function(e,n){const t=e.context(),o=r(7,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}(e,o.value||"");break;case 5:t.key=u(e,o.value||"");break;case 6:t.key=s(e,o.value||"");break;case 7:t.key=i(e,o.value||"");break;default:const n=e.context(),a=r(7,n.offset,n.startLoc);return a.value="",c(a,n.offset,n.startLoc),t.key=a,c(t,n.offset,n.startLoc),{nextConsumeToken:o,node:t}}return c(t,e.currentOffset(),e.currentPosition()),{node:t}}function f(e){const n=e.context(),t=r(2,1===n.currentType?e.currentOffset():n.offset,1===n.currentType?n.endLoc:n.startLoc);t.items=[];let f=null;do{const n=f||e.nextToken();switch(f=null,n.type){case 0:t.items.push(o(e,n.value||""));break;case 6:t.items.push(s(e,n.value||""));break;case 5:t.items.push(u(e,n.value||""));break;case 7:t.items.push(i(e,n.value||""));break;case 8:const r=a(e);t.items.push(r.node),f=r.nextConsumeToken||null}}while(14!==n.currentType&&1!==n.currentType);return c(t,1===n.currentType?n.lastOffset:e.currentOffset(),1===n.currentType?n.lastEndLoc:e.currentPosition()),t}function d(e){const n=e.context(),{offset:t,startLoc:o}=n,s=f(e);return 14===n.currentType?s:function(e,n,t,o){const s=e.context();let u=0===o.items.length;const i=r(1,n,t);i.cases=[],i.cases.push(o);do{const n=f(e);u||(u=0===n.items.length),i.cases.push(n)}while(14!==s.currentType);return c(i,e.currentOffset(),e.currentPosition()),i}(e,t,o,s)}return{parse:function(t){const o=l(t,{...e}),s=o.context(),u=r(0,s.offset,s.startLoc);return n&&u.loc&&(u.loc.source=t),u.body=d(o),c(u,o.currentOffset(),o.currentPosition()),u}}}function x(e,n){for(let t=0;t<e.length;t++)y(e[t],n)}function y(e,n){switch(e.type){case 1:x(e.cases,n),n.helper("plural");break;case 2:x(e.items,n);break;case 6:y(e.key,n),n.helper("linked");break;case 5:n.helper("interpolate"),n.helper("list");break;case 4:n.helper("interpolate"),n.helper("named")}}function m(e,n={}){const t=function(e,n={}){const t={ast:e,helpers:new Set};return{context:()=>t,helper:e=>(t.helpers.add(e),e)}}(e);t.helper("normalize"),e.body&&y(e.body,t);const r=t.context();e.helpers=[...r.helpers]}function b(e,n){const{helper:t}=e;switch(n.type){case 0:!function(e,n){n.body?b(e,n.body):e.push("null")}(e,n);break;case 1:!function(e,n){const{helper:t,needIndent:r}=e;if(n.cases.length>1){e.push(`${t("plural")}([`),e.indent(r());const c=n.cases.length;for(let t=0;t<c&&(b(e,n.cases[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}}(e,n);break;case 2:!function(e,n){const{helper:t,needIndent:r}=e;e.push(`${t("normalize")}([`),e.indent(r());const c=n.items.length;for(let t=0;t<c&&(b(e,n.items[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}(e,n);break;case 6:!function(e,n){const{helper:t}=e;e.push(`${t("linked")}(`),b(e,n.key),n.modifier&&(e.push(", "),b(e,n.modifier)),e.push(")")}(e,n);break;case 8:case 7:e.push(JSON.stringify(n.value),n);break;case 5:e.push(`${t("interpolate")}(${t("list")}(${n.index}))`,n);break;case 4:e.push(`${t("interpolate")}(${t("named")}(${JSON.stringify(n.key)}))`,n);break;case 9:case 3:e.push(JSON.stringify(n.value),n)}}function L(n,t={}){const r=h({...t}).parse(n);return m(r,{...t}),((n,t={})=>{const r=e(t.mode)?t.mode:"normal",c=e(t.filename)?t.filename:"message.intl",o=t.needIndent?t.needIndent:"arrow"!==r,s=n.helpers||[],u=function(e,n){const{filename:t,breakLineCode:r,needIndent:c}=n,o={source:e.loc.source,filename:t,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:r,needIndent:c,indentLevel:0};function s(e,n){o.code+=e}function u(e,n=!0){const t=n?r:"";s(c?t+" ".repeat(e):t)}return{context:()=>o,push:s,indent:function(e=!0){const n=++o.indentLevel;e&&u(n)},deindent:function(e=!0){const n=--o.indentLevel;e&&u(n)},newline:function(){u(o.indentLevel)},helper:e=>`_${e}`,needIndent:()=>o.needIndent}}(n,{mode:r,filename:c,sourceMap:!!t.sourceMap,breakLineCode:null!=t.breakLineCode?t.breakLineCode:"arrow"===r?";":"\n",needIndent:o});u.push("normal"===r?"function __msg__ (ctx) {":"(ctx) => {"),u.indent(o),s.length>0&&(u.push(`const { ${s.map((e=>`${e}: _${e}`)).join(", ")} } = ctx`),u.newline()),u.push("return "),b(u,n),u.deindent(o),u.push("}");const{code:i,map:a}=u.context();return{ast:n,code:i,map:a?a.toJSON():void 0}})(r,{...t})}export{d as ERROR_DOMAIN,c as LocationStub,L as baseCompile,t as createCompileError,s as createLocation,h as createParser,o as createPosition,r as defaultOnError,n as errorMessages}; | ||
const e=e=>"string"==typeof e,n={0:"Expected token: '{0}'",1:"Invalid token in placeholder: '{0}'",2:"Unterminated single quote in placeholder",3:"Unknown escape sequence: \\{0}",4:"Invalid unicode escape sequence: {0}",5:"Unbalanced closing brace",6:"Unterminated closing brace",7:"Empty placeholder",8:"Not allowed nest placeholder",9:"Invalid linked format",10:"Plural must have messages",11:"Unexpected empty linked modifier",12:"Unexpected empty linked key",13:"Unexpected lexical analysis in token: '{0}'"};function t(e,n,t={}){const{domain:r}=t,c=new SyntaxError(String(e));return c.code=e,n&&(c.location=n),c.domain=r,c}function r(e){throw e}const c={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}};function o(e,n,t){return{line:e,column:n,offset:t}}function u(e,n,t){const r={start:e,end:n};return null!=t&&(r.source=t),r}const s=String.fromCharCode(8232),i=String.fromCharCode(8233);function a(e){const n=e;let t=0,r=1,c=1,o=0;const u=e=>"\r"===n[e]&&"\n"===n[e+1],a=e=>n[e]===i,l=e=>n[e]===s,f=e=>u(e)||(e=>"\n"===n[e])(e)||a(e)||l(e),d=e=>u(e)||a(e)||l(e)?"\n":n[e];function p(){return o=0,f(t)&&(r++,c=0),u(t)&&t++,t++,c++,n[t]}return{index:()=>t,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:d,currentChar:()=>d(t),currentPeek:()=>d(t+o),next:p,peek:function(){return u(t+o)&&o++,o++,n[t+o]},reset:function(){t=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=t+o;for(;e!==t;)p();o=0}}}const l=void 0;function f(e,n={}){const t=!1!==n.location,r=a(e),c=()=>r.index(),s=()=>o(r.line(),r.column(),r.index()),i=s(),f=c(),d={currentType:14,offset:f,startLoc:i,endLoc:i,lastType:14,lastOffset:f,lastStartLoc:i,lastEndLoc:i,braceNest:0,inLinked:!1,text:""},p=()=>d,{onError:k}=n;function h(e,n,r){e.endLoc=s(),e.currentType=n;const c={type:n};return t&&(c.loc=u(e.startLoc,e.endLoc)),null!=r&&(c.value=r),c}const x=e=>h(e,14);function y(e,n){return e.currentChar()===n?(e.next(),n):(s(),"")}function m(e){let n="";for(;" "===e.currentPeek()||"\n"===e.currentPeek();)n+=e.currentPeek(),e.peek();return n}function b(e){const n=m(e);return e.skipToPeek(),n}function L(e){if(e===l)return!1;const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}function T(e,n){const{currentType:t}=n;if(2!==t)return!1;m(e);const r=function(e){if(e===l)return!1;const n=e.charCodeAt(0);return n>=48&&n<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function v(e){m(e);const n="|"===e.currentPeek();return e.resetPeek(),n}function P(e,n=!0){const t=(n=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&n:"@"!==o&&o?"%"===o?(e.peek(),t(n,"%",!0)):"|"===o?!("%"!==r&&!c)||!(" "===r||"\n"===r):" "===o?(e.peek(),t(!0," ",c)):"\n"!==o||(e.peek(),t(!0,"\n",c)):"%"===r||n},r=t();return n&&e.resetPeek(),r}function C(e,n){const t=e.currentChar();return t===l?l:n(t)?(e.next(),t):null}function O(e){return C(e,(e=>{const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||95===n||36===n}))}function g(e){return C(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57}))}function N(e){return C(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102}))}function w(e){let n="",t="";for(;n=g(e);)t+=n;return t}function $(e){const n=e.currentChar();switch(n){case"\\":case"'":return e.next(),`\\${n}`;case"u":return S(e,n,4);case"U":return S(e,n,6);default:return s(),""}}function S(e,n,t){y(e,n);let r="";for(let n=0;n<t;n++){const n=N(e);if(!n){s(),e.currentChar();break}r+=n}return`\\${n}${r}`}function I(e){b(e);const n=y(e,"|");return b(e),n}function E(e,n){let t=null;switch(e.currentChar()){case"{":return n.braceNest>=1&&s(),e.next(),t=h(n,2,"{"),b(e),n.braceNest++,t;case"}":return n.braceNest>0&&2===n.currentType&&s(),e.next(),t=h(n,3,"}"),n.braceNest--,n.braceNest>0&&b(e),n.inLinked&&0===n.braceNest&&(n.inLinked=!1),t;case"@":return n.braceNest>0&&s(),t=A(e,n)||x(n),n.braceNest=0,t;default:let r=!0,c=!0,o=!0;if(v(e))return n.braceNest>0&&s(),t=h(n,1,I(e)),n.braceNest=0,n.inLinked=!1,t;if(n.braceNest>0&&(5===n.currentType||6===n.currentType||7===n.currentType))return s(),n.braceNest=0,U(e,n);if(r=function(e,n){const{currentType:t}=n;if(2!==t)return!1;m(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,n))return t=h(n,5,function(e){b(e);let n="",t="";for(;n=O(e);)t+=n;return e.currentChar()===l&&s(),t}(e)),b(e),t;if(c=T(e,n))return t=h(n,6,function(e){b(e);let n="";return"-"===e.currentChar()?(e.next(),n+=`-${w(e)}`):n+=w(e),e.currentChar()===l&&s(),n}(e)),b(e),t;if(o=function(e,n){const{currentType:t}=n;if(2!==t)return!1;m(e);const r="'"===e.currentPeek();return e.resetPeek(),r}(e,n))return t=h(n,7,function(e){b(e),y(e,"'");let n="",t="";const r=e=>"'"!==e&&"\n"!==e;for(;n=C(e,r);)t+="\\"===n?$(e):n;const c=e.currentChar();return"\n"===c||c===l?(s(),"\n"===c&&(e.next(),y(e,"'")),t):(y(e,"'"),t)}(e)),b(e),t;if(!r&&!c&&!o)return t=h(n,13,function(e){b(e);let n="",t="";const r=e=>"{"!==e&&"}"!==e&&" "!==e&&"\n"!==e;for(;n=C(e,r);)t+=n;return t}(e)),s(),b(e),t}return t}function A(e,n){const{currentType:t}=n;let r=null;const c=e.currentChar();switch(8!==t&&9!==t&&12!==t&&10!==t||"\n"!==c&&" "!==c||s(),c){case"@":return e.next(),r=h(n,8,"@"),n.inLinked=!0,r;case".":return b(e),e.next(),h(n,9,".");case":":return b(e),e.next(),h(n,10,":");default:return v(e)?(r=h(n,1,I(e)),n.braceNest=0,n.inLinked=!1,r):function(e,n){const{currentType:t}=n;if(8!==t)return!1;m(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,n)||function(e,n){const{currentType:t}=n;if(8!==t&&12!==t)return!1;m(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,n)?(b(e),A(e,n)):function(e,n){const{currentType:t}=n;if(9!==t)return!1;m(e);const r=L(e.currentPeek());return e.resetPeek(),r}(e,n)?(b(e),h(n,12,function(e){let n="",t="";for(;n=O(e);)t+=n;return t}(e))):function(e,n){const{currentType:t}=n;if(10!==t)return!1;const r=()=>{const n=e.currentPeek();return"{"===n?L(e.peek()):!("@"===n||"%"===n||"|"===n||":"===n||"."===n||" "===n||!n)&&("\n"===n?(e.peek(),r()):L(n))},c=r();return e.resetPeek(),c}(e,n)?(b(e),"{"===c?E(e,n)||r:h(n,11,function(e){const n=(t=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&c?" "===c?r:"\n"===c?(r+=c,e.next(),n(t,r)):(r+=c,e.next(),n(!0,r)):r};return n(!1,"")}(e))):(8===t&&s(),n.braceNest=0,n.inLinked=!1,U(e,n))}}function U(e,n){let t={type:14};if(n.braceNest>0)return E(e,n)||x(n);if(n.inLinked)return A(e,n)||x(n);const r=e.currentChar();switch(r){case"{":return E(e,n)||x(n);case"}":return s(),e.next(),h(n,3,"}");case"@":return A(e,n)||x(n);default:if(v(e))return t=h(n,1,I(e)),n.braceNest=0,n.inLinked=!1,t;if(P(e))return h(n,0,function(e){const n=t=>{const r=e.currentChar();return"{"!==r&&"}"!==r&&"@"!==r&&r?"%"===r?P(e)?(t+=r,e.next(),n(t)):t:"|"===r?t:" "===r||"\n"===r?P(e)?(t+=r,e.next(),n(t)):v(e)?t:(t+=r,e.next(),n(t)):(t+=r,e.next(),n(t)):t};return n("")}(e));if("%"===r)return e.next(),h(n,4,"%")}return t}return{nextToken:function(){const{currentType:e,offset:n,startLoc:t,endLoc:o}=d;return d.lastType=e,d.lastOffset=n,d.lastStartLoc=t,d.lastEndLoc=o,d.offset=c(),d.startLoc=s(),r.currentChar()===l?h(d,14):U(r,d)},currentOffset:c,currentPosition:s,context:p}}const d="parser",p=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function k(e,n,t){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(n||t,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function h(e={}){const n=!1!==e.location,{onError:t}=e;function r(e,t,r){const c={type:e,start:t,end:t};return n&&(c.loc={start:r,end:r}),c}function c(e,t,r,c){e.end=t,c&&(e.type=c),n&&e.loc&&(e.loc.end=r)}function o(e,n){const t=e.context(),o=r(3,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}function u(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(5,o,u);return s.index=parseInt(n,10),e.nextToken(),c(s,e.currentOffset(),e.currentPosition()),s}function s(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(4,o,u);return s.key=n,e.nextToken(),c(s,e.currentOffset(),e.currentPosition()),s}function i(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(9,o,u);return s.value=n.replace(p,k),e.nextToken(),c(s,e.currentOffset(),e.currentPosition()),s}function a(e){const n=e.context(),t=r(6,n.offset,n.startLoc);let o=e.nextToken();if(9===o.type){const n=function(e){const n=e.nextToken(),t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(8,o,u);return 12!==n.type?(s.value="",c(s,o,u),{nextConsumeToken:n,node:s}):(null==n.value&&x(n),s.value=n.value||"",c(s,e.currentOffset(),e.currentPosition()),{node:s})}(e);t.modifier=n.node,o=n.nextConsumeToken||e.nextToken()}switch(10!==o.type&&x(o),o=e.nextToken(),2===o.type&&(o=e.nextToken()),o.type){case 11:null==o.value&&x(o),t.key=function(e,n){const t=e.context(),o=r(7,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}(e,o.value||"");break;case 5:null==o.value&&x(o),t.key=s(e,o.value||"");break;case 6:null==o.value&&x(o),t.key=u(e,o.value||"");break;case 7:null==o.value&&x(o),t.key=i(e,o.value||"");break;default:const n=e.context(),a=r(7,n.offset,n.startLoc);return a.value="",c(a,n.offset,n.startLoc),t.key=a,c(t,n.offset,n.startLoc),{nextConsumeToken:o,node:t}}return c(t,e.currentOffset(),e.currentPosition()),{node:t}}function l(e){const n=e.context(),t=r(2,1===n.currentType?e.currentOffset():n.offset,1===n.currentType?n.endLoc:n.startLoc);t.items=[];let l=null;do{const n=l||e.nextToken();switch(l=null,n.type){case 0:null==n.value&&x(n),t.items.push(o(e,n.value||""));break;case 6:null==n.value&&x(n),t.items.push(u(e,n.value||""));break;case 5:null==n.value&&x(n),t.items.push(s(e,n.value||""));break;case 7:null==n.value&&x(n),t.items.push(i(e,n.value||""));break;case 8:const r=a(e);t.items.push(r.node),l=r.nextConsumeToken||null}}while(14!==n.currentType&&1!==n.currentType);return c(t,1===n.currentType?n.lastOffset:e.currentOffset(),1===n.currentType?n.lastEndLoc:e.currentPosition()),t}function d(e){const n=e.context(),{offset:t,startLoc:o}=n,u=l(e);return 14===n.currentType?u:function(e,n,t,o){const u=e.context();let s=0===o.items.length;const i=r(1,n,t);i.cases=[],i.cases.push(o);do{const n=l(e);s||(s=0===n.items.length),i.cases.push(n)}while(14!==u.currentType);return c(i,e.currentOffset(),e.currentPosition()),i}(e,t,o,u)}return{parse:function(t){const o=f(t,{...e}),u=o.context(),s=r(0,u.offset,u.startLoc);return n&&s.loc&&(s.loc.source=t),s.body=d(o),c(s,o.currentOffset(),o.currentPosition()),s}}}function x(e){if(14===e.type)return"EOF";const n=(e.value||"").replace(/\r?\n/gu,"\\n");return n.length>10?n.slice(0,9)+"…":n}function y(e,n){for(let t=0;t<e.length;t++)m(e[t],n)}function m(e,n){switch(e.type){case 1:y(e.cases,n),n.helper("plural");break;case 2:y(e.items,n);break;case 6:m(e.key,n),n.helper("linked");break;case 5:n.helper("interpolate"),n.helper("list");break;case 4:n.helper("interpolate"),n.helper("named")}}function b(e,n={}){const t=function(e,n={}){const t={ast:e,helpers:new Set};return{context:()=>t,helper:e=>(t.helpers.add(e),e)}}(e);t.helper("normalize"),e.body&&m(e.body,t);const r=t.context();e.helpers=[...r.helpers]}function L(e,n){const{helper:t}=e;switch(n.type){case 0:!function(e,n){n.body?L(e,n.body):e.push("null")}(e,n);break;case 1:!function(e,n){const{helper:t,needIndent:r}=e;if(n.cases.length>1){e.push(`${t("plural")}([`),e.indent(r());const c=n.cases.length;for(let t=0;t<c&&(L(e,n.cases[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}}(e,n);break;case 2:!function(e,n){const{helper:t,needIndent:r}=e;e.push(`${t("normalize")}([`),e.indent(r());const c=n.items.length;for(let t=0;t<c&&(L(e,n.items[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}(e,n);break;case 6:!function(e,n){const{helper:t}=e;e.push(`${t("linked")}(`),L(e,n.key),n.modifier&&(e.push(", "),L(e,n.modifier)),e.push(")")}(e,n);break;case 8:case 7:e.push(JSON.stringify(n.value),n);break;case 5:e.push(`${t("interpolate")}(${t("list")}(${n.index}))`,n);break;case 4:e.push(`${t("interpolate")}(${t("named")}(${JSON.stringify(n.key)}))`,n);break;case 9:case 3:e.push(JSON.stringify(n.value),n)}}function T(n,t={}){const r=h({...t}).parse(n);return b(r,{...t}),((n,t={})=>{const r=e(t.mode)?t.mode:"normal",c=e(t.filename)?t.filename:"message.intl",o=t.needIndent?t.needIndent:"arrow"!==r,u=n.helpers||[],s=function(e,n){const{filename:t,breakLineCode:r,needIndent:c}=n,o={source:e.loc.source,filename:t,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:r,needIndent:c,indentLevel:0};function u(e,n){o.code+=e}function s(e,n=!0){const t=n?r:"";u(c?t+" ".repeat(e):t)}return{context:()=>o,push:u,indent:function(e=!0){const n=++o.indentLevel;e&&s(n)},deindent:function(e=!0){const n=--o.indentLevel;e&&s(n)},newline:function(){s(o.indentLevel)},helper:e=>`_${e}`,needIndent:()=>o.needIndent}}(n,{mode:r,filename:c,sourceMap:!!t.sourceMap,breakLineCode:null!=t.breakLineCode?t.breakLineCode:"arrow"===r?";":"\n",needIndent:o});s.push("normal"===r?"function __msg__ (ctx) {":"(ctx) => {"),s.indent(o),u.length>0&&(s.push(`const { ${u.map((e=>`${e}: _${e}`)).join(", ")} } = ctx`),s.newline()),s.push("return "),L(s,n),s.deindent(o),s.push("}");const{code:i,map:a}=s.context();return{ast:n,code:i,map:a?a.toJSON():void 0}})(r,{...t})}export{d as ERROR_DOMAIN,c as LocationStub,T as baseCompile,t as createCompileError,u as createLocation,h as createParser,o as createPosition,r as defaultOnError,n as errorMessages}; |
/*! | ||
* @intlify/message-compiler v9.0.0-beta.15 | ||
* @intlify/message-compiler v9.0.0-beta.16 | ||
* (c) 2020 kazuya kawaguchi | ||
@@ -23,3 +23,5 @@ * Released under the MIT License. | ||
[10 /* MUST_HAVE_MESSAGES_IN_PLURAL */]: `Plural must have messages`, | ||
[11 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
[11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */]: `Unexpected empty linked modifier`, | ||
[12 /* UNEXPECTED_EMPTY_LINKED_KEY */]: `Unexpected empty linked key`, | ||
[13 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
}; | ||
@@ -884,3 +886,3 @@ function createCompileError(code, loc, optinos = {}) { | ||
// empty modifier | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */, context.lastStartLoc, 0); | ||
node.value = ''; | ||
@@ -895,3 +897,3 @@ endNode(node, offset, loc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -922,3 +924,3 @@ node.value = token.value || ''; | ||
if (token.type !== 10 /* LinkedDelimiter */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -933,3 +935,3 @@ token = tokenizer.nextToken(); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -940,3 +942,3 @@ linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -947,3 +949,3 @@ linkedNode.key = parseNamed(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -954,3 +956,3 @@ linkedNode.key = parseList(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -961,3 +963,3 @@ linkedNode.key = parseLiteral(tokenizer, token.value || ''); | ||
// empty key | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 12 /* UNEXPECTED_EMPTY_LINKED_KEY */, context.lastStartLoc, 0); | ||
const nextContext = tokenizer.context(); | ||
@@ -996,3 +998,3 @@ const emptyLinkedKeyNode = startNode(7 /* LinkedKey */, nextContext.offset, nextContext.startLoc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1003,3 +1005,3 @@ node.items.push(parseText(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1010,3 +1012,3 @@ node.items.push(parseList(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1017,3 +1019,3 @@ node.items.push(parseNamed(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1080,3 +1082,3 @@ node.items.push(parseLiteral(tokenizer, token.value || '')); | ||
if (context.currentType !== 14 /* EOF */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, context.currentType); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, source[context.offset] || ''); | ||
} | ||
@@ -1088,2 +1090,9 @@ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); | ||
} | ||
function getTokenCaption(token) { | ||
if (token.type === 14 /* EOF */) { | ||
return 'EOF'; | ||
} | ||
const name = (token.value || '').replace(/\r?\n/gu, '\\n'); | ||
return name.length > 10 ? name.slice(0, 9) + '…' : name; | ||
} | ||
@@ -1090,0 +1099,0 @@ function createTransformer(ast, options = {} // eslint-disable-line |
/*! | ||
* @intlify/message-compiler v9.0.0-beta.15 | ||
* @intlify/message-compiler v9.0.0-beta.16 | ||
* (c) 2020 kazuya kawaguchi | ||
@@ -45,3 +45,5 @@ * Released under the MIT License. | ||
[10 /* MUST_HAVE_MESSAGES_IN_PLURAL */]: `Plural must have messages`, | ||
[11 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
[11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */]: `Unexpected empty linked modifier`, | ||
[12 /* UNEXPECTED_EMPTY_LINKED_KEY */]: `Unexpected empty linked key`, | ||
[13 /* UNEXPECTED_LEXICAL_ANALYSIS */]: `Unexpected lexical analysis in token: '{0}'` | ||
}; | ||
@@ -905,3 +907,3 @@ function createCompileError(code, loc, optinos = {}) { | ||
// empty modifier | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 11 /* UNEXPECTED_EMPTY_LINKED_MODIFIER */, context.lastStartLoc, 0); | ||
node.value = ''; | ||
@@ -916,3 +918,3 @@ endNode(node, offset, loc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -943,3 +945,3 @@ node.value = token.value || ''; | ||
if (token.type !== 10 /* LinkedDelimiter */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -954,3 +956,3 @@ token = tokenizer.nextToken(); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -961,3 +963,3 @@ linkedNode.key = parseLinkedKey(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -968,3 +970,3 @@ linkedNode.key = parseNamed(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -975,3 +977,3 @@ linkedNode.key = parseList(tokenizer, token.value || ''); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -982,3 +984,3 @@ linkedNode.key = parseLiteral(tokenizer, token.value || ''); | ||
// empty key | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 12 /* UNEXPECTED_EMPTY_LINKED_KEY */, context.lastStartLoc, 0); | ||
const nextContext = tokenizer.context(); | ||
@@ -1017,3 +1019,3 @@ const emptyLinkedKeyNode = startNode(7 /* LinkedKey */, nextContext.offset, nextContext.startLoc); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1024,3 +1026,3 @@ node.items.push(parseText(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1031,3 +1033,3 @@ node.items.push(parseList(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1038,3 +1040,3 @@ node.items.push(parseNamed(tokenizer, token.value || '')); | ||
if (token.value == null) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, token.type); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, getTokenCaption(token)); | ||
} | ||
@@ -1101,3 +1103,3 @@ node.items.push(parseLiteral(tokenizer, token.value || '')); | ||
if (context.currentType !== 14 /* EOF */) { | ||
emitError(tokenizer, 11 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, context.currentType); | ||
emitError(tokenizer, 13 /* UNEXPECTED_LEXICAL_ANALYSIS */, context.lastStartLoc, 0, source[context.offset] || ''); | ||
} | ||
@@ -1109,2 +1111,9 @@ endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition()); | ||
} | ||
function getTokenCaption(token) { | ||
if (token.type === 14 /* EOF */) { | ||
return 'EOF'; | ||
} | ||
const name = (token.value || '').replace(/\r?\n/gu, '\\n'); | ||
return name.length > 10 ? name.slice(0, 9) + '…' : name; | ||
} | ||
@@ -1111,0 +1120,0 @@ function createTransformer(ast, options = {} // eslint-disable-line |
/*! | ||
* @intlify/message-compiler v9.0.0-beta.15 | ||
* @intlify/message-compiler v9.0.0-beta.16 | ||
* (c) 2020 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/ | ||
var IntlifyMessageCompiler=function(e){"use strict";const n=e=>"string"==typeof e,t={0:"Expected token: '{0}'",1:"Invalid token in placeholder: '{0}'",2:"Unterminated single quote in placeholder",3:"Unknown escape sequence: \\{0}",4:"Invalid unicode escape sequence: {0}",5:"Unbalanced closing brace",6:"Unterminated closing brace",7:"Empty placeholder",8:"Not allowed nest placeholder",9:"Invalid linked format",10:"Plural must have messages",11:"Unexpected lexical analysis in token: '{0}'"};function r(e,n,t={}){const{domain:r}=t,c=new SyntaxError(String(e));return c.code=e,n&&(c.location=n),c.domain=r,c}function c(e,n,t){return{line:e,column:n,offset:t}}function o(e,n,t){const r={start:e,end:n};return null!=t&&(r.source=t),r}const s=" ",u="\n",i=String.fromCharCode(8232),a=String.fromCharCode(8233);function f(e){const n=e;let t=0,r=1,c=1,o=0;const s=e=>"\r"===n[e]&&n[e+1]===u,f=e=>n[e]===a,l=e=>n[e]===i,d=e=>s(e)||(e=>n[e]===u)(e)||f(e)||l(e),p=e=>s(e)||f(e)||l(e)?u:n[e];function k(){return o=0,d(t)&&(r++,c=0),s(t)&&t++,t++,c++,n[t]}return{index:()=>t,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:p,currentChar:()=>p(t),currentPeek:()=>p(t+o),next:k,peek:function(){return s(t+o)&&o++,o++,n[t+o]},reset:function(){t=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=t+o;for(;e!==t;)k();o=0}}}const l=void 0;function d(e,n={}){const t=!1!==n.location,r=f(e),i=()=>r.index(),a=()=>c(r.line(),r.column(),r.index()),d=a(),p=i(),k={currentType:14,offset:p,startLoc:d,endLoc:d,lastType:14,lastOffset:p,lastStartLoc:d,lastEndLoc:d,braceNest:0,inLinked:!1,text:""},h=()=>k,{onError:x}=n;function y(e,n,r){e.endLoc=a(),e.currentType=n;const c={type:n};return t&&(c.loc=o(e.startLoc,e.endLoc)),null!=r&&(c.value=r),c}const m=e=>y(e,14);function b(e,n){return e.currentChar()===n?(e.next(),n):(a(),"")}function L(e){let n="";for(;e.currentPeek()===s||e.currentPeek()===u;)n+=e.currentPeek(),e.peek();return n}function P(e){const n=L(e);return e.skipToPeek(),n}function T(e){if(e===l)return!1;const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}function C(e,n){const{currentType:t}=n;if(2!==t)return!1;L(e);const r=function(e){if(e===l)return!1;const n=e.charCodeAt(0);return n>=48&&n<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function v(e){L(e);const n="|"===e.currentPeek();return e.resetPeek(),n}function O(e,n=!0){const t=(n=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&n:"@"!==o&&o?"%"===o?(e.peek(),t(n,"%",!0)):"|"===o?!("%"!==r&&!c)||!(r===s||r===u):o===s?(e.peek(),t(!0,s,c)):o!==u||(e.peek(),t(!0,u,c)):"%"===r||n},r=t();return n&&e.resetPeek(),r}function g(e,n){const t=e.currentChar();return t===l?l:n(t)?(e.next(),t):null}function N(e){return g(e,(e=>{const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||95===n||36===n}))}function w(e){return g(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57}))}function S(e){return g(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102}))}function $(e){let n="",t="";for(;n=w(e);)t+=n;return t}function I(e){const n=e.currentChar();switch(n){case"\\":case"'":return e.next(),`\\${n}`;case"u":return E(e,n,4);case"U":return E(e,n,6);default:return a(),""}}function E(e,n,t){b(e,n);let r="";for(let n=0;n<t;n++){const n=S(e);if(!n){a(),e.currentChar();break}r+=n}return`\\${n}${r}`}function A(e){P(e);const n=b(e,"|");return P(e),n}function _(e,n){let t=null;switch(e.currentChar()){case"{":return n.braceNest>=1&&a(),e.next(),t=y(n,2,"{"),P(e),n.braceNest++,t;case"}":return n.braceNest>0&&2===n.currentType&&a(),e.next(),t=y(n,3,"}"),n.braceNest--,n.braceNest>0&&P(e),n.inLinked&&0===n.braceNest&&(n.inLinked=!1),t;case"@":return n.braceNest>0&&a(),t=U(e,n)||m(n),n.braceNest=0,t;default:let r=!0,c=!0,o=!0;if(v(e))return n.braceNest>0&&a(),t=y(n,1,A(e)),n.braceNest=0,n.inLinked=!1,t;if(n.braceNest>0&&(5===n.currentType||6===n.currentType||7===n.currentType))return a(),n.braceNest=0,M(e,n);if(r=function(e,n){const{currentType:t}=n;if(2!==t)return!1;L(e);const r=T(e.currentPeek());return e.resetPeek(),r}(e,n))return t=y(n,5,function(e){P(e);let n="",t="";for(;n=N(e);)t+=n;return e.currentChar()===l&&a(),t}(e)),P(e),t;if(c=C(e,n))return t=y(n,6,function(e){P(e);let n="";return"-"===e.currentChar()?(e.next(),n+=`-${$(e)}`):n+=$(e),e.currentChar()===l&&a(),n}(e)),P(e),t;if(o=function(e,n){const{currentType:t}=n;if(2!==t)return!1;L(e);const r="'"===e.currentPeek();return e.resetPeek(),r}(e,n))return t=y(n,7,function(e){P(e),b(e,"'");let n="",t="";const r=e=>"'"!==e&&e!==u;for(;n=g(e,r);)t+="\\"===n?I(e):n;const c=e.currentChar();return c===u||c===l?(a(),c===u&&(e.next(),b(e,"'")),t):(b(e,"'"),t)}(e)),P(e),t;if(!r&&!c&&!o)return t=y(n,13,function(e){P(e);let n="",t="";const r=e=>"{"!==e&&"}"!==e&&e!==s&&e!==u;for(;n=g(e,r);)t+=n;return t}(e)),a(),P(e),t}return t}function U(e,n){const{currentType:t}=n;let r=null;const c=e.currentChar();switch(8!==t&&9!==t&&12!==t&&10!==t||c!==u&&c!==s||a(),c){case"@":return e.next(),r=y(n,8,"@"),n.inLinked=!0,r;case".":return P(e),e.next(),y(n,9,".");case":":return P(e),e.next(),y(n,10,":");default:return v(e)?(r=y(n,1,A(e)),n.braceNest=0,n.inLinked=!1,r):function(e,n){const{currentType:t}=n;if(8!==t)return!1;L(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,n)||function(e,n){const{currentType:t}=n;if(8!==t&&12!==t)return!1;L(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,n)?(P(e),U(e,n)):function(e,n){const{currentType:t}=n;if(9!==t)return!1;L(e);const r=T(e.currentPeek());return e.resetPeek(),r}(e,n)?(P(e),y(n,12,function(e){let n="",t="";for(;n=N(e);)t+=n;return t}(e))):function(e,n){const{currentType:t}=n;if(10!==t)return!1;const r=()=>{const n=e.currentPeek();return"{"===n?T(e.peek()):!("@"===n||"%"===n||"|"===n||":"===n||"."===n||n===s||!n)&&(n===u?(e.peek(),r()):T(n))},c=r();return e.resetPeek(),c}(e,n)?(P(e),"{"===c?_(e,n)||r:y(n,11,function(e){const n=(t=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&c?c===s?r:c===u?(r+=c,e.next(),n(t,r)):(r+=c,e.next(),n(!0,r)):r};return n(!1,"")}(e))):(8===t&&a(),n.braceNest=0,n.inLinked=!1,M(e,n))}}function M(e,n){let t={type:14};if(n.braceNest>0)return _(e,n)||m(n);if(n.inLinked)return U(e,n)||m(n);const r=e.currentChar();switch(r){case"{":return _(e,n)||m(n);case"}":return a(),e.next(),y(n,3,"}");case"@":return U(e,n)||m(n);default:if(v(e))return t=y(n,1,A(e)),n.braceNest=0,n.inLinked=!1,t;if(O(e))return y(n,0,function(e){const n=t=>{const r=e.currentChar();return"{"!==r&&"}"!==r&&"@"!==r&&r?"%"===r?O(e)?(t+=r,e.next(),n(t)):t:"|"===r?t:r===s||r===u?O(e)?(t+=r,e.next(),n(t)):v(e)?t:(t+=r,e.next(),n(t)):(t+=r,e.next(),n(t)):t};return n("")}(e));if("%"===r)return e.next(),y(n,4,"%")}return t}return{nextToken:function(){const{currentType:e,offset:n,startLoc:t,endLoc:c}=k;return k.lastType=e,k.lastOffset=n,k.lastStartLoc=t,k.lastEndLoc=c,k.offset=i(),k.startLoc=a(),r.currentChar()===l?y(k,14):M(r,k)},currentOffset:i,currentPosition:a,context:h}}const p="parser",k=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function h(e,n,t){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(n||t,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function x(e={}){const n=!1!==e.location,{onError:t}=e;function r(e,t,r){const c={type:e,start:t,end:t};return n&&(c.loc={start:r,end:r}),c}function c(e,t,r,c){e.end=t,c&&(e.type=c),n&&e.loc&&(e.loc.end=r)}function o(e,n){const t=e.context(),o=r(3,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}function s(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(5,o,s);return u.index=parseInt(n,10),e.nextToken(),c(u,e.currentOffset(),e.currentPosition()),u}function u(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(4,o,s);return u.key=n,e.nextToken(),c(u,e.currentOffset(),e.currentPosition()),u}function i(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(9,o,s);return u.value=n.replace(k,h),e.nextToken(),c(u,e.currentOffset(),e.currentPosition()),u}function a(e){const n=e.context(),t=r(6,n.offset,n.startLoc);let o=e.nextToken();if(9===o.type){const n=function(e){const n=e.nextToken(),t=e.context(),{lastOffset:o,lastStartLoc:s}=t,u=r(8,o,s);return 12!==n.type?(u.value="",c(u,o,s),{nextConsumeToken:n,node:u}):(u.value=n.value||"",c(u,e.currentOffset(),e.currentPosition()),{node:u})}(e);t.modifier=n.node,o=n.nextConsumeToken||e.nextToken()}switch(o=e.nextToken(),2===o.type&&(o=e.nextToken()),o.type){case 11:t.key=function(e,n){const t=e.context(),o=r(7,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}(e,o.value||"");break;case 5:t.key=u(e,o.value||"");break;case 6:t.key=s(e,o.value||"");break;case 7:t.key=i(e,o.value||"");break;default:const n=e.context(),a=r(7,n.offset,n.startLoc);return a.value="",c(a,n.offset,n.startLoc),t.key=a,c(t,n.offset,n.startLoc),{nextConsumeToken:o,node:t}}return c(t,e.currentOffset(),e.currentPosition()),{node:t}}function f(e){const n=e.context(),t=r(2,1===n.currentType?e.currentOffset():n.offset,1===n.currentType?n.endLoc:n.startLoc);t.items=[];let f=null;do{const n=f||e.nextToken();switch(f=null,n.type){case 0:t.items.push(o(e,n.value||""));break;case 6:t.items.push(s(e,n.value||""));break;case 5:t.items.push(u(e,n.value||""));break;case 7:t.items.push(i(e,n.value||""));break;case 8:const r=a(e);t.items.push(r.node),f=r.nextConsumeToken||null}}while(14!==n.currentType&&1!==n.currentType);return c(t,1===n.currentType?n.lastOffset:e.currentOffset(),1===n.currentType?n.lastEndLoc:e.currentPosition()),t}function l(e){const n=e.context(),{offset:t,startLoc:o}=n,s=f(e);return 14===n.currentType?s:function(e,n,t,o){const s=e.context();let u=0===o.items.length;const i=r(1,n,t);i.cases=[],i.cases.push(o);do{const n=f(e);u||(u=0===n.items.length),i.cases.push(n)}while(14!==s.currentType);return c(i,e.currentOffset(),e.currentPosition()),i}(e,t,o,s)}return{parse:function(t){const o=d(t,{...e}),s=o.context(),u=r(0,s.offset,s.startLoc);return n&&u.loc&&(u.loc.source=t),u.body=l(o),c(u,o.currentOffset(),o.currentPosition()),u}}}function y(e,n){for(let t=0;t<e.length;t++)m(e[t],n)}function m(e,n){switch(e.type){case 1:y(e.cases,n),n.helper("plural");break;case 2:y(e.items,n);break;case 6:m(e.key,n),n.helper("linked");break;case 5:n.helper("interpolate"),n.helper("list");break;case 4:n.helper("interpolate"),n.helper("named")}}function b(e,n={}){const t=function(e,n={}){const t={ast:e,helpers:new Set};return{context:()=>t,helper:e=>(t.helpers.add(e),e)}}(e);t.helper("normalize"),e.body&&m(e.body,t);const r=t.context();e.helpers=[...r.helpers]}function L(e,n){const{helper:t}=e;switch(n.type){case 0:!function(e,n){n.body?L(e,n.body):e.push("null")}(e,n);break;case 1:!function(e,n){const{helper:t,needIndent:r}=e;if(n.cases.length>1){e.push(`${t("plural")}([`),e.indent(r());const c=n.cases.length;for(let t=0;t<c&&(L(e,n.cases[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}}(e,n);break;case 2:!function(e,n){const{helper:t,needIndent:r}=e;e.push(`${t("normalize")}([`),e.indent(r());const c=n.items.length;for(let t=0;t<c&&(L(e,n.items[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}(e,n);break;case 6:!function(e,n){const{helper:t}=e;e.push(`${t("linked")}(`),L(e,n.key),n.modifier&&(e.push(", "),L(e,n.modifier)),e.push(")")}(e,n);break;case 8:case 7:e.push(JSON.stringify(n.value),n);break;case 5:e.push(`${t("interpolate")}(${t("list")}(${n.index}))`,n);break;case 4:e.push(`${t("interpolate")}(${t("named")}(${JSON.stringify(n.key)}))`,n);break;case 9:case 3:e.push(JSON.stringify(n.value),n)}}return e.ERROR_DOMAIN=p,e.LocationStub={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}},e.baseCompile=function(e,t={}){const r=x({...t}).parse(e);return b(r,{...t}),((e,t={})=>{const r=n(t.mode)?t.mode:"normal",c=n(t.filename)?t.filename:"message.intl",o=t.needIndent?t.needIndent:"arrow"!==r,s=e.helpers||[],u=function(e,n){const{filename:t,breakLineCode:r,needIndent:c}=n,o={source:e.loc.source,filename:t,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:r,needIndent:c,indentLevel:0};function s(e,n){o.code+=e}function u(e,n=!0){const t=n?r:"";s(c?t+" ".repeat(e):t)}return{context:()=>o,push:s,indent:function(e=!0){const n=++o.indentLevel;e&&u(n)},deindent:function(e=!0){const n=--o.indentLevel;e&&u(n)},newline:function(){u(o.indentLevel)},helper:e=>`_${e}`,needIndent:()=>o.needIndent}}(e,{mode:r,filename:c,sourceMap:!!t.sourceMap,breakLineCode:null!=t.breakLineCode?t.breakLineCode:"arrow"===r?";":"\n",needIndent:o});u.push("normal"===r?"function __msg__ (ctx) {":"(ctx) => {"),u.indent(o),s.length>0&&(u.push(`const { ${s.map((e=>`${e}: _${e}`)).join(", ")} } = ctx`),u.newline()),u.push("return "),L(u,e),u.deindent(o),u.push("}");const{code:i,map:a}=u.context();return{ast:e,code:i,map:a?a.toJSON():void 0}})(r,{...t})},e.createCompileError=r,e.createLocation=o,e.createParser=x,e.createPosition=c,e.defaultOnError=function(e){throw e},e.errorMessages=t,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var IntlifyMessageCompiler=function(e){"use strict";const n=e=>"string"==typeof e,t={0:"Expected token: '{0}'",1:"Invalid token in placeholder: '{0}'",2:"Unterminated single quote in placeholder",3:"Unknown escape sequence: \\{0}",4:"Invalid unicode escape sequence: {0}",5:"Unbalanced closing brace",6:"Unterminated closing brace",7:"Empty placeholder",8:"Not allowed nest placeholder",9:"Invalid linked format",10:"Plural must have messages",11:"Unexpected empty linked modifier",12:"Unexpected empty linked key",13:"Unexpected lexical analysis in token: '{0}'"};function r(e,n,t={}){const{domain:r}=t,c=new SyntaxError(String(e));return c.code=e,n&&(c.location=n),c.domain=r,c}function c(e,n,t){return{line:e,column:n,offset:t}}function o(e,n,t){const r={start:e,end:n};return null!=t&&(r.source=t),r}const u=" ",s="\n",i=String.fromCharCode(8232),a=String.fromCharCode(8233);function l(e){const n=e;let t=0,r=1,c=1,o=0;const u=e=>"\r"===n[e]&&n[e+1]===s,l=e=>n[e]===a,f=e=>n[e]===i,d=e=>u(e)||(e=>n[e]===s)(e)||l(e)||f(e),p=e=>u(e)||l(e)||f(e)?s:n[e];function k(){return o=0,d(t)&&(r++,c=0),u(t)&&t++,t++,c++,n[t]}return{index:()=>t,line:()=>r,column:()=>c,peekOffset:()=>o,charAt:p,currentChar:()=>p(t),currentPeek:()=>p(t+o),next:k,peek:function(){return u(t+o)&&o++,o++,n[t+o]},reset:function(){t=0,r=1,c=1,o=0},resetPeek:function(e=0){o=e},skipToPeek:function(){const e=t+o;for(;e!==t;)k();o=0}}}const f=void 0;function d(e,n={}){const t=!1!==n.location,r=l(e),i=()=>r.index(),a=()=>c(r.line(),r.column(),r.index()),d=a(),p=i(),k={currentType:14,offset:p,startLoc:d,endLoc:d,lastType:14,lastOffset:p,lastStartLoc:d,lastEndLoc:d,braceNest:0,inLinked:!1,text:""},h=()=>k,{onError:x}=n;function y(e,n,r){e.endLoc=a(),e.currentType=n;const c={type:n};return t&&(c.loc=o(e.startLoc,e.endLoc)),null!=r&&(c.value=r),c}const m=e=>y(e,14);function b(e,n){return e.currentChar()===n?(e.next(),n):(a(),"")}function L(e){let n="";for(;e.currentPeek()===u||e.currentPeek()===s;)n+=e.currentPeek(),e.peek();return n}function P(e){const n=L(e);return e.skipToPeek(),n}function v(e){if(e===f)return!1;const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}function T(e,n){const{currentType:t}=n;if(2!==t)return!1;L(e);const r=function(e){if(e===f)return!1;const n=e.charCodeAt(0);return n>=48&&n<=57}("-"===e.currentPeek()?e.peek():e.currentPeek());return e.resetPeek(),r}function C(e){L(e);const n="|"===e.currentPeek();return e.resetPeek(),n}function O(e,n=!0){const t=(n=!1,r="",c=!1)=>{const o=e.currentPeek();return"{"===o?"%"!==r&&n:"@"!==o&&o?"%"===o?(e.peek(),t(n,"%",!0)):"|"===o?!("%"!==r&&!c)||!(r===u||r===s):o===u?(e.peek(),t(!0,u,c)):o!==s||(e.peek(),t(!0,s,c)):"%"===r||n},r=t();return n&&e.resetPeek(),r}function g(e,n){const t=e.currentChar();return t===f?f:n(t)?(e.next(),t):null}function N(e){return g(e,(e=>{const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||95===n||36===n}))}function w(e){return g(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57}))}function S(e){return g(e,(e=>{const n=e.charCodeAt(0);return n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102}))}function $(e){let n="",t="";for(;n=w(e);)t+=n;return t}function I(e){const n=e.currentChar();switch(n){case"\\":case"'":return e.next(),`\\${n}`;case"u":return E(e,n,4);case"U":return E(e,n,6);default:return a(),""}}function E(e,n,t){b(e,n);let r="";for(let n=0;n<t;n++){const n=S(e);if(!n){a(),e.currentChar();break}r+=n}return`\\${n}${r}`}function A(e){P(e);const n=b(e,"|");return P(e),n}function U(e,n){let t=null;switch(e.currentChar()){case"{":return n.braceNest>=1&&a(),e.next(),t=y(n,2,"{"),P(e),n.braceNest++,t;case"}":return n.braceNest>0&&2===n.currentType&&a(),e.next(),t=y(n,3,"}"),n.braceNest--,n.braceNest>0&&P(e),n.inLinked&&0===n.braceNest&&(n.inLinked=!1),t;case"@":return n.braceNest>0&&a(),t=_(e,n)||m(n),n.braceNest=0,t;default:let r=!0,c=!0,o=!0;if(C(e))return n.braceNest>0&&a(),t=y(n,1,A(e)),n.braceNest=0,n.inLinked=!1,t;if(n.braceNest>0&&(5===n.currentType||6===n.currentType||7===n.currentType))return a(),n.braceNest=0,M(e,n);if(r=function(e,n){const{currentType:t}=n;if(2!==t)return!1;L(e);const r=v(e.currentPeek());return e.resetPeek(),r}(e,n))return t=y(n,5,function(e){P(e);let n="",t="";for(;n=N(e);)t+=n;return e.currentChar()===f&&a(),t}(e)),P(e),t;if(c=T(e,n))return t=y(n,6,function(e){P(e);let n="";return"-"===e.currentChar()?(e.next(),n+=`-${$(e)}`):n+=$(e),e.currentChar()===f&&a(),n}(e)),P(e),t;if(o=function(e,n){const{currentType:t}=n;if(2!==t)return!1;L(e);const r="'"===e.currentPeek();return e.resetPeek(),r}(e,n))return t=y(n,7,function(e){P(e),b(e,"'");let n="",t="";const r=e=>"'"!==e&&e!==s;for(;n=g(e,r);)t+="\\"===n?I(e):n;const c=e.currentChar();return c===s||c===f?(a(),c===s&&(e.next(),b(e,"'")),t):(b(e,"'"),t)}(e)),P(e),t;if(!r&&!c&&!o)return t=y(n,13,function(e){P(e);let n="",t="";const r=e=>"{"!==e&&"}"!==e&&e!==u&&e!==s;for(;n=g(e,r);)t+=n;return t}(e)),a(),P(e),t}return t}function _(e,n){const{currentType:t}=n;let r=null;const c=e.currentChar();switch(8!==t&&9!==t&&12!==t&&10!==t||c!==s&&c!==u||a(),c){case"@":return e.next(),r=y(n,8,"@"),n.inLinked=!0,r;case".":return P(e),e.next(),y(n,9,".");case":":return P(e),e.next(),y(n,10,":");default:return C(e)?(r=y(n,1,A(e)),n.braceNest=0,n.inLinked=!1,r):function(e,n){const{currentType:t}=n;if(8!==t)return!1;L(e);const r="."===e.currentPeek();return e.resetPeek(),r}(e,n)||function(e,n){const{currentType:t}=n;if(8!==t&&12!==t)return!1;L(e);const r=":"===e.currentPeek();return e.resetPeek(),r}(e,n)?(P(e),_(e,n)):function(e,n){const{currentType:t}=n;if(9!==t)return!1;L(e);const r=v(e.currentPeek());return e.resetPeek(),r}(e,n)?(P(e),y(n,12,function(e){let n="",t="";for(;n=N(e);)t+=n;return t}(e))):function(e,n){const{currentType:t}=n;if(10!==t)return!1;const r=()=>{const n=e.currentPeek();return"{"===n?v(e.peek()):!("@"===n||"%"===n||"|"===n||":"===n||"."===n||n===u||!n)&&(n===s?(e.peek(),r()):v(n))},c=r();return e.resetPeek(),c}(e,n)?(P(e),"{"===c?U(e,n)||r:y(n,11,function(e){const n=(t=!1,r)=>{const c=e.currentChar();return"{"!==c&&"%"!==c&&"@"!==c&&"|"!==c&&c?c===u?r:c===s?(r+=c,e.next(),n(t,r)):(r+=c,e.next(),n(!0,r)):r};return n(!1,"")}(e))):(8===t&&a(),n.braceNest=0,n.inLinked=!1,M(e,n))}}function M(e,n){let t={type:14};if(n.braceNest>0)return U(e,n)||m(n);if(n.inLinked)return _(e,n)||m(n);const r=e.currentChar();switch(r){case"{":return U(e,n)||m(n);case"}":return a(),e.next(),y(n,3,"}");case"@":return _(e,n)||m(n);default:if(C(e))return t=y(n,1,A(e)),n.braceNest=0,n.inLinked=!1,t;if(O(e))return y(n,0,function(e){const n=t=>{const r=e.currentChar();return"{"!==r&&"}"!==r&&"@"!==r&&r?"%"===r?O(e)?(t+=r,e.next(),n(t)):t:"|"===r?t:r===u||r===s?O(e)?(t+=r,e.next(),n(t)):C(e)?t:(t+=r,e.next(),n(t)):(t+=r,e.next(),n(t)):t};return n("")}(e));if("%"===r)return e.next(),y(n,4,"%")}return t}return{nextToken:function(){const{currentType:e,offset:n,startLoc:t,endLoc:c}=k;return k.lastType=e,k.lastOffset=n,k.lastStartLoc=t,k.lastEndLoc=c,k.offset=i(),k.startLoc=a(),r.currentChar()===f?y(k,14):M(r,k)},currentOffset:i,currentPosition:a,context:h}}const p="parser",k=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function h(e,n,t){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const e=parseInt(n||t,16);return e<=55295||e>=57344?String.fromCodePoint(e):"�"}}}function x(e={}){const n=!1!==e.location,{onError:t}=e;function r(e,t,r){const c={type:e,start:t,end:t};return n&&(c.loc={start:r,end:r}),c}function c(e,t,r,c){e.end=t,c&&(e.type=c),n&&e.loc&&(e.loc.end=r)}function o(e,n){const t=e.context(),o=r(3,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}function u(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(5,o,u);return s.index=parseInt(n,10),e.nextToken(),c(s,e.currentOffset(),e.currentPosition()),s}function s(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(4,o,u);return s.key=n,e.nextToken(),c(s,e.currentOffset(),e.currentPosition()),s}function i(e,n){const t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(9,o,u);return s.value=n.replace(k,h),e.nextToken(),c(s,e.currentOffset(),e.currentPosition()),s}function a(e){const n=e.context(),t=r(6,n.offset,n.startLoc);let o=e.nextToken();if(9===o.type){const n=function(e){const n=e.nextToken(),t=e.context(),{lastOffset:o,lastStartLoc:u}=t,s=r(8,o,u);return 12!==n.type?(s.value="",c(s,o,u),{nextConsumeToken:n,node:s}):(null==n.value&&y(n),s.value=n.value||"",c(s,e.currentOffset(),e.currentPosition()),{node:s})}(e);t.modifier=n.node,o=n.nextConsumeToken||e.nextToken()}switch(10!==o.type&&y(o),o=e.nextToken(),2===o.type&&(o=e.nextToken()),o.type){case 11:null==o.value&&y(o),t.key=function(e,n){const t=e.context(),o=r(7,t.offset,t.startLoc);return o.value=n,c(o,e.currentOffset(),e.currentPosition()),o}(e,o.value||"");break;case 5:null==o.value&&y(o),t.key=s(e,o.value||"");break;case 6:null==o.value&&y(o),t.key=u(e,o.value||"");break;case 7:null==o.value&&y(o),t.key=i(e,o.value||"");break;default:const n=e.context(),a=r(7,n.offset,n.startLoc);return a.value="",c(a,n.offset,n.startLoc),t.key=a,c(t,n.offset,n.startLoc),{nextConsumeToken:o,node:t}}return c(t,e.currentOffset(),e.currentPosition()),{node:t}}function l(e){const n=e.context(),t=r(2,1===n.currentType?e.currentOffset():n.offset,1===n.currentType?n.endLoc:n.startLoc);t.items=[];let l=null;do{const n=l||e.nextToken();switch(l=null,n.type){case 0:null==n.value&&y(n),t.items.push(o(e,n.value||""));break;case 6:null==n.value&&y(n),t.items.push(u(e,n.value||""));break;case 5:null==n.value&&y(n),t.items.push(s(e,n.value||""));break;case 7:null==n.value&&y(n),t.items.push(i(e,n.value||""));break;case 8:const r=a(e);t.items.push(r.node),l=r.nextConsumeToken||null}}while(14!==n.currentType&&1!==n.currentType);return c(t,1===n.currentType?n.lastOffset:e.currentOffset(),1===n.currentType?n.lastEndLoc:e.currentPosition()),t}function f(e){const n=e.context(),{offset:t,startLoc:o}=n,u=l(e);return 14===n.currentType?u:function(e,n,t,o){const u=e.context();let s=0===o.items.length;const i=r(1,n,t);i.cases=[],i.cases.push(o);do{const n=l(e);s||(s=0===n.items.length),i.cases.push(n)}while(14!==u.currentType);return c(i,e.currentOffset(),e.currentPosition()),i}(e,t,o,u)}return{parse:function(t){const o=d(t,{...e}),u=o.context(),s=r(0,u.offset,u.startLoc);return n&&s.loc&&(s.loc.source=t),s.body=f(o),c(s,o.currentOffset(),o.currentPosition()),s}}}function y(e){if(14===e.type)return"EOF";const n=(e.value||"").replace(/\r?\n/gu,"\\n");return n.length>10?n.slice(0,9)+"…":n}function m(e,n){for(let t=0;t<e.length;t++)b(e[t],n)}function b(e,n){switch(e.type){case 1:m(e.cases,n),n.helper("plural");break;case 2:m(e.items,n);break;case 6:b(e.key,n),n.helper("linked");break;case 5:n.helper("interpolate"),n.helper("list");break;case 4:n.helper("interpolate"),n.helper("named")}}function L(e,n={}){const t=function(e,n={}){const t={ast:e,helpers:new Set};return{context:()=>t,helper:e=>(t.helpers.add(e),e)}}(e);t.helper("normalize"),e.body&&b(e.body,t);const r=t.context();e.helpers=[...r.helpers]}function P(e,n){const{helper:t}=e;switch(n.type){case 0:!function(e,n){n.body?P(e,n.body):e.push("null")}(e,n);break;case 1:!function(e,n){const{helper:t,needIndent:r}=e;if(n.cases.length>1){e.push(`${t("plural")}([`),e.indent(r());const c=n.cases.length;for(let t=0;t<c&&(P(e,n.cases[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}}(e,n);break;case 2:!function(e,n){const{helper:t,needIndent:r}=e;e.push(`${t("normalize")}([`),e.indent(r());const c=n.items.length;for(let t=0;t<c&&(P(e,n.items[t]),t!==c-1);t++)e.push(", ");e.deindent(r()),e.push("])")}(e,n);break;case 6:!function(e,n){const{helper:t}=e;e.push(`${t("linked")}(`),P(e,n.key),n.modifier&&(e.push(", "),P(e,n.modifier)),e.push(")")}(e,n);break;case 8:case 7:e.push(JSON.stringify(n.value),n);break;case 5:e.push(`${t("interpolate")}(${t("list")}(${n.index}))`,n);break;case 4:e.push(`${t("interpolate")}(${t("named")}(${JSON.stringify(n.key)}))`,n);break;case 9:case 3:e.push(JSON.stringify(n.value),n)}}return e.ERROR_DOMAIN=p,e.LocationStub={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0}},e.baseCompile=function(e,t={}){const r=x({...t}).parse(e);return L(r,{...t}),((e,t={})=>{const r=n(t.mode)?t.mode:"normal",c=n(t.filename)?t.filename:"message.intl",o=t.needIndent?t.needIndent:"arrow"!==r,u=e.helpers||[],s=function(e,n){const{filename:t,breakLineCode:r,needIndent:c}=n,o={source:e.loc.source,filename:t,code:"",column:1,line:1,offset:0,map:void 0,breakLineCode:r,needIndent:c,indentLevel:0};function u(e,n){o.code+=e}function s(e,n=!0){const t=n?r:"";u(c?t+" ".repeat(e):t)}return{context:()=>o,push:u,indent:function(e=!0){const n=++o.indentLevel;e&&s(n)},deindent:function(e=!0){const n=--o.indentLevel;e&&s(n)},newline:function(){s(o.indentLevel)},helper:e=>`_${e}`,needIndent:()=>o.needIndent}}(e,{mode:r,filename:c,sourceMap:!!t.sourceMap,breakLineCode:null!=t.breakLineCode?t.breakLineCode:"arrow"===r?";":"\n",needIndent:o});s.push("normal"===r?"function __msg__ (ctx) {":"(ctx) => {"),s.indent(o),u.length>0&&(s.push(`const { ${u.map((e=>`${e}: _${e}`)).join(", ")} } = ctx`),s.newline()),s.push("return "),P(s,e),s.deindent(o),s.push("}");const{code:i,map:a}=s.context();return{ast:e,code:i,map:a?a.toJSON():void 0}})(r,{...t})},e.createCompileError=r,e.createLocation=o,e.createParser=x,e.createPosition=c,e.defaultOnError=function(e){throw e},e.errorMessages=t,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
{ | ||
"name": "@intlify/message-compiler", | ||
"version": "9.0.0-beta.15", | ||
"version": "9.0.0-beta.16", | ||
"description": "@intlify/message-compiler", | ||
@@ -26,3 +26,6 @@ "keywords": [ | ||
}, | ||
"files": ["index.js", "dist"], | ||
"files": [ | ||
"index.js", | ||
"dist" | ||
], | ||
"main": "index.js", | ||
@@ -34,4 +37,4 @@ "module": "dist/message-compiler.esm-bundler.js", | ||
"dependencies": { | ||
"@intlify/message-resolver": "9.0.0-beta.15", | ||
"@intlify/shared": "9.0.0-beta.15", | ||
"@intlify/message-resolver": "9.0.0-beta.16", | ||
"@intlify/shared": "9.0.0-beta.16", | ||
"source-map": "0.6.1" | ||
@@ -44,5 +47,10 @@ }, | ||
"name": "IntlifyMessageCompiler", | ||
"formats": ["esm-bundler", "esm-browser", "cjs", "global"] | ||
"formats": [ | ||
"esm-bundler", | ||
"esm-browser", | ||
"cjs", | ||
"global" | ||
] | ||
}, | ||
"sideEffects": false | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
287303
7040
+ Added@intlify/message-resolver@9.0.0-beta.16(transitive)
+ Added@intlify/shared@9.0.0-beta.16(transitive)
- Removed@intlify/message-resolver@9.0.0-beta.15(transitive)
- Removed@intlify/shared@9.0.0-beta.15(transitive)