@formatjs/intl 4.1.5 → 4.1.6
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/index.d.ts +306 -20
- package/index.js +521 -14
- package/index.js.map +1 -0
- package/package.json +4 -5
- package/src/create-intl.d.ts +0 -14
- package/src/create-intl.js +0 -69
- package/src/dateTime.d.ts +0 -37
- package/src/dateTime.js +0 -86
- package/src/displayName.d.ts +0 -5
- package/src/displayName.js +0 -24
- package/src/error.d.ts +0 -35
- package/src/error.js +0 -68
- package/src/list.d.ts +0 -9
- package/src/list.js +0 -51
- package/src/message.d.ts +0 -15
- package/src/message.js +0 -106
- package/src/number.d.ts +0 -16
- package/src/number.js +0 -50
- package/src/plural.d.ts +0 -5
- package/src/plural.js +0 -19
- package/src/relativeTime.d.ts +0 -6
- package/src/relativeTime.js +0 -28
- package/src/types.d.ts +0 -111
- package/src/types.js +0 -3
- package/src/utils.d.ts +0 -15
- package/src/utils.js +0 -125
package/index.js
CHANGED
|
@@ -1,18 +1,525 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { memoize, strategies } from "@formatjs/fast-memoize";
|
|
2
|
+
import { ErrorCode, FormatError, IntlMessageFormat } from "intl-messageformat";
|
|
3
|
+
import { TYPE } from "@formatjs/icu-messageformat-parser";
|
|
4
|
+
//#region packages/intl/error.ts
|
|
5
|
+
let IntlErrorCode = /* @__PURE__ */ function(IntlErrorCode) {
|
|
6
|
+
IntlErrorCode["FORMAT_ERROR"] = "FORMAT_ERROR";
|
|
7
|
+
IntlErrorCode["UNSUPPORTED_FORMATTER"] = "UNSUPPORTED_FORMATTER";
|
|
8
|
+
IntlErrorCode["INVALID_CONFIG"] = "INVALID_CONFIG";
|
|
9
|
+
IntlErrorCode["MISSING_DATA"] = "MISSING_DATA";
|
|
10
|
+
IntlErrorCode["MISSING_TRANSLATION"] = "MISSING_TRANSLATION";
|
|
11
|
+
return IntlErrorCode;
|
|
12
|
+
}({});
|
|
13
|
+
var IntlError = class IntlError extends Error {
|
|
14
|
+
constructor(code, message, exception) {
|
|
15
|
+
const err = exception ? exception instanceof Error ? exception : new Error(String(exception)) : void 0;
|
|
16
|
+
super(`[@formatjs/intl Error ${code}] ${message}
|
|
17
|
+
${err ? `\n${err.message}\n${err.stack}` : ""}`);
|
|
18
|
+
this.code = code;
|
|
19
|
+
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(this, IntlError);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var UnsupportedFormatterError = class extends IntlError {
|
|
23
|
+
constructor(message, exception) {
|
|
24
|
+
super(IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var InvalidConfigError = class extends IntlError {
|
|
28
|
+
constructor(message, exception) {
|
|
29
|
+
super(IntlErrorCode.INVALID_CONFIG, message, exception);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var MissingDataError = class extends IntlError {
|
|
33
|
+
constructor(message, exception) {
|
|
34
|
+
super(IntlErrorCode.MISSING_DATA, message, exception);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var IntlFormatError = class extends IntlError {
|
|
38
|
+
constructor(message, locale, exception) {
|
|
39
|
+
super(IntlErrorCode.FORMAT_ERROR, `${message}
|
|
40
|
+
Locale: ${locale}
|
|
41
|
+
`, exception);
|
|
42
|
+
this.locale = locale;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var MessageFormatError = class extends IntlFormatError {
|
|
46
|
+
constructor(message, locale, descriptor, exception) {
|
|
47
|
+
super(`${message}
|
|
48
|
+
MessageID: ${descriptor?.id}
|
|
49
|
+
Default Message: ${descriptor?.defaultMessage}
|
|
50
|
+
Description: ${descriptor?.description}
|
|
51
|
+
`, locale, exception);
|
|
52
|
+
this.descriptor = descriptor;
|
|
53
|
+
this.locale = locale;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var MissingTranslationError = class extends IntlError {
|
|
57
|
+
constructor(descriptor, locale) {
|
|
58
|
+
super(IntlErrorCode.MISSING_TRANSLATION, `Missing message: "${descriptor.id}" for locale "${locale}", using ${descriptor.defaultMessage ? `default message (${typeof descriptor.defaultMessage === "string" ? descriptor.defaultMessage : descriptor.defaultMessage.map((e) => e.value ?? JSON.stringify(e)).join()})` : "id"} as fallback.`);
|
|
59
|
+
this.descriptor = descriptor;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region packages/intl/utils.ts
|
|
64
|
+
function invariant(condition, message, Err = Error) {
|
|
65
|
+
if (!condition) throw new Err(message);
|
|
66
|
+
}
|
|
67
|
+
function filterProps(props, allowlist, defaults = {}) {
|
|
68
|
+
return allowlist.reduce((filtered, name) => {
|
|
69
|
+
if (name in props) filtered[name] = props[name];
|
|
70
|
+
else if (name in defaults) filtered[name] = defaults[name];
|
|
71
|
+
return filtered;
|
|
72
|
+
}, {});
|
|
73
|
+
}
|
|
74
|
+
const defaultErrorHandler = (error) => {
|
|
75
|
+
console.error(error);
|
|
76
|
+
};
|
|
77
|
+
const defaultWarnHandler = (warning) => {
|
|
78
|
+
console.warn(warning);
|
|
79
|
+
};
|
|
80
|
+
const DEFAULT_INTL_CONFIG = {
|
|
81
|
+
formats: {},
|
|
82
|
+
messages: {},
|
|
83
|
+
timeZone: void 0,
|
|
84
|
+
defaultLocale: "en",
|
|
85
|
+
defaultFormats: {},
|
|
86
|
+
fallbackOnEmptyString: true,
|
|
87
|
+
onError: defaultErrorHandler,
|
|
88
|
+
onWarn: defaultWarnHandler
|
|
89
|
+
};
|
|
90
|
+
function createIntlCache() {
|
|
91
|
+
return {
|
|
92
|
+
dateTime: {},
|
|
93
|
+
number: {},
|
|
94
|
+
message: {},
|
|
95
|
+
relativeTime: {},
|
|
96
|
+
pluralRules: {},
|
|
97
|
+
list: {},
|
|
98
|
+
displayNames: {}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function createFastMemoizeCache(store) {
|
|
102
|
+
return { create() {
|
|
103
|
+
return {
|
|
104
|
+
get(key) {
|
|
105
|
+
return store[key];
|
|
106
|
+
},
|
|
107
|
+
set(key, value) {
|
|
108
|
+
store[key] = value;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
} };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create intl formatters and populate cache
|
|
115
|
+
* @param cache explicit cache to prevent leaking memory
|
|
116
|
+
*/
|
|
117
|
+
function createFormatters(cache = createIntlCache()) {
|
|
118
|
+
const RelativeTimeFormat = Intl.RelativeTimeFormat;
|
|
119
|
+
const ListFormat = Intl.ListFormat;
|
|
120
|
+
const DisplayNames = Intl.DisplayNames;
|
|
121
|
+
const getDateTimeFormat = memoize((...args) => new Intl.DateTimeFormat(...args), {
|
|
122
|
+
cache: createFastMemoizeCache(cache.dateTime),
|
|
123
|
+
strategy: strategies.variadic
|
|
124
|
+
});
|
|
125
|
+
const getNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), {
|
|
126
|
+
cache: createFastMemoizeCache(cache.number),
|
|
127
|
+
strategy: strategies.variadic
|
|
128
|
+
});
|
|
129
|
+
const getPluralRules = memoize((...args) => new Intl.PluralRules(...args), {
|
|
130
|
+
cache: createFastMemoizeCache(cache.pluralRules),
|
|
131
|
+
strategy: strategies.variadic
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
getDateTimeFormat,
|
|
135
|
+
getNumberFormat,
|
|
136
|
+
getMessageFormat: memoize((message, locales, overrideFormats, opts) => new IntlMessageFormat(message, locales, overrideFormats, {
|
|
137
|
+
formatters: {
|
|
138
|
+
getNumberFormat,
|
|
139
|
+
getDateTimeFormat,
|
|
140
|
+
getPluralRules
|
|
141
|
+
},
|
|
142
|
+
...opts
|
|
143
|
+
}), {
|
|
144
|
+
cache: createFastMemoizeCache(cache.message),
|
|
145
|
+
strategy: strategies.variadic
|
|
146
|
+
}),
|
|
147
|
+
getRelativeTimeFormat: memoize((...args) => new RelativeTimeFormat(...args), {
|
|
148
|
+
cache: createFastMemoizeCache(cache.relativeTime),
|
|
149
|
+
strategy: strategies.variadic
|
|
150
|
+
}),
|
|
151
|
+
getPluralRules,
|
|
152
|
+
getListFormat: memoize((...args) => new ListFormat(...args), {
|
|
153
|
+
cache: createFastMemoizeCache(cache.list),
|
|
154
|
+
strategy: strategies.variadic
|
|
155
|
+
}),
|
|
156
|
+
getDisplayNames: memoize((...args) => new DisplayNames(...args), {
|
|
157
|
+
cache: createFastMemoizeCache(cache.displayNames),
|
|
158
|
+
strategy: strategies.variadic
|
|
159
|
+
})
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function getNamedFormat(formats, type, name, onError) {
|
|
163
|
+
const formatType = formats && formats[type];
|
|
164
|
+
let format;
|
|
165
|
+
if (formatType) format = formatType[name];
|
|
166
|
+
if (format) return format;
|
|
167
|
+
onError(new UnsupportedFormatterError(`No ${type} format named: ${name}`));
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region packages/intl/message.ts
|
|
171
|
+
function setTimeZoneInOptions(opts, timeZone) {
|
|
172
|
+
return Object.keys(opts).reduce((all, k) => {
|
|
173
|
+
all[k] = {
|
|
174
|
+
timeZone,
|
|
175
|
+
...opts[k]
|
|
176
|
+
};
|
|
177
|
+
return all;
|
|
178
|
+
}, {});
|
|
179
|
+
}
|
|
180
|
+
function deepMergeOptions(opts1, opts2) {
|
|
181
|
+
return Object.keys({
|
|
182
|
+
...opts1,
|
|
183
|
+
...opts2
|
|
184
|
+
}).reduce((all, k) => {
|
|
185
|
+
all[k] = {
|
|
186
|
+
...opts1[k],
|
|
187
|
+
...opts2[k]
|
|
188
|
+
};
|
|
189
|
+
return all;
|
|
190
|
+
}, {});
|
|
191
|
+
}
|
|
192
|
+
function deepMergeFormatsAndSetTimeZone(f1, timeZone) {
|
|
193
|
+
if (!timeZone) return f1;
|
|
194
|
+
const mfFormats = IntlMessageFormat.formats;
|
|
195
|
+
return {
|
|
196
|
+
...mfFormats,
|
|
197
|
+
...f1,
|
|
198
|
+
date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)),
|
|
199
|
+
time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone))
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const formatMessage = ({ locale, formats, messages, defaultLocale, defaultFormats, fallbackOnEmptyString, onError, timeZone, defaultRichTextElements }, state, messageDescriptor = { id: "" }, values, opts) => {
|
|
203
|
+
const { id: msgId, defaultMessage } = messageDescriptor;
|
|
204
|
+
invariant(!!msgId, `[@formatjs/intl] An \`id\` must be provided to format a message. You can either:
|
|
205
|
+
1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.github.io/docs/tooling/babel-plugin)
|
|
206
|
+
or [@formatjs/ts-transformer](https://formatjs.github.io/docs/tooling/ts-transformer) OR
|
|
207
|
+
2. Configure your \`eslint\` config to include [eslint-plugin-formatjs](https://formatjs.github.io/docs/tooling/linter#enforce-id)
|
|
208
|
+
to autofix this issue`);
|
|
209
|
+
const id = String(msgId);
|
|
210
|
+
const message = messages && Object.prototype.hasOwnProperty.call(messages, id) && messages[id];
|
|
211
|
+
if (Array.isArray(message) && message.length === 1 && message[0].type === TYPE.literal) return message[0].value;
|
|
212
|
+
values = {
|
|
213
|
+
...defaultRichTextElements,
|
|
214
|
+
...values
|
|
215
|
+
};
|
|
216
|
+
formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
|
|
217
|
+
defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
|
|
218
|
+
if (!message) {
|
|
219
|
+
if (fallbackOnEmptyString === false && message === "") return message;
|
|
220
|
+
if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) onError(new MissingTranslationError(messageDescriptor, locale));
|
|
221
|
+
if (defaultMessage) try {
|
|
222
|
+
return state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts).format(values);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
onError(new MessageFormatError(`Error formatting default message for: "${id}", rendering default message verbatim`, locale, messageDescriptor, e));
|
|
225
|
+
return typeof defaultMessage === "string" ? defaultMessage : id;
|
|
226
|
+
}
|
|
227
|
+
return id;
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
return state.getMessageFormat(message, locale, formats, {
|
|
231
|
+
formatters: state,
|
|
232
|
+
...opts
|
|
233
|
+
}).format(values);
|
|
234
|
+
} catch (e) {
|
|
235
|
+
onError(new MessageFormatError(`Error formatting message: "${id}", using ${defaultMessage ? "default message" : "id"} as fallback.`, locale, messageDescriptor, e));
|
|
236
|
+
}
|
|
237
|
+
if (defaultMessage) try {
|
|
238
|
+
return state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts).format(values);
|
|
239
|
+
} catch (e) {
|
|
240
|
+
onError(new MessageFormatError(`Error formatting the default message for: "${id}", rendering message verbatim`, locale, messageDescriptor, e));
|
|
241
|
+
}
|
|
242
|
+
if (typeof message === "string") return message;
|
|
243
|
+
if (typeof defaultMessage === "string") return defaultMessage;
|
|
244
|
+
return id;
|
|
245
|
+
};
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region packages/intl/dateTime.ts
|
|
248
|
+
const DATE_TIME_FORMAT_OPTIONS = [
|
|
249
|
+
"formatMatcher",
|
|
250
|
+
"timeZone",
|
|
251
|
+
"hour12",
|
|
252
|
+
"weekday",
|
|
253
|
+
"era",
|
|
254
|
+
"year",
|
|
255
|
+
"month",
|
|
256
|
+
"day",
|
|
257
|
+
"hour",
|
|
258
|
+
"minute",
|
|
259
|
+
"second",
|
|
260
|
+
"timeZoneName",
|
|
261
|
+
"hourCycle",
|
|
262
|
+
"dateStyle",
|
|
263
|
+
"timeStyle",
|
|
264
|
+
"calendar",
|
|
265
|
+
"numberingSystem",
|
|
266
|
+
"fractionalSecondDigits"
|
|
267
|
+
];
|
|
268
|
+
function getFormatter$2({ locale, formats, onError, timeZone }, type, getDateTimeFormat, options = {}) {
|
|
269
|
+
const { format } = options;
|
|
270
|
+
let filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, {
|
|
271
|
+
...timeZone && { timeZone },
|
|
272
|
+
...format && getNamedFormat(formats, type, format, onError)
|
|
273
|
+
});
|
|
274
|
+
if (type === "time" && !filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second && !filteredOptions.timeStyle && !filteredOptions.dateStyle) filteredOptions = {
|
|
275
|
+
...filteredOptions,
|
|
276
|
+
hour: "numeric",
|
|
277
|
+
minute: "numeric"
|
|
278
|
+
};
|
|
279
|
+
return getDateTimeFormat(locale, filteredOptions);
|
|
280
|
+
}
|
|
281
|
+
function formatDate(config, getDateTimeFormat, value, options = {}) {
|
|
282
|
+
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
283
|
+
try {
|
|
284
|
+
return getFormatter$2(config, "date", getDateTimeFormat, options).format(date);
|
|
285
|
+
} catch (e) {
|
|
286
|
+
config.onError(new IntlFormatError("Error formatting date.", config.locale, e));
|
|
287
|
+
}
|
|
288
|
+
return String(date);
|
|
289
|
+
}
|
|
290
|
+
function formatTime(config, getDateTimeFormat, value, options = {}) {
|
|
291
|
+
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
292
|
+
try {
|
|
293
|
+
return getFormatter$2(config, "time", getDateTimeFormat, options).format(date);
|
|
294
|
+
} catch (e) {
|
|
295
|
+
config.onError(new IntlFormatError("Error formatting time.", config.locale, e));
|
|
296
|
+
}
|
|
297
|
+
return String(date);
|
|
298
|
+
}
|
|
299
|
+
function formatDateTimeRange(config, getDateTimeFormat, from, to, options = {}) {
|
|
300
|
+
const fromDate = typeof from === "string" ? new Date(from || 0) : from;
|
|
301
|
+
const toDate = typeof to === "string" ? new Date(to || 0) : to;
|
|
302
|
+
try {
|
|
303
|
+
return getFormatter$2(config, "dateTimeRange", getDateTimeFormat, options).formatRange(fromDate, toDate);
|
|
304
|
+
} catch (e) {
|
|
305
|
+
config.onError(new IntlFormatError("Error formatting date time range.", config.locale, e));
|
|
306
|
+
}
|
|
307
|
+
return String(fromDate);
|
|
308
|
+
}
|
|
309
|
+
function formatDateToParts(config, getDateTimeFormat, value, options = {}) {
|
|
310
|
+
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
311
|
+
try {
|
|
312
|
+
return getFormatter$2(config, "date", getDateTimeFormat, options).formatToParts(date);
|
|
313
|
+
} catch (e) {
|
|
314
|
+
config.onError(new IntlFormatError("Error formatting date.", config.locale, e));
|
|
315
|
+
}
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
function formatTimeToParts(config, getDateTimeFormat, value, options = {}) {
|
|
319
|
+
const date = typeof value === "string" ? new Date(value || 0) : value;
|
|
320
|
+
try {
|
|
321
|
+
return getFormatter$2(config, "time", getDateTimeFormat, options).formatToParts(date);
|
|
322
|
+
} catch (e) {
|
|
323
|
+
config.onError(new IntlFormatError("Error formatting time.", config.locale, e));
|
|
324
|
+
}
|
|
325
|
+
return [];
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region packages/intl/displayName.ts
|
|
329
|
+
const DISPLAY_NAMES_OPTONS = [
|
|
330
|
+
"style",
|
|
331
|
+
"type",
|
|
332
|
+
"fallback",
|
|
333
|
+
"languageDisplay"
|
|
334
|
+
];
|
|
335
|
+
function formatDisplayName({ locale, onError }, getDisplayNames, value, options) {
|
|
336
|
+
if (!Intl.DisplayNames) onError(new FormatError(`Intl.DisplayNames is not available in this environment.
|
|
337
|
+
Try polyfilling it using "@formatjs/intl-displaynames"
|
|
338
|
+
`, ErrorCode.MISSING_INTL_API));
|
|
339
|
+
const filteredOptions = filterProps(options, DISPLAY_NAMES_OPTONS);
|
|
340
|
+
try {
|
|
341
|
+
return getDisplayNames(locale, filteredOptions).of(value);
|
|
342
|
+
} catch (e) {
|
|
343
|
+
onError(new IntlFormatError("Error formatting display name.", locale, e));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region packages/intl/list.ts
|
|
348
|
+
const LIST_FORMAT_OPTIONS = ["type", "style"];
|
|
349
|
+
const now = Date.now();
|
|
350
|
+
function generateToken(i) {
|
|
351
|
+
return `${now}_${i}_${now}`;
|
|
352
|
+
}
|
|
353
|
+
function formatList(opts, getListFormat, values, options = {}) {
|
|
354
|
+
const results = formatListToParts(opts, getListFormat, values, options).reduce((all, el) => {
|
|
355
|
+
const val = el.value;
|
|
356
|
+
if (typeof val !== "string") all.push(val);
|
|
357
|
+
else if (typeof all[all.length - 1] === "string") all[all.length - 1] += val;
|
|
358
|
+
else all.push(val);
|
|
359
|
+
return all;
|
|
360
|
+
}, []);
|
|
361
|
+
return results.length === 1 ? results[0] : results.length === 0 ? "" : results;
|
|
362
|
+
}
|
|
363
|
+
function formatListToParts({ locale, onError }, getListFormat, values, options = {}) {
|
|
364
|
+
if (!Intl.ListFormat) onError(new FormatError(`Intl.ListFormat is not available in this environment.
|
|
365
|
+
Try polyfilling it using "@formatjs/intl-listformat"
|
|
366
|
+
`, ErrorCode.MISSING_INTL_API));
|
|
367
|
+
const filteredOptions = filterProps(options, LIST_FORMAT_OPTIONS);
|
|
368
|
+
try {
|
|
369
|
+
const richValues = {};
|
|
370
|
+
const serializedValues = Array.from(values).map((v, i) => {
|
|
371
|
+
if (typeof v === "object" && v !== null) {
|
|
372
|
+
const id = generateToken(i);
|
|
373
|
+
richValues[id] = v;
|
|
374
|
+
return id;
|
|
375
|
+
}
|
|
376
|
+
return String(v);
|
|
377
|
+
});
|
|
378
|
+
return getListFormat(locale, filteredOptions).formatToParts(serializedValues).map((part) => part.type === "literal" ? part : {
|
|
379
|
+
...part,
|
|
380
|
+
value: richValues[part.value] || part.value
|
|
381
|
+
});
|
|
382
|
+
} catch (e) {
|
|
383
|
+
onError(new IntlFormatError("Error formatting list.", locale, e));
|
|
384
|
+
}
|
|
385
|
+
return values;
|
|
386
|
+
}
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region packages/intl/plural.ts
|
|
389
|
+
const PLURAL_FORMAT_OPTIONS = ["type"];
|
|
390
|
+
function formatPlural({ locale, onError }, getPluralRules, value, options = {}) {
|
|
391
|
+
if (!Intl.PluralRules) onError(new FormatError(`Intl.PluralRules is not available in this environment.
|
|
392
|
+
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
393
|
+
`, ErrorCode.MISSING_INTL_API));
|
|
394
|
+
const filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
|
|
395
|
+
try {
|
|
396
|
+
return getPluralRules(locale, filteredOptions).select(value);
|
|
397
|
+
} catch (e) {
|
|
398
|
+
onError(new IntlFormatError("Error formatting plural.", locale, e));
|
|
399
|
+
}
|
|
400
|
+
return "other";
|
|
401
|
+
}
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region packages/intl/relativeTime.ts
|
|
404
|
+
const RELATIVE_TIME_FORMAT_OPTIONS = ["numeric", "style"];
|
|
405
|
+
function getFormatter$1({ locale, formats, onError }, getRelativeTimeFormat, options = {}) {
|
|
406
|
+
const { format } = options;
|
|
407
|
+
return getRelativeTimeFormat(locale, filterProps(options, RELATIVE_TIME_FORMAT_OPTIONS, !!format && getNamedFormat(formats, "relative", format, onError) || {}));
|
|
408
|
+
}
|
|
409
|
+
function formatRelativeTime(config, getRelativeTimeFormat, value, unit, options = {}) {
|
|
410
|
+
if (!unit) unit = "second";
|
|
411
|
+
if (!Intl.RelativeTimeFormat) config.onError(new FormatError(`Intl.RelativeTimeFormat is not available in this environment.
|
|
412
|
+
Try polyfilling it using "@formatjs/intl-relativetimeformat"
|
|
413
|
+
`, ErrorCode.MISSING_INTL_API));
|
|
414
|
+
try {
|
|
415
|
+
return getFormatter$1(config, getRelativeTimeFormat, options).format(value, unit);
|
|
416
|
+
} catch (e) {
|
|
417
|
+
config.onError(new IntlFormatError("Error formatting relative time.", config.locale, e));
|
|
418
|
+
}
|
|
419
|
+
return String(value);
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region packages/intl/number.ts
|
|
423
|
+
const NUMBER_FORMAT_OPTIONS = [
|
|
424
|
+
"style",
|
|
425
|
+
"currency",
|
|
426
|
+
"unit",
|
|
427
|
+
"unitDisplay",
|
|
428
|
+
"useGrouping",
|
|
429
|
+
"minimumIntegerDigits",
|
|
430
|
+
"minimumFractionDigits",
|
|
431
|
+
"maximumFractionDigits",
|
|
432
|
+
"minimumSignificantDigits",
|
|
433
|
+
"maximumSignificantDigits",
|
|
434
|
+
"compactDisplay",
|
|
435
|
+
"currencyDisplay",
|
|
436
|
+
"currencySign",
|
|
437
|
+
"notation",
|
|
438
|
+
"signDisplay",
|
|
439
|
+
"unit",
|
|
440
|
+
"unitDisplay",
|
|
441
|
+
"numberingSystem",
|
|
442
|
+
"trailingZeroDisplay",
|
|
443
|
+
"roundingPriority",
|
|
444
|
+
"roundingIncrement",
|
|
445
|
+
"roundingMode"
|
|
446
|
+
];
|
|
447
|
+
function getFormatter({ locale, formats, onError }, getNumberFormat, options = {}) {
|
|
448
|
+
const { format } = options;
|
|
449
|
+
return getNumberFormat(locale, filterProps(options, NUMBER_FORMAT_OPTIONS, format && getNamedFormat(formats, "number", format, onError) || {}));
|
|
450
|
+
}
|
|
451
|
+
function formatNumber(config, getNumberFormat, value, options = {}) {
|
|
452
|
+
try {
|
|
453
|
+
return getFormatter(config, getNumberFormat, options).format(value);
|
|
454
|
+
} catch (e) {
|
|
455
|
+
config.onError(new IntlFormatError("Error formatting number.", config.locale, e));
|
|
456
|
+
}
|
|
457
|
+
return String(value);
|
|
458
|
+
}
|
|
459
|
+
function formatNumberToParts(config, getNumberFormat, value, options = {}) {
|
|
460
|
+
try {
|
|
461
|
+
return getFormatter(config, getNumberFormat, options).formatToParts(value);
|
|
462
|
+
} catch (e) {
|
|
463
|
+
config.onError(new IntlFormatError("Error formatting number.", config.locale, e));
|
|
464
|
+
}
|
|
465
|
+
return [];
|
|
466
|
+
}
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region packages/intl/create-intl.ts
|
|
469
|
+
function messagesContainString(messages) {
|
|
470
|
+
return typeof (messages ? messages[Object.keys(messages)[0]] : void 0) === "string";
|
|
471
|
+
}
|
|
472
|
+
function verifyConfigMessages(config) {
|
|
473
|
+
if (config.onWarn && config.defaultRichTextElements && messagesContainString(config.messages || {})) config.onWarn(`[@formatjs/intl] "defaultRichTextElements" was specified but "message" was not pre-compiled.
|
|
474
|
+
Please consider using "@formatjs/cli" to pre-compile your messages for performance.
|
|
475
|
+
For more details see https://formatjs.github.io/docs/getting-started/message-distribution`);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Create intl object
|
|
479
|
+
* @param config intl config
|
|
480
|
+
* @param cache cache for formatter instances to prevent memory leak
|
|
481
|
+
*/
|
|
482
|
+
function createIntl(config, cache) {
|
|
483
|
+
const formatters = createFormatters(cache);
|
|
484
|
+
const resolvedConfig = {
|
|
485
|
+
...DEFAULT_INTL_CONFIG,
|
|
486
|
+
...config
|
|
487
|
+
};
|
|
488
|
+
const { locale, defaultLocale, onError } = resolvedConfig;
|
|
489
|
+
if (!locale) {
|
|
490
|
+
if (onError) onError(new InvalidConfigError(`"locale" was not configured, using "${defaultLocale}" as fallback. See https://formatjs.github.io/docs/react-intl/api#intlshape for more details`));
|
|
491
|
+
resolvedConfig.locale = resolvedConfig.defaultLocale || "en";
|
|
492
|
+
} else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) onError(new MissingDataError(`Missing locale data for locale: "${locale}" in Intl.NumberFormat. Using default locale: "${defaultLocale}" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`));
|
|
493
|
+
else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length && onError) onError(new MissingDataError(`Missing locale data for locale: "${locale}" in Intl.DateTimeFormat. Using default locale: "${defaultLocale}" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`));
|
|
494
|
+
verifyConfigMessages(resolvedConfig);
|
|
495
|
+
return {
|
|
496
|
+
...resolvedConfig,
|
|
497
|
+
formatters,
|
|
498
|
+
formatNumber: formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
499
|
+
formatNumberToParts: formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat),
|
|
500
|
+
formatRelativeTime: formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat),
|
|
501
|
+
formatDate: formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
502
|
+
formatDateToParts: formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
503
|
+
formatTime: formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
504
|
+
formatDateTimeRange: formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
505
|
+
formatTimeToParts: formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat),
|
|
506
|
+
formatPlural: formatPlural.bind(null, resolvedConfig, formatters.getPluralRules),
|
|
507
|
+
formatMessage: formatMessage.bind(null, resolvedConfig, formatters),
|
|
508
|
+
$t: formatMessage.bind(null, resolvedConfig, formatters),
|
|
509
|
+
formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat),
|
|
510
|
+
formatListToParts: formatListToParts.bind(null, resolvedConfig, formatters.getListFormat),
|
|
511
|
+
formatDisplayName: formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames)
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region packages/intl/index.ts
|
|
516
|
+
function defineMessages(msgs) {
|
|
4
517
|
return msgs;
|
|
5
518
|
}
|
|
6
|
-
|
|
519
|
+
function defineMessage(msg) {
|
|
7
520
|
return msg;
|
|
8
521
|
}
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export { formatDisplayName } from "./src/displayName.js";
|
|
14
|
-
export { formatList } from "./src/list.js";
|
|
15
|
-
export { formatPlural } from "./src/plural.js";
|
|
16
|
-
export { formatRelativeTime } from "./src/relativeTime.js";
|
|
17
|
-
export { formatNumber, formatNumberToParts } from "./src/number.js";
|
|
18
|
-
export { createIntl } from "./src/create-intl.js";
|
|
522
|
+
//#endregion
|
|
523
|
+
export { DEFAULT_INTL_CONFIG, IntlError, IntlErrorCode, IntlFormatError, InvalidConfigError, MessageFormatError, MissingDataError, MissingTranslationError, UnsupportedFormatterError, createFormatters, createIntl, createIntlCache, defineMessage, defineMessages, filterProps, formatDate, formatDateToParts, formatDisplayName, formatList, formatMessage, formatNumber, formatNumberToParts, formatPlural, formatRelativeTime, formatTime, formatTimeToParts, getNamedFormat };
|
|
524
|
+
|
|
525
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["getFormatter","getFormatter"],"sources":["../error.ts","../utils.ts","../message.ts","../dateTime.ts","../displayName.ts","../list.ts","../plural.ts","../relativeTime.ts","../number.ts","../create-intl.ts","../index.ts"],"sourcesContent":["import {type MessageDescriptor} from '#packages/intl/types.js'\n\nexport enum IntlErrorCode {\n FORMAT_ERROR = 'FORMAT_ERROR',\n UNSUPPORTED_FORMATTER = 'UNSUPPORTED_FORMATTER',\n INVALID_CONFIG = 'INVALID_CONFIG',\n MISSING_DATA = 'MISSING_DATA',\n MISSING_TRANSLATION = 'MISSING_TRANSLATION',\n}\n\nexport class IntlError<\n T extends IntlErrorCode = IntlErrorCode.FORMAT_ERROR,\n> extends Error {\n public readonly code: T\n\n constructor(code: T, message: string, exception?: Error | unknown) {\n const err = exception\n ? exception instanceof Error\n ? exception\n : new Error(String(exception))\n : undefined\n super(\n `[@formatjs/intl Error ${code}] ${message}\n${err ? `\\n${err.message}\\n${err.stack}` : ''}`\n )\n this.code = code\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (typeof Error.captureStackTrace === 'function') {\n // @ts-ignore just so we don't need to declare dep on @types/node\n Error.captureStackTrace(this, IntlError)\n }\n }\n}\n\nexport class UnsupportedFormatterError extends IntlError<IntlErrorCode.UNSUPPORTED_FORMATTER> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception)\n }\n}\n\nexport class InvalidConfigError extends IntlError<IntlErrorCode.INVALID_CONFIG> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.INVALID_CONFIG, message, exception)\n }\n}\n\nexport class MissingDataError extends IntlError<IntlErrorCode.MISSING_DATA> {\n constructor(message: string, exception?: Error | unknown) {\n super(IntlErrorCode.MISSING_DATA, message, exception)\n }\n}\n\nexport class IntlFormatError extends IntlError<IntlErrorCode.FORMAT_ERROR> {\n public readonly descriptor?: MessageDescriptor\n public readonly locale: string\n constructor(message: string, locale: string, exception?: Error | unknown) {\n super(\n IntlErrorCode.FORMAT_ERROR,\n `${message}\nLocale: ${locale}\n`,\n exception\n )\n this.locale = locale\n }\n}\n\nexport class MessageFormatError extends IntlFormatError {\n public readonly descriptor?: MessageDescriptor\n public readonly locale: string\n constructor(\n message: string,\n locale: string,\n descriptor?: MessageDescriptor,\n exception?: Error | unknown\n ) {\n super(\n `${message}\nMessageID: ${descriptor?.id}\nDefault Message: ${descriptor?.defaultMessage}\nDescription: ${descriptor?.description}\n`,\n locale,\n exception\n )\n this.descriptor = descriptor\n this.locale = locale\n }\n}\n\nexport class MissingTranslationError extends IntlError<IntlErrorCode.MISSING_TRANSLATION> {\n public readonly descriptor?: MessageDescriptor\n constructor(descriptor: MessageDescriptor, locale: string) {\n super(\n IntlErrorCode.MISSING_TRANSLATION,\n `Missing message: \"${descriptor.id}\" for locale \"${locale}\", using ${\n descriptor.defaultMessage\n ? `default message (${\n typeof descriptor.defaultMessage === 'string'\n ? descriptor.defaultMessage\n : descriptor.defaultMessage\n .map((e: any) => e.value ?? JSON.stringify(e))\n .join()\n })`\n : 'id'\n } as fallback.`\n )\n this.descriptor = descriptor\n }\n}\n","import {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {type Cache, memoize, strategies} from '@formatjs/fast-memoize'\nimport {IntlMessageFormat} from 'intl-messageformat'\nimport {UnsupportedFormatterError} from '#packages/intl/error.js'\nimport {\n type CustomFormats,\n type Formatters,\n type IntlCache,\n type OnErrorFn,\n type OnWarnFn,\n type ResolvedIntlConfig,\n} from '#packages/intl/types.js'\n\nexport function invariant(\n condition: boolean,\n message: string,\n Err: any = Error\n): asserts condition {\n if (!condition) {\n throw new Err(message)\n }\n}\n\nexport function filterProps<T extends Record<string, any>, K extends string>(\n props: T,\n allowlist: Array<K>,\n defaults: Partial<T> = {}\n): Pick<T, K> {\n return allowlist.reduce(\n (filtered, name) => {\n if (name in props) {\n filtered[name] = props[name]\n } else if (name in defaults) {\n filtered[name] = defaults[name]!\n }\n\n return filtered\n },\n {} as Pick<T, K>\n )\n}\n\nconst defaultErrorHandler: OnErrorFn = error => {\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (process.env.NODE_ENV !== 'production') {\n console.error(error)\n }\n}\n\nconst defaultWarnHandler: OnWarnFn = (warning: string) => {\n // @ts-ignore just so we don't need to declare dep on @types/node\n if (process.env.NODE_ENV !== 'production') {\n console.warn(warning)\n }\n}\n\nexport const DEFAULT_INTL_CONFIG: Pick<\n ResolvedIntlConfig<any>,\n | 'fallbackOnEmptyString'\n | 'formats'\n | 'messages'\n | 'timeZone'\n | 'defaultLocale'\n | 'defaultFormats'\n | 'onError'\n | 'onWarn'\n> = {\n formats: {},\n messages: {},\n timeZone: undefined,\n\n defaultLocale: 'en',\n defaultFormats: {},\n\n fallbackOnEmptyString: true,\n\n onError: defaultErrorHandler,\n onWarn: defaultWarnHandler,\n}\n\nexport function createIntlCache(): IntlCache {\n return {\n dateTime: {},\n number: {},\n message: {},\n relativeTime: {},\n pluralRules: {},\n list: {},\n displayNames: {},\n }\n}\n\nfunction createFastMemoizeCache<V>(\n store: Record<string, V | undefined>\n): Cache<string, V> {\n return {\n create() {\n return {\n get(key) {\n return store[key]\n },\n set(key, value) {\n store[key] = value\n },\n }\n },\n }\n}\n\n/**\n * Create intl formatters and populate cache\n * @param cache explicit cache to prevent leaking memory\n */\nexport function createFormatters(\n cache: IntlCache = createIntlCache()\n): Formatters {\n const RelativeTimeFormat = (Intl as any).RelativeTimeFormat\n const ListFormat = (Intl as any).ListFormat\n const DisplayNames = (Intl as any).DisplayNames\n const getDateTimeFormat = memoize(\n (...args) => new Intl.DateTimeFormat(...args),\n {\n cache: createFastMemoizeCache(cache.dateTime),\n strategy: strategies.variadic,\n }\n )\n const getNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), {\n cache: createFastMemoizeCache(cache.number),\n strategy: strategies.variadic,\n })\n const getPluralRules = memoize((...args) => new Intl.PluralRules(...args), {\n cache: createFastMemoizeCache(cache.pluralRules),\n strategy: strategies.variadic,\n })\n return {\n getDateTimeFormat,\n getNumberFormat,\n getMessageFormat: memoize(\n (message, locales, overrideFormats, opts) =>\n new IntlMessageFormat(message, locales, overrideFormats, {\n formatters: {\n getNumberFormat,\n getDateTimeFormat,\n getPluralRules,\n },\n ...opts,\n }),\n {\n cache: createFastMemoizeCache(cache.message),\n strategy: strategies.variadic,\n }\n ),\n getRelativeTimeFormat: memoize(\n (...args) => new RelativeTimeFormat(...args),\n {\n cache: createFastMemoizeCache(cache.relativeTime),\n strategy: strategies.variadic,\n }\n ),\n getPluralRules,\n getListFormat: memoize((...args) => new ListFormat(...args), {\n cache: createFastMemoizeCache(cache.list),\n strategy: strategies.variadic,\n }),\n getDisplayNames: memoize((...args) => new DisplayNames(...args), {\n cache: createFastMemoizeCache(cache.displayNames),\n strategy: strategies.variadic,\n }),\n }\n}\n\nexport function getNamedFormat<T extends keyof CustomFormats>(\n formats: CustomFormats,\n type: T,\n name: string,\n onError: OnErrorFn\n):\n | NumberFormatOptions\n | Intl.DateTimeFormatOptions\n | Intl.RelativeTimeFormatOptions\n | undefined {\n const formatType = formats && formats[type]\n let format\n if (formatType) {\n format = formatType[name]\n }\n if (format) {\n return format\n }\n\n onError(new UnsupportedFormatterError(`No ${type} format named: ${name}`))\n}\n","import {\n type CustomFormats,\n type Formatters,\n type MessageDescriptor,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {\n type MessageFormatElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser'\nimport {\n type FormatXMLElementFn,\n IntlMessageFormat,\n type Formatters as IntlMessageFormatFormatters,\n type Options,\n type PrimitiveType,\n} from 'intl-messageformat'\nimport {\n MessageFormatError,\n MissingTranslationError,\n} from '#packages/intl/error.js'\nimport {invariant} from '#packages/intl/utils.js'\n\nfunction setTimeZoneInOptions(\n opts: Record<string, Intl.DateTimeFormatOptions>,\n timeZone: string\n): Record<string, Intl.DateTimeFormatOptions> {\n return Object.keys(opts).reduce(\n (all: Record<string, Intl.DateTimeFormatOptions>, k) => {\n all[k] = {\n timeZone,\n ...opts[k],\n }\n return all\n },\n {}\n )\n}\n\nfunction deepMergeOptions(\n opts1: Record<string, Intl.DateTimeFormatOptions>,\n opts2: Record<string, Intl.DateTimeFormatOptions>\n): Record<string, Intl.DateTimeFormatOptions> {\n const keys = Object.keys({...opts1, ...opts2})\n return keys.reduce((all: Record<string, Intl.DateTimeFormatOptions>, k) => {\n all[k] = {\n ...opts1[k],\n ...opts2[k],\n }\n return all\n }, {})\n}\n\nfunction deepMergeFormatsAndSetTimeZone(\n f1: CustomFormats,\n timeZone?: string\n): CustomFormats {\n if (!timeZone) {\n return f1\n }\n const mfFormats = IntlMessageFormat.formats\n return {\n ...mfFormats,\n ...f1,\n date: deepMergeOptions(\n setTimeZoneInOptions(mfFormats.date, timeZone),\n setTimeZoneInOptions(f1.date || {}, timeZone)\n ),\n time: deepMergeOptions(\n setTimeZoneInOptions(mfFormats.time, timeZone),\n setTimeZoneInOptions(f1.time || {}, timeZone)\n ),\n }\n}\n\nexport type FormatMessageFn<T> = (\n {\n locale,\n formats,\n messages,\n defaultLocale,\n defaultFormats,\n fallbackOnEmptyString,\n onError,\n timeZone,\n defaultRichTextElements,\n }: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n messages: Record<string, string> | Record<string, MessageFormatElement[]>\n defaultLocale: string\n defaultFormats: CustomFormats\n defaultRichTextElements?: Record<string, FormatXMLElementFn<T>>\n fallbackOnEmptyString?: boolean\n onError: OnErrorFn\n },\n state: IntlMessageFormatFormatters & Pick<Formatters, 'getMessageFormat'>,\n messageDescriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>,\n opts?: Options\n) => T extends string ? string : Array<T | string> | string | T\n\nexport const formatMessage: FormatMessageFn<any> = (\n {\n locale,\n formats,\n messages,\n defaultLocale,\n defaultFormats,\n fallbackOnEmptyString,\n onError,\n timeZone,\n defaultRichTextElements,\n },\n state,\n messageDescriptor = {id: ''},\n values,\n opts\n) => {\n const {id: msgId, defaultMessage} = messageDescriptor\n\n // `id` is a required field of a Message Descriptor.\n invariant(\n !!msgId,\n `[@formatjs/intl] An \\`id\\` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.github.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.github.io/docs/tooling/ts-transformer) OR\n2. Configure your \\`eslint\\` config to include [eslint-plugin-formatjs](https://formatjs.github.io/docs/tooling/linter#enforce-id)\nto autofix this issue`\n )\n const id = String(msgId)\n const message =\n // In case messages is Object.create(null)\n // e.g import('foo.json') from webpack)\n // See https://github.com/formatjs/formatjs/issues/1914\n messages &&\n Object.prototype.hasOwnProperty.call(messages, id) &&\n messages[id]\n\n // IMPORTANT: Hot path if `message` is AST with a single literal node\n if (\n Array.isArray(message) &&\n message.length === 1 &&\n message[0].type === TYPE.literal\n ) {\n return message[0].value\n }\n\n values = {\n ...defaultRichTextElements,\n ...values,\n }\n formats = deepMergeFormatsAndSetTimeZone(formats, timeZone)\n defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone)\n\n if (!message) {\n if (fallbackOnEmptyString === false && message === '') {\n return message\n }\n\n if (\n !defaultMessage ||\n (locale && locale.toLowerCase() !== defaultLocale.toLowerCase())\n ) {\n // This prevents warnings from littering the console in development\n // when no `messages` are passed into the <IntlProvider> for the\n // default locale.\n onError(new MissingTranslationError(messageDescriptor, locale))\n }\n if (defaultMessage) {\n try {\n const formatter = state.getMessageFormat(\n defaultMessage,\n defaultLocale,\n defaultFormats,\n opts\n )\n\n return formatter.format(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting default message for: \"${id}\", rendering default message verbatim`,\n locale,\n messageDescriptor,\n e\n )\n )\n return typeof defaultMessage === 'string' ? defaultMessage : id\n }\n }\n return id\n }\n\n // We have the translated message\n try {\n const formatter = state.getMessageFormat(message, locale, formats, {\n formatters: state,\n ...opts,\n })\n\n return formatter.format<any>(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting message: \"${id}\", using ${\n defaultMessage ? 'default message' : 'id'\n } as fallback.`,\n locale,\n messageDescriptor,\n e\n )\n )\n }\n\n if (defaultMessage) {\n try {\n const formatter = state.getMessageFormat(\n defaultMessage,\n defaultLocale,\n defaultFormats,\n opts\n )\n\n return formatter.format(values)\n } catch (e) {\n onError(\n new MessageFormatError(\n `Error formatting the default message for: \"${id}\", rendering message verbatim`,\n locale,\n messageDescriptor,\n e\n )\n )\n }\n }\n\n if (typeof message === 'string') {\n return message\n }\n if (typeof defaultMessage === 'string') {\n return defaultMessage\n }\n return id\n}\n","import {\n type CustomFormats,\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {filterProps, getNamedFormat} from '#packages/intl/utils.js'\n\nconst DATE_TIME_FORMAT_OPTIONS: Array<keyof Intl.DateTimeFormatOptions> = [\n 'formatMatcher',\n\n 'timeZone',\n 'hour12',\n\n 'weekday',\n 'era',\n 'year',\n 'month',\n 'day',\n 'hour',\n 'minute',\n 'second',\n 'timeZoneName',\n 'hourCycle',\n 'dateStyle',\n 'timeStyle',\n 'calendar',\n // 'dayPeriod',\n 'numberingSystem',\n 'fractionalSecondDigits',\n]\n\nexport function getFormatter(\n {\n locale,\n formats,\n onError,\n timeZone,\n }: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n type: 'date' | 'time' | 'dateTimeRange',\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): Intl.DateTimeFormat {\n const {format} = options\n const defaults = {\n ...(timeZone && {timeZone}),\n ...(format && getNamedFormat(formats!, type, format, onError)),\n }\n\n let filteredOptions = filterProps(\n options,\n DATE_TIME_FORMAT_OPTIONS,\n defaults\n ) as Intl.DateTimeFormatOptions\n\n if (\n type === 'time' &&\n !filteredOptions.hour &&\n !filteredOptions.minute &&\n !filteredOptions.second &&\n !filteredOptions.timeStyle &&\n !filteredOptions.dateStyle\n ) {\n // Add default formatting options if hour, minute, or second isn't defined.\n filteredOptions = {...filteredOptions, hour: 'numeric', minute: 'numeric'}\n }\n\n return getDateTimeFormat(locale, filteredOptions)\n}\n\nexport function formatDate(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatDate']>[0],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): string {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n try {\n return getFormatter(config, 'date', getDateTimeFormat, options).format(date)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date.', config.locale, e)\n )\n }\n\n return String(date)\n}\n\nexport function formatTime(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatTime']>[0],\n options: Parameters<IntlFormatters['formatTime']>[1] = {}\n): string {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n\n try {\n return getFormatter(config, 'time', getDateTimeFormat, options).format(date)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting time.', config.locale, e)\n )\n }\n\n return String(date)\n}\n\nexport function formatDateTimeRange(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n from: Parameters<IntlFormatters['formatDateTimeRange']>[0],\n to: Parameters<IntlFormatters['formatDateTimeRange']>[1],\n options: Parameters<IntlFormatters['formatDateTimeRange']>[2] = {}\n): string {\n const fromDate = typeof from === 'string' ? new Date(from || 0) : from\n const toDate = typeof to === 'string' ? new Date(to || 0) : to\n\n try {\n return getFormatter(\n config,\n 'dateTimeRange',\n getDateTimeFormat,\n options\n ).formatRange(fromDate, toDate)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date time range.', config.locale, e)\n )\n }\n\n return String(fromDate)\n}\n\nexport function formatDateToParts(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatDate']>[0],\n options: Parameters<IntlFormatters['formatDate']>[1] = {}\n): Intl.DateTimeFormatPart[] {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n try {\n return getFormatter(\n config,\n 'date',\n getDateTimeFormat,\n options\n ).formatToParts(date) as Intl.DateTimeFormatPart[] // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting date.', config.locale, e)\n )\n }\n\n return []\n}\n\nexport function formatTimeToParts(\n config: {\n locale: string\n timeZone?: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getDateTimeFormat: Formatters['getDateTimeFormat'],\n value: Parameters<IntlFormatters['formatTimeToParts']>[0],\n options: Parameters<IntlFormatters['formatTimeToParts']>[1] = {}\n): Intl.DateTimeFormatPart[] {\n const date = typeof value === 'string' ? new Date(value || 0) : value\n\n try {\n return getFormatter(\n config,\n 'time',\n getDateTimeFormat,\n options\n ).formatToParts(date) as Intl.DateTimeFormatPart[] // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting time.', config.locale, e)\n )\n }\n\n return []\n}\n","import {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nimport {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\n\nconst DISPLAY_NAMES_OPTONS: Array<keyof Intl.DisplayNamesOptions> = [\n 'style',\n 'type',\n 'fallback',\n 'languageDisplay',\n]\n\nexport function formatDisplayName(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getDisplayNames: Formatters['getDisplayNames'],\n value: Parameters<IntlFormatters['formatDisplayName']>[0],\n options: Parameters<IntlFormatters['formatDisplayName']>[1]\n): string | undefined {\n const DisplayNames: typeof Intl.DisplayNames = (Intl as any).DisplayNames\n if (!DisplayNames) {\n onError(\n new FormatError(\n `Intl.DisplayNames is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-displaynames\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n DISPLAY_NAMES_OPTONS\n ) as Intl.DisplayNamesOptions\n try {\n return getDisplayNames(locale, filteredOptions).of(value)\n } catch (e) {\n onError(new IntlFormatError('Error formatting display name.', locale, e))\n }\n}\n","import {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n type Part,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nconst LIST_FORMAT_OPTIONS: Array<keyof Intl.ListFormatOptions> = [\n 'type',\n 'style',\n]\n\nconst now = Date.now()\n\nfunction generateToken(i: number): string {\n return `${now}_${i}_${now}`\n}\n\nexport function formatList(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string>,\n options: Parameters<IntlFormatters['formatList']>[1]\n): string\nexport function formatList<T>(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string | T>,\n options: Parameters<IntlFormatters['formatList']>[1] = {}\n): Array<T | string> | T | string {\n const results = formatListToParts(\n opts,\n getListFormat,\n values,\n options\n ).reduce((all: Array<string | T>, el) => {\n const val = el.value\n if (typeof val !== 'string') {\n all.push(val)\n } else if (typeof all[all.length - 1] === 'string') {\n all[all.length - 1] += val\n } else {\n all.push(val)\n }\n return all\n }, [])\n return results.length === 1 ? results[0] : results.length === 0 ? '' : results\n}\n\nexport function formatListToParts<T>(\n opts: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Iterable<string | T>,\n options: Parameters<IntlFormatters['formatList']>[1]\n): Part[]\nexport function formatListToParts<T>(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getListFormat: Formatters['getListFormat'],\n values: Parameters<IntlFormatters['formatList']>[0],\n options: Parameters<IntlFormatters['formatList']>[1] = {}\n): Part<T>[] {\n const ListFormat: typeof Intl.ListFormat = Intl.ListFormat\n if (!ListFormat) {\n onError(\n new FormatError(\n `Intl.ListFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-listformat\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n LIST_FORMAT_OPTIONS\n ) as Intl.ListFormatOptions\n\n try {\n const richValues: Record<string, T> = {}\n const serializedValues = Array.from(values).map((v, i) => {\n if (typeof v === 'object' && v !== null) {\n const id = generateToken(i)\n richValues[id] = v as any\n return id\n }\n return String(v)\n })\n return getListFormat(locale, filteredOptions)\n .formatToParts(serializedValues)\n .map(\n part =>\n (part.type === 'literal'\n ? part\n : {...part, value: richValues[part.value] || part.value}) as Part<T>\n )\n } catch (e) {\n onError(new IntlFormatError('Error formatting list.', locale, e))\n }\n\n // @ts-ignore\n return values\n}\n","import {ErrorCode, FormatError} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps} from '#packages/intl/utils.js'\n\nconst PLURAL_FORMAT_OPTIONS: Array<keyof Intl.PluralRulesOptions> = ['type']\n\nexport function formatPlural(\n {\n locale,\n onError,\n }: {\n locale: string\n onError: OnErrorFn\n },\n getPluralRules: Formatters['getPluralRules'],\n value: Parameters<IntlFormatters['formatPlural']>[0],\n options: Parameters<IntlFormatters['formatPlural']>[1] = {}\n): Intl.LDMLPluralRule {\n if (!Intl.PluralRules) {\n onError(\n new FormatError(\n `Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n const filteredOptions = filterProps(\n options,\n PLURAL_FORMAT_OPTIONS\n ) as Intl.PluralRulesOptions\n\n try {\n return getPluralRules(locale, filteredOptions).select(\n value\n ) as Intl.LDMLPluralRule\n } catch (e) {\n onError(new IntlFormatError('Error formatting plural.', locale, e))\n }\n\n return 'other'\n}\n","import {\n type IntlFormatters,\n type Formatters,\n type CustomFormats,\n type OnErrorFn,\n} from '#packages/intl/types.js'\n\nimport {getNamedFormat, filterProps} from '#packages/intl/utils.js'\nimport {FormatError, ErrorCode} from 'intl-messageformat'\nimport {IntlFormatError} from '#packages/intl/error.js'\n\nconst RELATIVE_TIME_FORMAT_OPTIONS: Array<\n keyof Intl.RelativeTimeFormatOptions\n> = ['numeric', 'style']\n\nfunction getFormatter(\n {\n locale,\n formats,\n onError,\n }: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getRelativeTimeFormat: Formatters['getRelativeTimeFormat'],\n options: Parameters<IntlFormatters['formatRelativeTime']>[2] = {}\n): Intl.RelativeTimeFormat {\n const {format} = options\n\n const defaults =\n (!!format && getNamedFormat(formats, 'relative', format, onError)) || {}\n const filteredOptions = filterProps(\n options,\n RELATIVE_TIME_FORMAT_OPTIONS,\n defaults as Intl.RelativeTimeFormatOptions\n ) as Intl.RelativeTimeFormatOptions\n\n return getRelativeTimeFormat(locale, filteredOptions)\n}\n\nexport function formatRelativeTime(\n config: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getRelativeTimeFormat: Formatters['getRelativeTimeFormat'],\n value: Parameters<IntlFormatters['formatRelativeTime']>[0],\n unit?: Parameters<IntlFormatters['formatRelativeTime']>[1],\n options: Parameters<IntlFormatters['formatRelativeTime']>[2] = {}\n): string {\n if (!unit) {\n unit = 'second'\n }\n const RelativeTimeFormat = Intl.RelativeTimeFormat\n if (!RelativeTimeFormat) {\n config.onError(\n new FormatError(\n `Intl.RelativeTimeFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-relativetimeformat\"\n`,\n ErrorCode.MISSING_INTL_API\n )\n )\n }\n try {\n return getFormatter(config, getRelativeTimeFormat, options).format(\n value,\n unit\n )\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting relative time.', config.locale, e)\n )\n }\n\n return String(value)\n}\n","import {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {IntlFormatError} from '#packages/intl/error.js'\nimport {\n type CustomFormats,\n type Formatters,\n type IntlFormatters,\n type OnErrorFn,\n} from '#packages/intl/types.js'\nimport {filterProps, getNamedFormat} from '#packages/intl/utils.js'\n\nconst NUMBER_FORMAT_OPTIONS: Array<keyof NumberFormatOptions> = [\n 'style',\n 'currency',\n 'unit',\n 'unitDisplay',\n 'useGrouping',\n\n 'minimumIntegerDigits',\n 'minimumFractionDigits',\n 'maximumFractionDigits',\n 'minimumSignificantDigits',\n 'maximumSignificantDigits',\n\n // ES2020 NumberFormat\n 'compactDisplay',\n 'currencyDisplay',\n 'currencySign',\n 'notation',\n 'signDisplay',\n 'unit',\n 'unitDisplay',\n 'numberingSystem',\n\n // ES2023 NumberFormat\n 'trailingZeroDisplay',\n 'roundingPriority',\n 'roundingIncrement',\n 'roundingMode',\n]\n\nexport function getFormatter(\n {\n locale,\n formats,\n onError,\n }: {\n locale: string\n\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): Intl.NumberFormat {\n const {format} = options\n const defaults = ((format &&\n getNamedFormat(formats!, 'number', format, onError)) ||\n {}) as NumberFormatOptions\n const filteredOptions = filterProps(\n options,\n NUMBER_FORMAT_OPTIONS,\n defaults\n ) as NumberFormatOptions\n\n return getNumberFormat(locale, filteredOptions)\n}\n\nexport function formatNumber(\n config: {\n locale: string\n\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n value: Parameters<IntlFormatters['formatNumber']>[0],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): string {\n try {\n return getFormatter(config, getNumberFormat, options).format(value)\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting number.', config.locale, e)\n )\n }\n\n return String(value)\n}\n\nexport function formatNumberToParts(\n config: {\n locale: string\n formats: CustomFormats\n onError: OnErrorFn\n },\n getNumberFormat: Formatters['getNumberFormat'],\n value: Parameters<IntlFormatters['formatNumber']>[0],\n options: Parameters<IntlFormatters['formatNumber']>[1] = {}\n): Intl.NumberFormatPart[] {\n try {\n return getFormatter(config, getNumberFormat, options).formatToParts(\n value as number\n )\n } catch (e) {\n config.onError(\n new IntlFormatError('Error formatting number.', config.locale, e)\n )\n }\n\n return []\n}\n","import {type MessageFormatElement} from '@formatjs/icu-messageformat-parser'\nimport {\n formatDate,\n formatDateTimeRange,\n formatDateToParts,\n formatTime,\n formatTimeToParts,\n} from '#packages/intl/dateTime.js'\nimport {formatDisplayName} from '#packages/intl/displayName.js'\nimport {InvalidConfigError, MissingDataError} from '#packages/intl/error.js'\nimport {formatList, formatListToParts} from '#packages/intl/list.js'\nimport {formatMessage} from '#packages/intl/message.js'\nimport {formatNumber, formatNumberToParts} from '#packages/intl/number.js'\nimport {formatPlural} from '#packages/intl/plural.js'\nimport {formatRelativeTime} from '#packages/intl/relativeTime.js'\nimport {\n type IntlCache,\n type IntlConfig,\n type IntlShape,\n type ResolvedIntlConfig,\n} from '#packages/intl/types.js'\nimport {createFormatters, DEFAULT_INTL_CONFIG} from '#packages/intl/utils.js'\n\nexport interface CreateIntlFn<\n T = string,\n C extends IntlConfig<T> = IntlConfig<T>,\n S extends IntlShape<T> = IntlShape<T>,\n> {\n (config: C, cache?: IntlCache): S\n}\n\nfunction messagesContainString(\n messages: Record<string, string> | Record<string, MessageFormatElement[]>\n): messages is Record<string, MessageFormatElement[]> {\n const firstMessage = messages ? messages[Object.keys(messages)[0]] : undefined\n\n return typeof firstMessage === 'string'\n}\n\nfunction verifyConfigMessages<T = string>(config: IntlConfig<T>) {\n if (\n config.onWarn &&\n config.defaultRichTextElements &&\n messagesContainString(config.messages || {})\n ) {\n config.onWarn(`[@formatjs/intl] \"defaultRichTextElements\" was specified but \"message\" was not pre-compiled. \nPlease consider using \"@formatjs/cli\" to pre-compile your messages for performance.\nFor more details see https://formatjs.github.io/docs/getting-started/message-distribution`)\n }\n}\n\n/**\n * Create intl object\n * @param config intl config\n * @param cache cache for formatter instances to prevent memory leak\n */\nexport function createIntl<T = string>(\n config: IntlConfig<T>,\n cache?: IntlCache\n): IntlShape<T> {\n const formatters = createFormatters(cache)\n const resolvedConfig: ResolvedIntlConfig<T> = {\n ...DEFAULT_INTL_CONFIG,\n ...config,\n }\n\n const {locale, defaultLocale, onError} = resolvedConfig\n if (!locale) {\n if (onError) {\n onError(\n new InvalidConfigError(\n `\"locale\" was not configured, using \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl/api#intlshape for more details`\n )\n )\n }\n // Since there's no registered locale data for `locale`, this will\n // fallback to the `defaultLocale` to make sure things can render.\n // The `messages` are overridden to the `defaultProps` empty object\n // to maintain referential equality across re-renders. It's assumed\n // each <FormattedMessage> contains a `defaultMessage` prop.\n resolvedConfig.locale = resolvedConfig.defaultLocale || 'en'\n } else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {\n onError(\n new MissingDataError(\n `Missing locale data for locale: \"${locale}\" in Intl.NumberFormat. Using default locale: \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`\n )\n )\n } else if (\n !Intl.DateTimeFormat.supportedLocalesOf(locale).length &&\n onError\n ) {\n onError(\n new MissingDataError(\n `Missing locale data for locale: \"${locale}\" in Intl.DateTimeFormat. Using default locale: \"${defaultLocale}\" as fallback. See https://formatjs.github.io/docs/react-intl#runtime-requirements for more details`\n )\n )\n }\n\n verifyConfigMessages(resolvedConfig)\n return {\n ...resolvedConfig,\n formatters,\n formatNumber: formatNumber.bind(\n null,\n resolvedConfig,\n formatters.getNumberFormat\n ),\n formatNumberToParts: formatNumberToParts.bind(\n null,\n resolvedConfig,\n formatters.getNumberFormat\n ),\n formatRelativeTime: formatRelativeTime.bind(\n null,\n resolvedConfig,\n formatters.getRelativeTimeFormat\n ),\n formatDate: formatDate.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatDateToParts: formatDateToParts.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatTime: formatTime.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatDateTimeRange: formatDateTimeRange.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatTimeToParts: formatTimeToParts.bind(\n null,\n resolvedConfig,\n formatters.getDateTimeFormat\n ),\n formatPlural: formatPlural.bind(\n null,\n resolvedConfig,\n formatters.getPluralRules\n ),\n formatMessage: formatMessage.bind(null, resolvedConfig, formatters),\n $t: formatMessage.bind(null, resolvedConfig, formatters),\n formatList: formatList.bind(null, resolvedConfig, formatters.getListFormat),\n formatListToParts: formatListToParts.bind(\n null,\n resolvedConfig,\n formatters.getListFormat\n ),\n formatDisplayName: formatDisplayName.bind(\n null,\n resolvedConfig,\n formatters.getDisplayNames\n ),\n }\n}\n","import {type MessageDescriptor} from '#packages/intl/types.js'\nexport * from '#packages/intl/types.js'\n\nexport function defineMessages<\n K extends keyof any,\n T = MessageDescriptor,\n U extends Record<K, T> = Record<K, T>,\n>(msgs: U): U {\n return msgs\n}\n\nexport function defineMessage<T>(msg: T): T {\n return msg\n}\n\nexport {\n createIntlCache,\n filterProps,\n DEFAULT_INTL_CONFIG,\n createFormatters,\n getNamedFormat,\n} from '#packages/intl/utils.js'\nexport * from '#packages/intl/error.js'\nexport {formatMessage} from '#packages/intl/message.js'\nexport type {FormatMessageFn} from '#packages/intl/message.js'\nexport {\n formatDate,\n formatDateToParts,\n formatTime,\n formatTimeToParts,\n} from '#packages/intl/dateTime.js'\nexport {formatDisplayName} from '#packages/intl/displayName.js'\nexport {formatList} from '#packages/intl/list.js'\nexport {formatPlural} from '#packages/intl/plural.js'\nexport {formatRelativeTime} from '#packages/intl/relativeTime.js'\nexport {formatNumber, formatNumberToParts} from '#packages/intl/number.js'\nexport {createIntl} from '#packages/intl/create-intl.js'\nexport type {CreateIntlFn} from '#packages/intl/create-intl.js'\n"],"mappings":";;;;AAEA,IAAY,gBAAL,yBAAA,eAAA;AACL,eAAA,kBAAA;AACA,eAAA,2BAAA;AACA,eAAA,oBAAA;AACA,eAAA,kBAAA;AACA,eAAA,yBAAA;;KACD;AAED,IAAa,YAAb,MAAa,kBAEH,MAAM;CAGd,YAAY,MAAS,SAAiB,WAA6B;EACjE,MAAM,MAAM,YACR,qBAAqB,QACnB,YACA,IAAI,MAAM,OAAO,UAAU,CAAC,GAC9B,KAAA;AACJ,QACE,yBAAyB,KAAK,IAAI,QAAQ;EAC9C,MAAM,KAAK,IAAI,QAAQ,IAAI,IAAI,UAAU,KACtC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