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

33
server/node_modules/intl-messageformat/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,33 @@
Copyright (c) 2023, Oath Inc.
Licensed under the terms of the New BSD license. See below for terms.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
- Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
- Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
- Neither the name of Oath Inc. nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of Oath Inc.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

3
server/node_modules/intl-messageformat/README.md generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Intl MessageFormat
We've migrated the docs to https://formatjs.io/docs/intl-messageformat.

6
server/node_modules/intl-messageformat/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { IntlMessageFormat } from './src/core';
export * from './src/core';
export * from './src/error';
export * from './src/formatters';
export { IntlMessageFormat };
export default IntlMessageFormat;

15
server/node_modules/intl-messageformat/index.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
"use strict";
/*
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntlMessageFormat = void 0;
var tslib_1 = require("tslib");
var core_1 = require("./src/core");
Object.defineProperty(exports, "IntlMessageFormat", { enumerable: true, get: function () { return core_1.IntlMessageFormat; } });
tslib_1.__exportStar(require("./src/core"), exports);
tslib_1.__exportStar(require("./src/error"), exports);
tslib_1.__exportStar(require("./src/formatters"), exports);
exports.default = core_1.IntlMessageFormat;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
import { IntlMessageFormat } from './src/core';
export * from './src/core';
export * from './src/error';
export * from './src/formatters';
export { IntlMessageFormat };
export default IntlMessageFormat;

11
server/node_modules/intl-messageformat/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
/*
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/
import { IntlMessageFormat } from './src/core';
export * from './src/core';
export * from './src/error';
export * from './src/formatters';
export { IntlMessageFormat };
export default IntlMessageFormat;

View File

@@ -0,0 +1,26 @@
import { parse, MessageFormatElement, ParserOptions } from '@formatjs/icu-messageformat-parser';
import { Formatters, Formats, FormatXMLElementFn, PrimitiveType, MessageFormatPart } from './formatters';
export interface Options extends Omit<ParserOptions, 'locale'> {
formatters?: Formatters;
}
export declare class IntlMessageFormat {
private readonly ast;
private readonly locales;
private readonly resolvedLocale?;
private readonly formatters;
private readonly formats;
private readonly message;
private readonly formatterCache;
constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
format: <T = void>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>> | undefined) => string | T | (string | T)[];
formatToParts: <T>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>> | undefined) => MessageFormatPart<T>[];
resolvedOptions: () => {
locale: string;
};
getAst: () => MessageFormatElement[];
private static memoizedDefaultLocale;
static get defaultLocale(): string;
static resolveLocale: (locales: string | string[]) => Intl.Locale | undefined;
static __parse: typeof parse | undefined;
static formats: Formats;
}

238
server/node_modules/intl-messageformat/lib/src/core.js generated vendored Normal file
View File

@@ -0,0 +1,238 @@
/*
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/
import { __assign, __rest, __spreadArray } from "tslib";
import { parse, } from '@formatjs/icu-messageformat-parser';
import { memoize, strategies } from '@formatjs/fast-memoize';
import { formatToParts, PART_TYPE, } from './formatters';
// -- MessageFormat --------------------------------------------------------
function mergeConfig(c1, c2) {
if (!c2) {
return c1;
}
return __assign(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {
all[k] = __assign(__assign({}, c1[k]), (c2[k] || {}));
return all;
}, {}));
}
function mergeConfigs(defaultConfig, configs) {
if (!configs) {
return defaultConfig;
}
return Object.keys(defaultConfig).reduce(function (all, k) {
all[k] = mergeConfig(defaultConfig[k], configs[k]);
return all;
}, __assign({}, defaultConfig));
}
function createFastMemoizeCache(store) {
return {
create: function () {
return {
get: function (key) {
return store[key];
},
set: function (key, value) {
store[key] = value;
},
};
},
};
}
function createDefaultFormatters(cache) {
if (cache === void 0) { cache = {
number: {},
dateTime: {},
pluralRules: {},
}; }
return {
getNumberFormat: 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, __spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.number),
strategy: strategies.variadic,
}),
getDateTimeFormat: 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, __spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.dateTime),
strategy: strategies.variadic,
}),
getPluralRules: 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, __spreadArray([void 0], args, false)))();
}, {
cache: createFastMemoizeCache(cache.pluralRules),
strategy: strategies.variadic,
}),
};
}
var IntlMessageFormat = /** @class */ (function () {
function IntlMessageFormat(message, locales, overrideFormats, opts) {
var _this = this;
if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
this.formatterCache = {
number: {},
dateTime: {},
pluralRules: {},
};
this.format = function (values) {
var parts = _this.formatToParts(values);
// Hot path for straight simple msg translations
if (parts.length === 1) {
return parts[0].value;
}
var result = parts.reduce(function (all, part) {
if (!all.length ||
part.type !== PART_TYPE.literal ||
typeof all[all.length - 1] !== 'string') {
all.push(part.value);
}
else {
all[all.length - 1] += part.value;
}
return all;
}, []);
if (result.length <= 1) {
return result[0] || '';
}
return result;
};
this.formatToParts = function (values) {
return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
};
this.resolvedOptions = function () {
var _a;
return ({
locale: ((_a = _this.resolvedLocale) === null || _a === void 0 ? void 0 : _a.toString()) ||
Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
});
};
this.getAst = function () { return _this.ast; };
// Defined first because it's used to build the format pattern.
this.locales = locales;
this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);
if (typeof message === 'string') {
this.message = message;
if (!IntlMessageFormat.__parse) {
throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
}
var _a = opts || {}, formatters = _a.formatters, parseOpts = __rest(_a, ["formatters"]);
// Parse string messages into an AST.
this.ast = IntlMessageFormat.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale }));
}
else {
this.ast = message;
}
if (!Array.isArray(this.ast)) {
throw new TypeError('A message must be provided as a String or AST.');
}
// Creates a new object with the specified `formats` merged with the default
// formats.
this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
this.formatters =
(opts && opts.formatters) || createDefaultFormatters(this.formatterCache);
}
Object.defineProperty(IntlMessageFormat, "defaultLocale", {
get: function () {
if (!IntlMessageFormat.memoizedDefaultLocale) {
IntlMessageFormat.memoizedDefaultLocale =
new Intl.NumberFormat().resolvedOptions().locale;
}
return IntlMessageFormat.memoizedDefaultLocale;
},
enumerable: false,
configurable: true
});
IntlMessageFormat.memoizedDefaultLocale = null;
IntlMessageFormat.resolveLocale = function (locales) {
if (typeof Intl.Locale === 'undefined') {
return;
}
var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
if (supportedLocales.length > 0) {
return new Intl.Locale(supportedLocales[0]);
}
return new Intl.Locale(typeof locales === 'string' ? locales : locales[0]);
};
IntlMessageFormat.__parse = parse;
// Default format options used as the prototype of the `formats` provided to the
// constructor. These are used when constructing the internal Intl.NumberFormat
// and Intl.DateTimeFormat instances.
IntlMessageFormat.formats = {
number: {
integer: {
maximumFractionDigits: 0,
},
currency: {
style: 'currency',
},
percent: {
style: 'percent',
},
},
date: {
short: {
month: 'numeric',
day: 'numeric',
year: '2-digit',
},
medium: {
month: 'short',
day: 'numeric',
year: 'numeric',
},
long: {
month: 'long',
day: 'numeric',
year: 'numeric',
},
full: {
weekday: 'long',
month: 'long',
day: 'numeric',
year: 'numeric',
},
},
time: {
short: {
hour: 'numeric',
minute: 'numeric',
},
medium: {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
},
long: {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZoneName: 'short',
},
full: {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZoneName: 'short',
},
},
};
return IntlMessageFormat;
}());
export { IntlMessageFormat };

