@intlify/core 12.0.0-alpha.10 → 12.0.0-alpha.12
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.esm-browser.js +24 -21
- package/dist/core.esm-browser.prod.js +50 -41
- package/dist/core.global.js +24 -21
- package/dist/core.global.prod.js +423 -414
- package/dist/core.js +1 -1
- package/dist/core.node.js +1 -1
- package/dist/core.runtime.esm-browser.js +12 -5
- package/dist/core.runtime.esm-browser.prod.js +28 -22
- package/dist/core.runtime.global.js +12 -5
- package/dist/core.runtime.global.prod.js +240 -234
- package/dist/core.runtime.js +1 -1
- package/dist/core.runtime.node.js +1 -1
- package/package.json +3 -3
package/dist/core.esm-browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @intlify/core v12.0.0-alpha.
|
|
2
|
+
* @intlify/core v12.0.0-alpha.12
|
|
3
3
|
* (c) 2016-present kazuya kawaguchi and contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -604,7 +604,7 @@ function createScanner(str) {
|
|
|
604
604
|
}
|
|
605
605
|
// packages/message-compiler/src/tokenizer.ts
|
|
606
606
|
const EOF = void 0;
|
|
607
|
-
const
|
|
607
|
+
const TAB = " ";
|
|
608
608
|
const LITERAL_DELIMITER = "'";
|
|
609
609
|
const ERROR_DOMAIN$1 = "tokenizer";
|
|
610
610
|
function createTokenizer(source, options = {}) {
|
|
@@ -934,22 +934,18 @@ function createTokenizer(source, options = {}) {
|
|
|
934
934
|
while (ch = takeIdentifierChar(scnr)) name += ch;
|
|
935
935
|
return name;
|
|
936
936
|
}
|
|
937
|
+
function isLinkedKeyChar(ch) {
|
|
938
|
+
return !(ch === "{" || ch === "@" || ch === "|" || ch === "(" || ch === ")" || ch === " " || ch === TAB || ch === "\n");
|
|
939
|
+
}
|
|
937
940
|
function readLinkedRefer(scnr) {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
} else {
|
|
947
|
-
buf += ch;
|
|
948
|
-
scnr.next();
|
|
949
|
-
return fn(buf);
|
|
950
|
-
}
|
|
951
|
-
};
|
|
952
|
-
return fn("");
|
|
941
|
+
while (scnr.currentChar() === TAB) scnr.next();
|
|
942
|
+
let buf = "";
|
|
943
|
+
let ch;
|
|
944
|
+
while ((ch = scnr.currentChar()) && isLinkedKeyChar(ch)) {
|
|
945
|
+
buf += ch;
|
|
946
|
+
scnr.next();
|
|
947
|
+
}
|
|
948
|
+
return buf;
|
|
953
949
|
}
|
|
954
950
|
function readPlural(scnr) {
|
|
955
951
|
skipSpaces(scnr);
|
|
@@ -1900,7 +1896,7 @@ function getWarnMessage(code, ...args) {
|
|
|
1900
1896
|
* Intlify core-base version
|
|
1901
1897
|
* @internal
|
|
1902
1898
|
*/
|
|
1903
|
-
const VERSION = "12.0.0-alpha.
|
|
1899
|
+
const VERSION = "12.0.0-alpha.12";
|
|
1904
1900
|
const NOT_RESOLVED = -1;
|
|
1905
1901
|
const DEFAULT_LOCALE = "en-US";
|
|
1906
1902
|
const MISSING_RESOLVE_VALUE = "";
|
|
@@ -2493,7 +2489,7 @@ function translate(context, ...args) {
|
|
|
2493
2489
|
};
|
|
2494
2490
|
const msg = !isMessageFunction(format) ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) : format;
|
|
2495
2491
|
if (occurred) return format;
|
|
2496
|
-
const msgContext = createMessageContext(getMessageContextOptions(context, targetLocale, message, options));
|
|
2492
|
+
const msgContext = createMessageContext(getMessageContextOptions(context, targetLocale, message, options, escapeParameter));
|
|
2497
2493
|
const timeline = startTimelineMeasure(context, "evaluation");
|
|
2498
2494
|
const messaged = msg(msgContext);
|
|
2499
2495
|
if (timeline) timeline.emitter.emit("message-evaluation", {
|
|
@@ -2518,6 +2514,13 @@ function escapeParams(options) {
|
|
|
2518
2514
|
options.named = named;
|
|
2519
2515
|
}
|
|
2520
2516
|
}
|
|
2517
|
+
function interpolateEscaped(value) {
|
|
2518
|
+
return isString(value) ? value : escapeHtml(toDisplayString(value));
|
|
2519
|
+
}
|
|
2520
|
+
function resolveProcessor(processor, escapeParameter) {
|
|
2521
|
+
if (!escapeParameter || isFunction(processor?.interpolate)) return processor ?? void 0;
|
|
2522
|
+
return assign({}, processor, { interpolate: interpolateEscaped });
|
|
2523
|
+
}
|
|
2521
2524
|
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
|
|
2522
2525
|
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
|
|
2523
2526
|
const locales = localeFallbacker(context, fallbackLocale, locale);
|
|
@@ -2662,7 +2665,7 @@ function getSourceForCodeFrame(source) {
|
|
|
2662
2665
|
if (isString(source)) return source;
|
|
2663
2666
|
else if (source.loc?.source) return source.loc.source;
|
|
2664
2667
|
}
|
|
2665
|
-
function getMessageContextOptions(context, locale, message, options) {
|
|
2668
|
+
function getMessageContextOptions(context, locale, message, options, escapeParameter) {
|
|
2666
2669
|
const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
|
|
2667
2670
|
const resolveMessage = (key, useLinked) => {
|
|
2668
2671
|
let val = resolveValue(message, key);
|
|
@@ -2685,7 +2688,7 @@ function getMessageContextOptions(context, locale, message, options) {
|
|
|
2685
2688
|
modifiers,
|
|
2686
2689
|
pluralRules,
|
|
2687
2690
|
messages: resolveMessage,
|
|
2688
|
-
processor: context.processor
|
|
2691
|
+
processor: resolveProcessor(context.processor, escapeParameter),
|
|
2689
2692
|
list: options.list ?? void 0,
|
|
2690
2693
|
named: options.named ?? void 0,
|
|
2691
2694
|
pluralIndex: isNumber(options.plural) ? options.plural : void 0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @intlify/core v12.0.0-alpha.
|
|
2
|
+
* @intlify/core v12.0.0-alpha.12
|
|
3
3
|
* (c) 2016-present kazuya kawaguchi and contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/ const e = /\{([0-9a-z]+)\}/gi;
|
|
@@ -74,7 +74,7 @@ function pe(e, t, n, r) {
|
|
|
74
74
|
let a = n || ``;
|
|
75
75
|
return `${i}=${a}${fe(e, t)}${a}`;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function me(e, t, n) {
|
|
78
78
|
k.lastIndex = t;
|
|
79
79
|
let r = k.exec(e);
|
|
80
80
|
if (!r) return;
|
|
@@ -98,18 +98,18 @@ function P(e, t, n) {
|
|
|
98
98
|
-1
|
|
99
99
|
];
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function P(e, t, n) {
|
|
102
102
|
for (let r = e.indexOf(`</`, t); r !== -1; r = e.indexOf(`</`, r + 2)) {
|
|
103
|
-
let t =
|
|
103
|
+
let t = me(e, r, {});
|
|
104
104
|
if (t && t[1].toLowerCase() === n.toLowerCase()) return t[2] === -1 ? -1 : r;
|
|
105
105
|
}
|
|
106
106
|
return -1;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function F(e) {
|
|
109
109
|
let t = {}, n = ``, r = 0, i;
|
|
110
110
|
for (; (i = e.indexOf(`<`, r)) !== -1;) {
|
|
111
111
|
n += e.slice(r, i), r = i + 1;
|
|
112
|
-
let a =
|
|
112
|
+
let a = me(e, i, t);
|
|
113
113
|
if (a) {
|
|
114
114
|
let [o, s, c] = a;
|
|
115
115
|
if (c === -1) {
|
|
@@ -119,16 +119,16 @@ function I(e) {
|
|
|
119
119
|
if (r = c, o[1] === `/`) n += o;
|
|
120
120
|
else if (ce.test(s)) t.element = !0, n += N(o);
|
|
121
121
|
else if (le.test(s)) {
|
|
122
|
-
let i =
|
|
122
|
+
let i = P(e, c, s);
|
|
123
123
|
i === -1 ? (t.unclosed = !0, n += N(o)) : (n += o + N(e.slice(c, i)), r = i);
|
|
124
124
|
} else n += o;
|
|
125
125
|
} else j.lastIndex = i, j.test(e) ? (n += e.slice(i, j.lastIndex), r = j.lastIndex) : (e.startsWith(`<!--`, i) && (t.unclosed = !0), n += `<`);
|
|
126
126
|
}
|
|
127
127
|
return n += e.slice(r), n;
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
function
|
|
131
|
-
if (
|
|
129
|
+
const I = (e) => !y(e) || h(e);
|
|
130
|
+
function L(e, t) {
|
|
131
|
+
if (I(e) || I(t) || t === Object.prototype) throw Error(`Invalid value`);
|
|
132
132
|
let n = [e, t];
|
|
133
133
|
for (; n.length;) {
|
|
134
134
|
let e = n.pop(), t = n.pop(), r = Object.keys(t);
|
|
@@ -529,11 +529,14 @@ function Se(e, t = {}) {
|
|
|
529
529
|
return n;
|
|
530
530
|
}
|
|
531
531
|
function pe(e) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
532
|
+
return e !== `{` && e !== `@` && e !== `|` && e !== `(` && e !== `)` && e !== ` ` && e !== ` ` && e !== `
|
|
533
|
+
`;
|
|
534
|
+
}
|
|
535
|
+
function me(e) {
|
|
536
|
+
for (; e.currentChar() === ` `;) e.next();
|
|
537
|
+
let t = ``, n;
|
|
538
|
+
for (; (n = e.currentChar()) && pe(n);) t += n, e.next();
|
|
539
|
+
return t;
|
|
537
540
|
}
|
|
538
541
|
function P(e) {
|
|
539
542
|
h(e);
|
|
@@ -566,7 +569,7 @@ function Se(e, t = {}) {
|
|
|
566
569
|
case `@`: return e.next(), r = d(t, 7, `@`), t.inLinked = !0, r;
|
|
567
570
|
case `.`: return h(e), e.next(), d(t, 8, `.`);
|
|
568
571
|
case `:`: return h(e), e.next(), d(t, 9, `:`);
|
|
569
|
-
default: return T(e) ? (r = d(t, 1, P(e)), t.braceNest = 0, t.inLinked = !1, r) : x(e, t) || C(e, t) ? (h(e), I(e, t)) : S(e, t) ? (h(e), d(t, 11, N(e))) : w(e, t) ? (h(e), i === `{` ? F(e, t) || r : d(t, 10,
|
|
572
|
+
default: return T(e) ? (r = d(t, 1, P(e)), t.braceNest = 0, t.inLinked = !1, r) : x(e, t) || C(e, t) ? (h(e), I(e, t)) : S(e, t) ? (h(e), d(t, 11, N(e))) : w(e, t) ? (h(e), i === `{` ? F(e, t) || r : d(t, 10, me(e))) : (n === 7 && (R.INVALID_LINKED_FORMAT, a()), t.braceNest = 0, t.inLinked = !1, L(e, t));
|
|
570
573
|
}
|
|
571
574
|
}
|
|
572
575
|
function L(e, t) {
|
|
@@ -583,12 +586,12 @@ function Se(e, t = {}) {
|
|
|
583
586
|
}
|
|
584
587
|
return n;
|
|
585
588
|
}
|
|
586
|
-
function
|
|
589
|
+
function _e() {
|
|
587
590
|
let { currentType: e, offset: t, startLoc: n, endLoc: o } = c;
|
|
588
591
|
return c.lastType = e, c.lastOffset = t, c.lastStartLoc = n, c.lastEndLoc = o, c.offset = i(), c.startLoc = a(), r.currentChar() === void 0 ? d(c, 13) : L(r, c);
|
|
589
592
|
}
|
|
590
593
|
return {
|
|
591
|
-
nextToken:
|
|
594
|
+
nextToken: _e,
|
|
592
595
|
currentOffset: i,
|
|
593
596
|
currentPosition: a,
|
|
594
597
|
context: l
|
|
@@ -1079,7 +1082,7 @@ const J = {
|
|
|
1079
1082
|
function yt(e, ...n) {
|
|
1080
1083
|
return t(vt[e], ...n);
|
|
1081
1084
|
}
|
|
1082
|
-
const bt = `12.0.0-alpha.
|
|
1085
|
+
const bt = `12.0.0-alpha.12`, xt = -1, Y = `en-US`, St = ``, Ct = (e) => `${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`;
|
|
1083
1086
|
function wt() {
|
|
1084
1087
|
return {
|
|
1085
1088
|
upper: (e, t) => t === `text` && _(e) ? e.toUpperCase() : t === `vnode` && y(e) && `__v_isVNode` in e ? e.children.toUpperCase() : e,
|
|
@@ -1133,7 +1136,7 @@ function Pt(e, t) {
|
|
|
1133
1136
|
let n = p(e.messages, t);
|
|
1134
1137
|
if (n == null) return;
|
|
1135
1138
|
let r = u();
|
|
1136
|
-
return
|
|
1139
|
+
return L(n, r), r;
|
|
1137
1140
|
}
|
|
1138
1141
|
function Ft(e, t, n) {
|
|
1139
1142
|
m(t) || (e.messages[t] = n);
|
|
@@ -1396,24 +1399,24 @@ function gn(e = {}) {
|
|
|
1396
1399
|
}
|
|
1397
1400
|
const _n = () => ``, Q = (e) => g(e), $ = (e) => _(e) || V(e) || Q(e);
|
|
1398
1401
|
function vn(e, ...t) {
|
|
1399
|
-
let [n, r] =
|
|
1402
|
+
let [n, r] = wn(...t), i = et(e, r), a = v(r.escapeParameter) ? r.escapeParameter : e.escapeParameter;
|
|
1400
1403
|
a && yn(r);
|
|
1401
1404
|
let o = !!r.resolvedMessage, [s, c, l] = o ? [
|
|
1402
1405
|
n,
|
|
1403
1406
|
i,
|
|
1404
1407
|
p(e.messages, i) || u()
|
|
1405
|
-
] :
|
|
1408
|
+
] : Sn(e, n, i, e.fallbackLocale, v(r.fallbackWarn) ? r.fallbackWarn : e.fallbackWarn, v(r.missingWarn) ? r.missingWarn : e.missingWarn), d = n;
|
|
1406
1409
|
if (!o && !$(s)) {
|
|
1407
1410
|
let t = _(r.default) ? r.default : v(r.default) || e.fallbackFormat ? e.messageCompiler ? n : () => n : null;
|
|
1408
1411
|
(e.fallbackFormat || t != null && (_(t) || g(t))) && (s = t, d = s);
|
|
1409
1412
|
}
|
|
1410
1413
|
if (!o && (!$(s) || !_(c))) return e.unresolving ? -1 : n;
|
|
1411
|
-
let f = !1, m = Q(s) ? s :
|
|
1414
|
+
let f = !1, m = Q(s) ? s : Cn(e, n, c, s, d, () => {
|
|
1412
1415
|
f = !0;
|
|
1413
1416
|
});
|
|
1414
1417
|
if (f) return s;
|
|
1415
|
-
let h = m(gn(
|
|
1416
|
-
return a && _(y) && (y =
|
|
1418
|
+
let h = m(gn(En(e, c, l, r, a))), y = e.postTranslation ? e.postTranslation(h, n) : h;
|
|
1419
|
+
return a && _(y) && (y = F(y)), y;
|
|
1417
1420
|
}
|
|
1418
1421
|
function yn(e) {
|
|
1419
1422
|
if (h(e.list) && (e.list = e.list.map((e) => _(e) ? D(e) : e)), y(e.named)) {
|
|
@@ -1425,7 +1428,13 @@ function yn(e) {
|
|
|
1425
1428
|
e.named = n;
|
|
1426
1429
|
}
|
|
1427
1430
|
}
|
|
1428
|
-
function bn(e
|
|
1431
|
+
function bn(e) {
|
|
1432
|
+
return _(e) ? e : D(w(e));
|
|
1433
|
+
}
|
|
1434
|
+
function xn(e, t) {
|
|
1435
|
+
return !t || g(e?.interpolate) ? e ?? void 0 : c({}, e, { interpolate: bn });
|
|
1436
|
+
}
|
|
1437
|
+
function Sn(e, t, n, r, i, a) {
|
|
1429
1438
|
let { messages: o, onWarn: s, messageResolver: c, localeFallbacker: l } = e, d = l(e, r, n), f = u(), m, h = null;
|
|
1430
1439
|
for (let n = 0; n < d.length && (m = d[n], f = p(o, m) || u(), (h = c(f, t)) === null && (h = p(f, t)), !$(h)); n++) if (!Wt(m, d)) {
|
|
1431
1440
|
let n = Bt(e, t, m, a, `translate`);
|
|
@@ -1437,7 +1446,7 @@ function bn(e, t, n, r, i, a) {
|
|
|
1437
1446
|
f
|
|
1438
1447
|
];
|
|
1439
1448
|
}
|
|
1440
|
-
function
|
|
1449
|
+
function Cn(e, t, n, r, i, a) {
|
|
1441
1450
|
if (Q(r)) {
|
|
1442
1451
|
let e = r;
|
|
1443
1452
|
return e.locale = e.locale || n, e.key = e.key || t, e;
|
|
@@ -1446,16 +1455,16 @@ function xn(e, t, n, r, i, a) {
|
|
|
1446
1455
|
let e = (() => r);
|
|
1447
1456
|
return e.locale = n, e.key = t, e;
|
|
1448
1457
|
}
|
|
1449
|
-
let o = e.messageCompiler(r,
|
|
1458
|
+
let o = e.messageCompiler(r, Tn(e, n, i, r, e.warnHtmlMessage, a));
|
|
1450
1459
|
return o.locale = n, o.key = t, o.source = r, o;
|
|
1451
1460
|
}
|
|
1452
|
-
function
|
|
1461
|
+
function wn(...e) {
|
|
1453
1462
|
let [t, n, r] = e;
|
|
1454
1463
|
if (!_(t) && !i(t) && !Q(t) && !V(t)) throw Error(K.INVALID_ARGUMENT);
|
|
1455
1464
|
let a = i(t) ? String(t) : (Q(t), t), o = u();
|
|
1456
1465
|
return i(n) ? o.plural = n : _(n) ? o.default = n : C(n) && !s(n) ? o.named = n : h(n) && (o.list = n), i(r) ? o.plural = r : _(r) ? o.default = r : C(r) && c(o, r), [a, o];
|
|
1457
1466
|
}
|
|
1458
|
-
function
|
|
1467
|
+
function Tn(e, t, r, i, a, o) {
|
|
1459
1468
|
return {
|
|
1460
1469
|
locale: t,
|
|
1461
1470
|
key: r,
|
|
@@ -1466,30 +1475,30 @@ function Cn(e, t, r, i, a, o) {
|
|
|
1466
1475
|
onCacheKey: (e) => n(t, r, e)
|
|
1467
1476
|
};
|
|
1468
1477
|
}
|
|
1469
|
-
function
|
|
1470
|
-
let { modifiers:
|
|
1478
|
+
function En(e, t, n, r, a) {
|
|
1479
|
+
let { modifiers: o, pluralRules: s, messageResolver: c, fallbackLocale: l, fallbackWarn: u, missingWarn: d, fallbackContext: f } = e;
|
|
1471
1480
|
return {
|
|
1472
1481
|
locale: t,
|
|
1473
|
-
modifiers:
|
|
1474
|
-
pluralRules:
|
|
1482
|
+
modifiers: o,
|
|
1483
|
+
pluralRules: s,
|
|
1475
1484
|
messages: (r, i) => {
|
|
1476
|
-
let a =
|
|
1477
|
-
if (a == null && (
|
|
1478
|
-
let [n, , i] =
|
|
1479
|
-
a = n ??
|
|
1485
|
+
let a = c(n, r);
|
|
1486
|
+
if (a == null && (f || i)) {
|
|
1487
|
+
let [n, , i] = Sn(f || e, r, t, l, u, d);
|
|
1488
|
+
a = n ?? c(i, r);
|
|
1480
1489
|
}
|
|
1481
1490
|
if (_(a) || V(a)) {
|
|
1482
|
-
let n = !1, i =
|
|
1491
|
+
let n = !1, i = Cn(e, r, t, a, r, () => {
|
|
1483
1492
|
n = !0;
|
|
1484
1493
|
});
|
|
1485
1494
|
return n ? _n : i;
|
|
1486
1495
|
}
|
|
1487
1496
|
return Q(a) ? a : _n;
|
|
1488
1497
|
},
|
|
1489
|
-
processor: e.processor
|
|
1498
|
+
processor: xn(e.processor, a),
|
|
1490
1499
|
list: r.list ?? void 0,
|
|
1491
1500
|
named: r.named ?? void 0,
|
|
1492
1501
|
pluralIndex: i(r.plural) ? r.plural : void 0
|
|
1493
1502
|
};
|
|
1494
1503
|
}
|
|
1495
|
-
export { Ue as AST_NODE_PROPS_KEYS, Qe as CORE_ERROR_CODES_EXTEND_POINT, _t as CORE_WARN_CODES_EXTEND_POINT, J as CoreWarnCodes, $t as DATETIME_FORMAT_OPTIONS_KEYS, Y as DEFAULT_LOCALE, ln as DEFAULT_MESSAGE_DATA_TYPE, St as MISSING_RESOLVE_VALUE, xt as NOT_RESOLVED, rn as NUMBER_FORMAT_OPTIONS_KEYS, bt as VERSION, Ye as clearCompileCache, tn as clearDateTimeFormat, on as clearNumberFormat, Ze as compile, _e as createCompileError, Mt as createCoreContext, $e as createCoreError, gn as createMessageContext, Qt as datetime, it as fallbackWithLocaleChain, rt as fallbackWithSimple, et as getLocale, Pt as getLocaleMessage, yt as getWarnMessage, Bt as handleMissing, Ut as isAlmostSameLocale, It as isFallbackLocale, Wt as isImplicitFallback, V as isMessageAST, $ as isMessageFormat, Q as isMessageFunction, Rt as isTranslateFallbackWarn, zt as isTranslateMissingWarn, Lt as isWarnOption, nn as number, pt as parse, en as parseDateTimeArgs, an as parseNumberArgs,
|
|
1504
|
+
export { Ue as AST_NODE_PROPS_KEYS, Qe as CORE_ERROR_CODES_EXTEND_POINT, _t as CORE_WARN_CODES_EXTEND_POINT, J as CoreWarnCodes, $t as DATETIME_FORMAT_OPTIONS_KEYS, Y as DEFAULT_LOCALE, ln as DEFAULT_MESSAGE_DATA_TYPE, St as MISSING_RESOLVE_VALUE, xt as NOT_RESOLVED, rn as NUMBER_FORMAT_OPTIONS_KEYS, bt as VERSION, Ye as clearCompileCache, tn as clearDateTimeFormat, on as clearNumberFormat, Ze as compile, _e as createCompileError, Mt as createCoreContext, $e as createCoreError, gn as createMessageContext, Qt as datetime, it as fallbackWithLocaleChain, rt as fallbackWithSimple, et as getLocale, Pt as getLocaleMessage, yt as getWarnMessage, Bt as handleMissing, Ut as isAlmostSameLocale, It as isFallbackLocale, Wt as isImplicitFallback, V as isMessageAST, $ as isMessageFormat, Q as isMessageFunction, Rt as isTranslateFallbackWarn, zt as isTranslateMissingWarn, Lt as isWarnOption, nn as number, pt as parse, en as parseDateTimeArgs, an as parseNumberArgs, wn as parseTranslateArgs, At as registerLocaleFallbacker, Et as registerMessageCompiler, Ot as registerMessageResolver, nt as resolveLocale, gt as resolveValue, ht as resolveWithKeyValue, Ft as setLocaleMessage, vn as translate, Ht as updateFallbackLocale };
|
package/dist/core.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @intlify/core v12.0.0-alpha.
|
|
2
|
+
* @intlify/core v12.0.0-alpha.12
|
|
3
3
|
* (c) 2016-present kazuya kawaguchi and contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -606,7 +606,7 @@ var IntlifyCore = (function(exports) {
|
|
|
606
606
|
}
|
|
607
607
|
// packages/message-compiler/src/tokenizer.ts
|
|
608
608
|
const EOF = void 0;
|
|
609
|
-
const
|
|
609
|
+
const TAB = " ";
|
|
610
610
|
const LITERAL_DELIMITER = "'";
|
|
611
611
|
const ERROR_DOMAIN$1 = "tokenizer";
|
|
612
612
|
function createTokenizer(source, options = {}) {
|
|
@@ -936,22 +936,18 @@ var IntlifyCore = (function(exports) {
|
|
|
936
936
|
while (ch = takeIdentifierChar(scnr)) name += ch;
|
|
937
937
|
return name;
|
|
938
938
|
}
|
|
939
|
+
function isLinkedKeyChar(ch) {
|
|
940
|
+
return !(ch === "{" || ch === "@" || ch === "|" || ch === "(" || ch === ")" || ch === " " || ch === TAB || ch === "\n");
|
|
941
|
+
}
|
|
939
942
|
function readLinkedRefer(scnr) {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
} else {
|
|
949
|
-
buf += ch;
|
|
950
|
-
scnr.next();
|
|
951
|
-
return fn(buf);
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
return fn("");
|
|
943
|
+
while (scnr.currentChar() === TAB) scnr.next();
|
|
944
|
+
let buf = "";
|
|
945
|
+
let ch;
|
|
946
|
+
while ((ch = scnr.currentChar()) && isLinkedKeyChar(ch)) {
|
|
947
|
+
buf += ch;
|
|
948
|
+
scnr.next();
|
|
949
|
+
}
|
|
950
|
+
return buf;
|
|
955
951
|
}
|
|
956
952
|
function readPlural(scnr) {
|
|
957
953
|
skipSpaces(scnr);
|
|
@@ -1902,7 +1898,7 @@ var IntlifyCore = (function(exports) {
|
|
|
1902
1898
|
* Intlify core-base version
|
|
1903
1899
|
* @internal
|
|
1904
1900
|
*/
|
|
1905
|
-
const VERSION = "12.0.0-alpha.
|
|
1901
|
+
const VERSION = "12.0.0-alpha.12";
|
|
1906
1902
|
const NOT_RESOLVED = -1;
|
|
1907
1903
|
const DEFAULT_LOCALE = "en-US";
|
|
1908
1904
|
const MISSING_RESOLVE_VALUE = "";
|
|
@@ -2495,7 +2491,7 @@ var IntlifyCore = (function(exports) {
|
|
|
2495
2491
|
};
|
|
2496
2492
|
const msg = !isMessageFunction(format) ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) : format;
|
|
2497
2493
|
if (occurred) return format;
|
|
2498
|
-
const msgContext = createMessageContext(getMessageContextOptions(context, targetLocale, message, options));
|
|
2494
|
+
const msgContext = createMessageContext(getMessageContextOptions(context, targetLocale, message, options, escapeParameter));
|
|
2499
2495
|
const timeline = startTimelineMeasure(context, "evaluation");
|
|
2500
2496
|
const messaged = msg(msgContext);
|
|
2501
2497
|
if (timeline) timeline.emitter.emit("message-evaluation", {
|
|
@@ -2520,6 +2516,13 @@ var IntlifyCore = (function(exports) {
|
|
|
2520
2516
|
options.named = named;
|
|
2521
2517
|
}
|
|
2522
2518
|
}
|
|
2519
|
+
function interpolateEscaped(value) {
|
|
2520
|
+
return isString(value) ? value : escapeHtml(toDisplayString(value));
|
|
2521
|
+
}
|
|
2522
|
+
function resolveProcessor(processor, escapeParameter) {
|
|
2523
|
+
if (!escapeParameter || isFunction(processor?.interpolate)) return processor ?? void 0;
|
|
2524
|
+
return assign({}, processor, { interpolate: interpolateEscaped });
|
|
2525
|
+
}
|
|
2523
2526
|
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
|
|
2524
2527
|
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
|
|
2525
2528
|
const locales = localeFallbacker(context, fallbackLocale, locale);
|
|
@@ -2664,7 +2667,7 @@ var IntlifyCore = (function(exports) {
|
|
|
2664
2667
|
if (isString(source)) return source;
|
|
2665
2668
|
else if (source.loc?.source) return source.loc.source;
|
|
2666
2669
|
}
|
|
2667
|
-
function getMessageContextOptions(context, locale, message, options) {
|
|
2670
|
+
function getMessageContextOptions(context, locale, message, options, escapeParameter) {
|
|
2668
2671
|
const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
|
|
2669
2672
|
const resolveMessage = (key, useLinked) => {
|
|
2670
2673
|
let val = resolveValue(message, key);
|
|
@@ -2687,7 +2690,7 @@ var IntlifyCore = (function(exports) {
|
|
|
2687
2690
|
modifiers,
|
|
2688
2691
|
pluralRules,
|
|
2689
2692
|
messages: resolveMessage,
|
|
2690
|
-
processor: context.processor
|
|
2693
|
+
processor: resolveProcessor(context.processor, escapeParameter),
|
|
2691
2694
|
list: options.list ?? void 0,
|
|
2692
2695
|
named: options.named ?? void 0,
|
|
2693
2696
|
pluralIndex: isNumber(options.plural) ? options.plural : void 0
|