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 @@
export declare function CanonicalCodeForDisplayNames(type: 'language' | 'region' | 'script' | 'calendar' | 'dateTimeField' | 'currency', code: string): string;

View File

@@ -0,0 +1,48 @@
import { CanonicalizeLocaleList, invariant, IsWellFormedCurrencyCode, } from '@formatjs/ecma402-abstract';
import { IsValidDateTimeFieldCode } from './IsValidDateTimeFieldCode';
var UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
var ALPHA_4 = /^[a-z]{4}$/i;
var UNICODE_TYPE_REGEX = /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i;
function isUnicodeRegionSubtag(region) {
return UNICODE_REGION_SUBTAG_REGEX.test(region);
}
function isUnicodeScriptSubtag(script) {
return ALPHA_4.test(script);
}
function isUnicodeLocaleIdentifierType(code) {
return UNICODE_TYPE_REGEX.test(code);
}
export function CanonicalCodeForDisplayNames(type, code) {
if (type === 'language') {
return CanonicalizeLocaleList([code])[0];
}
if (type === 'region') {
if (!isUnicodeRegionSubtag(code)) {
throw RangeError('invalid region');
}
return code.toUpperCase();
}
if (type === 'script') {
if (!isUnicodeScriptSubtag(code)) {
throw RangeError('invalid script');
}
return "".concat(code[0].toUpperCase()).concat(code.slice(1).toLowerCase());
}
if (type === 'calendar') {
if (!isUnicodeLocaleIdentifierType(code)) {
throw RangeError('invalid calendar');
}
return code.toLowerCase();
}
if (type === 'dateTimeField') {
if (!IsValidDateTimeFieldCode(code)) {
throw RangeError('invalid dateTimeField');
}
return code;
}
invariant(type === 'currency', 'invalid type');
if (!IsWellFormedCurrencyCode(code)) {
throw RangeError('invalid currency');
}
return code.toUpperCase();
}

View File

@@ -0,0 +1 @@
export declare function IsValidDateTimeFieldCode(field: string): boolean;

View File

@@ -0,0 +1,17 @@
var CODES_FOR_DATE_TIME_FIELD = [
'era',
'year',
'quarter',
'month',
'weekOfYear',
'weekday',
'day',
'dayPeriod',
'hour',
'minute',
'second',
'timeZoneName',
];
export function IsValidDateTimeFieldCode(field) {
return CODES_FOR_DATE_TIME_FIELD.indexOf(field) >= 0;
}

View File

@@ -0,0 +1,27 @@
import { DisplayNamesData, DisplayNamesLocaleData } from '@formatjs/ecma402-abstract';
export interface DisplayNamesOptions {
localeMatcher?: 'lookup' | 'best fit';
style?: 'narrow' | 'short' | 'long';
type: 'language' | 'region' | 'script' | 'currency' | 'calendar' | 'dateTimeField';
fallback?: 'code' | 'none';
languageDisplay?: 'dialect' | 'standard';
}
export interface DisplayNamesResolvedOptions {
locale: string;
style: NonNullable<DisplayNamesOptions['style']>;
type: NonNullable<DisplayNamesOptions['type']>;
fallback: NonNullable<DisplayNamesOptions['fallback']>;
languageDisplay: NonNullable<DisplayNamesOptions['languageDisplay']>;
}
export declare class DisplayNames {
constructor(locales: string | string[] | undefined, options: DisplayNamesOptions);
static supportedLocalesOf(locales?: string | string[], options?: Pick<DisplayNamesOptions, 'localeMatcher'>): string[];
static __addLocaleData(...data: DisplayNamesLocaleData[]): void;
of(code: string | number | Record<string, unknown>): string | undefined;
resolvedOptions(): DisplayNamesResolvedOptions;
static localeData: Record<string, DisplayNamesData | undefined>;
private static availableLocales;
private static __defaultLocale;
private static getDefaultLocale;
static readonly polyfilled = true;
}

View File