View File

@@ -0,0 +1,27 @@
export declare enum ErrorCode {
MISSING_VALUE = "MISSING_VALUE",
INVALID_VALUE = "INVALID_VALUE",
MISSING_INTL_API = "MISSING_INTL_API"
}
export declare class FormatError extends Error {
readonly code: ErrorCode;
/**
* Original message we're trying to format
* `undefined` if we're only dealing w/ AST
*
* @type {(string | undefined)}
* @memberof FormatError
*/
readonly originalMessage: string | undefined;
constructor(msg: string, code: ErrorCode, originalMessage?: string);
toString(): string;
}
export declare class InvalidValueError extends FormatError {
constructor(variableId: string, value: any, options: string[], originalMessage?: string);
}
export declare class InvalidValueTypeError extends FormatError {
constructor(value: any, type: string, originalMessage?: string);
}
export declare class MissingValueError extends FormatError {
constructor(variableId: string, originalMessage?: string);
}

View File

@@ -0,0 +1,48 @@
import { __extends } from "tslib";
export var ErrorCode;
(function (ErrorCode) {
// When we have a placeholder but no value to format
ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
// When value supplied is invalid
ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
// When we need specific Intl API but it's not available
ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
})(ErrorCode || (ErrorCode = {}));
var FormatError = /** @class */ (function (_super) {
__extends(FormatError, _super);
function FormatError(msg, code, originalMessage) {
var _this = _super.call(this, msg) || this;
_this.code = code;
_this.originalMessage = originalMessage;
return _this;
}
FormatError.prototype.toString = function () {
return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
};
return FormatError;
}(Error));
export { FormatError };
var InvalidValueError = /** @class */ (function (_super) {
__extends(InvalidValueError, _super);
function InvalidValueError(variableId, value, options, originalMessage) {
return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this;
}
return InvalidValueError;
}(FormatError));
export { InvalidValueError };
var InvalidValueTypeError = /** @class */ (function (_super) {
__extends(InvalidValueTypeError, _super);
function InvalidValueTypeError(value, type, originalMessage) {
return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
}
return InvalidValueTypeError;
}(FormatError));
export { InvalidValueTypeError };
var MissingValueError = /** @class */ (function (_super) {
__extends(MissingValueError, _super);
function MissingValueError(variableId, originalMessage) {
return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this;
}
return MissingValueError;
}(FormatError));
export { MissingValueError };

