node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import { IntlCache, IntlShape, IntlConfig } from './types';
export interface CreateIntlFn<T = string, C extends IntlConfig<T> = IntlConfig<T>, S extends IntlShape<T> = IntlShape<T>> {
(config: C, cache?: IntlCache): S;
}
/**
* Create intl object
* @param config intl config
* @param cache cache for formatter instances to prevent memory leak
*/
export declare function createIntl<T = string>(config: IntlConfig<T>, cache?: IntlCache): IntlShape<T>;

59
server/node_modules/@formatjs/intl/src/create-intl.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createIntl = void 0;
var tslib_1 = require("tslib");
var utils_1 = require("./utils");
var error_1 = require("./error");
var number_1 = require("./number");
var relativeTime_1 = require("./relativeTime");
var dateTime_1 = require("./dateTime");
var plural_1 = require("./plural");
var message_1 = require("./message");
var list_1 = require("./list");
var displayName_1 = require("./displayName");
function messagesContainString(messages) {
var firstMessage = messages ? messages[Object.keys(messages)[0]] : undefined;
return typeof firstMessage === 'string';
}
function verifyConfigMessages(config) {
if (config.onWarn &&
config.defaultRichTextElements &&
messagesContainString(config.messages || {})) {
config.onWarn("[@formatjs/intl] \"defaultRichTextElements\" was specified but \"message\" was not pre-compiled. \nPlease consider using \"@formatjs/cli\" to pre-compile your messages for performance.\nFor more details see https://formatjs.io/docs/getting-started/message-distribution");
}
}
/**
* Create intl object
* @param config intl config
* @param cache cache for formatter instances to prevent memory leak
*/
function createIntl(config, cache) {
var formatters = (0, utils_1.createFormatters)(cache);
var resolvedConfig = tslib_1.__assign(tslib_1.__assign({}, utils_1.DEFAULT_INTL_CONFIG), config);
var locale = resolvedConfig.locale, defaultLocale = resolvedConfig.defaultLocale, onError = resolvedConfig.onError;
if (!locale) {
if (onError) {
onError(new error_1.InvalidConfigError("\"locale\" was not configured, using \"".concat(defaultLocale, "\" as fallback. See https://formatjs.io/docs/react-intl/api#intlshape for more details")));
}
// Since there's no registered locale data for `locale`, this will
// fallback to the `defaultLocale` to make sure things can render.
// The `messages` are overridden to the `defaultProps` empty object
// to maintain referential equality across re-renders. It's assumed
// each <FormattedMessage> contains a `defaultMessage` prop.
resolvedConfig.locale = resolvedConfig.defaultLocale || 'en';
}
else if (!Intl.NumberFormat.supportedLocalesOf(locale).length && onError) {
onError(new error_1.MissingDataError("Missing locale data for locale: \"".concat(locale, "\" in Intl.NumberFormat. Using default locale: \"").concat(defaultLocale, "\" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details")));
}
else if (!Intl.DateTimeFormat.supportedLocalesOf(locale).length &&
onError) {
onError(new error_1.MissingDataError("Missing locale data for locale: \"".concat(locale, "\" in Intl.DateTimeFormat. Using default locale: \"").concat(defaultLocale, "\" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details")));
}
verifyConfigMessages(resolvedConfig);
return tslib_1.__assign(tslib_1.__assign({}, resolvedConfig), { formatters: formatters, formatNumber: number_1.formatNumber.bind(null, resolvedConfig, formatters.getNumberFormat), formatNumberToParts: number_1.formatNumberToParts.bind(null, resolvedConfig, formatters.getNumberFormat), formatRelativeTime: relativeTime_1.formatRelativeTime.bind(null, resolvedConfig, formatters.getRelativeTimeFormat), formatDate: dateTime_1.formatDate.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateToParts: dateTime_1.formatDateToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTime: dateTime_1.formatTime.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatDateTimeRange: dateTime_1.formatDateTimeRange.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatTimeToParts: dateTime_1.formatTimeToParts.bind(null, resolvedConfig, formatters.getDateTimeFormat), formatPlural: plural_1.formatPlural.bind(null, resolvedConfig, formatters.getPluralRules),
// @ts-expect-error TODO: will get to this later
formatMessage: message_1.formatMessage.bind(null, resolvedConfig, formatters),
// @ts-expect-error TODO: will get to this later
$t: message_1.formatMessage.bind(null, resolvedConfig, formatters), formatList: list_1.formatList.bind(null, resolvedConfig, formatters.getListFormat), formatListToParts: list_1.formatListToParts.bind(null, resolvedConfig, formatters.getListFormat), formatDisplayName: displayName_1.formatDisplayName.bind(null, resolvedConfig, formatters.getDisplayNames) });
}
exports.createIntl = createIntl;

37
server/node_modules/@formatjs/intl/src/dateTime.d.ts generated vendored Normal file
View File