@@ -0,0 +1,210 @@
import { __assign } from "tslib";
import { CanonicalizeLocaleList, GetOption, GetOptionsObject, IsWellFormedCurrencyCode, SupportedLocales, ToString, getInternalSlot, getMultiInternalSlots, invariant, setInternalSlot, } from '@formatjs/ecma402-abstract';
import { CanonicalCodeForDisplayNames } from './abstract/CanonicalCodeForDisplayNames';
import { IsValidDateTimeFieldCode } from './abstract/IsValidDateTimeFieldCode';
import { ResolveLocale } from '@formatjs/intl-localematcher';
var DisplayNames = /** @class */ (function () {
function DisplayNames(locales, options) {
var _newTarget = this.constructor;
if (_newTarget === undefined) {
throw TypeError("Constructor Intl.DisplayNames requires 'new'");
}
var requestedLocales = CanonicalizeLocaleList(locales);
options = GetOptionsObject(options);
var opt = Object.create(null);
var localeData = DisplayNames.localeData;
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
opt.localeMatcher = matcher;
var r = ResolveLocale(Array.from(DisplayNames.availableLocales), requestedLocales, opt, [], // there is no relevantExtensionKeys
DisplayNames.localeData, DisplayNames.getDefaultLocale);
var style = GetOption(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
setSlot(this, 'style', style);
var type = GetOption(options, 'type', 'string', ['language', 'region', 'script', 'currency', 'calendar', 'dateTimeField'], undefined);
if (type === undefined) {
throw TypeError("Intl.DisplayNames constructor requires \"type\" option");
}
setSlot(this, 'type', type);
var fallback = GetOption(options, 'fallback', 'string', ['code', 'none'], 'code');
setSlot(this, 'fallback', fallback);
setSlot(this, 'locale', r.locale);
var dataLocale = r.dataLocale;
var dataLocaleData = localeData[dataLocale];
invariant(!!dataLocaleData, "Missing locale data for ".concat(dataLocale));
setSlot(this, 'localeData', dataLocaleData);
invariant(dataLocaleData !== undefined, "locale data for ".concat(r.locale, " does not exist."));
var types = dataLocaleData.types;
invariant(typeof types === 'object' && types != null, 'invalid types data');
var typeFields = types[type];
invariant(typeof typeFields === 'object' && typeFields != null, 'invalid typeFields data');
var languageDisplay = GetOption(options, 'languageDisplay', 'string', ['dialect', 'standard'], 'dialect');
if (type === 'language') {
setSlot(this, 'languageDisplay', languageDisplay);
// Using types[type] instead of typeFields because TypeScript cannot infer the correct type
var typeFields_1 = types[type][languageDisplay];
invariant(typeof typeFields_1 === 'object' && typeFields_1 != null, 'invalid language typeFields data');
}
// Using types[type] instead of typeFields because TypeScript cannot infer the correct type
var styleFields = type === 'language'
? types[type][languageDisplay][style]
: types[type][style];
invariant(typeof styleFields === 'object' && styleFields != null, 'invalid styleFields data');
setSlot(this, 'fields', styleFields);
}
DisplayNames.supportedLocalesOf = function (locales, options) {
return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
};
DisplayNames.__addLocaleData = function () {
var data = [];
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
var _b = data_1[_a], d = _b.data, locale = _b.locale;
var minimizedLocale = new Intl.Locale(locale)
.minimize()
.toString();
DisplayNames.localeData[locale] = DisplayNames.localeData[minimizedLocale] = d;
DisplayNames.availableLocales.add(minimizedLocale);
DisplayNames.availableLocales.add(locale);
if (!DisplayNames.__defaultLocale) {
DisplayNames.__defaultLocale = minimizedLocale;
}
}
};
DisplayNames.prototype.of = function (code) {
checkReceiver(this, 'of');
var type = getSlot(this, 'type');
var codeAsString = ToString(code);
if (!isValidCodeForDisplayNames(type, codeAsString)) {
throw RangeError('invalid code for Intl.DisplayNames.prototype.of');
}
var _a = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), localeData = _a.localeData, style = _a.style, fallback = _a.fallback;
// Canonicalize the case.
var canonicalCode = CanonicalCodeForDisplayNames(type, codeAsString);
var name;
if (type === 'language') {
var languageDisplay = getSlot(this, 'languageDisplay');
name = getNameForTypeLanguage(languageDisplay, localeData, style, canonicalCode, fallback);
}
else {
// All the other types
var typesData = localeData.types[type];
name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
}
if (name !== undefined) {
return name;
}
if (fallback === 'code') {
return codeAsString;
}
};
DisplayNames.prototype.resolvedOptions = function () {
checkReceiver(this, 'resolvedOptions');
return __assign({}, getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'locale', 'style', 'type', 'fallback', 'languageDisplay'));
};
DisplayNames.getDefaultLocale = function () {
return DisplayNames.__defaultLocale;
};
DisplayNames.localeData = {};
DisplayNames.availableLocales = new Set();
DisplayNames.__defaultLocale = '';
DisplayNames.polyfilled = true;
return DisplayNames;
}());
export { DisplayNames };
// https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames
function isValidCodeForDisplayNames(type, code) {
switch (type) {
case 'language':
// subset of unicode_language_id
// languageCode ["-" scriptCode] ["-" regionCode] *("-" variant)
// where:
// - languageCode is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.
// - scriptCode is should be an ISO-15924 four letters script code
// - regionCode is either an ISO-3166 two letters region code, or a three digits UN M49 Geographic Regions.
return /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*$/i.test(code);
case 'region':
// unicode_region_subtag
return /^([a-z]{2}|\d{3})$/i.test(code);
case 'script':
// unicode_script_subtag
return /^[a-z]{4}$/i.test(code);
case 'currency':
return IsWellFormedCurrencyCode(code);
case 'calendar':
// unicode locale identifier type
return /^[a-z0-9]{3,8}([-_][a-z0-9]{3,8})*$/i.test(code);
case 'dateTimeField':
return IsValidDateTimeFieldCode(code);
}
}
try {
// IE11 does not have Symbol
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {
value: 'Intl.DisplayNames',
configurable: true,
enumerable: false,
writable: false,
});
}
Object.defineProperty(DisplayNames, 'length', {
value: 2,
writable: false,
enumerable: false,
configurable: true,
});
}
catch (e) {
// Make test 262 compliant
}
var __INTERNAL_SLOT_MAP__ = new WeakMap();
function getSlot(instance, key) {
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
}
function setSlot(instance, key, value) {
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
}
function checkReceiver(receiver, methodName) {
if (!(receiver instanceof DisplayNames)) {
throw TypeError("Method Intl.DisplayNames.prototype.".concat(methodName, " called on incompatible receiver"));
}
}
function getNameForTypeLanguage(languageDisplay, localeData, style, canonicalCode, fallback) {
// First, try to get the name using the canonicalCode
var typesData = localeData.types.language[languageDisplay];
var name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
if (name === undefined) {
// If no name has been found using the canonicalCode,
// check if the latter contains a region sub tag
var regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);
if (regionMatch) {
// Extract the language and region sub tags
var languageSubTag = canonicalCode.substring(0, regionMatch.index) +
canonicalCode.substring(regionMatch.index + regionMatch[0].length);
var regionSubTag = regionMatch[1];
// Let's try again using languageSubTag this time
var name_1 = typesData[style][languageSubTag] || typesData.long[languageSubTag];
// If a name has been found and a region sub tag exists,
// compose them together or use the code fallback
if (name_1 !== undefined && regionSubTag) {
// Retrieve region display names
var regionsData = localeData.types.region;
var regionDisplayName = regionsData[style][regionSubTag] || regionsData.long[regionSubTag];
if (regionDisplayName || fallback === 'code') {
// Interpolate into locale-specific pattern.
var pattern = localeData.patterns.locale;
return pattern
.replace('{0}', name_1)
.replace('{1}', regionDisplayName || regionSubTag);
}
}
else {
return name_1;
}
}
}
else {
return name;
}
}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,7 @@
import { DisplayNames } from './';
Object.defineProperty(Intl, 'DisplayNames', {
value: DisplayNames,
enumerable: false,
writable: true,
configurable: true,
});

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,10 @@
import { DisplayNames } from './';
import { shouldPolyfill } from './should-polyfill';
if (shouldPolyfill()) {
Object.defineProperty(Intl, 'DisplayNames', {
value: DisplayNames,
enumerable: false,
writable: true,
configurable: true,
});
}