View File

@@ -0,0 +1,46 @@
import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
declare global {
namespace FormatjsIntl {
interface Message {
}
interface IntlConfig {
}
interface Formats {
}
}
}
type Format<Source = string> = Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
export interface Formats {
number: Record<Format<'number'>, NumberFormatOptions>;
date: Record<Format<'date'>, Intl.DateTimeFormatOptions>;
time: Record<Format<'time'>, Intl.DateTimeFormatOptions>;
}
export interface FormatterCache {
number: Record<string, NumberFormatOptions>;
dateTime: Record<string, Intl.DateTimeFormat>;
pluralRules: Record<string, Intl.PluralRules>;
}
export interface Formatters {
getNumberFormat(locals?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
}
export declare enum PART_TYPE {
literal = 0,
object = 1
}
export interface LiteralPart {
type: PART_TYPE.literal;
value: string;
}
export interface ObjectPart<T = any> {
type: PART_TYPE.object;
value: T;
}
export type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
export type PrimitiveType = string | number | boolean | null | undefined | Date;
export declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
export declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
export type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
export {};

View File

@@ -0,0 +1,177 @@
import { isArgumentElement, isDateElement, isDateTimeSkeleton, isLiteralElement, isNumberElement, isNumberSkeleton, isPluralElement, isPoundElement, isSelectElement, isTimeElement, isTagElement, } from '@formatjs/icu-messageformat-parser';
import { MissingValueError, InvalidValueError, ErrorCode, FormatError, InvalidValueTypeError, } from './error';
export var PART_TYPE;
(function (PART_TYPE) {
PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
PART_TYPE[PART_TYPE["object"] = 1] = "object";
})(PART_TYPE || (PART_TYPE = {}));
function mergeLiteral(parts) {
if (parts.length < 2) {
return parts;
}
return parts.reduce(function (all, part) {
var lastPart = all[all.length - 1];
if (!lastPart ||
lastPart.type !== PART_TYPE.literal ||
part.type !== PART_TYPE.literal) {
all.push(part);
}
else {
lastPart.value += part.value;
}
return all;
}, []);
}
export function isFormatXMLElementFn(el) {
return typeof el === 'function';
}
// TODO(skeleton): add skeleton support
export function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
// For debugging
originalMessage) {
// Hot path for straight simple msg translations
if (els.length === 1 && isLiteralElement(els[0])) {
return [
{
type: PART_TYPE.literal,
value: els[0].value,
},
];
}
var result = [];
for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
var el = els_1[_i];
// Exit early for string parts.
if (isLiteralElement(el)) {
result.push({
type: PART_TYPE.literal,
value: el.value,
});
continue;
}
// TODO: should this part be literal type?
// Replace `#` in plural rules with the actual numeric value.
if (isPoundElement(el)) {
if (typeof currentPluralValue === 'number') {
result.push({
type: PART_TYPE.literal,
value: formatters.getNumberFormat(locales).format(currentPluralValue),
});
}
continue;
}
var varName = el.value;
// Enforce that all required values are provided by the caller.
if (!(values && varName in values)) {
throw new MissingValueError(varName, originalMessage);
}
var value = values[varName];
if (isArgumentElement(el)) {
if (!value || typeof value === 'string' || typeof value === 'number') {
value =
typeof value === 'string' || typeof value === 'number'
? String(value)
: '';
}
result.push({
type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,
value: value,
});
continue;
}
// Recursively format plural and select parts' option — which can be a
// nested pattern structure. The choosing of the option to use is
// abstracted-by and delegated-to the part helper object.
if (isDateElement(el)) {
var style = typeof el.style === 'string'
? formats.date[el.style]
: isDateTimeSkeleton(el.style)
? el.style.parsedOptions
: undefined;
result.push({
type: PART_TYPE.literal,
value: formatters
.getDateTimeFormat(locales, style)
.format(value),
});
continue;
}
if (isTimeElement(el)) {
var style = typeof el.style === 'string'
? formats.time[el.style]
: isDateTimeSkeleton(el.style)
? el.style.parsedOptions
: formats.time.medium;
result.push({
type: PART_TYPE.literal,
value: formatters
.getDateTimeFormat(locales, style)
.format(value),
});
continue;
}
if (isNumberElement(el)) {
var style = typeof el.style === 'string'
? formats.number[el.style]
: isNumberSkeleton(el.style)
? el.style.parsedOptions
: undefined;
if (style && style.scale) {
value =
value *
(style.scale || 1);
}
result.push({
type: PART_TYPE.literal,
value: formatters
.getNumberFormat(locales, style)
.format(value),
});
continue;
}
if (isTagElement(el)) {
var children = el.children, value_1 = el.value;
var formatFn = values[value_1];
if (!isFormatXMLElementFn(formatFn)) {
throw new InvalidValueTypeError(value_1, 'function', originalMessage);
}
var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
var chunks = formatFn(parts.map(function (p) { return p.value; }));
if (!Array.isArray(chunks)) {
chunks = [chunks];
}
result.push.apply(result, chunks.map(function (c) {
return {
type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,
value: c,
};
}));
}
if (isSelectElement(el)) {
var opt = el.options[value] || el.options.other;
if (!opt) {
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
}
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
continue;
}
if (isPluralElement(el)) {
var opt = el.options["=".concat(value)];
if (!opt) {
if (!Intl.PluralRules) {
throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
}
var rule = formatters
.getPluralRules(locales, { type: el.pluralType })
.select(value - (el.offset || 0));
opt = el.options[rule] || el.options.other;
}
if (!opt) {
throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
}
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
continue;
}
}
return mergeLiteral(result);
}

