@intlify/core 12.0.0-alpha.4 → 12.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,8 @@
1
1
  /**
2
- * @intlify/core v12.0.0-alpha.4
2
+ * @intlify/core v12.0.0-alpha.5
3
3
  * (c) 2016-present kazuya kawaguchi and contributors
4
4
  * @license MIT
5
5
  **/
6
- //#region packages/shared/src/warn.ts
7
- function warn(msg, err) {
8
- if (typeof console !== "undefined") {
9
- console.warn(`[intlify] ` + msg);
10
- /* istanbul ignore if */
11
- if (err) console.warn(err.stack);
12
- }
13
- }
14
- const hasWarned = {};
15
- function warnOnce(msg) {
16
- if (!hasWarned[msg]) {
17
- hasWarned[msg] = true;
18
- warn(msg);
19
- }
20
- }
21
- //#endregion
22
6
  //#region packages/shared/src/utils.ts
23
7
  /**
24
8
  * Original Utilities
@@ -37,6 +21,7 @@ let measure;
37
21
  perf.measure(name, startTag, endTag);
38
22
  perf.clearMarks(startTag);
39
23
  perf.clearMarks(endTag);
24
+ perf.clearMeasures(name);
40
25
  };
41
26
  }
42
27
  }
@@ -55,75 +40,36 @@ const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({
55
40
  });
56
41
  const friendlyJSONstringify = (json) => JSON.stringify(json).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/\u0027/g, "\\u0027");
57
42
  const isNumber = (val) => typeof val === "number" && isFinite(val);
43
+ function toDevtoolsGroupId(type, key) {
44
+ return isString(key) || isNumber(key) ? `${type}:${key}` : type;
45
+ }
58
46
  const isDate = (val) => toTypeString(val) === "[object Date]";
59
47
  const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
60
48
  const isKeylessObject = (val) => Object.keys(val).length === 0;
61
49
  const assign = Object.assign;
62
50
  const _create = Object.create;
63
51
  const create = (obj = null) => _create(obj);
64
- function escapeHtml(rawText) {
65
- return rawText.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/\//g, "&#x2F;").replace(/=/g, "&#x3D;");
66
- }
67
- function escapeAttributeValue(value) {
68
- return value.replace(/&(?![a-z0-9#]{2,6};)/gi, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
69
- }
70
- const javascriptSchemePattern = /^\s*javascript\s*(?::|&#0*58;?|&#x0*3a;?|&colon;?)/i;
71
- const urlAttributePattern = /^(?:href|src|action|formaction)$/i;
72
- function hasJavascriptScheme(value) {
73
- return javascriptSchemePattern.test(value);
74
- }
75
- function sanitizeStyleValue(value) {
76
- const urlPattern = /url\s*\(/gi;
77
- let sanitized = "";
78
- let cursor = 0;
79
- let match;
80
- while ((match = urlPattern.exec(value)) !== null) {
81
- const urlStart = match.index;
82
- const openParenIndex = urlPattern.lastIndex - 1;
83
- let index = openParenIndex + 1;
84
- let depth = 1;
85
- let quote = null;
86
- for (; index < value.length; index++) {
87
- const char = value[index];
88
- if (quote) {
89
- if (char === quote) quote = null;
90
- continue;
91
- }
92
- if (char === "\"" || char === "'") quote = char;
93
- else if (char === "(") depth++;
94
- else if (char === ")") {
95
- depth--;
96
- if (depth === 0) break;
97
- }
98
- }
99
- if (depth !== 0) break;
100
- const rawUrlValue = value.slice(openParenIndex + 1, index).trim();
101
- const unquotedUrlValue = rawUrlValue.startsWith("\"") && rawUrlValue.endsWith("\"") || rawUrlValue.startsWith("'") && rawUrlValue.endsWith("'") ? rawUrlValue.slice(1, -1).trim() : rawUrlValue;
102
- sanitized += value.slice(cursor, urlStart);
103
- sanitized += hasJavascriptScheme(unquotedUrlValue) ? "url(about:blank)" : value.slice(urlStart, index + 1);
104
- cursor = index + 1;
105
- }
106
- return sanitized + value.slice(cursor);
107
- }
108
- function sanitizeAttributeValue(attrName, value) {
109
- if (urlAttributePattern.test(attrName) && hasJavascriptScheme(value)) return "about:blank";
110
- return escapeAttributeValue(attrName.toLowerCase() === "style" ? sanitizeStyleValue(value) : value);
111
- }
112
- function sanitizeTranslatedHtml(html) {
113
- html = html.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${sanitizeAttributeValue(attrName, attrValue)}"`);
114
- html = html.replace(/([\w:-]+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${sanitizeAttributeValue(attrName, attrValue)}'`);
115
- if (/\s*on\w+\s*=\s*["']?[^"'>]+["']?/i.test(html)) {
116
- warn("Potentially dangerous event handlers detected in translation. Consider removing onclick, onerror, etc. from your translation messages.");
117
- html = html.replace(/(\s+)on(\w+\s*=)/gi, "$1&#111;n$2");
118
- }
119
- html = html.replace(/(\s+(?:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi, (match, prefix, attrValue) => hasJavascriptScheme(attrValue) ? `${prefix}about:blank` : match);
120
- return html;
121
- }
122
52
  const hasOwnProperty = Object.prototype.hasOwnProperty;
123
53
  function hasOwn(obj, key) {
124
54
  return hasOwnProperty.call(obj, key);
125
55
  }
126
56
  /**
57
+ * Get `obj[key]` only when `key` is an own property of `obj`, so that a key such as `constructor`
58
+ * does not read a property inherited from `Object.prototype`.
59
+ * The property is read before the check, so that a reactive `obj` tracks `key` even when it is missing.
60
+ */
61
+ function getOwn(obj, key) {
62
+ const value = obj[key];
63
+ return hasOwn(obj, key) ? value : void 0;
64
+ }
65
+ /**
66
+ * Whether `key` is a property name of `Object.prototype`, such as `__proto__`, `constructor` or `toString`.
67
+ * On a plain object, such a key reads a built-in, and assigning to `__proto__` replaces the prototype.
68
+ */
69
+ function isObjectPrototypeKey(key) {
70
+ return hasOwn(Object.prototype, key);
71
+ }
72
+ /**
127
73
  * Useful Utilities By Evan you
128
74
  * Modified by kazuya kawaguchi
129
75
  * MIT License
@@ -178,25 +124,130 @@ function generateCodeFrame(source, start = 0, end = source.length) {
178
124
  return res.join("\n");
179
125
  }
180
126
  //#endregion
127
+ //#region packages/shared/src/warn.ts
128
+ function warn(msg, err) {
129
+ if (typeof console !== "undefined") {
130
+ console.warn(`[intlify] ` + msg);
131
+ /* istanbul ignore if */
132
+ if (err) console.warn(err.stack);
133
+ }
134
+ }
135
+ const hasWarned = {};
136
+ function warnOnce(msg) {
137
+ if (!hasWarned[msg]) {
138
+ hasWarned[msg] = true;
139
+ warn(msg);
140
+ }
141
+ }
142
+ //#endregion
143
+ //#region packages/shared/src/sanitize.ts
144
+ function escapeHtml(rawText) {
145
+ return rawText.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/\//g, "&#x2F;").replace(/=/g, "&#x3D;");
146
+ }
147
+ function escapeAttributeValue(value) {
148
+ return value.replace(/&(?![a-z0-9#]{2,6};)/gi, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
149
+ }
150
+ const javascriptSchemePattern = /^javascript:/i;
151
+ const urlAttributePattern = /^(?:href|src|action|formaction)$/i;
152
+ const numericCharacterReferencePattern = /&#(?:x([0-9a-f]+)|(\d+));?/gi;
153
+ const namedWhitespaceCharacterReferencePattern = /&(?:Tab|NewLine);/g;
154
+ const colonCharacterReferencePattern = /&colon;?/gi;
155
+ const controlOrWhitespacePattern = /[\u0000-\u0020\u007f-\u009f]/g;
156
+ const eventHandlerPattern = /(?:^|[\s"'<>/])on\w+\s*=\s*["']?[^"'>]+["']?/i;
157
+ const eventHandlerAttributePattern = /(^|[\s"'<>/])on(\w+\s*=)/gi;
158
+ const srcdocPattern = /(?:^|[\s"'<>/])srcdoc\s*=/i;
159
+ const srcdocAttributePattern = /(^|[\s"'<>/])s(rcdoc\s*=)/gi;
160
+ const unquotedUrlAttributePattern = /(^|[\s"'<>/])((?:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;
161
+ function decodeNumericCharacterReference(match, hex, decimal) {
162
+ const digits = hex || decimal;
163
+ if (!digits) return match;
164
+ const codePoint = Number.parseInt(digits, hex ? 16 : 10);
165
+ return codePoint <= 127 ? String.fromCharCode(codePoint) : match;
166
+ }
167
+ function hasJavascriptScheme(value) {
168
+ const normalized = value.replace(numericCharacterReferencePattern, decodeNumericCharacterReference).replace(namedWhitespaceCharacterReferencePattern, "").replace(colonCharacterReferencePattern, ":").replace(controlOrWhitespacePattern, "");
169
+ return javascriptSchemePattern.test(normalized);
170
+ }
171
+ function sanitizeStyleValue(value) {
172
+ const urlPattern = /url\s*\(/gi;
173
+ let sanitized = "";
174
+ let cursor = 0;
175
+ let match;
176
+ while ((match = urlPattern.exec(value)) !== null) {
177
+ const urlStart = match.index;
178
+ const openParenIndex = urlPattern.lastIndex - 1;
179
+ let index = openParenIndex + 1;
180
+ let depth = 1;
181
+ let quote = null;
182
+ for (; index < value.length; index++) {
183
+ const char = value[index];
184
+ if (quote) {
185
+ if (char === quote) quote = null;
186
+ continue;
187
+ }
188
+ if (char === "\"" || char === "'") quote = char;
189
+ else if (char === "(") depth++;
190
+ else if (char === ")") {
191
+ depth--;
192
+ if (depth === 0) break;
193
+ }
194
+ }
195
+ if (depth !== 0) break;
196
+ const rawUrlValue = value.slice(openParenIndex + 1, index).trim();
197
+ const unquotedUrlValue = rawUrlValue.startsWith("\"") && rawUrlValue.endsWith("\"") || rawUrlValue.startsWith("'") && rawUrlValue.endsWith("'") ? rawUrlValue.slice(1, -1).trim() : rawUrlValue;
198
+ sanitized += value.slice(cursor, urlStart);
199
+ sanitized += hasJavascriptScheme(unquotedUrlValue) ? "url(about:blank)" : value.slice(urlStart, index + 1);
200
+ cursor = index + 1;
201
+ }
202
+ return sanitized + value.slice(cursor);
203
+ }
204
+ function sanitizeAttributeValue(attrName, value) {
205
+ if (urlAttributePattern.test(attrName) && hasJavascriptScheme(value)) return "about:blank";
206
+ return escapeAttributeValue(attrName.toLowerCase() === "style" ? sanitizeStyleValue(value) : value);
207
+ }
208
+ function sanitizeTranslatedHtml(html) {
209
+ html = html.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${sanitizeAttributeValue(attrName, attrValue)}"`);
210
+ html = html.replace(/([\w:-]+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${sanitizeAttributeValue(attrName, attrValue)}'`);
211
+ if (eventHandlerPattern.test(html)) {
212
+ warn("Potentially dangerous event handlers detected in translation. Consider removing onclick, onerror, etc. from your translation messages.");
213
+ html = html.replace(eventHandlerAttributePattern, "$1&#111;n$2");
214
+ }
215
+ if (srcdocPattern.test(html)) {
216
+ warn("Potentially dangerous srcdoc attribute detected in translation. Consider removing srcdoc from your translation messages.");
217
+ html = html.replace(srcdocAttributePattern, "$1&#115;$2");
218
+ }
219
+ html = html.replace(unquotedUrlAttributePattern, (match, boundary, prefix, attrValue) => hasJavascriptScheme(attrValue) ? `${boundary}${prefix}about:blank` : match);
220
+ return html;
221
+ }
222
+ //#endregion
181
223
  //#region packages/shared/src/messages.ts
182
224
  const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val);
183
225
  function deepCopy(src, des) {
184
- if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) throw new Error("Invalid value");
185
- const stack = [{
186
- src,
187
- des
188
- }];
226
+ if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des) || des === Object.prototype) throw new Error("Invalid value");
227
+ const stack = [src, des];
189
228
  while (stack.length) {
190
- const { src, des } = stack.pop();
191
- Object.keys(src).forEach((key) => {
192
- if (key === "__proto__") return;
193
- if (isObject(src[key]) && !isObject(des[key])) des[key] = Array.isArray(src[key]) ? [] : create();
194
- if (isNotObjectOrIsArray(des[key]) || isNotObjectOrIsArray(src[key])) des[key] = src[key];
195
- else stack.push({
196
- src: src[key],
197
- des: des[key]
198
- });
199
- });
229
+ const des = stack.pop();
230
+ const src = stack.pop();
231
+ const keys = Object.keys(src);
232
+ for (let i = 0; i < keys.length; i++) {
233
+ const key = keys[i];
234
+ if (key === "__proto__") continue;
235
+ const value = src[key];
236
+ if (!isObject(value)) {
237
+ des[key] = value;
238
+ continue;
239
+ }
240
+ if (isArray(value)) {
241
+ const copied = [];
242
+ copied.length = value.length;
243
+ des[key] = copied;
244
+ stack.push(value, copied);
245
+ continue;
246
+ }
247
+ let desValue = des[key];
248
+ if (!isObject(desValue) || isArray(desValue)) desValue = des[key] = create();
249
+ stack.push(value, desValue);
250
+ }
200
251
  }
201
252
  }
202
253
  //#endregion
@@ -474,10 +525,13 @@ function createTokenizer(source, options = {}) {
474
525
  const ctx = context();
475
526
  pos.column += offset;
476
527
  pos.offset += offset;
477
- if (onError) onError(createCompileError(code, location ? createLocation(ctx.startLoc, pos) : null, {
478
- domain: ERROR_DOMAIN$1,
479
- args
480
- }));
528
+ if (onError) {
529
+ const err = createCompileError(code, location ? createLocation(ctx.startLoc, pos) : null, {
530
+ domain: ERROR_DOMAIN$1,
531
+ args
532
+ });
533
+ onError(err);
534
+ }
481
535
  }
482
536
  function getToken(context, type, value) {
483
537
  context.endLoc = currentPosition();
@@ -610,7 +664,7 @@ function createTokenizer(source, options = {}) {
610
664
  }
611
665
  function takeChar(scnr, fn) {
612
666
  const ch = scnr.currentChar();
613
- if (ch === EOF) return EOF;
667
+ if (ch === EOF) return;
614
668
  if (fn(ch)) {
615
669
  scnr.next();
616
670
  return ch;
@@ -667,15 +721,16 @@ function createTokenizer(source, options = {}) {
667
721
  scnr.next();
668
722
  }
669
723
  } else if (ch === "{" || ch === "}" || ch === "@" || ch === "|" || !ch) break;
670
- else if (ch === " " || ch === "\n") if (isTextStart(scnr)) {
671
- buf += ch;
672
- scnr.next();
673
- } else if (isPluralStart(scnr)) break;
674
- else {
675
- buf += ch;
676
- scnr.next();
677
- }
678
- else {
724
+ else if (ch === " " || ch === "\n") {
725
+ if (isTextStart(scnr)) {
726
+ buf += ch;
727
+ scnr.next();
728
+ } else if (isPluralStart(scnr)) break;
729
+ else {
730
+ buf += ch;
731
+ scnr.next();
732
+ }
733
+ } else {
679
734
  buf += ch;
680
735
  scnr.next();
681
736
  }
@@ -923,7 +978,6 @@ function createTokenizer(source, options = {}) {
923
978
  return token;
924
979
  }
925
980
  if (isTextStart(scnr)) return getToken(context, 0, readText(scnr));
926
- break;
927
981
  }
928
982
  return token;
929
983
  }
@@ -971,10 +1025,13 @@ function createParser(options = {}) {
971
1025
  const end = tokenzer.currentPosition();
972
1026
  end.offset += offset;
973
1027
  end.column += offset;
974
- if (onError) onError(createCompileError(code, location ? createLocation(start, end) : null, {
975
- domain: ERROR_DOMAIN,
976
- args
977
- }));
1028
+ if (onError) {
1029
+ const err = createCompileError(code, location ? createLocation(start, end) : null, {
1030
+ domain: ERROR_DOMAIN,
1031
+ args
1032
+ });
1033
+ onError(err);
1034
+ }
978
1035
  }
979
1036
  function startNode(type, offset, loc) {
980
1037
  const node = { type };
@@ -1311,7 +1368,7 @@ function baseCompile(message, options = {}) {
1311
1368
  code: ""
1312
1369
  };
1313
1370
  }
1314
- /* @__NO_SIDE_EFFECTS__ */
1371
+ /* #__NO_SIDE_EFFECTS__ */
1315
1372
  function compile(message, context) {
1316
1373
  if (isString(message)) {
1317
1374
  checkHtmlMessage(message, isBoolean(context.warnHtmlMessage) ? context.warnHtmlMessage : true);
@@ -1345,12 +1402,11 @@ const CoreErrorCodes = {
1345
1402
  INVALID_ARGUMENT: 17,
1346
1403
  INVALID_DATE_ARGUMENT: 18,
1347
1404
  INVALID_ISO_DATE_ARGUMENT: 19,
1348
- NOT_SUPPORT_NON_STRING_MESSAGE: 20,
1349
- NOT_SUPPORT_LOCALE_PROMISE_VALUE: 21,
1350
- NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 22,
1351
- NOT_SUPPORT_LOCALE_TYPE: 23
1405
+ NOT_SUPPORT_LOCALE_PROMISE_VALUE: 20,
1406
+ NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 21,
1407
+ NOT_SUPPORT_LOCALE_TYPE: 22
1352
1408
  };
1353
- const CORE_ERROR_CODES_EXTEND_POINT = 24;
1409
+ const CORE_ERROR_CODES_EXTEND_POINT = 23;
1354
1410
  function createCoreError(code) {
1355
1411
  return createCompileError(code, null, { messages: errorMessages });
1356
1412
  }
@@ -1359,7 +1415,6 @@ const errorMessages = {
1359
1415
  [CoreErrorCodes.INVALID_ARGUMENT]: "Invalid arguments",
1360
1416
  [CoreErrorCodes.INVALID_DATE_ARGUMENT]: "The date provided is an invalid Date object.Make sure your Date represents a valid date.",
1361
1417
  [CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: "The argument provided is not a valid ISO date string",
1362
- [CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]: "Not support non-string message",
1363
1418
  [CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: "cannot support promise value",
1364
1419
  [CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: "cannot support async function",
1365
1420
  [CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: "cannot support locale type"
@@ -1374,13 +1429,14 @@ let _resolveLocale;
1374
1429
  /** @internal */
1375
1430
  function resolveLocale(locale) {
1376
1431
  if (isString(locale)) return locale;
1377
- else if (isFunction(locale)) if (locale.resolvedOnce && _resolveLocale != null) return _resolveLocale;
1378
- else if (locale.constructor.name === "Function") {
1379
- const resolve = locale();
1380
- if (isPromise(resolve)) throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);
1381
- return _resolveLocale = resolve;
1382
- } else throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION);
1383
- else throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE);
1432
+ else if (isFunction(locale)) {
1433
+ if (locale.resolvedOnce && _resolveLocale != null) return _resolveLocale;
1434
+ else if (locale.constructor.name === "Function") {
1435
+ const resolve = locale();
1436
+ if (isPromise(resolve)) throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);
1437
+ return _resolveLocale = resolve;
1438
+ } else throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION);
1439
+ } else throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE);
1384
1440
  }
1385
1441
  /**
1386
1442
  * Fallback with simple implemenation
@@ -1388,7 +1444,7 @@ function resolveLocale(locale) {
1388
1444
  * @remarks
1389
1445
  * A fallback locale function implemented with a simple fallback algorithm.
1390
1446
  *
1391
- * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify.
1447
+ * Basically, the chain consists of `start` plus the specified fallback: for a string or array `fallbackLocale`, the value as specified in the props is used; for a map `fallbackLocale`, the map's **keys** are used and the `default` key is skipped since it is not a locale name.
1392
1448
  *
1393
1449
  * @param ctx - A {@link CoreContext | context}
1394
1450
  * @param fallback - A {@link FallbackLocale | fallback locale}
@@ -1399,7 +1455,7 @@ function resolveLocale(locale) {
1399
1455
  * @VueI18nGeneral
1400
1456
  */
1401
1457
  function fallbackWithSimple(_ctx, fallback, start) {
1402
- return [...new Set([start, ...isArray(fallback) ? fallback : isObject(fallback) ? Object.keys(fallback) : isString(fallback) ? [fallback] : [start]])];
1458
+ return [.../* @__PURE__ */ new Set([start, ...isArray(fallback) ? fallback : isObject(fallback) ? Object.keys(fallback).filter((locale) => locale !== "default") : isString(fallback) ? [fallback] : [start]])];
1403
1459
  }
1404
1460
  /**
1405
1461
  * Fallback with locale chain
@@ -1407,6 +1463,9 @@ function fallbackWithSimple(_ctx, fallback, start) {
1407
1463
  * @remarks
1408
1464
  * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default.
1409
1465
  *
1466
+ * Chains are cached per fallback identity. If you mutate an object or array fallback in place,
1467
+ * pass a new object or array instead so that the chain is recomputed.
1468
+ *
1410
1469
  * @param ctx - A {@link CoreContext | context}
1411
1470
  * @param fallback - A {@link FallbackLocale | fallback locale}
1412
1471
  * @param start - A starting {@link Locale | locale}
@@ -1420,17 +1479,31 @@ function fallbackWithSimple(_ctx, fallback, start) {
1420
1479
  function fallbackWithLocaleChain(ctx, fallback, start) {
1421
1480
  const startLocale = isString(start) ? start : DEFAULT_LOCALE;
1422
1481
  const context = ctx;
1423
- if (!context.__localeChainCache) context.__localeChainCache = /* @__PURE__ */ new Map();
1424
- let chain = context.__localeChainCache.get(startLocale);
1425
- if (!chain) {
1426
- chain = [];
1427
- let block = [start];
1428
- while (isArray(block)) block = appendBlockToChain(chain, block, fallback);
1429
- const defaults = isArray(fallback) || !isPlainObject(fallback) ? fallback : fallback["default"] ? fallback["default"] : null;
1430
- block = isString(defaults) ? [defaults] : defaults;
1431
- if (isArray(block)) appendBlockToChain(chain, block, false);
1432
- context.__localeChainCache.set(startLocale, chain);
1482
+ let chains;
1483
+ if (isObject(fallback)) {
1484
+ if (!context.__localeChainObjectCache) context.__localeChainObjectCache = /* @__PURE__ */ new WeakMap();
1485
+ chains = context.__localeChainObjectCache.get(fallback);
1486
+ if (!chains) {
1487
+ chains = /* @__PURE__ */ new Map();
1488
+ context.__localeChainObjectCache.set(fallback, chains);
1489
+ }
1490
+ } else {
1491
+ if (!context.__localeChainCache) context.__localeChainCache = /* @__PURE__ */ new Map();
1492
+ chains = context.__localeChainCache.get(fallback);
1493
+ if (!chains) {
1494
+ chains = /* @__PURE__ */ new Map();
1495
+ context.__localeChainCache.set(fallback, chains);
1496
+ }
1433
1497
  }
1498
+ const cached = chains.get(startLocale);
1499
+ if (cached) return cached;
1500
+ const chain = [];
1501
+ let block = [start];
1502
+ while (isArray(block)) block = appendBlockToChain(chain, block, fallback);
1503
+ const defaults = isArray(fallback) || !isPlainObject(fallback) ? fallback : fallback["default"] ? fallback["default"] : null;
1504
+ block = isString(defaults) ? [defaults] : defaults;
1505
+ if (isArray(block)) appendBlockToChain(chain, block, false);
1506
+ chains.set(startLocale, chain);
1434
1507
  return chain;
1435
1508
  }
1436
1509
  function appendBlockToChain(chain, block, blocks) {
@@ -1722,7 +1795,7 @@ function getWarnMessage(code, ...args) {
1722
1795
  * Intlify core-base version
1723
1796
  * @internal
1724
1797
  */
1725
- const VERSION = "12.0.0-alpha.4";
1798
+ const VERSION = "12.0.0-alpha.5";
1726
1799
  const NOT_RESOLVED = -1;
1727
1800
  const DEFAULT_LOCALE = "en-US";
1728
1801
  const MISSING_RESOLVE_VALUE = "";
@@ -1782,11 +1855,6 @@ function registerLocaleFallbacker(fallbacker) {
1782
1855
  warnOnce(`registerLocaleFallbacker is deprecated. Use 'localeFallbacker' option of 'createI18n' or 'createCoreContext' instead.`);
1783
1856
  _fallbacker = fallbacker;
1784
1857
  }
1785
- let _fallbackContext = null;
1786
- const setFallbackContext = (context) => {
1787
- _fallbackContext = context;
1788
- };
1789
- const getFallbackContext = () => _fallbackContext;
1790
1858
  let _cid = 0;
1791
1859
  function createCoreContext(options = {}) {
1792
1860
  const onWarn = isFunction(options.onWarn) ? options.onWarn : warn;
@@ -1852,7 +1920,7 @@ const createResources = (locale) => ({ [locale]: create() });
1852
1920
  * @version 12.0.0
1853
1921
  */
1854
1922
  function getLocaleMessage(ctx, locale) {
1855
- const src = ctx.messages[locale];
1923
+ const src = getOwn(ctx.messages, locale);
1856
1924
  if (src == null) return;
1857
1925
  const dest = create();
1858
1926
  deepCopy(src, dest);
@@ -1862,6 +1930,7 @@ function getLocaleMessage(ctx, locale) {
1862
1930
  * @version 12.0.0
1863
1931
  */
1864
1932
  function setLocaleMessage(ctx, locale, messages) {
1933
+ if (isObjectPrototypeKey(locale)) return;
1865
1934
  ctx.messages[locale] = messages;
1866
1935
  }
1867
1936
  /** @internal */
@@ -1881,7 +1950,7 @@ function handleMissing(context, key, locale, missingWarn, type) {
1881
1950
  locale,
1882
1951
  key,
1883
1952
  type,
1884
- groupId: `${type}:${key}`
1953
+ groupId: toDevtoolsGroupId(type, key)
1885
1954
  });
1886
1955
  }
1887
1956
  if (missing !== null) {
@@ -1895,10 +1964,15 @@ function handleMissing(context, key, locale, missingWarn, type) {
1895
1964
  return key;
1896
1965
  }
1897
1966
  }
1967
+ function invalidateLocaleChainCache(ctx, fallback) {
1968
+ const context = ctx;
1969
+ if (isObject(fallback)) context.__localeChainObjectCache?.delete(fallback);
1970
+ else context.__localeChainCache?.delete(fallback);
1971
+ }
1898
1972
  /** @internal */
1899
1973
  function updateFallbackLocale(ctx, locale, fallback) {
1900
- const context = ctx;
1901
- context.__localeChainCache = /* @__PURE__ */ new Map();
1974
+ invalidateLocaleChainCache(ctx, fallback);
1975
+ if (ctx.fallbackContext) invalidateLocaleChainCache(ctx.fallbackContext, fallback);
1902
1976
  ctx.localeFallbacker(ctx, fallback, locale);
1903
1977
  }
1904
1978
  /** @internal */
@@ -1914,6 +1988,59 @@ function isImplicitFallback(targetLocale, locales) {
1914
1988
  return false;
1915
1989
  }
1916
1990
  //#endregion
1991
+ //#region packages/core-base/src/formatter.ts
1992
+ function resolveFormatLocale(context, key, locale, formats, missingWarn, fallbackWarn, type) {
1993
+ const { fallbackLocale, localeFallbacker, onWarn } = context;
1994
+ const locales = localeFallbacker(context, fallbackLocale, locale);
1995
+ let from = locale;
1996
+ for (let i = 0; i < locales.length; i++) {
1997
+ const targetLocale = locales[i];
1998
+ if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) onWarn(getWarnMessage(type === "datetime format" ? CoreWarnCodes.FALLBACK_TO_DATE_FORMAT : CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, {
1999
+ key,
2000
+ target: targetLocale
2001
+ }));
2002
+ if (locale !== targetLocale) {
2003
+ const emitter = context.__v_emitter;
2004
+ if (emitter) emitter.emit("fallback", {
2005
+ type,
2006
+ key,
2007
+ from,
2008
+ to: targetLocale,
2009
+ groupId: toDevtoolsGroupId(type, key)
2010
+ });
2011
+ }
2012
+ const format = (formats[targetLocale] || {})[key];
2013
+ if (isPlainObject(format) && isString(targetLocale)) return targetLocale;
2014
+ handleMissing(context, key, targetLocale, missingWarn, type);
2015
+ from = targetLocale;
2016
+ }
2017
+ return null;
2018
+ }
2019
+ function getFormatterCacheKey(locale, key, overrides) {
2020
+ let id = `${locale}__${key}`;
2021
+ if (isPlainObject(overrides) && !isKeylessObject(overrides)) id = `${id}__${JSON.stringify(overrides)}`;
2022
+ return id;
2023
+ }
2024
+ function clearFormatCache(formatters, locale, format) {
2025
+ for (const key in format) {
2026
+ const prefix = `${locale}__${key}`;
2027
+ for (const id of formatters.keys()) if (id === prefix || id.startsWith(`${prefix}__`)) formatters.delete(id);
2028
+ }
2029
+ }
2030
+ function parseFormatArgs(args, options, initialOverrides, optionsKeys) {
2031
+ const [, arg2, arg3, arg4] = args;
2032
+ let overrides = initialOverrides;
2033
+ if (isString(arg2)) options.key = arg2;
2034
+ else if (isPlainObject(arg2)) Object.keys(arg2).forEach((key) => {
2035
+ if (optionsKeys.includes(key)) overrides[key] = arg2[key];
2036
+ else options[key] = arg2[key];
2037
+ });
2038
+ if (isString(arg3)) options.locale = arg3;
2039
+ else if (isPlainObject(arg3)) overrides = arg3;
2040
+ if (isPlainObject(arg4)) overrides = arg4;
2041
+ return overrides;
2042
+ }
2043
+ //#endregion
1917
2044
  //#region packages/core-base/src/intl.ts
1918
2045
  const intlDefined = typeof Intl !== "undefined";
1919
2046
  const Availabilities = {
@@ -1923,7 +2050,7 @@ const Availabilities = {
1923
2050
  //#endregion
1924
2051
  //#region packages/core-base/src/datetime.ts
1925
2052
  function datetime(context, ...args) {
1926
- const { datetimeFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
2053
+ const { datetimeFormats, unresolving, onWarn } = context;
1927
2054
  const { __datetimeFormatters } = context;
1928
2055
  if (!Availabilities.dateTimeFormat) {
1929
2056
  onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE));
@@ -1938,39 +2065,14 @@ function datetime(context, ...args) {
1938
2065
  const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
1939
2066
  const part = !!options.part;
1940
2067
  const locale = getLocale(context, options);
1941
- const locales = localeFallbacker(context, fallbackLocale, locale);
1942
- if (!isString(key) || key === "") return new Intl.DateTimeFormat(locale.replace(/!/g, ""), overrides).format(value);
1943
- let datetimeFormat = {};
1944
- let targetLocale;
1945
- let format = null;
1946
- let from = locale;
1947
- let to = null;
1948
- const type = "datetime format";
1949
- for (let i = 0; i < locales.length; i++) {
1950
- targetLocale = to = locales[i];
1951
- if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_DATE_FORMAT, {
1952
- key,
1953
- target: targetLocale
1954
- }));
1955
- if (locale !== targetLocale) {
1956
- const emitter = context.__v_emitter;
1957
- if (emitter) emitter.emit("fallback", {
1958
- type,
1959
- key,
1960
- from,
1961
- to,
1962
- groupId: `${type}:${key}`
1963
- });
1964
- }
1965
- datetimeFormat = datetimeFormats[targetLocale] || {};
1966
- format = datetimeFormat[key];
1967
- if (isPlainObject(format)) break;
1968
- handleMissing(context, key, targetLocale, missingWarn, type);
1969
- from = to;
1970
- }
1971
- if (!isPlainObject(format) || !isString(targetLocale)) return unresolving ? -1 : key;
1972
- let id = `${targetLocale}__${key}`;
1973
- if (isPlainObject(overrides) && !isKeylessObject(overrides)) id = `${id}__${JSON.stringify(overrides)}`;
2068
+ if (!isString(key) || key === "") {
2069
+ const formatter = new Intl.DateTimeFormat(locale.replace(/!/g, ""), overrides);
2070
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
2071
+ }
2072
+ const targetLocale = resolveFormatLocale(context, key, locale, datetimeFormats, missingWarn, fallbackWarn, "datetime format");
2073
+ if (!isString(targetLocale)) return unresolving ? -1 : key;
2074
+ const format = datetimeFormats[targetLocale][key];
2075
+ const id = getFormatterCacheKey(targetLocale, key, overrides);
1974
2076
  let formatter = __datetimeFormatters.get(id);
1975
2077
  if (!formatter) {
1976
2078
  formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides));
@@ -2003,12 +2105,12 @@ const DATETIME_FORMAT_OPTIONS_KEYS = [
2003
2105
  ];
2004
2106
  /** @internal */
2005
2107
  function parseDateTimeArgs(...args) {
2006
- const [arg1, arg2, arg3, arg4] = args;
2108
+ const [arg1] = args;
2007
2109
  const options = create();
2008
- let overrides = create();
2110
+ const initialOverrides = create();
2009
2111
  let value;
2010
2112
  if (isString(arg1)) {
2011
- const matches = arg1.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/);
2113
+ const matches = arg1.match(/^(\d{4}-\d{2}-\d{2})(?:(T|\s)(.+))?$/);
2012
2114
  if (!matches) throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
2013
2115
  const dateTime = matches[3] ? matches[3].trim().startsWith("T") ? `${matches[1].trim()}${matches[3].trim()}` : `${matches[1].trim()}T${matches[3].trim()}` : matches[1].trim();
2014
2116
  value = new Date(dateTime);
@@ -2022,14 +2124,7 @@ function parseDateTimeArgs(...args) {
2022
2124
  value = arg1;
2023
2125
  } else if (isNumber(arg1)) value = arg1;
2024
2126
  else throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
2025
- if (isString(arg2)) options.key = arg2;
2026
- else if (isPlainObject(arg2)) Object.keys(arg2).forEach((key) => {
2027
- if (DATETIME_FORMAT_OPTIONS_KEYS.includes(key)) overrides[key] = arg2[key];
2028
- else options[key] = arg2[key];
2029
- });
2030
- if (isString(arg3)) options.locale = arg3;
2031
- else if (isPlainObject(arg3)) overrides = arg3;
2032
- if (isPlainObject(arg4)) overrides = arg4;
2127
+ const overrides = parseFormatArgs(args, options, initialOverrides, DATETIME_FORMAT_OPTIONS_KEYS);
2033
2128
  return [
2034
2129
  options.key || "",
2035
2130
  value,
@@ -2039,17 +2134,12 @@ function parseDateTimeArgs(...args) {
2039
2134
  }
2040
2135
  /** @internal */
2041
2136
  function clearDateTimeFormat(ctx, locale, format) {
2042
- const context = ctx;
2043
- for (const key in format) {
2044
- const id = `${locale}__${key}`;
2045
- if (!context.__datetimeFormatters.has(id)) continue;
2046
- context.__datetimeFormatters.delete(id);
2047
- }
2137
+ clearFormatCache(ctx.__datetimeFormatters, locale, format);
2048
2138
  }
2049
2139
  //#endregion
2050
2140
  //#region packages/core-base/src/number.ts
2051
2141
  function number(context, ...args) {
2052
- const { numberFormats, unresolving, fallbackLocale, onWarn, localeFallbacker } = context;
2142
+ const { numberFormats, unresolving, onWarn } = context;
2053
2143
  const { __numberFormatters } = context;
2054
2144
  if (!Availabilities.numberFormat) {
2055
2145
  onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER));
@@ -2064,39 +2154,14 @@ function number(context, ...args) {
2064
2154
  const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
2065
2155
  const part = !!options.part;
2066
2156
  const locale = getLocale(context, options);
2067
- const locales = localeFallbacker(context, fallbackLocale, locale);
2068
- if (!isString(key) || key === "") return new Intl.NumberFormat(locale.replace(/!/g, ""), overrides).format(value);
2069
- let numberFormat = {};
2070
- let targetLocale;
2071
- let format = null;
2072
- let from = locale;
2073
- let to = null;
2074
- const type = "number format";
2075
- for (let i = 0; i < locales.length; i++) {
2076
- targetLocale = to = locales[i];
2077
- if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, {
2078
- key,
2079
- target: targetLocale
2080
- }));
2081
- if (locale !== targetLocale) {
2082
- const emitter = context.__v_emitter;
2083
- if (emitter) emitter.emit("fallback", {
2084
- type,
2085
- key,
2086
- from,
2087
- to,
2088
- groupId: `${type}:${key}`
2089
- });
2090
- }
2091
- numberFormat = numberFormats[targetLocale] || {};
2092
- format = numberFormat[key];
2093
- if (isPlainObject(format)) break;
2094
- handleMissing(context, key, targetLocale, missingWarn, type);
2095
- from = to;
2096
- }
2097
- if (!isPlainObject(format) || !isString(targetLocale)) return unresolving ? -1 : key;
2098
- let id = `${targetLocale}__${key}`;
2099
- if (isPlainObject(overrides) && !isKeylessObject(overrides)) id = `${id}__${JSON.stringify(overrides)}`;
2157
+ if (!isString(key) || key === "") {
2158
+ const formatter = new Intl.NumberFormat(locale.replace(/!/g, ""), overrides);
2159
+ return !part ? formatter.format(value) : formatter.formatToParts(value);
2160
+ }
2161
+ const targetLocale = resolveFormatLocale(context, key, locale, numberFormats, missingWarn, fallbackWarn, "number format");
2162
+ if (!isString(targetLocale)) return unresolving ? -1 : key;
2163
+ const format = numberFormats[targetLocale][key];
2164
+ const id = getFormatterCacheKey(targetLocale, key, overrides);
2100
2165
  let formatter = __numberFormatters.get(id);
2101
2166
  if (!formatter) {
2102
2167
  formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides));
@@ -2129,19 +2194,12 @@ const NUMBER_FORMAT_OPTIONS_KEYS = [
2129
2194
  ];
2130
2195
  /** @internal */
2131
2196
  function parseNumberArgs(...args) {
2132
- const [arg1, arg2, arg3, arg4] = args;
2197
+ const [arg1] = args;
2133
2198
  const options = create();
2134
- let overrides = create();
2199
+ const initialOverrides = create();
2135
2200
  if (!isNumber(arg1)) throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
2136
2201
  const value = arg1;
2137
- if (isString(arg2)) options.key = arg2;
2138
- else if (isPlainObject(arg2)) Object.keys(arg2).forEach((key) => {
2139
- if (NUMBER_FORMAT_OPTIONS_KEYS.includes(key)) overrides[key] = arg2[key];
2140
- else options[key] = arg2[key];
2141
- });
2142
- if (isString(arg3)) options.locale = arg3;
2143
- else if (isPlainObject(arg3)) overrides = arg3;
2144
- if (isPlainObject(arg4)) overrides = arg4;
2202
+ const overrides = parseFormatArgs(args, options, initialOverrides, NUMBER_FORMAT_OPTIONS_KEYS);
2145
2203
  return [
2146
2204
  options.key || "",
2147
2205
  value,
@@ -2151,12 +2209,7 @@ function parseNumberArgs(...args) {
2151
2209
  }
2152
2210
  /** @internal */
2153
2211
  function clearNumberFormat(ctx, locale, format) {
2154
- const context = ctx;
2155
- for (const key in format) {
2156
- const id = `${locale}__${key}`;
2157
- if (!context.__numberFormatters.has(id)) continue;
2158
- context.__numberFormatters.delete(id);
2159
- }
2212
+ clearFormatCache(ctx.__numberFormatters, locale, format);
2160
2213
  }
2161
2214
  //#endregion
2162
2215
  //#region packages/core-base/src/runtime.ts
@@ -2261,6 +2314,8 @@ function createMessageContext(options = {}) {
2261
2314
  //#region packages/core-base/src/translate.ts
2262
2315
  const NOOP_MESSAGE_FUNCTION = () => "";
2263
2316
  const isMessageFunction = (val) => isFunction(val);
2317
+ /** @internal */
2318
+ const isMessageFormat = (val) => isString(val) || isMessageAST(val) || isMessageFunction(val);
2264
2319
  function translate(context, ...args) {
2265
2320
  const [key, options] = parseTranslateArgs(...args);
2266
2321
  const locale = getLocale(context, options);
@@ -2273,16 +2328,16 @@ function translate(context, ...args) {
2273
2328
  context.messages[locale] || create()
2274
2329
  ];
2275
2330
  let cacheBaseKey = key;
2276
- if (!resolvedMessage && !(isString(format) || isMessageAST(format) || isMessageFunction(format))) {
2331
+ if (!resolvedMessage && !isMessageFormat(format)) {
2277
2332
  const defaultMsgOrKey = isString(options.default) ? options.default : isBoolean(options.default) || context.fallbackFormat ? !context.messageCompiler ? () => key : key : null;
2278
2333
  if (context.fallbackFormat || defaultMsgOrKey != null && (isString(defaultMsgOrKey) || isFunction(defaultMsgOrKey))) {
2279
2334
  format = defaultMsgOrKey;
2280
2335
  cacheBaseKey = format;
2281
2336
  }
2282
2337
  }
2283
- if (!resolvedMessage && (!(isString(format) || isMessageAST(format) || isMessageFunction(format)) || !isString(targetLocale))) return context.unresolving ? -1 : key;
2338
+ if (!resolvedMessage && (!isMessageFormat(format) || !isString(targetLocale))) return context.unresolving ? -1 : key;
2284
2339
  if (isString(format) && context.messageCompiler == null) {
2285
- warn(`The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return '${isString(key) ? key : isObject(key) ? JSON.stringify(key) : isFunction(key) ? key.name || "function" : ""}'.`);
2340
+ warn(`The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return '${stringifyKey(key)}'.`);
2286
2341
  return key;
2287
2342
  }
2288
2343
  let occurred = false;
@@ -2299,9 +2354,15 @@ function translate(context, ...args) {
2299
2354
  }
2300
2355
  function escapeParams(options) {
2301
2356
  if (isArray(options.list)) options.list = options.list.map((item) => isString(item) ? escapeHtml(item) : item);
2302
- else if (isObject(options.named)) Object.keys(options.named).forEach((key) => {
2303
- if (isString(options.named[key])) options.named[key] = escapeHtml(options.named[key]);
2304
- });
2357
+ if (isObject(options.named)) {
2358
+ const source = options.named;
2359
+ const named = create();
2360
+ for (const key of Object.keys(source)) {
2361
+ const value = source[key];
2362
+ named[key] = isString(value) ? escapeHtml(value) : value;
2363
+ }
2364
+ options.named = named;
2365
+ }
2305
2366
  }
2306
2367
  function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
2307
2368
  const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
@@ -2324,7 +2385,7 @@ function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn
2324
2385
  key,
2325
2386
  from,
2326
2387
  to: targetLocale,
2327
- groupId: `${type}:${key}`
2388
+ groupId: toDevtoolsGroupId(type, key)
2328
2389
  });
2329
2390
  }
2330
2391
  message = messages[targetLocale] || create();
@@ -2346,14 +2407,14 @@ function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn
2346
2407
  key,
2347
2408
  message: format,
2348
2409
  time: end - start,
2349
- groupId: `${type}:${key}`
2410
+ groupId: toDevtoolsGroupId(type, key)
2350
2411
  });
2351
2412
  if (startTag && endTag && mark && measure) {
2352
2413
  mark(endTag);
2353
2414
  measure("intlify message resolve", startTag, endTag);
2354
2415
  }
2355
2416
  }
2356
- if (isString(format) || isMessageAST(format) || isMessageFunction(format)) break;
2417
+ if (isMessageFormat(format)) break;
2357
2418
  if (!isImplicitFallback(targetLocale, locales)) {
2358
2419
  const missingRet = handleMissing(context, key, targetLocale, missingWarn, type);
2359
2420
  if (missingRet !== key) format = missingRet;
@@ -2366,6 +2427,9 @@ function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn
2366
2427
  message
2367
2428
  ];
2368
2429
  }
2430
+ function stringifyKey(key) {
2431
+ return isString(key) ? key : isObject(key) ? JSON.stringify(key) : isFunction(key) ? key.name || "function" : "";
2432
+ }
2369
2433
  function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) {
2370
2434
  if (isMessageFunction(format)) {
2371
2435
  const msg = format;
@@ -2396,7 +2460,7 @@ function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey,
2396
2460
  type: "message-compilation",
2397
2461
  message: format,
2398
2462
  time: end - start,
2399
- groupId: `translate:${key}`
2463
+ groupId: toDevtoolsGroupId("translate", key)
2400
2464
  });
2401
2465
  if (startTag && endTag && mark && measure) {
2402
2466
  mark(endTag);
@@ -2421,7 +2485,7 @@ if (inBrowser) {
2421
2485
  type: "message-evaluation",
2422
2486
  value: messaged,
2423
2487
  time: end - start,
2424
- groupId: `translate:${msg.key}`
2488
+ groupId: toDevtoolsGroupId("translate", msg.key)
2425
2489
  });
2426
2490
  mark(endTag);
2427
2491
  measure("intlify message evaluation", startTag, endTag);
@@ -2459,12 +2523,11 @@ function getCompileContext(context, locale, key, source, warnHtmlMessage, onErro
2459
2523
  error: err.message,
2460
2524
  start: err.location && err.location.start.offset,
2461
2525
  end: err.location && err.location.end.offset,
2462
- groupId: `translate:${key}`
2526
+ groupId: toDevtoolsGroupId("translate", key)
2463
2527
  });
2464
2528
  const message = `Message compilation error: ${err.message}`;
2465
2529
  throw new SyntaxError(codeFrame ? `${message}\n${codeFrame}` : message);
2466
2530
  }
2467
- throw err;
2468
2531
  },
2469
2532
  onCacheKey: (source) => generateFormatCacheKey(locale, key, source)
2470
2533
  };
@@ -2503,4 +2566,4 @@ function getMessageContextOptions(context, locale, message, options) {
2503
2566
  };
2504
2567
  }
2505
2568
  //#endregion
2506
- export { AST_NODE_PROPS_KEYS, CORE_ERROR_CODES_EXTEND_POINT, CORE_WARN_CODES_EXTEND_POINT, CoreWarnCodes, DATETIME_FORMAT_OPTIONS_KEYS, DEFAULT_LOCALE, DEFAULT_MESSAGE_DATA_TYPE, MISSING_RESOLVE_VALUE, NOT_RESOLVED, NUMBER_FORMAT_OPTIONS_KEYS, VERSION, clearCompileCache, clearDateTimeFormat, clearNumberFormat, compile, createCompileError, createCoreContext, createCoreError, createMessageContext, datetime, fallbackWithLocaleChain, fallbackWithSimple, getFallbackContext, getLocale, getLocaleMessage, getWarnMessage, handleMissing, isAlmostSameLocale, isImplicitFallback, isMessageAST, isMessageFunction, isTranslateFallbackWarn, isTranslateMissingWarn, number, parse, parseDateTimeArgs, parseNumberArgs, parseTranslateArgs, registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveLocale, resolveValue, resolveWithKeyValue, setFallbackContext, setLocaleMessage, translate, updateFallbackLocale };
2569
+ export { AST_NODE_PROPS_KEYS, CORE_ERROR_CODES_EXTEND_POINT, CORE_WARN_CODES_EXTEND_POINT, CoreWarnCodes, DATETIME_FORMAT_OPTIONS_KEYS, DEFAULT_LOCALE, DEFAULT_MESSAGE_DATA_TYPE, MISSING_RESOLVE_VALUE, NOT_RESOLVED, NUMBER_FORMAT_OPTIONS_KEYS, VERSION, clearCompileCache, clearDateTimeFormat, clearNumberFormat, compile, createCompileError, createCoreContext, createCoreError, createMessageContext, datetime, fallbackWithLocaleChain, fallbackWithSimple, getLocale, getLocaleMessage, getWarnMessage, handleMissing, isAlmostSameLocale, isImplicitFallback, isMessageAST, isMessageFormat, isMessageFunction, isTranslateFallbackWarn, isTranslateMissingWarn, number, parse, parseDateTimeArgs, parseNumberArgs, parseTranslateArgs, registerLocaleFallbacker, registerMessageCompiler, registerMessageResolver, resolveLocale, resolveValue, resolveWithKeyValue, setLocaleMessage, translate, updateFallbackLocale };