View File

@@ -0,0 +1,2 @@
export declare function _shouldPolyfillWithoutLocale(): boolean;
export declare function shouldPolyfill(locale?: string): string | true | undefined;

View File

@@ -0,0 +1,48 @@
import { match } from '@formatjs/intl-localematcher';
import { supportedLocales } from './supported-locales.generated';
/**
* https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
*/
function hasMissingICUBug() {
var DisplayNames = Intl.DisplayNames;
if (DisplayNames && !DisplayNames.polyfilled) {
return (new DisplayNames(['en'], {
type: 'region',
}).of('CA') === 'CA');
}
return false;
}
/**
* https://bugs.chromium.org/p/chromium/issues/detail?id=1176979
*/
function hasScriptBug() {
var DisplayNames = Intl.DisplayNames;
if (DisplayNames && !DisplayNames.polyfilled) {
return (new DisplayNames(['en'], {
type: 'script',
}).of('arab') !== 'Arabic');
}
return false;
}
function supportedLocalesOf(locale) {
if (!locale) {
return true;
}
var locales = Array.isArray(locale) ? locale : [locale];
return (Intl.DisplayNames.supportedLocalesOf(locales).length ===
locales.length);
}
export function _shouldPolyfillWithoutLocale() {
return !Intl.DisplayNames || hasMissingICUBug() || hasScriptBug();
}
export function shouldPolyfill(locale) {
if (locale === void 0) { locale = 'en'; }
try {
if (_shouldPolyfillWithoutLocale() || !supportedLocalesOf(locale)) {
return match([locale], supportedLocales, 'en');
}
}
catch (e) {
return true;
}
}

