@intlify/core-base 9.13.1 → 10.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-base.cjs +12 -29
- package/dist/core-base.d.ts +2 -2
- package/dist/core-base.esm-browser.js +65 -164
- package/dist/core-base.esm-browser.prod.js +2 -2
- package/dist/core-base.global.js +65 -164
- package/dist/core-base.global.prod.js +2 -2
- package/dist/core-base.mjs +13 -30
- package/dist/core-base.prod.cjs +12 -13
- package/package.json +5 -5
package/dist/core-base.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* core-base
|
|
2
|
+
* core-base v10.0.0-alpha.2
|
|
3
3
|
* (c) 2024 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -157,23 +157,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
157
157
|
return loc;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
const CompileWarnCodes = {
|
|
161
|
-
USE_MODULO_SYNTAX: 1,
|
|
162
|
-
__EXTEND_POINT__: 2
|
|
163
|
-
};
|
|
164
|
-
/** @internal */
|
|
165
|
-
const warnMessages$1 = {
|
|
166
|
-
[CompileWarnCodes.USE_MODULO_SYNTAX]: `Use modulo before '{{0}}'.`
|
|
167
|
-
};
|
|
168
|
-
function createCompileWarn(code, loc, ...args) {
|
|
169
|
-
const msg = format$1(warnMessages$1[code] || '', ...(args || [])) ;
|
|
170
|
-
const message = { message: String(msg), code };
|
|
171
|
-
if (loc) {
|
|
172
|
-
message.location = loc;
|
|
173
|
-
}
|
|
174
|
-
return message;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
160
|
const CompileErrorCodes = {
|
|
178
161
|
// tokenizer error codes
|
|
179
162
|
EXPECTED_TOKEN: 1,
|
|
@@ -298,7 +281,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
298
281
|
}
|
|
299
282
|
function skipToPeek() {
|
|
300
283
|
const target = _index + _peekOffset;
|
|
301
|
-
// eslint-disable-next-line no-unmodified-loop-condition
|
|
302
284
|
while (target !== _index) {
|
|
303
285
|
next();
|
|
304
286
|
}
|
|
@@ -332,11 +314,11 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
332
314
|
const _initLoc = currentPosition();
|
|
333
315
|
const _initOffset = currentOffset();
|
|
334
316
|
const _context = {
|
|
335
|
-
currentType:
|
|
317
|
+
currentType: 13 /* TokenTypes.EOF */,
|
|
336
318
|
offset: _initOffset,
|
|
337
319
|
startLoc: _initLoc,
|
|
338
320
|
endLoc: _initLoc,
|
|
339
|
-
lastType:
|
|
321
|
+
lastType: 13 /* TokenTypes.EOF */,
|
|
340
322
|
lastOffset: _initOffset,
|
|
341
323
|
lastStartLoc: _initLoc,
|
|
342
324
|
lastEndLoc: _initLoc,
|
|
@@ -371,7 +353,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
371
353
|
}
|
|
372
354
|
return token;
|
|
373
355
|
}
|
|
374
|
-
const getEndToken = (context) => getToken(context,
|
|
356
|
+
const getEndToken = (context) => getToken(context, 13 /* TokenTypes.EOF */);
|
|
375
357
|
function eat(scnr, ch) {
|
|
376
358
|
if (scnr.currentChar() === ch) {
|
|
377
359
|
scnr.next();
|
|
@@ -445,7 +427,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
445
427
|
}
|
|
446
428
|
function isLinkedDotStart(scnr, context) {
|
|
447
429
|
const { currentType } = context;
|
|
448
|
-
if (currentType !==
|
|
430
|
+
if (currentType !== 7 /* TokenTypes.LinkedAlias */) {
|
|
449
431
|
return false;
|
|
450
432
|
}
|
|
451
433
|
peekSpaces(scnr);
|
|
@@ -455,7 +437,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
455
437
|
}
|
|
456
438
|
function isLinkedModifierStart(scnr, context) {
|
|
457
439
|
const { currentType } = context;
|
|
458
|
-
if (currentType !==
|
|
440
|
+
if (currentType !== 8 /* TokenTypes.LinkedDot */) {
|
|
459
441
|
return false;
|
|
460
442
|
}
|
|
461
443
|
peekSpaces(scnr);
|
|
@@ -465,8 +447,8 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
465
447
|
}
|
|
466
448
|
function isLinkedDelimiterStart(scnr, context) {
|
|
467
449
|
const { currentType } = context;
|
|
468
|
-
if (!(currentType ===
|
|
469
|
-
currentType ===
|
|
450
|
+
if (!(currentType === 7 /* TokenTypes.LinkedAlias */ ||
|
|
451
|
+
currentType === 11 /* TokenTypes.LinkedModifier */)) {
|
|
470
452
|
return false;
|
|
471
453
|
}
|
|
472
454
|
peekSpaces(scnr);
|
|
@@ -476,7 +458,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
476
458
|
}
|
|
477
459
|
function isLinkedReferStart(scnr, context) {
|
|
478
460
|
const { currentType } = context;
|
|
479
|
-
if (currentType !==
|
|
461
|
+
if (currentType !== 9 /* TokenTypes.LinkedDelimiter */) {
|
|
480
462
|
return false;
|
|
481
463
|
}
|
|
482
464
|
const fn = () => {
|
|
@@ -485,7 +467,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
485
467
|
return isIdentifierStart(scnr.peek());
|
|
486
468
|
}
|
|
487
469
|
else if (ch === "@" /* TokenChars.LinkedAlias */ ||
|
|
488
|
-
ch === "%" /* TokenChars.Modulo */ ||
|
|
489
470
|
ch === "|" /* TokenChars.Pipe */ ||
|
|
490
471
|
ch === ":" /* TokenChars.LinkedDelimiter */ ||
|
|
491
472
|
ch === "." /* TokenChars.LinkedDot */ ||
|
|
@@ -512,41 +493,25 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
512
493
|
scnr.resetPeek();
|
|
513
494
|
return ret;
|
|
514
495
|
}
|
|
515
|
-
function detectModuloStart(scnr) {
|
|
516
|
-
const spaces = peekSpaces(scnr);
|
|
517
|
-
const ret = scnr.currentPeek() === "%" /* TokenChars.Modulo */ &&
|
|
518
|
-
scnr.peek() === "{" /* TokenChars.BraceLeft */;
|
|
519
|
-
scnr.resetPeek();
|
|
520
|
-
return {
|
|
521
|
-
isModulo: ret,
|
|
522
|
-
hasSpace: spaces.length > 0
|
|
523
|
-
};
|
|
524
|
-
}
|
|
525
496
|
function isTextStart(scnr, reset = true) {
|
|
526
|
-
const fn = (hasSpace = false, prev = ''
|
|
497
|
+
const fn = (hasSpace = false, prev = '') => {
|
|
527
498
|
const ch = scnr.currentPeek();
|
|
528
499
|
if (ch === "{" /* TokenChars.BraceLeft */) {
|
|
529
|
-
return
|
|
500
|
+
return hasSpace;
|
|
530
501
|
}
|
|
531
502
|
else if (ch === "@" /* TokenChars.LinkedAlias */ || !ch) {
|
|
532
|
-
return
|
|
533
|
-
}
|
|
534
|
-
else if (ch === "%" /* TokenChars.Modulo */) {
|
|
535
|
-
scnr.peek();
|
|
536
|
-
return fn(hasSpace, "%" /* TokenChars.Modulo */, true);
|
|
503
|
+
return hasSpace;
|
|
537
504
|
}
|
|
538
505
|
else if (ch === "|" /* TokenChars.Pipe */) {
|
|
539
|
-
return prev ===
|
|
540
|
-
? true
|
|
541
|
-
: !(prev === CHAR_SP || prev === CHAR_LF);
|
|
506
|
+
return !(prev === CHAR_SP || prev === CHAR_LF);
|
|
542
507
|
}
|
|
543
508
|
else if (ch === CHAR_SP) {
|
|
544
509
|
scnr.peek();
|
|
545
|
-
return fn(true, CHAR_SP
|
|
510
|
+
return fn(true, CHAR_SP);
|
|
546
511
|
}
|
|
547
512
|
else if (ch === CHAR_LF) {
|
|
548
513
|
scnr.peek();
|
|
549
|
-
return fn(true, CHAR_LF
|
|
514
|
+
return fn(true, CHAR_LF);
|
|
550
515
|
}
|
|
551
516
|
else {
|
|
552
517
|
return true;
|
|
@@ -616,18 +581,8 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
616
581
|
}
|
|
617
582
|
return num;
|
|
618
583
|
}
|
|
619
|
-
function readModulo(scnr) {
|
|
620
|
-
skipSpaces(scnr);
|
|
621
|
-
const ch = scnr.currentChar();
|
|
622
|
-
if (ch !== "%" /* TokenChars.Modulo */) {
|
|
623
|
-
emitError(CompileErrorCodes.EXPECTED_TOKEN, currentPosition(), 0, ch);
|
|
624
|
-
}
|
|
625
|
-
scnr.next();
|
|
626
|
-
return "%" /* TokenChars.Modulo */;
|
|
627
|
-
}
|
|
628
584
|
function readText(scnr) {
|
|
629
585
|
let buf = '';
|
|
630
|
-
// eslint-disable-next-line no-constant-condition
|
|
631
586
|
while (true) {
|
|
632
587
|
const ch = scnr.currentChar();
|
|
633
588
|
if (ch === "{" /* TokenChars.BraceLeft */ ||
|
|
@@ -637,15 +592,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
637
592
|
!ch) {
|
|
638
593
|
break;
|
|
639
594
|
}
|
|
640
|
-
else if (ch === "%" /* TokenChars.Modulo */) {
|
|
641
|
-
if (isTextStart(scnr)) {
|
|
642
|
-
buf += ch;
|
|
643
|
-
scnr.next();
|
|
644
|
-
}
|
|
645
|
-
else {
|
|
646
|
-
break;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
595
|
else if (ch === CHAR_SP || ch === CHAR_LF) {
|
|
650
596
|
if (isTextStart(scnr)) {
|
|
651
597
|
buf += ch;
|
|
@@ -781,7 +727,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
781
727
|
const fn = (buf) => {
|
|
782
728
|
const ch = scnr.currentChar();
|
|
783
729
|
if (ch === "{" /* TokenChars.BraceLeft */ ||
|
|
784
|
-
ch === "%" /* TokenChars.Modulo */ ||
|
|
785
730
|
ch === "@" /* TokenChars.LinkedAlias */ ||
|
|
786
731
|
ch === "|" /* TokenChars.Pipe */ ||
|
|
787
732
|
ch === "(" /* TokenChars.ParenLeft */ ||
|
|
@@ -860,31 +805,31 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
860
805
|
return token;
|
|
861
806
|
}
|
|
862
807
|
if (context.braceNest > 0 &&
|
|
863
|
-
(context.currentType ===
|
|
864
|
-
context.currentType ===
|
|
865
|
-
context.currentType ===
|
|
808
|
+
(context.currentType === 4 /* TokenTypes.Named */ ||
|
|
809
|
+
context.currentType === 5 /* TokenTypes.List */ ||
|
|
810
|
+
context.currentType === 6 /* TokenTypes.Literal */)) {
|
|
866
811
|
emitError(CompileErrorCodes.UNTERMINATED_CLOSING_BRACE, currentPosition(), 0);
|
|
867
812
|
context.braceNest = 0;
|
|
868
813
|
return readToken(scnr, context);
|
|
869
814
|
}
|
|
870
815
|
if ((validNamedIdentifier = isNamedIdentifierStart(scnr, context))) {
|
|
871
|
-
token = getToken(context,
|
|
816
|
+
token = getToken(context, 4 /* TokenTypes.Named */, readNamedIdentifier(scnr));
|
|
872
817
|
skipSpaces(scnr);
|
|
873
818
|
return token;
|
|
874
819
|
}
|
|
875
820
|
if ((validListIdentifier = isListIdentifierStart(scnr, context))) {
|
|
876
|
-
token = getToken(context,
|
|
821
|
+
token = getToken(context, 5 /* TokenTypes.List */, readListIdentifier(scnr));
|
|
877
822
|
skipSpaces(scnr);
|
|
878
823
|
return token;
|
|
879
824
|
}
|
|
880
825
|
if ((validLiteral = isLiteralStart(scnr, context))) {
|
|
881
|
-
token = getToken(context,
|
|
826
|
+
token = getToken(context, 6 /* TokenTypes.Literal */, readLiteral(scnr));
|
|
882
827
|
skipSpaces(scnr);
|
|
883
828
|
return token;
|
|
884
829
|
}
|
|
885
830
|
if (!validNamedIdentifier && !validListIdentifier && !validLiteral) {
|
|
886
831
|
// TODO: we should be re-designed invalid cases, when we will extend message syntax near the future ...
|
|
887
|
-
token = getToken(context,
|
|
832
|
+
token = getToken(context, 12 /* TokenTypes.InvalidPlace */, readInvalidIdentifier(scnr));
|
|
888
833
|
emitError(CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER, currentPosition(), 0, token.value);
|
|
889
834
|
skipSpaces(scnr);
|
|
890
835
|
return token;
|
|
@@ -899,27 +844,27 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
899
844
|
const { currentType } = context;
|
|
900
845
|
let token = null;
|
|
901
846
|
const ch = scnr.currentChar();
|
|
902
|
-
if ((currentType ===
|
|
903
|
-
currentType ===
|
|
904
|
-
currentType ===
|
|
905
|
-
currentType ===
|
|
847
|
+
if ((currentType === 7 /* TokenTypes.LinkedAlias */ ||
|
|
848
|
+
currentType === 8 /* TokenTypes.LinkedDot */ ||
|
|
849
|
+
currentType === 11 /* TokenTypes.LinkedModifier */ ||
|
|
850
|
+
currentType === 9 /* TokenTypes.LinkedDelimiter */) &&
|
|
906
851
|
(ch === CHAR_LF || ch === CHAR_SP)) {
|
|
907
852
|
emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
|
|
908
853
|
}
|
|
909
854
|
switch (ch) {
|
|
910
855
|
case "@" /* TokenChars.LinkedAlias */:
|
|
911
856
|
scnr.next();
|
|
912
|
-
token = getToken(context,
|
|
857
|
+
token = getToken(context, 7 /* TokenTypes.LinkedAlias */, "@" /* TokenChars.LinkedAlias */);
|
|
913
858
|
context.inLinked = true;
|
|
914
859
|
return token;
|
|
915
860
|
case "." /* TokenChars.LinkedDot */:
|
|
916
861
|
skipSpaces(scnr);
|
|
917
862
|
scnr.next();
|
|
918
|
-
return getToken(context,
|
|
863
|
+
return getToken(context, 8 /* TokenTypes.LinkedDot */, "." /* TokenChars.LinkedDot */);
|
|
919
864
|
case ":" /* TokenChars.LinkedDelimiter */:
|
|
920
865
|
skipSpaces(scnr);
|
|
921
866
|
scnr.next();
|
|
922
|
-
return getToken(context,
|
|
867
|
+
return getToken(context, 9 /* TokenTypes.LinkedDelimiter */, ":" /* TokenChars.LinkedDelimiter */);
|
|
923
868
|
default:
|
|
924
869
|
if (isPluralStart(scnr)) {
|
|
925
870
|
token = getToken(context, 1 /* TokenTypes.Pipe */, readPlural(scnr));
|
|
@@ -935,7 +880,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
935
880
|
}
|
|
936
881
|
if (isLinkedModifierStart(scnr, context)) {
|
|
937
882
|
skipSpaces(scnr);
|
|
938
|
-
return getToken(context,
|
|
883
|
+
return getToken(context, 11 /* TokenTypes.LinkedModifier */, readLinkedModifier(scnr));
|
|
939
884
|
}
|
|
940
885
|
if (isLinkedReferStart(scnr, context)) {
|
|
941
886
|
skipSpaces(scnr);
|
|
@@ -944,10 +889,10 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
944
889
|
return readTokenInPlaceholder(scnr, context) || token;
|
|
945
890
|
}
|
|
946
891
|
else {
|
|
947
|
-
return getToken(context,
|
|
892
|
+
return getToken(context, 10 /* TokenTypes.LinkedKey */, readLinkedRefer(scnr));
|
|
948
893
|
}
|
|
949
894
|
}
|
|
950
|
-
if (currentType ===
|
|
895
|
+
if (currentType === 7 /* TokenTypes.LinkedAlias */) {
|
|
951
896
|
emitError(CompileErrorCodes.INVALID_LINKED_FORMAT, currentPosition(), 0);
|
|
952
897
|
}
|
|
953
898
|
context.braceNest = 0;
|
|
@@ -957,7 +902,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
957
902
|
}
|
|
958
903
|
// TODO: We need refactoring of token parsing ...
|
|
959
904
|
function readToken(scnr, context) {
|
|
960
|
-
let token = { type:
|
|
905
|
+
let token = { type: 13 /* TokenTypes.EOF */ };
|
|
961
906
|
if (context.braceNest > 0) {
|
|
962
907
|
return readTokenInPlaceholder(scnr, context) || getEndToken(context);
|
|
963
908
|
}
|
|
@@ -982,12 +927,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
982
927
|
context.inLinked = false;
|
|
983
928
|
return token;
|
|
984
929
|
}
|
|
985
|
-
const { isModulo, hasSpace } = detectModuloStart(scnr);
|
|
986
|
-
if (isModulo) {
|
|
987
|
-
return hasSpace
|
|
988
|
-
? getToken(context, 0 /* TokenTypes.Text */, readText(scnr))
|
|
989
|
-
: getToken(context, 4 /* TokenTypes.Modulo */, readModulo(scnr));
|
|
990
|
-
}
|
|
991
930
|
if (isTextStart(scnr)) {
|
|
992
931
|
return getToken(context, 0 /* TokenTypes.Text */, readText(scnr));
|
|
993
932
|
}
|
|
@@ -1005,7 +944,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1005
944
|
_context.offset = currentOffset();
|
|
1006
945
|
_context.startLoc = currentPosition();
|
|
1007
946
|
if (_scnr.currentChar() === EOF) {
|
|
1008
|
-
return getToken(_context,
|
|
947
|
+
return getToken(_context, 13 /* TokenTypes.EOF */);
|
|
1009
948
|
}
|
|
1010
949
|
return readToken(_scnr, _context);
|
|
1011
950
|
}
|
|
@@ -1041,7 +980,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1041
980
|
}
|
|
1042
981
|
function createParser(options = {}) {
|
|
1043
982
|
const location = options.location !== false;
|
|
1044
|
-
const { onError
|
|
983
|
+
const { onError } = options;
|
|
1045
984
|
function emitError(tokenzer, code, start, offset, ...args) {
|
|
1046
985
|
const end = tokenzer.currentPosition();
|
|
1047
986
|
end.offset += offset;
|
|
@@ -1055,15 +994,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1055
994
|
onError(err);
|
|
1056
995
|
}
|
|
1057
996
|
}
|
|
1058
|
-
function emitWarn(tokenzer, code, start, offset, ...args) {
|
|
1059
|
-
const end = tokenzer.currentPosition();
|
|
1060
|
-
end.offset += offset;
|
|
1061
|
-
end.column += offset;
|
|
1062
|
-
if (onWarn) {
|
|
1063
|
-
const loc = location ? createLocation(start, end) : null;
|
|
1064
|
-
onWarn(createCompileWarn(code, loc, args));
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
997
|
function startNode(type, offset, loc) {
|
|
1068
998
|
const node = { type };
|
|
1069
999
|
if (location) {
|
|
@@ -1100,14 +1030,11 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1100
1030
|
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1101
1031
|
return node;
|
|
1102
1032
|
}
|
|
1103
|
-
function parseNamed(tokenizer, key
|
|
1033
|
+
function parseNamed(tokenizer, key) {
|
|
1104
1034
|
const context = tokenizer.context();
|
|
1105
1035
|
const { lastOffset: offset, lastStartLoc: loc } = context; // get brace left loc
|
|
1106
1036
|
const node = startNode(4 /* NodeTypes.Named */, offset, loc);
|
|
1107
1037
|
node.key = key;
|
|
1108
|
-
if (modulo === true) {
|
|
1109
|
-
node.modulo = true;
|
|
1110
|
-
}
|
|
1111
1038
|
tokenizer.nextToken(); // skip brach right
|
|
1112
1039
|
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
1113
1040
|
return node;
|
|
@@ -1126,7 +1053,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1126
1053
|
const context = tokenizer.context();
|
|
1127
1054
|
const { lastOffset: offset, lastStartLoc: loc } = context; // get linked dot loc
|
|
1128
1055
|
const node = startNode(8 /* NodeTypes.LinkedModifier */, offset, loc);
|
|
1129
|
-
if (token.type !==
|
|
1056
|
+
if (token.type !== 11 /* TokenTypes.LinkedModifier */) {
|
|
1130
1057
|
// empty modifier
|
|
1131
1058
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER, context.lastStartLoc, 0);
|
|
1132
1059
|
node.value = '';
|
|
@@ -1157,13 +1084,13 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1157
1084
|
const context = tokenizer.context();
|
|
1158
1085
|
const linkedNode = startNode(6 /* NodeTypes.Linked */, context.offset, context.startLoc);
|
|
1159
1086
|
let token = tokenizer.nextToken();
|
|
1160
|
-
if (token.type ===
|
|
1087
|
+
if (token.type === 8 /* TokenTypes.LinkedDot */) {
|
|
1161
1088
|
const parsed = parseLinkedModifier(tokenizer);
|
|
1162
1089
|
linkedNode.modifier = parsed.node;
|
|
1163
1090
|
token = parsed.nextConsumeToken || tokenizer.nextToken();
|
|
1164
1091
|
}
|
|
1165
1092
|
// asset check token
|
|
1166
|
-
if (token.type !==
|
|
1093
|
+
if (token.type !== 9 /* TokenTypes.LinkedDelimiter */) {
|
|
1167
1094
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1168
1095
|
}
|
|
1169
1096
|
token = tokenizer.nextToken();
|
|
@@ -1172,25 +1099,25 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1172
1099
|
token = tokenizer.nextToken();
|
|
1173
1100
|
}
|
|
1174
1101
|
switch (token.type) {
|
|
1175
|
-
case
|
|
1102
|
+
case 10 /* TokenTypes.LinkedKey */:
|
|
1176
1103
|
if (token.value == null) {
|
|
1177
1104
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1178
1105
|
}
|
|
1179
1106
|
linkedNode.key = parseLinkedKey(tokenizer, token.value || '');
|
|
1180
1107
|
break;
|
|
1181
|
-
case
|
|
1108
|
+
case 4 /* TokenTypes.Named */:
|
|
1182
1109
|
if (token.value == null) {
|
|
1183
1110
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1184
1111
|
}
|
|
1185
1112
|
linkedNode.key = parseNamed(tokenizer, token.value || '');
|
|
1186
1113
|
break;
|
|
1187
|
-
case
|
|
1114
|
+
case 5 /* TokenTypes.List */:
|
|
1188
1115
|
if (token.value == null) {
|
|
1189
1116
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1190
1117
|
}
|
|
1191
1118
|
linkedNode.key = parseList(tokenizer, token.value || '');
|
|
1192
1119
|
break;
|
|
1193
|
-
case
|
|
1120
|
+
case 6 /* TokenTypes.Literal */:
|
|
1194
1121
|
if (token.value == null) {
|
|
1195
1122
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1196
1123
|
}
|
|
@@ -1227,7 +1154,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1227
1154
|
const node = startNode(2 /* NodeTypes.Message */, startOffset, startLoc);
|
|
1228
1155
|
node.items = [];
|
|
1229
1156
|
let nextToken = null;
|
|
1230
|
-
let modulo = null;
|
|
1231
1157
|
do {
|
|
1232
1158
|
const token = nextToken || tokenizer.nextToken();
|
|
1233
1159
|
nextToken = null;
|
|
@@ -1238,39 +1164,32 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1238
1164
|
}
|
|
1239
1165
|
node.items.push(parseText(tokenizer, token.value || ''));
|
|
1240
1166
|
break;
|
|
1241
|
-
case
|
|
1167
|
+
case 5 /* TokenTypes.List */:
|
|
1242
1168
|
if (token.value == null) {
|
|
1243
1169
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1244
1170
|
}
|
|
1245
1171
|
node.items.push(parseList(tokenizer, token.value || ''));
|
|
1246
1172
|
break;
|
|
1247
|
-
case 4 /* TokenTypes.
|
|
1248
|
-
modulo = true;
|
|
1249
|
-
break;
|
|
1250
|
-
case 5 /* TokenTypes.Named */:
|
|
1173
|
+
case 4 /* TokenTypes.Named */:
|
|
1251
1174
|
if (token.value == null) {
|
|
1252
1175
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1253
1176
|
}
|
|
1254
|
-
node.items.push(parseNamed(tokenizer, token.value || ''
|
|
1255
|
-
if (modulo) {
|
|
1256
|
-
emitWarn(tokenizer, CompileWarnCodes.USE_MODULO_SYNTAX, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1257
|
-
modulo = null;
|
|
1258
|
-
}
|
|
1177
|
+
node.items.push(parseNamed(tokenizer, token.value || ''));
|
|
1259
1178
|
break;
|
|
1260
|
-
case
|
|
1179
|
+
case 6 /* TokenTypes.Literal */:
|
|
1261
1180
|
if (token.value == null) {
|
|
1262
1181
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, getTokenCaption(token));
|
|
1263
1182
|
}
|
|
1264
1183
|
node.items.push(parseLiteral(tokenizer, token.value || ''));
|
|
1265
1184
|
break;
|
|
1266
|
-
case
|
|
1185
|
+
case 7 /* TokenTypes.LinkedAlias */: {
|
|
1267
1186
|
const parsed = parseLinked(tokenizer);
|
|
1268
1187
|
node.items.push(parsed.node);
|
|
1269
1188
|
nextToken = parsed.nextConsumeToken || null;
|
|
1270
1189
|
break;
|
|
1271
1190
|
}
|
|
1272
1191
|
}
|
|
1273
|
-
} while (context.currentType !==
|
|
1192
|
+
} while (context.currentType !== 13 /* TokenTypes.EOF */ &&
|
|
1274
1193
|
context.currentType !== 1 /* TokenTypes.Pipe */);
|
|
1275
1194
|
// adjust message node loc
|
|
1276
1195
|
const endOffset = context.currentType === 1 /* TokenTypes.Pipe */
|
|
@@ -1294,7 +1213,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1294
1213
|
hasEmptyMessage = msg.items.length === 0;
|
|
1295
1214
|
}
|
|
1296
1215
|
node.cases.push(msg);
|
|
1297
|
-
} while (context.currentType !==
|
|
1216
|
+
} while (context.currentType !== 13 /* TokenTypes.EOF */);
|
|
1298
1217
|
if (hasEmptyMessage) {
|
|
1299
1218
|
emitError(tokenizer, CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL, loc, 0);
|
|
1300
1219
|
}
|
|
@@ -1305,7 +1224,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1305
1224
|
const context = tokenizer.context();
|
|
1306
1225
|
const { offset, startLoc } = context;
|
|
1307
1226
|
const msgNode = parseMessage(tokenizer);
|
|
1308
|
-
if (context.currentType ===
|
|
1227
|
+
if (context.currentType === 13 /* TokenTypes.EOF */) {
|
|
1309
1228
|
return msgNode;
|
|
1310
1229
|
}
|
|
1311
1230
|
else {
|
|
@@ -1324,7 +1243,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1324
1243
|
node.cacheKey = options.onCacheKey(source);
|
|
1325
1244
|
}
|
|
1326
1245
|
// assert whether achieved to EOF
|
|
1327
|
-
if (context.currentType !==
|
|
1246
|
+
if (context.currentType !== 13 /* TokenTypes.EOF */) {
|
|
1328
1247
|
emitError(tokenizer, CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS, context.lastStartLoc, 0, source[context.offset] || '');
|
|
1329
1248
|
}
|
|
1330
1249
|
endNode(node, tokenizer.currentOffset(), tokenizer.currentPosition());
|
|
@@ -1333,7 +1252,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1333
1252
|
return { parse };
|
|
1334
1253
|
}
|
|
1335
1254
|
function getTokenCaption(token) {
|
|
1336
|
-
if (token.type ===
|
|
1255
|
+
if (token.type === 13 /* TokenTypes.EOF */) {
|
|
1337
1256
|
return 'EOF';
|
|
1338
1257
|
}
|
|
1339
1258
|
const name = (token.value || '').replace(/\r?\n/gu, '\\n');
|
|
@@ -1671,8 +1590,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
1671
1590
|
}
|
|
1672
1591
|
}
|
|
1673
1592
|
// generate code from AST
|
|
1674
|
-
const generate = (ast, options = {}
|
|
1675
|
-
) => {
|
|
1593
|
+
const generate = (ast, options = {}) => {
|
|
1676
1594
|
const mode = isString(options.mode) ? options.mode : 'normal';
|
|
1677
1595
|
const filename = isString(options.filename)
|
|
1678
1596
|
? options.filename
|
|
@@ -2156,17 +2074,17 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
2156
2074
|
return (payloads) => devtools && devtools.emit(hook, payloads);
|
|
2157
2075
|
}
|
|
2158
2076
|
|
|
2159
|
-
const code$1 =
|
|
2077
|
+
const code$1 = 1;
|
|
2160
2078
|
const inc$1 = incrementer(code$1);
|
|
2161
2079
|
const CoreWarnCodes = {
|
|
2162
|
-
NOT_FOUND_KEY: code$1, //
|
|
2163
|
-
FALLBACK_TO_TRANSLATE: inc$1(), //
|
|
2164
|
-
CANNOT_FORMAT_NUMBER: inc$1(), //
|
|
2165
|
-
FALLBACK_TO_NUMBER_FORMAT: inc$1(), //
|
|
2166
|
-
CANNOT_FORMAT_DATE: inc$1(), //
|
|
2167
|
-
FALLBACK_TO_DATE_FORMAT: inc$1(), //
|
|
2168
|
-
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), //
|
|
2169
|
-
__EXTEND_POINT__: inc$1() //
|
|
2080
|
+
NOT_FOUND_KEY: code$1, // 1
|
|
2081
|
+
FALLBACK_TO_TRANSLATE: inc$1(), // 2
|
|
2082
|
+
CANNOT_FORMAT_NUMBER: inc$1(), // 3
|
|
2083
|
+
FALLBACK_TO_NUMBER_FORMAT: inc$1(), // 4
|
|
2084
|
+
CANNOT_FORMAT_DATE: inc$1(), // 5
|
|
2085
|
+
FALLBACK_TO_DATE_FORMAT: inc$1(), // 6
|
|
2086
|
+
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: inc$1(), // 7
|
|
2087
|
+
__EXTEND_POINT__: inc$1() // 8
|
|
2170
2088
|
};
|
|
2171
2089
|
/** @internal */
|
|
2172
2090
|
const warnMessages = {
|
|
@@ -2258,8 +2176,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
2258
2176
|
*
|
|
2259
2177
|
* @VueI18nGeneral
|
|
2260
2178
|
*/
|
|
2261
|
-
function fallbackWithSimple(ctx, fallback, start
|
|
2262
|
-
) {
|
|
2179
|
+
function fallbackWithSimple(ctx, fallback, start) {
|
|
2263
2180
|
// prettier-ignore
|
|
2264
2181
|
return [...new Set([
|
|
2265
2182
|
start,
|
|
@@ -2363,7 +2280,7 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
2363
2280
|
* Intlify core-base version
|
|
2364
2281
|
* @internal
|
|
2365
2282
|
*/
|
|
2366
|
-
const VERSION = '
|
|
2283
|
+
const VERSION = '10.0.0-alpha.2';
|
|
2367
2284
|
const NOT_REOSLVED = -1;
|
|
2368
2285
|
const DEFAULT_LOCALE = 'en-US';
|
|
2369
2286
|
const MISSING_RESOLVE_VALUE = '';
|
|
@@ -2684,14 +2601,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
2684
2601
|
}
|
|
2685
2602
|
const defaultOnCacheKey = (message) => message;
|
|
2686
2603
|
let compileCache = Object.create(null);
|
|
2687
|
-
function onCompileWarn(_warn) {
|
|
2688
|
-
if (_warn.code === CompileWarnCodes.USE_MODULO_SYNTAX) {
|
|
2689
|
-
warn(`The use of named interpolation with modulo syntax is deprecated. ` +
|
|
2690
|
-
`It will be removed in v10.\n` +
|
|
2691
|
-
`reference: https://vue-i18n.intlify.dev/guide/essentials/syntax#rails-i18n-format \n` +
|
|
2692
|
-
`(message compiler warning message: ${_warn.message})`);
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
2604
|
function clearCompileCache() {
|
|
2696
2605
|
compileCache = Object.create(null);
|
|
2697
2606
|
}
|
|
@@ -2714,10 +2623,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
2714
2623
|
if (!isString(message)) {
|
|
2715
2624
|
throw createCoreError(CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE);
|
|
2716
2625
|
}
|
|
2717
|
-
// set onWarn
|
|
2718
|
-
{
|
|
2719
|
-
context.onWarn = onCompileWarn;
|
|
2720
|
-
}
|
|
2721
2626
|
{
|
|
2722
2627
|
// check HTML message
|
|
2723
2628
|
const warnHtmlMessage = isBoolean(context.warnHtmlMessage)
|
|
@@ -2742,10 +2647,6 @@ var IntlifyCoreBase = (function (exports) {
|
|
|
2742
2647
|
}
|
|
2743
2648
|
};
|
|
2744
2649
|
function compile(message, context) {
|
|
2745
|
-
// set onWarn
|
|
2746
|
-
{
|
|
2747
|
-
context.onWarn = onCompileWarn;
|
|
2748
|
-
}
|
|
2749
2650
|
if (isString(message)) {
|
|
2750
2651
|
// check HTML message
|
|
2751
2652
|
const warnHtmlMessage = isBoolean(context.warnHtmlMessage)
|