@@ -0,0 +1,37 @@
import { Formatters, IntlFormatters, CustomFormats, OnErrorFn } from './types';
import { DateTimeFormat } from '@formatjs/ecma402-abstract';
export declare function getFormatter({ locale, formats, onError, timeZone, }: {
locale: string;
timeZone?: string;
formats: CustomFormats;
onError: OnErrorFn;
}, type: 'date' | 'time', getDateTimeFormat: Formatters['getDateTimeFormat'], options?: Parameters<IntlFormatters['formatDate']>[1]): DateTimeFormat;
export declare function formatDate(config: {
locale: string;
timeZone?: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getDateTimeFormat: Formatters['getDateTimeFormat'], ...[value, options]: Parameters<IntlFormatters['formatDate']>): string;
export declare function formatTime(config: {
locale: string;
timeZone?: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getDateTimeFormat: Formatters['getDateTimeFormat'], ...[value, options]: Parameters<IntlFormatters['formatTime']>): string;
export declare function formatDateTimeRange(config: {
locale: string;
timeZone?: string;
onError: OnErrorFn;
}, getDateTimeFormat: Formatters['getDateTimeFormat'], ...[from, to, options]: Parameters<IntlFormatters['formatDateTimeRange']>): string;
export declare function formatDateToParts(config: {
locale: string;
timeZone?: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getDateTimeFormat: Formatters['getDateTimeFormat'], ...[value, options]: Parameters<IntlFormatters['formatDate']>): Intl.DateTimeFormatPart[];
export declare function formatTimeToParts(config: {
locale: string;
timeZone?: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getDateTimeFormat: Formatters['getDateTimeFormat'], ...[value, options]: Parameters<IntlFormatters['formatTimeToParts']>): Intl.DateTimeFormatPart[];

126
server/node_modules/@formatjs/intl/src/dateTime.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTimeToParts = exports.formatDateToParts = exports.formatDateTimeRange = exports.formatTime = exports.formatDate = exports.getFormatter = void 0;
var tslib_1 = require("tslib");
var utils_1 = require("./utils");
var error_1 = require("./error");
var DATE_TIME_FORMAT_OPTIONS = [
'formatMatcher',
'timeZone',
'hour12',
'weekday',
'era',
'year',
'month',
'day',
'hour',
'minute',
'second',
'timeZoneName',
'hourCycle',
'dateStyle',
'timeStyle',
'calendar',
// 'dayPeriod',
'numberingSystem',
'fractionalSecondDigits',
];
function getFormatter(_a, type, getDateTimeFormat, options) {
var locale = _a.locale, formats = _a.formats, onError = _a.onError, timeZone = _a.timeZone;
if (options === void 0) { options = {}; }
var format = options.format;
var defaults = tslib_1.__assign(tslib_1.__assign({}, (timeZone && { timeZone: timeZone })), (format && (0, utils_1.getNamedFormat)(formats, type, format, onError)));
var filteredOptions = (0, utils_1.filterProps)(options, DATE_TIME_FORMAT_OPTIONS, defaults);
if (type === 'time' &&
!filteredOptions.hour &&
!filteredOptions.minute &&
!filteredOptions.second &&
!filteredOptions.timeStyle &&
!filteredOptions.dateStyle) {
// Add default formatting options if hour, minute, or second isn't defined.
filteredOptions = tslib_1.__assign(tslib_1.__assign({}, filteredOptions), { hour: 'numeric', minute: 'numeric' });
}
return getDateTimeFormat(locale, filteredOptions);
}
exports.getFormatter = getFormatter;
function formatDate(config, getDateTimeFormat) {
var _a = [];
for (var _i = 2; _i < arguments.length; _i++) {
_a[_i - 2] = arguments[_i];
}
var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
var date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'date', getDateTimeFormat, options).format(date);
}
catch (e) {
config.onError(new error_1.IntlFormatError('Error formatting date.', config.locale, e));
}
return String(date);
}
exports.formatDate = formatDate;
function formatTime(config, getDateTimeFormat) {
var _a = [];
for (var _i = 2; _i < arguments.length; _i++) {
_a[_i - 2] = arguments[_i];
}
var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
var date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'time', getDateTimeFormat, options).format(date);
}
catch (e) {
config.onError(new error_1.IntlFormatError('Error formatting time.', config.locale, e));
}
return String(date);
}
exports.formatTime = formatTime;
function formatDateTimeRange(config, getDateTimeFormat) {
var _a = [];
for (var _i = 2; _i < arguments.length; _i++) {
_a[_i - 2] = arguments[_i];
}
var from = _a[0], to = _a[1], _b = _a[2], options = _b === void 0 ? {} : _b;
var timeZone = config.timeZone, locale = config.locale, onError = config.onError;
var filteredOptions = (0, utils_1.filterProps)(options, DATE_TIME_FORMAT_OPTIONS, timeZone ? { timeZone: timeZone } : {});
try {
return getDateTimeFormat(locale, filteredOptions).formatRange(from, to);
}
catch (e) {
onError(new error_1.IntlFormatError('Error formatting date time range.', config.locale, e));
}
return String(from);
}
exports.formatDateTimeRange = formatDateTimeRange;
function formatDateToParts(config, getDateTimeFormat) {
var _a = [];
for (var _i = 2; _i < arguments.length; _i++) {
_a[_i - 2] = arguments[_i];
}
var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
var date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'date', getDateTimeFormat, options).formatToParts(date); // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged
}
catch (e) {
config.onError(new error_1.IntlFormatError('Error formatting date.', config.locale, e));
}
return [];
}
exports.formatDateToParts = formatDateToParts;
function formatTimeToParts(config, getDateTimeFormat) {
var _a = [];
for (var _i = 2; _i < arguments.length; _i++) {
_a[_i - 2] = arguments[_i];
}
var value = _a[0], _b = _a[1], options = _b === void 0 ? {} : _b;
var date = typeof value === 'string' ? new Date(value || 0) : value;
try {
return getFormatter(config, 'time', getDateTimeFormat, options).formatToParts(date); // TODO: remove this when https://github.com/microsoft/TypeScript/pull/50402 is merged
}
catch (e) {
config.onError(new error_1.IntlFormatError('Error formatting time.', config.locale, e));
}
return [];
}
exports.formatTimeToParts = formatTimeToParts;

View File

@@ -0,0 +1,5 @@
import { Formatters, IntlFormatters, OnErrorFn } from './types';
export declare function formatDisplayName({ locale, onError, }: {
locale: string;
onError: OnErrorFn;
}, getDisplayNames: Formatters['getDisplayNames'], value: Parameters<IntlFormatters['formatDisplayName']>[0], options: Parameters<IntlFormatters['formatDisplayName']>[1]): string | undefined;

