use-intl 3.0.0-beta.1 → 3.0.0-beta.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/dist/core/MessageFormatCache.d.ts +5 -0
- package/dist/core/convertFormatsToIntlMessageFormat.esm.js +7 -2
- package/dist/core/convertFormatsToIntlMessageFormat.esm.js.map +1 -1
- package/dist/core/createBaseTranslator.d.ts +2 -2
- package/dist/core/createBaseTranslator.esm.js +21 -12
- package/dist/core/createBaseTranslator.esm.js.map +1 -1
- package/dist/core/use-intl.esm.js +30 -34
- package/dist/core/use-intl.esm.js.map +1 -1
- package/dist/core/use-intl.esm10.js +1 -1
- package/dist/core/use-intl.esm2.js +206 -29
- package/dist/core/use-intl.esm2.js.map +1 -1
- package/dist/core/use-intl.esm3.js +33 -10
- package/dist/core/use-intl.esm3.js.map +1 -1
- package/dist/core/use-intl.esm4.js +9 -196
- package/dist/core/use-intl.esm4.js.map +1 -1
- package/dist/core/use-intl.esm5.js +1 -1
- package/dist/core/use-intl.esm6.js +2 -2
- package/dist/core/use-intl.esm7.js +32 -10
- package/dist/core/use-intl.esm7.js.map +1 -1
- package/dist/core/use-intl.esm8.js +12 -47
- package/dist/core/use-intl.esm8.js.map +1 -1
- package/dist/core/use-intl.esm9.js +46 -28
- package/dist/core/use-intl.esm9.js.map +1 -1
- package/dist/core.cjs.development.js +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/{createIntl-8a2b87eb.js → createIntl-34d4281e.js} +28 -15
- package/dist/createIntl-34d4281e.js.map +1 -0
- package/dist/{createIntl-f7979de1.js → createIntl-bc325740.js} +2 -2
- package/dist/createIntl-bc325740.js.map +1 -0
- package/dist/react/IntlContext.d.ts +11 -2
- package/dist/react/IntlContext.esm.js.map +1 -1
- package/dist/react/IntlProvider.esm.js +9 -3
- package/dist/react/IntlProvider.esm.js.map +1 -1
- package/dist/react/use-intl.esm11.js.map +1 -1
- package/dist/react/use-intl.esm2.js +3 -19
- package/dist/react/use-intl.esm2.js.map +1 -1
- package/dist/react/use-intl.esm3.js +24 -39
- package/dist/react/use-intl.esm3.js.map +1 -1
- package/dist/react/use-intl.esm4.js +9 -3
- package/dist/react/use-intl.esm4.js.map +1 -1
- package/dist/react/use-intl.esm5.js +19 -3
- package/dist/react/use-intl.esm5.js.map +1 -1
- package/dist/react/use-intl.esm6.js +40 -3
- package/dist/react/use-intl.esm6.js.map +1 -1
- package/dist/react/use-intl.esm7.js +3 -25
- package/dist/react/use-intl.esm7.js.map +1 -1
- package/dist/react/use-intl.esm8.js +3 -3
- package/dist/react/use-intl.esm8.js.map +1 -1
- package/dist/react/use-intl.esm9.js +5 -5
- package/dist/react/use-intl.esm9.js.map +1 -1
- package/dist/react/useIntlContext.d.ts +10 -1
- package/dist/react/useTranslationsImpl.esm.js +4 -4
- package/dist/react/useTranslationsImpl.esm.js.map +1 -1
- package/dist/react.cjs.development.js +11 -5
- package/dist/react.cjs.development.js.map +1 -1
- package/dist/react.cjs.production.min.js +1 -1
- package/dist/react.cjs.production.min.js.map +1 -1
- package/dist/use-intl.cjs.development.js +37 -18
- package/dist/use-intl.cjs.development.js.map +1 -1
- package/dist/use-intl.cjs.production.min.js +1 -1
- package/dist/use-intl.cjs.production.min.js.map +1 -1
- package/dist/use-intl.esm.js +10 -10
- package/package.json +1 -1
- package/dist/createIntl-8a2b87eb.js.map +0 -1
- package/dist/createIntl-f7979de1.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-intl.cjs.production.min.js","sources":["../src/core/IntlError.tsx","../src/core/convertFormatsToIntlMessageFormat.tsx","../src/core/defaults.tsx","../src/core/createBaseTranslator.tsx","../src/core/resolveNamespace.tsx","../src/core/createFormatter.tsx","../src/core/initializeConfig.tsx","../src/core/createIntl.tsx","../src/react/IntlContext.tsx","../src/react/useIntlContext.tsx","../src/react/useNow.tsx","../src/react/useIntl.tsx","../src/react/IntlProvider.tsx","../src/core/createTranslator.tsx","../src/core/createTranslatorImpl.tsx","../src/react/useFormatter.tsx","../src/react/useLocale.tsx","../src/react/useMessages.tsx","../src/react/useTimeZone.tsx","../src/react/useTranslations.tsx","../src/react/useTranslationsImpl.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n","import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n","import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n","// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nfunction getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages?: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(config: Omit<CreateBaseTranslatorProps<Messages>, 'messagesOrError'>) {\n const messagesOrError = getMessagesOrError({\n messages: config.messages,\n namespace: config.namespace,\n onError: config.onError\n }) as Messages | IntlError;\n\n return createBaseTranslatorImpl<Messages, NestedKey>({\n ...config,\n messagesOrError\n });\n}\n\nfunction createBaseTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n cachedFormatsByLocale,\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([namespace, key, String(message)]);\n\n let messageFormat;\n if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale?.[locale][cacheKey];\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an object, but only strings are supported. Use a \\`.\\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n if (cachedFormatsByLocale) {\n if (!cachedFormatsByLocale[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n","/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n","import IntlConfig from './IntlConfig';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport validateMessages from './validateMessages';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function initializeConfig<\n // This is a generic to allow for stricter typing. E.g.\n // the RSC integration always provides a `now` value.\n Props extends Omit<IntlConfig, 'children'>\n>({getMessageFallback, messages, onError, ...rest}: Props) {\n const finalOnError = onError || defaultOnError;\n const finalGetMessageFallback =\n getMessageFallback || defaultGetMessageFallback;\n\n if (process.env.NODE_ENV !== 'production') {\n if (messages) {\n validateMessages(messages, finalOnError);\n }\n }\n\n return {\n ...rest,\n messages,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback\n };\n}\n","import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n","import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\n\nconst IntlContext = createContext<InitializedIntlConfig | undefined>(undefined);\n\nexport default IntlContext;\n","import {useContext} from 'react';\nimport IntlContext from './IntlContext';\n\nexport default function useIntlContext() {\n const context = useContext(IntlContext);\n\n if (!context) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","import {useState, useEffect} from 'react';\nimport useIntlContext from './useIntlContext';\n\ntype Options = {\n updateInterval?: number;\n};\n\nfunction getNow() {\n return new Date();\n}\n\n/**\n * Reading the current date via `new Date()` in components should be avoided, as\n * it causes components to be impure and can lead to flaky tests. Instead, this\n * hook can be used.\n *\n * By default, it returns the time when the component mounts. If `updateInterval`\n * is specified, the value will be updated based on the interval.\n *\n * You can however also return a static value from this hook, if you\n * configure the `now` parameter on the context provider. Note however,\n * that if `updateInterval` is configured in this case, the component\n * will initialize with the global value, but will afterwards update\n * continuously based on the interval.\n *\n * For unit tests, this can be mocked to a constant value. For end-to-end\n * testing, an environment parameter can be passed to the `now` parameter\n * of the provider to mock this to a static value.\n */\nexport default function useNow(options?: Options) {\n const updateInterval = options?.updateInterval;\n\n const {now: globalNow} = useIntlContext();\n const [now, setNow] = useState(globalNow || getNow());\n\n useEffect(() => {\n if (!updateInterval) return;\n\n const intervalId = setInterval(() => {\n setNow(getNow());\n }, updateInterval);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [globalNow, updateInterval]);\n\n return now;\n}\n","import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nlet hasWarned = false;\n\n/** @deprecated Switch to `useFormatter` instead. */\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n if (!hasWarned) {\n hasWarned = true;\n console.warn(\n '`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.'\n );\n }\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n","import React, {ReactNode} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n return (\n <IntlContext.Provider value={initializeConfig(config)}>\n {children}\n </IntlContext.Provider>\n );\n}\n","import Formats from './Formats';\nimport IntlConfig from './IntlConfig';\nimport TranslationValues, {\n RichTranslationValuesPlain\n} from './TranslationValues';\nimport createTranslatorImpl from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n onError = defaultOnError,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: NonNullable<IntlConfig<IntlMessages>['messages']>;\n namespace?: NestedKey;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValuesPlain,\n formats?: Partial<Formats>\n ): string;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n","import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {\n RichTranslationValues,\n RichTranslationValuesPlain\n} from './TranslationValues';\nimport createBaseTranslator from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CreateTranslatorImplProps<Messages> = Omit<\n InitializedIntlConfig,\n 'messages'\n> & {\n namespace: string;\n messages: Messages;\n};\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messages,\n namespace\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: RichTranslationValuesPlain,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n process.env.NODE_ENV !== 'production'\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n","import {useMemo} from 'react';\nimport createFormatter from '../core/createFormatter';\nimport useIntlContext from './useIntlContext';\n\nexport default function useFormatter() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createFormatter({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n","import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n","// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {useMemo, useRef} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator from '../core/createBaseTranslator';\nimport resolveNamespace from '../core/resolveNamespace';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport useIntlContext from './useIntlContext';\n\nexport default function useTranslationsImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n // The `namespacePrefix` is part of the type system.\n // See the comment in the hook invocation.\n allMessages = allMessages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["IntlErrorCode","IntlError","_Error","code","originalMessage","_this","message","call","this","_wrapNativeSuper","Error","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","defaultGetMessageFallback","props","namespace","filter","part","join","defaultOnError","error","console","resolvePath","messages","undefined","split","forEach","next","createBaseTranslator","config","_ref2","cachedFormatsByLocale","defaultTranslationValues","globalFormats","_ref2$getMessageFallb","getMessageFallback","locale","messagesOrError","onError","getFallbackFromErrorAndNotify","translateBaseFn","values","_cachedFormatsByLocal","MISSING_MESSAGE","messageFormat","cacheKey","String","Array","isArray","INVALID_MESSAGE","INSUFFICIENT_PATH","errorMessage","IntlMessageFormat","formatsWithTimeZone","dateTime","date","time","convertFormatsToIntlMessageFormat","formattedMessage","format","length","transformedValues","index","value","chunks","result","isValidElement","cloneElement","prepareTranslationValues","FORMATTING_ERROR","translateFn","rich","raw","createBaseTranslatorImpl","_ref","_ref$onError","retrievedMessages","intlError","getMessagesOrError","resolveNamespace","namespacePrefix","slice","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","createFormatter","globalNow","now","getFormattedValue","formatOrOptions","typeFormats","formatter","options","MISSING_FORMAT","resolveFormatOrOptions","_options","Intl","DateTimeFormat","number","NumberFormat","relativeTime","dateDate","Date","nowDate","_getRelativeTimeForma","seconds","unit","absValue","Math","abs","round","getRelativeTimeFormatConfig","getTime","RelativeTimeFormat","numeric","list","ListFormat","initializeConfig","_objectWithoutPropertiesLoose","_excluded","createIntl","apply","arguments","formatDateTime","formatNumber","formatRelativeTime","IntlContext","createContext","useIntlContext","context","useContext","getNow","hasWarned","children","React","createElement","Provider","_ref$getMessageFallba","rest","translator","originalRich","base","createTranslatorImpl","_useIntlContext","useMemo","warn","updateInterval","_useState","useState","setNow","useEffect","intervalId","setInterval","clearInterval","allMessages","cachedFormatsByLocaleRef","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OAAO+F,IAAiB5G,QAC1B,iBPyBwB,SAAOwE,GAC7B,IAAMsD,EAAiBtD,MAAAA,OAAAA,EAAAA,EAASsD,eAEpB5D,EAAa0C,IAAlBzC,IACP4D,EAAsBC,EAAAA,SAAS9D,GAAa6C,KAArC5C,EAAG4D,EAAA,GAAEE,EAAMF,EAAA,GAclB,OAZAG,EAAAA,WAAU,WACR,GAAKJ,EAAL,CAEA,IAAMK,EAAaC,aAAY,WAC7BH,EAAOlB,IACR,GAAEe,GAEH,OAAO,WACLO,cAAcF,GAPK,CASvB,GAAG,CAACjE,EAAW4D,IAER3D,CACT,sBQ9Cc,WACZ,OAAOyC,IAAiB7H,QAC1B,0BCgBwB,SAMtBS,GAmEA,OCpFsB,SAGtB8I,EAAuB9I,EAAsBiE,GAC7C,IAAAkE,EAOIf,IANFnG,EAAwBkH,EAAxBlH,yBACSC,EAAaiH,EAAtB7I,QACA8B,EAAkB+G,EAAlB/G,mBACAC,EAAM8G,EAAN9G,OACAE,EAAO4G,EAAP5G,QACAhC,EAAQ4I,EAAR5I,SAKFuJ,EAAcA,ED4EZ,KC3EF9I,EAAYgE,EAAiBhE,ED2E3B,KCzEF,IAAM+I,EAA2BC,SAE/B,CAAA,GA2BF,OAzBkBZ,EAAAA,SAChB,WAAA,OACEvH,EAAqB,CACnBG,sBAAuB+H,EAAyBE,QAChD7H,mBAAAA,EACAZ,SAAUsI,EACV7H,yBAAAA,EACAjB,UAAAA,EACAuB,QAAAA,EACAjC,QAAS4B,EACTG,OAAAA,EACA9B,SAAAA,GACA,GACJ,CACE6B,EACA0H,EACA9I,EACAuB,EACAN,EACAC,EACAG,EACA9B,GAKN,CDoCS2J,CAIL,CAAC,IAVa9B,IACS5G,UAWvBR,OAAiBA,EAAc,IAGnC"}
|
|
1
|
+
{"version":3,"file":"use-intl.cjs.production.min.js","sources":["../src/core/IntlError.tsx","../src/core/convertFormatsToIntlMessageFormat.tsx","../src/core/defaults.tsx","../src/core/createBaseTranslator.tsx","../src/core/resolveNamespace.tsx","../src/core/createFormatter.tsx","../src/core/initializeConfig.tsx","../src/core/createIntl.tsx","../src/react/IntlContext.tsx","../src/react/useIntlContext.tsx","../src/react/useNow.tsx","../src/react/useIntl.tsx","../src/react/IntlProvider.tsx","../src/core/createTranslator.tsx","../src/core/createTranslatorImpl.tsx","../src/react/useFormatter.tsx","../src/react/useLocale.tsx","../src/react/useMessages.tsx","../src/react/useTimeZone.tsx","../src/react/useTranslations.tsx","../src/react/useTranslationsImpl.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n","// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat, {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n const mfDateDefaults = IntlMessageFormat.formats.date as Formats['dateTime'];\n const defaultDateFormats = timeZone\n ? setTimeZoneInFormats(mfDateDefaults, timeZone)\n : mfDateDefaults;\n\n const mfTimeDefaults = IntlMessageFormat.formats.time as Formats['dateTime'];\n const defaultTimeFormats = timeZone\n ? setTimeZoneInFormats(mfTimeDefaults, timeZone)\n : mfTimeDefaults;\n\n return {\n ...formatsWithTimeZone,\n date: {\n ...defaultDateFormats,\n ...formatsWithTimeZone?.dateTime\n },\n time: {\n ...defaultTimeFormats,\n ...formatsWithTimeZone?.dateTime\n }\n };\n}\n","import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n","// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport MessageFormatCache from './MessageFormatCache';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nfunction getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages?: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n messageFormatCache?: MessageFormatCache;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nfunction getPlainMessage(candidate: string, values?: unknown) {\n if (values) return undefined;\n\n const unescapedMessage = candidate.replace(/'([{}])/gi, '$1');\n\n // Placeholders can be in the message if there are default values,\n // or if the user has forgotten to provide values. In the latter\n // case we need to compile the message to receive an error.\n const hasPlaceholders = /<|{/.test(unescapedMessage);\n\n if (!hasPlaceholders) {\n return unescapedMessage;\n }\n\n return undefined;\n}\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(config: Omit<CreateBaseTranslatorProps<Messages>, 'messagesOrError'>) {\n const messagesOrError = getMessagesOrError({\n messages: config.messages,\n namespace: config.namespace,\n onError: config.onError\n }) as Messages | IntlError;\n\n return createBaseTranslatorImpl<Messages, NestedKey>({\n ...config,\n messagesOrError\n });\n}\n\nfunction createBaseTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messageFormatCache,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([locale, namespace, key, String(message)]);\n\n let messageFormat: IntlMessageFormat;\n if (messageFormatCache?.has(cacheKey)) {\n messageFormat = messageFormatCache.get(cacheKey)!;\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an object, but only strings are supported. Use a \\`.\\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n // Hot path that avoids creating an `IntlMessageFormat` instance\n const plainMessage = getPlainMessage(message as string, values);\n if (plainMessage) return plainMessage;\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n messageFormatCache?.set(cacheKey, messageFormat);\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n","/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n","import IntlConfig from './IntlConfig';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport validateMessages from './validateMessages';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function initializeConfig<\n // This is a generic to allow for stricter typing. E.g.\n // the RSC integration always provides a `now` value.\n Props extends Omit<IntlConfig, 'children'>\n>({getMessageFallback, messages, onError, ...rest}: Props) {\n const finalOnError = onError || defaultOnError;\n const finalGetMessageFallback =\n getMessageFallback || defaultGetMessageFallback;\n\n if (process.env.NODE_ENV !== 'production') {\n if (messages) {\n validateMessages(messages, finalOnError);\n }\n }\n\n return {\n ...rest,\n messages,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback\n };\n}\n","import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n","import {createContext} from 'react';\nimport {InitializedIntlConfig} from '../core/IntlConfig';\nimport MessageFormatCache from '../core/MessageFormatCache';\n\nconst IntlContext = createContext<\n | (InitializedIntlConfig & {\n messageFormatCache?: MessageFormatCache;\n })\n | undefined\n>(undefined);\n\nexport default IntlContext;\n","import {useContext} from 'react';\nimport IntlContext from './IntlContext';\n\nexport default function useIntlContext() {\n const context = useContext(IntlContext);\n\n if (!context) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? 'No intl context found. Have you configured the provider?'\n : undefined\n );\n }\n\n return context;\n}\n","import {useState, useEffect} from 'react';\nimport useIntlContext from './useIntlContext';\n\ntype Options = {\n updateInterval?: number;\n};\n\nfunction getNow() {\n return new Date();\n}\n\n/**\n * Reading the current date via `new Date()` in components should be avoided, as\n * it causes components to be impure and can lead to flaky tests. Instead, this\n * hook can be used.\n *\n * By default, it returns the time when the component mounts. If `updateInterval`\n * is specified, the value will be updated based on the interval.\n *\n * You can however also return a static value from this hook, if you\n * configure the `now` parameter on the context provider. Note however,\n * that if `updateInterval` is configured in this case, the component\n * will initialize with the global value, but will afterwards update\n * continuously based on the interval.\n *\n * For unit tests, this can be mocked to a constant value. For end-to-end\n * testing, an environment parameter can be passed to the `now` parameter\n * of the provider to mock this to a static value.\n */\nexport default function useNow(options?: Options) {\n const updateInterval = options?.updateInterval;\n\n const {now: globalNow} = useIntlContext();\n const [now, setNow] = useState(globalNow || getNow());\n\n useEffect(() => {\n if (!updateInterval) return;\n\n const intervalId = setInterval(() => {\n setNow(getNow());\n }, updateInterval);\n\n return () => {\n clearInterval(intervalId);\n };\n }, [globalNow, updateInterval]);\n\n return now;\n}\n","import {useMemo} from 'react';\nimport createIntl from '../core/createIntl';\nimport useIntlContext from './useIntlContext';\n\nlet hasWarned = false;\n\n/** @deprecated Switch to `useFormatter` instead. */\nexport default function useIntl() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n if (!hasWarned) {\n hasWarned = true;\n console.warn(\n '`useIntl()` is deprecated and will be removed in the next major version. Please switch to `useFormatter()`.'\n );\n }\n\n return useMemo(\n () =>\n createIntl({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n","import React, {ReactNode, useState} from 'react';\nimport IntlConfig from '../core/IntlConfig';\nimport initializeConfig from '../core/initializeConfig';\nimport IntlContext from './IntlContext';\n\ntype Props = IntlConfig & {\n children: ReactNode;\n};\n\nexport default function IntlProvider({children, ...config}: Props) {\n const [messageFormatCache] = useState(() => new Map());\n\n return (\n <IntlContext.Provider\n value={{\n ...initializeConfig(config),\n messageFormatCache\n }}\n >\n {children}\n </IntlContext.Provider>\n );\n}\n","import Formats from './Formats';\nimport IntlConfig from './IntlConfig';\nimport TranslationValues, {\n RichTranslationValuesPlain\n} from './TranslationValues';\nimport createTranslatorImpl from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n onError = defaultOnError,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: NonNullable<IntlConfig<IntlMessages>['messages']>;\n namespace?: NestedKey;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValuesPlain,\n formats?: Partial<Formats>\n ): string;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n","import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {\n RichTranslationValues,\n RichTranslationValuesPlain\n} from './TranslationValues';\nimport createBaseTranslator from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CreateTranslatorImplProps<Messages> = Omit<\n InitializedIntlConfig,\n 'messages'\n> & {\n namespace: string;\n messages: Messages;\n};\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messages,\n namespace\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: RichTranslationValuesPlain,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n process.env.NODE_ENV !== 'production'\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n","import {useMemo} from 'react';\nimport createFormatter from '../core/createFormatter';\nimport useIntlContext from './useIntlContext';\n\nexport default function useFormatter() {\n const {formats, locale, now: globalNow, onError, timeZone} = useIntlContext();\n\n return useMemo(\n () =>\n createFormatter({\n formats,\n locale,\n now: globalNow,\n onError,\n timeZone\n }),\n [formats, globalNow, locale, onError, timeZone]\n );\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useLocale() {\n return useIntlContext().locale;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useMessages() {\n return useIntlContext().messages;\n}\n","import useIntlContext from './useIntlContext';\n\nexport default function useTimeZone() {\n return useIntlContext().timeZone;\n}\n","import {ReactElement, ReactNodeArray} from 'react';\nimport Formats from '../core/Formats';\nimport TranslationValues, {\n RichTranslationValues\n} from '../core/TranslationValues';\nimport MessageKeys from '../core/utils/MessageKeys';\nimport NamespaceKeys from '../core/utils/NamespaceKeys';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport NestedValueOf from '../core/utils/NestedValueOf';\nimport useIntlContext from './useIntlContext';\nimport useTranslationsImpl from './useTranslationsImpl';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function useTranslations<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>(\n namespace?: NestedKey\n): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: RichTranslationValues,\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n const context = useIntlContext();\n const messages = context.messages as IntlMessages;\n\n // We have to wrap the actual hook so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return useTranslationsImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {'!': messages},\n // @ts-ignore\n namespace ? `!.${namespace}` : '!',\n '!'\n );\n}\n","import {useMemo} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator from '../core/createBaseTranslator';\nimport resolveNamespace from '../core/resolveNamespace';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport useIntlContext from './useIntlContext';\n\nexport default function useTranslationsImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n messageFormatCache,\n onError,\n timeZone\n } = useIntlContext();\n\n // The `namespacePrefix` is part of the type system.\n // See the comment in the hook invocation.\n allMessages = allMessages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translate = useMemo(\n () =>\n createBaseTranslator({\n messageFormatCache,\n getMessageFallback,\n messages: allMessages,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n messageFormatCache,\n getMessageFallback,\n allMessages,\n namespace,\n onError,\n defaultTranslationValues,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["IntlErrorCode","IntlError","_Error","code","originalMessage","_this","message","call","this","_wrapNativeSuper","Error","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","defaultGetMessageFallback","props","namespace","filter","part","join","defaultOnError","error","console","resolvePath","messages","undefined","split","forEach","next","createBaseTranslator","config","_ref2","defaultTranslationValues","globalFormats","_ref2$getMessageFallb","getMessageFallback","locale","messageFormatCache","messagesOrError","onError","getFallbackFromErrorAndNotify","translateBaseFn","values","MISSING_MESSAGE","messageFormat","cacheKey","String","has","get","Array","isArray","INVALID_MESSAGE","INSUFFICIENT_PATH","errorMessage","plainMessage","candidate","unescapedMessage","replace","test","getPlainMessage","IntlMessageFormat","formatsWithTimeZone","dateTime","mfDateDefaults","date","defaultDateFormats","mfTimeDefaults","time","defaultTimeFormats","convertFormatsToIntlMessageFormat","set","formattedMessage","format","length","transformedValues","index","value","chunks","result","isValidElement","cloneElement","prepareTranslationValues","FORMATTING_ERROR","translateFn","rich","raw","createBaseTranslatorImpl","_ref","_ref$onError","retrievedMessages","intlError","getMessagesOrError","resolveNamespace","namespacePrefix","slice","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","createFormatter","globalNow","now","getFormattedValue","formatOrOptions","typeFormats","formatter","options","MISSING_FORMAT","resolveFormatOrOptions","_options","Intl","DateTimeFormat","number","NumberFormat","relativeTime","dateDate","Date","nowDate","_getRelativeTimeForma","seconds","unit","absValue","Math","abs","round","getRelativeTimeFormatConfig","getTime","RelativeTimeFormat","numeric","list","ListFormat","initializeConfig","_objectWithoutPropertiesLoose","_excluded","createIntl","apply","arguments","formatDateTime","formatNumber","formatRelativeTime","IntlContext","createContext","useIntlContext","context","useContext","getNow","hasWarned","children","useState","Map","React","createElement","Provider","_ref$getMessageFallba","rest","translator","originalRich","base","createTranslatorImpl","_useIntlContext","useMemo","warn","updateInterval","_useState","setNow","useEffect","intervalId","setInterval","clearInterval","allMessages","useTranslationsImpl"],"mappings":"uMAAYA,giDAAAA,QAOXA,mBAAA,GAPWA,EAAAA,wBAAAA,QAAAA,cAOX,CAAA,IANC,gBAAA,kBACAA,EAAA,eAAA,iBACAA,EAAA,kBAAA,oBACAA,EAAA,gBAAA,kBACAA,EAAA,YAAA,cACAA,EAAA,iBAAA,mBAGmBC,IAAAA,WAAUC,WAI7B,SAAAD,EAAYE,EAAqBC,GAAwB,IAAAC,EACnDC,EAAkBH,EASrB,OARGC,IACFE,GAAW,KAAOF,IAEpBC,EAAAH,EAAAK,KAAAC,KAAMF,IAAQE,MARAL,UAAI,EAAAE,EACJD,qBAAe,EAS7BC,EAAKF,KAAO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} from './core/use-intl.
|
|
2
|
-
export { default as createTranslator } from './core/use-intl.
|
|
3
|
-
export { default as createBaseTranslator } from './core/use-intl.
|
|
1
|
+
export { default as IntlError, IntlErrorCode } from './core/use-intl.esm.js';
|
|
2
|
+
export { default as createTranslator } from './core/use-intl.esm3.js';
|
|
3
|
+
export { default as createBaseTranslator } from './core/use-intl.esm2.js';
|
|
4
4
|
export { default as createFormatter } from './core/use-intl.esm6.js';
|
|
5
5
|
export { default as initializeConfig } from './core/use-intl.esm5.js';
|
|
6
|
-
export { default as createIntl } from './core/use-intl.
|
|
6
|
+
export { default as createIntl } from './core/use-intl.esm4.js';
|
|
7
7
|
export { default as IntlProvider } from './react/use-intl.esm4.js';
|
|
8
8
|
export { default as useTranslations } from './react/use-intl.esm.js';
|
|
9
|
-
export { default as useLocale } from './react/use-intl.
|
|
10
|
-
export { default as useNow } from './react/use-intl.
|
|
11
|
-
export { default as useTimeZone } from './react/use-intl.
|
|
12
|
-
export { default as useMessages } from './react/use-intl.
|
|
13
|
-
export { default as useFormatter } from './react/use-intl.
|
|
14
|
-
export { default as useIntl } from './react/use-intl.
|
|
9
|
+
export { default as useLocale } from './react/use-intl.esm2.js';
|
|
10
|
+
export { default as useNow } from './react/use-intl.esm6.js';
|
|
11
|
+
export { default as useTimeZone } from './react/use-intl.esm7.js';
|
|
12
|
+
export { default as useMessages } from './react/use-intl.esm8.js';
|
|
13
|
+
export { default as useFormatter } from './react/use-intl.esm5.js';
|
|
14
|
+
export { default as useIntl } from './react/use-intl.esm3.js';
|
|
15
15
|
//# sourceMappingURL=use-intl.esm.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createIntl-8a2b87eb.js","sources":["../src/core/IntlError.tsx","../src/core/convertFormatsToIntlMessageFormat.tsx","../src/core/defaults.tsx","../src/core/createBaseTranslator.tsx","../src/core/resolveNamespace.tsx","../src/core/createFormatter.tsx","../src/core/validateMessages.tsx","../src/core/initializeConfig.tsx","../src/core/createIntl.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n","import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n","import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n","// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nfunction getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages?: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(config: Omit<CreateBaseTranslatorProps<Messages>, 'messagesOrError'>) {\n const messagesOrError = getMessagesOrError({\n messages: config.messages,\n namespace: config.namespace,\n onError: config.onError\n }) as Messages | IntlError;\n\n return createBaseTranslatorImpl<Messages, NestedKey>({\n ...config,\n messagesOrError\n });\n}\n\nfunction createBaseTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n cachedFormatsByLocale,\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([namespace, key, String(message)]);\n\n let messageFormat;\n if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale?.[locale][cacheKey];\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an object, but only strings are supported. Use a \\`.\\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n if (cachedFormatsByLocale) {\n if (!cachedFormatsByLocale[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n","/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n","import AbstractIntlMessages from './AbstractIntlMessages';\nimport IntlError, {IntlErrorCode} from './IntlError';\n\nfunction validateMessagesSegment(\n messages: AbstractIntlMessages,\n invalidKeyLabels: Array<string>,\n parentPath?: string\n) {\n Object.entries(messages).forEach(([key, messageOrMessages]) => {\n if (key.includes('.')) {\n let keyLabel = key;\n if (parentPath) keyLabel += ` (at ${parentPath})`;\n invalidKeyLabels.push(keyLabel);\n }\n\n if (messageOrMessages != null && typeof messageOrMessages === 'object') {\n validateMessagesSegment(\n messageOrMessages,\n invalidKeyLabels,\n [parentPath, key].filter((part) => part != null).join('.')\n );\n }\n });\n}\n\nexport default function validateMessages(\n messages: AbstractIntlMessages,\n onError: (error: IntlError) => void\n) {\n const invalidKeyLabels: Array<string> = [];\n validateMessagesSegment(messages, invalidKeyLabels);\n\n if (invalidKeyLabels.length > 0) {\n onError(\n new IntlError(\n IntlErrorCode.INVALID_KEY,\n process.env.NODE_ENV !== 'production'\n ? `Namespace keys can not contain the character \".\" as this is used to express nesting. Please remove it or replace it with another character.\n\nInvalid ${\n invalidKeyLabels.length === 1 ? 'key' : 'keys'\n }: ${invalidKeyLabels.join(', ')}\n\nIf you're migrating from a flat structure, you can convert your messages as follows:\n\nimport {set} from \"lodash\";\n\nconst input = {\n \"one.one\": \"1.1\",\n \"one.two\": \"1.2\",\n \"two.one.one\": \"2.1.1\"\n};\n\nconst output = Object.entries(input).reduce(\n (acc, [key, value]) => set(acc, key, value),\n {}\n);\n\n// Output:\n//\n// {\n// \"one\": {\n// \"one\": \"1.1\",\n// \"two\": \"1.2\"\n// },\n// \"two\": {\n// \"one\": {\n// \"one\": \"2.1.1\"\n// }\n// }\n// }\n`\n : undefined\n )\n );\n }\n}\n","import IntlConfig from './IntlConfig';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport validateMessages from './validateMessages';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function initializeConfig<\n // This is a generic to allow for stricter typing. E.g.\n // the RSC integration always provides a `now` value.\n Props extends Omit<IntlConfig, 'children'>\n>({getMessageFallback, messages, onError, ...rest}: Props) {\n const finalOnError = onError || defaultOnError;\n const finalGetMessageFallback =\n getMessageFallback || defaultGetMessageFallback;\n\n if (process.env.NODE_ENV !== 'production') {\n if (messages) {\n validateMessages(messages, finalOnError);\n }\n }\n\n return {\n ...rest,\n messages,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback\n };\n}\n","import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"names":["IntlErrorCode","IntlError","_Error","_inheritsLoose","code","originalMessage","_this","message","call","_wrapNativeSuper","Error","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","convertFormatsToIntlMessageFormat","formatsWithTimeZone","dateTime","date","time","defaultGetMessageFallback","props","namespace","filter","part","join","defaultOnError","error","console","resolvePath","messages","split","forEach","next","prepareTranslationValues","values","length","undefined","transformedValues","index","value","transformed","chunks","result","isValidElement","cloneElement","getMessagesOrError","_ref","_ref$onError","onError","process","retrievedMessages","intlError","MISSING_MESSAGE","createBaseTranslator","config","messagesOrError","createBaseTranslatorImpl","_ref2","cachedFormatsByLocale","defaultTranslationValues","globalFormats","_ref2$getMessageFallb","getMessageFallback","locale","getFallbackFromErrorAndNotify","translateBaseFn","_cachedFormatsByLocal","joinPath","parts","cacheKey","String","messageFormat","errorMessage","Array","isArray","INVALID_MESSAGE","INSUFFICIENT_PATH","IntlMessageFormat","formattedMessage","format","FORMATTING_ERROR","translateFn","rich","raw","resolveNamespace","namespacePrefix","slice","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","Math","abs","unit","round","createFormatter","globalNow","now","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","MISSING_FORMAT","getFormattedValue","formatter","_options","Intl","DateTimeFormat","number","NumberFormat","relativeTime","dateDate","Date","nowDate","getTime","_getRelativeTimeForma","RelativeTimeFormat","numeric","list","ListFormat","validateMessagesSegment","invalidKeyLabels","parentPath","entries","messageOrMessages","includes","keyLabel","push","validateMessages","INVALID_KEY","initializeConfig","rest","_objectWithoutPropertiesLoose","_excluded","finalOnError","finalGetMessageFallback","createIntl","apply","arguments","formatDateTime","formatNumber","formatRelativeTime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAYA,+BAOX;AAPD,CAAA,UAAYA,aAAa,EAAA;AACvBA,EAAAA,aAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC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tsx","../src/core/convertFormatsToIntlMessageFormat.tsx","../src/core/defaults.tsx","../src/core/createBaseTranslator.tsx","../src/core/createFormatter.tsx","../src/core/createIntl.tsx","../src/core/initializeConfig.tsx","../src/core/resolveNamespace.tsx"],"sourcesContent":["export enum IntlErrorCode {\n MISSING_MESSAGE = 'MISSING_MESSAGE',\n MISSING_FORMAT = 'MISSING_FORMAT',\n INSUFFICIENT_PATH = 'INSUFFICIENT_PATH',\n INVALID_MESSAGE = 'INVALID_MESSAGE',\n INVALID_KEY = 'INVALID_KEY',\n FORMATTING_ERROR = 'FORMATTING_ERROR'\n}\n\nexport default class IntlError extends Error {\n public readonly code: IntlErrorCode;\n public readonly originalMessage: string | undefined;\n\n constructor(code: IntlErrorCode, originalMessage?: string) {\n let message: string = code;\n if (originalMessage) {\n message += ': ' + originalMessage;\n }\n super(message);\n\n this.code = code;\n if (originalMessage) {\n this.originalMessage = originalMessage;\n }\n }\n}\n","import {Formats as IntlFormats} from 'intl-messageformat';\nimport DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport TimeZone from './TimeZone';\n\nfunction setTimeZoneInFormats(\n formats: Record<string, DateTimeFormatOptions> | undefined,\n timeZone: TimeZone\n) {\n if (!formats) return formats;\n\n // The only way to set a time zone with `intl-messageformat` is to merge it into the formats\n // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15\n return Object.keys(formats).reduce(\n (acc: Record<string, DateTimeFormatOptions>, key) => {\n acc[key] = {\n timeZone,\n ...formats[key]\n };\n return acc;\n },\n {}\n );\n}\n\n/**\n * `intl-messageformat` uses separate keys for `date` and `time`, but there's\n * only one native API: `Intl.DateTimeFormat`. Additionally you might want to\n * include both a time and a date in a value, therefore the separation doesn't\n * seem so useful. We offer a single `dateTime` namespace instead, but we have\n * to convert the format before `intl-messageformat` can be used.\n */\nexport default function convertFormatsToIntlMessageFormat(\n formats: Partial<Formats>,\n timeZone?: TimeZone\n): Partial<IntlFormats> {\n const formatsWithTimeZone = timeZone\n ? {...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone)}\n : formats;\n\n return {\n ...formatsWithTimeZone,\n date: formatsWithTimeZone?.dateTime,\n time: formatsWithTimeZone?.dateTime\n };\n}\n","import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n","// eslint-disable-next-line import/no-named-as-default -- False positive\nimport IntlMessageFormat from 'intl-messageformat';\nimport {\n cloneElement,\n isValidElement,\n ReactElement,\n ReactNode,\n ReactNodeArray\n} from 'react';\nimport AbstractIntlMessages from './AbstractIntlMessages';\nimport Formats from './Formats';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport TranslationValues, {RichTranslationValues} from './TranslationValues';\nimport convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\nfunction resolvePath(\n messages: AbstractIntlMessages | undefined,\n key: string,\n namespace?: string\n) {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages available at \\`${namespace}\\`.`\n : undefined\n );\n }\n\n let message = messages;\n\n key.split('.').forEach((part) => {\n const next = (message as any)[part];\n\n if (part == null || next == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Could not resolve \\`${key}\\` in ${\n namespace ? `\\`${namespace}\\`` : 'messages'\n }.`\n : undefined\n );\n }\n\n message = next;\n });\n\n return message;\n}\n\nfunction prepareTranslationValues(values: RichTranslationValues) {\n if (Object.keys(values).length === 0) return undefined;\n\n // Workaround for https://github.com/formatjs/formatjs/issues/1467\n const transformedValues: RichTranslationValues = {};\n Object.keys(values).forEach((key) => {\n let index = 0;\n const value = values[key];\n\n let transformed;\n if (typeof value === 'function') {\n transformed = (chunks: ReactNode) => {\n const result = value(chunks);\n\n return isValidElement(result)\n ? cloneElement(result, {key: key + index++})\n : result;\n };\n } else {\n transformed = value;\n }\n\n transformedValues[key] = transformed;\n });\n\n return transformedValues;\n}\n\nfunction getMessagesOrError<Messages extends AbstractIntlMessages>({\n messages,\n namespace,\n onError = defaultOnError\n}: {\n messages?: Messages;\n namespace?: string;\n onError?(error: IntlError): void;\n}) {\n try {\n if (!messages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages were configured on the provider.`\n : undefined\n );\n }\n\n const retrievedMessages = namespace\n ? resolvePath(messages, namespace)\n : messages;\n\n if (!retrievedMessages) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `No messages for namespace \\`${namespace}\\` found.`\n : undefined\n );\n }\n\n return retrievedMessages;\n } catch (error) {\n const intlError = new IntlError(\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n onError(intlError);\n return intlError;\n }\n}\n\nexport type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {\n cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;\n defaultTranslationValues?: RichTranslationValues;\n namespace?: string;\n messagesOrError: Messages | IntlError;\n};\n\nexport default function createBaseTranslator<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(config: Omit<CreateBaseTranslatorProps<Messages>, 'messagesOrError'>) {\n const messagesOrError = getMessagesOrError({\n messages: config.messages,\n namespace: config.namespace,\n onError: config.onError\n }) as Messages | IntlError;\n\n return createBaseTranslatorImpl<Messages, NestedKey>({\n ...config,\n messagesOrError\n });\n}\n\nfunction createBaseTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>({\n cachedFormatsByLocale,\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback = defaultGetMessageFallback,\n locale,\n messagesOrError,\n namespace,\n onError,\n timeZone\n}: CreateBaseTranslatorProps<Messages>) {\n function getFallbackFromErrorAndNotify(\n key: string,\n code: IntlErrorCode,\n message?: string\n ) {\n const error = new IntlError(code, message);\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n function translateBaseFn(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string,\n /** Key value pairs for values to interpolate into the message. */\n values?: RichTranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string | ReactElement | ReactNodeArray {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n let message;\n try {\n message = resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n\n function joinPath(parts: Array<string | undefined>) {\n return parts.filter((part) => part != null).join('.');\n }\n\n const cacheKey = joinPath([namespace, key, String(message)]);\n\n let messageFormat;\n if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {\n messageFormat = cachedFormatsByLocale?.[locale][cacheKey];\n } else {\n if (typeof message === 'object') {\n let code, errorMessage;\n if (Array.isArray(message)) {\n code = IntlErrorCode.INVALID_MESSAGE;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;\n }\n } else {\n code = IntlErrorCode.INSUFFICIENT_PATH;\n if (process.env.NODE_ENV !== 'production') {\n errorMessage = `Message at \\`${joinPath([\n namespace,\n key\n ])}\\` resolved to an object, but only strings are supported. Use a \\`.\\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;\n }\n }\n\n return getFallbackFromErrorAndNotify(key, code, errorMessage);\n }\n\n try {\n messageFormat = new IntlMessageFormat(\n message,\n locale,\n convertFormatsToIntlMessageFormat(\n {...globalFormats, ...formats},\n timeZone\n )\n );\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n (error as Error).message\n );\n }\n\n if (cachedFormatsByLocale) {\n if (!cachedFormatsByLocale[locale]) {\n cachedFormatsByLocale[locale] = {};\n }\n cachedFormatsByLocale[locale][cacheKey] = messageFormat;\n }\n }\n\n try {\n const formattedMessage = messageFormat.format(\n // @ts-ignore `intl-messageformat` expects a different format\n // for rich text elements since a recent minor update. This\n // needs to be evaluated in detail, possibly also in regards\n // to be able to format to parts.\n prepareTranslationValues({...defaultTranslationValues, ...values})\n );\n\n if (formattedMessage == null) {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `Unable to format \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n }`\n : undefined\n );\n }\n\n // Limit the function signature to return strings or React elements\n return isValidElement(formattedMessage) ||\n // Arrays of React elements\n Array.isArray(formattedMessage) ||\n typeof formattedMessage === 'string'\n ? formattedMessage\n : String(formattedMessage);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.FORMATTING_ERROR,\n (error as Error).message\n );\n }\n }\n\n function translateFn<\n TargetKey extends MessageKeys<\n NestedValueOf<Messages, NestedKey>,\n NestedKeyOf<NestedValueOf<Messages, NestedKey>>\n >\n >(\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: TargetKey,\n /** Key value pairs for values to interpolate into the message. */\n values?: TranslationValues,\n /** Provide custom formats for numbers, dates and times. */\n formats?: Partial<Formats>\n ): string {\n const result = translateBaseFn(key, values, formats);\n\n if (typeof result !== 'string') {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.INVALID_MESSAGE,\n process.env.NODE_ENV !== 'production'\n ? `The message \\`${key}\\` in ${\n namespace ? `namespace \\`${namespace}\\`` : 'messages'\n } didn't resolve to a string. If you want to format rich text, use \\`t.rich\\` instead.`\n : undefined\n );\n }\n\n return result;\n }\n\n translateFn.rich = translateBaseFn;\n\n translateFn.raw = (\n /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */\n key: string\n ): any => {\n if (messagesOrError instanceof IntlError) {\n // We have already warned about this during render\n return getMessageFallback({\n error: messagesOrError,\n key,\n namespace\n });\n }\n const messages = messagesOrError;\n\n try {\n return resolvePath(messages, key, namespace);\n } catch (error) {\n return getFallbackFromErrorAndNotify(\n key,\n IntlErrorCode.MISSING_MESSAGE,\n (error as Error).message\n );\n }\n };\n\n return translateFn;\n}\n","import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n","import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n","import IntlConfig from './IntlConfig';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport validateMessages from './validateMessages';\n\n/**\n * Enhances the incoming props with defaults.\n */\nexport default function initializeConfig<\n // This is a generic to allow for stricter typing. E.g.\n // the RSC integration always provides a `now` value.\n Props extends Omit<IntlConfig, 'children'>\n>({getMessageFallback, messages, onError, ...rest}: Props) {\n const finalOnError = onError || defaultOnError;\n const finalGetMessageFallback =\n getMessageFallback || defaultGetMessageFallback;\n\n if (process.env.NODE_ENV !== 'production') {\n if (messages) {\n validateMessages(messages, finalOnError);\n }\n }\n\n return {\n ...rest,\n messages,\n onError: finalOnError,\n getMessageFallback: finalGetMessageFallback\n };\n}\n","/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n"],"names":["IntlErrorCode","IntlError","_Error","code","originalMessage","_this","message","call","this","_wrapNativeSuper","Error","setTimeZoneInFormats","formats","timeZone","Object","keys","reduce","acc","key","_extends","defaultGetMessageFallback","props","namespace","filter","part","join","defaultOnError","error","console","resolvePath","messages","undefined","split","forEach","next","DAY","HOUR","WEEK","MONTH","YEAR","createFormatter","_ref","locale","globalNow","now","_ref$onError","onError","getFormattedValue","value","formatOrOptions","typeFormats","formatter","options","MISSING_FORMAT","resolveFormatOrOptions","String","FORMATTING_ERROR","dateTime","_options","Intl","DateTimeFormat","format","number","NumberFormat","relativeTime","date","dateDate","Date","nowDate","_getRelativeTimeForma","seconds","unit","absValue","Math","abs","round","MINUTE","getRelativeTimeFormatConfig","getTime","RelativeTimeFormat","numeric","list","ListFormat","config","_ref2","cachedFormatsByLocale","defaultTranslationValues","globalFormats","_ref2$getMessageFallb","getMessageFallback","messagesOrError","getFallbackFromErrorAndNotify","translateBaseFn","values","_cachedFormatsByLocal","MISSING_MESSAGE","messageFormat","cacheKey","Array","isArray","INVALID_MESSAGE","INSUFFICIENT_PATH","errorMessage","IntlMessageFormat","formatsWithTimeZone","time","convertFormatsToIntlMessageFormat","formattedMessage","length","transformedValues","index","chunks","result","isValidElement","cloneElement","prepareTranslationValues","translateFn","rich","raw","createBaseTranslatorImpl","retrievedMessages","intlError","getMessagesOrError","apply","arguments","formatDateTime","formatNumber","formatRelativeTime","_objectWithoutPropertiesLoose","_excluded","namespacePrefix","slice"],"mappings":"gJAAYA,yhDAAAA,QAOXA,mBAAA,GAPWA,EAAAA,wBAAAA,QAAAA,cAOX,CAAA,IANC,gBAAA,kBACAA,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