intl-messageformat 11.2.13 → 11.2.14

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
@@ -51,44 +51,44 @@ declare global {
51
51
  }
52
52
  }
53
53
  type Format<Source = string> = Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
54
- interface Formats {
54
+ export interface Formats {
55
55
  number: Record<Format<"number">, NumberFormatOptions>;
56
56
  date: Record<Format<"date">, Intl.DateTimeFormatOptions>;
57
57
  time: Record<Format<"time">, Intl.DateTimeFormatOptions>;
58
58
  }
59
- interface FormatterCache {
59
+ export interface FormatterCache {
60
60
  number: Record<string, NumberFormatOptions>;
61
61
  dateTime: Record<string, Intl.DateTimeFormat>;
62
62
  pluralRules: Record<string, Intl.PluralRules>;
63
63
  }
64
- interface Formatters {
64
+ export interface Formatters {
65
65
  getNumberFormat(locals?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
66
66
  getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
67
67
  getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
68
68
  }
69
- declare enum PART_TYPE {
69
+ export declare enum PART_TYPE {
70
70
  literal = 0,
71
71
  object = 1
72
72
  }
73
- interface LiteralPart {
73
+ export interface LiteralPart {
74
74
  type: PART_TYPE.literal;
75
75
  value: string;
76
76
  }
77
- interface ObjectPart<T = any> {
77
+ export interface ObjectPart<T = any> {
78
78
  type: PART_TYPE.object;
79
79
  value: T;
80
80
  }
81
- type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
82
- type PrimitiveType = string | number | bigint | boolean | null | undefined | Date;
83
- declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
84
- 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>[];
85
- type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
81
+ export type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
82
+ export type PrimitiveType = string | number | bigint | boolean | null | undefined | Date;
83
+ export declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
84
+ export 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>[];
85
+ export type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
86
86
  //#endregion
87
87
  //#region packages/intl-messageformat/core.d.ts
88
- interface Options extends Omit<ParserOptions, "locale"> {
88
+ export interface Options extends Omit<ParserOptions, "locale"> {
89
89
  formatters?: Formatters;
90
90
  }
91
- declare class IntlMessageFormat {
91
+ export declare class IntlMessageFormat {
92
92
  private readonly ast;
93
93
  private readonly locales;
94
94
  private readonly resolvedLocale?;
@@ -111,12 +111,12 @@ declare class IntlMessageFormat {
111
111
  }
112
112
  //#endregion
113
113
  //#region packages/intl-messageformat/error.d.ts
114
- declare enum ErrorCode {
114
+ export declare enum ErrorCode {
115
115
  MISSING_VALUE = "MISSING_VALUE",
116
116
  INVALID_VALUE = "INVALID_VALUE",
117
117
  MISSING_INTL_API = "MISSING_INTL_API"
118
118
  }
119
- declare class FormatError extends Error {
119
+ export declare class FormatError extends Error {
120
120
  readonly code: ErrorCode;
121
121
  /**
122
122
  * Original message we're trying to format
@@ -129,15 +129,15 @@ declare class FormatError extends Error {
129
129
  constructor(msg: string, code: ErrorCode, originalMessage?: string);
130
130
  toString(): string;
131
131
  }
132
- declare class InvalidValueError extends FormatError {
132
+ export declare class InvalidValueError extends FormatError {
133
133
  constructor(variableId: string, value: any, options: string[], originalMessage?: string);
134
134
  }
135
- declare class InvalidValueTypeError extends FormatError {
135
+ export declare class InvalidValueTypeError extends FormatError {
136
136
  constructor(value: any, type: string, originalMessage?: string);
137
137
  }
138
- declare class MissingValueError extends FormatError {
138
+ export declare class MissingValueError extends FormatError {
139
139
  constructor(variableId: string, originalMessage?: string);
140
140
  }
141
141
  //#endregion
142
- export { ErrorCode, FormatError, FormatXMLElementFn, Formats, FormatterCache, Formatters, IntlMessageFormat, IntlMessageFormat as default, InvalidValueError, InvalidValueTypeError, LiteralPart, MessageFormatPart, MissingValueError, ObjectPart, Options, PART_TYPE, PrimitiveType, formatToParts, isFormatXMLElementFn };
142
+ export { IntlMessageFormat as default };
143
143
  //# sourceMappingURL=index.d.ts.map
package/index.js.map CHANGED
@@ -1 +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;CAEL,UAAA,mBAAA;CAEA,UAAA,mBAAA;CAEA,UAAA,sBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAa,cAAb,cAAiC,MAAM;CAUrC,YAAY,KAAa,MAAiB,iBAA0B;EAClE,MAAM,GAAG;EACT,KAAK,OAAO;EACZ,KAAK,kBAAkB;CACzB;CACA,WAAkB;EAChB,OAAO,oBAAoB,KAAK,KAAK,IAAI,KAAK;CAChD;AACF;AAEA,IAAa,oBAAb,cAAuC,YAAY;CACjD,YACE,YACA,OACA,SACA,iBACA;EACA,MACE,uBAAuB,WAAW,MAAM,MAAM,kBAAkB,OAAO,KACrE,OACF,CAAC,CAAC,KAAK,QAAM,EAAE,IAAA,iBAEf,eACF;CACF;AACF;AAEA,IAAa,wBAAb,cAA2C,YAAY;CACrD,YAAY,OAAY,MAAc,iBAA0B;EAC9D,MACE,cAAc,MAAM,oBAAoB,QAAA,iBAExC,eACF;CACF;AACF;AAEA,IAAa,oBAAb,cAAuC,YAAY;CACjD,YAAY,YAAoB,iBAA0B;EACxD,MACE,qCAAqC,WAAW,oCAAoC,gBAAgB,IAAA,iBAEpG,eACF;CACF;AACF;;;ACHA,IAAY,YAAL,yBAAA,WAAA;CACL,UAAA,UAAA,aAAA,KAAA;CACA,UAAA,UAAA,YAAA,KAAA;;AACF,EAAA,CAAA,CAAA;AAuBA,SAAS,aACP,OAC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,wBAAwB,KAAK,cAAc;CAC5E;;+BAmDsD;;CAEtD,WAAW,gBAAwB;EACjC,IAAI,CAAC,kBAAkB,uBACrB,kBAAkB,wBAChB,IAAI,KAAK,aAAa,CAAC,CAAC,gBAAgB,CAAC,CAAC;EAG9C,OAAO,kBAAkB;CAC3B;;wBAEE,YAC4B;GAC5B,IAAI,OAAO,KAAK,WAAW,aACzB;GAEF,MAAM,mBAAmB,KAAK,aAAa,mBAAmB,OAAO;GACrE,IAAI,iBAAiB,SAAS,GAC5B,OAAO,IAAI,KAAK,OAAO,iBAAiB,EAAE;GAG5C,OAAO,IAAI,KAAK,OAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,EAAE;EAC3E;;;iBAC2C;;;iBAIjB;GACxB,QAAQ;IACN,SAAS,EACP,uBAAuB,EACzB;IACA,UAAU,EACR,OAAO,WACT;IAEA,SAAS,EACP,OAAO,UACT;GACF;GAEA,MAAM;IACJ,OAAO;KACL,OAAO;KACP,KAAK;KACL,MAAM;IACR;IAEA,QAAQ;KACN,OAAO;KACP,KAAK;KACL,MAAM;IACR;IAEA,MAAM;KACJ,OAAO;KACP,KAAK;KACL,MAAM;IACR;IAEA,MAAM;KACJ,SAAS;KACT,OAAO;KACP,KAAK;KACL,MAAM;IACR;GACF;GAEA,MAAM;IACJ,OAAO;KACL,MAAM;KACN,QAAQ;IACV;IAEA,QAAQ;KACN,MAAM;KACN,QAAQ;KACR,QAAQ;IACV;IAEA,MAAM;KACJ,MAAM;KACN,QAAQ;KACR,QAAQ;KACR,cAAc;IAChB;IAEA,MAAM;KACJ,MAAM;KACN,QAAQ;KACR,QAAQ;KACR,cAAc;IAChB;GACF;EACF;;AACF;;;AC/RA,IAAA,6BAAe"}
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;CAEL,UAAA,mBAAA;CAEA,UAAA,mBAAA;CAEA,UAAA,sBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAa,cAAb,cAAiC,MAAM;CAUrC,YAAY,KAAa,MAAiB,iBAA0B;EAClE,MAAM,GAAG;EACT,KAAK,OAAO;EACZ,KAAK,kBAAkB;CACzB;CACA,WAAkB;EAChB,OAAO,oBAAoB,KAAK,KAAK,IAAI,KAAK;CAChD;AACF;A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AAO,UACT;GACF;GAEA,MAAM;IACJ,OAAO;KACL,OAAO;KACP,KAAK;KACL,MAAM;IACR;IAEA,QAAQ;KACN,OAAO;KACP,KAAK;KACL,MAAM;IACR;IAEA,MAAM;KACJ,OAAO;KACP,KAAK;KACL,MAAM;IACR;IAEA,MAAM;KACJ,SAAS;KACT,OAAO;KACP,KAAK;KACL,MAAM;IACR;GACF;GAEA,MAAM;IACJ,OAAO;KACL,MAAM;KACN,QAAQ;IACV;IAEA,QAAQ;KACN,MAAM;KACN,QAAQ;KACR,QAAQ;IACV;IAEA,MAAM;KACJ,MAAM;KACN,QAAQ;KACR,QAAQ;KACR,cAAc;IAChB;IAEA,MAAM;KACJ,MAAM;KACN,QAAQ;KACR,QAAQ;KACR,cAAc;IAChB;GACF;EACF;;AACF;;;AC/RA,IAAA,6BAAe"}
@@ -1776,7 +1776,7 @@ const trimEnd = hasTrimEnd ? function trimEnd(s) {
1776
1776
  } : function trimEnd(s) {
1777
1777
  return s.replace(SPACE_SEPARATOR_END_REGEX, "");
1778
1778
  };
1779
- const IDENTIFIER_PREFIX_RE = /* @__PURE__ */ new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1779
+ const IDENTIFIER_PREFIX_RE = new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
1780
1780
  function matchIdentifierAtIndex(s, index) {
1781
1781
  IDENTIFIER_PREFIX_RE.lastIndex = index;
1782
1782
  return IDENTIFIER_PREFIX_RE.exec(s)[1] ?? "";
@@ -1863,9 +1863,10 @@ var Parser = class {
1863
1863
  type: 7,
1864
1864
  location: createLocation(position, this.clonePosition())
1865
1865
  });
1866
- } else if (char === 60 && !this.ignoreTag && this.peek() === 47) if (expectingCloseTag) break;
1867
- else return this.error(26, createLocation(this.clonePosition(), this.clonePosition()));
1868
- else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
1866
+ } else if (char === 60 && !this.ignoreTag && this.peek() === 47) {
1867
+ if (expectingCloseTag) break;
1868
+ else return this.error(26, createLocation(this.clonePosition(), this.clonePosition()));
1869
+ } else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
1869
1870
  const result = this.parseTag(nestingLevel, parentArgType);
1870
1871
  if (result.err) return result;
1871
1872
  elements.push(result.val);
@@ -2007,14 +2008,15 @@ var Parser = class {
2007
2008
  this.bump();
2008
2009
  while (!this.isEOF()) {
2009
2010
  const ch = this.char();
2010
- if (ch === 39) if (this.peek() === 39) {
2011
- codePoints.push(39);
2012
- this.bump();
2013
- } else {
2014
- this.bump();
2015
- break;
2016
- }
2017
- else codePoints.push(ch);
2011
+ if (ch === 39) {
2012
+ if (this.peek() === 39) {
2013
+ codePoints.push(39);
2014
+ this.bump();
2015
+ } else {
2016
+ this.bump();
2017
+ break;
2018
+ }
2019
+ } else codePoints.push(ch);
2018
2020
  this.bump();
2019
2021
  }
2020
2022
  return String.fromCodePoint(...codePoints);
@@ -2226,9 +2228,7 @@ var Parser = class {
2226
2228
  err: null
2227
2229
  };
2228
2230
  break;
2229
- default:
2230
- this.bump();
2231
- break;
2231
+ default: this.bump();
2232
2232
  }
2233
2233
  return {
2234
2234
  val: this.message.slice(startPosition.offset, this.offset()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intl-messageformat",
3
- "version": "11.2.13",
3
+ "version": "11.2.14",
4
4
  "description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
5
5
  "keywords": [
6
6
  "globalization",
@@ -35,6 +35,6 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@formatjs/fast-memoize": "3.1.7",
38
- "@formatjs/icu-messageformat-parser": "3.5.16"
38
+ "@formatjs/icu-messageformat-parser": "3.5.17"
39
39
  }
40
40
  }