27
server/node_modules/@formatjs/intl/src/displayName.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatDisplayName = void 0;
var utils_1 = require("./utils");
var intl_messageformat_1 = require("intl-messageformat");
var error_1 = require("./error");
var DISPLAY_NAMES_OPTONS = [
'style',
'type',
'fallback',
'languageDisplay',
];
function formatDisplayName(_a, getDisplayNames, value, options) {
var locale = _a.locale, onError = _a.onError;
var DisplayNames = Intl.DisplayNames;
if (!DisplayNames) {
onError(new intl_messageformat_1.FormatError("Intl.DisplayNames is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-displaynames\"\n", intl_messageformat_1.ErrorCode.MISSING_INTL_API));
}
var filteredOptions = (0, utils_1.filterProps)(options, DISPLAY_NAMES_OPTONS);
try {
return getDisplayNames(locale, filteredOptions).of(value);
}
catch (e) {
onError(new error_1.IntlFormatError('Error formatting display name.', locale, e));
}
}
exports.formatDisplayName = formatDisplayName;

35
server/node_modules/@formatjs/intl/src/error.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
import { MessageDescriptor } from './types';
export declare enum IntlErrorCode {
FORMAT_ERROR = "FORMAT_ERROR",
UNSUPPORTED_FORMATTER = "UNSUPPORTED_FORMATTER",
INVALID_CONFIG = "INVALID_CONFIG",
MISSING_DATA = "MISSING_DATA",
MISSING_TRANSLATION = "MISSING_TRANSLATION"
}
export declare class IntlError<T extends IntlErrorCode = IntlErrorCode.FORMAT_ERROR> extends Error {
readonly code: T;
constructor(code: T, message: string, exception?: Error | unknown);
}
export declare class UnsupportedFormatterError extends IntlError<IntlErrorCode.UNSUPPORTED_FORMATTER> {
constructor(message: string, exception?: Error | unknown);
}
export declare class InvalidConfigError extends IntlError<IntlErrorCode.INVALID_CONFIG> {
constructor(message: string, exception?: Error | unknown);
}
export declare class MissingDataError extends IntlError<IntlErrorCode.MISSING_DATA> {
constructor(message: string, exception?: Error | unknown);
}
export declare class IntlFormatError extends IntlError<IntlErrorCode.FORMAT_ERROR> {
readonly descriptor?: MessageDescriptor;
readonly locale: string;
constructor(message: string, locale: string, exception?: Error | unknown);
}
export declare class MessageFormatError extends IntlFormatError {
readonly descriptor?: MessageDescriptor;
readonly locale: string;
constructor(message: string, locale: string, descriptor?: MessageDescriptor, exception?: Error | unknown);
}
export declare class MissingTranslationError extends IntlError<IntlErrorCode.MISSING_TRANSLATION> {
readonly descriptor?: MessageDescriptor;
constructor(descriptor: MessageDescriptor, locale: string);
}

94
server/node_modules/@formatjs/intl/src/error.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MissingTranslationError = exports.MessageFormatError = exports.IntlFormatError = exports.MissingDataError = exports.InvalidConfigError = exports.UnsupportedFormatterError = exports.IntlError = exports.IntlErrorCode = void 0;
var tslib_1 = require("tslib");
var IntlErrorCode;
(function (IntlErrorCode) {
IntlErrorCode["FORMAT_ERROR"] = "FORMAT_ERROR";
IntlErrorCode["UNSUPPORTED_FORMATTER"] = "UNSUPPORTED_FORMATTER";
IntlErrorCode["INVALID_CONFIG"] = "INVALID_CONFIG";
IntlErrorCode["MISSING_DATA"] = "MISSING_DATA";
IntlErrorCode["MISSING_TRANSLATION"] = "MISSING_TRANSLATION";
})(IntlErrorCode || (exports.IntlErrorCode = IntlErrorCode = {}));
var IntlError = /** @class */ (function (_super) {
tslib_1.__extends(IntlError, _super);
function IntlError(code, message, exception) {
var _this = this;
var err = exception
? exception instanceof Error
? exception
: new Error(String(exception))
: undefined;
_this = _super.call(this, "[@formatjs/intl Error ".concat(code, "] ").concat(message, "\n").concat(err ? "\n".concat(err.message, "\n").concat(err.stack) : '')) || this;
_this.code = code;
// @ts-ignore just so we don't need to declare dep on @types/node
if (typeof Error.captureStackTrace === 'function') {
// @ts-ignore just so we don't need to declare dep on @types/node
Error.captureStackTrace(_this, IntlError);
}
return _this;
}
return IntlError;
}(Error));
exports.IntlError = IntlError;
var UnsupportedFormatterError = /** @class */ (function (_super) {
tslib_1.__extends(UnsupportedFormatterError, _super);
function UnsupportedFormatterError(message, exception) {
return _super.call(this, IntlErrorCode.UNSUPPORTED_FORMATTER, message, exception) || this;
}
return UnsupportedFormatterError;
}(IntlError));
exports.UnsupportedFormatterError = UnsupportedFormatterError;
var InvalidConfigError = /** @class */ (function (_super) {
tslib_1.__extends(InvalidConfigError, _super);
function InvalidConfigError(message, exception) {
return _super.call(this, IntlErrorCode.INVALID_CONFIG, message, exception) || this;
}
return InvalidConfigError;
}(IntlError));
exports.InvalidConfigError = InvalidConfigError;
var MissingDataError = /** @class */ (function (_super) {
tslib_1.__extends(MissingDataError, _super);
function MissingDataError(message, exception) {
return _super.call(this, IntlErrorCode.MISSING_DATA, message, exception) || this;
}
return MissingDataError;
}(IntlError));
exports.MissingDataError = MissingDataError;
var IntlFormatError = /** @class */ (function (_super) {
tslib_1.__extends(IntlFormatError, _super);
function IntlFormatError(message, locale, exception) {
var _this = _super.call(this, IntlErrorCode.FORMAT_ERROR, "".concat(message, "\nLocale: ").concat(locale, "\n"), exception) || this;
_this.locale = locale;
return _this;
}
return IntlFormatError;
}(IntlError));
exports.IntlFormatError = IntlFormatError;
var MessageFormatError = /** @class */ (function (_super) {
tslib_1.__extends(MessageFormatError, _super);
function MessageFormatError(message, locale, descriptor, exception) {
var _this = _super.call(this, "".concat(message, "\nMessageID: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.id, "\nDefault Message: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.defaultMessage, "\nDescription: ").concat(descriptor === null || descriptor === void 0 ? void 0 : descriptor.description, "\n"), locale, exception) || this;
_this.descriptor = descriptor;
_this.locale = locale;
return _this;
}
return MessageFormatError;
}(IntlFormatError));
exports.MessageFormatError = MessageFormatError;
var MissingTranslationError = /** @class */ (function (_super) {
tslib_1.__extends(MissingTranslationError, _super);
function MissingTranslationError(descriptor, locale) {
var _this = _super.call(this, IntlErrorCode.MISSING_TRANSLATION, "Missing message: \"".concat(descriptor.id, "\" for locale \"").concat(locale, "\", using ").concat(descriptor.defaultMessage
? "default message (".concat(typeof descriptor.defaultMessage === 'string'
? descriptor.defaultMessage
: descriptor.defaultMessage
.map(function (e) { var _a; return (_a = e.value) !== null && _a !== void 0 ? _a : JSON.stringify(e); })
.join(), ")")
: 'id', " as fallback.")) || this;
_this.descriptor = descriptor;
return _this;
}
return MissingTranslationError;
}(IntlError));
exports.MissingTranslationError = MissingTranslationError;