43
server/node_modules/intl-messageformat/package.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "intl-messageformat",
"version": "10.5.11",
"description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
"keywords": [
"i18n",
"intl",
"internationalization",
"localization",
"globalization",
"messageformat",
"parser",
"plural",
"icu"
],
"author": "Eric Ferraiuolo <eferraiuolo@gmail.com>",
"contributors": [
"Anthony Pipkin <a.pipkin@yahoo.com>",
"Caridy Patino <caridy@gmail.com>",
"Drew Folta <drew@folta.net>",
"Long Ho <holevietlong@gmail.com"
],
"bugs": {
"url": "https://github.com/formatjs/formatjs/issues"
},
"repository": {
"type": "git",
"url": "git@github.com:formatjs/formatjs.git"
},
"main": "index.js",
"module": "lib/index.js",
"types": "index.d.ts",
"dependencies": {
"tslib": "^2.4.0",
"@formatjs/ecma402-abstract": "1.18.2",
"@formatjs/icu-messageformat-parser": "2.7.6",
"@formatjs/fast-memoize": "2.2.0"
},
"sideEffects": false,
"homepage": "https://github.com/formatjs/formatjs",
"license": "BSD-3-Clause",
"gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c"
}

26
server/node_modules/intl-messageformat/src/core.d.ts generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import { parse, MessageFormatElement, ParserOptions } from '@formatjs/icu-messageformat-parser';
import { Formatters, Formats, FormatXMLElementFn, PrimitiveType, MessageFormatPart } from './formatters';
export interface Options extends Omit<ParserOptions, 'locale'> {
formatters?: Formatters;
}
export declare class IntlMessageFormat {
private readonly ast;
private readonly locales;
private readonly resolvedLocale?;
private readonly formatters;
private readonly formats;
private readonly message;
private readonly formatterCache;
constructor(message: string | MessageFormatElement[], locales?: string | string[], overrideFormats?: Partial<Formats>, opts?: Options);
format: <T = void>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>> | undefined) => string | T | (string | T)[];
formatToParts: <T>(values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>> | undefined) => MessageFormatPart<T>[];
resolvedOptions: () => {
locale: string;
};
getAst: () => MessageFormatElement[];
private static memoizedDefaultLocale;
static get defaultLocale(): string;
static resolveLocale: (locales: string | string[]) => Intl.Locale | undefined;
static __parse: typeof parse | undefined;
static formats: Formats;
}

