react-intl 10.1.20 → 10.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +13 -13
- package/index.js +7 -4
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/react-intl.iife.js +22 -19
- package/server.d.ts +4 -4
- package/server.js +2 -1
- package/server.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ interface IntlShape extends ResolvedIntlConfig, IntlFormatters$1<React.ReactNode
|
|
|
67
67
|
* @param config intl config
|
|
68
68
|
* @param cache cache for formatter instances to prevent memory leak
|
|
69
69
|
*/
|
|
70
|
-
declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
|
|
70
|
+
export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region packages/react-intl/components/context.d.ts
|
|
73
73
|
declare const IntlContext: React.Context<IntlShape>;
|
|
@@ -126,44 +126,44 @@ type Formatter = {
|
|
|
126
126
|
formatList: FormatListOptions$1;
|
|
127
127
|
formatDisplayName: FormatDisplayNameOptions$1;
|
|
128
128
|
};
|
|
129
|
-
declare const FormattedNumberParts: React.FC<Formatter["formatNumber"] & {
|
|
129
|
+
export declare const FormattedNumberParts: React.FC<Formatter["formatNumber"] & {
|
|
130
130
|
value: Parameters<IntlShape["formatNumber"]>[0];
|
|
131
131
|
children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
|
|
132
132
|
}>;
|
|
133
|
-
declare const FormattedListParts: React.FC<Formatter["formatList"] & {
|
|
133
|
+
export declare const FormattedListParts: React.FC<Formatter["formatList"] & {
|
|
134
134
|
value: Parameters<IntlShape["formatList"]>[0];
|
|
135
135
|
children(val: ReturnType<Intl.ListFormat["formatToParts"]>): React.ReactElement | null;
|
|
136
136
|
}>;
|
|
137
137
|
//#endregion
|
|
138
138
|
//#region packages/react-intl/index.d.ts
|
|
139
|
-
declare function defineMessages<K extends keyof any, T = MessageDescriptor$1, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
140
|
-
declare function defineMessage<T extends MessageDescriptor$1>(msg: T): T;
|
|
141
|
-
declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig$1<"date"> & {
|
|
139
|
+
export declare function defineMessages<K extends keyof any, T = MessageDescriptor$1, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
140
|
+
export declare function defineMessage<T extends MessageDescriptor$1>(msg: T): T;
|
|
141
|
+
export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig$1<"date"> & {
|
|
142
142
|
value: string | number | Date | undefined;
|
|
143
143
|
children?(formattedDate: string): React.ReactElement | null;
|
|
144
144
|
}>;
|
|
145
|
-
declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig$1<"time"> & {
|
|
145
|
+
export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig$1<"time"> & {
|
|
146
146
|
value: string | number | Date | undefined;
|
|
147
147
|
children?(formattedTime: string): React.ReactElement | null;
|
|
148
148
|
}>;
|
|
149
|
-
declare const FormattedNumber: React.FC<Omit<NumberFormatOptions, "localeMatcher"> & CustomFormatConfig$1<"number"> & {
|
|
149
|
+
export declare const FormattedNumber: React.FC<Omit<NumberFormatOptions, "localeMatcher"> & CustomFormatConfig$1<"number"> & {
|
|
150
150
|
value: Parameters<IntlShape["formatNumber"]>[0];
|
|
151
151
|
children?(formattedNumber: string): React.ReactElement | null;
|
|
152
152
|
}>;
|
|
153
|
-
declare const FormattedList: React.FC<Intl.ListFormatOptions & {
|
|
153
|
+
export declare const FormattedList: React.FC<Intl.ListFormatOptions & {
|
|
154
154
|
value: Parameters<IntlShape["formatList"]>[0];
|
|
155
155
|
}>;
|
|
156
|
-
declare const FormattedDisplayName: React.FC<Intl.DisplayNamesOptions & {
|
|
156
|
+
export declare const FormattedDisplayName: React.FC<Intl.DisplayNamesOptions & {
|
|
157
157
|
value: string;
|
|
158
158
|
}>;
|
|
159
|
-
declare const FormattedDateParts: React.FC<FormatDateOptions$1 & {
|
|
159
|
+
export declare const FormattedDateParts: React.FC<FormatDateOptions$1 & {
|
|
160
160
|
value: Parameters<Intl.DateTimeFormat["format"]>[0] | string;
|
|
161
161
|
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
162
162
|
}>;
|
|
163
|
-
declare const FormattedTimeParts: React.FC<FormatTimeOptions & {
|
|
163
|
+
export declare const FormattedTimeParts: React.FC<FormatTimeOptions & {
|
|
164
164
|
value: Parameters<Intl.DateTimeFormat["format"]>[0] | string;
|
|
165
165
|
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
|
|
166
166
|
}>;
|
|
167
167
|
//#endregion
|
|
168
|
-
export { type CustomFormatConfig, type CustomFormats, type FormatDateOptions, type FormatDisplayNameOptions, type FormatListOptions, type FormatNumberOptions, type FormatPluralOptions, type FormatRelativeTimeOptions,
|
|
168
|
+
export { type CustomFormatConfig, type CustomFormats, type FormatDateOptions, type FormatDisplayNameOptions, type FormatListOptions, type FormatNumberOptions, type FormatPluralOptions, type FormatRelativeTimeOptions, FormattedDateTimeRange, MemoizedFormattedMessage as FormattedMessage, FormattedPlural, FormattedRelativeTime, type Formatters, type IntlCache, type IntlConfig, IntlContext, type IntlFormatters, IntlProvider, type IntlShape, InvalidConfigError, type MessageDescriptor, type MessageFormatElement, MessageFormatError, MissingDataError, MissingTranslationError, type PrimitiveType, Provider as RawIntlProvider, ReactIntlError, ReactIntlErrorCode, type ResolvedIntlConfig, UnsupportedFormatterError, createIntlCache, useIntl };
|
|
169
169
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -110,7 +110,8 @@ function createFormattedComponent(name) {
|
|
|
110
110
|
const { value, children, ...formatProps } = props;
|
|
111
111
|
const formattedValue = intl[name](value, formatProps);
|
|
112
112
|
if (typeof children === "function") return children(formattedValue);
|
|
113
|
-
|
|
113
|
+
const Text = intl.textComponent || React.Fragment;
|
|
114
|
+
return /* @__PURE__ */ jsx(Text, { children: formattedValue });
|
|
114
115
|
};
|
|
115
116
|
Component.displayName = DisplayName[name];
|
|
116
117
|
return Component;
|
|
@@ -126,7 +127,8 @@ function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
|
126
127
|
}, {});
|
|
127
128
|
}
|
|
128
129
|
const formatMessage$1 = (config, formatters, descriptor, rawValues, ...rest) => {
|
|
129
|
-
const
|
|
130
|
+
const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
|
|
131
|
+
const chunks = formatMessage(config, formatters, descriptor, values, ...rest);
|
|
130
132
|
if (Array.isArray(chunks)) return toKeyedReactNodeArray(chunks);
|
|
131
133
|
return chunks;
|
|
132
134
|
};
|
|
@@ -166,7 +168,8 @@ const FormattedDateTimeRange = (props) => {
|
|
|
166
168
|
const { from, to, children, ...formatProps } = props;
|
|
167
169
|
const formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
|
168
170
|
if (typeof children === "function") return children(formattedValue);
|
|
169
|
-
|
|
171
|
+
const Text = intl.textComponent || React.Fragment;
|
|
172
|
+
return /* @__PURE__ */ jsx(Text, { children: formattedValue });
|
|
170
173
|
};
|
|
171
174
|
FormattedDateTimeRange.displayName = "FormattedDateTimeRange";
|
|
172
175
|
//#endregion
|
|
@@ -246,7 +249,7 @@ const IntlProvider = IntlProviderImpl;
|
|
|
246
249
|
//#region packages/react-intl/components/relative.tsx
|
|
247
250
|
const MINUTE = 60;
|
|
248
251
|
const HOUR = 3600;
|
|
249
|
-
const DAY =
|
|
252
|
+
const DAY = 86400;
|
|
250
253
|
function selectUnit(seconds) {
|
|
251
254
|
const absValue = Math.abs(seconds);
|
|
252
255
|
if (absValue < MINUTE) return "second";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DEFAULT_INTL_CONFIG","CORE_DEFAULT_INTL_CONFIG","Context","formatMessage","coreFormatMessage","coreCreateIntl","DEFAULT_INTL_CONFIG","createIntlCache","DEFAULT_INTL_CONFIG"],"sources":["../utils.tsx","../components/context.ts","../components/useIntl.ts","../components/createFormattedComponent.tsx","../components/createIntl.ts","../components/dateTimeRange.tsx","../components/message.tsx","../components/plural.tsx","../components/provider.tsx","../components/relative.tsx","../index.ts"],"sourcesContent":["import {type FormatXMLElementFn} from 'intl-messageformat'\nimport * as React from 'react'\nimport {type ResolvedIntlConfig} from '#packages/react-intl/types.js'\n\nimport {DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG} from '@formatjs/intl'\n\nexport function invariant(\n condition: boolean,\n message: string,\n Err: any = Error\n): asserts condition {\n if (!condition) {\n throw new Err(message)\n }\n}\n\nexport function invariantIntlContext(intl?: any): asserts intl {\n invariant(\n intl,\n '[React Intl] Could not find required `intl` object. ' +\n '<IntlProvider> needs to exist in the component ancestry.'\n )\n}\n\nexport type DefaultIntlConfig = Pick<\n ResolvedIntlConfig,\n | 'fallbackOnEmptyString'\n | 'formats'\n | 'messages'\n | 'timeZone'\n | 'textComponent'\n | 'defaultLocale'\n | 'defaultFormats'\n | 'onError'\n>\n\nexport const DEFAULT_INTL_CONFIG: DefaultIntlConfig = {\n ...CORE_DEFAULT_INTL_CONFIG,\n textComponent: React.Fragment,\n}\n\n/**\n * Builds an array of {@link React.ReactNode}s with index-based keys, similar to\n * {@link React.Children.toArray}. However, this function tells React that it\n * was intentional, so they won't produce a bunch of warnings about it.\n *\n * React doesn't recommend doing this because it makes reordering inefficient,\n * but we mostly need this for message chunks, which don't tend to reorder to\n * begin with.\n *\n */\nexport const toKeyedReactNodeArray: typeof React.Children.toArray =\n children => {\n const childrenArray = React.Children.toArray(children)\n\n return childrenArray.map((child, index) => {\n // For React elements, wrap in a keyed Fragment\n // This creates a new element with a key rather than trying to add one after creation\n if (React.isValidElement(child)) {\n return <React.Fragment key={index}>{child}</React.Fragment>\n }\n return child\n })\n }\n\n/**\n * Takes a `formatXMLElementFn`, and composes it in function, which passes\n * argument `parts` through, assigning unique key to each part, to prevent\n * \"Each child in a list should have a unique \"key\"\" React error.\n * @param formatXMLElementFn\n */\nexport function assignUniqueKeysToParts(\n formatXMLElementFn: FormatXMLElementFn<React.ReactNode>\n): FormatXMLElementFn<React.ReactNode> {\n return function (parts: any) {\n // eslint-disable-next-line prefer-rest-params\n return formatXMLElementFn(toKeyedReactNodeArray(parts)) as any\n }\n}\n\nexport function shallowEqual<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(objA?: T, objB?: T): boolean {\n if (objA === objB) {\n return true\n }\n\n if (!objA || !objB) {\n return false\n }\n\n var aKeys = Object.keys(objA)\n var bKeys = Object.keys(objB)\n var len = aKeys.length\n\n if (bKeys.length !== len) {\n return false\n }\n\n for (var i = 0; i < len; i++) {\n var key = aKeys[i]\n\n if (\n objA[key] !== objB[key] ||\n !Object.prototype.hasOwnProperty.call(objB, key)\n ) {\n return false\n }\n }\n\n return true\n}\n","import * as React from 'react'\nimport {type IntlShape} from '#packages/react-intl/types.js'\n\nconst IntlContext: React.Context<IntlShape> = React.createContext<IntlShape>(\n null as any\n)\nconst Provider: React.Provider<IntlShape> = IntlContext.Provider\n\nexport {Provider, IntlContext as Context}\n","import * as React from 'react'\nimport {type IntlShape} from '#packages/react-intl/types.js'\nimport {invariantIntlContext} from '#packages/react-intl/utils.js'\nimport {Context} from '#packages/react-intl/components/context.js'\n\nexport default function useIntl(this: void): IntlShape {\n const intl = React.useContext(Context)\n invariantIntlContext(intl)\n return intl\n}\n","import {\n type FormatDateOptions,\n type FormatDisplayNameOptions,\n type FormatListOptions,\n type FormatNumberOptions,\n} from '@formatjs/intl'\nimport * as React from 'react'\nimport {type IntlShape} from '#packages/react-intl/types.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\nenum DisplayName {\n formatDate = 'FormattedDate',\n formatTime = 'FormattedTime',\n formatNumber = 'FormattedNumber',\n formatList = 'FormattedList',\n // Note that this DisplayName is the locale display name, not to be confused with\n // the name of the enum, which is for React component display name in dev tools.\n formatDisplayName = 'FormattedDisplayName',\n}\n\nenum DisplayNameParts {\n formatDate = 'FormattedDateParts',\n formatTime = 'FormattedTimeParts',\n formatNumber = 'FormattedNumberParts',\n formatList = 'FormattedListParts',\n}\n\ntype Formatter = {\n formatDate: FormatDateOptions\n formatTime: FormatDateOptions\n formatNumber: FormatNumberOptions\n formatList: FormatListOptions\n formatDisplayName: FormatDisplayNameOptions\n}\n\nexport const FormattedNumberParts: React.FC<\n Formatter['formatNumber'] & {\n value: Parameters<IntlShape['formatNumber']>[0]\n\n children(val: Intl.NumberFormatPart[]): React.ReactElement | null\n }\n> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n return children(intl.formatNumberToParts(value, formatProps))\n}\nFormattedNumberParts.displayName = 'FormattedNumberParts'\n\nexport const FormattedListParts: React.FC<\n Formatter['formatList'] & {\n value: Parameters<IntlShape['formatList']>[0]\n\n children(\n val: ReturnType<Intl.ListFormat['formatToParts']>\n ): React.ReactElement | null\n }\n> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n return children(intl.formatListToParts(value, formatProps))\n}\nFormattedListParts.displayName = 'FormattedListParts'\n\nexport function createFormattedDateTimePartsComponent<\n Name extends 'formatDate' | 'formatTime',\n>(\n name: Name\n): React.FC<\n Formatter[Name] & {\n value: Parameters<IntlShape[Name]>[0]\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n> {\n type FormatFn = IntlShape[Name]\n type Props = Formatter[Name] & {\n value: Parameters<FormatFn>[0]\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n\n const ComponentParts: React.FC<Props> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n const date = typeof value === 'string' ? new Date(value || 0) : value\n const formattedParts: Intl.DateTimeFormatPart[] =\n name === 'formatDate'\n ? intl.formatDateToParts(date, formatProps)\n : intl.formatTimeToParts(date, formatProps)\n\n return children(formattedParts)\n }\n ComponentParts.displayName = DisplayNameParts[name]\n return ComponentParts\n}\n\nexport function createFormattedComponent<Name extends keyof Formatter>(\n name: Name\n): React.FC<\n Formatter[Name] & {\n value: Parameters<IntlShape[Name]>[0]\n children?(val: string): React.ReactElement | null\n }\n> {\n type FormatFn = IntlShape[Name]\n type Props = Formatter[Name] & {\n value: Parameters<FormatFn>[0]\n children?(val: string): React.ReactElement | null\n }\n\n const Component: React.FC<Props> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n // TODO: fix TS type definition for localeMatcher upstream\n const formattedValue = intl[name](value as never, formatProps as any)\n\n if (typeof children === 'function') {\n return children(formattedValue as any)\n }\n const Text = intl.textComponent || React.Fragment\n return <Text>{formattedValue}</Text>\n }\n\n Component.displayName = DisplayName[name]\n return Component\n}\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport {\n type CreateIntlFn,\n type FormatMessageFn,\n createIntl as coreCreateIntl,\n formatMessage as coreFormatMessage,\n} from '@formatjs/intl'\nimport {\n type FormatXMLElementFn,\n type PrimitiveType,\n isFormatXMLElementFn,\n} from 'intl-messageformat'\nimport * as React from 'react'\nimport type {\n IntlConfig,\n IntlShape,\n ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\nimport {\n DEFAULT_INTL_CONFIG,\n assignUniqueKeysToParts,\n toKeyedReactNodeArray,\n} from '#packages/react-intl/utils.js'\n\nfunction assignUniqueKeysToFormatXMLElementFnArgument<\n T extends Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n > = Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n >,\n>(values?: T): T | undefined {\n if (!values) {\n return values\n }\n return Object.keys(values).reduce((acc: T, k) => {\n const v = values[k]\n ;(acc as any)[k] = isFormatXMLElementFn<React.ReactNode>(v)\n ? assignUniqueKeysToParts(v)\n : v\n return acc\n }, {} as T)\n}\n\nconst formatMessage: FormatMessageFn<React.ReactNode> = (\n config,\n formatters,\n descriptor,\n rawValues,\n ...rest\n) => {\n const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues)\n const chunks = coreFormatMessage(\n config,\n formatters,\n descriptor,\n values as any,\n ...rest\n )\n if (Array.isArray(chunks)) {\n return toKeyedReactNodeArray(chunks)\n }\n return chunks\n}\n\n/**\n * Create intl object\n * @param config intl config\n * @param cache cache for formatter instances to prevent memory leak\n */\nexport const createIntl: CreateIntlFn<\n React.ReactNode,\n IntlConfig,\n IntlShape\n> = (\n {defaultRichTextElements: rawDefaultRichTextElements, ...config},\n cache\n) => {\n const defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(\n rawDefaultRichTextElements\n )\n const coreIntl = coreCreateIntl<React.ReactNode>(\n {\n ...DEFAULT_INTL_CONFIG,\n ...config,\n defaultRichTextElements,\n },\n cache\n )\n\n const resolvedConfig: ResolvedIntlConfig = {\n locale: coreIntl.locale,\n timeZone: coreIntl.timeZone,\n fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,\n formats: coreIntl.formats,\n defaultLocale: coreIntl.defaultLocale,\n defaultFormats: coreIntl.defaultFormats,\n messages: coreIntl.messages,\n onError: coreIntl.onError,\n defaultRichTextElements,\n }\n\n return {\n ...coreIntl,\n formatMessage: formatMessage.bind(\n null,\n resolvedConfig,\n coreIntl.formatters\n ),\n $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters),\n } as any\n}\n","import {type FormatDateTimeRangeOptions} from '@formatjs/intl'\nimport * as React from 'react'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\ninterface Props extends FormatDateTimeRangeOptions {\n from: Parameters<Intl.DateTimeFormat['formatRange']>[0]\n to: Parameters<Intl.DateTimeFormat['formatRange']>[1]\n children?(value: React.ReactNode): React.ReactElement | null\n}\n\nconst FormattedDateTimeRange: React.FC<Props> = props => {\n const intl = useIntl()\n\n const {from, to, children, ...formatProps} = props\n const formattedValue = intl.formatDateTimeRange(from, to, formatProps)\n\n if (typeof children === 'function') {\n return children(formattedValue as any)\n }\n const Text = intl.textComponent || React.Fragment\n return <Text>{formattedValue}</Text>\n}\n\nFormattedDateTimeRange.displayName = 'FormattedDateTimeRange'\nexport default FormattedDateTimeRange\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport type {\n FormatXMLElementFn,\n Options as IntlMessageFormatOptions,\n PrimitiveType,\n} from 'intl-messageformat'\nimport * as React from 'react'\n\nimport {type MessageDescriptor} from '@formatjs/intl'\nimport {shallowEqual} from '#packages/react-intl/utils.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\nexport interface Props<\n V extends Record<string, any> = Record<\n string,\n React.ReactNode | PrimitiveType | FormatXMLElementFn<React.ReactNode>\n >,\n> extends MessageDescriptor {\n values?: V\n tagName?: React.ElementType<any>\n children?(nodes: React.ReactNode[]): React.ReactNode | null\n ignoreTag?: IntlMessageFormatOptions['ignoreTag']\n}\n\nfunction areEqual(prevProps: Props, nextProps: Props): boolean {\n const {values, ...otherProps} = prevProps\n const {values: nextValues, ...nextOtherProps} = nextProps\n return (\n shallowEqual(nextValues, values) &&\n shallowEqual(otherProps as any, nextOtherProps)\n )\n}\n\nfunction FormattedMessage(props: Props) {\n const intl = useIntl()\n const {formatMessage, textComponent: Text = React.Fragment} = intl\n const {\n id,\n description,\n defaultMessage,\n values,\n children,\n tagName: Component = Text,\n ignoreTag,\n } = props\n\n const descriptor = {id, description, defaultMessage}\n const nodes = formatMessage(descriptor, values, {\n ignoreTag,\n })\n\n if (typeof children === 'function') {\n return children(Array.isArray(nodes) ? nodes : [nodes])\n }\n\n if (Component) {\n return <Component>{nodes}</Component>\n }\n return <>{nodes}</>\n}\nFormattedMessage.displayName = 'FormattedMessage'\n\nconst MemoizedFormattedMessage: React.ComponentType<Props> = React.memo<Props>(\n FormattedMessage,\n areEqual\n)\nMemoizedFormattedMessage.displayName = 'MemoizedFormattedMessage'\n\nexport default MemoizedFormattedMessage\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport * as React from 'react'\nimport {type FormatPluralOptions} from '@formatjs/intl'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\ninterface Props extends FormatPluralOptions {\n value: number\n other: React.ReactNode\n zero?: React.ReactNode\n one?: React.ReactNode\n two?: React.ReactNode\n few?: React.ReactNode\n many?: React.ReactNode\n children?(value: React.ReactNode): React.ReactElement | null\n}\n\nconst FormattedPlural: React.FC<Props> = props => {\n const {formatPlural, textComponent: Text} = useIntl()\n const {value, other, children} = props\n\n const pluralCategory = formatPlural(value, props)\n const formattedPlural = props[pluralCategory as 'one'] || other\n\n if (typeof children === 'function') {\n return children(formattedPlural)\n }\n if (Text) {\n return <Text>{formattedPlural}</Text>\n }\n // Work around @types/react where React.FC cannot return string\n return formattedPlural as any\n}\n\nFormattedPlural.displayName = 'FormattedPlural'\n\nexport default FormattedPlural\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport {type IntlCache, createIntlCache} from '@formatjs/intl'\nimport * as React from 'react'\nimport type {IntlConfig, IntlShape} from '#packages/react-intl/types.js'\nimport {\n DEFAULT_INTL_CONFIG,\n invariantIntlContext,\n shallowEqual,\n} from '#packages/react-intl/utils.js'\nimport {createIntl} from '#packages/react-intl/components/createIntl.js'\nimport {Provider} from '#packages/react-intl/components/context.js'\n\nfunction processIntlConfig<P extends IntlConfig = IntlConfig>(\n config: P\n): IntlConfig {\n return {\n locale: config.locale,\n timeZone: config.timeZone,\n fallbackOnEmptyString: config.fallbackOnEmptyString,\n formats: config.formats,\n textComponent: config.textComponent,\n messages: config.messages,\n defaultLocale: config.defaultLocale,\n defaultFormats: config.defaultFormats,\n onError: config.onError,\n onWarn: config.onWarn,\n wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,\n defaultRichTextElements: config.defaultRichTextElements,\n }\n}\n\nfunction IntlProviderImpl(\n props: React.PropsWithChildren<IntlConfig>\n): React.JSX.Element {\n const cacheRef = React.useRef<IntlCache>(createIntlCache())\n const prevConfigRef = React.useRef<IntlConfig | undefined>(undefined)\n const intlRef = React.useRef<IntlShape | undefined>(undefined)\n\n // Filter out undefined values from props so they don't override defaults.\n // React's defaultProps treated `prop={undefined}` as \"not provided\"; we\n // replicate that behaviour here after converting to a function component.\n const filteredProps: Record<string, unknown> = {}\n for (const key in props) {\n if ((props as any)[key] !== undefined) {\n filteredProps[key] = (props as any)[key]\n }\n }\n const config = processIntlConfig({\n ...DEFAULT_INTL_CONFIG,\n ...filteredProps,\n } as IntlConfig)\n\n if (!prevConfigRef.current || !shallowEqual(prevConfigRef.current, config)) {\n prevConfigRef.current = config\n intlRef.current = createIntl(config, cacheRef.current)\n }\n\n invariantIntlContext(intlRef.current)\n return <Provider value={intlRef.current}>{props.children}</Provider>\n}\n\nIntlProviderImpl.displayName = 'IntlProvider'\n\nconst IntlProvider: React.FC<React.PropsWithChildren<IntlConfig>> =\n IntlProviderImpl\nexport default IntlProvider\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\nimport * as React from 'react'\n\nimport {type FormatRelativeTimeOptions} from '@formatjs/intl'\nimport {invariant} from '#packages/react-intl/utils.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\nconst MINUTE = 60\nconst HOUR = 60 * 60\nconst DAY = 60 * 60 * 24\n\nfunction selectUnit(seconds: number): Intl.RelativeTimeFormatUnit {\n const absValue = Math.abs(seconds)\n\n if (absValue < MINUTE) {\n return 'second'\n }\n\n if (absValue < HOUR) {\n return 'minute'\n }\n\n if (absValue < DAY) {\n return 'hour'\n }\n\n return 'day'\n}\n\nfunction getDurationInSeconds(unit?: Intl.RelativeTimeFormatUnit): number {\n switch (unit) {\n case 'second':\n return 1\n case 'minute':\n return MINUTE\n case 'hour':\n return HOUR\n default:\n return DAY\n }\n}\n\nfunction valueToSeconds(\n value?: number,\n unit?: Intl.RelativeTimeFormatUnit\n): number {\n if (!value) {\n return 0\n }\n switch (unit) {\n case 'second':\n return value\n case 'minute':\n return value * MINUTE\n default:\n return value * HOUR\n }\n}\n\nexport interface Props extends FormatRelativeTimeOptions {\n value?: number\n unit?: Intl.RelativeTimeFormatUnit\n updateIntervalInSeconds?: number\n children?(value: string): React.ReactElement | null\n}\n\nconst INCREMENTABLE_UNITS: Intl.RelativeTimeFormatUnit[] = [\n 'second',\n 'minute',\n 'hour',\n]\nfunction canIncrement(unit: Intl.RelativeTimeFormatUnit = 'second'): boolean {\n return INCREMENTABLE_UNITS.indexOf(unit) > -1\n}\n\nconst SimpleFormattedRelativeTime: React.FC<\n Omit<Props, 'updateIntervalInSeconds'>\n> = props => {\n const {formatRelativeTime, textComponent: Text} = useIntl()\n const {children, value, unit, ...otherProps} = props\n\n const formattedRelativeTime = formatRelativeTime(value || 0, unit, otherProps)\n\n if (typeof children === 'function') {\n return children(formattedRelativeTime)\n }\n if (Text) {\n return <Text>{formattedRelativeTime}</Text>\n }\n return <>{formattedRelativeTime}</>\n}\n\nconst FormattedRelativeTime: React.FC<Props> = ({\n value = 0,\n unit = 'second',\n updateIntervalInSeconds,\n ...otherProps\n}) => {\n invariant(\n !updateIntervalInSeconds ||\n !!(updateIntervalInSeconds && canIncrement(unit)),\n 'Cannot schedule update with unit longer than hour'\n )\n const [prevUnit, setPrevUnit] = React.useState<\n Intl.RelativeTimeFormatUnit | undefined\n >()\n const [prevValue, setPrevValue] = React.useState<number>(0)\n const [currentValueInSeconds, setCurrentValueInSeconds] =\n React.useState<number>(0)\n const updateTimer = React.useRef<number | undefined>(undefined)\n\n if (unit !== prevUnit || value !== prevValue) {\n setPrevValue(value || 0)\n setPrevUnit(unit)\n setCurrentValueInSeconds(\n canIncrement(unit) ? valueToSeconds(value, unit) : 0\n )\n }\n\n React.useEffect(() => {\n function clearUpdateTimer() {\n clearTimeout(updateTimer.current)\n }\n clearUpdateTimer()\n // If there's no interval and we cannot increment this unit, do nothing\n if (!updateIntervalInSeconds || !canIncrement(unit)) {\n return clearUpdateTimer\n }\n // Figure out the next interesting time\n const nextValueInSeconds = currentValueInSeconds - updateIntervalInSeconds\n const nextUnit = selectUnit(nextValueInSeconds)\n // We've reached the max auto incrementable unit, don't schedule another update\n if (nextUnit === 'day') {\n return clearUpdateTimer\n }\n\n const unitDuration = getDurationInSeconds(nextUnit)\n const remainder = nextValueInSeconds % unitDuration\n const prevInterestingValueInSeconds = nextValueInSeconds - remainder\n const nextInterestingValueInSeconds =\n prevInterestingValueInSeconds >= currentValueInSeconds\n ? prevInterestingValueInSeconds - unitDuration\n : prevInterestingValueInSeconds\n const delayInSeconds = Math.abs(\n nextInterestingValueInSeconds - currentValueInSeconds\n )\n\n if (currentValueInSeconds !== nextInterestingValueInSeconds) {\n updateTimer.current = setTimeout(\n () => setCurrentValueInSeconds(nextInterestingValueInSeconds),\n delayInSeconds * 1e3\n ) as unknown as number\n }\n return clearUpdateTimer\n }, [currentValueInSeconds, updateIntervalInSeconds, unit])\n\n let currentValue = value || 0\n let currentUnit = unit\n\n if (\n canIncrement(unit) &&\n typeof currentValueInSeconds === 'number' &&\n updateIntervalInSeconds\n ) {\n currentUnit = selectUnit(currentValueInSeconds)\n const unitDuration = getDurationInSeconds(currentUnit)\n currentValue = Math.round(currentValueInSeconds / unitDuration)\n }\n return (\n <SimpleFormattedRelativeTime\n value={currentValue}\n unit={currentUnit}\n {...otherProps}\n />\n )\n}\n\nFormattedRelativeTime.displayName = 'FormattedRelativeTime'\n\nexport default FormattedRelativeTime\n","'use client'\n/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\nimport {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {\n type CustomFormatConfig,\n type FormatDateOptions,\n type FormatTimeOptions,\n type MessageDescriptor,\n} from '@formatjs/intl'\nimport * as React from 'react'\nimport {\n createFormattedComponent,\n createFormattedDateTimePartsComponent,\n} from '#packages/react-intl/components/createFormattedComponent.js'\nimport {createIntl} from '#packages/react-intl/components/createIntl.js'\nimport {\n Context as IntlContext,\n Provider as RawIntlProvider,\n} from '#packages/react-intl/components/context.js'\nimport FormattedDateTimeRange from '#packages/react-intl/components/dateTimeRange.js'\nimport FormattedMessage from '#packages/react-intl/components/message.js'\nimport FormattedPlural from '#packages/react-intl/components/plural.js'\nimport IntlProvider from '#packages/react-intl/components/provider.js'\nimport FormattedRelativeTime from '#packages/react-intl/components/relative.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\nimport {type IntlShape} from '#packages/react-intl/types.js'\nexport {\n createIntlCache,\n type CustomFormatConfig,\n type CustomFormats,\n type FormatDateOptions,\n type FormatDisplayNameOptions,\n type FormatListOptions,\n type FormatNumberOptions,\n type FormatPluralOptions,\n type FormatRelativeTimeOptions,\n type Formatters,\n type IntlCache,\n type IntlFormatters,\n InvalidConfigError,\n type MessageDescriptor,\n MessageFormatError,\n MissingDataError,\n MissingTranslationError,\n IntlError as ReactIntlError,\n IntlErrorCode as ReactIntlErrorCode,\n UnsupportedFormatterError,\n} from '@formatjs/intl'\nexport {\n type IntlConfig,\n type IntlShape,\n type ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\nexport {\n createIntl,\n FormattedDateTimeRange,\n FormattedMessage,\n FormattedPlural,\n FormattedRelativeTime,\n IntlContext,\n IntlProvider,\n RawIntlProvider,\n useIntl,\n}\n\nexport function defineMessages<\n K extends keyof any,\n T = MessageDescriptor,\n U extends Record<K, T> = Record<K, T>,\n>(msgs: U): U {\n return msgs\n}\n\nexport function defineMessage<T extends MessageDescriptor>(msg: T): T {\n return msg\n}\n// IMPORTANT: Explicit here to prevent api-extractor from outputing `import('./types').CustomFormatConfig`\nexport const FormattedDate: React.FC<\n Intl.DateTimeFormatOptions &\n CustomFormatConfig<'date'> & {\n value: string | number | Date | undefined\n children?(formattedDate: string): React.ReactElement | null\n }\n> = createFormattedComponent('formatDate')\nexport const FormattedTime: React.FC<\n Intl.DateTimeFormatOptions &\n CustomFormatConfig<'time'> & {\n value: string | number | Date | undefined\n children?(formattedTime: string): React.ReactElement | null\n }\n> = createFormattedComponent('formatTime')\nexport const FormattedNumber: React.FC<\n Omit<NumberFormatOptions, 'localeMatcher'> &\n CustomFormatConfig<'number'> & {\n value: Parameters<IntlShape['formatNumber']>[0]\n children?(formattedNumber: string): React.ReactElement | null\n }\n> = createFormattedComponent('formatNumber')\nexport const FormattedList: React.FC<\n Intl.ListFormatOptions & {\n value: Parameters<IntlShape['formatList']>[0]\n }\n> = createFormattedComponent('formatList')\nexport const FormattedDisplayName: React.FC<\n Intl.DisplayNamesOptions & {\n value: string\n }\n> = createFormattedComponent('formatDisplayName')\nexport const FormattedDateParts: React.FC<\n FormatDateOptions & {\n value: Parameters<Intl.DateTimeFormat['format']>[0] | string\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n> = createFormattedDateTimePartsComponent('formatDate')\nexport const FormattedTimeParts: React.FC<\n FormatTimeOptions & {\n value: Parameters<Intl.DateTimeFormat['format']>[0] | string\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n> = createFormattedDateTimePartsComponent('formatTime')\n\nexport type {MessageFormatElement} from '@formatjs/icu-messageformat-parser'\nexport type {PrimitiveType} from 'intl-messageformat'\nexport {\n FormattedListParts,\n FormattedNumberParts,\n} from '#packages/react-intl/components/createFormattedComponent.js'\n"],"mappings":";;;;;;AAMA,SAAgB,UACd,WACA,SACA,MAAW,OACQ;CACnB,IAAI,CAAC,WACH,MAAM,IAAI,IAAI,OAAO;AAEzB;AAEA,SAAgB,qBAAqB,MAA0B;CAC7D,UACE,MACA,8GAEF;AACF;AAcA,MAAaA,wBAAyC;CACpD,GAAGC;CACH,eAAe,MAAM;AACvB;;;;;;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EzD,IAAI,eAAe,SAAS;CAC5B,IAAI,cAAc;CAElB,IACE,aAAa,IAAI,KACjB,OAAO,0BAA0B,YACjC,yBACA;EACA,cAAc,WAAW,qBAAqB;EAC9C,MAAM,eAAe,qBAAqB,WAAW;EACrD,eAAe,KAAK,MAAM,wBAAwB,YAAY;CAChE;CACA,OACE,oBAAC,6BAAD;EACE,OAAO;EACP,MAAM;EACN,GAAI;CACL,CAAA;AAEL;AAEA,sBAAsB,cAAc;;;AChHpC,SAAgB,eAId,MAAY;CACZ,OAAO;AACT;AAEA,SAAgB,cAA2C,KAAW;CACpE,OAAO;AACT;AAEA,MAAa,gBAMT,yBAAyB,YAAY;AACzC,MAAa,gBAMT,yBAAyB,YAAY;AACzC,MAAa,kBAMT,yBAAyB,cAAc;AAC3C,MAAa,gBAIT,yBAAyB,YAAY;AACzC,MAAa,uBAIT,yBAAyB,mBAAmB;AAChD,MAAa,qBAKT,sCAAsC,YAAY;AACtD,MAAa,qBAKT,sCAAsC,YAAY"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["DEFAULT_INTL_CONFIG","CORE_DEFAULT_INTL_CONFIG","Context","formatMessage","coreFormatMessage","coreCreateIntl","DEFAULT_INTL_CONFIG","createIntlCache","DEFAULT_INTL_CONFIG"],"sources":["../utils.tsx","../components/context.ts","../components/useIntl.ts","../components/createFormattedComponent.tsx","../components/createIntl.ts","../components/dateTimeRange.tsx","../components/message.tsx","../components/plural.tsx","../components/provider.tsx","../components/relative.tsx","../index.ts"],"sourcesContent":["import {type FormatXMLElementFn} from 'intl-messageformat'\nimport * as React from 'react'\nimport {type ResolvedIntlConfig} from '#packages/react-intl/types.js'\n\nimport {DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG} from '@formatjs/intl'\n\nexport function invariant(\n condition: boolean,\n message: string,\n Err: any = Error\n): asserts condition {\n if (!condition) {\n throw new Err(message)\n }\n}\n\nexport function invariantIntlContext(intl?: any): asserts intl {\n invariant(\n intl,\n '[React Intl] Could not find required `intl` object. ' +\n '<IntlProvider> needs to exist in the component ancestry.'\n )\n}\n\nexport type DefaultIntlConfig = Pick<\n ResolvedIntlConfig,\n | 'fallbackOnEmptyString'\n | 'formats'\n | 'messages'\n | 'timeZone'\n | 'textComponent'\n | 'defaultLocale'\n | 'defaultFormats'\n | 'onError'\n>\n\nexport const DEFAULT_INTL_CONFIG: DefaultIntlConfig = {\n ...CORE_DEFAULT_INTL_CONFIG,\n textComponent: React.Fragment,\n}\n\n/**\n * Builds an array of {@link React.ReactNode}s with index-based keys, similar to\n * {@link React.Children.toArray}. However, this function tells React that it\n * was intentional, so they won't produce a bunch of warnings about it.\n *\n * React doesn't recommend doing this because it makes reordering inefficient,\n * but we mostly need this for message chunks, which don't tend to reorder to\n * begin with.\n *\n */\nexport const toKeyedReactNodeArray: typeof React.Children.toArray =\n children => {\n const childrenArray = React.Children.toArray(children)\n\n return childrenArray.map((child, index) => {\n // For React elements, wrap in a keyed Fragment\n // This creates a new element with a key rather than trying to add one after creation\n if (React.isValidElement(child)) {\n return <React.Fragment key={index}>{child}</React.Fragment>\n }\n return child\n })\n }\n\n/**\n * Takes a `formatXMLElementFn`, and composes it in function, which passes\n * argument `parts` through, assigning unique key to each part, to prevent\n * \"Each child in a list should have a unique \"key\"\" React error.\n * @param formatXMLElementFn\n */\nexport function assignUniqueKeysToParts(\n formatXMLElementFn: FormatXMLElementFn<React.ReactNode>\n): FormatXMLElementFn<React.ReactNode> {\n return function (parts: any) {\n // eslint-disable-next-line prefer-rest-params\n return formatXMLElementFn(toKeyedReactNodeArray(parts)) as any\n }\n}\n\nexport function shallowEqual<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(objA?: T, objB?: T): boolean {\n if (objA === objB) {\n return true\n }\n\n if (!objA || !objB) {\n return false\n }\n\n var aKeys = Object.keys(objA)\n var bKeys = Object.keys(objB)\n var len = aKeys.length\n\n if (bKeys.length !== len) {\n return false\n }\n\n for (var i = 0; i < len; i++) {\n var key = aKeys[i]\n\n if (\n objA[key] !== objB[key] ||\n !Object.prototype.hasOwnProperty.call(objB, key)\n ) {\n return false\n }\n }\n\n return true\n}\n","import * as React from 'react'\nimport {type IntlShape} from '#packages/react-intl/types.js'\n\nconst IntlContext: React.Context<IntlShape> = React.createContext<IntlShape>(\n null as any\n)\nconst Provider: React.Provider<IntlShape> = IntlContext.Provider\n\nexport {Provider, IntlContext as Context}\n","import * as React from 'react'\nimport {type IntlShape} from '#packages/react-intl/types.js'\nimport {invariantIntlContext} from '#packages/react-intl/utils.js'\nimport {Context} from '#packages/react-intl/components/context.js'\n\nexport default function useIntl(this: void): IntlShape {\n const intl = React.useContext(Context)\n invariantIntlContext(intl)\n return intl\n}\n","import {\n type FormatDateOptions,\n type FormatDisplayNameOptions,\n type FormatListOptions,\n type FormatNumberOptions,\n} from '@formatjs/intl'\nimport * as React from 'react'\nimport {type IntlShape} from '#packages/react-intl/types.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\nenum DisplayName {\n formatDate = 'FormattedDate',\n formatTime = 'FormattedTime',\n formatNumber = 'FormattedNumber',\n formatList = 'FormattedList',\n // Note that this DisplayName is the locale display name, not to be confused with\n // the name of the enum, which is for React component display name in dev tools.\n formatDisplayName = 'FormattedDisplayName',\n}\n\nenum DisplayNameParts {\n formatDate = 'FormattedDateParts',\n formatTime = 'FormattedTimeParts',\n formatNumber = 'FormattedNumberParts',\n formatList = 'FormattedListParts',\n}\n\ntype Formatter = {\n formatDate: FormatDateOptions\n formatTime: FormatDateOptions\n formatNumber: FormatNumberOptions\n formatList: FormatListOptions\n formatDisplayName: FormatDisplayNameOptions\n}\n\nexport const FormattedNumberParts: React.FC<\n Formatter['formatNumber'] & {\n value: Parameters<IntlShape['formatNumber']>[0]\n\n children(val: Intl.NumberFormatPart[]): React.ReactElement | null\n }\n> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n return children(intl.formatNumberToParts(value, formatProps))\n}\nFormattedNumberParts.displayName = 'FormattedNumberParts'\n\nexport const FormattedListParts: React.FC<\n Formatter['formatList'] & {\n value: Parameters<IntlShape['formatList']>[0]\n\n children(\n val: ReturnType<Intl.ListFormat['formatToParts']>\n ): React.ReactElement | null\n }\n> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n return children(intl.formatListToParts(value, formatProps))\n}\nFormattedListParts.displayName = 'FormattedListParts'\n\nexport function createFormattedDateTimePartsComponent<\n Name extends 'formatDate' | 'formatTime',\n>(\n name: Name\n): React.FC<\n Formatter[Name] & {\n value: Parameters<IntlShape[Name]>[0]\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n> {\n type FormatFn = IntlShape[Name]\n type Props = Formatter[Name] & {\n value: Parameters<FormatFn>[0]\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n\n const ComponentParts: React.FC<Props> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n const date = typeof value === 'string' ? new Date(value || 0) : value\n const formattedParts: Intl.DateTimeFormatPart[] =\n name === 'formatDate'\n ? intl.formatDateToParts(date, formatProps)\n : intl.formatTimeToParts(date, formatProps)\n\n return children(formattedParts)\n }\n ComponentParts.displayName = DisplayNameParts[name]\n return ComponentParts\n}\n\nexport function createFormattedComponent<Name extends keyof Formatter>(\n name: Name\n): React.FC<\n Formatter[Name] & {\n value: Parameters<IntlShape[Name]>[0]\n children?(val: string): React.ReactElement | null\n }\n> {\n type FormatFn = IntlShape[Name]\n type Props = Formatter[Name] & {\n value: Parameters<FormatFn>[0]\n children?(val: string): React.ReactElement | null\n }\n\n const Component: React.FC<Props> = props => {\n const intl = useIntl()\n const {value, children, ...formatProps} = props\n // TODO: fix TS type definition for localeMatcher upstream\n const formattedValue = intl[name](value as never, formatProps as any)\n\n if (typeof children === 'function') {\n return children(formattedValue as any)\n }\n const Text = intl.textComponent || React.Fragment\n return <Text>{formattedValue}</Text>\n }\n\n Component.displayName = DisplayName[name]\n return Component\n}\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport {\n type CreateIntlFn,\n type FormatMessageFn,\n createIntl as coreCreateIntl,\n formatMessage as coreFormatMessage,\n} from '@formatjs/intl'\nimport {\n type FormatXMLElementFn,\n type PrimitiveType,\n isFormatXMLElementFn,\n} from 'intl-messageformat'\nimport * as React from 'react'\nimport type {\n IntlConfig,\n IntlShape,\n ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\nimport {\n DEFAULT_INTL_CONFIG,\n assignUniqueKeysToParts,\n toKeyedReactNodeArray,\n} from '#packages/react-intl/utils.js'\n\nfunction assignUniqueKeysToFormatXMLElementFnArgument<\n T extends Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n > = Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n >,\n>(values?: T): T | undefined {\n if (!values) {\n return values\n }\n return Object.keys(values).reduce((acc: T, k) => {\n const v = values[k]\n ;(acc as any)[k] = isFormatXMLElementFn<React.ReactNode>(v)\n ? assignUniqueKeysToParts(v)\n : v\n return acc\n }, {} as T)\n}\n\nconst formatMessage: FormatMessageFn<React.ReactNode> = (\n config,\n formatters,\n descriptor,\n rawValues,\n ...rest\n) => {\n const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues)\n const chunks = coreFormatMessage(\n config,\n formatters,\n descriptor,\n values as any,\n ...rest\n )\n if (Array.isArray(chunks)) {\n return toKeyedReactNodeArray(chunks)\n }\n return chunks\n}\n\n/**\n * Create intl object\n * @param config intl config\n * @param cache cache for formatter instances to prevent memory leak\n */\nexport const createIntl: CreateIntlFn<\n React.ReactNode,\n IntlConfig,\n IntlShape\n> = (\n {defaultRichTextElements: rawDefaultRichTextElements, ...config},\n cache\n) => {\n const defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(\n rawDefaultRichTextElements\n )\n const coreIntl = coreCreateIntl<React.ReactNode>(\n {\n ...DEFAULT_INTL_CONFIG,\n ...config,\n defaultRichTextElements,\n },\n cache\n )\n\n const resolvedConfig: ResolvedIntlConfig = {\n locale: coreIntl.locale,\n timeZone: coreIntl.timeZone,\n fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,\n formats: coreIntl.formats,\n defaultLocale: coreIntl.defaultLocale,\n defaultFormats: coreIntl.defaultFormats,\n messages: coreIntl.messages,\n onError: coreIntl.onError,\n defaultRichTextElements,\n }\n\n return {\n ...coreIntl,\n formatMessage: formatMessage.bind(\n null,\n resolvedConfig,\n coreIntl.formatters\n ),\n $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters),\n } as any\n}\n","import {type FormatDateTimeRangeOptions} from '@formatjs/intl'\nimport * as React from 'react'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\ninterface Props extends FormatDateTimeRangeOptions {\n from: Parameters<Intl.DateTimeFormat['formatRange']>[0]\n to: Parameters<Intl.DateTimeFormat['formatRange']>[1]\n children?(value: React.ReactNode): React.ReactElement | null\n}\n\nconst FormattedDateTimeRange: React.FC<Props> = props => {\n const intl = useIntl()\n\n const {from, to, children, ...formatProps} = props\n const formattedValue = intl.formatDateTimeRange(from, to, formatProps)\n\n if (typeof children === 'function') {\n return children(formattedValue as any)\n }\n const Text = intl.textComponent || React.Fragment\n return <Text>{formattedValue}</Text>\n}\n\nFormattedDateTimeRange.displayName = 'FormattedDateTimeRange'\nexport default FormattedDateTimeRange\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport type {\n FormatXMLElementFn,\n Options as IntlMessageFormatOptions,\n PrimitiveType,\n} from 'intl-messageformat'\nimport * as React from 'react'\n\nimport {type MessageDescriptor} from '@formatjs/intl'\nimport {shallowEqual} from '#packages/react-intl/utils.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\nexport interface Props<\n V extends Record<string, any> = Record<\n string,\n React.ReactNode | PrimitiveType | FormatXMLElementFn<React.ReactNode>\n >,\n> extends MessageDescriptor {\n values?: V\n tagName?: React.ElementType<any>\n children?(nodes: React.ReactNode[]): React.ReactNode | null\n ignoreTag?: IntlMessageFormatOptions['ignoreTag']\n}\n\nfunction areEqual(prevProps: Props, nextProps: Props): boolean {\n const {values, ...otherProps} = prevProps\n const {values: nextValues, ...nextOtherProps} = nextProps\n return (\n shallowEqual(nextValues, values) &&\n shallowEqual(otherProps as any, nextOtherProps)\n )\n}\n\nfunction FormattedMessage(props: Props) {\n const intl = useIntl()\n const {formatMessage, textComponent: Text = React.Fragment} = intl\n const {\n id,\n description,\n defaultMessage,\n values,\n children,\n tagName: Component = Text,\n ignoreTag,\n } = props\n\n const descriptor = {id, description, defaultMessage}\n const nodes = formatMessage(descriptor, values, {\n ignoreTag,\n })\n\n if (typeof children === 'function') {\n return children(Array.isArray(nodes) ? nodes : [nodes])\n }\n\n if (Component) {\n return <Component>{nodes}</Component>\n }\n return <>{nodes}</>\n}\nFormattedMessage.displayName = 'FormattedMessage'\n\nconst MemoizedFormattedMessage: React.ComponentType<Props> = React.memo<Props>(\n FormattedMessage,\n areEqual\n)\nMemoizedFormattedMessage.displayName = 'MemoizedFormattedMessage'\n\nexport default MemoizedFormattedMessage\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport * as React from 'react'\nimport {type FormatPluralOptions} from '@formatjs/intl'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\ninterface Props extends FormatPluralOptions {\n value: number\n other: React.ReactNode\n zero?: React.ReactNode\n one?: React.ReactNode\n two?: React.ReactNode\n few?: React.ReactNode\n many?: React.ReactNode\n children?(value: React.ReactNode): React.ReactElement | null\n}\n\nconst FormattedPlural: React.FC<Props> = props => {\n const {formatPlural, textComponent: Text} = useIntl()\n const {value, other, children} = props\n\n const pluralCategory = formatPlural(value, props)\n const formattedPlural = props[pluralCategory as 'one'] || other\n\n if (typeof children === 'function') {\n return children(formattedPlural)\n }\n if (Text) {\n return <Text>{formattedPlural}</Text>\n }\n // Work around @types/react where React.FC cannot return string\n return formattedPlural as any\n}\n\nFormattedPlural.displayName = 'FormattedPlural'\n\nexport default FormattedPlural\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport {type IntlCache, createIntlCache} from '@formatjs/intl'\nimport * as React from 'react'\nimport type {IntlConfig, IntlShape} from '#packages/react-intl/types.js'\nimport {\n DEFAULT_INTL_CONFIG,\n invariantIntlContext,\n shallowEqual,\n} from '#packages/react-intl/utils.js'\nimport {createIntl} from '#packages/react-intl/components/createIntl.js'\nimport {Provider} from '#packages/react-intl/components/context.js'\n\nfunction processIntlConfig<P extends IntlConfig = IntlConfig>(\n config: P\n): IntlConfig {\n return {\n locale: config.locale,\n timeZone: config.timeZone,\n fallbackOnEmptyString: config.fallbackOnEmptyString,\n formats: config.formats,\n textComponent: config.textComponent,\n messages: config.messages,\n defaultLocale: config.defaultLocale,\n defaultFormats: config.defaultFormats,\n onError: config.onError,\n onWarn: config.onWarn,\n wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,\n defaultRichTextElements: config.defaultRichTextElements,\n }\n}\n\nfunction IntlProviderImpl(\n props: React.PropsWithChildren<IntlConfig>\n): React.JSX.Element {\n const cacheRef = React.useRef<IntlCache>(createIntlCache())\n const prevConfigRef = React.useRef<IntlConfig | undefined>(undefined)\n const intlRef = React.useRef<IntlShape | undefined>(undefined)\n\n // Filter out undefined values from props so they don't override defaults.\n // React's defaultProps treated `prop={undefined}` as \"not provided\"; we\n // replicate that behaviour here after converting to a function component.\n const filteredProps: Record<string, unknown> = {}\n for (const key in props) {\n if ((props as any)[key] !== undefined) {\n filteredProps[key] = (props as any)[key]\n }\n }\n const config = processIntlConfig({\n ...DEFAULT_INTL_CONFIG,\n ...filteredProps,\n } as IntlConfig)\n\n if (!prevConfigRef.current || !shallowEqual(prevConfigRef.current, config)) {\n prevConfigRef.current = config\n intlRef.current = createIntl(config, cacheRef.current)\n }\n\n invariantIntlContext(intlRef.current)\n return <Provider value={intlRef.current}>{props.children}</Provider>\n}\n\nIntlProviderImpl.displayName = 'IntlProvider'\n\nconst IntlProvider: React.FC<React.PropsWithChildren<IntlConfig>> =\n IntlProviderImpl\nexport default IntlProvider\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\nimport * as React from 'react'\n\nimport {type FormatRelativeTimeOptions} from '@formatjs/intl'\nimport {invariant} from '#packages/react-intl/utils.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\n\nconst MINUTE = 60\nconst HOUR = 60 * 60\nconst DAY = 60 * 60 * 24\n\nfunction selectUnit(seconds: number): Intl.RelativeTimeFormatUnit {\n const absValue = Math.abs(seconds)\n\n if (absValue < MINUTE) {\n return 'second'\n }\n\n if (absValue < HOUR) {\n return 'minute'\n }\n\n if (absValue < DAY) {\n return 'hour'\n }\n\n return 'day'\n}\n\nfunction getDurationInSeconds(unit?: Intl.RelativeTimeFormatUnit): number {\n switch (unit) {\n case 'second':\n return 1\n case 'minute':\n return MINUTE\n case 'hour':\n return HOUR\n default:\n return DAY\n }\n}\n\nfunction valueToSeconds(\n value?: number,\n unit?: Intl.RelativeTimeFormatUnit\n): number {\n if (!value) {\n return 0\n }\n switch (unit) {\n case 'second':\n return value\n case 'minute':\n return value * MINUTE\n default:\n return value * HOUR\n }\n}\n\nexport interface Props extends FormatRelativeTimeOptions {\n value?: number\n unit?: Intl.RelativeTimeFormatUnit\n updateIntervalInSeconds?: number\n children?(value: string): React.ReactElement | null\n}\n\nconst INCREMENTABLE_UNITS: Intl.RelativeTimeFormatUnit[] = [\n 'second',\n 'minute',\n 'hour',\n]\nfunction canIncrement(unit: Intl.RelativeTimeFormatUnit = 'second'): boolean {\n return INCREMENTABLE_UNITS.indexOf(unit) > -1\n}\n\nconst SimpleFormattedRelativeTime: React.FC<\n Omit<Props, 'updateIntervalInSeconds'>\n> = props => {\n const {formatRelativeTime, textComponent: Text} = useIntl()\n const {children, value, unit, ...otherProps} = props\n\n const formattedRelativeTime = formatRelativeTime(value || 0, unit, otherProps)\n\n if (typeof children === 'function') {\n return children(formattedRelativeTime)\n }\n if (Text) {\n return <Text>{formattedRelativeTime}</Text>\n }\n return <>{formattedRelativeTime}</>\n}\n\nconst FormattedRelativeTime: React.FC<Props> = ({\n value = 0,\n unit = 'second',\n updateIntervalInSeconds,\n ...otherProps\n}) => {\n invariant(\n !updateIntervalInSeconds ||\n !!(updateIntervalInSeconds && canIncrement(unit)),\n 'Cannot schedule update with unit longer than hour'\n )\n const [prevUnit, setPrevUnit] = React.useState<\n Intl.RelativeTimeFormatUnit | undefined\n >()\n const [prevValue, setPrevValue] = React.useState<number>(0)\n const [currentValueInSeconds, setCurrentValueInSeconds] =\n React.useState<number>(0)\n const updateTimer = React.useRef<number | undefined>(undefined)\n\n if (unit !== prevUnit || value !== prevValue) {\n setPrevValue(value || 0)\n setPrevUnit(unit)\n setCurrentValueInSeconds(\n canIncrement(unit) ? valueToSeconds(value, unit) : 0\n )\n }\n\n React.useEffect(() => {\n function clearUpdateTimer() {\n clearTimeout(updateTimer.current)\n }\n clearUpdateTimer()\n // If there's no interval and we cannot increment this unit, do nothing\n if (!updateIntervalInSeconds || !canIncrement(unit)) {\n return clearUpdateTimer\n }\n // Figure out the next interesting time\n const nextValueInSeconds = currentValueInSeconds - updateIntervalInSeconds\n const nextUnit = selectUnit(nextValueInSeconds)\n // We've reached the max auto incrementable unit, don't schedule another update\n if (nextUnit === 'day') {\n return clearUpdateTimer\n }\n\n const unitDuration = getDurationInSeconds(nextUnit)\n const remainder = nextValueInSeconds % unitDuration\n const prevInterestingValueInSeconds = nextValueInSeconds - remainder\n const nextInterestingValueInSeconds =\n prevInterestingValueInSeconds >= currentValueInSeconds\n ? prevInterestingValueInSeconds - unitDuration\n : prevInterestingValueInSeconds\n const delayInSeconds = Math.abs(\n nextInterestingValueInSeconds - currentValueInSeconds\n )\n\n if (currentValueInSeconds !== nextInterestingValueInSeconds) {\n updateTimer.current = setTimeout(\n () => setCurrentValueInSeconds(nextInterestingValueInSeconds),\n delayInSeconds * 1e3\n ) as unknown as number\n }\n return clearUpdateTimer\n }, [currentValueInSeconds, updateIntervalInSeconds, unit])\n\n let currentValue = value || 0\n let currentUnit = unit\n\n if (\n canIncrement(unit) &&\n typeof currentValueInSeconds === 'number' &&\n updateIntervalInSeconds\n ) {\n currentUnit = selectUnit(currentValueInSeconds)\n const unitDuration = getDurationInSeconds(currentUnit)\n currentValue = Math.round(currentValueInSeconds / unitDuration)\n }\n return (\n <SimpleFormattedRelativeTime\n value={currentValue}\n unit={currentUnit}\n {...otherProps}\n />\n )\n}\n\nFormattedRelativeTime.displayName = 'FormattedRelativeTime'\n\nexport default FormattedRelativeTime\n","'use client'\n/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\nimport {type NumberFormatOptions} from '#packages/ecma402-abstract/types/number.js'\nimport {\n type CustomFormatConfig,\n type FormatDateOptions,\n type FormatTimeOptions,\n type MessageDescriptor,\n} from '@formatjs/intl'\nimport * as React from 'react'\nimport {\n createFormattedComponent,\n createFormattedDateTimePartsComponent,\n} from '#packages/react-intl/components/createFormattedComponent.js'\nimport {createIntl} from '#packages/react-intl/components/createIntl.js'\nimport {\n Context as IntlContext,\n Provider as RawIntlProvider,\n} from '#packages/react-intl/components/context.js'\nimport FormattedDateTimeRange from '#packages/react-intl/components/dateTimeRange.js'\nimport FormattedMessage from '#packages/react-intl/components/message.js'\nimport FormattedPlural from '#packages/react-intl/components/plural.js'\nimport IntlProvider from '#packages/react-intl/components/provider.js'\nimport FormattedRelativeTime from '#packages/react-intl/components/relative.js'\nimport useIntl from '#packages/react-intl/components/useIntl.js'\nimport {type IntlShape} from '#packages/react-intl/types.js'\nexport {\n createIntlCache,\n type CustomFormatConfig,\n type CustomFormats,\n type FormatDateOptions,\n type FormatDisplayNameOptions,\n type FormatListOptions,\n type FormatNumberOptions,\n type FormatPluralOptions,\n type FormatRelativeTimeOptions,\n type Formatters,\n type IntlCache,\n type IntlFormatters,\n InvalidConfigError,\n type MessageDescriptor,\n MessageFormatError,\n MissingDataError,\n MissingTranslationError,\n IntlError as ReactIntlError,\n IntlErrorCode as ReactIntlErrorCode,\n UnsupportedFormatterError,\n} from '@formatjs/intl'\nexport {\n type IntlConfig,\n type IntlShape,\n type ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\nexport {\n createIntl,\n FormattedDateTimeRange,\n FormattedMessage,\n FormattedPlural,\n FormattedRelativeTime,\n IntlContext,\n IntlProvider,\n RawIntlProvider,\n useIntl,\n}\n\nexport function defineMessages<\n K extends keyof any,\n T = MessageDescriptor,\n U extends Record<K, T> = Record<K, T>,\n>(msgs: U): U {\n return msgs\n}\n\nexport function defineMessage<T extends MessageDescriptor>(msg: T): T {\n return msg\n}\n// IMPORTANT: Explicit here to prevent api-extractor from outputing `import('./types').CustomFormatConfig`\nexport const FormattedDate: React.FC<\n Intl.DateTimeFormatOptions &\n CustomFormatConfig<'date'> & {\n value: string | number | Date | undefined\n children?(formattedDate: string): React.ReactElement | null\n }\n> = createFormattedComponent('formatDate')\nexport const FormattedTime: React.FC<\n Intl.DateTimeFormatOptions &\n CustomFormatConfig<'time'> & {\n value: string | number | Date | undefined\n children?(formattedTime: string): React.ReactElement | null\n }\n> = createFormattedComponent('formatTime')\nexport const FormattedNumber: React.FC<\n Omit<NumberFormatOptions, 'localeMatcher'> &\n CustomFormatConfig<'number'> & {\n value: Parameters<IntlShape['formatNumber']>[0]\n children?(formattedNumber: string): React.ReactElement | null\n }\n> = createFormattedComponent('formatNumber')\nexport const FormattedList: React.FC<\n Intl.ListFormatOptions & {\n value: Parameters<IntlShape['formatList']>[0]\n }\n> = createFormattedComponent('formatList')\nexport const FormattedDisplayName: React.FC<\n Intl.DisplayNamesOptions & {\n value: string\n }\n> = createFormattedComponent('formatDisplayName')\nexport const FormattedDateParts: React.FC<\n FormatDateOptions & {\n value: Parameters<Intl.DateTimeFormat['format']>[0] | string\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n> = createFormattedDateTimePartsComponent('formatDate')\nexport const FormattedTimeParts: React.FC<\n FormatTimeOptions & {\n value: Parameters<Intl.DateTimeFormat['format']>[0] | string\n children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null\n }\n> = createFormattedDateTimePartsComponent('formatTime')\n\nexport type {MessageFormatElement} from '@formatjs/icu-messageformat-parser'\nexport type {PrimitiveType} from 'intl-messageformat'\nexport {\n FormattedListParts,\n FormattedNumberParts,\n} from '#packages/react-intl/components/createFormattedComponent.js'\n"],"mappings":";;;;;;AAMA,SAAgB,UACd,WACA,SACA,MAAW,OACQ;CACnB,IAAI,CAAC,WACH,MAAM,IAAI,IAAI,OAAO;AAEzB;AAEA,SAAgB,qBAAqB,MAA0B;CAC7D,UACE,MACA,8GAEF;AACF;AAcA,MAAaA,wBAAyC;CACpD,GAAGC;CACH,eAAe,MAAM;AACvB;;;;;;;;;;;AAYA,MAAa,yBACX,aAAY;CAGV,OAFsB,MAAM,SAAS,QAAQ,QAE1B,CAAC,CAAC,KAAK,OAAO,UAAU;EAGzC,IAAI,MAAM,eAAe,KAAK,GAC5B,OAAO,oBAAC,MAAM,UAAP,EAAA,UAA6B,MAAsB,GAA9B,KAA8B;EAE5D,OAAO;CACT,CAAC;AACH;;;;;;;AAQF,SAAgB,wBACd,oBACqC;CACrC,OAAO,SAAU,OAAY;EAE3B,OAAO,mBAAmB,sBAAsB,KAAK,CAAC;CACxD;AACF;AAEA,SAAgB,aAEd,MAAU,MAAmB;CAC7B,IAAI,SAAS,MACX,OAAO;CAGT,IAAI,CAAC,QAAQ,CAAC,MACZ,OAAO;CAGT,IAAI,QAAQ,OAAO,KAAK,IAAI;CAC5B,IAAI,QAAQ,OAAO,KAAK,IAAI;CAC5B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AyB,cAAc;AAC3C,MAAa,gBAIT,yBAAyB,YAAY;AACzC,MAAa,uBAIT,yBAAyB,mBAAmB;AAChD,MAAa,qBAKT,sCAAsC,YAAY;AACtD,MAAa,qBAKT,sCAAsC,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intl",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.23",
|
|
4
4
|
"description": "Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"format",
|
|
@@ -130,9 +130,9 @@
|
|
|
130
130
|
"./server": "./server.js"
|
|
131
131
|
},
|
|
132
132
|
"dependencies": {
|
|
133
|
-
"@formatjs/icu-messageformat-parser": "3.5.
|
|
134
|
-
"@formatjs/intl": "4.1.
|
|
135
|
-
"intl-messageformat": "11.2.
|
|
133
|
+
"@formatjs/icu-messageformat-parser": "3.5.17",
|
|
134
|
+
"@formatjs/intl": "4.1.19",
|
|
135
|
+
"intl-messageformat": "11.2.14"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"@types/react": ">=18.0.0",
|
package/react-intl.iife.js
CHANGED
|
@@ -1819,7 +1819,7 @@ const trimEnd = hasTrimEnd ? function trimEnd(s) {
|
|
|
1819
1819
|
} : function trimEnd(s) {
|
|
1820
1820
|
return s.replace(SPACE_SEPARATOR_END_REGEX, "");
|
|
1821
1821
|
};
|
|
1822
|
-
const IDENTIFIER_PREFIX_RE =
|
|
1822
|
+
const IDENTIFIER_PREFIX_RE = new RegExp("([^\\p{White_Space}\\p{Pattern_Syntax}]*)", "yu");
|
|
1823
1823
|
function matchIdentifierAtIndex(s, index) {
|
|
1824
1824
|
IDENTIFIER_PREFIX_RE.lastIndex = index;
|
|
1825
1825
|
return IDENTIFIER_PREFIX_RE.exec(s)[1] ?? "";
|
|
@@ -1906,9 +1906,10 @@ var Parser = class {
|
|
|
1906
1906
|
type: 7,
|
|
1907
1907
|
location: createLocation(position, this.clonePosition())
|
|
1908
1908
|
});
|
|
1909
|
-
} else if (char === 60 && !this.ignoreTag && this.peek() === 47)
|
|
1910
|
-
|
|
1911
|
-
|
|
1909
|
+
} else if (char === 60 && !this.ignoreTag && this.peek() === 47) {
|
|
1910
|
+
if (expectingCloseTag) break;
|
|
1911
|
+
else return this.error(26, createLocation(this.clonePosition(), this.clonePosition()));
|
|
1912
|
+
} else if (char === 60 && !this.ignoreTag && _isAlpha(this.peek() || 0)) {
|
|
1912
1913
|
const result = this.parseTag(nestingLevel, parentArgType);
|
|
1913
1914
|
if (result.err) return result;
|
|
1914
1915
|
elements.push(result.val);
|
|
@@ -2050,14 +2051,15 @@ var Parser = class {
|
|
|
2050
2051
|
this.bump();
|
|
2051
2052
|
while (!this.isEOF()) {
|
|
2052
2053
|
const ch = this.char();
|
|
2053
|
-
if (ch === 39)
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2054
|
+
if (ch === 39) {
|
|
2055
|
+
if (this.peek() === 39) {
|
|
2056
|
+
codePoints.push(39);
|
|
2057
|
+
this.bump();
|
|
2058
|
+
} else {
|
|
2059
|
+
this.bump();
|
|
2060
|
+
break;
|
|
2061
|
+
}
|
|
2062
|
+
} else codePoints.push(ch);
|
|
2061
2063
|
this.bump();
|
|
2062
2064
|
}
|
|
2063
2065
|
return String.fromCodePoint(...codePoints);
|
|
@@ -2269,9 +2271,7 @@ var Parser = class {
|
|
|
2269
2271
|
err: null
|
|
2270
2272
|
};
|
|
2271
2273
|
break;
|
|
2272
|
-
default:
|
|
2273
|
-
this.bump();
|
|
2274
|
-
break;
|
|
2274
|
+
default: this.bump();
|
|
2275
2275
|
}
|
|
2276
2276
|
return {
|
|
2277
2277
|
val: this.message.slice(startPosition.offset, this.offset()),
|
|
@@ -3444,7 +3444,8 @@ function createFormattedComponent(name) {
|
|
|
3444
3444
|
const { value, children, ...formatProps } = props;
|
|
3445
3445
|
const formattedValue = intl[name](value, formatProps);
|
|
3446
3446
|
if (typeof children === "function") return children(formattedValue);
|
|
3447
|
-
|
|
3447
|
+
const Text = intl.textComponent || React.Fragment;
|
|
3448
|
+
return /* @__PURE__ */ jsx(Text, { children: formattedValue });
|
|
3448
3449
|
};
|
|
3449
3450
|
Component.displayName = DisplayName[name];
|
|
3450
3451
|
return Component;
|
|
@@ -3460,7 +3461,8 @@ function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
|
3460
3461
|
}, {});
|
|
3461
3462
|
}
|
|
3462
3463
|
const formatMessage = (config, formatters, descriptor, rawValues, ...rest) => {
|
|
3463
|
-
const
|
|
3464
|
+
const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
|
|
3465
|
+
const chunks = formatMessage$1(config, formatters, descriptor, values, ...rest);
|
|
3464
3466
|
if (Array.isArray(chunks)) return toKeyedReactNodeArray(chunks);
|
|
3465
3467
|
return chunks;
|
|
3466
3468
|
};
|
|
@@ -3500,7 +3502,8 @@ const FormattedDateTimeRange = (props) => {
|
|
|
3500
3502
|
const { from, to, children, ...formatProps } = props;
|
|
3501
3503
|
const formattedValue = intl.formatDateTimeRange(from, to, formatProps);
|
|
3502
3504
|
if (typeof children === "function") return children(formattedValue);
|
|
3503
|
-
|
|
3505
|
+
const Text = intl.textComponent || React.Fragment;
|
|
3506
|
+
return /* @__PURE__ */ jsx(Text, { children: formattedValue });
|
|
3504
3507
|
};
|
|
3505
3508
|
FormattedDateTimeRange.displayName = "FormattedDateTimeRange";
|
|
3506
3509
|
//#endregion
|
|
@@ -3580,7 +3583,7 @@ const IntlProvider = IntlProviderImpl;
|
|
|
3580
3583
|
//#region packages/react-intl/components/relative.tsx
|
|
3581
3584
|
const MINUTE = 60;
|
|
3582
3585
|
const HOUR = 3600;
|
|
3583
|
-
const DAY =
|
|
3586
|
+
const DAY = 86400;
|
|
3584
3587
|
function selectUnit(seconds) {
|
|
3585
3588
|
const absValue = Math.abs(seconds);
|
|
3586
3589
|
if (absValue < MINUTE) return "second";
|
package/server.d.ts
CHANGED
|
@@ -23,11 +23,11 @@ interface IntlShape extends ResolvedIntlConfig, IntlFormatters<React.ReactNode>
|
|
|
23
23
|
* @param config intl config
|
|
24
24
|
* @param cache cache for formatter instances to prevent memory leak
|
|
25
25
|
*/
|
|
26
|
-
declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
|
|
26
|
+
export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region packages/react-intl/server.d.ts
|
|
29
|
-
declare function defineMessages<K extends keyof any, T = MessageDescriptor$1, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
30
|
-
declare function defineMessage<T extends MessageDescriptor$1>(msg: T): T;
|
|
29
|
+
export declare function defineMessages<K extends keyof any, T = MessageDescriptor$1, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
|
|
30
|
+
export declare function defineMessage<T extends MessageDescriptor$1>(msg: T): T;
|
|
31
31
|
//#endregion
|
|
32
|
-
export { type IntlCache, type IntlConfig, type IntlShape, type MessageDescriptor, type ResolvedIntlConfig,
|
|
32
|
+
export { type IntlCache, type IntlConfig, type IntlShape, type MessageDescriptor, type ResolvedIntlConfig, createIntlCache };
|
|
33
33
|
//# sourceMappingURL=server.d.ts.map
|
package/server.js
CHANGED
|
@@ -45,7 +45,8 @@ function assignUniqueKeysToFormatXMLElementFnArgument(values) {
|
|
|
45
45
|
}, {});
|
|
46
46
|
}
|
|
47
47
|
const formatMessage$1 = (config, formatters, descriptor, rawValues, ...rest) => {
|
|
48
|
-
const
|
|
48
|
+
const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
|
|
49
|
+
const chunks = formatMessage(config, formatters, descriptor, values, ...rest);
|
|
49
50
|
if (Array.isArray(chunks)) return toKeyedReactNodeArray(chunks);
|
|
50
51
|
return chunks;
|
|
51
52
|
};
|
package/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["DEFAULT_INTL_CONFIG","CORE_DEFAULT_INTL_CONFIG","formatMessage","coreFormatMessage","coreCreateIntl","DEFAULT_INTL_CONFIG"],"sources":["../utils.tsx","../components/createIntl.ts","../server.ts"],"sourcesContent":["import {type FormatXMLElementFn} from 'intl-messageformat'\nimport * as React from 'react'\nimport {type ResolvedIntlConfig} from '#packages/react-intl/types.js'\n\nimport {DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG} from '@formatjs/intl'\n\nexport function invariant(\n condition: boolean,\n message: string,\n Err: any = Error\n): asserts condition {\n if (!condition) {\n throw new Err(message)\n }\n}\n\nexport function invariantIntlContext(intl?: any): asserts intl {\n invariant(\n intl,\n '[React Intl] Could not find required `intl` object. ' +\n '<IntlProvider> needs to exist in the component ancestry.'\n )\n}\n\nexport type DefaultIntlConfig = Pick<\n ResolvedIntlConfig,\n | 'fallbackOnEmptyString'\n | 'formats'\n | 'messages'\n | 'timeZone'\n | 'textComponent'\n | 'defaultLocale'\n | 'defaultFormats'\n | 'onError'\n>\n\nexport const DEFAULT_INTL_CONFIG: DefaultIntlConfig = {\n ...CORE_DEFAULT_INTL_CONFIG,\n textComponent: React.Fragment,\n}\n\n/**\n * Builds an array of {@link React.ReactNode}s with index-based keys, similar to\n * {@link React.Children.toArray}. However, this function tells React that it\n * was intentional, so they won't produce a bunch of warnings about it.\n *\n * React doesn't recommend doing this because it makes reordering inefficient,\n * but we mostly need this for message chunks, which don't tend to reorder to\n * begin with.\n *\n */\nexport const toKeyedReactNodeArray: typeof React.Children.toArray =\n children => {\n const childrenArray = React.Children.toArray(children)\n\n return childrenArray.map((child, index) => {\n // For React elements, wrap in a keyed Fragment\n // This creates a new element with a key rather than trying to add one after creation\n if (React.isValidElement(child)) {\n return <React.Fragment key={index}>{child}</React.Fragment>\n }\n return child\n })\n }\n\n/**\n * Takes a `formatXMLElementFn`, and composes it in function, which passes\n * argument `parts` through, assigning unique key to each part, to prevent\n * \"Each child in a list should have a unique \"key\"\" React error.\n * @param formatXMLElementFn\n */\nexport function assignUniqueKeysToParts(\n formatXMLElementFn: FormatXMLElementFn<React.ReactNode>\n): FormatXMLElementFn<React.ReactNode> {\n return function (parts: any) {\n // eslint-disable-next-line prefer-rest-params\n return formatXMLElementFn(toKeyedReactNodeArray(parts)) as any\n }\n}\n\nexport function shallowEqual<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(objA?: T, objB?: T): boolean {\n if (objA === objB) {\n return true\n }\n\n if (!objA || !objB) {\n return false\n }\n\n var aKeys = Object.keys(objA)\n var bKeys = Object.keys(objB)\n var len = aKeys.length\n\n if (bKeys.length !== len) {\n return false\n }\n\n for (var i = 0; i < len; i++) {\n var key = aKeys[i]\n\n if (\n objA[key] !== objB[key] ||\n !Object.prototype.hasOwnProperty.call(objB, key)\n ) {\n return false\n }\n }\n\n return true\n}\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport {\n type CreateIntlFn,\n type FormatMessageFn,\n createIntl as coreCreateIntl,\n formatMessage as coreFormatMessage,\n} from '@formatjs/intl'\nimport {\n type FormatXMLElementFn,\n type PrimitiveType,\n isFormatXMLElementFn,\n} from 'intl-messageformat'\nimport * as React from 'react'\nimport type {\n IntlConfig,\n IntlShape,\n ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\nimport {\n DEFAULT_INTL_CONFIG,\n assignUniqueKeysToParts,\n toKeyedReactNodeArray,\n} from '#packages/react-intl/utils.js'\n\nfunction assignUniqueKeysToFormatXMLElementFnArgument<\n T extends Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n > = Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n >,\n>(values?: T): T | undefined {\n if (!values) {\n return values\n }\n return Object.keys(values).reduce((acc: T, k) => {\n const v = values[k]\n ;(acc as any)[k] = isFormatXMLElementFn<React.ReactNode>(v)\n ? assignUniqueKeysToParts(v)\n : v\n return acc\n }, {} as T)\n}\n\nconst formatMessage: FormatMessageFn<React.ReactNode> = (\n config,\n formatters,\n descriptor,\n rawValues,\n ...rest\n) => {\n const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues)\n const chunks = coreFormatMessage(\n config,\n formatters,\n descriptor,\n values as any,\n ...rest\n )\n if (Array.isArray(chunks)) {\n return toKeyedReactNodeArray(chunks)\n }\n return chunks\n}\n\n/**\n * Create intl object\n * @param config intl config\n * @param cache cache for formatter instances to prevent memory leak\n */\nexport const createIntl: CreateIntlFn<\n React.ReactNode,\n IntlConfig,\n IntlShape\n> = (\n {defaultRichTextElements: rawDefaultRichTextElements, ...config},\n cache\n) => {\n const defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(\n rawDefaultRichTextElements\n )\n const coreIntl = coreCreateIntl<React.ReactNode>(\n {\n ...DEFAULT_INTL_CONFIG,\n ...config,\n defaultRichTextElements,\n },\n cache\n )\n\n const resolvedConfig: ResolvedIntlConfig = {\n locale: coreIntl.locale,\n timeZone: coreIntl.timeZone,\n fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,\n formats: coreIntl.formats,\n defaultLocale: coreIntl.defaultLocale,\n defaultFormats: coreIntl.defaultFormats,\n messages: coreIntl.messages,\n onError: coreIntl.onError,\n defaultRichTextElements,\n }\n\n return {\n ...coreIntl,\n formatMessage: formatMessage.bind(\n null,\n resolvedConfig,\n coreIntl.formatters\n ),\n $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters),\n } as any\n}\n","import {type MessageDescriptor} from '@formatjs/intl'\n\nexport {\n createIntlCache,\n type IntlCache,\n type MessageDescriptor,\n} from '@formatjs/intl'\nexport {createIntl} from '#packages/react-intl/components/createIntl.js'\nexport type {\n IntlConfig,\n IntlShape,\n ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\n\n// Identity functions — duplicated here to avoid importing from \"use client\" index\nexport function defineMessages<\n K extends keyof any,\n T = MessageDescriptor,\n U extends Record<K, T> = Record<K, T>,\n>(msgs: U): U {\n return msgs\n}\n\nexport function defineMessage<T extends MessageDescriptor>(msg: T): T {\n return msg\n}\n"],"mappings":";;;;;AAoCA,MAAaA,wBAAyC;CACpD,GAAGC;CACH,eAAe,MAAM;AACvB;;;;;;;;;;;AAYA,MAAa,yBACX,aAAY;CAGV,OAFsB,MAAM,SAAS,QAAQ,QAE1B,CAAC,CAAC,KAAK,OAAO,UAAU;EAGzC,IAAI,MAAM,eAAe,KAAK,GAC5B,OAAO,oBAAC,MAAM,UAAP,EAAA,UAA6B,MAAsB,GAA9B,KAA8B;EAE5D,OAAO;CACT,CAAC;AACH;;;;;;;AAQF,SAAgB,wBACd,oBACqC;CACrC,OAAO,SAAU,OAAY;EAE3B,OAAO,mBAAmB,sBAAsB,KAAK,CAAC;CACxD;AACF;;;ACjDA,SAAS,6CAYP,QAA2B;CAC3B,IAAI,CAAC,QACH,OAAO;CAET,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,QAAQ,KAAQ,MAAM;EAC/C,MAAM,IAAI,OAAO;EAChB,IAAa,KAAK,qBAAsC,CAAC,IACtD,wBAAwB,CAAC,IACzB;EACJ,OAAO;CACT,GAAG,CAAC,CAAM;AACZ;AAEA,MAAMC,mBACJ,QACA,YACA,YACA,WACA,GAAG,SACA;
|
|
1
|
+
{"version":3,"file":"server.js","names":["DEFAULT_INTL_CONFIG","CORE_DEFAULT_INTL_CONFIG","formatMessage","coreFormatMessage","coreCreateIntl","DEFAULT_INTL_CONFIG"],"sources":["../utils.tsx","../components/createIntl.ts","../server.ts"],"sourcesContent":["import {type FormatXMLElementFn} from 'intl-messageformat'\nimport * as React from 'react'\nimport {type ResolvedIntlConfig} from '#packages/react-intl/types.js'\n\nimport {DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG} from '@formatjs/intl'\n\nexport function invariant(\n condition: boolean,\n message: string,\n Err: any = Error\n): asserts condition {\n if (!condition) {\n throw new Err(message)\n }\n}\n\nexport function invariantIntlContext(intl?: any): asserts intl {\n invariant(\n intl,\n '[React Intl] Could not find required `intl` object. ' +\n '<IntlProvider> needs to exist in the component ancestry.'\n )\n}\n\nexport type DefaultIntlConfig = Pick<\n ResolvedIntlConfig,\n | 'fallbackOnEmptyString'\n | 'formats'\n | 'messages'\n | 'timeZone'\n | 'textComponent'\n | 'defaultLocale'\n | 'defaultFormats'\n | 'onError'\n>\n\nexport const DEFAULT_INTL_CONFIG: DefaultIntlConfig = {\n ...CORE_DEFAULT_INTL_CONFIG,\n textComponent: React.Fragment,\n}\n\n/**\n * Builds an array of {@link React.ReactNode}s with index-based keys, similar to\n * {@link React.Children.toArray}. However, this function tells React that it\n * was intentional, so they won't produce a bunch of warnings about it.\n *\n * React doesn't recommend doing this because it makes reordering inefficient,\n * but we mostly need this for message chunks, which don't tend to reorder to\n * begin with.\n *\n */\nexport const toKeyedReactNodeArray: typeof React.Children.toArray =\n children => {\n const childrenArray = React.Children.toArray(children)\n\n return childrenArray.map((child, index) => {\n // For React elements, wrap in a keyed Fragment\n // This creates a new element with a key rather than trying to add one after creation\n if (React.isValidElement(child)) {\n return <React.Fragment key={index}>{child}</React.Fragment>\n }\n return child\n })\n }\n\n/**\n * Takes a `formatXMLElementFn`, and composes it in function, which passes\n * argument `parts` through, assigning unique key to each part, to prevent\n * \"Each child in a list should have a unique \"key\"\" React error.\n * @param formatXMLElementFn\n */\nexport function assignUniqueKeysToParts(\n formatXMLElementFn: FormatXMLElementFn<React.ReactNode>\n): FormatXMLElementFn<React.ReactNode> {\n return function (parts: any) {\n // eslint-disable-next-line prefer-rest-params\n return formatXMLElementFn(toKeyedReactNodeArray(parts)) as any\n }\n}\n\nexport function shallowEqual<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(objA?: T, objB?: T): boolean {\n if (objA === objB) {\n return true\n }\n\n if (!objA || !objB) {\n return false\n }\n\n var aKeys = Object.keys(objA)\n var bKeys = Object.keys(objB)\n var len = aKeys.length\n\n if (bKeys.length !== len) {\n return false\n }\n\n for (var i = 0; i < len; i++) {\n var key = aKeys[i]\n\n if (\n objA[key] !== objB[key] ||\n !Object.prototype.hasOwnProperty.call(objB, key)\n ) {\n return false\n }\n }\n\n return true\n}\n","/*\n * Copyright 2015, Yahoo Inc.\n * Copyrights licensed under the New BSD License.\n * See the accompanying LICENSE file for terms.\n */\n\nimport {\n type CreateIntlFn,\n type FormatMessageFn,\n createIntl as coreCreateIntl,\n formatMessage as coreFormatMessage,\n} from '@formatjs/intl'\nimport {\n type FormatXMLElementFn,\n type PrimitiveType,\n isFormatXMLElementFn,\n} from 'intl-messageformat'\nimport * as React from 'react'\nimport type {\n IntlConfig,\n IntlShape,\n ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\nimport {\n DEFAULT_INTL_CONFIG,\n assignUniqueKeysToParts,\n toKeyedReactNodeArray,\n} from '#packages/react-intl/utils.js'\n\nfunction assignUniqueKeysToFormatXMLElementFnArgument<\n T extends Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n > = Record<\n string,\n | PrimitiveType\n | React.ReactNode\n | FormatXMLElementFn<React.ReactNode, React.ReactNode>\n >,\n>(values?: T): T | undefined {\n if (!values) {\n return values\n }\n return Object.keys(values).reduce((acc: T, k) => {\n const v = values[k]\n ;(acc as any)[k] = isFormatXMLElementFn<React.ReactNode>(v)\n ? assignUniqueKeysToParts(v)\n : v\n return acc\n }, {} as T)\n}\n\nconst formatMessage: FormatMessageFn<React.ReactNode> = (\n config,\n formatters,\n descriptor,\n rawValues,\n ...rest\n) => {\n const values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues)\n const chunks = coreFormatMessage(\n config,\n formatters,\n descriptor,\n values as any,\n ...rest\n )\n if (Array.isArray(chunks)) {\n return toKeyedReactNodeArray(chunks)\n }\n return chunks\n}\n\n/**\n * Create intl object\n * @param config intl config\n * @param cache cache for formatter instances to prevent memory leak\n */\nexport const createIntl: CreateIntlFn<\n React.ReactNode,\n IntlConfig,\n IntlShape\n> = (\n {defaultRichTextElements: rawDefaultRichTextElements, ...config},\n cache\n) => {\n const defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(\n rawDefaultRichTextElements\n )\n const coreIntl = coreCreateIntl<React.ReactNode>(\n {\n ...DEFAULT_INTL_CONFIG,\n ...config,\n defaultRichTextElements,\n },\n cache\n )\n\n const resolvedConfig: ResolvedIntlConfig = {\n locale: coreIntl.locale,\n timeZone: coreIntl.timeZone,\n fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,\n formats: coreIntl.formats,\n defaultLocale: coreIntl.defaultLocale,\n defaultFormats: coreIntl.defaultFormats,\n messages: coreIntl.messages,\n onError: coreIntl.onError,\n defaultRichTextElements,\n }\n\n return {\n ...coreIntl,\n formatMessage: formatMessage.bind(\n null,\n resolvedConfig,\n coreIntl.formatters\n ),\n $t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters),\n } as any\n}\n","import {type MessageDescriptor} from '@formatjs/intl'\n\nexport {\n createIntlCache,\n type IntlCache,\n type MessageDescriptor,\n} from '@formatjs/intl'\nexport {createIntl} from '#packages/react-intl/components/createIntl.js'\nexport type {\n IntlConfig,\n IntlShape,\n ResolvedIntlConfig,\n} from '#packages/react-intl/types.js'\n\n// Identity functions — duplicated here to avoid importing from \"use client\" index\nexport function defineMessages<\n K extends keyof any,\n T = MessageDescriptor,\n U extends Record<K, T> = Record<K, T>,\n>(msgs: U): U {\n return msgs\n}\n\nexport function defineMessage<T extends MessageDescriptor>(msg: T): T {\n return msg\n}\n"],"mappings":";;;;;AAoCA,MAAaA,wBAAyC;CACpD,GAAGC;CACH,eAAe,MAAM;AACvB;;;;;;;;;;;AAYA,MAAa,yBACX,aAAY;CAGV,OAFsB,MAAM,SAAS,QAAQ,QAE1B,C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