10
server/node_modules/@formatjs/intl/src/list.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import { Formatters, IntlFormatters, OnErrorFn } from './types';
import type { Part } from '@formatjs/intl-listformat';
export declare function formatList(opts: {
locale: string;
onError: OnErrorFn;
}, getListFormat: Formatters['getListFormat'], values: ReadonlyArray<string>, options: Parameters<IntlFormatters['formatList']>[1]): string;
export declare function formatListToParts<T>(opts: {
locale: string;
onError: OnErrorFn;
}, getListFormat: Formatters['getListFormat'], values: ReadonlyArray<string | T>, options: Parameters<IntlFormatters['formatList']>[1]): Part[];

66
server/node_modules/@formatjs/intl/src/list.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatListToParts = exports.formatList = void 0;
var tslib_1 = require("tslib");
var utils_1 = require("./utils");
var intl_messageformat_1 = require("intl-messageformat");
var error_1 = require("./error");
var LIST_FORMAT_OPTIONS = [
'type',
'style',
];
var now = Date.now();
function generateToken(i) {
return "".concat(now, "_").concat(i, "_").concat(now);
}
function formatList(opts, getListFormat, values, options) {
if (options === void 0) { options = {}; }
var results = formatListToParts(opts, getListFormat, values, options).reduce(function (all, el) {
var val = el.value;
if (typeof val !== 'string') {
all.push(val);
}
else if (typeof all[all.length - 1] === 'string') {
all[all.length - 1] += val;
}
else {
all.push(val);
}
return all;
}, []);
return results.length === 1 ? results[0] : results.length === 0 ? '' : results;
}
exports.formatList = formatList;
function formatListToParts(_a, getListFormat, values, options) {
var locale = _a.locale, onError = _a.onError;
if (options === void 0) { options = {}; }
var ListFormat = Intl.ListFormat;
if (!ListFormat) {
onError(new intl_messageformat_1.FormatError("Intl.ListFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-listformat\"\n", intl_messageformat_1.ErrorCode.MISSING_INTL_API));
}
var filteredOptions = (0, utils_1.filterProps)(options, LIST_FORMAT_OPTIONS);
try {
var richValues_1 = {};
var serializedValues = values.map(function (v, i) {
if (typeof v === 'object') {
var id = generateToken(i);
richValues_1[id] = v;
return id;
}
return String(v);
});
return getListFormat(locale, filteredOptions)
.formatToParts(serializedValues)
.map(function (part) {
return part.type === 'literal'
? part
: tslib_1.__assign(tslib_1.__assign({}, part), { value: richValues_1[part.value] || part.value });
});
}
catch (e) {
onError(new error_1.IntlFormatError('Error formatting list.', locale, e));
}
// @ts-ignore
return values;
}
exports.formatListToParts = formatListToParts;

15
server/node_modules/@formatjs/intl/src/message.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { Formatters, MessageDescriptor, CustomFormats, OnErrorFn } from './types';
import { FormatXMLElementFn, PrimitiveType, Formatters as IntlMessageFormatFormatters, Options } from 'intl-messageformat';
import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
export type FormatMessageFn<T> = ({ locale, formats, messages, defaultLocale, defaultFormats, fallbackOnEmptyString, onError, timeZone, defaultRichTextElements, }: {
locale: string;
timeZone?: string;
formats: CustomFormats;
messages: Record<string, string> | Record<string, MessageFormatElement[]>;
defaultLocale: string;
defaultFormats: CustomFormats;
defaultRichTextElements?: Record<string, FormatXMLElementFn<T>>;
fallbackOnEmptyString?: boolean;
onError: OnErrorFn;
}, state: IntlMessageFormatFormatters & Pick<Formatters, 'getMessageFormat'>, messageDescriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: Options) => T extends string ? string : Array<T | string> | string | T;
export declare const formatMessage: FormatMessageFn<any>;