241
server/node_modules/intl-messageformat/src/core.js generated vendored Normal file
View File

@@ -0,0 +1,241 @@
"use strict";
/*
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntlMessageFormat = void 0;
var tslib_1 = require("tslib");
var icu_messageformat_parser_1 = require("@formatjs/icu-messageformat-parser");
var fast_memoize_1 = require("@formatjs/fast-memoize");
var formatters_1 = require("./formatters");
// -- MessageFormat --------------------------------------------------------
function mergeConfig(c1, c2) {
if (!c2) {
return c1;
}
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {
all[k] = tslib_1.__assign(tslib_1.__assign({}, c1[k]), (c2[k] || {}));
return all;
}, {}));
}
function mergeConfigs(defaultConfig, configs) {
if (!configs) {
return defaultConfig;
}
return Object.keys(defaultConfig).reduce(function (all, k) {
all[k] = mergeConfig(defaultConfig[k], configs[k]);
return all;
}, tslib_1.__assign({}, defaultConfig));
}
function createFastMemoizeCache(store) {
return {
create: function () {
return {
get: function (key) {
return store[key];
},
set: function (key, value) {
store[key] = value;
},
};
},
};
}
function createDefaultFormatters(cache) {
if (cache === void 0) { cache = {
number: {},
dateTime: {},
pluralRules: {},
}; }
return {
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,
}),
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,
}),
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,
}),
};
}
var IntlMessageFormat = /** @class */ (function () {
function IntlMessageFormat(message, locales, overrideFormats, opts) {
var _this = this;
if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
this.formatterCache = {
number: {},
dateTime: {},
pluralRules: {},
};
this.format = function (values) {
var parts = _this.formatToParts(values);
// Hot path for straight simple msg translations
if (parts.length === 1) {
return parts[0].value;
}
var result = parts.reduce(function (all, part) {
if (!all.length ||
part.type !== formatters_1.PART_TYPE.literal ||
typeof all[all.length - 1] !== 'string') {
all.push(part.value);
}
else {
all[all.length - 1] += part.value;
}
return all;
}, []);
if (result.length <= 1) {
return result[0] || '';
}
return result;
};
this.formatToParts = function (values) {
return (0, formatters_1.formatToParts)(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
};
this.resolvedOptions = function () {
var _a;
return ({
locale: ((_a = _this.resolvedLocale) === null || _a === void 0 ? void 0 : _a.toString()) ||
Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
});
};
this.getAst = function () { return _this.ast; };
// Defined first because it's used to build the format pattern.
this.locales = locales;
this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);
if (typeof message === 'string') {
this.message = message;
if (!IntlMessageFormat.__parse) {
throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
}
var _a = opts || {}, formatters = _a.formatters, parseOpts = tslib_1.__rest(_a, ["formatters"]);
// Parse string messages into an AST.
this.ast = IntlMessageFormat.__parse(message, tslib_1.__assign(tslib_1.__assign({}, parseOpts), { locale: this.resolvedLocale }));
}
else {
this.ast = message;
}
if (!Array.isArray(this.ast)) {
throw new TypeError('A message must be provided as a String or AST.');
}
// Creates a new object with the specified `formats` merged with the default
// formats.
this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
this.formatters =
(opts && opts.formatters) || createDefaultFormatters(this.formatterCache);
}
Object.defineProperty(IntlMessageFormat, "defaultLocale", {
get: function () {
if (!IntlMessageFormat.memoizedDefaultLocale) {
IntlMessageFormat.memoizedDefaultLocale =
new Intl.NumberFormat().resolvedOptions().locale;
}
return IntlMessageFormat.memoizedDefaultLocale;
},
enumerable: false,
configurable: true
});
IntlMessageFormat.memoizedDefaultLocale = null;
IntlMessageFormat.resolveLocale = function (locales) {
if (typeof Intl.Locale === 'undefined') {
return;
}
var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
if (supportedLocales.length > 0) {
return new Intl.Locale(supportedLocales[0]);
}
return new Intl.Locale(typeof locales === 'string' ? locales : locales[0]);
};
IntlMessageFormat.__parse = icu_messageformat_parser_1.parse;
// Default format options used as the prototype of the `formats` provided to the
// constructor. These are used when constructing the internal Intl.NumberFormat
// and Intl.DateTimeFormat instances.
IntlMessageFormat.formats = {
number: {
integer: {
maximumFractionDigits: 0,
},
currency: {
style: 'currency',
},
percent: {
style: 'percent',
},
},
date: {
short: {
month: 'numeric',
day: 'numeric',
year: '2-digit',
},
medium: {
month: 'short',
day: 'numeric',
year: 'numeric',
},
long: {
month: 'long',
day: 'numeric',
year: 'numeric',
},
full: {
weekday: 'long',
month: 'long',
day: 'numeric',
year: 'numeric',
},
},
time: {
short: {
hour: 'numeric',
minute: 'numeric',
},
medium: {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
},
long: {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZoneName: 'short',
},
full: {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
timeZoneName: 'short',
},
},
};
return IntlMessageFormat;
}());
exports.IntlMessageFormat = IntlMessageFormat;