View File

@@ -0,0 +1 @@
export declare const supportedLocales: string[];

View File

@@ -0,0 +1 @@
export var supportedLocales = ["af", "af-NA", "agq", "ak", "am", "ar", "ar-AE", "ar-BH", "ar-DJ", "ar-DZ", "ar-EG", "ar-EH", "ar-ER", "ar-IL", "ar-IQ", "ar-JO", "ar-KM", "ar-KW", "ar-LB", "ar-LY", "ar-MA", "ar-MR", "ar-OM", "ar-PS", "ar-QA", "ar-SA", "ar-SD", "ar-SO", "ar-SS", "ar-SY", "ar-TD", "ar-TN", "ar-YE", "as", "asa", "ast", "az", "az-Cyrl", "az-Latn", "bas", "be", "be-tarask", "bem", "bez", "bg", "bm", "bn", "bn-IN", "bo", "bo-IN", "br", "brx", "bs", "bs-Cyrl", "bs-Latn", "ca", "ca-AD", "ca-ES-valencia", "ca-FR", "ca-IT", "ccp", "ccp-IN", "ce", "ceb", "cgg", "chr", "ckb", "ckb-IR", "cs", "cy", "da", "da-GL", "dav", "de", "de-AT", "de-BE", "de-CH", "de-IT", "de-LI", "de-LU", "dje", "doi", "dsb", "dua", "dyo", "dz", "ebu", "ee", "ee-TG", "el", "el-CY", "en", "en-001", "en-150", "en-AE", "en-AG", "en-AI", "en-AS", "en-AT", "en-AU", "en-BB", "en-BE", "en-BI", "en-BM", "en-BS", "en-BW", "en-BZ", "en-CA", "en-CC", "en-CH", "en-CK", "en-CM", "en-CX", "en-CY", "en-DE", "en-DG", "en-DK", "en-DM", "en-ER", "en-FI", "en-FJ", "en-FK", "en-FM", "en-GB", "en-GD", "en-GG", "en-GH", "en-GI", "en-GM", "en-GU", "en-GY", "en-HK", "en-IE", "en-IL", "en-IM", "en-IN", "en-IO", "en-JE", "en-JM", "en-KE", "en-KI", "en-KN", "en-KY", "en-LC", "en-LR", "en-LS", "en-MG", "en-MH", "en-MO", "en-MP", "en-MS", "en-MT", "en-MU", "en-MW", "en-MY", "en-NA", "en-NF", "en-NG", "en-NL", "en-NR", "en-NU", "en-NZ", "en-PG", "en-PH", "en-PK", "en-PN", "en-PR", "en-PW", "en-RW", "en-SB", "en-SC", "en-SD", "en-SE", "en-SG", "en-SH", "en-SI", "en-SL", "en-SS", "en-SX", "en-SZ", "en-TC", "en-TK", "en-TO", "en-TT", "en-TV", "en-TZ", "en-UG", "en-UM", "en-VC", "en-VG", "en-VI", "en-VU", "en-WS", "en-ZA", "en-ZM", "en-ZW", "eo", "es", "es-419", "es-AR", "es-BO", "es-BR", "es-BZ", "es-CL", "es-CO", "es-CR", "es-CU", "es-DO", "es-EA", "es-EC", "es-GQ", "es-GT", "es-HN", "es-IC", "es-MX", "es-NI", "es-PA", "es-PE", "es-PH", "es-PR", "es-PY", "es-SV", "es-US", "es-UY", "es-VE", "et", "eu", "ewo", "fa", "fa-AF", "ff", "ff-Adlm", "ff-Adlm-BF", "ff-Adlm-CM", "ff-Adlm-GH", "ff-Adlm-GM", "ff-Adlm-GW", "ff-Adlm-LR", "ff-Adlm-MR", "ff-Adlm-NE", "ff-Adlm-NG", "ff-Adlm-SL", "ff-Adlm-SN", "ff-Latn", "ff-Latn-BF", "ff-Latn-CM", "ff-Latn-GH", "ff-Latn-GM", "ff-Latn-GN", "ff-Latn-GW", "ff-Latn-LR", "ff-Latn-MR", "ff-Latn-NE", "ff-Latn-NG", "ff-Latn-SL", "fi", "fil", "fo", "fo-DK", "fr", "fr-BE", "fr-BF", "fr-BI", "fr-BJ", "fr-BL", "fr-CA", "fr-CD", "fr-CF", "fr-CG", "fr-CH", "fr-CI", "fr-CM", "fr-DJ", "fr-DZ", "fr-GA", "fr-GF", "fr-GN", "fr-GP", "fr-GQ", "fr-HT", "fr-KM", "fr-LU", "fr-MA", "fr-MC", "fr-MF", "fr-MG", "fr-ML", "fr-MQ", "fr-MR", "fr-MU", "fr-NC", "fr-NE", "fr-PF", "fr-PM", "fr-RE", "fr-RW", "fr-SC", "fr-SN", "fr-SY", "fr-TD", "fr-TG", "fr-TN", "fr-VU", "fr-WF", "fr-YT", "fur", "fy", "ga", "ga-GB", "gd", "gl", "gsw", "gsw-FR", "gsw-LI", "gu", "guz", "gv", "ha", "ha-GH", "ha-NE", "haw", "he", "hi", "hr", "hr-BA", "hsb", "hu", "hy", "ia", "id", "ig", "ii", "is", "it", "it-CH", "it-SM", "it-VA", "ja", "jgo", "jmc", "jv", "ka", "kab", "kam", "kde", "kea", "kgp", "khq", "ki", "kk", "kkj", "kl", "kln", "km", "kn", "ko", "ko-KP", "kok", "ks", "ks-Arab", "ksb", "ksf", "ksh", "ku", "kw", "ky", "lag", "lb", "lg", "lkt", "ln", "ln-AO", "ln-CF", "ln-CG", "lo", "lrc", "lrc-IQ", "lt", "lu", "luo", "luy", "lv", "mai", "mas", "mas-TZ", "mer", "mfe", "mg", "mgh", "mgo", "mi", "mk", "ml", "mn", "mni", "mni-Beng", "mr", "ms", "ms-BN", "ms-ID", "ms-SG", "mt", "mua", "my", "mzn", "naq", "nb", "nb-SJ", "nd", "nds", "nds-NL", "ne", "ne-IN", "nl", "nl-AW", "nl-BE", "nl-BQ", "nl-CW", "nl-SR", "nl-SX", "nmg", "nn", "nnh", "no", "nus", "nyn", "om", "om-KE", "or", "os", "os-RU", "pa", "pa-Arab", "pa-Guru", "pcm", "pl", "ps", "ps-PK", "pt", "pt-AO", "pt-CH", "pt-CV", "pt-GQ", "pt-GW", "pt-LU", "pt-MO", "pt-MZ", "pt-PT", "pt-ST", "pt-TL", "qu", "qu-BO", "qu-EC", "rm", "rn", "ro", "ro-MD", "rof", "ru", "ru-BY", "ru-KG", "ru-KZ", "ru-MD", "ru-UA", "rw", "rwk", "sa", "sah", "saq", "sat", "sat-Olck", "sbp", "sc", "sd", "sd-Arab", "sd-Deva", "se", "se-FI", "se-SE", "seh", "ses", "sg", "shi", "shi-Latn", "shi-Tfng", "si", "sk", "sl", "smn", "sn", "so", "so-DJ", "so-ET", "so-KE", "sq", "sq-MK", "sq-XK", "sr", "sr-Cyrl", "sr-Cyrl-BA", "sr-Cyrl-ME", "sr-Cyrl-XK", "sr-Latn", "sr-Latn-BA", "sr-Latn-ME", "sr-Latn-XK", "su", "su-Latn", "sv", "sv-AX", "sv-FI", "sw", "sw-CD", "sw-KE", "sw-UG", "ta", "ta-LK", "ta-MY", "ta-SG", "te", "teo", "teo-KE", "tg", "th", "ti", "ti-ER", "tk", "to", "tr", "tr-CY", "tt", "twq", "tzm", "ug", "uk", "und", "ur", "ur-IN", "uz", "uz-Arab", "uz-Cyrl", "uz-Latn", "vai", "vai-Latn", "vai-Vaii", "vi", "vun", "wae", "wo", "xh", "xog", "yav", "yi", "yo", "yo-BJ", "yrl", "yrl-CO", "yrl-VE", "yue", "yue-Hans", "yue-Hant", "zgh", "zh", "zh-Hans", "zh-Hans-HK", "zh-Hans-MO", "zh-Hans-SG", "zh-Hant", "zh-Hant-HK", "zh-Hant-MO", "zu"];