107
server/node_modules/@formatjs/intl/src/message.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatMessage = void 0;
var tslib_1 = require("tslib");
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
var intl_messageformat_1 = require("intl-messageformat");
var error_1 = require("./error");
var icu_messageformat_parser_1 = require("@formatjs/icu-messageformat-parser");
function setTimeZoneInOptions(opts, timeZone) {
return Object.keys(opts).reduce(function (all, k) {
all[k] = tslib_1.__assign({ timeZone: timeZone }, opts[k]);
return all;
}, {});
}
function deepMergeOptions(opts1, opts2) {
var keys = Object.keys(tslib_1.__assign(tslib_1.__assign({}, opts1), opts2));
return keys.reduce(function (all, k) {
all[k] = tslib_1.__assign(tslib_1.__assign({}, (opts1[k] || {})), (opts2[k] || {}));
return all;
}, {});
}
function deepMergeFormatsAndSetTimeZone(f1, timeZone) {
if (!timeZone) {
return f1;
}
var mfFormats = intl_messageformat_1.IntlMessageFormat.formats;
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, mfFormats), f1), { date: deepMergeOptions(setTimeZoneInOptions(mfFormats.date, timeZone), setTimeZoneInOptions(f1.date || {}, timeZone)), time: deepMergeOptions(setTimeZoneInOptions(mfFormats.time, timeZone), setTimeZoneInOptions(f1.time || {}, timeZone)) });
}
var formatMessage = function (_a, state, messageDescriptor, values, opts) {
var locale = _a.locale, formats = _a.formats, messages = _a.messages, defaultLocale = _a.defaultLocale, defaultFormats = _a.defaultFormats, fallbackOnEmptyString = _a.fallbackOnEmptyString, onError = _a.onError, timeZone = _a.timeZone, defaultRichTextElements = _a.defaultRichTextElements;
if (messageDescriptor === void 0) { messageDescriptor = { id: '' }; }
var msgId = messageDescriptor.id, defaultMessage = messageDescriptor.defaultMessage;
// `id` is a required field of a Message Descriptor.
(0, ecma402_abstract_1.invariant)(!!msgId, "[@formatjs/intl] An `id` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.io/docs/tooling/ts-transformer) OR\n2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.io/docs/tooling/linter#enforce-id)\nto autofix this issue");
var id = String(msgId);
var message =
// In case messages is Object.create(null)
// e.g import('foo.json') from webpack)
// See https://github.com/formatjs/formatjs/issues/1914
messages &&
Object.prototype.hasOwnProperty.call(messages, id) &&
messages[id];
// IMPORTANT: Hot path if `message` is AST with a single literal node
if (Array.isArray(message) &&
message.length === 1 &&
message[0].type === icu_messageformat_parser_1.TYPE.literal) {
return message[0].value;
}
// IMPORTANT: Hot path straight lookup for performance
if (!values &&
message &&
typeof message === 'string' &&
!defaultRichTextElements) {
return message.replace(/'\{(.*?)\}'/gi, "{$1}");
}
values = tslib_1.__assign(tslib_1.__assign({}, defaultRichTextElements), (values || {}));
formats = deepMergeFormatsAndSetTimeZone(formats, timeZone);
defaultFormats = deepMergeFormatsAndSetTimeZone(defaultFormats, timeZone);
if (!message) {
if (fallbackOnEmptyString === false && message === '') {
return message;
}
if (!defaultMessage ||
(locale && locale.toLowerCase() !== defaultLocale.toLowerCase())) {
// This prevents warnings from littering the console in development
// when no `messages` are passed into the <IntlProvider> for the
// default locale.
onError(new error_1.MissingTranslationError(messageDescriptor, locale));
}
if (defaultMessage) {
try {
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
return formatter.format(values);
}
catch (e) {
onError(new error_1.MessageFormatError("Error formatting default message for: \"".concat(id, "\", rendering default message verbatim"), locale, messageDescriptor, e));
return typeof defaultMessage === 'string' ? defaultMessage : id;
}
}
return id;
}
// We have the translated message
try {
var formatter = state.getMessageFormat(message, locale, formats, tslib_1.__assign({ formatters: state }, (opts || {})));
return formatter.format(values);
}
catch (e) {
onError(new error_1.MessageFormatError("Error formatting message: \"".concat(id, "\", using ").concat(defaultMessage ? 'default message' : 'id', " as fallback."), locale, messageDescriptor, e));
}
if (defaultMessage) {
try {
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats, opts);
return formatter.format(values);
}
catch (e) {
onError(new error_1.MessageFormatError("Error formatting the default message for: \"".concat(id, "\", rendering message verbatim"), locale, messageDescriptor, e));
}
}
if (typeof message === 'string') {
return message;
}
if (typeof defaultMessage === 'string') {
return defaultMessage;
}
return id;
};
exports.formatMessage = formatMessage;