27
server/node_modules/intl-messageformat/src/error.d.ts generated vendored Normal file
View File

@@ -0,0 +1,27 @@
export declare enum ErrorCode {
MISSING_VALUE = "MISSING_VALUE",
INVALID_VALUE = "INVALID_VALUE",
MISSING_INTL_API = "MISSING_INTL_API"
}
export declare class FormatError extends Error {
readonly code: ErrorCode;
/**
* Original message we're trying to format
* `undefined` if we're only dealing w/ AST
*
* @type {(string | undefined)}
* @memberof FormatError
*/
readonly originalMessage: string | undefined;
constructor(msg: string, code: ErrorCode, originalMessage?: string);
toString(): string;
}
export declare class InvalidValueError extends FormatError {
constructor(variableId: string, value: any, options: string[], originalMessage?: string);
}
export declare class InvalidValueTypeError extends FormatError {
constructor(value: any, type: string, originalMessage?: string);
}
export declare class MissingValueError extends FormatError {
constructor(variableId: string, originalMessage?: string);
}

51
server/node_modules/intl-messageformat/src/error.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MissingValueError = exports.InvalidValueTypeError = exports.InvalidValueError = exports.FormatError = exports.ErrorCode = void 0;
var tslib_1 = require("tslib");
var ErrorCode;
(function (ErrorCode) {
// When we have a placeholder but no value to format
ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
// When value supplied is invalid
ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
// When we need specific Intl API but it's not available
ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
var FormatError = /** @class */ (function (_super) {
tslib_1.__extends(FormatError, _super);
function FormatError(msg, code, originalMessage) {
var _this = _super.call(this, msg) || this;
_this.code = code;
_this.originalMessage = originalMessage;
return _this;
}
FormatError.prototype.toString = function () {
return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
};
return FormatError;
}(Error));
exports.FormatError = FormatError;
var InvalidValueError = /** @class */ (function (_super) {
tslib_1.__extends(InvalidValueError, _super);
function InvalidValueError(variableId, value, options, originalMessage) {
return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this;
}
return InvalidValueError;
}(FormatError));
exports.InvalidValueError = InvalidValueError;
var InvalidValueTypeError = /** @class */ (function (_super) {
tslib_1.__extends(InvalidValueTypeError, _super);
function InvalidValueTypeError(value, type, originalMessage) {
return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
}
return InvalidValueTypeError;
}(FormatError));
exports.InvalidValueTypeError = InvalidValueTypeError;
var MissingValueError = /** @class */ (function (_super) {
tslib_1.__extends(MissingValueError, _super);
function MissingValueError(variableId, originalMessage) {
return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this;
}
return MissingValueError;
}(FormatError));
exports.MissingValueError = MissingValueError;

View File

@@ -0,0 +1,46 @@
import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
import { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
declare global {
namespace FormatjsIntl {
interface Message {
}
interface IntlConfig {
}
interface Formats {
}
}
}
type Format<Source = string> = Source extends keyof FormatjsIntl.Formats ? FormatjsIntl.Formats[Source] : string;
export interface Formats {
number: Record<Format<'number'>, NumberFormatOptions>;
date: Record<Format<'date'>, Intl.DateTimeFormatOptions>;
time: Record<Format<'time'>, Intl.DateTimeFormatOptions>;
}
export interface FormatterCache {
number: Record<string, NumberFormatOptions>;
dateTime: Record<string, Intl.DateTimeFormat>;
pluralRules: Record<string, Intl.PluralRules>;
}
export interface Formatters {
getNumberFormat(locals?: string | string[], opts?: NumberFormatOptions): Intl.NumberFormat;
getDateTimeFormat(...args: ConstructorParameters<typeof Intl.DateTimeFormat>): Intl.DateTimeFormat;
getPluralRules(...args: ConstructorParameters<typeof Intl.PluralRules>): Intl.PluralRules;
}
export declare enum PART_TYPE {
literal = 0,
object = 1
}
export interface LiteralPart {
type: PART_TYPE.literal;
value: string;
}
export interface ObjectPart<T = any> {
type: PART_TYPE.object;
value: T;
}
export type MessageFormatPart<T> = LiteralPart | ObjectPart<T>;
export type PrimitiveType = string | number | boolean | null | undefined | Date;
export declare function isFormatXMLElementFn<T>(el: PrimitiveType | T | FormatXMLElementFn<T>): el is FormatXMLElementFn<T>;
export declare function formatToParts<T>(els: MessageFormatElement[], locales: string | string[], formatters: Formatters, formats: Formats, values?: Record<string, PrimitiveType | T | FormatXMLElementFn<T>>, currentPluralValue?: number, originalMessage?: string): MessageFormatPart<T>[];
export type FormatXMLElementFn<T, R = string | T | (string | T)[]> = (parts: Array<string | T>) => R;
export {};

View File

@@ -0,0 +1,182 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatToParts = exports.isFormatXMLElementFn = exports.PART_TYPE = void 0;
var icu_messageformat_parser_1 = require("@formatjs/icu-messageformat-parser");
var error_1 = require("./error");
var PART_TYPE;
(function (PART_TYPE) {
PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
PART_TYPE[PART_TYPE["object"] = 1] = "object";
})(PART_TYPE || (exports.PART_TYPE = PART_TYPE = {}));
function mergeLiteral(parts) {
if (parts.length < 2) {
return parts;
}
return parts.reduce(function (all, part) {
var lastPart = all[all.length - 1];
if (!lastPart ||
lastPart.type !== PART_TYPE.literal ||
part.type !== PART_TYPE.literal) {
all.push(part);
}
else {
lastPart.value += part.value;
}
return all;
}, []);
}
function isFormatXMLElementFn(el) {
return typeof el === 'function';
}
exports.isFormatXMLElementFn = isFormatXMLElementFn;
// TODO(skeleton): add skeleton support
function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
// For debugging
originalMessage) {
// Hot path for straight simple msg translations
if (els.length === 1 && (0, icu_messageformat_parser_1.isLiteralElement)(els[0])) {
return [
{
type: PART_TYPE.literal,
value: els[0].value,
},
];
}
var result = [];
for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
var el = els_1[_i];
// Exit early for string parts.
if ((0, icu_messageformat_parser_1.isLiteralElement)(el)) {
result.push({
type: PART_TYPE.literal,
value: el.value,
});
continue;
}
// TODO: should this part be literal type?
// Replace `#` in plural rules with the actual numeric value.
if ((0, icu_messageformat_parser_1.isPoundElement)(el)) {
if (typeof currentPluralValue === 'number') {
result.push({
type: PART_TYPE.literal,
value: formatters.getNumberFormat(locales).format(currentPluralValue),
});
}
continue;
}
var varName = el.value;
// Enforce that all required values are provided by the caller.
if (!(values && varName in values)) {
throw new error_1.MissingValueError(varName, originalMessage);
}
var value = values[varName];
if ((0, icu_messageformat_parser_1.isArgumentElement)(el)) {
if (!value || typeof value === 'string' || typeof value === 'number') {
value =
typeof value === 'string' || typeof value === 'number'
? String(value)
: '';
}
result.push({
type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,
value: value,
});
continue;
}
// Recursively format plural and select parts' option — which can be a
// nested pattern structure. The choosing of the option to use is
// abstracted-by and delegated-to the part helper object.
if ((0, icu_messageformat_parser_1.isDateElement)(el)) {
var style = typeof el.style === 'string'
? formats.date[el.style]
: (0, icu_messageformat_parser_1.isDateTimeSkeleton)(el.style)
? el.style.parsedOptions
: undefined;
result.push({
type: PART_TYPE.literal,
value: formatters
.getDateTimeFormat(locales, style)
.format(value),
});
continue;
}
if ((0, icu_messageformat_parser_1.isTimeElement)(el)) {
var style = typeof el.style === 'string'
? formats.time[el.style]
: (0, icu_messageformat_parser_1.isDateTimeSkeleton)(el.style)
? el.style.parsedOptions
: formats.time.medium;
result.push({
type: PART_TYPE.literal,
value: formatters
.getDateTimeFormat(locales, style)
.format(value),
});
continue;
}
if ((0, icu_messageformat_parser_1.isNumberElement)(el)) {
var style = typeof el.style === 'string'
? formats.number[el.style]
: (0, icu_messageformat_parser_1.isNumberSkeleton)(el.style)
? el.style.parsedOptions
: undefined;
if (style && style.scale) {
value =
value *
(style.scale || 1);
}
result.push({
type: PART_TYPE.literal,
value: formatters
.getNumberFormat(locales, style)
.format(value),
});
continue;
}
if ((0, icu_messageformat_parser_1.isTagElement)(el)) {
var children = el.children, value_1 = el.value;
var formatFn = values[value_1];
if (!isFormatXMLElementFn(formatFn)) {
throw new error_1.InvalidValueTypeError(value_1, 'function', originalMessage);
}
var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
var chunks = formatFn(parts.map(function (p) { return p.value; }));
if (!Array.isArray(chunks)) {
chunks = [chunks];
}
result.push.apply(result, chunks.map(function (c) {
return {
type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,
value: c,
};
}));
}
if ((0, icu_messageformat_parser_1.isSelectElement)(el)) {
var opt = el.options[value] || el.options.other;
if (!opt) {
throw new error_1.InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
}
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
continue;
}
if ((0, icu_messageformat_parser_1.isPluralElement)(el)) {
var opt = el.options["=".concat(value)];
if (!opt) {
if (!Intl.PluralRules) {
throw new error_1.FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", error_1.ErrorCode.MISSING_INTL_API, originalMessage);
}
var rule = formatters
.getPluralRules(locales, { type: el.pluralType })
.select(value - (el.offset || 0));
opt = el.options[rule] || el.options.other;
}
if (!opt) {
throw new error_1.InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
}
result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
continue;
}
}
return mergeLiteral(result);
}
exports.formatToParts = formatToParts;