intl-messageformat 11.2.0 → 11.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,6 +1,144 @@
1
- import { IntlMessageFormat } from "./src/core.js";
2
- export * from "./src/core.js";
3
- export * from "./src/error.js";
4
- export * from "./src/formatters.js";
5
- export { IntlMessageFormat };
6
- export default IntlMessageFormat;
1
+ import { MessageFormatElement, ParserOptions, parse } from "@formatjs/icu-messageformat-parser";
2
+
3
+ //#region packages/ecma402-abstract/types/number.d.ts
4
+ type NumberFormatNotation = "standard" | "scientific" | "engineering" | "compact";
5
+ type RoundingPriorityType = "auto" | "morePrecision" | "lessPrecision";
6
+ type RoundingModeType = "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven";
7
+ type UseGroupingType = "min2" | "auto" | "always" | boolean;
8
+ interface NumberFormatDigitOptions {
9
+ minimumIntegerDigits?: number;
10
+ minimumSignificantDigits?: number;
11
+ maximumSignificantDigits?: number;
12
+ minimumFractionDigits?: number;
13
+ maximumFractionDigits?: number;
14
+ roundingPriority?: RoundingPriorityType;
15
+ roundingIncrement?: number;
16
+ roundingMode?: RoundingModeType;
17
+ trailingZeroDisplay?: TrailingZeroDisplay;
18
+ }
19
+ type NumberFormatOptionsLocaleMatcher = "lookup" | "best fit";
20
+ type NumberFormatOptionsStyle = "decimal" | "percent" | "currency" | "unit";
21
+ type NumberFormatOptionsCompactDisplay = "short" | "long";
22
+ type NumberFormatOptionsCurrencyDisplay = "symbol" | "code" | "name" | "narrowSymbol";
23
+ type NumberFormatOptionsCurrencySign = "standard" | "accounting";
24
+ type NumberFormatOptionsNotation = NumberFormatNotation;
25
+ type NumberFormatOptionsSignDisplay = "auto" | "always" | "never" | "exceptZero" | "negative";
26
+ type NumberFormatOptionsUnitDisplay = "long" | "short" | "narrow";
27
+ type TrailingZeroDisplay = "auto" | "stripIfInteger";
28
+ type NumberFormatOptions = Omit<Intl.NumberFormatOptions, "signDisplay" | "useGrouping"> & NumberFormatDigitOptions & {
29
+ localeMatcher?: NumberFormatOptionsLocaleMatcher;
30
+ style?: NumberFormatOptionsStyle;
31
+ compactDisplay?: NumberFormatOptionsCompactDisplay;
32
+ currencyDisplay?: NumberFormatOptionsCurrencyDisplay;
33
+ currencySign?: NumberFormatOptionsCurrencySign;
34
+ notation?: NumberFormatOptionsNotation;
35
+ signDisplay?: NumberFormatOptionsSignDisplay;
36
+ unit?: string;
37
+ unitDisplay?: NumberFormatOptionsUnitDisplay;
38
+ numberingSystem?: string;
39
+ trailingZeroDisplay?: TrailingZeroDisplay;
40
+ roundingPriority?: RoundingPriorityType;
41
+ roundingIncrement?: number;
42
+ roundingMode?: RoundingModeType;
43
+ useGrouping?: UseGroupingType;
44
+ };
45
+ //#endregion
46
+ //#region packages/intl-messageformat/formatters.d.ts
47
+ declare global {
48
+ namespace FormatjsIntl {
49
+ interface Message {}
50
+ interface IntlConfig {}
51
+ interface Formats {}
52
+ }
53
+ }
54
+ type Format<Source = string> = Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
55
+ interface Formats {
56
+ number: Record<Format<"number">, NumberFormatOptions>;
57
+ date: Record<Format<"date">, Intl.DateTimeFormatOptions>;
58
+ time: Record<Format<"time">, Intl.DateTimeFormatOptions>;
59
+ }
60
+ interface FormatterCache {
61
+ number: Record<string, NumberFormatOptions>;
62
+ dateTime: Record<string, Intl.DateTimeFormat>;
63
+ pluralRules: Record<string, Intl.PluralRules>;
64
+ }
65
+ interface Formatters {
66
+ getNumberFormat(locals?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
67
+ getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
68
+ getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
69
+ }
70
+ declare enum PART_TYPE {
71
+ literal = 0,
72
+ object = 1
73
+ }
74
+ interface LiteralPart {
75
+ type: PART_TYPE.literal;
76
+ value: string;
77
+ }
78
+ interface ObjectPart<T = any> {
79
+ type: PART_TYPE.object;
80
+ value: T;
81
+ }
82
+ type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
83
+ type PrimitiveType = string | number | bigint | boolean | null | undefined | Date;
84
+ declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
85
+ declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
86
+ type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
87
+ //#endregion
88
+ //#region packages/intl-messageformat/core.d.ts
89
+ interface Options extends Omit<ParserOptions, "locale"> {
90
+ formatters?: Formatters;
91
+ }
92
+ declare class IntlMessageFormat {
93
+ private readonly ast;
94
+ private readonly locales;
95
+ private readonly resolvedLocale?;
96
+ private readonly formatters;
97
+ private readonly formats;
98
+ private readonly message;
99
+ private readonly formatterCache;
100
+ constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
101
+ format: <T = void>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => string | T | (string | T)[];
102
+ formatToParts: <T>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>) => MessageFormatPart<T>[];
103
+ resolvedOptions: () => {
104
+ locale: string;
105
+ };
106
+ getAst: () => MessageFormatElement[];
107
+ private static memoizedDefaultLocale;
108
+ static get defaultLocale(): string;
109
+ static resolveLocale: (locales: string | string[]) => Intl.Locale | undefined;
110
+ static __parse: typeof parse | undefined;
111
+ static formats: Formats;
112
+ }
113
+ //#endregion
114
+ //#region packages/intl-messageformat/error.d.ts
115
+ declare enum ErrorCode {
116
+ MISSING_VALUE = "MISSING_VALUE",
117
+ INVALID_VALUE = "INVALID_VALUE",
118
+ MISSING_INTL_API = "MISSING_INTL_API"
119
+ }
120
+ declare class FormatError extends Error {
121
+ readonly code: ErrorCode;
122
+ /**
123
+ * Original message we're trying to format
124
+ * `undefined` if we're only dealing w/ AST
125
+ *
126
+ * @type {(string | undefined)}
127
+ * @memberof FormatError
128
+ */
129
+ readonly originalMessage: string | undefined;
130
+ constructor(msg: string, code: ErrorCode, originalMessage?: string);
131
+ toString(): string;
132
+ }
133
+ declare class InvalidValueError extends FormatError {
134
+ constructor(variableId: string, value: any, options: string[], originalMessage?: string);
135
+ }
136
+ declare class InvalidValueTypeError extends FormatError {
137
+ constructor(value: any, type: string, originalMessage?: string);
138
+ }
139
+ declare class MissingValueError extends FormatError {
140
+ constructor(variableId: string, originalMessage?: string);
141
+ }
142
+ //#endregion
143
+ export { ErrorCode, FormatError, FormatXMLElementFn, Formats, FormatterCache, Formatters, IntlMessageFormat, IntlMessageFormat as default, InvalidValueError, InvalidValueTypeError, LiteralPart, MessageFormatPart, MissingValueError, ObjectPart, Options, PART_TYPE, PrimitiveType, formatToParts, isFormatXMLElementFn };
144
+ //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,11 +1,327 @@
1
- /*
2
- Copyright (c) 2014, Yahoo! Inc. All rights reserved.
3
- Copyrights licensed under the New BSD License.
4
- See the accompanying LICENSE file for terms.
5
- */
6
- import { IntlMessageFormat } from "./src/core.js";
7
- export * from "./src/core.js";
8
- export * from "./src/error.js";
9
- export * from "./src/formatters.js";
10
- export { IntlMessageFormat };
11
- export default IntlMessageFormat;
1
+ import { memoize, strategies } from "@formatjs/fast-memoize";
2
+ import { isArgumentElement, isDateElement, isDateTimeSkeleton, isLiteralElement, isNumberElement, isNumberSkeleton, isPluralElement, isPoundElement, isSelectElement, isTagElement, isTimeElement, parse } from "@formatjs/icu-messageformat-parser";
3
+ //#region packages/intl-messageformat/error.ts
4
+ let ErrorCode = /* @__PURE__ */ function(ErrorCode) {
5
+ ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
6
+ ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
7
+ ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
8
+ return ErrorCode;
9
+ }({});
10
+ var FormatError = class extends Error {
11
+ constructor(msg, code, originalMessage) {
12
+ super(msg);
13
+ this.code = code;
14
+ this.originalMessage = originalMessage;
15
+ }
16
+ toString() {
17
+ return `[formatjs Error: ${this.code}] ${this.message}`;
18
+ }
19
+ };
20
+ var InvalidValueError = class extends FormatError {
21
+ constructor(variableId, value, options, originalMessage) {
22
+ super(`Invalid values for "${variableId}": "${value}". Options are "${Object.keys(options).join("\", \"")}"`, ErrorCode.INVALID_VALUE, originalMessage);
23
+ }
24
+ };
25
+ var InvalidValueTypeError = class extends FormatError {
26
+ constructor(value, type, originalMessage) {
27
+ super(`Value for "${value}" must be of type ${type}`, ErrorCode.INVALID_VALUE, originalMessage);
28
+ }
29
+ };
30
+ var MissingValueError = class extends FormatError {
31
+ constructor(variableId, originalMessage) {
32
+ super(`The intl string context variable "${variableId}" was not provided to the string "${originalMessage}"`, ErrorCode.MISSING_VALUE, originalMessage);
33
+ }
34
+ };
35
+ //#endregion
36
+ //#region packages/intl-messageformat/formatters.ts
37
+ let PART_TYPE = /* @__PURE__ */ function(PART_TYPE) {
38
+ PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
39
+ PART_TYPE[PART_TYPE["object"] = 1] = "object";
40
+ return PART_TYPE;
41
+ }({});
42
+ function mergeLiteral(parts) {
43
+ if (parts.length < 2) return parts;
44
+ return parts.reduce((all, part) => {
45
+ const lastPart = all[all.length - 1];
46
+ if (!lastPart || lastPart.type !== PART_TYPE.literal || part.type !== PART_TYPE.literal) all.push(part);
47
+ else lastPart.value += part.value;
48
+ return all;
49
+ }, []);
50
+ }
51
+ function isFormatXMLElementFn(el) {
52
+ return typeof el === "function";
53
+ }
54
+ function formatToParts(els, locales, formatters, formats, values, currentPluralValue, originalMessage) {
55
+ if (els.length === 1 && isLiteralElement(els[0])) return [{
56
+ type: PART_TYPE.literal,
57
+ value: els[0].value
58
+ }];
59
+ const result = [];
60
+ for (const el of els) {
61
+ if (isLiteralElement(el)) {
62
+ result.push({
63
+ type: PART_TYPE.literal,
64
+ value: el.value
65
+ });
66
+ continue;
67
+ }
68
+ if (isPoundElement(el)) {
69
+ if (typeof currentPluralValue === "number") result.push({
70
+ type: PART_TYPE.literal,
71
+ value: formatters.getNumberFormat(locales).format(currentPluralValue)
72
+ });
73
+ continue;
74
+ }
75
+ const { value: varName } = el;
76
+ if (!(values && varName in values)) throw new MissingValueError(varName, originalMessage);
77
+ let value = values[varName];
78
+ if (isArgumentElement(el)) {
79
+ if (!value || typeof value === "string" || typeof value === "number" || typeof value === "bigint") value = typeof value === "string" || typeof value === "number" || typeof value === "bigint" ? String(value) : "";
80
+ result.push({
81
+ type: typeof value === "string" ? PART_TYPE.literal : PART_TYPE.object,
82
+ value
83
+ });
84
+ continue;
85
+ }
86
+ if (isDateElement(el)) {
87
+ const style = typeof el.style === "string" ? formats.date[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : void 0;
88
+ result.push({
89
+ type: PART_TYPE.literal,
90
+ value: formatters.getDateTimeFormat(locales, style).format(value)
91
+ });
92
+ continue;
93
+ }
94
+ if (isTimeElement(el)) {
95
+ const style = typeof el.style === "string" ? formats.time[el.style] : isDateTimeSkeleton(el.style) ? el.style.parsedOptions : formats.time.medium;
96
+ result.push({
97
+ type: PART_TYPE.literal,
98
+ value: formatters.getDateTimeFormat(locales, style).format(value)
99
+ });
100
+ continue;
101
+ }
102
+ if (isNumberElement(el)) {
103
+ const style = typeof el.style === "string" ? formats.number[el.style] : isNumberSkeleton(el.style) ? el.style.parsedOptions : void 0;
104
+ if (style && style.scale) {
105
+ const scale = style.scale || 1;
106
+ if (typeof value === "bigint") {
107
+ if (!Number.isInteger(scale)) throw new TypeError(`Cannot apply fractional scale ${scale} to bigint value. Scale must be an integer when formatting bigint.`);
108
+ value = value * BigInt(scale);
109
+ } else value = value * scale;
110
+ }
111
+ result.push({
112
+ type: PART_TYPE.literal,
113
+ value: formatters.getNumberFormat(locales, style).format(value)
114
+ });
115
+ continue;
116
+ }
117
+ if (isTagElement(el)) {
118
+ const { children, value } = el;
119
+ const formatFn = values[value];
120
+ if (!isFormatXMLElementFn(formatFn)) throw new InvalidValueTypeError(value, "function", originalMessage);
121
+ let chunks = formatFn(formatToParts(children, locales, formatters, formats, values, currentPluralValue).map((p) => p.value));
122
+ if (!Array.isArray(chunks)) chunks = [chunks];
123
+ result.push(...chunks.map((c) => {
124
+ return {
125
+ type: typeof c === "string" ? PART_TYPE.literal : PART_TYPE.object,
126
+ value: c
127
+ };
128
+ }));
129
+ }
130
+ if (isSelectElement(el)) {
131
+ const key = value;
132
+ const opt = (Object.prototype.hasOwnProperty.call(el.options, key) ? el.options[key] : void 0) || el.options.other;
133
+ if (!opt) throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
134
+ result.push(...formatToParts(opt.value, locales, formatters, formats, values));
135
+ continue;
136
+ }
137
+ if (isPluralElement(el)) {
138
+ const exactKey = `=${value}`;
139
+ let opt = Object.prototype.hasOwnProperty.call(el.options, exactKey) ? el.options[exactKey] : void 0;
140
+ if (!opt) {
141
+ if (!Intl.PluralRules) throw new FormatError(`Intl.PluralRules is not available in this environment.
142
+ Try polyfilling it using "@formatjs/intl-pluralrules"
143
+ `, ErrorCode.MISSING_INTL_API, originalMessage);
144
+ const numericValue = typeof value === "bigint" ? Number(value) : value;
145
+ const rule = formatters.getPluralRules(locales, { type: el.pluralType }).select(numericValue - (el.offset || 0));
146
+ opt = (Object.prototype.hasOwnProperty.call(el.options, rule) ? el.options[rule] : void 0) || el.options.other;
147
+ }
148
+ if (!opt) throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
149
+ const numericValue = typeof value === "bigint" ? Number(value) : value;
150
+ result.push(...formatToParts(opt.value, locales, formatters, formats, values, numericValue - (el.offset || 0)));
151
+ continue;
152
+ }
153
+ }
154
+ return mergeLiteral(result);
155
+ }
156
+ //#endregion
157
+ //#region packages/intl-messageformat/core.ts
158
+ function mergeConfig(c1, c2) {
159
+ if (!c2) return c1;
160
+ return {
161
+ ...c1,
162
+ ...c2,
163
+ ...Object.keys(c1).reduce((all, k) => {
164
+ all[k] = {
165
+ ...c1[k],
166
+ ...c2[k]
167
+ };
168
+ return all;
169
+ }, {})
170
+ };
171
+ }
172
+ function mergeConfigs(defaultConfig, configs) {
173
+ if (!configs) return defaultConfig;
174
+ return Object.keys(defaultConfig).reduce((all, k) => {
175
+ all[k] = mergeConfig(defaultConfig[k], configs[k]);
176
+ return all;
177
+ }, { ...defaultConfig });
178
+ }
179
+ function createFastMemoizeCache(store) {
180
+ return { create() {
181
+ return {
182
+ get(key) {
183
+ return store[key];
184
+ },
185
+ set(key, value) {
186
+ store[key] = value;
187
+ }
188
+ };
189
+ } };
190
+ }
191
+ function createDefaultFormatters(cache = {
192
+ number: {},
193
+ dateTime: {},
194
+ pluralRules: {}
195
+ }) {
196
+ return {
197
+ getNumberFormat: memoize((...args) => new Intl.NumberFormat(...args), {
198
+ cache: createFastMemoizeCache(cache.number),
199
+ strategy: strategies.variadic
200
+ }),
201
+ getDateTimeFormat: memoize((...args) => new Intl.DateTimeFormat(...args), {
202
+ cache: createFastMemoizeCache(cache.dateTime),
203
+ strategy: strategies.variadic
204
+ }),
205
+ getPluralRules: memoize((...args) => new Intl.PluralRules(...args), {
206
+ cache: createFastMemoizeCache(cache.pluralRules),
207
+ strategy: strategies.variadic
208
+ })
209
+ };
210
+ }
211
+ var IntlMessageFormat = class IntlMessageFormat {
212
+ constructor(message, locales = IntlMessageFormat.defaultLocale, overrideFormats, opts) {
213
+ this.formatterCache = {
214
+ number: {},
215
+ dateTime: {},
216
+ pluralRules: {}
217
+ };
218
+ this.format = (values) => {
219
+ const parts = this.formatToParts(values);
220
+ if (parts.length === 1) return parts[0].value;
221
+ const result = parts.reduce((all, part) => {
222
+ if (!all.length || part.type !== PART_TYPE.literal || typeof all[all.length - 1] !== "string") all.push(part.value);
223
+ else all[all.length - 1] += part.value;
224
+ return all;
225
+ }, []);
226
+ if (result.length <= 1) return result[0] || "";
227
+ return result;
228
+ };
229
+ this.formatToParts = (values) => formatToParts(this.ast, this.locales, this.formatters, this.formats, values, void 0, this.message);
230
+ this.resolvedOptions = () => ({ locale: this.resolvedLocale?.toString() || Intl.NumberFormat.supportedLocalesOf(this.locales)[0] });
231
+ this.getAst = () => this.ast;
232
+ this.locales = locales;
233
+ this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);
234
+ if (typeof message === "string") {
235
+ this.message = message;
236
+ if (!IntlMessageFormat.__parse) throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");
237
+ const { ...parseOpts } = opts || {};
238
+ this.ast = IntlMessageFormat.__parse(message, {
239
+ ...parseOpts,
240
+ locale: this.resolvedLocale
241
+ });
242
+ } else this.ast = message;
243
+ if (!Array.isArray(this.ast)) throw new TypeError("A message must be provided as a String or AST.");
244
+ this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
245
+ this.formatters = opts && opts.formatters || createDefaultFormatters(this.formatterCache);
246
+ }
247
+ static {
248
+ this.memoizedDefaultLocale = null;
249
+ }
250
+ static get defaultLocale() {
251
+ if (!IntlMessageFormat.memoizedDefaultLocale) IntlMessageFormat.memoizedDefaultLocale = new Intl.NumberFormat().resolvedOptions().locale;
252
+ return IntlMessageFormat.memoizedDefaultLocale;
253
+ }
254
+ static {
255
+ this.resolveLocale = (locales) => {
256
+ if (typeof Intl.Locale === "undefined") return;
257
+ const supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
258
+ if (supportedLocales.length > 0) return new Intl.Locale(supportedLocales[0]);
259
+ return new Intl.Locale(typeof locales === "string" ? locales : locales[0]);
260
+ };
261
+ }
262
+ static {
263
+ this.__parse = parse;
264
+ }
265
+ static {
266
+ this.formats = {
267
+ number: {
268
+ integer: { maximumFractionDigits: 0 },
269
+ currency: { style: "currency" },
270
+ percent: { style: "percent" }
271
+ },
272
+ date: {
273
+ short: {
274
+ month: "numeric",
275
+ day: "numeric",
276
+ year: "2-digit"
277
+ },
278
+ medium: {
279
+ month: "short",
280
+ day: "numeric",
281
+ year: "numeric"
282
+ },
283
+ long: {
284
+ month: "long",
285
+ day: "numeric",
286
+ year: "numeric"
287
+ },
288
+ full: {
289
+ weekday: "long",
290
+ month: "long",
291
+ day: "numeric",
292
+ year: "numeric"
293
+ }
294
+ },
295
+ time: {
296
+ short: {
297
+ hour: "numeric",
298
+ minute: "numeric"
299
+ },
300
+ medium: {
301
+ hour: "numeric",
302
+ minute: "numeric",
303
+ second: "numeric"
304
+ },
305
+ long: {
306
+ hour: "numeric",
307
+ minute: "numeric",
308
+ second: "numeric",
309
+ timeZoneName: "short"
310
+ },
311
+ full: {
312
+ hour: "numeric",
313
+ minute: "numeric",
314
+ second: "numeric",
315
+ timeZoneName: "short"
316
+ }
317
+ }
318
+ };
319
+ }
320
+ };
321
+ //#endregion
322
+ //#region packages/intl-messageformat/index.ts
323
+ var intl_messageformat_default = IntlMessageFormat;
324
+ //#endregion
325
+ export { ErrorCode, FormatError, IntlMessageFormat, InvalidValueError, InvalidValueTypeError, MissingValueError, PART_TYPE, intl_messageformat_default as default, formatToParts, isFormatXMLElementFn };
326
+
327
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../error.ts","../formatters.ts","../core.ts","../index.ts"],"sourcesContent":["export enum ErrorCode {\n // When we have a placeholder but no value to format\n MISSING_VALUE = 'MISSING_VALUE',\n // When value supplied is invalid\n INVALID_VALUE = 'INVALID_VALUE',\n // When we need specific Intl API but it's not available\n MISSING_INTL_API = 'MISSING_INTL_API',\n}\n\nexport class FormatError extends Error {\n public readonly code: ErrorCode\n /**\n * Original message we're trying to format\n * `undefined` if we're only dealing w/ AST\n *\n * @type {(string | undefined)}\n * @memberof FormatError\n */\n public readonly originalMessage: string | undefined\n constructor(msg: string, code: ErrorCode, originalMessage?: string) {\n super(msg)\n this.code = code\n this.originalMessage = originalMessage\n }\n public toString() {\n return `[formatjs Error: ${this.code}] ${this.message}`\n }\n}\n\nexport class InvalidValueError extends FormatError {\n constructor(\n variableId: string,\n value: any,\n options: string[],\n originalMessage?: string\n ) {\n super(\n `Invalid values for \"${variableId}\": \"${value}\". Options are \"${Object.keys(\n options\n ).join('\", \"')}\"`,\n ErrorCode.INVALID_VALUE,\n originalMessage\n )\n }\n}\n\nexport class InvalidValueTypeError extends FormatError {\n constructor(value: any, type: string, originalMessage?: string) {\n super(\n `Value for \"${value}\" must be of type ${type}`,\n ErrorCode.INVALID_VALUE,\n originalMessage\n )\n }\n}\n\nexport class MissingValueError extends FormatError {\n constructor(variableId: string, originalMessage?: string) {\n super(\n `The intl string context variable \"${variableId}\" was not provided to the string \"${originalMessage}\"`,\n ErrorCode.MISSING_VALUE,\n originalMessage\n )\n }\n}\n","import {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {\n type ExtendedNumberFormatOptions,\n isArgumentElement,\n isDateElement,\n isDateTimeSkeleton,\n isLiteralElement,\n isNumberElement,\n isNumberSkeleton,\n isPluralElement,\n isPoundElement,\n isSelectElement,\n isTagElement,\n isTimeElement,\n type MessageFormatElement,\n} from '@formatjs/icu-messageformat-parser'\nimport {\n ErrorCode,\n FormatError,\n InvalidValueError,\n InvalidValueTypeError,\n MissingValueError,\n} from '#packages/intl-messageformat/error.js'\n\ndeclare global {\n namespace FormatjsIntl {\n interface Message {}\n interface IntlConfig {}\n interface Formats {}\n }\n}\n\ntype Format<Source = string> = Source extends keyof FormatjsIntl.Formats\n ? FormatjsIntl.Formats[Source]\n : string\n\nexport interface Formats {\n number: Record<Format<'number'>, NumberFormatOptions>\n date: Record<Format<'date'>, Intl.DateTimeFormatOptions>\n time: Record<Format<'time'>, Intl.DateTimeFormatOptions>\n}\n\nexport interface FormatterCache {\n number: Record<string, NumberFormatOptions>\n dateTime: Record<string, Intl.DateTimeFormat>\n pluralRules: Record<string, Intl.PluralRules>\n}\n\nexport interface Formatters {\n getNumberFormat(\n locals?: string | string[],\n opts?: NumberFormatOptions\n ): Intl.NumberFormat\n getDateTimeFormat(\n ...args: ConstructorParameters<typeof Intl.DateTimeFormat>\n ): Intl.DateTimeFormat\n getPluralRules(\n ...args: ConstructorParameters<typeof Intl.PluralRules>\n ): Intl.PluralRules\n}\n\nexport enum PART_TYPE {\n literal,\n object,\n}\n\nexport interface LiteralPart {\n type: PART_TYPE.literal\n value: string\n}\n\nexport interface ObjectPart<T = any> {\n type: PART_TYPE.object\n value: T\n}\n\nexport type MessageFormatPart<T> = LiteralPart | ObjectPart<T>\n\nexport type PrimitiveType =\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | Date\n\nfunction mergeLiteral<T>(\n parts: MessageFormatPart<T>[]\n): MessageFormatPart<T>[] {\n if (parts.length < 2) {\n return parts\n }\n return parts.reduce((all, part) => {\n const lastPart = all[all.length - 1]\n if (\n !lastPart ||\n lastPart.type !== PART_TYPE.literal ||\n part.type !== PART_TYPE.literal\n ) {\n all.push(part)\n } else {\n lastPart.value += part.value\n }\n return all\n }, [] as MessageFormatPart<T>[])\n}\n\nexport function isFormatXMLElementFn<T>(\n el: PrimitiveType | T | FormatXMLElementFn<T>\n): el is FormatXMLElementFn<T> {\n return typeof el === 'function'\n}\n\n// TODO(skeleton): add skeleton support\nexport function formatToParts<T>(\n els: MessageFormatElement[],\n locales: string | string[],\n formatters: Formatters,\n formats: Formats,\n values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>,\n currentPluralValue?: number,\n // For debugging\n originalMessage?: string\n): MessageFormatPart<T>[] {\n // Hot path for straight simple msg translations\n if (els.length === 1 && isLiteralElement(els[0])) {\n return [\n {\n type: PART_TYPE.literal,\n value: els[0].value,\n },\n ]\n }\n const result: MessageFormatPart<T>[] = []\n for (const el of els) {\n // Exit early for string parts.\n if (isLiteralElement(el)) {\n result.push({\n type: PART_TYPE.literal,\n value: el.value,\n })\n continue\n }\n // TODO: should this part be literal type?\n // Replace `#` in plural rules with the actual numeric value.\n if (isPoundElement(el)) {\n if (typeof currentPluralValue === 'number') {\n result.push({\n type: PART_TYPE.literal,\n value: formatters.getNumberFormat(locales).format(currentPluralValue),\n })\n }\n continue\n }\n\n const {value: varName} = el\n\n // Enforce that all required values are provided by the caller.\n if (!(values && varName in values)) {\n throw new MissingValueError(varName, originalMessage)\n }\n\n let value = values[varName]\n if (isArgumentElement(el)) {\n if (\n !value ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n ) {\n value =\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n ? String(value)\n : ''\n }\n result.push({\n type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,\n value,\n } as ObjectPart<T>)\n continue\n }\n\n // Recursively format plural and select parts' option — which can be a\n // nested pattern structure. The choosing of the option to use is\n // abstracted-by and delegated-to the part helper object.\n if (isDateElement(el)) {\n const style =\n typeof el.style === 'string'\n ? formats.date[el.style]\n : isDateTimeSkeleton(el.style)\n ? el.style.parsedOptions\n : undefined\n result.push({\n type: PART_TYPE.literal,\n value: formatters\n .getDateTimeFormat(locales, style)\n .format(value as number),\n })\n continue\n }\n if (isTimeElement(el)) {\n const style =\n typeof el.style === 'string'\n ? formats.time[el.style]\n : isDateTimeSkeleton(el.style)\n ? el.style.parsedOptions\n : formats.time.medium\n result.push({\n type: PART_TYPE.literal,\n value: formatters\n .getDateTimeFormat(locales, style)\n .format(value as number),\n })\n continue\n }\n if (isNumberElement(el)) {\n const style =\n typeof el.style === 'string'\n ? formats.number[el.style]\n : isNumberSkeleton(el.style)\n ? el.style.parsedOptions\n : undefined\n\n if (style && (style as ExtendedNumberFormatOptions).scale) {\n const scale = (style as ExtendedNumberFormatOptions).scale || 1\n // Handle bigint scale multiplication\n // BigInt can only be multiplied by BigInt\n if (typeof value === 'bigint') {\n // Check if scale is a safe integer that can be converted to BigInt\n if (!Number.isInteger(scale)) {\n throw new TypeError(\n `Cannot apply fractional scale ${scale} to bigint value. Scale must be an integer when formatting bigint.`\n )\n }\n value = value * BigInt(scale)\n } else {\n value = (value as number) * scale\n }\n }\n result.push({\n type: PART_TYPE.literal,\n value: formatters\n .getNumberFormat(locales, style)\n .format(value as number | bigint),\n })\n continue\n }\n if (isTagElement(el)) {\n const {children, value} = el\n const formatFn = values[value]\n if (!isFormatXMLElementFn<T>(formatFn)) {\n throw new InvalidValueTypeError(value, 'function', originalMessage)\n }\n const parts = formatToParts<T>(\n children,\n locales,\n formatters,\n formats,\n values,\n currentPluralValue\n )\n let chunks = formatFn(parts.map(p => p.value))\n if (!Array.isArray(chunks)) {\n chunks = [chunks]\n }\n result.push(\n ...chunks.map((c): MessageFormatPart<T> => {\n return {\n type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,\n value: c,\n } as MessageFormatPart<T>\n })\n )\n }\n if (isSelectElement(el)) {\n // GH #4490: Use hasOwnProperty to avoid prototype chain issues with keys like \"constructor\"\n const key = value as string\n const opt =\n (Object.prototype.hasOwnProperty.call(el.options, key)\n ? el.options[key]\n : undefined) || el.options.other\n if (!opt) {\n throw new InvalidValueError(\n el.value,\n value,\n Object.keys(el.options),\n originalMessage\n )\n }\n result.push(\n ...formatToParts(opt.value, locales, formatters, formats, values)\n )\n continue\n }\n if (isPluralElement(el)) {\n // GH #4490: Use hasOwnProperty to avoid prototype chain issues\n const exactKey = `=${value}`\n let opt = Object.prototype.hasOwnProperty.call(el.options, exactKey)\n ? el.options[exactKey]\n : undefined\n if (!opt) {\n if (!Intl.PluralRules) {\n throw 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 originalMessage\n )\n }\n // Convert bigint to number for PluralRules (which only accepts number)\n const numericValue =\n typeof value === 'bigint' ? Number(value) : (value as number)\n const rule = formatters\n .getPluralRules(locales, {type: el.pluralType})\n .select(numericValue - (el.offset || 0))\n opt =\n (Object.prototype.hasOwnProperty.call(el.options, rule)\n ? el.options[rule]\n : undefined) || el.options.other\n }\n if (!opt) {\n throw new InvalidValueError(\n el.value,\n value,\n Object.keys(el.options),\n originalMessage\n )\n }\n // Convert bigint to number for currentPluralValue\n const numericValue =\n typeof value === 'bigint' ? Number(value) : (value as number)\n result.push(\n ...formatToParts(\n opt.value,\n locales,\n formatters,\n formats,\n values,\n numericValue - (el.offset || 0)\n )\n )\n continue\n }\n }\n return mergeLiteral(result)\n}\n\nexport type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (\n parts: Array<string | T>\n) => R\n","/*\nCopyright (c) 2014, Yahoo! Inc. All rights reserved.\nCopyrights licensed under the New BSD License.\nSee the accompanying LICENSE file for terms.\n*/\n\nimport {type Cache, memoize, strategies} from '@formatjs/fast-memoize'\nimport {\n type MessageFormatElement,\n parse,\n type ParserOptions,\n} from '@formatjs/icu-messageformat-parser'\nimport {\n type Formats,\n type FormatterCache,\n type Formatters,\n formatToParts,\n type FormatXMLElementFn,\n type MessageFormatPart,\n PART_TYPE,\n type PrimitiveType,\n} from '#packages/intl-messageformat/formatters.js'\n\n// -- MessageFormat --------------------------------------------------------\n\nfunction mergeConfig(c1: Record<string, object>, c2?: Record<string, object>) {\n if (!c2) {\n return c1\n }\n return {\n ...c1,\n ...c2,\n ...Object.keys(c1).reduce((all: Record<string, object>, k) => {\n all[k] = {\n ...c1[k],\n ...c2[k],\n }\n return all\n }, {}),\n }\n}\n\nfunction mergeConfigs(\n defaultConfig: Formats,\n configs?: Partial<Formats>\n): Formats {\n if (!configs) {\n return defaultConfig\n }\n\n return (Object.keys(defaultConfig) as Array<keyof Formats>).reduce(\n (all: Formats, k: keyof Formats) => {\n all[k] = mergeConfig(defaultConfig[k], configs[k])\n return all\n },\n {...defaultConfig}\n )\n}\n\nexport interface Options extends Omit<ParserOptions, 'locale'> {\n formatters?: Formatters\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\nfunction createDefaultFormatters(\n cache: FormatterCache = {\n number: {},\n dateTime: {},\n pluralRules: {},\n }\n): Formatters {\n return {\n getNumberFormat: memoize((...args) => new Intl.NumberFormat(...args), {\n cache: createFastMemoizeCache(cache.number),\n strategy: strategies.variadic,\n }),\n getDateTimeFormat: memoize((...args) => new Intl.DateTimeFormat(...args), {\n cache: createFastMemoizeCache(cache.dateTime),\n strategy: strategies.variadic,\n }),\n getPluralRules: memoize((...args) => new Intl.PluralRules(...args), {\n cache: createFastMemoizeCache(cache.pluralRules),\n strategy: strategies.variadic,\n }),\n }\n}\n\nexport class IntlMessageFormat {\n private readonly ast: MessageFormatElement[]\n private readonly locales: string | string[]\n private readonly resolvedLocale?: Intl.Locale\n private readonly formatters: Formatters\n private readonly formats: Formats\n private readonly message: string | undefined\n private readonly formatterCache: FormatterCache = {\n number: {},\n dateTime: {},\n pluralRules: {},\n }\n constructor(\n message: string | MessageFormatElement[],\n locales: string | string[] = IntlMessageFormat.defaultLocale,\n overrideFormats?: Partial<Formats>,\n opts?: Options\n ) {\n // Defined first because it's used to build the format pattern.\n this.locales = locales\n this.resolvedLocale = IntlMessageFormat.resolveLocale(locales)\n\n if (typeof message === 'string') {\n this.message = message\n if (!IntlMessageFormat.__parse) {\n throw new TypeError(\n 'IntlMessageFormat.__parse must be set to process `message` of type `string`'\n )\n }\n const {...parseOpts} = opts || {}\n // Parse string messages into an AST.\n this.ast = IntlMessageFormat.__parse(message, {\n ...parseOpts,\n locale: this.resolvedLocale,\n })\n } else {\n this.ast = message\n }\n\n if (!Array.isArray(this.ast)) {\n throw new TypeError('A message must be provided as a String or AST.')\n }\n\n // Creates a new object with the specified `formats` merged with the default\n // formats.\n this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats)\n\n this.formatters =\n (opts && opts.formatters) || createDefaultFormatters(this.formatterCache)\n }\n\n format = <T = void>(\n values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>\n ): string | T | (string | T)[] => {\n const parts = this.formatToParts(values)\n // Hot path for straight simple msg translations\n if (parts.length === 1) {\n return parts[0].value\n }\n const result = parts.reduce(\n (all, part) => {\n if (\n !all.length ||\n part.type !== PART_TYPE.literal ||\n typeof all[all.length - 1] !== 'string'\n ) {\n all.push(part.value)\n } else {\n all[all.length - 1] += part.value\n }\n return all\n },\n [] as Array<string | T>\n )\n\n if (result.length <= 1) {\n return result[0] || ''\n }\n return result\n }\n formatToParts = <T>(\n values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>\n ): MessageFormatPart<T>[] =>\n formatToParts(\n this.ast,\n this.locales,\n this.formatters,\n this.formats,\n values,\n undefined,\n this.message\n )\n resolvedOptions = (): {\n locale: string\n } => ({\n locale:\n this.resolvedLocale?.toString() ||\n Intl.NumberFormat.supportedLocalesOf(this.locales)[0],\n })\n getAst = (): MessageFormatElement[] => this.ast\n private static memoizedDefaultLocale: string | null = null\n\n static get defaultLocale(): string {\n if (!IntlMessageFormat.memoizedDefaultLocale) {\n IntlMessageFormat.memoizedDefaultLocale =\n new Intl.NumberFormat().resolvedOptions().locale\n }\n\n return IntlMessageFormat.memoizedDefaultLocale\n }\n static resolveLocale = (\n locales: string | string[]\n ): Intl.Locale | undefined => {\n if (typeof Intl.Locale === 'undefined') {\n return\n }\n const supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales)\n if (supportedLocales.length > 0) {\n return new Intl.Locale(supportedLocales[0])\n }\n\n return new Intl.Locale(typeof locales === 'string' ? locales : locales[0])\n }\n static __parse: typeof parse | undefined = parse\n // Default format options used as the prototype of the `formats` provided to the\n // constructor. These are used when constructing the internal Intl.NumberFormat\n // and Intl.DateTimeFormat instances.\n static formats: Formats = {\n number: {\n integer: {\n maximumFractionDigits: 0,\n },\n currency: {\n style: 'currency',\n },\n\n percent: {\n style: 'percent',\n },\n },\n\n date: {\n short: {\n month: 'numeric',\n day: 'numeric',\n year: '2-digit',\n },\n\n medium: {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n },\n\n long: {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n },\n\n full: {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n },\n },\n\n time: {\n short: {\n hour: 'numeric',\n minute: 'numeric',\n },\n\n medium: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n },\n\n long: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n timeZoneName: 'short',\n },\n\n full: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n timeZoneName: 'short',\n },\n },\n }\n}\n","/*\nCopyright (c) 2014, Yahoo! Inc. All rights reserved.\nCopyrights licensed under the New BSD License.\nSee the accompanying LICENSE file for terms.\n*/\n\nimport {IntlMessageFormat} from '#packages/intl-messageformat/core.js'\nexport * from '#packages/intl-messageformat/core.js'\nexport * from '#packages/intl-messageformat/error.js'\nexport * from '#packages/intl-messageformat/formatters.js'\nexport {IntlMessageFormat}\nexport default IntlMessageFormat\n"],"mappings":";;;AAAA,IAAY,YAAL,yBAAA,WAAA;AAEL,WAAA,mBAAA;AAEA,WAAA,mBAAA;AAEA,WAAA,sBAAA;;KACD;AAED,IAAa,cAAb,cAAiC,MAAM;CAUrC,YAAY,KAAa,MAAiB,iBAA0B;AAClE,QAAM,IAAI;AACV,OAAK,OAAO;AACZ,OAAK,kBAAkB;;CAEzB,WAAkB;AAChB,SAAO,oBAAoB,KAAK,KAAK,IAAI,KAAK;;;AAIlD,IAAa,oBAAb,cAAuC,YAAY;CACjD,YACE,YACA,OACA,SACA,iBACA;AACA,QACE,uBAAuB,WAAW,MAAM,MAAM,kBAAkB,OAAO,KACrE,QACD,CAAC,KAAK,SAAO,CAAC,IACf,UAAU,eACV,gBACD;;;AAIL,IAAa,wBAAb,cAA2C,YAAY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