16
server/node_modules/@formatjs/intl/src/number.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import { CustomFormats, Formatters, IntlFormatters, OnErrorFn } from './types';
export declare function getFormatter({ locale, formats, onError, }: {
locale: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getNumberFormat: Formatters['getNumberFormat'], options?: Parameters<IntlFormatters['formatNumber']>[1]): Intl.NumberFormat;
export declare function formatNumber(config: {
locale: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getNumberFormat: Formatters['getNumberFormat'], value: Parameters<IntlFormatters['formatNumber']>[0], options?: Parameters<IntlFormatters['formatNumber']>[1]): string;
export declare function formatNumberToParts(config: {
locale: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getNumberFormat: Formatters['getNumberFormat'], value: Parameters<IntlFormatters['formatNumber']>[0], options?: Parameters<IntlFormatters['formatNumber']>[1]): Intl.NumberFormatPart[];

64
server/node_modules/@formatjs/intl/src/number.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatNumberToParts = exports.formatNumber = exports.getFormatter = void 0;
var error_1 = require("./error");
var utils_1 = require("./utils");
var NUMBER_FORMAT_OPTIONS = [
'style',
'currency',
'unit',
'unitDisplay',
'useGrouping',
'minimumIntegerDigits',
'minimumFractionDigits',
'maximumFractionDigits',
'minimumSignificantDigits',
'maximumSignificantDigits',
// ES2020 NumberFormat
'compactDisplay',
'currencyDisplay',
'currencySign',
'notation',
'signDisplay',
'unit',
'unitDisplay',
'numberingSystem',
// ES2023 NumberFormat
'trailingZeroDisplay',
'roundingPriority',
'roundingIncrement',
'roundingMode',
];
function getFormatter(_a, getNumberFormat, options) {
var locale = _a.locale, formats = _a.formats, onError = _a.onError;
if (options === void 0) { options = {}; }
var format = options.format;
var defaults = ((format &&
(0, utils_1.getNamedFormat)(formats, 'number', format, onError)) ||
{});
var filteredOptions = (0, utils_1.filterProps)(options, NUMBER_FORMAT_OPTIONS, defaults);
return getNumberFormat(locale, filteredOptions);
}
exports.getFormatter = getFormatter;
function formatNumber(config, getNumberFormat, value, options) {
if (options === void 0) { options = {}; }
try {
return getFormatter(config, getNumberFormat, options).format(value);
}
catch (e) {
config.onError(new error_1.IntlFormatError('Error formatting number.', config.locale, e));
}
return String(value);
}
exports.formatNumber = formatNumber;
function formatNumberToParts(config, getNumberFormat, value, options) {
if (options === void 0) { options = {}; }
try {
return getFormatter(config, getNumberFormat, options).formatToParts(value);
}
catch (e) {
config.onError(new error_1.IntlFormatError('Error formatting number.', config.locale, e));
}
return [];
}
exports.formatNumberToParts = formatNumberToParts;

6
server/node_modules/@formatjs/intl/src/plural.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { Formatters, IntlFormatters, OnErrorFn } from './types';
import { LDMLPluralRule } from '@formatjs/ecma402-abstract';
export declare function formatPlural({ locale, onError, }: {
locale: string;
onError: OnErrorFn;
}, getPluralRules: Formatters['getPluralRules'], value: Parameters<IntlFormatters['formatPlural']>[0], options?: Parameters<IntlFormatters['formatPlural']>[1]): LDMLPluralRule;

23
server/node_modules/@formatjs/intl/src/plural.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatPlural = void 0;
var utils_1 = require("./utils");
var error_1 = require("./error");
var intl_messageformat_1 = require("intl-messageformat");
var PLURAL_FORMAT_OPTIONS = ['type'];
function formatPlural(_a, getPluralRules, value, options) {
var locale = _a.locale, onError = _a.onError;
if (options === void 0) { options = {}; }
if (!Intl.PluralRules) {
onError(new intl_messageformat_1.FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", intl_messageformat_1.ErrorCode.MISSING_INTL_API));
}
var filteredOptions = (0, utils_1.filterProps)(options, PLURAL_FORMAT_OPTIONS);
try {
return getPluralRules(locale, filteredOptions).select(value);
}
catch (e) {
onError(new error_1.IntlFormatError('Error formatting plural.', locale, e));
}
return 'other';
}
exports.formatPlural = formatPlural;

View File

@@ -0,0 +1,6 @@
import { IntlFormatters, Formatters, CustomFormats, OnErrorFn } from './types';
export declare function formatRelativeTime(config: {
locale: string;
formats: CustomFormats;
onError: OnErrorFn;
}, getRelativeTimeFormat: Formatters['getRelativeTimeFormat'], value: Parameters<IntlFormatters['formatRelativeTime']>[0], unit?: Parameters<IntlFormatters['formatRelativeTime']>[1], options?: Parameters<IntlFormatters['formatRelativeTime']>[2]): string;

33
server/node_modules/@formatjs/intl/src/relativeTime.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatRelativeTime = void 0;
var utils_1 = require("./utils");
var intl_messageformat_1 = require("intl-messageformat");
var error_1 = require("./error");
var RELATIVE_TIME_FORMAT_OPTIONS = ['numeric', 'style'];
function getFormatter(_a, getRelativeTimeFormat, options) {
var locale = _a.locale, formats = _a.formats, onError = _a.onError;
if (options === void 0) { options = {}; }
var format = options.format;
var defaults = (!!format && (0, utils_1.getNamedFormat)(formats, 'relative', format, onError)) || {};
var filteredOptions = (0, utils_1.filterProps)(options, RELATIVE_TIME_FORMAT_OPTIONS, defaults);
return getRelativeTimeFormat(locale, filteredOptions);
}
function formatRelativeTime(config, getRelativeTimeFormat, value, unit, options) {
if (options === void 0) { options = {}; }
if (!unit) {
unit = 'second';
}
var RelativeTimeFormat = Intl.RelativeTimeFormat;
if (!RelativeTimeFormat) {
config.onError(new intl_messageformat_1.FormatError("Intl.RelativeTimeFormat is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-relativetimeformat\"\n", intl_messageformat_1.ErrorCode.MISSING_INTL_API));
}
try {
return getFormatter(config, getRelativeTimeFormat, options).format(value, unit);
}
catch (e) {
config.onError(new error_1.IntlFormatError('Error formatting relative time.', config.locale, e));
}
return String(value);
}
exports.formatRelativeTime = formatRelativeTime;

106
server/node_modules/@formatjs/intl/src/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,106 @@
import { IntlMessageFormat, Formats, FormatXMLElementFn, FormatError, PrimitiveType, Options as IntlMessageFormatOptions } from 'intl-messageformat';
import { DateTimeFormat } from '@formatjs/ecma402-abstract';
import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
import IntlListFormat, { IntlListFormatOptions, Part } from '@formatjs/intl-listformat';
import { DisplayNames, DisplayNamesOptions } from '@formatjs/intl-displaynames';
import { MissingTranslationError, MessageFormatError, MissingDataError, InvalidConfigError, UnsupportedFormatterError } from './error';
import { DEFAULT_INTL_CONFIG } from './utils';
import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
declare global {
namespace FormatjsIntl {
interface Message {
}
interface IntlConfig {
}
interface Formats {
}
}
}
type MessageIds = FormatjsIntl.Message extends {
ids: infer T;
} ? T extends string ? T : string : string;
type Locale = FormatjsIntl.IntlConfig extends {
locale: infer T;
} ? T extends string ? T : string : string;
export type OnErrorFn = (err: MissingTranslationError | MessageFormatError | MissingDataError | InvalidConfigError | UnsupportedFormatterError | FormatError) => void;
export type OnWarnFn = (warning: string) => void;
/**
* Config for intl object.
* Generic type T is the type of potential rich text element. For example:
* With React, T would be React.ReactNode
*/
export interface ResolvedIntlConfig<T = string> {
locale: Locale;
timeZone?: string;
fallbackOnEmptyString?: boolean;
formats: CustomFormats;
messages: Record<MessageIds, string> | Record<MessageIds, MessageFormatElement[]>;
defaultLocale: string;
defaultFormats: CustomFormats;
defaultRichTextElements?: Record<string, FormatXMLElementFn<T>>;
onError: OnErrorFn;
onWarn?: OnWarnFn;
}
export interface CustomFormats extends Partial<Formats> {
relative?: Record<string, Intl.RelativeTimeFormatOptions>;
}
export interface CustomFormatConfig<Source = string> {
format?: Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
}
export type FormatDateOptions = Omit<Intl.DateTimeFormatOptions, 'localeMatcher'> & CustomFormatConfig<'date'>;
export type FormatNumberOptions = Omit<NumberFormatOptions, 'localeMatcher'> & CustomFormatConfig<'number'>;
export type FormatRelativeTimeOptions = Omit<Intl.RelativeTimeFormatOptions, 'localeMatcher'> & CustomFormatConfig<'time'>;
export type FormatPluralOptions = Omit<Intl.PluralRulesOptions, 'localeMatcher'> & CustomFormatConfig;
export type FormatListOptions = Omit<IntlListFormatOptions, 'localeMatcher'>;
export type FormatDisplayNameOptions = Omit<DisplayNamesOptions, 'localeMatcher'>;
/**
* `TBase` is the type constraints of the rich text element in the formatted output.
* For example, with React, `TBase` should be `React.ReactNode`.
*/
export interface IntlFormatters<TBase = unknown> {
formatDateTimeRange(from: Parameters<DateTimeFormat['formatRange']>[0], to: Parameters<DateTimeFormat['formatRange']>[1], opts?: FormatDateOptions): string;
formatDate(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
formatTime(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): string;
formatDateToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
formatTimeToParts(value: Parameters<Intl.DateTimeFormat['format']>[0] | string, opts?: FormatDateOptions): Intl.DateTimeFormatPart[];
formatRelativeTime(value: Parameters<Intl.RelativeTimeFormat['format']>[0], unit?: Parameters<Intl.RelativeTimeFormat['format']>[1], opts?: FormatRelativeTimeOptions): string;
formatNumber(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): string;
formatNumberToParts(value: Parameters<Intl.NumberFormat['format']>[0], opts?: FormatNumberOptions): Intl.NumberFormatPart[];
formatPlural(value: Parameters<Intl.PluralRules['select']>[0], opts?: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>;
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
formatMessage<T extends TBase>(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
$t(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>, opts?: IntlMessageFormatOptions): string;
$t<T extends TBase>(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, opts?: IntlMessageFormatOptions): string | T | (T | string)[];
formatList(values: ReadonlyArray<string>, opts?: FormatListOptions): string;
formatList<T extends TBase>(values: ReadonlyArray<string | T>, opts?: FormatListOptions): T | string | (string | T)[];
formatListToParts<T extends TBase>(values: ReadonlyArray<string | T>, opts?: FormatListOptions): Part[];
formatDisplayName(value: Parameters<DisplayNames['of']>[0], opts: FormatDisplayNameOptions): string | undefined;
}
export interface Formatters {
getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): DateTimeFormat;
getNumberFormat(locales?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
getMessageFormat(...args: ConstructorParameters<typeof IntlMessageFormat>): IntlMessageFormat;
getRelativeTimeFormat(...args: ConstructorParameters<typeof Intl.RelativeTimeFormat>): Intl.RelativeTimeFormat;
getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
getListFormat(...args: ConstructorParameters<typeof IntlListFormat>): IntlListFormat;
getDisplayNames(...args: ConstructorParameters<typeof DisplayNames>): DisplayNames;
}
export interface IntlShape<T = string> extends ResolvedIntlConfig<T>, IntlFormatters<T> {
formatters: Formatters;
}
export interface IntlCache {
dateTime: Record<string, DateTimeFormat>;
number: Record<string, Intl.NumberFormat>;
message: Record<string, IntlMessageFormat>;
relativeTime: Record<string, Intl.RelativeTimeFormat>;
pluralRules: Record<string, Intl.PluralRules>;
list: Record<string, IntlListFormat>;
displayNames: Record<string, DisplayNames>;
}
export interface MessageDescriptor {
id?: MessageIds;
description?: string | object;
defaultMessage?: string | MessageFormatElement[];
}
export type IntlConfig<T = string> = Omit<ResolvedIntlConfig<T>, keyof typeof DEFAULT_INTL_CONFIG> & Partial<typeof DEFAULT_INTL_CONFIG>;
export {};

2
server/node_modules/@formatjs/intl/src/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

11
server/node_modules/@formatjs/intl/src/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { IntlCache, CustomFormats, Formatters, OnErrorFn, ResolvedIntlConfig } from './types';
import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
export declare function filterProps<T extends Record<string, any>, K extends string>(props: T, allowlist: Array<K>, defaults?: Partial<T>): Pick<T, K>;
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig<any>, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'defaultLocale' | 'defaultFormats' | 'onError' | 'onWarn'>;
export declare function createIntlCache(): IntlCache;
/**
* Create intl formatters and populate cache
* @param cache explicit cache to prevent leaking memory
*/
export declare function createFormatters(cache?: IntlCache): Formatters;
export declare function getNamedFormat<T extends keyof CustomFormats>(formats: CustomFormats, type: T, name: string, onError: OnErrorFn): NumberFormatOptions | Intl.DateTimeFormatOptions | Intl.RelativeTimeFormatOptions | undefined;

169
server/node_modules/@formatjs/intl/src/utils.js generated vendored Normal file
View File

@@ -0,0 +1,169 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNamedFormat = exports.createFormatters = exports.createIntlCache = exports.DEFAULT_INTL_CONFIG = exports.filterProps = void 0;
var tslib_1 = require("tslib");
var intl_messageformat_1 = require("intl-messageformat");
var fast_memoize_1 = require("@formatjs/fast-memoize");
var error_1 = require("./error");
function filterProps(props, allowlist, defaults) {
if (defaults === void 0) { defaults = {}; }
return allowlist.reduce(function (filtered, name) {
if (name in props) {
filtered[name] = props[name];
}
else if (name in defaults) {
filtered[name] = defaults[name];
}
return filtered;
}, {});
}
exports.filterProps = filterProps;
var defaultErrorHandler = function (error) {
// @ts-ignore just so we don't need to declare dep on @types/node
if (process.env.NODE_ENV !== 'production') {
console.error(error);
}
};
var defaultWarnHandler = function (warning) {
// @ts-ignore just so we don't need to declare dep on @types/node
if (process.env.NODE_ENV !== 'production') {
console.warn(warning);
}
};
exports.DEFAULT_INTL_CONFIG = {
formats: {},
messages: {},
timeZone: undefined,
defaultLocale: 'en',
defaultFormats: {},
fallbackOnEmptyString: true,
onError: defaultErrorHandler,
onWarn: defaultWarnHandler,
};
function createIntlCache() {
return {
dateTime: {},
number: {},
message: {},
relativeTime: {},
pluralRules: {},
list: {},
displayNames: {},
};
}
exports.createIntlCache = createIntlCache;
function createFastMemoizeCache(store) {
return {
create: function () {
return {
get: function (key) {
return store[key];
},
set: function (key, value) {
store[key] = value;
},
};
},
};
}
/**
* Create intl formatters and populate cache
* @param cache explicit cache to prevent leaking memory
*/
function createFormatters(cache) {
if (cache === void 0) { cache = createIntlCache(); }
var RelativeTimeFormat = Intl.RelativeTimeFormat;
var ListFormat = Intl.ListFormat;
var DisplayNames = Intl.DisplayNames;
var getDateTimeFormat = (0, fast_memoize_1.memoize)(function () {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, tslib_1.__spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.dateTime),
strategy: fast_memoize_1.strategies.variadic,
});
var getNumberFormat = (0, fast_memoize_1.memoize)(function () {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new ((_a = Intl.NumberFormat).bind.apply(_a, tslib_1.__spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.number),
strategy: fast_memoize_1.strategies.variadic,
});
var getPluralRules = (0, fast_memoize_1.memoize)(function () {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new ((_a = Intl.PluralRules).bind.apply(_a, tslib_1.__spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.pluralRules),
strategy: fast_memoize_1.strategies.variadic,
});
return {
getDateTimeFormat: getDateTimeFormat,
getNumberFormat: getNumberFormat,
getMessageFormat: (0, fast_memoize_1.memoize)(function (message, locales, overrideFormats, opts) {
return new intl_messageformat_1.IntlMessageFormat(message, locales, overrideFormats, tslib_1.__assign({ formatters: {
getNumberFormat: getNumberFormat,
getDateTimeFormat: getDateTimeFormat,
getPluralRules: getPluralRules,
} }, (opts || {})));
}, {
cache: createFastMemoizeCache(cache.message),
strategy: fast_memoize_1.strategies.variadic,
}),
getRelativeTimeFormat: (0, fast_memoize_1.memoize)(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new (RelativeTimeFormat.bind.apply(RelativeTimeFormat, tslib_1.__spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.relativeTime),
strategy: fast_memoize_1.strategies.variadic,
}),
getPluralRules: getPluralRules,
getListFormat: (0, fast_memoize_1.memoize)(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new (ListFormat.bind.apply(ListFormat, tslib_1.__spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.list),
strategy: fast_memoize_1.strategies.variadic,
}),
getDisplayNames: (0, fast_memoize_1.memoize)(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return new (DisplayNames.bind.apply(DisplayNames, tslib_1.__spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.displayNames),
strategy: fast_memoize_1.strategies.variadic,
}),
};
}
exports.createFormatters = createFormatters;
function getNamedFormat(formats, type, name, onError) {
var formatType = formats && formats[type];
var format;
if (formatType) {
format = formatType[name];
}
if (format) {
return format;
}
onError(new error_1.UnsupportedFormatterError("No ".concat(type, " format named: ").concat(name)));
}
exports.getNamedFormat = getNamedFormat;